10 #ifndef __GU_ConvexHull3D_h__
11 #define __GU_ConvexHull3D_h__
39 int npoints,
bool remove_inline);
42 { computeAndShrink(shrink_amount, points.
data(), points.
entries(), remove_inline); }
46 void computeAndShrink(
52 void computeAndShrink(
59 void expand(
fpreal expand_amount);
85 return myPoints(myVertices(vtx));
121 for (
auto && pt : pts)
133 if (poly.nvertices() < 3)
138 for (
exint vtx = 0; vtx < poly.nvertices(); vtx++)
147 for (
exint vtx = 0; vtx < poly.nvertices(); vtx++)
183 plane.shiftOffset(offset);
188 template <
typename S>
196 dist =
SYSmax(dist, plane.distance(pos));
203 template <
typename S>
211 dist =
SYSmax(dist, plane.distance(pos));
221 template <
typename IDX,
typename S>
227 for (
auto && idx : activeplanes)
243 template <
typename IDX,
typename S>
248 bool allinside =
true;
250 activeplanes.
clear();
253 T dist = plane.distance(pos);
254 if (dist >= -rad && dist < rad)
258 else if (dist >= rad)
262 activeplanes.
clear();
273 template <
typename S>
281 T bboxrad = (bmax - bmin).
length() / 2;
283 T centerdist =
distance(center, bboxrad);
286 if (centerdist <= -bboxrad)
291 if (centerdist >= bboxrad)
299 for (
int i = 0; i < 8; i++)
302 i & 2 ? bmin.y() : bmax.y(),
303 i & 4 ? bmin.z() : bmax.z() );
310 template <
typename S>
322 template <
typename S>
353 return f.
format(writer,
"[{}]", {tmp.
str()});
360 template <
typename T>
363 return h.
format(buffer, bufsize);
GA_API const UT_StringHolder dist
bool findActivePlanes(UT_Array< IDX > &activeplanes, UT_Vector3T< S > pos, T rad) const
const UT_Array< int > & getVertices() const
GLenum GLuint GLsizei bufsize
GLdouble GLdouble GLint GLint const GLdouble * points
const UT_Array< UT_Vector3D > & getPoints() const
Returns a list of the points in the convex hull.
Axis-aligned bounding box (AABB).
bool excludes(const UT_BoundingBoxT< S > &bbox) const
size_t format(char *buffer, size_t bufsize) const
void computeAndShrink(fpreal shrink_amount, const UT_Vector3DArray &points, bool remove_inline)
bool contains(const UT_BoundingBoxT< S > &bbox) const
UT_Vector3T< T > maxvec() const
GLuint GLsizei GLsizei * length
An output stream object that owns its own string buffer storage.
size_t format(char *buffer, size_t bufsize, const GU_ConvexHullHalfPlanesT< T > &h)
constexpr SYS_FORCE_INLINE T length() const noexcept
const UT_WorkBuffer & str()
Returns a read-only reference to the underlying UT_WorkBuffer.
T distance(const UT_Array< IDX > &activeplanes, UT_Vector3T< S > pos, T maxdist) const
A range of elements in an index-map.
static int entries()
Returns the vector size.
UT_Array< UT_PlaneT< T > > myPlanes
T distance(UT_Vector3T< S > pos) const
Return signed distance for the convex hull.
T distance(UT_Vector3T< S > pos, T maxdist) const
GA_API const UT_StringHolder transform
void applyOffset(T offset)
exint entries() const
Alias of size(). size() is preferred.
GLfloat GLfloat GLfloat GLfloat h
const UT_Array< int > & getPointSources() const
Returns the source point index for each point in the convex hull.
UT_Vector3T< T > minvec() const
void addPlane(const UT_PlaneT< T > &plane)
void computeAndShrink(fpreal shrink_amount, const UT_Vector3D *points, int npoints, bool remove_inline)
SYS_FORCE_INLINE UT_StorageMathFloat_t< T > normalize() noexcept
GU_ConvexHullHalfPlanesT(const UT_Vector3DArray &pts)
Build from a cloud of points.
void clear()
Resets list to an empty list.
SYS_FORCE_INLINE void normal(const UT_Vector3T< T > &va, const UT_Vector3T< T > &vb)
GU_ConvexHullHalfPlanesT(const UT_Array< UT_PlaneT< T >> &planes)
Directly build from a set of directed half planes.
T distance(const UT_Vector3T< T > &p) const
const GEO_PolyCounts & getPolygonSizes() const
Returns a list of the polygons in the convex hull.
bool excludes(UT_Vector3T< S > pos, T radius=0) const