13 #ifndef __GU_PathFinder__
14 #define __GU_PathFinder__
87 template <
class T = gu_ShortestPathCost>
101 mySHedge(sh), myPrev(prev) { myPathCost.zero(); }
104 mySHedge(sh), myPrev(prev), myPathCost(cost) { }
107 {
return (p1.myPathCost > p2.myPathCost); }
145 void setStartHedge(
const GU_PathHedge& sh,
bool and_equiv =
true);
146 void setEndHedge(
const GU_PathHedge& eh,
bool and_equiv =
true);
155 bool and_reverse =
false);
157 bool and_reverse =
false);
179 void clearStartSHedges();
181 bool and_reverse =
false);
183 void clearEndSHedges();
184 void addEndSHedge(
const GU_PathSHedge& sh,
bool and_reverse =
false);
200 { myAvoidPoints = grp; }
204 { myAvoidEdges = grp; }
208 { myAvoidPrimitives = grp; }
212 { myAvoidVertices = grp; }
223 if (edgegrp && edgegrp->
entries())
226 if (vtxgrp && vtxgrp->
entries())
227 avoidVertices(vtxgrp);
229 if (primgrp && primgrp->
entries())
230 avoidPrimitives(primgrp);
235 avoidPoints(
nullptr);
237 avoidPrimitives(
nullptr);
238 avoidVertices(
nullptr);
243 myCollisionPoints =
nullptr;
244 myCollisionPrimitives =
nullptr;
245 myCollisionVertices =
nullptr;
246 myCollisionEdges =
nullptr;
247 myCollisionGroup = group;
248 myExcludeCollisionGroup = exclude;
249 myCollisionStrong = strong;
256 myCollisionPoints =
static_cast<const GA_PointGroup *
>(group);
265 myCollisionEdges =
static_cast<const GA_EdgeGroup *
>(group);
275 void reset(
bool heap_only =
false);
279 {
return myStartSHedges; }
292 bool trim_crossing =
true);
297 bool trim_crossing =
true,
298 bool is_for_prim_loo =
false);
316 void initializeEdgeHeap();
327 {
return myDhip->isValidHedge(getPrev(sh).hedge()); }
369 {
return pt == myDhip->srcPoint(h) ? 1 : -1; }
374 {
return GA_Edge(myDhip->srcPoint(h),
375 myDhip->dstPoint(h)); }
408 bool myLastStartSHedgeFlag =
false;
411 bool myLastStartHedgeFlag =
false;
413 bool myStartOnBoundary =
false;
414 bool myEndOnBoundary =
false;
432 const GA_Group * myCollisionGroup =
nullptr;
436 bool myExcludeCollisionGroup =
true;
440 bool myCollisionStrong =
false;
442 SuccessorMask mySuccessorTypeMask;
459 void zero() { myLength = 0.0; }
465 bool isSet() {
return myLength > -0.5; }
469 {
return myLength > c.myLength; }
478 myLength += c.myLength;
506 myPathLength(dhip->
length(sh.hedge())) { }
509 myPathLength(len), myPenalty(bends) { }
512 myPathLength(c.myPathLength),
513 myPenalty(c.myPenalty) { }
523 void unset() { myPathLength = -1.0; }
526 bool isSet() {
return myPathLength > -0.5; }
531 if (myPenalty != c.myPenalty)
532 return myPenalty > c.myPenalty;
534 return myPathLength > c.myPathLength;
543 myPenalty += c.myPenalty;
544 myPathLength += c.myPathLength;
562 if (!sided_quad_succ.
isValid())
569 bool to_sided_quad_succ = (sided_quad_succ.
isValid() &&
572 bool to_opposite = opposite.
isValid() &&
575 if (to_sided_quad_succ)
588 fpreal myPathLength = -1.0;
601 myPathLength(dhip->
length(sh.hedge())) { }
604 myPathLength(len), myPenalty(bends) { }
617 void unset() { myPathLength = -1.0; }
620 bool isSet() {
return myPathLength > -0.5; }
625 if (myPenalty != c.myPenalty)
626 return myPenalty > c.myPenalty;
628 return myPathLength > c.myPathLength;
637 myPenalty += c.myPenalty;
638 myPathLength += c.myPathLength;
652 bool to_bd_succ = bd_succ.
isValid() &&
659 if (!sided_quad_succ.
isValid())
666 bool to_sided_quad_succ = (sided_quad_succ.
isValid() &&
669 bool to_opposite = opposite.
isValid() &&
672 if (to_sided_quad_succ)
685 fpreal myPathLength = -1.0;
697 if (myDhip->isHedgeValidPolygon(sh.
hedge()))
700 myPolyPosMarked.setBitFast(sh.
hedge().
v0(),
true);
702 myPolyNegMarked.setBitFast(sh.
hedge().
v0(),
true);
707 myPosMarked.insert(sh.
hedge());
709 myNegMarked.insert(sh.
hedge());
717 if (myDhip->isHedgeValidPolygon(sh.
hedge()))
720 return myPolyPosMarked.getBitFast(sh.
hedge().
v0());
722 return myPolyNegMarked.getBitFast(sh.
hedge().
v0());
727 return myPosMarked.contains(sh.
hedge());
729 return myNegMarked.contains(sh.
hedge());
739 if (myDhip->isHedgeValidPolygon(sh.
hedge()))
743 myPolyPosCost[sh.
hedge().
v0()] = cost;
744 myPolyPosPrev[sh.
hedge().
v0()] = prev_sh;
748 myPolyNegCost[sh.
hedge().
v0()] = cost;
749 myPolyNegPrev[sh.
hedge().
v0()] = prev_sh;
756 myPosCost[sh.
hedge()] = cost;
757 myPosPrev[sh.
hedge()] = prev_sh;
761 myNegCost[sh.
hedge()] = cost;
762 myNegPrev[sh.
hedge()] = prev_sh;
771 if (myDhip->isHedgeValidPolygon(sh.
hedge()))
774 return myPolyPosCost[sh.
hedge().
v0()];
776 return myPolyNegCost[sh.
hedge().
v0()];
781 return myPosCost[sh.
hedge()];
783 return myNegCost[sh.
hedge()];
792 if (myDhip->isHedgeValidPolygon(sh.
hedge()))
795 return myPolyPosPrev[sh.
hedge().
v0()];
797 return myPolyNegPrev[sh.
hedge().
v0()];
802 return myPosPrev[sh.
hedge()];
804 return myNegPrev[sh.
hedge()];
835 bool backward =
false,
836 bool no_self_intersection =
false,
837 bool include_ends =
false,
842 const GA_Group * collision_group =
nullptr,
843 bool exclude_collision =
true,
844 bool strong_rule =
true);
850 bool backward =
false,
851 bool no_self_intersection =
false,
852 bool include_ends =
false,
857 const GA_Group * collision_group =
nullptr,
858 bool exclude_collision =
true,
859 bool strong_rule =
true);
GU_WalkEndReason GU_API guDualEdgeWalk(GU_PathHedge::Interface *dhip, const GA_ROHandleV2 &uvh, GU_SHedgeArray &path, GU_SHedgeArray &walk, bool backward=false, bool no_self_intersection=false, bool include_ends=false, const GA_PrimitiveGroup *avoid_prims=nullptr, const GA_PointGroup *avoid_points=nullptr, const GA_VertexGroup *avoid_vtx=nullptr, const GA_EdgeGroup *avoid_edges=nullptr, const GA_Group *collision_group=nullptr, bool exclude_collision=true, bool strong_rule=true)
GA_Size entries() const override
Returns the number of edges in this group.
SYS_FORCE_INLINE void unset()
SYS_FORCE_INLINE GA_Offset srcPoint(const GA_Detail *gdp, GEO_Hedge h)
SYS_FORCE_INLINE bool isPositive() const
void avoidGroups(GA_PointGroup *ptgrp, GA_EdgeGroup *edgegrp, GA_VertexGroup *vtxgrp, GA_PrimitiveGroup *primgrp)
Definition of a geometry attribute.
const GU_SHedgeArray & getStartSHedges() const
SYS_FORCE_INLINE gu_ShortestPathCost & operator=(const gu_ShortestPathCost &c)=default
void avoidPoints(GA_PointGroup *grp)
GU_WalkEndReason GU_API guEdgeWalk(GU_PathHedge::Interface *dhip, const GA_ROHandleV2 &uvh, GU_SHedgeArray &path, GU_SHedgeArray &walk, bool backward=false, bool no_self_intersection=false, bool include_ends=false, const GA_PrimitiveGroup *avoid_prims=nullptr, const GA_PointGroup *avoid_points=nullptr, const GA_VertexGroup *avoid_vtx=nullptr, const GA_EdgeGroup *avoid_edges=nullptr, const GA_Group *collision_group=nullptr, bool exclude_collision=true, bool strong_rule=true)
SYS_FORCE_INLINE fpreal length(const GU_PathHedge &h) const
GU_PathSHedge operator()(int i) const
GA_Size entries() const overridefinal
Will return the number of primary elements.
SYS_FORCE_INLINE const gu_EdgeLoopCost & operator+=(const gu_EdgeLoopCost &c)
SYS_FORCE_INLINE void unset()
GLsizei const GLchar *const * path
SYS_FORCE_INLINE fpreal getLength()
gu_EdgeLoopCost & operator=(const gu_EdgeLoopCost &c)=default
GLuint GLsizei GLsizei * length
SYS_FORCE_INLINE fpreal getLength()
SYS_FORCE_INLINE bool isNegative() const
PathEdge(GU_PathSHedge sh, GU_PathSHedge prev=GU_PathSHedge())
SYS_FORCE_INLINE bool areEquivalent(const GU_PathHedge &h1, const GU_PathHedge &h2)
SYS_FORCE_INLINE const GU_PathHedge & hedge() const
GA_EdgeT< GA_Offset, false > GA_Edge
gu_EdgeRingCost(const GU_PathSHedge &sh, GU_PathHedge::Interface *dhip)
SYS_FORCE_INLINE void zero()
PathEdge(GU_PathSHedge sh, GU_PathSHedge prev, const T &cost)
#define GA_INVALID_OFFSET
SYS_FORCE_INLINE T & getBestCost(const GU_PathSHedge &sh)
SYS_FORCE_INLINE bool isSet()
GU_PathSHedge getSHedge()
SYS_FORCE_INLINE bool isValid() const
gu_ShortestPathCost(const GU_PathSHedge &sh, GU_PathHedge::Interface *dhip)
GU_PathFinder< gu_EdgeRingCost > GU_EdgeRingFinder
gu_EdgeLoopCost(const gu_EdgeLoopCost &c)
GU_PathFinder< gu_EdgeLoopCost > GU_EdgeLoopFinder
gu_ShortestPathCost(fpreal l)
SYS_FORCE_INLINE fpreal getLength()
SYS_FORCE_INLINE bool isSet()
SYS_FORCE_INLINE const gu_ShortestPathCost & operator+=(const gu_ShortestPathCost &c)
void avoidPrimitives(GA_PrimitiveGroup *grp)
gu_EdgeRingCost & operator=(const gu_EdgeRingCost &c)=default
GA_GroupType classType() const
SYS_FORCE_INLINE bool operator>(const gu_EdgeLoopCost &c) const
void avoidVertices(GA_VertexGroup *grp)
gu_EdgeLoopCost()=default
static SYS_FORCE_INLINE gu_ShortestPathCost turnCost(GU_PathHedge::Interface *dhip, const GU_PathSHedge &from_sh, const GU_PathSHedge &to_sh, const GU_EdgeSuccessor &exits)
SYS_FORCE_INLINE void unset()
bool operator()(PathEdge &p1, PathEdge &p2) const
GLfloat GLfloat GLfloat GLfloat h
SYS_FORCE_INLINE bool operator>(const gu_EdgeRingCost &c) const
SYS_FORCE_INLINE bool isSet()
gu_EdgeLoopCost(fpreal len, int bends)
SYS_FORCE_INLINE bool operator>(const gu_ShortestPathCost &c) const
static SYS_FORCE_INLINE gu_EdgeRingCost turnCost(GU_PathHedge::Interface *dhip, const GU_PathSHedge &from_sh, const GU_PathSHedge &to_sh, const GU_EdgeSuccessor &successors)
gu_EdgeRingCost()=default
SYS_FORCE_INLINE void zero()
gu_EdgeRingCost(fpreal len, int bends)
Container class for all geometry.
gu_ShortestPathCost()=default
void avoidEdges(GA_EdgeGroup *grp)
const GEO_DetachedHedgeInterface HedgeInterface
void setCollisionGroup(const GA_Group *group, bool exclude, bool strong)
SYS_FORCE_INLINE void zero()
SYS_FORCE_INLINE GA_Offset v0() const
SYS_FORCE_INLINE const gu_EdgeRingCost & operator+=(const gu_EdgeRingCost &c)
gu_EdgeLoopCost(const GU_PathSHedge &sh, GU_PathHedge::Interface *dhip)
static Mask typeMask(Type t)
static SYS_FORCE_INLINE gu_EdgeLoopCost turnCost(GU_PathHedge::Interface *dhip, const GU_PathSHedge &from_sh, const GU_PathSHedge &to_sh, const GU_EdgeSuccessor &successors)
SYS_FORCE_INLINE GA_Offset dstPoint(T &iface, GEO_Hedge h)
GU_PathSHedge & operator()(int i)