46 #ifndef vtkVoronoiHull_h
47 #define vtkVoronoiHull_h
50 #include "vtkFiltersMeshingModule.h"
56 VTK_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>;
244 , PruneTolerance(1.0e-13)
245 , RecomputeCircumFlower(
true)
246 , RecomputePetals(
true)
252 this->Points.reserve(256);
253 this->Faces.reserve(256);
254 this->FacePoints.reserve(2048);
255 this->InProcessPoints.reserve(256);
256 this->InProcessFaces.reserve(256);
257 this->DeletedPoints.Reserve(256);
258 this->DeletedFaces.Reserve(256);
261 this->SortP.reserve(256);
263 this->Petals->SetNumberOfComponents(4);
264 this->Petals->ReserveValues(256);
274 , PruneTolerance(1.0e-13)
275 , RecomputeCircumFlower(
true)
276 , RecomputePetals(
true)
282 this->Points.reserve(256);
283 this->Faces.reserve(256);
284 this->FacePoints.reserve(2048);
285 this->InProcessPoints.reserve(256);
286 this->InProcessFaces.reserve(256);
287 this->DeletedPoints.Reserve(256);
288 this->DeletedFaces.Reserve(256);
291 this->SortP.reserve(256);
293 this->Petals->SetNumberOfComponents(4);
294 this->Petals->ReserveTuples(256);
304 void Initialize(
vtkIdType genPtId,
const double genPt[3],
double bds[6]);
327 if (this->RecomputeCircumFlower)
329 this->ComputeCircumFlower();
331 return (r2 <= this->CircumFlower2);
333 bool InFlower(
const double x[3]);
334 void UpdatePetals(
double cf2);
337 if (this->RecomputePetals)
339 this->UpdatePetals(this->CircumFlower2);
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); }
414 std::function<void(vtkVoronoiHull& hull, int, int, int)>
Function;
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);
510 this->FacePoints[face->
Points + idx] = ptId;
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));
554 void RebuildFace(
int faceId,
int startIdx,
int numKeptPts);
561 int IntersectFaceEdge(
int faceId,
int p0,
int p1);
567 void AllocatePointIds(
int npts,
vtkHullFace& face);
574 int MIN_POINTIDS_ALLOC = 10;
589 void ComputeCircumFlower();
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);
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);
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)
881 VTK_ABI_NAMESPACE_END
vtkIdType AddNewPoint(double x[3])
ProcessingStatus
Clipping plane operations result in the dynamic deletion, modification, and addition of points and fa...
bool operator!=(const vtkHullEdgeTuple &et) const
bool IsEdge(vtkIdType v0, vtkIdType v1) const
vtkVoronoiHull & operator=(const vtkVoronoiHull &)
vtkVoronoiHull(const vtkVoronoiHull &)
vtkSMPTools require a proper operator= and copy constructor.
DeletionStack DeletedPoints
Represent a point/vertex of the Voronoi polyhedron.
std::vector< vtkHullFace > vtkHullFacesArray
void AddFacePoint(vtkHullFace *face, vtkIdType ptId)
Add a point id defining the current face.
vtkHullFace(vtkIdType neiId)
Represent a face composing the polyhedron.
bool AddFace(vtkVoronoiHull *hull, int faceId)
std::vector< vtkHullPoint * > SortP
The polyhedron class proper.
std::vector< int > FacePointsArray
void SetPointFaces(vtkIdType pId, vtkIdType f0, vtkIdType f1, vtkIdType f2)
std::vector< int > FaceScratchArray
InsertedEdgePointsArray InsertedEdgePoints
void DeleteFace(int faceId, int startIdx, int numKeptPts)
Delete a face from the polyhedron.
void InsertNextTuple4(double val0, double val1, double val2, double val3)
These methods are included as convenience for the wrappers.
vtkSmartPointer< vtkDoubleArray > Petals
bool operator==(int faceId) const
Unique list of faces (by id) that require processing.
FaceScratchArray FaceIdsBuffer
bool operator==(const vtkHullEdgeTuple &et) const
concrete dataset represents vertices, lines, polygons, and triangle strips
int AddNewFace(vtkIdType npts, vtkIdType neiPtId)
Methods to create, modify, and delete polyhedron faces.
static vtkSmartPointer< T > New()
Create an instance of a VTK object.
vtkVoronoiRandom01Range Bumper
bool InFlower(const double x[3])
bool AddPoint(vtkVoronoiHull *hull, vtkHullPoint &point, int ptId)
Add points to be processed.
void Replace(vtkIdType neiPtId)
vtkHullPoint(double x, double y, double z)
dynamic, self-adjusting array of double
void RebuildFace(int faceId, int startIdx, int numKeptPts)
Rebuild a convex, intersected face after a clipping operation.
vtkDoubleArray * GetPetals()
void UpdatePetals(double cf2)
vtkVoronoiHull()
Constructor.
FaceOperation(int faceId)
void ComputeCircumFlower()
bool InCircumFlower(double r2)
Represent a polyhedral edge intersected by the current clipping plane.
void MapPoints()
Used to produce debugging output (e.g., generate vtkPolyData).
void Replace(double x, double y, double z)
DeletionStack DeletedFaces
vtkHullPointsArray Points
Keep track of points and faces currently being operated on.
vtkHullPoint(double x[3])
std::vector< vtkHullEdgeTuple > InsertedEdgePointsArray
void Reset()
Reset to an empty state, without freeing any memory.
ClipIntersectionStatus
Classes, structs, and typedefs in support of Voronoi processing.
vtkIdType AddNewPoint(double x, double y, double z)
Methods to add and delete polyhedron points.
int GetFacePoint(vtkHullFace *face, int ptNum)
Return the nth point id defining the current face.
A homebrew stack with a preferred API.
void RebuildFacePoints(vtkHullFace *face, FaceScratchArray &idsBuffer)
After clipping, rebuild the face.
double GetCircumFlower2()
Methods to determine whether a point x[3] is within the Voronoi flower, or Voronoi circumflower...
bool RecomputeCircumFlower
vtkHullEdgeTuple(vtkIdType v0, vtkIdType v1)
std::vector< vtkHullPoint > vtkHullPointsArray
vtkHullFace * GetFace(int faceId)
void Clear()
Empty out the polyhedron: clear memory but leave allocation intact.
int EvaluateFace(vtkHullFace *face, int &startIdx, int &numKeptPts)
After a face clipping operation, characterize the face, and provide information for subsequent proces...
static ReturnTypeT Distance2BetweenPoints(const TupleRangeT1 &p1, const TupleRangeT2 &p2)
Compute distance squared between two points p1 and p2.
FaceProcessingArray InProcessFaces
void AllocatePointIds(int npts, vtkHullFace &face)
Internal memory operation to allocate space when adding new points (due to a reabuild) which define a...
void AddNthFacePoint(vtkHullFace *face, int idx, vtkIdType ptId)
Add the nth point id defining the current face.
PointProcessingArray InProcessPoints
void DeletePoint(vtkIdType ptId)
std::function< void(vtkVoronoiHull &hull, int, int, int)> Function
FacePointsArray FacePoints
Internal data members.