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

Method Inflate

Common/DataModel/vtkCell.cxx:288–406  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

286
287//------------------------------------------------------------------------------
288int vtkCell::Inflate(double dist)
289{
290 if (this->GetNumberOfFaces() != 0)
291 {
292 vtkWarningMacro(<< "Base version of vtkCell::Inflate only implements cell inflation"
293 << " for linear non 3D cells. Class " << this->GetClassName()
294 << " needs to overload this method. Ignoring this cell.");
295 return 0;
296 }
297
298 // Strategy:
299 // For each point, store in a buffer its inflated position by moving each
300 // incident edge their normal direction by a distance of dist. This new
301 // position is done by solving a linear system of equation (intersection of 2
302 // lines).
303
304 auto pointRange = vtk::DataArrayTupleRange<3>(this->Points->GetData());
305 using ConstTupleRef = typename decltype(pointRange)::ConstTupleReferenceType;
306 using TupleRef = typename decltype(pointRange)::TupleReferenceType;
307 using ConstScalar = typename ConstTupleRef::value_type;
308 using Scalar = typename TupleRef::value_type;
309
310 std::vector<Scalar> buf(3 * pointRange.size());
311
312 Scalar normal[3];
313 vtkPolygon::ComputeNormal(this->Points, normal);
314
315 // Matrix transforming the 3D world into a 2D space
316 // used for solving line intersection.
317 // 2x3 matrix
318 Scalar basis[6];
319
320 // This will be used to store consecutive edge line equations
321 // 2x2 matrix
322 Scalar normals2D[4];
323
324 Scalar edgeNormal3D[3];
325
326 // Offset of the corresponding edge line equations in normals2D, shifted by
327 // dist
328 Scalar y[2];
329
330 // Intersection coordinates in 2D basis normals2D of the intersection between
331 // edges
332 Scalar x[2];
333
334 // Current index in normals2D and y. At each iteration, it binary swaps
335 int baseId = 1;
336
337 {
338 ConstTupleRef p1 = pointRange[this->Points->GetNumberOfPoints() - 1], p2 = pointRange[0];
339
340 // We do not support the case of collapsed edges
341 if (vtkMathUtilities::NearlyEqual<ConstScalar>(p1[0], p2[0]) &&
342 vtkMathUtilities::NearlyEqual<ConstScalar>(p1[1], p2[1]) &&
343 vtkMathUtilities::NearlyEqual<ConstScalar>(p1[2], p2[2]))
344 {
345 return 0;

Callers 15

BuildLocatorInternalMethod · 0.45
BuildLocatorMethod · 0.45
IntersectWithLineMethod · 0.45
BuildLocatorInternalMethod · 0.45
BuildLocatorInternalMethod · 0.45
InitPointInsertionMethod · 0.45
BuildLocatorInternalMethod · 0.45
BuildLocatorInternalMethod · 0.45
TestCellInflationFunction · 0.45
GetRenderedBoundsMethod · 0.45
GetRenderedBoundsMethod · 0.45

Calls 10

ComputeNormalFunction · 0.70
NormalizeFunction · 0.70
DotFunction · 0.70
CrossFunction · 0.50
GetNumberOfFacesMethod · 0.45
GetClassNameMethod · 0.45
GetDataMethod · 0.45
sizeMethod · 0.45
GetNumberOfPointsMethod · 0.45
dataMethod · 0.45

Tested by 2

TestCellInflationFunction · 0.36
TestCutsFunction · 0.36