Commit 8fbe9d7b authored by Will Schroeder's avatar Will Schroeder
Browse files

ERR: Logic problems with continue statements

parent 086b7635
......@@ -33,6 +33,8 @@ vlFeatureEdges::vlFeatureEdges()
// Generate feature edges for mesh
void vlFeatureEdges::Execute()
{
vlPolyData *input=(vlPolyData *)this->Input;
vlPoints *inPts;
vlFloatPoints *newPts;
vlFloatScalars *newScalars;
vlCellArray *newLines;
......@@ -49,22 +51,28 @@ void vlFeatureEdges::Execute()
int numPts, nei;
vlIdList neighbors(MAX_CELL_SIZE);
int p1, p2;
vlPolyData *input=(vlPolyData *)this->Input;
vlDebugMacro(<<"Executing feature edges");
this->Initialize();
//
// Check input
//
if (!(numPts=input->GetNumberOfPoints()) )
if ( (numPts=input->GetNumberOfPoints()) < 1 ||
(inPts=input->GetPoints()) == NULL ||
(inPolys=input->GetPolys()) == NULL )
{
vlErrorMacro(<<"No input data!");
return;
}
if ( !this->BoundaryEdges && !this->NonManifoldEdges && !this->FeatureEdges)
{
vlWarningMacro(<<"All edge types turned off!");
return;
}
// build cell structure. Only operate with polygons.
Mesh.SetPoints(input->GetPoints());
inPolys = input->GetPolys();
Mesh.SetPoints(inPts);
Mesh.SetPolys(inPolys);
Mesh.BuildLinks();
//
......@@ -76,82 +84,86 @@ void vlFeatureEdges::Execute()
//
// Loop over all polygons generating boundary, non-manifold, and feature edges
//
if (this->BoundaryEdges || this->NonManifoldEdges || this->FeatureEdges)
{
if ( this->FeatureEdges )
{
polyNormals = new vlFloatNormals(inPolys->GetNumberOfCells());
for (cellId=0, inPolys->InitTraversal(); inPolys->GetNextCell(npts,pts);
cellId++)
{
poly.ComputeNormal(input->GetPoints(),npts,pts,n);
polyNormals->InsertNormal(cellId,n);
}
cosAngle = cos ((double) math.DegreesToRadians() * this->FeatureAngle);
}
if ( this->FeatureEdges )
{
polyNormals = new vlFloatNormals(inPolys->GetNumberOfCells());
numBEdges = numNonManifoldEdges = numFedges = 0;
for (cellId=0, inPolys->InitTraversal(); inPolys->GetNextCell(npts,pts);
cellId++)
{
for (i=0; i < npts; i++)
poly.ComputeNormal(inPts,npts,pts,n);
polyNormals->InsertNormal(cellId,n);
}
cosAngle = cos ((double) math.DegreesToRadians() * this->FeatureAngle);
}
numBEdges = numNonManifoldEdges = numFedges = 0;
for (cellId=0, inPolys->InitTraversal(); inPolys->GetNextCell(npts,pts);
cellId++)
{
for (i=0; i < npts; i++)
{
p1 = pts[i];
p2 = pts[(i+1)%npts];
Mesh.GetCellEdgeNeighbors(cellId,p1,p2,neighbors);
if ( this->BoundaryEdges && (numNei=neighbors.GetNumberOfIds()) < 1 )
{
p1 = pts[i];
p2 = pts[(i+1)%npts];
Mesh.GetCellEdgeNeighbors(cellId,p1,p2,neighbors);
numBEdges++;
scalar = 0.0;
}
if ( (numNei=neighbors.GetNumberOfIds()) < 1 && this->BoundaryEdges )
{
numBEdges++;
scalar = 0.0;
}
else if ( numNei > 1 && this->NonManifoldEdges )
else if ( this->NonManifoldEdges && numNei > 1 )
{
// check to make sure that this edge hasn't been created before
for (j=0; j < numNei; j++)
if ( neighbors.GetId(j) < cellId )
break;
if ( j >= numNei )
{
// check to make sure that this edge hasn't been created before
for (j=0; j < numNei; j++)
if ( neighbors.GetId(j) < cellId )
break;
if ( j >= numNei )
{
numNonManifoldEdges++;
scalar = 0.33333;
}
numNonManifoldEdges++;
scalar = 0.33333;
}
else if ( numNei == 1 && (nei=neighbors.GetId(0)) > cellId )
else continue;
}
else if ( this->FeatureEdges &&
numNei == 1 && (nei=neighbors.GetId(0)) > cellId )
{
if ( math.Dot(polyNormals->GetNormal(nei),polyNormals->GetNormal(cellId)) <= cosAngle )
{
if ( math.Dot(polyNormals->GetNormal(nei),polyNormals->GetNormal(cellId)) <= cosAngle )
{
numFedges++;
scalar = 0.66667;
}
else
{
continue;
}
numFedges++;
scalar = 0.66667;
}
else continue;
}
x1 = Mesh.GetPoint(p1);
x2 = Mesh.GetPoint(p2);
else continue;
lineIds[0] = newPts->InsertNextPoint(x1);
lineIds[1] = newPts->InsertNextPoint(x2);
// Add edge to output
x1 = Mesh.GetPoint(p1);
x2 = Mesh.GetPoint(p2);
newLines->InsertNextCell(2,lineIds);
lineIds[0] = newPts->InsertNextPoint(x1);
lineIds[1] = newPts->InsertNextPoint(x2);
newScalars->InsertScalar(lineIds[0], scalar);
newScalars->InsertScalar(lineIds[1], scalar);
}
newLines->InsertNextCell(2,lineIds);
newScalars->InsertScalar(lineIds[0], scalar);
newScalars->InsertScalar(lineIds[1], scalar);
}
vlDebugMacro(<<"Created " << numBEdges << " boundary edges, " <<
numNonManifoldEdges << " non-manifold edges, " <<
numFedges << " feature edges");
if ( this->FeatureEdges ) delete polyNormals;
}
vlDebugMacro(<<"Created " << numBEdges << " boundary edges, " <<
numNonManifoldEdges << " non-manifold edges, " <<
numFedges << " feature edges");
//
// Update ourselves.
//
if ( this->FeatureEdges ) delete polyNormals;
this->SetPoints(newPts);
this->SetLines(newLines);
if ( this->Coloring )
......
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