Commit de4c3524 authored by pugmire's avatar pugmire

Fix a few bugs.


git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@11768 18c085ea-50e0-402c-830e-de6fd14e8384
parent acfd976e
......@@ -985,6 +985,9 @@ avtStreamlineFilter::GenerateSeedPointsFromLine(std::vector<avtVector> &pts)
// Dave Pugmire, Thu Jun 10 10:44:02 EDT 2010
// New seed sources.
//
// Dave Pugmire, Wed Jun 23 16:44:36 EDT 2010
// Fix the centering.
//
// ****************************************************************************
void
......@@ -996,15 +999,14 @@ avtStreamlineFilter::GenerateSeedPointsFromPlane(std::vector<avtVector> &pts)
avtVector X0(1,0,0), Y0(0,1,0), Z0(0,0,1), C0(0,0,0);
avtVector Y1=vectors[1], Z1=vectors[0], C1=points[0];
// Move the sample center to the origin.
C1.x -= (sampleDistance[0]/2.0);
C1.y -= (sampleDistance[1]/2.0);
avtVector X1 = Y1.cross(Z1);
avtMatrix m = avtMatrix::CreateFrameToFrameConversion(X1, Y1, Z1, C1,
X0, Y0, Z0, C0);
float x0 = 0.0, y0 = 0.0;
float x1 = sampleDistance[0], y1 = sampleDistance[1];
float x0 = -(sampleDistance[0]/2.0);
float y0 = -(sampleDistance[0]/2.0);
float x1 = (sampleDistance[0]/2.0);
float y1 = (sampleDistance[0]/2.0);
if (randomSamples)
{
......@@ -1062,6 +1064,7 @@ avtStreamlineFilter::GenerateSeedPointsFromPlane(std::vector<avtVector> &pts)
avtVector p(x0+((float)x*dX),
y0+((float)y*dY),
0.0);
p = m*p;
pts.push_back(p);
}
......@@ -1083,6 +1086,9 @@ avtStreamlineFilter::GenerateSeedPointsFromPlane(std::vector<avtVector> &pts)
// Dave Pugmire, Thu Jun 10 10:44:02 EDT 2010
// New seed sources.
//
// Dave Pugmire, Wed Jun 23 16:44:36 EDT 2010
// Add circle center for interior sampling.
//
// ****************************************************************************
void
......@@ -1146,6 +1152,7 @@ avtStreamlineFilter::GenerateSeedPointsFromCircle(std::vector<avtVector> &pts)
r += dR;
}
theta += dTheta;
pts.push_back(points[0]);
}
}
else
......@@ -1175,6 +1182,9 @@ avtStreamlineFilter::GenerateSeedPointsFromCircle(std::vector<avtVector> &pts)
// Dave Pugmire, Thu Jun 10 10:44:02 EDT 2010
// New seed sources.
//
// Dave Pugmire, Wed Jun 23 16:44:36 EDT 2010
// Bug fix for random sampling on a sphere. Implment uniform interior sampling.
//
// ****************************************************************************
void
......@@ -1204,33 +1214,52 @@ avtStreamlineFilter::GenerateSeedPointsFromSphere(std::vector<avtVector> &pts)
for (int i = 0; i < numSamplePoints; i++)
{
float theta = random01()*TWO_PI;
float u = random_11()*R;
float x = sqrt(R-(u*u));
float u = random_11();
float x = sqrt(1.0-(u*u));
avtVector p(cos(theta)*x, sin(theta)*x, u);
p.normalize();
p *= R;
pts.push_back(p+points[0]);
}
}
}
else
{
vtkSphereSource* sphere = vtkSphereSource::New();
sphere->SetCenter(points[0].x, points[0].y, points[0].z);
sphere->SetRadius(R);
sphere->SetLatLongTessellation(1);
double t = double(30 - sampleDensity[0]) / 29.;
double angle = t * 3. + (1. - t) * 30.;
sphere->SetPhiResolution(int(angle));
t = double(30 - sampleDensity[1]) / 29.;
angle = t * 3. + (1. - t) * 30.;
sphere->SetThetaResolution(int(angle));
if (fill)
{
cout<<"TODO"<<endl;
float dR = R/(float)sampleDensity[2];
float r = dR;
for (int i = 0; i < sampleDensity[2]; i++)
{
sphere->SetRadius(r);
sphere->Update();
for (int j = 0; j < sphere->GetOutput()->GetNumberOfPoints(); j++)
{
double *pt = sphere->GetOutput()->GetPoint(j);
avtVector p(pt[0], pt[1], pt[2]);
pts.push_back(p);
}
r = r+dR;
}
//Add center, R=0 sample.
pts.push_back(points[0]);
}
else //LAT-LONG
{
vtkSphereSource* sphere = vtkSphereSource::New();
sphere->SetCenter(points[0].x, points[0].y, points[0].z);
sphere->SetRadius(R);
sphere->SetLatLongTessellation(1);
double t = double(30 - sampleDensity[0]) / 29.;
double angle = t * 3. + (1. - t) * 30.;
sphere->SetPhiResolution(int(angle));
t = double(30 - sampleDensity[1]) / 29.;
angle = t * 3. + (1. - t) * 30.;
sphere->SetThetaResolution(int(angle));
sphere->Update();
for (int i = 0; i < sphere->GetOutput()->GetNumberOfPoints(); i++)
{
......@@ -1238,8 +1267,9 @@ avtStreamlineFilter::GenerateSeedPointsFromSphere(std::vector<avtVector> &pts)
avtVector p(pt[0], pt[1], pt[2]);
pts.push_back(p);
}
sphere->Delete();
}
sphere->Delete();
}
}
......
......@@ -52,6 +52,8 @@
#include <QPushButton>
#include <QTabWidget>
#include <QToolTip>
#include <QButtonGroup>
#include <QRadioButton>
#include <QvisColorTableButton.h>
#include <QvisColorButton.h>
#include <QvisLineWidthWidget.h>
......@@ -374,11 +376,19 @@ QvisStreamlinePlotWindow::CreateWindowContents()
gRow++;
int sRow = 0;
fillInterior = new QCheckBox(tr("Fill Interior"), samplingGroup);
connect(fillInterior, SIGNAL(toggled(bool)),this, SLOT(fillInteriorChanged(bool)));
samplingLayout->addWidget(fillInterior, sRow, 0);
fillLabel = new QLabel(tr("Sampling along:"), samplingGroup);
samplingLayout->addWidget(fillLabel, sRow, 0);
fillButtonGroup = new QButtonGroup(samplingGroup);
fillButtons[0] = new QRadioButton(tr("Exterior"), samplingGroup);
fillButtons[1] = new QRadioButton(tr("Interior"), samplingGroup);
fillButtons[0]->setChecked(true);
fillButtonGroup->addButton(fillButtons[0], 0);
fillButtonGroup->addButton(fillButtons[1], 1);
samplingLayout->addWidget(fillButtons[0], sRow, 1);
samplingLayout->addWidget(fillButtons[1], sRow, 2);
connect(fillButtonGroup, SIGNAL(buttonClicked(int)), this, SLOT(fillChanged(int)));
sRow++;
randomSamples = new QCheckBox(tr("Random"), samplingGroup);
connect(randomSamples, SIGNAL(toggled(bool)),this, SLOT(randomSamplesChanged(bool)));
samplingLayout->addWidget(randomSamples, sRow, 0);
......@@ -1573,10 +1583,10 @@ QvisStreamlinePlotWindow::UpdateWindow(bool doAll)
break;
case StreamlineAttributes::ID_fillInterior:
fillInterior->blockSignals(true);
fillInterior->setChecked(streamAtts->GetFillInterior());
fillButtonGroup->blockSignals(true);
fillButtonGroup->button(streamAtts->GetFillInterior()?1:0)->setChecked(true);
UpdateSourceAttributes();
fillInterior->blockSignals(false);
fillButtonGroup->blockSignals(false);
break;
case StreamlineAttributes::ID_randomSeed:
......@@ -1622,7 +1632,9 @@ QvisStreamlinePlotWindow::TurnOffSourceAttributes()
TurnOff(randomSamples);
TurnOff(numberOfRandomSamples, numberOfRandomSamplesLabel);
TurnOff(randomSeed, randomSeedLabel);
TurnOff(fillInterior);
TurnOff(fillLabel);
TurnOff(fillButtons[0]);
TurnOff(fillButtons[1]);
for (int i = 0; i < 3; i++)
{
TurnOff(sampleDensity[i], sampleDensityLabel[i]);
......@@ -1800,7 +1812,9 @@ QvisStreamlinePlotWindow::UpdateSourceAttributes()
if (enableFill)
{
TurnOn(fillInterior);
TurnOn(fillLabel);
TurnOn(fillButtons[0]);
TurnOn(fillButtons[1]);
}
if (showSampling)
TurnOn(samplingGroup);
......@@ -2980,9 +2994,9 @@ QvisStreamlinePlotWindow::randomSamplesChanged(bool val)
}
void
QvisStreamlinePlotWindow::fillInteriorChanged(bool val)
QvisStreamlinePlotWindow::fillChanged(int index)
{
streamAtts->SetFillInterior(val);
streamAtts->SetFillInterior(index == 1);
Apply();
}
......
......@@ -56,6 +56,8 @@ class QvisLineWidthWidget;
class QvisVariableButton;
class QvisOpacitySlider;
class QPushButton;
class QButtonGroup;
class QRadioButton;
class StreamlineAttributes;
// ****************************************************************************
......@@ -122,6 +124,9 @@ class StreamlineAttributes;
// Dave Pugmire, Thu Jun 10 10:44:02 EDT 2010
// New seed sources.
//
// Dave Pugmire, Wed Jun 23 16:44:36 EDT 2010
// Repace fill interior checkbox with radio button.
//
// ****************************************************************************
class QvisStreamlinePlotWindow : public QvisPostableWindowObserver
......@@ -181,7 +186,7 @@ class QvisStreamlinePlotWindow : public QvisPostableWindowObserver
void randomSamplesChanged(bool);
void randomSeedChanged(int);
void numberOfRandomSamplesChanged(int);
void fillInteriorChanged(bool);
void fillChanged(int);
void maxSLCountChanged(int val);
void maxDomainCacheChanged(int val);
void workGroupSizeChanged(int val);
......@@ -271,7 +276,9 @@ class QvisStreamlinePlotWindow : public QvisPostableWindowObserver
QLabel *numberOfRandomSamplesLabel;
QSpinBox *randomSeed;
QLabel *randomSeedLabel;
QCheckBox *fillInterior;
QLabel *fillLabel;
QButtonGroup *fillButtonGroup;
QRadioButton *fillButtons[2];
QComboBox *displayMethod;
......
......@@ -55,13 +55,14 @@ StreamlineAttributes::CopyAttributes(const AttributeGroup *atts)
}
else if(atts->TypeName() == "PlaneAttributes")
{
if(sourceType == SpecifiedPlane)
if(sourceType == SpecifiedPlane || sourceType == SpecifiedCircle)
{
const PlaneAttributes *plane = (const PlaneAttributes *)atts;
SetPlaneOrigin(plane->GetOrigin());
SetPlaneNormal(plane->GetNormal());
SetPlaneUpAxis(plane->GetUpAxis());
SetRadius(plane->GetRadius());
if (sourceType == SpecifiedCircle)
SetRadius(plane->GetRadius());
retval = true;
}
}
......@@ -75,18 +76,6 @@ StreamlineAttributes::CopyAttributes(const AttributeGroup *atts)
retval = true;
}
}
else if(atts->TypeName() == "CircleAttributes")
{
if(sourceType == SpecifiedCircle)
{
const PlaneAttributes *plane = (const PlaneAttributes *)atts;
SetPlaneOrigin(plane->GetOrigin());
SetPlaneNormal(plane->GetNormal());
SetPlaneUpAxis(plane->GetUpAxis());
SetRadius(plane->GetRadius());
retval = true;
}
}
else if(atts->TypeName() == "BoxExtents")
{
if(sourceType == SpecifiedBox)
......
......@@ -1009,13 +1009,14 @@ StreamlineAttributes::CopyAttributes(const AttributeGroup *atts)
}
else if(atts->TypeName() == "PlaneAttributes")
{
if(sourceType == SpecifiedPlane)
if(sourceType == SpecifiedPlane || sourceType == SpecifiedCircle)
{
const PlaneAttributes *plane = (const PlaneAttributes *)atts;
SetPlaneOrigin(plane->GetOrigin());
SetPlaneNormal(plane->GetNormal());
SetPlaneUpAxis(plane->GetUpAxis());
SetRadius(plane->GetRadius());
if (sourceType == SpecifiedCircle)
SetRadius(plane->GetRadius());
retval = true;
}
}
......@@ -1029,18 +1030,6 @@ StreamlineAttributes::CopyAttributes(const AttributeGroup *atts)
retval = true;
}
}
else if(atts->TypeName() == "CircleAttributes")
{
if(sourceType == SpecifiedCircle)
{
const PlaneAttributes *plane = (const PlaneAttributes *)atts;
SetPlaneOrigin(plane->GetOrigin());
SetPlaneNormal(plane->GetNormal());
SetPlaneUpAxis(plane->GetUpAxis());
SetRadius(plane->GetRadius());
retval = true;
}
}
else if(atts->TypeName() == "BoxExtents")
{
if(sourceType == SpecifiedBox)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment