Commit c4bc7210 authored by hrchilds's avatar hrchilds

Commit fix from Jean Favre for persistent particles.


git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@20903 18c085ea-50e0-402c-830e-de6fd14e8384
parent 03fa7608
......@@ -100,6 +100,9 @@ vtkConnectedTubeFilter::PointSequence::~PointSequence()
// Hank Childs (for Jeremy Meredith), Mon Apr 7 11:46:51 PDT 2003
// Increased size of cellindex.
//
//
// Jean Favre, Tue May 7 16:38:37 CEST 2013
// Used vtkIdType where needed
// ****************************************************************************
void
vtkConnectedTubeFilter::PointSequence::Init(int maxlen)
......@@ -110,8 +113,8 @@ vtkConnectedTubeFilter::PointSequence::Init(int maxlen)
delete[] cellindex;
length = 0;
index = new int[maxlen];
cellindex = new int[maxlen];
index = new vtkIdType[maxlen];
cellindex = new vtkIdType[maxlen];
}
// ****************************************************************************
......@@ -123,9 +126,11 @@ vtkConnectedTubeFilter::PointSequence::Init(int maxlen)
// Programmer: Jeremy Meredith
// Creation: November 1, 2002
//
// Jean Favre, Tue May 7 16:38:37 CEST 2013
// Used vtkIdType where needed
// ****************************************************************************
void
vtkConnectedTubeFilter::PointSequence::Add(int i, int ci)
vtkConnectedTubeFilter::PointSequence::Add(vtkIdType i, vtkIdType ci)
{
index[length] = i;
cellindex[length] = ci;
......@@ -194,6 +199,8 @@ vtkConnectedTubeFilter::PointSequenceList::~PointSequenceList()
// Programmer: Jeremy Meredith
// Creation: November 1, 2002
//
// Jean Favre, Tue May 7 16:38:37 CEST 2013
// Used vtkIdType where needed
// ****************************************************************************
bool
vtkConnectedTubeFilter::PointSequenceList::Build(vtkPoints *points,
......@@ -201,10 +208,10 @@ vtkConnectedTubeFilter::PointSequenceList::Build(vtkPoints *points,
{
pts = points;
len = points->GetNumberOfPoints();
numneighbors = new int[len];
connectivity[0] = new int[len];
connectivity[1] = new int[len];
cellindex = new int[len];
numneighbors = new vtkIdType[len];
connectivity[0] = new vtkIdType[len];
connectivity[1] = new vtkIdType[len];
cellindex = new vtkIdType[len];
vtkIdType *cells = lines->GetPointer();
......@@ -225,8 +232,8 @@ vtkConnectedTubeFilter::PointSequenceList::Build(vtkPoints *points,
}
// Get the begin and end index for this segment
int a = cells[i*3 + 1];
int b = cells[i*3 + 2];
vtkIdType a = cells[i*3 + 1];
vtkIdType b = cells[i*3 + 2];
// If we have two neighbors already, this is a T intersection
if (numneighbors[a] >= 2 || numneighbors[b] >= 2)
......@@ -294,6 +301,11 @@ vtkConnectedTubeFilter::PointSequenceList::InitTraversal()
// that have 2 neighbors. Previously it would have considered points
// with no neighbors, which caused it to reference uninitialized memory.
//
// Jean Favre, Tue May 7 16:38:37 CEST 2013
// I modified the calls to GetPoint() to use the other variant of the call
// with two arguments. The previous version would never succeed in the test
// to remove sequential identical points.
// Used vtkIdType where needed
// ****************************************************************************
bool
vtkConnectedTubeFilter::PointSequenceList::GetNextSequence(PointSequence &seq)
......@@ -305,24 +317,26 @@ vtkConnectedTubeFilter::PointSequenceList::GetNextSequence(PointSequence &seq)
if (((lookforloops && numneighbors[index] == 2) ||
numneighbors[index] == 1) && !visited[index])
{
int current = index;
int previous = -1;
vtkIdType current = index;
vtkIdType previous = -1;
seq.Init(len);
seq.Add(current, cellindex[current]);
visited[current] = true;
while (true)
{
int n1 = connectivity[0][current];
int n2 = connectivity[1][current];
int next = (n1 == previous) ? n2 : n1;
vtkIdType n1 = connectivity[0][current];
vtkIdType n2 = connectivity[1][current];
vtkIdType next = (n1 == previous) ? n2 : n1;
previous = current;
current = next;
// we must skip any sequential identical points:
// 1) they are useless, and 2) they mess up calculations
double *prePt = pts->GetPoint(previous);
double *curPt = pts->GetPoint(current);
double prePt[3];
double curPt[3];
pts->GetPoint(previous, prePt);
pts->GetPoint(current, curPt);
if (prePt[0] != curPt[0] ||
prePt[1] != curPt[1] ||
prePt[2] != curPt[2])
......@@ -475,6 +489,10 @@ bool vtkConnectedTubeFilter::BuildConnectivityArrays(vtkPolyData *input)
// Eric Brugger, Wed Jan 9 11:31:17 PST 2013
// Modified to inherit from vtkPolyDataAlgorithm.
//
// Jean Favre, Tue May 7 16:38:37 CEST 2013
// I modified the calls to GetPoint() to use the other variant of the call
// with two arguments. The previous version would fail getting the right values.
// Used vtkIdType where needed
// ****************************************************************************
int vtkConnectedTubeFilter::RequestData(
vtkInformation *vtkNotUsed(request),
......@@ -561,24 +579,27 @@ int vtkConnectedTubeFilter::RequestData(
bool lastPoint = (i==seq.length-1);
// Get the current, previous, and next indices
int ix = seq.index[i];
int ix1 = (firstPoint ? seq.index[i] : seq.index[i-1]);
int ix2 = (lastPoint ? seq.index[i] : seq.index[i+1]);
vtkIdType ix = seq.index[i];
vtkIdType ix1 = (firstPoint ? seq.index[i] : seq.index[i-1]);
vtkIdType ix2 = (lastPoint ? seq.index[i] : seq.index[i+1]);
// Use a centered difference approximation for direction
double dir[3];
vtkMath::Subtract(inPts->GetPoint(ix2),inPts->GetPoint(ix1), dir);
double v0[3], v1[3], v2[3], dir[3], pt[3];
inPts->GetPoint(ix2, v2);
inPts->GetPoint(ix1, v1);
vtkMath::Subtract(v2, v1, dir);
// If our centered difference was zero, do a forward
// difference instead. We ensured no sequential points
// are identical, so this can't fail.
if (dir[0]==0 && dir[1]==0 && dir[2]==0)
{
vtkMath::Subtract(inPts->GetPoint(ix2),inPts->GetPoint(ix),dir);
inPts->GetPoint(ix, v0);
vtkMath::Subtract(v2, v0, dir);
}
// Get a couple vectors orthogonal to our direction
double v1[3], v2[3];
//double v1[3], v2[3];
vtkMath::Perpendiculars(dir, v1,v2, 0.0);
vtkMath::Normalize(v1);
vtkMath::Normalize(v2);
......@@ -587,7 +608,8 @@ int vtkConnectedTubeFilter::RequestData(
// to create the cells
vtkIdType firstIndex = newPts->GetNumberOfPoints();
double *pt = inPts->GetPoint(ix);
//double *pt = inPts->GetPoint(ix);
inPts->GetPoint(ix, pt);
for (int j = 0 ; j < NumberOfSides ; j++)
{
double q = (j * 2. * vtkMath::Pi()) / double(NumberOfSides);
......
......@@ -102,17 +102,19 @@ class VISIT_VTK_API vtkConnectedTubeFilter : public vtkPolyDataAlgorithm
// Purpose:
// Encapsulates a single doubly connected point sequence.
//
// Jean Favre, Tue May 7 16:38:37 CEST 2013
// Used vtkIdType where needed
// ************************************************************************
struct PointSequence
{
int length;
int *index;
int *cellindex;
vtkIdType *index;
vtkIdType *cellindex;
public:
PointSequence();
~PointSequence();
void Init(int maxlen);
void Add(int i, int ci);
void Add(vtkIdType i, vtkIdType ci);
};
// ************************************************************************
......@@ -125,20 +127,22 @@ class VISIT_VTK_API vtkConnectedTubeFilter : public vtkPolyDataAlgorithm
// Rich Cook and Hank Childs, Thu Oct 2 16:31:45 PDT 2008
// Added data member to support tubing over loops.
//
// Jean Favre, Tue May 7 16:38:37 CEST 2013
// Used vtkIdType where needed
// ************************************************************************
class PointSequenceList
{
private:
// connectivity data
int len;
int *numneighbors;
int *connectivity[2];
int *cellindex;
vtkIdType *numneighbors;
vtkIdType *connectivity[2];
vtkIdType *cellindex;
vtkPoints *pts;
// traversal variables
bool *visited;
int index;
vtkIdType index;
bool lookforloops;
public:
PointSequenceList();
......
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