32 #define GEO_INVALID_HEDGE GEO_Hedge(GA_INVALID_OFFSET)
55 {
return mySrcVertex == h.mySrcVertex; }
59 {
return mySrcVertex != h.mySrcVertex; }
62 size_t hash()
const {
return SYShash(
int64(mySrcVertex)); }
83 #define GEO_INVALID_SHEDGE GEO_SHedge(GEO_INVALID_HEDGE, 1)
84 #define NEG_MASK (1ll << 62)
92 myBits(hedge.mySrcVertex) { setSign(
sign); }
96 int sign()
const {
return isPositive() ? 1 : -1; }
99 bool isValid()
const {
return myBits >= 0; }
102 void setSign(
int sign);
112 {
return myBits == other.myBits; }
116 {
return myBits != other.myBits; }
128 #ifndef SESI_LITTLE_ENDIAN
129 #error "Make sure the bitfields in the union work on big endian platforms!"
146 myBits = other.myBits;
181 return h.mySrcVertex;
212 template <
typename T>
220 template <
typename T>
228 template <
typename T>
238 return iface.polyNext(next_v);
241 template <
typename T>
246 return iface.vertexPoint(
dstVertex(iface, h));
249 template <
typename T>
257 template <
typename T>
265 template <
typename T>
273 template <
typename T>
281 template <
typename T>
286 if (iface.srcPoint(h) == pt)
287 return iface.lprev(h);
289 if (iface.dstPoint(h) == pt)
290 return iface.lnext(h);
295 template <
typename T>
300 auto dst1 = iface.dstPoint(h1);
301 auto src1 = iface.srcPoint(h1);
302 auto dst2 = iface.dstPoint(h2);
303 auto src2 = iface.srcPoint(h2);
304 return ((dst1 == dst2 && src1 == src2) || (dst1 == src2 && src1 == dst2));
311 return iface.nextEquivalentHedge(h) ==
h;
318 GEO_Hedge h0 = iface.nextEquivalentHedge(h);
323 GA_Offset eprim = iface.vertexPrimitive(esrcv);
324 GA_Offset esrcp = iface.vertexPoint(esrcv);
329 if (iface.vertexPrimitive(e0srcv) == eprim &&
330 iface.vertexPoint(e0srcv) != esrcp)
332 h0 = iface.nextEquivalentHedge(h0);
343 GEO_Hedge ne = iface.nextEquivalentHedge(h);
348 if (iface.nextEquivalentHedge(ne) !=
h)
351 return (iface.srcPoint(h) != iface.srcPoint(ne));
364 h0 = iface.nextEquivalentHedge(h0);
370 template <
typename T>
375 auto dst1 = iface.dstPoint(h1);
376 auto src1 = iface.srcPoint(h1);
377 auto dst2 = iface.dstPoint(h2);
378 auto src2 = iface.srcPoint(h2);
379 return (src1 == dst2 && dst1 == src2);
390 template <
typename T>
394 for (
auto vtx = iface.pointVertex(pt);
GAisValid(vtx);
395 vtx = iface.vertexToNextVertex(vtx))
399 if (iface.isValidHedge(h) && iface.dstPoint(h) != pt)
404 if (iface.isValidHedge(hprev) && iface.srcPoint(hprev) != pt)
411 template <
typename T>
420 auto vnext = iface.polyNext(vtx, vprev);
425 if (iface.vertexPoint(vtx) == pt && iface.vertexPoint(vnext) != pt)
429 if (iface.isValidHedge(hprev) && iface.vertexPoint(vprev) != pt)
444 vtmp : iface.pointVertex(pt);
true;
445 v =
GAisValid(vtmp = iface.vertexToNextVertex(
v)) ? vtmp :
446 iface.pointVertex(pt))
450 if (iface.isValidHedge(h0) && iface.dstPoint(h0) != pt)
454 if (iface.isValidHedge(hprev) && iface.srcPoint(hprev) != pt)
472 template <
typename T>
477 if (!iface.isValidHedge(h))
480 while (!iface.isPrimary(h))
482 h = iface.nextIncidentHedge(h, pt);
486 if (!iface.isValidHedge(h))
492 template <
typename T>
496 GEO_Hedge h0 = iface.nextIncidentHedge(h, point);
497 if (!iface.isValidHedge(h0))
500 while (!iface.isPrimary(h0))
502 h0 = iface.nextIncidentHedge(h0, point);
503 if (!iface.isValidHedge(h0))
509 template <
typename T>
514 vtx = iface.vertexToNextVertex(vtx))
517 if (iface.isValidHedge(h))
523 template <
typename T>
531 GA_Offset point = iface.vertexPoint(vtx);
540 iface.pointVertex(point);
true;
541 v =
GAisValid(vtmp = iface.vertexToNextVertex(
v)) ? vtmp :
542 iface.pointVertex(point))
545 if (iface.isValidHedge(h0))
552 UT_ASSERT(0 &&
"Cotnrol should not reach this point!");
556 template <
typename T>
561 vtx = iface.vertexToNextVertex(vtx))
567 if (iface.isValidHedge(hprev))
574 template <
typename T>
582 GA_Offset point = iface.vertexPoint(vtx);
588 for (
auto v =
GAisValid(vtmp = iface.vertexToNextVertex(v0)) ? vtmp :
589 iface.pointVertex(point);
true;
590 v =
GAisValid(vtmp = iface.vertexToNextVertex(
v)) ? vtmp :
591 iface.pointVertex(point))
598 if (iface.isValidHedge(hprev))
606 UT_ASSERT(0 &&
"Cotnrol should not reach this point!");
615 GEO_Hedge hprev = iface.prevPrimitiveHedge(h);
616 if (!iface.isValidHedge(hprev))
618 GEO_Hedge hprevmate = iface.nextEquivalentHedge(hprev);
619 if (hprevmate == hprev ||
620 iface.nextEquivalentHedge(hprevmate) != hprev)
623 if (iface.srcPoint(hprev) != iface.dstPoint(hprevmate))
633 GEO_Hedge hmate = iface.nextEquivalentHedge(h);
634 if (!iface.isValidHedge(hmate))
636 if (hmate == h || iface.nextEquivalentHedge(hmate) !=
h)
639 if (iface.srcPoint(h) != iface.dstPoint(hmate))
642 GEO_Hedge hmatenext = iface.nextPrimitiveHedge(hmate);
643 if (!iface.isValidHedge(hmatenext))
652 GEO_Hedge hnext = iface.nextPrimitiveHedge(h);
653 if (!iface.isValidHedge(hnext))
655 GEO_Hedge hnextmate = iface.nextEquivalentHedge(hnext);
656 if (hnextmate == hnext ||
657 iface.nextEquivalentHedge(hnextmate) != hnext)
659 if (iface.srcPoint(hnext) != iface.dstPoint(hnextmate))
668 GEO_Hedge hmate = iface.nextEquivalentHedge(h);
669 if (hmate == h || iface.nextEquivalentHedge(hmate) !=
h)
671 if (iface.srcPoint(h) != iface.dstPoint(hmate))
673 GEO_Hedge hmateprev = iface.prevPrimitiveHedge(hmate);
674 if (!iface.isValidHedge(hmateprev))
687 if (!iface.isValidHedge(hprev))
702 if (!iface.isValidHedge(hprev))
709 template <
typename T>
714 auto gdp = iface.getDetail();
719 template <
typename T>
723 const GA_Detail *gdp = iface.getDetail();
725 auto v_next = iface.polyNext(v, v_prev);
733 v0 = gdp->
getPos3(iface.vertexPoint(v_prev)) - v0;
736 if (!nml ||
dot(v1,
cross(*nml, v0)) >= 0.0)
739 return (2.0 *
M_PI - angle);
749 template <
typename T>
754 return iface.getDetail()->getPos3(
dstPoint(iface, h));
757 template <
typename T>
764 template <
typename T>
778 return udotv >= 0.0 ? 1.0 : -1.0;
782 return udotv >= 0.0 ? 1.0 : -1.0;
784 return udotv/(ulen * vlen);
787 template <
typename T>
791 auto gdp = iface.getDetail();
797 template <
typename T>
801 auto gdp = iface.getDetail();
804 gdp->getPos3(
srcPoint(gdp, h)) - pos);
807 template <
typename T>
811 auto gdp = iface.getDetail();
813 v = gdp->vertexToNextVertex(
v))
816 auto v_next = iface.polyNext(
v, v_prev);
818 if (iface.vertexPoint(v_prev) == p1)
821 if (iface.vertexPoint(v_next) == p1)
827 template <
typename T>
831 GEO_Hedge h0 = iface.firstIncidentEdge(pt);
832 if (!iface.isValidHedge(h0))
836 GEO_Hedge h1 = iface.nextIncidentEdge(h0, pt);
840 h1 = iface.nextIncidentEdge(h1, pt);
845 template <
typename T>
849 GEO_Hedge h0 = iface.firstIncidentHedge(pt);
850 if (!iface.isValidHedge(h0))
854 GEO_Hedge h1 = iface.nextIncidentHedge(h0, pt);
858 h1 = iface.nextIncidentHedge(h1, pt);
GEO_Hedge prevManifoldOutgoingHedge(T &iface, GEO_Hedge h)
SYS_FORCE_INLINE fpreal length(T &iface, GEO_Hedge h)
SYS_FORCE_INLINE GA_Offset hedgePrimitiveOffset(const GA_Detail *gdp, GEO_Hedge h)
SYS_FORCE_INLINE GEO_Hedge coincidentPolyHedge(T &iface, GEO_Hedge h, GA_Offset pt)
GEO_Hedge firstOutgoingHedge(T &iface, GA_Offset point)
SYS_FORCE_INLINE GA_Offset srcPoint(const GA_Detail *gdp, GEO_Hedge h)
SYS_FORCE_INLINE GA_Offset postDstPoint(T &iface, GEO_Hedge h)
GEO_Hedge firstManifoldOutgoingHedge(T &iface, GEO_Hedge h)
GA_Size numIncidentEdges(T &iface, GA_Offset pt)
SYS_FORCE_INLINE GA_Primitive * getPrimitive(GA_Offset prim_off)
SYS_FORCE_INLINE bool operator!=(GEO_Hedge h) const
SYS_FORCE_INLINE UT_Vector3 dstPos3(T &iface, GEO_Hedge h)
SIM_API const UT_StringHolder angle
T distance3d(const UT_Vector3T< T > &p1, const UT_Vector3T< T > &p2)
Compute the distance between two points.
SYS_FORCE_INLINE size_t hash_value(const GEO_Hedge &h)
SYS_FORCE_INLINE GA_Offset postDstVertex(T &iface, GEO_Hedge h)
GA_Size numIncidentHedges(T &iface, GA_Offset pt)
fpreal64 UTangleBetween(const UT_Vector3T< T > &v1, const UT_Vector3T< T > &v2)
The angle between two vectors in radians.
GA_Offset srcVertex(GEO_Hedge)
GEO_Hedge nextIncomingHedge(T &iface, GEO_Hedge h)
SYS_FORCE_INLINE GEO_Hedge nextPrimitiveHedge(T &iface, GEO_Hedge h)
GEO_Hedge nextManifoldOutgoingHedge(T &iface, GEO_Hedge h)
SYS_FORCE_INLINE const GA_Primitive * hedgePrimitive(const GA_Detail *gdp, GEO_Hedge h)
constexpr GEO_Hedge(GA_Offset vtx)
SYS_FORCE_INLINE GA_Offset preSrcPoint(T &iface, GEO_Hedge h)
SYS_FORCE_INLINE UT_Vector3 srcPos3(const GA_Detail *gdp, GEO_Hedge h)
SYS_FORCE_INLINE GA_Offset preSrcVertex(T &iface, GEO_Hedge h)
constexpr SYS_FORCE_INLINE T length() const noexcept
GEO_SHedge(GEO_Hedge hedge, int sign=1)
bool isBridgeHedge(T &iface, GEO_Hedge h)
#define GEO_INVALID_HEDGE
An invalid hedge is sometimes returned if an operation is unsuccessful.
SYS_FORCE_INLINE size_t hash() const
SYS_FORCE_INLINE void setSign(int sign)
SYS_FORCE_INLINE UT_Vector3 getPos3(GA_Offset ptoff) const
The ptoff passed is the point offset.
SYS_FORCE_INLINE bool operator==(GEO_Hedge h) const
bool isNegative(const Type &x)
Return true if x is less than zero.
SYS_FORCE_INLINE bool GAisValid(GA_Size v)
exint GA_Size
Defines the bit width for index and offset types in GA.
GEO_Hedge nextManifoldIncomingHedge(T &iface, GEO_Hedge h)
#define GA_INVALID_OFFSET
SYS_FORCE_INLINE fpreal srcPrimitiveAngleCos(T &iface, GEO_Hedge h)
#define UT_ASSERT_MSG(ZZ,...)
GEO_Hedge firstManifoldIncomingHedge(T &iface, GEO_Hedge h)
SYS_FORCE_INLINE bool operator!=(const GEO_SHedge &other) const
SYS_FORCE_INLINE fpreal srcPrimitiveAngle(T &iface, GEO_Hedge h, UT_Vector3 *nml)
SYS_FORCE_INLINE bool areOpposite(T &iface, GEO_Hedge h1, GEO_Hedge h2)
GEO_Hedge encapsulates a half-edge (hedge) which is the restriction of.
fpreal64 dot(const CE_VectorT< T > &a, const CE_VectorT< T > &b)
SYS_FORCE_INLINE GA_Size numEquivalentHedges(T &iface, GEO_Hedge h)
SYS_FORCE_INLINE fpreal vertexAngle(T &iface, GA_Offset v, UT_Vector3 *nml)
SYS_FORCE_INLINE GEO_SHedge operator-()
SYS_FORCE_INLINE fpreal dstPrimitiveAngleCos(T &iface, GEO_Hedge h)
SYS_FORCE_INLINE fpreal angleCos(const UT_Vector3 &u, const UT_Vector3 &v)
GEO_Hedge nextIncidentEdge(T &iface, GEO_Hedge h, GA_Offset point)
GEO_Hedge nextIncidentHedge(T &iface, GEO_Hedge h, GA_Offset pt)
SYS_FORCE_INLINE GA_Offset vertexPoint(GA_Offset vertex) const
Given a vertex, return the point it references.
GEO_Hedge firstIncomingHedge(T &iface, GA_Offset pt)
IMATH_HOSTDEVICE constexpr int sign(T a) IMATH_NOEXCEPT
SYS_FORCE_INLINE GA_Offset dstVertex(T &iface, GEO_Hedge h)
SYS_FORCE_INLINE fpreal dstPrimitiveAngle(T &iface, GEO_Hedge h, UT_Vector3 *nml)
bool SYSequalZero(const UT_Vector3T< T > &v)
SYS_FORCE_INLINE bool isManifoldHedge(T &iface, GEO_Hedge h, bool accept_bd)
SYS_FORCE_INLINE size_t hash() const
GLfloat GLfloat GLfloat GLfloat h
SYS_FORCE_INLINE GA_Offset vertexPrimitive(GA_Offset vertex) const
GEO_Hedge nextOutgoingHedge(T &iface, GEO_Hedge h)
GEO_Hedge prevManifoldIncomingHedge(T &iface, GEO_Hedge h)
GEO_Hedge findHedgeWithEndpoints(T &iface, GA_Offset p0, GA_Offset p1)
LeafData & operator=(const LeafData &)=delete
GEO_Hedge firstIncidentEdge(T &iface, GA_Offset pt)
SYS_FORCE_INLINE bool areEquivalent(T &iface, GEO_Hedge h1, GEO_Hedge h2)
Container class for all geometry.
SYS_FORCE_INLINE GEO_SHedge & operator=(const GEO_SHedge &other)
GEO_Hedge firstIncidentHedge(T &iface, GA_Offset pt)
SYS_FORCE_INLINE GEO_Hedge hedge() const
SYS_FORCE_INLINE GEO_Hedge prevPrimitiveHedge(T &iface, GEO_Hedge h)
SIM_DerVector3 cross(const SIM_DerVector3 &lhs, const SIM_DerVector3 &rhs)
SYS_FORCE_INLINE bool operator==(const GEO_SHedge &other) const
SYS_FORCE_INLINE GA_Offset dstPoint(T &iface, GEO_Hedge h)
SYS_FORCE_INLINE bool isBoundaryHedge(T &iface, GEO_Hedge h)