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

Method SampleTriangle

Filters/Modeling/vtkPolyDataPointSampler.cxx:466–511  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

464 }
465
466 void SampleTriangle(const vtkIdType* pts) override
467 {
468 double x0[3], x1[3], x2[3];
469 this->InPts->GetPoint(pts[0], x0);
470 this->InPts->GetPoint(pts[1], x1);
471 this->InPts->GetPoint(pts[2], x2);
472
473 double area = vtkTriangle::TriangleArea(x0, x1, x2);
474 vtkIdType npts = static_cast<vtkIdType>(std::ceil(2.0 * area / this->Distance2));
475 npts *= 2; // due to triangular parametric space
476
477 if (npts > 0)
478 {
479 vtkIdType pId;
480 double s, t, x[3];
481 if (this->InPD)
482 {
483 this->TriIds->SetId(0, pts[0]);
484 this->TriIds->SetId(1, pts[1]);
485 this->TriIds->SetId(2, pts[2]);
486 }
487
488 for (auto i = 0; i < npts; ++i)
489 {
490 s = this->RandomSeq->GetValue();
491 this->RandomSeq->Next();
492 t = this->RandomSeq->GetValue();
493 this->RandomSeq->Next();
494 if ((1.0 - s - t) >= 0.0)
495 { // in triangle parametric space
496 x[0] = x0[0] + s * (x1[0] - x0[0]) + t * (x2[0] - x0[0]);
497 x[1] = x0[1] + s * (x1[1] - x0[1]) + t * (x2[1] - x0[1]);
498 x[2] = x0[2] + s * (x1[2] - x0[2]) + t * (x2[2] - x0[2]);
499
500 pId = this->OutPts->InsertNextPoint(x);
501 if (this->InPD)
502 {
503 this->TriWeights[0] = 1.0 - s - t;
504 this->TriWeights[1] = s;
505 this->TriWeights[2] = t;
506 this->OutPD->InterpolatePoint(this->InPD, pId, this->TriIds, this->TriWeights);
507 }
508 }
509 }
510 }
511 }
512
513 void SamplePolygon(vtkIdType npts, const vtkIdType* pts) override
514 {

Callers 2

SamplePolygonMethod · 0.95
operator()Method · 0.45

Calls 7

ceilFunction · 0.50
GetPointMethod · 0.45
SetIdMethod · 0.45
GetValueMethod · 0.45
NextMethod · 0.45
InsertNextPointMethod · 0.45
InterpolatePointMethod · 0.45

Tested by

no test coverage detected