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

Method IntersectWithLine

Common/DataModel/vtkQuadraticPyramid.cxx:496–580  ·  view source on GitHub ↗

------------------------------------------------------------------------------ Line-hex intersection. Intersection has to occur within [0,1] parametric coordinates and with specified tolerance.

Source from the content-addressed store, hash-verified

494// coordinates and with specified tolerance.
495//
496int vtkQuadraticPyramid::IntersectWithLine(
497 const double* p1, const double* p2, double tol, double& t, double* x, double* pcoords, int& subId)
498{
499 int intersection = 0;
500 double tTemp;
501 double pc[3], xTemp[3];
502 int faceNum;
503 int inter;
504
505 t = VTK_DOUBLE_MAX;
506 this->TriangleFace->GetPoints()->ShallowCopy(this->GetPoints());
507 for (faceNum = 0; faceNum < 5; faceNum++)
508 {
509 // We have 8 nodes on rect face
510 // and 6 on triangle faces
511 if (faceNum > 0)
512 {
513 for (int i = 0; i < 6; i++)
514 {
515 this->TriangleFace->PointIds->SetId(i, this->PointIds->GetId(PyramidFaces[faceNum][i]));
516 }
517 inter = this->TriangleFace->IntersectWithLine(p1, p2, tol, tTemp, xTemp, pc, subId);
518 }
519 else
520 {
521 // No need to set the PointIds. They are set in the Face constructor
522 // Points need to be set to correspond with the constructor's PointIds.
523 for (int i = 0; i < 8; i++)
524 {
525 this->Face->Points->SetPoint(i, this->Points->GetPoint(PyramidFaces[faceNum][i]));
526 }
527 inter = this->Face->IntersectWithLine(p1, p2, tol, tTemp, xTemp, pc, subId);
528 }
529 if (inter)
530 {
531 intersection = 1;
532 if (tTemp < t)
533 {
534 t = tTemp;
535 x[0] = xTemp[0];
536 x[1] = xTemp[1];
537 x[2] = xTemp[2];
538 switch (faceNum)
539 {
540 case 0:
541 pcoords[0] = 0.0;
542 pcoords[1] = pc[1];
543 pcoords[2] = pc[0];
544 break;
545
546 case 1:
547 pcoords[0] = 1.0;
548 pcoords[1] = pc[0];
549 pcoords[2] = pc[1];
550 break;
551
552 case 2:
553 pcoords[0] = pc[0];

Callers

nothing calls this directly

Calls 6

ShallowCopyMethod · 0.45
GetPointsMethod · 0.45
SetIdMethod · 0.45
GetIdMethod · 0.45
SetPointMethod · 0.45
GetPointMethod · 0.45

Tested by

no test coverage detected