MCPcopy Create free account
hub / github.com/Kitware/VTK / ComputeNormal

Method ComputeNormal

Common/DataModel/vtkPolygon.cxx:198–219  ·  view source on GitHub ↗

Compute the polygon normal from a points list, and a list of point ids that index into the points list. Parameter pts can be nullptr, indicating that the polygon indexing is {0, 1, ..., numPts-1}. This version will handle non-convex polygons.

Source from the content-addressed store, hash-verified

196// the polygon indexing is {0, 1, ..., numPts-1}. This version will handle
197// non-convex polygons.
198vtkCellStatus vtkPolygon::ComputeNormal(vtkPoints* p, int numPts, const vtkIdType* pts, double* n)
199{
200 //
201 // Check for special triangle case. Saves extra work.
202 //
203 n[0] = n[1] = n[2] = 0.0;
204 if (numPts < 3)
205 {
206 return vtkCellStatus::WrongNumberOfPoints;
207 }
208
209 if (pts)
210 {
211 ::ComputeNormal<true>(p, numPts, pts, n);
212 }
213 else
214 {
215 ::ComputeNormal<false>(p, numPts, pts, n);
216 }
217
218 return (vtkMath::Normalize(n) == 0) ? vtkCellStatus::DegenerateFaces : vtkCellStatus::Valid;
219}
220
221//------------------------------------------------------------------------------
222// Compute the polygon normal from a points list, and a list of point ids

Callers 4

ParameterizePolygonMethod · 0.95
IntersectWithLineMethod · 0.95
EarCutTriangulationMethod · 0.45

Calls 7

NormalizeFunction · 0.70
ComputeNormalFunction · 0.70
sqrtFunction · 0.50
CrossFunction · 0.50
GetNumberOfTuplesMethod · 0.45
GetPointerMethod · 0.45
GetNumberOfPointsMethod · 0.45

Tested by

no test coverage detected