41 if (myConvexInfo) free(myConvexInfo);
42 if (myPointList) free(myPointList);
48 void convex(
exint maxsides,
bool allowinterrupt =
true,
49 bool avoiddegeneracy =
false);
53 virtual int getPointCount()
const = 0;
54 virtual void getPoint(
int num,
float &
x,
float &
y)
const = 0;
57 virtual void beginPolygon(
int npoints,
bool lastone) = 0;
58 virtual void polyVertex(
int num) = 0;
59 virtual void endPolygon() = 0;
66 virtual void earlyTermination();
103 template <
typename T = fpreal>
120 template <
typename T>
126 const fpreal tol = smallAngleTolerance();
140 fpreal cscale = lca * lcd;
141 fpreal bscale = lbd * lba;
145 if ((ccross < -tol * cscale && bcross > tol * bscale) ||
146 (ccross > tol * cscale && bcross < -tol * bscale))
149 fpreal perim = lca + lcd + lbd + lba;
150 fpreal lsmall = tol * perim;
168 if (
SYSmin(lba, lca, lbd, lcd) <= lsmall)
191 area1x2overbc / lcd);
195 area3x2overad / lcd);
196 return min23 > min01;
203 template <
typename PTS,
typename TRIS,
typename ON_FLIP>
207 const int ntripts =
int(tripts.size());
208 const int ntris = ntripts/3;
217 for (
int i = 0; i < ntripts; ++i)
219 for (
int tri = 0; tri < ntris; ++tri)
221 int trioff = 3 * tri;
222 for (
int i = 0; i < 3; ++i)
225 if (adjtrioff(trioff + i) >= 0)
228 int pti = tripts(trioff + i);
229 int ptip1 = tripts(trioff + (i + 1) % 3);
232 for (
int tri2 = tri+1; tri2 < ntris && !found; ++tri2)
234 int tri2off = 3 * tri2;
235 for (
int j = 0;
j < 3; ++
j)
237 int ptj = tripts(tri2off +
j);
238 int ptjp1 = tripts(tri2off + (
j + 1) % 3);
240 if (ptjp1 == pti && ptj == ptip1)
242 adjtrioff(trioff + i) = tri2off +
j;
243 adjtrioff(tri2off + j) = trioff + i;
257 edgesflipped =
false;
258 for (
int tri = 0; tri < ntris; ++tri)
260 int trioff = 3 * tri;
261 for (
int i = 0; i < 3; ++i)
263 if (adjtrioff(trioff + i) < 0)
266 int j = adjtrioff(trioff + i) % 3;
267 int tri2off = adjtrioff(trioff + i) -
j;
268 int tri2 = tri2off / 3;
270 int a = tripts(trioff + ((i + 2) % 3));
271 int b = tripts(trioff + i);
272 int c = tripts(trioff + ((i + 1) % 3));
273 int d = tripts(tri2off + ((j + 2) % 3));
275 if (!shouldFlipEdge(pts(a), pts(b), pts(c), pts(d)))
292 on_flip(tri, tri2, i, j);
296 tripts(trioff + (i + 1) % 3) = tripts(tri2off + (j + 2) % 3);
297 tripts(tri2off + (j + 1) % 3) = tripts(trioff + (i + 2) % 3);
300 int nowacrossedgei = adjtrioff(tri2off + (j + 1) % 3);
301 adjtrioff(trioff + i) = nowacrossedgei;
302 if (nowacrossedgei >= 0)
303 adjtrioff(nowacrossedgei) = trioff + i;
305 int nowacrossedgej = adjtrioff(trioff + (i + 1) % 3);
306 adjtrioff(tri2off + j) = nowacrossedgej;
307 if (nowacrossedgej >= 0)
308 adjtrioff(nowacrossedgej) = tri2off +
j;
310 adjtrioff(trioff + (i + 1) % 3) = tri2off + (j + 1) % 3;
311 adjtrioff(tri2off + (j + 1) % 3) = trioff + (i + 1) % 3;
322 }
while (edgesflipped && count <
int64(ntris) * ntris);
326 template <
typename PTS,
typename TRIS>
329 flipEdgesToAvoidSmallAngles(pts, tripts, [](
int,
int,
int,
int) {});
332 virtual int64 getMemoryUsage(
bool inclusive)
const;
335 UT_ConvexPoint *polySetup(
bool avoiddegeneracy);
336 int leftOrRight(
int v1,
int v2,
int v3,
bool &double_back);
337 int leftOrRight(
int v1,
int v2,
int v3)
340 return leftOrRight(v1, v2, v3, double_back);
349 bool avoiddegeneracy);
354 bool cornerTest(
int side,
uint la,
uint lb,
358 uint chooseCoincidentIntruder(
372 UT_ConvexPoint *myConvexInfo;
374 uint myConvexEntries;
382 bool myAvoidDegeneracyPrev;
typedef int(APIENTRYP RE_PFNGLXSWAPINTERVALSGIPROC)(int)
static void flipEdgesToAvoidSmallAngles(const PTS &pts, TRIS &tripts, ON_FLIP &&on_flip)
static bool isQuadConvex(const UT_Vector3 &p0, const UT_Vector3 &p1, const UT_Vector3 &p2, const UT_Vector3 &p3)
SIM_DerScalar dot(const SIM_DerVector3 &rhs) const
GLboolean GLboolean GLboolean GLboolean a
GLfloat GLfloat GLfloat v2
GLfloat GLfloat GLfloat GLfloat v3
void setSize(exint newsize)
static bool shouldFlipEdge(const UT_Vector2T< T > &a, const UT_Vector2T< T > &b, const UT_Vector2T< T > &c, const UT_Vector2T< T > &d)
constexpr SYS_FORCE_INLINE T length() const noexcept
fpreal64 dot(const CE_VectorT< T > &a, const CE_VectorT< T > &b)
#define UT_NON_COPYABLE(CLASS)
Define deleted copy constructor and assignment operator inside a class.
static constexpr T smallAngleTolerance()
OPENVDB_API void initialize()
Global registration of native Grid, Transform, Metadata and Point attribute types. Also initializes blosc (if enabled).
GLboolean GLboolean GLboolean b
__hostdev__ uint64_t last(uint32_t i) const
static void flipEdgesToAvoidSmallAngles(const PTS &pts, TRIS &tripts)
As above, without a flip callback.
static bool canSplitQuad02(const UT_Vector3 &p0, const UT_Vector3 &p1, const UT_Vector3 &p2, const UT_Vector3 &p3)
SIM_DerVector3 cross(const SIM_DerVector3 &lhs, const SIM_DerVector3 &rhs)