Commit 2b64cfa3 authored by David Thompson's avatar David Thompson Committed by Code Review
Browse files

Merge topic '14188_polyhedron_fixes' into master

0627519c Terminate early when possible.
fc0ee6cf Reset point ID list when appending polyhedra.
ee3a7c30 Fix polyhedron-ray intersection...
31d834a4 Don't forget to copy polyhedron cell-data...
2f4a9cad Fix problems processing polyhedron connectivity.
parents d132ee85 0627519c
......@@ -1775,6 +1775,8 @@ int vtkPolyhedron::IntersectWithLine(double p1[3], double p2[3], double tol,
hit = this->Quad->IntersectWithLine(p1,p2,tol,t,x,pc,subId);
break;
default: //general polygon
this->Polygon->GetPoints()->SetNumberOfPoints(npts);
this->Polygon->GetPointIds()->SetNumberOfIds(npts);
for (i=0; i<npts; i++)
{
this->Polygon->Points->SetPoint(i,this->Points->GetPoint(face[i+1]));
......@@ -2838,7 +2840,6 @@ void vtkPolyhedron::Contour(double value,
this->Internal->RestoreFaceArrayAndEdgeTable(this->Faces, this->EdgeTable);
}
//----------------------------------------------------------------------------
void vtkPolyhedron::Clip(double value,
vtkDataArray *pointScalars,
......@@ -2946,6 +2947,10 @@ void vtkPolyhedron::Clip(double value,
}
// polyhedron is all inside
// FIXME: Documentation needed:
// 1. How this can ever happen given the IntersectWithContour call above?
// 2. If it can happen, how+why is it different than the code above that
// copies the cell to the output?
if (ret == 1)
{
cellVector.push_back(this->Faces->GetValue(0));
......
......@@ -1165,6 +1165,7 @@ void vtkUnstructuredGrid::SetCells(vtkUnsignedCharArray *cellTypes,
if (cellTypes->GetValue(i) == VTK_POLYHEDRON)
{
containPolyhedron = true;
break; // We can terminate early
}
}
......@@ -1326,13 +1327,13 @@ void vtkUnstructuredGrid::GetFaceStream(vtkIdType cellId, vtkIdList *ptIds)
return;
}
ptIds->Reset();
if (!this->Faces || !this->FaceLocations)
{
return;
}
ptIds->Reset();
vtkIdType loc = this->FaceLocations->GetValue(cellId);
vtkIdType* facePtr = this->Faces->GetPointer(loc);
......
......@@ -305,14 +305,16 @@ int vtkAppendFilter::RequestData(
ug->GetFaceStream(cellId,nfaces,facePtIds);
for(vtkIdType id=0; id < nfaces; ++id)
{
vtkIdType nPoints = *facePtIds;
vtkIdType nPoints = *facePtIds++;
newPtIds->InsertNextId(nPoints);
for (vtkIdType j=0; j <= nPoints; ++j)
for (vtkIdType j=0; j < nPoints; ++j)
{
newPtIds->InsertNextId(*(++facePtIds)+ptOffset);
newPtIds->InsertNextId(*(facePtIds++)+ptOffset);
}
}
output->InsertNextCell(VTK_POLYHEDRON,nfaces,newPtIds->GetPointer(0));
newCellId = output->InsertNextCell(VTK_POLYHEDRON,nfaces,newPtIds->GetPointer(0));
outputCD->CopyData(cellList,cd,inputCount,cellId,newCellId);
newPtIds->Reset ();
}
else
{
......
......@@ -3437,7 +3437,7 @@ void vtkTableBasedClipDataSet::ClipUnstructuredGridData( vtkDataSet * inputGrd,
inputPts = NULL;
// the stuffs that can not be clipped
// the stuff that can not be clipped
if ( numCants > 0 )
{
vtkUnstructuredGrid * vtkUGrid = vtkUnstructuredGrid::New();
......
......@@ -2063,7 +2063,7 @@ void vtkDataSetSurfaceFilter::InsertPolygonInHash(vtkIdType* ids,
// find the index to the smallest id
vtkIdType offset = 0;
for(int i=1; i<numPts; i++)
for(int i=0; i < numPts; i++)
{
if(ids[i] < ids[offset])
{
......@@ -2089,11 +2089,11 @@ void vtkDataSetSurfaceFilter::InsertPolygonInHash(vtkIdType* ids,
bool match = true;
if (numPts == quad->numPts)
{
if ( tab[1] == quad->ptArray[1])
if ( tab[0] == quad->ptArray[0])
{
// if the first two points match loop through forwards
// checking all points
for (int i = 2; i < numPts; i++)
for (int i = 1; i < numPts; i++)
{
if ( tab[i] != quad->ptArray[i])
{
......@@ -2102,13 +2102,13 @@ void vtkDataSetSurfaceFilter::InsertPolygonInHash(vtkIdType* ids,
}
}
}
else if (tab[numPts-1] == quad->ptArray[1])
else if (tab[numPts-1] == quad->ptArray[0])
{
// the first two points match with the opposite sense.
// loop though comparing the correct sense
for (int i = 2; i < numPts; i++)
for (int i = 1; i < numPts; i++)
{
if ( tab[numPts - i] != quad->ptArray[i])
if ( tab[numPts - i - 1] != quad->ptArray[i])
{
match = false;
break;
......
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