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

Method EvaluateFunction

Common/DataModel/vtkBox.cxx:115–174  ·  view source on GitHub ↗

------------------------------------------------------------------------------ Evaluate box equation. This differs from the similar vtkPlanes (with six planes) because of the "rounded" nature of the corners.

Source from the content-addressed store, hash-verified

113// Evaluate box equation. This differs from the similar vtkPlanes
114// (with six planes) because of the "rounded" nature of the corners.
115double vtkBox::EvaluateFunction(double x[3])
116{
117 double diff, dist, minDistance = (-VTK_DOUBLE_MAX), t, distance = 0.0;
118 int inside = 1;
119 const double* minP = this->BBox->GetMinPoint();
120 const double* maxP = this->BBox->GetMaxPoint();
121
122 for (int i = 0; i < 3; i++)
123 {
124 diff = this->BBox->GetLength(i);
125 if (diff != 0.0)
126 {
127 t = (x[i] - minP[i]) / diff;
128 if (t < 0.0)
129 {
130 inside = 0;
131 dist = minP[i] - x[i];
132 }
133 else if (t > 1.0)
134 {
135 inside = 0;
136 dist = x[i] - maxP[i];
137 }
138 else
139 { // want negative distance, we are inside
140 if (t <= 0.5)
141 {
142 dist = minP[i] - x[i];
143 }
144 else
145 {
146 dist = x[i] - maxP[i];
147 }
148 minDistance = std::max(dist, minDistance); // remember, it's negative
149 } // if inside
150 }
151 else
152 {
153 dist = fabs(x[i] - minP[i]);
154 if (dist > 0.0)
155 {
156 inside = 0;
157 }
158 }
159 if (dist > 0.0)
160 {
161 distance += dist * dist;
162 }
163 } // for all coordinate directions
164
165 distance = sqrt(distance);
166 if (inside)
167 {
168 return minDistance;
169 }
170 else
171 {
172 return distance;

Callers 15

EvaluateFunctionFunction · 0.45
TestPlaneFunction · 0.45
UnitTestImplicitVolumeFunction · 0.45
MakeScalarsFunction · 0.45
MakeScalarsFunction · 0.45
MakeScalarsFunction · 0.45
MakeScalarsFunction · 0.45
TestCoordinateFrameFunction · 0.45
MakeScalarsFunction · 0.45
UnitTestImplicitDataSetFunction · 0.45
TestPolyhedron1Function · 0.45

Calls 5

GetMinPointMethod · 0.80
GetMaxPointMethod · 0.80
maxFunction · 0.50
sqrtFunction · 0.50
GetLengthMethod · 0.45

Tested by 13

TestPlaneFunction · 0.36
UnitTestImplicitVolumeFunction · 0.36
MakeScalarsFunction · 0.36
MakeScalarsFunction · 0.36
MakeScalarsFunction · 0.36
MakeScalarsFunction · 0.36
TestCoordinateFrameFunction · 0.36
MakeScalarsFunction · 0.36
UnitTestImplicitDataSetFunction · 0.36
TestPolyhedron1Function · 0.36