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

Method CellBoundary

Common/DataModel/vtkPolygon.cxx:1756–1820  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

1754
1755//------------------------------------------------------------------------------
1756int vtkPolygon::CellBoundary(int vtkNotUsed(subId), const double pcoords[3], vtkIdList* pts)
1757{
1758 int i, numPts = this->PointIds->GetNumberOfIds();
1759 double x[3];
1760 int closestPoint = 0, previousPoint, nextPoint;
1761 double largestWeight = 0.0;
1762 double p0[3], p10[3], l10, p20[3], l20, n[3];
1763
1764 pts->Reset();
1765 std::vector<double> weights(numPts);
1766
1767 // determine global coordinates given parametric coordinates
1768 this->ParameterizePolygon(p0, p10, l10, p20, l20, n);
1769 for (i = 0; i < 3; i++)
1770 {
1771 x[i] = p0[i] + pcoords[0] * p10[i] + pcoords[1] * p20[i];
1772 }
1773
1774 // find edge with largest and next largest weight values. This will be
1775 // the closest edge.
1776 this->InterpolateFunctions(x, weights.data());
1777 for (i = 0; i < numPts; i++)
1778 {
1779 if (weights[i] > largestWeight)
1780 {
1781 closestPoint = i;
1782 largestWeight = weights[i];
1783 }
1784 }
1785
1786 pts->InsertId(0, this->PointIds->GetId(closestPoint));
1787
1788 previousPoint = closestPoint - 1;
1789 nextPoint = closestPoint + 1;
1790 if (previousPoint < 0)
1791 {
1792 previousPoint = numPts - 1;
1793 }
1794 if (nextPoint >= numPts)
1795 {
1796 nextPoint = 0;
1797 }
1798
1799 if (weights[previousPoint] > weights[nextPoint])
1800 {
1801 pts->InsertId(1, this->PointIds->GetId(previousPoint));
1802 }
1803 else
1804 {
1805 pts->InsertId(1, this->PointIds->GetId(nextPoint));
1806 }
1807
1808 // determine whether point is inside of polygon
1809 if (pcoords[0] >= 0.0 && pcoords[0] <= 1.0 && pcoords[1] >= 0.0 && pcoords[1] <= 1.0 &&
1810 (this->PointInPolygon(x, this->Points->GetNumberOfPoints(),
1811 static_cast<vtkDoubleArray*>(this->Points->GetData())->GetPointer(0), this->GetBounds(),
1812 n) == VTK_POLYGON_INSIDE))
1813 {

Callers

nothing calls this directly

Calls 12

ParameterizePolygonMethod · 0.95
InterpolateFunctionsMethod · 0.95
PointInPolygonMethod · 0.95
InsertIdMethod · 0.80
GetNumberOfIdsMethod · 0.45
ResetMethod · 0.45
dataMethod · 0.45
GetIdMethod · 0.45
GetNumberOfPointsMethod · 0.45
GetPointerMethod · 0.45
GetDataMethod · 0.45
GetBoundsMethod · 0.45

Tested by

no test coverage detected