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

Method FindTriangleIntersections

Filters/General/vtkIntersectionPolyDataFilter.cxx:212–452  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

210
211//------------------------------------------------------------------------------
212int vtkIntersectionPolyDataFilter::Impl ::FindTriangleIntersections(
213 vtkOBBNode* node0, vtkOBBNode* node1, vtkMatrix4x4* transform, void* arg)
214{
215 vtkIntersectionPolyDataFilter::Impl* info =
216 reinterpret_cast<vtkIntersectionPolyDataFilter::Impl*>(arg);
217
218 // Set up local structures to hold Impl array information
219 vtkPolyData* mesh0 = info->Mesh[0];
220 vtkPolyData* mesh1 = info->Mesh[1];
221 vtkOBBTree* obbTree1 = info->OBBTree1;
222 vtkCellArray* intersectionLines = info->IntersectionLines;
223 vtkIdTypeArray* intersectionSurfaceId = info->SurfaceId;
224 vtkIdTypeArray* intersectionCellIds0 = info->CellIds[0];
225 vtkIdTypeArray* intersectionCellIds1 = info->CellIds[1];
226 vtkPointLocator* pointMerger = info->PointMerger;
227 double tolerance = info->Tolerance;
228
229 // The number of cells in OBBTree
230 int numCells0 = node0->Cells->GetNumberOfIds();
231
232 for (vtkIdType id0 = 0; id0 < numCells0; id0++)
233 {
234 vtkIdType cellId0 = node0->Cells->GetId(id0);
235 int type0 = mesh0->GetCellType(cellId0);
236
237 // Make sure the cell is a triangle
238 if (type0 == VTK_TRIANGLE)
239 {
240 vtkIdType npts0;
241 const vtkIdType* triPtIds0;
242 mesh0->GetCellPoints(cellId0, npts0, triPtIds0);
243 double triPts0[3][3];
244 for (vtkIdType id = 0; id < npts0; id++)
245 {
246 mesh0->GetPoint(triPtIds0[id], triPts0[id]);
247 }
248
249 if (obbTree1->TriangleIntersectsNode(node1, triPts0[0], triPts0[1], triPts0[2], transform))
250 {
251 int numCells1 = node1->Cells->GetNumberOfIds();
252 for (vtkIdType id1 = 0; id1 < numCells1; id1++)
253 {
254 vtkIdType cellId1 = node1->Cells->GetId(id1);
255 int type1 = mesh1->GetCellType(cellId1);
256 if (type1 == VTK_TRIANGLE)
257 {
258 // See if the two cells actually intersect. If they do,
259 // add an entry into the intersection maps and add an
260 // intersection line.
261 vtkIdType npts1;
262 const vtkIdType* triPtIds1;
263 mesh1->GetCellPoints(cellId1, npts1, triPtIds1);
264
265 double triPts1[3][3];
266 for (vtkIdType id = 0; id < npts1; id++)
267 {
268 mesh1->GetPoint(triPtIds1[id], triPts1[id]);
269 }

Callers

nothing calls this directly

Calls 15

SetLinesMethod · 0.80
CheckLineMethod · 0.80
InsertCellPointMethod · 0.80
AddToPointEdgeMapMethod · 0.80
NewFunction · 0.50
GetNumberOfIdsMethod · 0.45
GetIdMethod · 0.45
GetCellTypeMethod · 0.45
GetCellPointsMethod · 0.45
GetPointMethod · 0.45
GetNumberOfCellsMethod · 0.45

Tested by

no test coverage detected