46#ifndef vtkVoronoiHull_h
47#define vtkVoronoiHull_h
50#include "vtkFiltersMeshingModule.h"
56VTK_ABI_NAMESPACE_BEGIN
102 ,
Faces{ -1, -1, -1 }
107 :
X{ x[0], x[1], x[2] }
111 ,
Faces{ -1, -1, -1 }
125 this->Faces[0] = (-1);
126 this->Faces[1] = (-1);
127 this->Faces[2] = (-1);
160 this->NeiId = neiPtId;
196 if (this->V0 > this->V1)
198 std::swap(this->V0, this->V1);
203 return this->V0 == et.
V0 && this->V1 == et.
V1;
207 return this->V0 != et.
V0 || this->V1 != et.
V1;
213 return (this->V0 == v0 && this->V1 == v1);
217 return (this->V0 == v1 && this->V1 == v0);
230 std::vector<vtkHullPoint>;
252 this->
Points.reserve(256);
253 this->
Faces.reserve(256);
261 this->
SortP.reserve(256);
263 this->
Petals->SetNumberOfComponents(4);
264 this->
Petals->Allocate(256);
301 bool InFlower(
const double x[3]);
302 void UpdatePetals(
double cf2);
309 return (this->
Petals->GetNumberOfTuples() > 0 ? this->Petals :
nullptr);
343 void BumpNormal(
int bumpNum,
double normal[3],
double bumpNormal[3]);
344 void BumpOrigin(
int bumpNum,
double origin[3],
double bumpOrigin[3]);
361 void Push(
int id) { this->Stack.emplace_back(
id); }
365 this->Stack.pop_back();
368 bool IsEmpty() {
return (this->Stack.empty()); }
369 void Clear() { this->Stack.clear(); }
370 void Reserve(
int sze) { this->Stack.reserve(sze); }
394 bool operator==(
int faceId)
const {
return (this->FaceId == faceId); }
407 if (std::find(this->begin(), this->end(), faceId) == this->end())
415 else if (numInts == 2)
437 this->emplace_back(ptId);
454 vtkIdType AddNewPoint(
double x,
double y,
double z);
488 void RebuildFacePoints(
vtkHullFace* face, FaceScratchArray& idsBuffer);
504 int EvaluateFace(
vtkHullFace* face,
int& startIdx,
int& numKeptPts);
513 void DeleteFace(
int faceId,
int vtkNotUsed(startIdx),
int vtkNotUsed(numKeptPts));
574 this->Points.clear();
577 this->FacePoints.clear();
578 this->DeletedPoints.
Clear();
579 this->DeletedFaces.
Clear();
594 this->Points[pId].Faces[0] = f0;
595 this->Points[pId].Faces[1] = f1;
596 this->Points[pId].Faces[2] = f2;
606 id = this->Points.size();
607 this->Points.emplace_back(x, y, z);
613 this->Points[id].Replace(x, y, z);
642 id = this->Faces.size();
643 this->Faces.emplace_back(neiPtId);
649 this->Faces[id].Replace(neiPtId);
660 startIdx = numKeptPts = 0;
661 int npts = face->
NumPts, numEdgeInts = 0;
665 for (
int i = 0; i < npts; ++i)
668 ip = ((i + 1) == npts ? 0 : (i + 1));
671 val0 = this->Points[p0].Val;
672 val1 = this->Points[p1].Val;
679 if (val0 > 0 && val1 <= 0)
684 else if (val0 <= 0 && val1 > 0)
714 int npts =
static_cast<int>(idsBuffer.size());
747 for (
const auto& pt : this->Points)
751 this->
MinRadius2 = std::min(pt.R2, this->MinRadius2);
752 this->
MaxRadius2 = std::max(pt.R2, this->MaxRadius2);
763 for (
const auto& pt : this->Points)
784 for (
auto& pitr : this->Points)
808 constexpr double SphereRatio = 2.0, SphereRatio2 = SphereRatio * SphereRatio;
815 constexpr double LargeSphereRatio = 0.25;
816 int maxLargeSpheres = LargeSphereRatio * this->NumPts;
820 for (
auto& pt : this->Points)
825 if ((4 * pt.R2) >= cf2)
827 minR2 = std::min(pt.R2, minR2);
828 maxR2 = std::max(pt.R2, maxR2);
829 this->
SortP.emplace_back(&pt);
834 if (
static_cast<int>(this->
SortP.size()) > maxLargeSpheres || (maxR2 / minR2) < SphereRatio2)
840 std::sort(this->
SortP.begin(), this->SortP.end(),
842 for (
auto& pt : this->
SortP)
844 this->
Petals->InsertNextTuple4(pt->X[0], pt->X[1], pt->X[2], pt->R2);
dynamic, self-adjusting array of double
static ReturnTypeT Distance2BetweenPoints(const TupleRangeT1 &p1, const TupleRangeT2 &p2)
Compute distance squared between two points p1 and p2.
concrete dataset represents vertices, lines, polygons, and triangle strips
Hold a reference to a vtkObjectBase instance.
static vtkSmartPointer< T > New()
Create an instance of a VTK object.
std::vector< vtkHullFace > vtkHullFacesArray
vtkHullFace * GetFace(int faceId)
void ProducePolyData(vtkPolyData *pd)
Produce a vtkPolyData from the current polyhedron.
bool RecomputeCircumFlower
void AddFacePoint(vtkHullFace *face, vtkIdType ptId)
Add a point id defining the current face.
vtkHullPointsArray Points
vtkSmartPointer< vtkDoubleArray > Petals
ClipIntersectionStatus IntersectWithPlane(double origin[3], double normal[3], vtkIdType neiPtId)
The core geometric intersection operation.
FaceProcessingArray InProcessFaces
vtkVoronoiHull()
Constructor.
vtkIdType AddNewPoint(double x, double y, double z)
Methods to add and delete polyhedron points.
int EvaluateFace(vtkHullFace *face, int &startIdx, int &numKeptPts)
After a face clipping operation, characterize the face, and provide information for subsequent proces...
void UpdatePetals(double cf2)
void ComputeCircumFlower()
void SetPointFaces(vtkIdType pId, vtkIdType f0, vtkIdType f1, vtkIdType f2)
int IntersectFaceEdge(int faceId, int p0, int p1)
Given two point ids that form the edge of a polyhedron face, intersect the edge to produce a new inte...
DeletionStack DeletedFaces
std::vector< vtkHullPoint * > SortP
ClipIntersectionStatus Clip(vtkIdType neiPtId, const double neiPt[3])
Method to clip the current convex polyhedron/hull with a plane defined by a neighboring point.
int AddNewFace(vtkIdType npts, vtkIdType neiPtId)
Methods to create, modify, and delete polyhedron faces.
vtkVoronoiRandom01Range Bumper
std::vector< int > FaceScratchArray
void RebuildFace(int faceId, int startIdx, int numKeptPts)
Rebuild a convex, intersected face after a clipping operation.
FacePointsArray FacePoints
Internal data members.
bool InFlower(const double x[3])
void RebuildFacePoints(vtkHullFace *face, FaceScratchArray &idsBuffer)
After clipping, rebuild the face.
void Clear()
Empty out the polyhedron: clear memory but leave allocation intact.
int GetFacePoint(vtkHullFace *face, int ptNum)
Return the nth point id defining the current face.
void ProduceFacePolyData(vtkPolyData *pd, vtkHullFace *face)
Produce a vtkPolyData from the current polyhedron and one specified face.
void BumpNormal(int bumpNum, double normal[3], double bumpNormal[3])
void DeletePoint(vtkIdType ptId)
std::vector< int > FacePointsArray
vtkIdType AddNewPoint(double x[3])
DeletionStack DeletedPoints
void Initialize(vtkIdType genPtId, const double genPt[3], double bds[6])
Method to initiate the construction of the polyhedron.
void BumpOrigin(int bumpNum, double origin[3], double bumpOrigin[3])
FaceScratchArray FaceIdsBuffer
PointProcessingArray InProcessPoints
void MapPoints()
Used to produce debugging output (e.g., generate vtkPolyData).
vtkDoubleArray * GetPetals()
void DeleteFace(int faceId, int startIdx, int numKeptPts)
Delete a face from the polyhedron.
bool InCircumFlower(double r2)
std::vector< vtkHullEdgeTuple > InsertedEdgePointsArray
void AddNthFacePoint(vtkHullFace *face, int idx, vtkIdType ptId)
Add the nth point id defining the current face.
double GetCircumFlower2()
Methods to determine whether a point x[3] is within the Voronoi flower, or Voronoi circumflower.
InsertedEdgePointsArray InsertedEdgePoints
std::vector< vtkHullPoint > vtkHullPointsArray
void AllocatePointIds(int npts, vtkHullFace &face)
Internal memory operation to allocate space when adding new points (due to a reabuild) which define a...
bool operator!=(const vtkHullEdgeTuple &et) const
bool IsEdge(vtkIdType v0, vtkIdType v1) const
vtkHullEdgeTuple(vtkIdType v0, vtkIdType v1)
bool operator==(const vtkHullEdgeTuple &et) const
Represent a face composing the polyhedron.
void Replace(vtkIdType neiPtId)
vtkHullFace(vtkIdType neiId)
Represent a point/vertex of the Voronoi polyhedron.
vtkHullPoint(double x, double y, double z)
void Replace(double x, double y, double z)
vtkHullPoint(double x[3])
A homebrew stack with a preferred API.
Keep track of points and faces currently being operated on.
bool operator==(int faceId) const
std::function< void(vtkVoronoiHull &hull, int, int, int)> Function
FaceOperation(int faceId)
Unique list of faces (by id) that require processing.
bool AddFace(vtkVoronoiHull *hull, int faceId)
Add points to be processed.
bool AddPoint(vtkVoronoiHull *hull, vtkHullPoint &point, int ptId)
@ Valid
Cell is in a good state.
ClipIntersectionStatus
Classes, structs, and typedefs in support of Voronoi processing.
ProcessingStatus
Clipping plane operations result in the dynamic deletion, modification, and addition of points and fa...