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

Function IntersectWithCellImpl

Common/DataModel/vtkCell.cxx:27–82  ·  view source on GitHub ↗

---------------------------------------------------------------------------- Strategy: We throw all edges from one cell to an other and look if they intersect. In the case of a cell of one point, we just check if it lies inside the other cell.

Source from the content-addressed store, hash-verified

25// In the case of a cell of one point, we just check if it lies inside
26// the other cell.
27int IntersectWithCellImpl(vtkCell* self, vtkCell* other, double tol)
28{
29 if (!other->GetNumberOfPoints() || !self->GetNumberOfPoints())
30 {
31 return 0;
32 }
33 double x[3], pcoords[3];
34 if (other->GetNumberOfPoints() == 1)
35 {
36 double closestPoint[3];
37 double* point = other->GetPoints()->GetPoint(0);
38 int subId;
39 double dist2, *weights = new double[self->GetNumberOfPoints()];
40 self->EvaluatePosition(point, closestPoint, subId, pcoords, dist2, weights);
41 delete[] weights;
42 return dist2 <= tol * tol;
43 }
44 if (self->GetNumberOfPoints() == 1)
45 {
46 double closestPoint[3];
47 double* point = self->GetPoints()->GetPoint(0);
48 int subId;
49 double dist2, *weights = new double[other->GetNumberOfPoints()];
50 other->EvaluatePosition(point, closestPoint, subId, pcoords, dist2, weights);
51 delete[] weights;
52 return dist2 <= tol * tol;
53 }
54 double p1[3], p2[3];
55 for (vtkIdType edgeId = 0; edgeId < self->GetNumberOfEdges(); ++edgeId)
56 {
57 double t;
58 int subId;
59 vtkCell* edge = self->GetEdge(edgeId);
60 vtkPoints* ends = edge->GetPoints();
61 ends->GetPoint(0, p1);
62 ends->GetPoint(1, p2);
63 if (other->IntersectWithLine(p1, p2, tol, t, x, pcoords, subId))
64 {
65 return 1;
66 }
67 }
68 for (vtkIdType edgeId = 0; edgeId < other->GetNumberOfEdges(); ++edgeId)
69 {
70 double t;
71 int subId;
72 vtkCell* edge = other->GetEdge(edgeId);
73 vtkPoints* ends = edge->GetPoints();
74 ends->GetPoint(0, p1);
75 ends->GetPoint(1, p2);
76 if (self->IntersectWithLine(p1, p2, tol, t, x, pcoords, subId))
77 {
78 return 1;
79 }
80 }
81 return 0;
82}
83} // anonymous namespace
84

Callers 1

IntersectWithCellMethod · 0.85

Calls 7

GetNumberOfPointsMethod · 0.45
GetPointMethod · 0.45
GetPointsMethod · 0.45
EvaluatePositionMethod · 0.45
GetNumberOfEdgesMethod · 0.45
GetEdgeMethod · 0.45
IntersectWithLineMethod · 0.45

Tested by

no test coverage detected