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

Method BoundedTriangulate

Common/DataModel/vtkPolygon.cxx:1000–1037  ·  view source on GitHub ↗

------------------------------------------------------------------------------ Triangulate polygon and enforce that the ratio of the smallest triangle area to the polygon area is greater than a user-defined tolerance.

Source from the content-addressed store, hash-verified

998// Triangulate polygon and enforce that the ratio of the smallest triangle area
999// to the polygon area is greater than a user-defined tolerance.
1000int vtkPolygon::BoundedTriangulate(vtkIdList* outTris, double tolerance)
1001{
1002 int i, j, k, success = 0, numPts = this->PointIds->GetNumberOfIds();
1003 double totalArea, area, areaMin;
1004 double p[3][3];
1005
1006 for (i = 0; i < numPts; i++)
1007 {
1008 success = this->UnbiasedEarCutTriangulation(i, outTris);
1009
1010 if (!success)
1011 {
1012 continue;
1013 }
1014 areaMin = DBL_MAX;
1015 totalArea = 0.;
1016 for (j = 0; j < numPts - 2; j++)
1017 {
1018 for (k = 0; k < 3; k++)
1019 {
1020 this->Points->GetPoint(outTris->GetId(3 * j + k), p[k]);
1021 }
1022 area = vtkTriangle::TriangleArea(p[0], p[1], p[2]);
1023 totalArea += area;
1024 areaMin = std::min(area, areaMin);
1025 }
1026
1027 if ((totalArea != 0.) && areaMin / totalArea < tolerance)
1028 {
1029 success = 0;
1030 }
1031 else
1032 {
1033 break;
1034 }
1035 }
1036 return success;
1037}
1038
1039// Special triangulation helper class. At some point, we may want to split this
1040// outside of vtkPolygon. It could be generalized for different polygon

Callers 3

SplitCellMethod · 0.80
RecoverEdgeMethod · 0.80

Calls 5

minFunction · 0.50
GetNumberOfIdsMethod · 0.45
GetPointMethod · 0.45
GetIdMethod · 0.45

Tested by 1