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);
282 this->
Points.reserve(256);
283 this->
Faces.reserve(256);
291 this->
SortP.reserve(256);
293 this->
Petals->SetNumberOfComponents(4);
294 this->
Petals->Allocate(256);
333 bool InFlower(
const double x[3]);
334 void UpdatePetals(
double cf2);
341 return (this->
Petals->GetNumberOfTuples() > 0 ? this->Petals :
nullptr);
375 void BumpNormal(
int bumpNum,
double normal[3],
double bumpNormal[3]);
376 void BumpOrigin(
int bumpNum,
double origin[3],
double bumpOrigin[3]);
393 void Push(
int id) { this->Stack.emplace_back(
id); }
397 this->Stack.pop_back();
400 bool IsEmpty() {
return (this->Stack.empty()); }
401 void Clear() { this->Stack.clear(); }
402 void Reserve(
int sze) { this->Stack.reserve(sze); }
426 bool operator==(
int faceId)
const {
return (this->FaceId == faceId); }
439 if (std::find(this->begin(), this->end(), faceId) == this->end())
447 else if (numInts == 2)
469 this->emplace_back(ptId);
486 vtkIdType AddNewPoint(
double x,
double y,
double z);
520 void RebuildFacePoints(
vtkHullFace* face, FaceScratchArray& idsBuffer);
536 int EvaluateFace(
vtkHullFace* face,
int& startIdx,
int& numKeptPts);
545 void DeleteFace(
int faceId,
int vtkNotUsed(startIdx),
int vtkNotUsed(numKeptPts));
606 this->Points.clear();
609 this->FacePoints.clear();
610 this->DeletedPoints.
Clear();
611 this->DeletedFaces.
Clear();
626 this->Points[pId].Faces[0] = f0;
627 this->Points[pId].Faces[1] = f1;
628 this->Points[pId].Faces[2] = f2;
638 id = this->Points.size();
639 this->Points.emplace_back(x, y, z);
645 this->Points[id].Replace(x, y, z);
674 id = this->Faces.size();
675 this->Faces.emplace_back(neiPtId);
681 this->Faces[id].Replace(neiPtId);
692 startIdx = numKeptPts = 0;
693 int npts = face->
NumPts, numEdgeInts = 0;
697 for (
int i = 0; i < npts; ++i)
700 ip = ((i + 1) == npts ? 0 : (i + 1));
703 val0 = this->Points[p0].Val;
704 val1 = this->Points[p1].Val;
711 if (val0 > 0 && val1 <= 0)
716 else if (val0 <= 0 && val1 > 0)
746 int npts =
static_cast<int>(idsBuffer.size());
779 for (
const auto& pt : this->Points)
783 this->
MinRadius2 = std::min(pt.R2, this->MinRadius2);
784 this->
MaxRadius2 = std::max(pt.R2, this->MaxRadius2);
795 for (
const auto& pt : this->Points)
816 for (
auto& pitr : this->Points)
840 constexpr double SphereRatio = 2.0, SphereRatio2 = SphereRatio * SphereRatio;
847 constexpr double LargeSphereRatio = 0.25;
848 int maxLargeSpheres = LargeSphereRatio * this->NumPts;
852 for (
auto& pt : this->Points)
857 if ((4 * pt.R2) >= cf2)
859 minR2 = std::min(pt.R2, minR2);
860 maxR2 = std::max(pt.R2, maxR2);
861 this->
SortP.emplace_back(&pt);
866 if (
static_cast<int>(this->
SortP.size()) > maxLargeSpheres || (maxR2 / minR2) < SphereRatio2)
872 std::sort(this->
SortP.begin(), this->SortP.end(),
874 for (
auto& pt : this->
SortP)
876 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
vtkVoronoiHull(const vtkVoronoiHull &)
vtkSMPTools require a proper operator= and copy constructor.
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...
vtkVoronoiHull & operator=(const vtkVoronoiHull &)
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...