VTK  9.3.20240328
vtkLine.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
122 #ifndef vtkLine_h
123 #define vtkLine_h
124 
125 #include "vtkCell.h"
126 #include "vtkCommonDataModelModule.h" // For export macro
127 
128 VTK_ABI_NAMESPACE_BEGIN
130 
131 class VTKCOMMONDATAMODEL_EXPORT vtkLine : public vtkCell
132 {
133 public:
134  static vtkLine* New();
135  vtkTypeMacro(vtkLine, vtkCell);
136  void PrintSelf(ostream& os, vtkIndent indent) override;
137 
139 
142  int GetCellType() override { return VTK_LINE; }
143  int GetCellDimension() override { return 1; }
144  int GetNumberOfEdges() override { return 0; }
145  int GetNumberOfFaces() override { return 0; }
146  vtkCell* GetEdge(int) override { return nullptr; }
147  vtkCell* GetFace(int) override { return nullptr; }
148  int CellBoundary(int subId, const double pcoords[3], vtkIdList* pts) override;
149  void Contour(double value, vtkDataArray* cellScalars, vtkIncrementalPointLocator* locator,
150  vtkCellArray* verts, vtkCellArray* lines, vtkCellArray* polys, vtkPointData* inPd,
151  vtkPointData* outPd, vtkCellData* inCd, vtkIdType cellId, vtkCellData* outCd) override;
152  int EvaluatePosition(const double x[3], double closestPoint[3], int& subId, double pcoords[3],
153  double& dist2, double weights[]) override;
154  void EvaluateLocation(int& subId, const double pcoords[3], double x[3], double* weights) override;
155  int TriangulateLocalIds(int index, vtkIdList* ptIds) override;
157  int subId, const double pcoords[3], const double* values, int dim, double* derivs) override;
158  double* GetParametricCoords() override;
160 
167  int Inflate(double dist) override;
168 
173  void Clip(double value, vtkDataArray* cellScalars, vtkIncrementalPointLocator* locator,
174  vtkCellArray* lines, vtkPointData* inPd, vtkPointData* outPd, vtkCellData* inCd,
175  vtkIdType cellId, vtkCellData* outCd, int insideOut) override;
176 
180  int GetParametricCenter(double pcoords[3]) override;
181 
186  int IntersectWithLine(const double p1[3], const double p2[3], double tol, double& t, double x[3],
187  double pcoords[3], int& subId) override;
188 
189  // Return result type for Intersection() and Intersection3D()
191  {
192  NoIntersect = 0,
193  Intersect = 2,
194  OnLine = 3
195  };
196 
197  // Control the meaning of the provided tolerance. Fuzzy tolerances allow
198  // intersections to occur outside of the range (0<=u,v<=1) as long as they
199  // fall within the tolerance provided. Thus non-fuzzy tolerances must be
200  // within the (0,1) parametric range (inclusive)
202  {
203  Relative = 0,
204  Absolute = 1,
205  RelativeFuzzy = 2,
206  AbsoluteFuzzy = 3
207  };
208 
225  static int Intersection(const double p1[3], const double p2[3], const double x1[3],
226  const double x2[3], double& u, double& v, double tolerance = 1e-6,
227  int toleranceType = ToleranceType::Relative);
228 
237  static double DistanceToLine(const double x[3], const double p1[3], const double p2[3], double& t,
238  double closestPoint[3] = nullptr);
239 
245  static double DistanceToLine(const double x[3], const double p1[3], const double p2[3]);
246 
255  static double DistanceBetweenLines(double l0[3], double l1[3], double m0[3], double m1[3],
256  double closestPt1[3], double closestPt2[3], double& t1, double& t2);
257 
266  static double DistanceBetweenLineSegments(double l0[3], double l1[3], double m0[3], double m1[3],
267  double closestPt1[3], double closestPt2[3], double& t1, double& t2);
268 
269  static void InterpolationFunctions(const double pcoords[3], double weights[2]);
270  static void InterpolationDerivs(const double pcoords[3], double derivs[2]);
272 
276  void InterpolateFunctions(const double pcoords[3], double weights[2]) override
277  {
278  vtkLine::InterpolationFunctions(pcoords, weights);
279  }
280  void InterpolateDerivs(const double pcoords[3], double derivs[2]) override
281  {
282  vtkLine::InterpolationDerivs(pcoords, derivs);
283  }
285 
286 protected:
288  ~vtkLine() override = default;
289 
290 private:
291  vtkLine(const vtkLine&) = delete;
292  void operator=(const vtkLine&) = delete;
293 };
294 
295 //----------------------------------------------------------------------------
296 inline int vtkLine::GetParametricCenter(double pcoords[3])
297 {
298  pcoords[0] = 0.5;
299  pcoords[1] = pcoords[2] = 0.0;
300  return 0;
301 }
302 
303 VTK_ABI_NAMESPACE_END
304 #endif
object to represent cell connectivity
Definition: vtkCellArray.h:285
represent and manipulate cell attribute data
Definition: vtkCellData.h:140
abstract class to specify cell behavior
Definition: vtkCell.h:130
virtual int GetParametricCenter(double pcoords[3])
Return center of the cell in parametric coordinates.
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:154
list of point or cell ids
Definition: vtkIdList.h:132
Abstract class in support of both point location and point insertion.
a simple class to control print indentation
Definition: vtkIndent.h:108
cell represents a 1D line
Definition: vtkLine.h:132
double * GetParametricCoords() override
See the vtkCell API for descriptions of these methods.
int Inflate(double dist) override
Inflates this line by extending both end by dist.
int TriangulateLocalIds(int index, vtkIdList *ptIds) override
See the vtkCell API for descriptions of these methods.
static void InterpolationFunctions(const double pcoords[3], double weights[2])
static int Intersection(const double p1[3], const double p2[3], const double x1[3], const double x2[3], double &u, double &v, double tolerance=1e-6, int toleranceType=ToleranceType::Relative)
Performs intersection of the projection of two finite 3D lines onto a 2D plane.
int EvaluatePosition(const double x[3], double closestPoint[3], int &subId, double pcoords[3], double &dist2, double weights[]) override
See the vtkCell API for descriptions of these methods.
int GetParametricCenter(double pcoords[3]) override
Return the center of the triangle in parametric coordinates.
Definition: vtkLine.h:296
static void InterpolationDerivs(const double pcoords[3], double derivs[2])
void EvaluateLocation(int &subId, const double pcoords[3], double x[3], double *weights) override
See the vtkCell API for descriptions of these methods.
static double DistanceToLine(const double x[3], const double p1[3], const double p2[3], double &t, double closestPoint[3]=nullptr)
Compute the distance of a point x to a finite line (p1,p2).
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
static double DistanceBetweenLineSegments(double l0[3], double l1[3], double m0[3], double m1[3], double closestPt1[3], double closestPt2[3], double &t1, double &t2)
Computes the shortest distance squared between two finite line segments defined by their end points (...
~vtkLine() override=default
static double DistanceToLine(const double x[3], const double p1[3], const double p2[3])
Determine the distance of the current vertex to the edge defined by the vertices provided.
ToleranceType
Definition: vtkLine.h:202
void Contour(double value, vtkDataArray *cellScalars, vtkIncrementalPointLocator *locator, vtkCellArray *verts, vtkCellArray *lines, vtkCellArray *polys, vtkPointData *inPd, vtkPointData *outPd, vtkCellData *inCd, vtkIdType cellId, vtkCellData *outCd) override
See the vtkCell API for descriptions of these methods.
IntersectionType
Definition: vtkLine.h:191
void InterpolateFunctions(const double pcoords[3], double weights[2]) override
Compute the interpolation functions/derivatives (aka shape functions/derivatives)
Definition: vtkLine.h:276
int CellBoundary(int subId, const double pcoords[3], vtkIdList *pts) override
See the vtkCell API for descriptions of these methods.
static double DistanceBetweenLines(double l0[3], double l1[3], double m0[3], double m1[3], double closestPt1[3], double closestPt2[3], double &t1, double &t2)
Computes the shortest distance squared between two infinite lines, each defined by a pair of points (...
int IntersectWithLine(const double p1[3], const double p2[3], double tol, double &t, double x[3], double pcoords[3], int &subId) override
Line-line intersection.
int GetCellDimension() override
See the vtkCell API for descriptions of these methods.
Definition: vtkLine.h:143
vtkCell * GetFace(int) override
See the vtkCell API for descriptions of these methods.
Definition: vtkLine.h:147
int GetNumberOfEdges() override
See the vtkCell API for descriptions of these methods.
Definition: vtkLine.h:144
static vtkLine * New()
vtkCell * GetEdge(int) override
See the vtkCell API for descriptions of these methods.
Definition: vtkLine.h:146
int GetCellType() override
See the vtkCell API for descriptions of these methods.
Definition: vtkLine.h:142
void Clip(double value, vtkDataArray *cellScalars, vtkIncrementalPointLocator *locator, vtkCellArray *lines, vtkPointData *inPd, vtkPointData *outPd, vtkCellData *inCd, vtkIdType cellId, vtkCellData *outCd, int insideOut) override
Clip this line using scalar value provided.
int GetNumberOfFaces() override
See the vtkCell API for descriptions of these methods.
Definition: vtkLine.h:145
void InterpolateDerivs(const double pcoords[3], double derivs[2]) override
Compute the interpolation functions/derivatives (aka shape functions/derivatives)
Definition: vtkLine.h:280
void Derivatives(int subId, const double pcoords[3], const double *values, int dim, double *derivs) override
See the vtkCell API for descriptions of these methods.
represent and manipulate point attribute data
Definition: vtkPointData.h:139
@ value
Definition: vtkX3D.h:220
@ index
Definition: vtkX3D.h:246
@ VTK_LINE
Definition: vtkCellType.h:59
int vtkIdType
Definition: vtkType.h:315