VTK  9.7.20260915
vtkPolygon.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
116
117#ifndef vtkPolygon_h
118#define vtkPolygon_h
119
120#include "vtkCell.h"
121#include "vtkCellStatus.h" // For return type
122#include "vtkCommonDataModelModule.h" // For export macro
123
124#include <cmath> // For std::sqrt in the quality ear clip
125#include <utility> // For std::swap in the quality ear clip
126#include <vector> // For ear-clip scratch buffers
127
128VTK_ABI_NAMESPACE_BEGIN
129class vtkDoubleArray;
130class vtkIdTypeArray;
131class vtkLine;
132class vtkPoints;
133class vtkQuad;
134class vtkTriangle;
135class vtkPriorityQueue;
137
138class VTKCOMMONDATAMODEL_EXPORT vtkPolygon : public vtkCell
139{
140public:
141 static vtkPolygon* New();
142 vtkTypeMacro(vtkPolygon, vtkCell);
143 void PrintSelf(ostream& os, vtkIndent indent) override;
144
146
149 int GetCellType() override { return VTK_POLYGON; }
150 int GetCellDimension() override { return 2; }
151 int GetNumberOfEdges() override { return this->GetNumberOfPoints(); }
152 int GetNumberOfFaces() override { return 0; }
153 vtkCell* GetEdge(int edgeId) override;
154 vtkCell* GetFace(int) override { return nullptr; }
155 int CellBoundary(int subId, const double pcoords[3], vtkIdList* pts) override;
156 void Contour(double value, vtkDataArray* cellScalars, vtkIncrementalPointLocator* locator,
157 vtkCellArray* verts, vtkCellArray* lines, vtkCellArray* polys, vtkPointData* inPd,
158 vtkPointData* outPd, vtkCellData* inCd, vtkIdType cellId, vtkCellData* outCd) override;
159 void Clip(double value, vtkDataArray* cellScalars, vtkIncrementalPointLocator* locator,
160 vtkCellArray* tris, vtkPointData* inPd, vtkPointData* outPd, vtkCellData* inCd,
161 vtkIdType cellId, vtkCellData* outCd, int insideOut) override;
162 int EvaluatePosition(const double x[3], double closestPoint[3], int& subId, double pcoords[3],
163 double& dist2, double weights[]) override;
164 void EvaluateLocation(int& subId, const double pcoords[3], double x[3], double* weights) override;
165 int IntersectWithLine(const double p1[3], const double p2[3], double tol, double& t, double x[3],
166 double pcoords[3], int& subId) override;
167 int TriangulateLocalIds(int index, vtkIdList* ptIds) override;
169 int subId, const double pcoords[3], const double* values, int dim, double* derivs) override;
170 int IsPrimaryCell() VTK_FUTURE_CONST override { return 0; }
172
182 bool ClipIfTrivial(double value, vtkDataArray* cellScalars, vtkIncrementalPointLocator* locator,
183 vtkCellArray* tris, vtkPointData* inPD, vtkPointData* outPD, vtkCellData* inCD,
184 vtkIdType cellId, vtkCellData* outCD, int insideOut);
185
192 double ComputeArea();
193
203 void InterpolateFunctions(const double x[3], double* sf) override;
204
206
210 static vtkCellStatus ComputeNormal(vtkPoints* p, int numPts, const vtkIdType* pts, double n[3]);
211 static vtkCellStatus ComputeNormal(vtkPoints* p, double n[3]);
212 static vtkCellStatus ComputeNormal(vtkIdTypeArray* ids, vtkPoints* pts, double n[3]);
214
219 static vtkCellStatus ComputeNormal(int numPts, double* pts, double n[3]);
220
227 bool IsConvex();
228
230
242 static bool IsConvex(vtkPoints* p, int numPts, const vtkIdType* pts);
243 static bool IsConvex(vtkIdTypeArray* ids, vtkPoints* p);
244 static bool IsConvex(vtkPoints* p);
246
248
273 vtkPoints* p, int numPts, const vtkIdType* pts, double centroid[3], double tolerance);
274 static bool ComputeCentroid(vtkPoints* p, int numPts, const vtkIdType* pts, double centroid[3]);
275 static bool ComputeCentroid(vtkIdTypeArray* ids, vtkPoints* pts, double centroid[3]);
277
286 vtkPoints* p, int numPts, const vtkIdType* ids, double center[3], double& radius2);
287
296 static double ComputeArea(vtkPoints* p, vtkIdType numPts, const vtkIdType* pts, double normal[3]);
297
305 static double ComputeArea(int numPts, double* pts, double normal[3]);
306
315 double p0[3], double p10[3], double& l10, double p20[3], double& l20, double n[3]);
316
328 static int PointInPolygon(double x[3], int numPts, double* pts, double bounds[6], double n[3]);
329
330 // Needed to remove warning "member function does not override any
331 // base class virtual member function"
332 int Triangulate(int index, vtkIdList* ptIds, vtkPoints* pts) override
333 {
334 return vtkCell::Triangulate(index, ptIds, pts);
335 }
336
342
350 int BoundedTriangulate(vtkIdList* outTris, double tol);
351
357 static double DistanceToPolygon(
358 double x[3], int numPts, double* pts, double bounds[6], double closest[3]);
359
368 static int IntersectPolygonWithPolygon(int npts, double* pts, double bounds[6], int npts2,
369 double* pts2, double bounds2[6], double tol, double x[3]);
370
383 vtkCell* cell1, vtkCell* cell2, double tol, double p0[3], double p1[3]);
384
386
392 vtkGetMacro(UseMVCInterpolation, bool);
393 vtkSetMacro(UseMVCInterpolation, bool);
395
397
405 vtkSetClampMacro(Tolerance, double, 0.0, 1.0);
406 vtkGetMacro(Tolerance, double);
408
409protected:
411 ~vtkPolygon() override = default;
412
413 // Compute the interpolation functions using Mean Value Coordinate.
414 void InterpolateFunctionsUsingMVC(const double x[3], double* weights);
415
416 // variables used by instances of this class
417 double Tolerance; // Intersection tolerance set by public API
418 double Tol; // Internal tolerance set by ComputeBounds()
419 void ComputeTolerance(); // Compute the internal tolerance Tol
420
421 int SuccessfulTriangulation; // Stops recursive triangulation if necessary
422 vtkSmartPointer<vtkIdList> Tris; // Output triangulation placed here
423
424 // These are used for internal computation.
429 vtkSmartPointer<vtkPriorityQueue> EarClipQueue; // reused ear-clip removal queue
430 vtkSmartPointer<vtkCellArray> ClippedTris; // reused scratch triangle/quad buffer for Clip()
431 vtkSmartPointer<vtkCellData> ScratchCD; // reused scratch cell data buffer for Clip()
432
433 // Parameter indicating whether to use Mean Value Coordinate algorithm
434 // for interpolation. The parameter is false by default.
436
437 // Helper methods for triangulation------------------------------
438 // Made public for external access
439public:
440 // Ear cut triangulation options. The order in which vertices are
441 // removed are controlled by different measures. Changing this can
442 // make subtle differences in some cases. Historically the
443 // PERIMETER2_TO_AREA_RATIO has been used.
450
452
463
465
474 int seed, vtkIdList* outTris, int measure = PERIMETER2_TO_AREA_RATIO);
476
478
505 template <typename PointsRange, typename CellIter>
506 static int CompactPolygonRing(
507 const PointsRange& points, CellIter cell, int cellSize, std::vector<int>& ring);
508 template <typename PointsRange, typename CellIter>
510 const PointsRange& points, CellIter cell, int cellSize, std::vector<int>& ring);
511 template <typename PointsRange, typename CellIter, typename EmitFn>
512 static void EarClipPolygon3D(const PointsRange& points, CellIter cell, int cellSize,
513 std::vector<int>& prevBuf, std::vector<int>& nextBuf, std::vector<int>& ring, EmitFn&& emit);
515
516private:
517 vtkPolygon(const vtkPolygon&) = delete;
518 void operator=(const vtkPolygon&) = delete;
519};
520
521//------------------------------------------------------------------------------
522template <typename PointsRange, typename CellIter>
524 const PointsRange& points, CellIter cell, int cellSize, std::vector<int>& ring)
525{
526 // Build the ring of distinct vertices, dropping consecutive coincident
527 // vertices (degenerate edges). Banded contouring and clipping routinely emit
528 // polygons with coincident consecutive vertices when a scalar lands exactly
529 // on a clip value; the historical fan triangulation tolerated these by
530 // skipping zero-area triangles, and the ear clip must do the same or it
531 // computes a bogus normal / ear test at the duplicated vertex.
532 ring.clear();
533 for (int i = 0; i < cellSize; ++i)
534 {
535 if (!ring.empty())
536 {
537 auto pPrev = points[cell[ring.back()]];
538 auto pCur = points[cell[i]];
539 if (pPrev[0] == pCur[0] && pPrev[1] == pCur[1] && pPrev[2] == pCur[2])
540 {
541 continue; // coincident with previous kept vertex
542 }
543 }
544 ring.push_back(i);
545 }
546 // Drop the last vertex if it coincides with the first (wrap-around duplicate).
547 if (ring.size() >= 2)
548 {
549 auto pFirst = points[cell[ring.front()]];
550 auto pLast = points[cell[ring.back()]];
551 if (pFirst[0] == pLast[0] && pFirst[1] == pLast[1] && pFirst[2] == pLast[2])
552 {
553 ring.pop_back();
554 }
555 }
556 return static_cast<int>(ring.size());
557}
558
559//------------------------------------------------------------------------------
560template <typename PointsRange, typename CellIter>
562 const PointsRange& points, CellIter cell, int cellSize, std::vector<int>& ring)
563{
564 const int m = vtkPolygon::CompactPolygonRing(points, cell, cellSize, ring);
565 return m >= 3 ? static_cast<vtkIdType>(m - 2) : 0;
566}
567
568//------------------------------------------------------------------------------
569template <typename PointsRange, typename CellIter, typename EmitFn>
570void vtkPolygon::EarClipPolygon3D(const PointsRange& points, CellIter cell, int cellSize,
571 std::vector<int>& prevBuf, std::vector<int>& nextBuf, std::vector<int>& ring, EmitFn&& emit)
572{
573 const int m = vtkPolygon::CompactPolygonRing(points, cell, cellSize, ring);
574 if (m < 3)
575 {
576 return; // fully degenerate (collapses to a point or segment): no triangles
577 }
578
579 // ring[k] is the polygon-local index of the k-th distinct vertex. Work in
580 // compacted space 0..m-1; map back through ring[] when emitting and looking
581 // up coordinates.
582 auto P = [&](int k) { return points[cell[ring[k]]]; };
583
584 // Compute polygon normal via Newell's method over the compacted ring.
585 double normal[3] = { 0.0, 0.0, 0.0 };
586 {
587 auto pLast = P(m - 1);
588 double xp = pLast[0], yp = pLast[1], zp = pLast[2];
589 for (int i = 0; i < m; ++i)
590 {
591 auto pi = P(i);
592 double x = pi[0], y = pi[1], z = pi[2];
593 normal[0] += (yp - y) * (zp + z);
594 normal[1] += (zp - z) * (xp + x);
595 normal[2] += (xp - x) * (yp + y);
596 xp = x;
597 yp = y;
598 zp = z;
599 }
600 }
601
602 // Emit a triangle given compacted-ring indices, computing the polygon-
603 // boundary edge mask from compacted-ring adjacency, then mapping to local.
604 auto emitRing = [&](int a, int b, int c)
605 {
606 auto isBoundary = [m](int x, int y) -> int
607 {
608 const int d = (y - x + m) % m;
609 return (d == 1 || d == m - 1) ? 1 : 0;
610 };
611 int mask = isBoundary(a, b);
612 mask |= isBoundary(b, c) << 1;
613 mask |= isBoundary(c, a) << 2;
614 emit(ring[a], ring[b], ring[c], mask);
615 };
616
617 const double normLen2 = normal[0] * normal[0] + normal[1] * normal[1] + normal[2] * normal[2];
618 if (normLen2 == 0.0)
619 {
620 // Zero-area (collinear) polygon. No meaningful triangulation; fall back to
621 // a fan over the compacted ring so the emit count matches m - 2.
622 for (int i = 1; i < m - 1; ++i)
623 {
624 emitRing(0, i, i + 1);
625 }
626 return;
627 }
628
629 // Doubly-linked circular list over the compacted ring 0..m-1.
630 prevBuf.resize(m);
631 nextBuf.resize(m);
632 for (int i = 0; i < m; ++i)
633 {
634 prevBuf[i] = (i + m - 1) % m;
635 nextBuf[i] = (i + 1) % m;
636 }
637
638 auto isEar = [&](int b) -> bool
639 {
640 const int a = prevBuf[b];
641 const int c = nextBuf[b];
642 auto pa = P(a);
643 auto pb = P(b);
644 auto pc = P(c);
645 const double ax = pa[0], ay = pa[1], az = pa[2];
646 const double bx = pb[0], by = pb[1], bz = pb[2];
647 const double cx = pc[0], cy = pc[1], cz = pc[2];
648
649 // Convexity at b: ((b - a) x (c - b)) . normal > 0
650 const double e1x = bx - ax, e1y = by - ay, e1z = bz - az;
651 const double e2x = cx - bx, e2y = cy - by, e2z = cz - bz;
652 const double crx = e1y * e2z - e1z * e2y;
653 const double cry = e1z * e2x - e1x * e2z;
654 const double crz = e1x * e2y - e1y * e2x;
655 if (crx * normal[0] + cry * normal[1] + crz * normal[2] <= 0.0)
656 {
657 return false; // reflex or zero-area
658 }
659
660 // No other vertex in the remaining polygon may lie strictly inside
661 // triangle (a, b, c). Use the polygon normal as the projection axis for
662 // a same-side test against each triangle edge.
663 for (int q = nextBuf[c]; q != a; q = nextBuf[q])
664 {
665 auto pq = P(q);
666 const double qx = pq[0], qy = pq[1], qz = pq[2];
667 auto sideOf = [&](double sx, double sy, double sz, double ex, double ey, double ez) -> double
668 {
669 const double dx = ex - sx, dy = ey - sy, dz = ez - sz;
670 const double rx = qx - sx, ry = qy - sy, rz = qz - sz;
671 const double tcrx = dy * rz - dz * ry;
672 const double tcry = dz * rx - dx * rz;
673 const double tcrz = dx * ry - dy * rx;
674 return tcrx * normal[0] + tcry * normal[1] + tcrz * normal[2];
675 };
676 const double s1 = sideOf(ax, ay, az, bx, by, bz);
677 const double s2 = sideOf(bx, by, bz, cx, cy, cz);
678 const double s3 = sideOf(cx, cy, cz, ax, ay, az);
679 if (s1 > 0.0 && s2 > 0.0 && s3 > 0.0)
680 {
681 return false;
682 }
683 }
684 return true;
685 };
686
687 // Clip ears walking forward from vertex 1, keeping the clipped vertex's
688 // successor as the next candidate. For a convex polygon this clips vertices
689 // 1, 2, 3, ... in order while vertex 0 remains the common apex, reproducing
690 // exactly the fan-from-vertex-0 triangulation VTK has always emitted (and
691 // that existing image baselines were generated with). Triangulation is not
692 // invariant under interior diagonals: per-triangle texture-coordinate and
693 // Gouraud interpolation depend on the diagonals chosen, so a convex polygon
694 // must keep producing the fan. For non-convex polygons reflex vertices are
695 // skipped and the walk still finds valid ears.
696 int remaining = m;
697 int current = 1 % m;
698 int safetyBudget = 2 * m;
699 while (remaining > 3 && safetyBudget > 0)
700 {
701 if (isEar(current))
702 {
703 const int a = prevBuf[current];
704 const int c = nextBuf[current];
705 emitRing(a, current, c);
706 nextBuf[a] = c;
707 prevBuf[c] = a;
708 current = c;
709 --remaining;
710 safetyBudget = 2 * m;
711 }
712 else
713 {
714 current = nextBuf[current];
715 --safetyBudget;
716 }
717 }
718
719 if (remaining > 3)
720 {
721 // Ear-clip stalled. Emit remaining vertices as a fan from `current` to
722 // satisfy the emit-pass triangle count. Result will be visually wrong for
723 // a non-convex remainder, but degenerate input has no correct triangulation.
724 const int head = current;
725 int v = nextBuf[head];
726 int vn = nextBuf[v];
727 while (vn != head)
728 {
729 emitRing(head, v, vn);
730 v = vn;
731 vn = nextBuf[vn];
732 }
733 return;
734 }
735
736 // Final triangle: the three vertices still in the list. Emit it anchored at
737 // prev(current) so that for a convex polygon (where current has advanced to
738 // the second-to-last vertex with vertex 0 still the apex) the triangle is
739 // (0, m-2, m-1) - the same vertex order and boundary-edge mask the fan emits.
740 const int b = current;
741 const int a = prevBuf[b];
742 const int c = nextBuf[b];
743 emitRing(a, b, c);
744}
745
746VTK_ABI_NAMESPACE_END
747#endif
RealT s2
Definition PyrC2Basis.h:21
object to represent cell connectivity
represent and manipulate cell attribute data
virtual int Triangulate(int index, vtkIdList *ptIds, vtkPoints *pts)
Generate simplices of proper dimension.
vtkIdType GetNumberOfPoints() const
Return the number of points in the cell.
Definition vtkCell.h:208
dynamic, self-adjusting array of double
list of point or cell ids
Definition vtkIdList.h:135
dynamic, self-adjusting array of vtkIdType
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
represent and manipulate point attribute data
represent and manipulate 3D points
Definition vtkPoints.h:140
static int PointInPolygon(double x[3], int numPts, double *pts, double bounds[6], double n[3])
Determine whether a point is inside the specified polygon.
bool ClipIfTrivial(double value, vtkDataArray *cellScalars, vtkIncrementalPointLocator *locator, vtkCellArray *tris, vtkPointData *inPD, vtkPointData *outPD, vtkCellData *inCD, vtkIdType cellId, vtkCellData *outCD, int insideOut)
Evaluate a polygon against a clip value without clipping it.
double ComputeArea()
Compute the area of a polygon.
@ PERIMETER2_TO_AREA_RATIO
Definition vtkPolygon.h:446
int GetCellType() override
See the vtkCell API for descriptions of these methods.
Definition vtkPolygon.h:149
void Clip(double value, vtkDataArray *cellScalars, vtkIncrementalPointLocator *locator, vtkCellArray *tris, vtkPointData *inPd, vtkPointData *outPd, vtkCellData *inCd, vtkIdType cellId, vtkCellData *outCd, int insideOut) override
See the vtkCell API for descriptions of these methods.
static vtkIdType EarClipTriangleCount(const PointsRange &points, CellIter cell, int cellSize, std::vector< int > &ring)
Templated, allocation-free ear-clip triangulation of a simple (possibly non-convex) 3D polygon,...
Definition vtkPolygon.h:561
static bool IsConvex(vtkPoints *p, int numPts, const vtkIdType *pts)
Determine whether or not a polygon is convex.
int CellBoundary(int subId, const double pcoords[3], vtkIdList *pts) override
See the vtkCell API for descriptions of these methods.
int UnbiasedEarCutTriangulation(int seed, int measure=PERIMETER2_TO_AREA_RATIO)
A fast triangulation method.
static int IntersectPolygonWithPolygon(int npts, double *pts, double bounds[6], int npts2, double *pts2, double bounds2[6], double tol, double x[3])
Method intersects two polygons.
int GetNumberOfEdges() override
See the vtkCell API for descriptions of these methods.
Definition vtkPolygon.h:151
static bool IsConvex(vtkPoints *p)
Determine whether or not a polygon is convex.
int Triangulate(int index, vtkIdList *ptIds, vtkPoints *pts) override
Generate simplices of proper dimension.
Definition vtkPolygon.h:332
void ComputeTolerance()
bool UseMVCInterpolation
Definition vtkPolygon.h:435
double Tolerance
Definition vtkPolygon.h:417
void InterpolateFunctionsUsingMVC(const double x[3], double *weights)
static vtkCellStatus ComputeNormal(vtkPoints *p, double n[3])
Computes the unit normal to the polygon.
static int CompactPolygonRing(const PointsRange &points, CellIter cell, int cellSize, std::vector< int > &ring)
Templated, allocation-free ear-clip triangulation of a simple (possibly non-convex) 3D polygon,...
Definition vtkPolygon.h:523
int IsPrimaryCell() VTK_FUTURE_CONST override
See the vtkCell API for descriptions of these methods.
Definition vtkPolygon.h:170
int GetNumberOfFaces() override
See the vtkCell API for descriptions of these methods.
Definition vtkPolygon.h:152
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.
vtkSmartPointer< vtkIdList > Tris
Definition vtkPolygon.h:422
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
int NonDegenerateTriangulate(vtkIdList *outTris)
Same as Triangulate(vtkIdList *outTris) but with a first pass to split the polygon into non-degenerat...
int GetCellDimension() override
See the vtkCell API for descriptions of these methods.
Definition vtkPolygon.h:150
static double DistanceToPolygon(double x[3], int numPts, double *pts, double bounds[6], double closest[3])
Compute the distance of a point to a polygon.
int SuccessfulTriangulation
Definition vtkPolygon.h:421
vtkCell * GetEdge(int edgeId) override
See the vtkCell API for descriptions of these methods.
~vtkPolygon() override=default
vtkSmartPointer< vtkTriangle > Triangle
Definition vtkPolygon.h:425
void EvaluateLocation(int &subId, const double pcoords[3], double x[3], double *weights) override
See the vtkCell API for descriptions of these methods.
vtkSmartPointer< vtkLine > Line
Definition vtkPolygon.h:428
int TriangulateLocalIds(int index, vtkIdList *ptIds) override
See the vtkCell API for descriptions of these methods.
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.
static vtkCellStatus ComputeNormal(vtkPoints *p, int numPts, const vtkIdType *pts, double n[3])
Computes the unit normal to the polygon.
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.
static bool IsConvex(vtkIdTypeArray *ids, vtkPoints *p)
Determine whether or not a polygon is convex.
static double ComputeArea(int numPts, double *pts, double normal[3])
Compute the area of a polygon from a flat array of 3D point coordinates (packed as x0,...
int IntersectWithLine(const double p1[3], const double p2[3], double tol, double &t, double x[3], double pcoords[3], int &subId) override
See the vtkCell API for descriptions of these methods.
int ParameterizePolygon(double p0[3], double p10[3], double &l10, double p20[3], double &l20, double n[3])
Create a local s-t coordinate system for a polygon.
vtkSmartPointer< vtkDoubleArray > TriScalars
Definition vtkPolygon.h:427
int EarCutTriangulation(vtkIdList *outTris, int measure=PERIMETER2_TO_AREA_RATIO)
A fast triangulation method.
static void EarClipPolygon3D(const PointsRange &points, CellIter cell, int cellSize, std::vector< int > &prevBuf, std::vector< int > &nextBuf, std::vector< int > &ring, EmitFn &&emit)
Templated, allocation-free ear-clip triangulation of a simple (possibly non-convex) 3D polygon,...
Definition vtkPolygon.h:570
vtkSmartPointer< vtkQuad > Quad
Definition vtkPolygon.h:426
static vtkCellStatus ComputeNormal(vtkIdTypeArray *ids, vtkPoints *pts, double n[3])
Computes the unit normal to the polygon.
int BoundedTriangulate(vtkIdList *outTris, double tol)
Triangulate polygon and enforce that the ratio of the smallest triangle area to the polygon area is g...
int EarCutTriangulation(int measure=PERIMETER2_TO_AREA_RATIO)
A fast triangulation method.
vtkCell * GetFace(int) override
See the vtkCell API for descriptions of these methods.
Definition vtkPolygon.h:154
static bool ComputeCentroid(vtkPoints *p, int numPts, const vtkIdType *pts, double centroid[3])
Compute the centroid of a set of points.
vtkSmartPointer< vtkCellData > ScratchCD
Definition vtkPolygon.h:431
static double ComputeArea(vtkPoints *p, vtkIdType numPts, const vtkIdType *pts, double normal[3])
Compute the area of a polygon in 3D.
void InterpolateFunctions(const double x[3], double *sf) override
Compute the interpolation functions/derivatives.
bool IsConvex()
Determine whether or not a polygon is convex.
vtkSmartPointer< vtkCellArray > ClippedTris
Definition vtkPolygon.h:430
static bool ComputeCentroid(vtkIdTypeArray *ids, vtkPoints *pts, double centroid[3])
Compute the centroid of a set of points.
static vtkCellStatus ComputeNormal(int numPts, double *pts, double n[3])
Compute the polygon normal from an array of points.
int UnbiasedEarCutTriangulation(int seed, vtkIdList *outTris, int measure=PERIMETER2_TO_AREA_RATIO)
A fast triangulation method.
static vtkPolygon * New()
static bool ComputeInteriorCircle(vtkPoints *p, int numPts, const vtkIdType *ids, double center[3], double &radius2)
Compute a circle interior to a polygon.
double Tol
Definition vtkPolygon.h:418
static vtkCellStatus ComputeCentroid(vtkPoints *p, int numPts, const vtkIdType *pts, double centroid[3], double tolerance)
Compute the centroid of a set of points.
vtkSmartPointer< vtkPriorityQueue > EarClipQueue
Definition vtkPolygon.h:429
static int IntersectConvex2DCells(vtkCell *cell1, vtkCell *cell2, double tol, double p0[3], double p1[3])
Intersect two convex 2D polygons to produce a line segment as output.
a list of ids arranged in priority order
a cell that represents a 2D quadrilateral
Definition vtkQuad.h:87
Hold a reference to a vtkObjectBase instance.
a cell that represents a triangle
vtkCellStatus
Diagnostic values indicating how well-specified a cell is.
@ VTK_POLYGON
Definition vtkCellType.h:44
#define vtkDataArray
int vtkIdType
Definition vtkType.h:363