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

Method IntersectWithLine

Common/DataModel/vtkPolygon.cxx:1888–1923  ·  view source on GitHub ↗

------------------------------------------------------------------------------ Intersect this plane with finite line defined by p1 & p2 with tolerance tol.

Source from the content-addressed store, hash-verified

1886// Intersect this plane with finite line defined by p1 & p2 with tolerance tol.
1887//
1888int vtkPolygon::IntersectWithLine(const double p1[3], const double p2[3], double tol, double& t,
1889 double x[3], double pcoords[3], int& subId)
1890{
1891 double pt1[3], n[3];
1892 double tol2 = tol * tol;
1893 double closestPoint[3];
1894 double dist2;
1895 int npts = this->GetNumberOfPoints();
1896
1897 subId = 0;
1898 pcoords[0] = pcoords[1] = pcoords[2] = 0.0;
1899
1900 // Define a plane to intersect with
1901 //
1902 this->Points->GetPoint(1, pt1);
1903 this->ComputeNormal(this->Points, n);
1904
1905 // Intersect plane of the polygon with line
1906 //
1907 if (!vtkPlane::IntersectWithLine(p1, p2, n, pt1, t, x))
1908 {
1909 return 0;
1910 }
1911
1912 // Evaluate position
1913 //
1914 std::vector<double> weights(npts);
1915 if (this->EvaluatePosition(x, closestPoint, subId, pcoords, dist2, weights.data()) >= 0)
1916 {
1917 if (dist2 <= tol2)
1918 {
1919 return 1;
1920 }
1921 }
1922 return 0;
1923}
1924
1925//------------------------------------------------------------------------------
1926int vtkPolygon::TriangulateLocalIds(int vtkNotUsed(index), vtkIdList* ptIds)

Callers 1

Calls 5

ComputeNormalMethod · 0.95
EvaluatePositionMethod · 0.95
GetNumberOfPointsMethod · 0.45
GetPointMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected