Commit dfb1542d authored by Michael Migliore's avatar Michael Migliore

Fix normal computation when verts and lines are presents

parent 8d39b7dd
Pipeline #135020 running with stage
......@@ -80,7 +80,7 @@ int vtkPolyDataNormals::RequestData(
vtkIdType *pts = nullptr;
vtkIdType numNewPts;
double flipDirection=1.0;
vtkIdType numPolys, numStrips;
vtkIdType numVerts, numLines, numPolys, numStrips;
vtkIdType cellId;
vtkIdType numPts;
vtkPoints *inPts;
......@@ -95,6 +95,8 @@ int vtkPolyDataNormals::RequestData(
vtkDebugMacro(<<"Generating surface normals");
numVerts=input->GetNumberOfVerts();
numLines=input->GetNumberOfLines();
numPolys=input->GetNumberOfPolys();
numStrips=input->GetNumberOfStrips();
if ( (numPts=input->GetNumberOfPoints()) < 1 )
......@@ -342,9 +344,19 @@ int vtkPolyDataNormals::RequestData(
//
this->PolyNormals = vtkFloatArray::New();
this->PolyNormals->SetNumberOfComponents(3);
this->PolyNormals->Allocate(3*numPolys);
this->PolyNormals->SetName("Normals");
this->PolyNormals->SetNumberOfTuples(numPolys);
this->PolyNormals->SetNumberOfTuples(numVerts + numLines + numPolys);
vtkIdType offsetCells = numVerts + numLines;
n[0] = 1.0;
n[1] = 0.0;
n[2] = 0.0;
for (cellId=0; cellId < offsetCells; cellId++)
{
// add a default value for vertices and lines
// normals do not have meaningful values, we set them to X
this->PolyNormals->SetTuple(cellId, n);
}
for (cellId=0, newPolys->InitTraversal(); newPolys->GetNextCell(npts,pts);
cellId++ )
......@@ -358,7 +370,7 @@ int vtkPolyDataNormals::RequestData(
}
}
vtkPolygon::ComputeNormal(inPts, npts, pts, n);
this->PolyNormals->SetTuple(cellId,n);
this->PolyNormals->SetTuple(offsetCells + cellId, n);
}
// Split mesh if sharp features
......@@ -457,7 +469,7 @@ int vtkPolyDataNormals::RequestData(
float *fNormals = newNormals->WritePointer(0, 3 * numNewPts);
std::fill_n(fNormals, 3 * numNewPts, 0);
float *fPolyNormals = this->PolyNormals->WritePointer(0, 3 * numPolys);
float *fPolyNormals = this->PolyNormals->WritePointer(3 * offsetCells, 3 * numPolys);
if (this->ComputePointNormals)
{
......
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