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

Method EvaluatePosition

Common/DataModel/vtkPixel.cxx:52–140  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

50
51//------------------------------------------------------------------------------
52int vtkPixel::EvaluatePosition(const double x[3], double closestPoint[3], int& subId,
53 double pcoords[3], double& dist2, double weights[])
54{
55 const double *pt1, *pt2, *pt3;
56 int i;
57 double p[3], p21[3], p31[3], cp[3];
58 double l21, l31, n[3];
59
60 subId = 0;
61 pcoords[2] = 0.0;
62
63 // Efficient point access
64 const auto pointsArray = vtkDoubleArray::FastDownCast(this->Points->GetData());
65 if (!pointsArray)
66 {
67 vtkErrorMacro(<< "Points should be double type");
68 return 0;
69 }
70 const double* pts = pointsArray->GetPointer(0);
71
72 // Get normal for pixel
73 pt1 = pts;
74 pt2 = pts + 3;
75 pt3 = pts + 6;
76
77 vtkTriangle::ComputeNormal(pt1, pt2, pt3, n);
78
79 // Project point to plane
80 //
81 vtkPlane::ProjectPoint(x, pt1, n, cp);
82
83 for (i = 0; i < 3; i++)
84 {
85 p21[i] = pt2[i] - pt1[i];
86 p31[i] = pt3[i] - pt1[i];
87 p[i] = x[i] - pt1[i];
88 }
89
90 if ((l21 = vtkMath::Norm(p21)) == 0.0)
91 {
92 l21 = 1.0;
93 }
94 if ((l31 = vtkMath::Norm(p31)) == 0.0)
95 {
96 l31 = 1.0;
97 }
98
99 pcoords[0] = vtkMath::Dot(p21, p) / (l21 * l21);
100 pcoords[1] = vtkMath::Dot(p31, p) / (l31 * l31);
101
102 vtkPixel::InterpolationFunctions(pcoords, weights);
103
104 if (pcoords[0] >= 0.0 && pcoords[0] <= 1.0 && pcoords[1] >= 0.0 && pcoords[1] <= 1.0)
105 {
106 if (closestPoint)
107 {
108 closestPoint[0] = cp[0];
109 closestPoint[1] = cp[1];

Callers 1

IntersectWithLineMethod · 0.95

Calls 7

EvaluateLocationMethod · 0.95
ComputeNormalFunction · 0.70
NormFunction · 0.70
DotFunction · 0.70
FastDownCastFunction · 0.50
GetDataMethod · 0.45
GetPointerMethod · 0.45

Tested by

no test coverage detected