HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GEO_PrimPolySoup.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: GEO_PrimPolySoup.h (GEO Library, C++)
7  *
8  * COMMENTS: Implements a set of polygons sharing primitive attributes
9  * and some vertices, to save memory
10  */
11 
12 #pragma once
13 
14 #ifndef __GEO_PrimPolySoup__
15 #define __GEO_PrimPolySoup__
16 
17 #include "GEO_TriMesh.h"
18 #include "GEO_PrimType.h"
19 #include "GEO_PrimTypeCompat.h"
20 #include "GEO_API.h"
21 #include "GEO_PolyCounts.h"
22 #include <GA/GA_Detail.h>
23 #include <GA/GA_ElementWrangler.h>
24 #include <GA/GA_Types.h>
25 #include <UT/UT_Array.h>
26 #include <UT/UT_SafeFloat.h>
27 #include <UT/UT_Vector3.h>
28 #include <UT/UT_VectorTypes.h>
29 #include <SYS/SYS_Deprecated.h>
30 #include <SYS/SYS_Inline.h>
31 
32 class GA_Detail;
33 class GEO_PolySoupParms;
34 class GA_PrimitiveGroup;
35 class GEO_PrimPoly;
36 
37 /// A soup of polygons
39 {
40 protected:
41  /// NOTE: The constructor should only be called from subclass
42  /// constructors.
44  : GEO_TriMesh(d, offset)
45  {}
46 
47  /// NOTE: The destructor should only be called from subclass
48  /// destructors.
49  ~GEO_PrimPolySoup() override {}
50 
51 public:
53  {
54  public:
57  : GA_PolyCounts::const_iterator(prim.myPolygonSizeList)
58  , myPrim(&prim)
59  {}
61  : GA_PolyCounts::const_iterator(prim.myPolygonSizeList, polygon)
62  , myPrim(&prim)
63  {}
64  SYS_FORCE_INLINE const GEO_PrimPolySoup &prim() const { return *myPrim; }
66  {
68  this->myPrim = that.myPrim;
69  return *this;
70  }
72  {
73  UT_ASSERT_P(i >= 0 && i < nvertices());
74  return myPrim->myPolygonVertexList(start()+i);
75  }
77  {
78  UT_ASSERT_P(i >= 0 && i < nvertices());
79  const GA_Detail &detail = myPrim->getDetail();
80  return detail.vertexIndex(myPrim->myPolygonVertexList(start()+i));
81  }
83  {
84  UT_ASSERT_P(i >= 0 && i < nvertices());
85  return myPrim->getDetail().vertexPoint(myPrim->myPolygonVertexList(start()+i));
86  }
88  {
89  UT_ASSERT_P(i >= 0 && i < nvertices());
90  const GA_Detail &detail = myPrim->getDetail();
91  return detail.pointIndex(detail.vertexPoint(myPrim->myPolygonVertexList(start()+i)));
92  }
94  {
95  UT_ASSERT_P(i >= 0 && i < nvertices());
96  const GA_Detail &detail = myPrim->getDetail();
97  return detail.getPos3(detail.vertexPoint(myPrim->myPolygonVertexList(start()+i)));
98  }
100  {
101  UT_ASSERT_P(i >= 0 && i < nvertices());
102  const GA_Detail &detail = myPrim->getDetail();
103  return detail.getPos4(detail.vertexPoint(myPrim->myPolygonVertexList(start()+i)));
104  }
106  { return myPrim->baryCenter(*this); }
108  { return myPrim->baryCenterD(*this); }
110  { return myPrim->computeNormal(*this); }
112  { return myPrim->computeNormalD(*this); }
114  { return myPrim->calcPerimeter(*this); }
116  { return myPrim->calcArea(*this); }
118  { return myPrim->calcVolume(refpt, *this); }
119  SYS_FORCE_INLINE float getW() const
120  { return UTpackIntToSafeFloat(polygon()); }
121 
122  /// These are just here for interchangeability with GEO_Face
124  { return getVertexOffset(i); }
126  { return nvertices(); }
128  { return nvertices(); }
130  { return true; }
131  private:
132  const GEO_PrimPolySoup *myPrim;
133  };
134 
136  {
137  public:
138  VertexIterator(const PolygonIterator &it, GA_Size vtxnum = 0)
139  : myPrim(it.prim())
140  , myIndex(it.start()+vtxnum)
141  , myEnd(it.start()+it.nvertices())
142  {}
143  bool atEnd() const
144  {
145  return myIndex == myEnd;
146  }
148  {
149  ++myIndex;
150  return *this;
151  }
153  {
154  --myIndex;
155  return *this;
156  }
158  {
159  return VertexIterator(myPrim, myIndex + i, myEnd);
160  }
162  {
163  return VertexIterator(myPrim, myIndex - i, myEnd);
164  }
165  GA_Size number() const
166  {
167  return myIndex;
168  }
170  {
171  return myPrim.myPolygonVertexList(myIndex);
172  }
173  private:
175  : myPrim(prim)
176  , myIndex(index)
177  , myEnd(end)
178  {}
179  const GEO_PrimPolySoup &myPrim;
180  GA_Size myIndex;
181  GA_Size myEnd;
182  };
183 
184  /// Have we been deactivated and stashed?
185  void stashed(bool beingstashed,
186  GA_Offset offset = GA_INVALID_OFFSET) override;
187 
188  /// @{
189  /// Interface from GEO_TriMesh
190  UT_Vector3 computeNormal() const override;
191  UT_Vector3D computeNormalD() const override;
192  void reverse() override;
193 
194  fpreal calcVolume(const UT_Vector3 &refpt) const override;
195  fpreal calcArea() const override;
196  fpreal calcPerimeter() const override;
197  /// @}
198 
199  // This is here only to avoid a compile error on baryCenter(it) below
200  UT_Vector3 baryCenter() const override
201  { return GEO_TriMesh::baryCenter(); }
202  UT_Vector3D baryCenterD() const override
203  { return GEO_TriMesh::baryCenterD(); }
204 
205  UT_Vector3 computeNormal(const PolygonIterator &it) const;
206  UT_Vector3D computeNormalD(const PolygonIterator &it) const;
207  UT_Vector3 baryCenter(const PolygonIterator &it) const;
208  UT_Vector3D baryCenterD(const PolygonIterator &it) const;
209  fpreal calcVolume(const UT_Vector3 &refpt, const PolygonIterator &it) const;
210  fpreal calcArea(const PolygonIterator &it) const;
211  fpreal calcPerimeter(const PolygonIterator &it) const;
212 
213  /// Get number of polygons in the soup
215  {
216  return myPolygonSizeList.getNumPolygons();
217  }
218 
219  /// Get the number of vertices in the polygon
221  {
222  UT_ASSERT_P(myPolygonSizeList.getArray().entries() != 0);
223  return myPolygonSizeList.getSize(polygon);
224  }
225 
226  /// Get the start offset into myPolygonVertexList of vertices for a
227  /// single polygon in the soup and the number of vertices in the polygon
229  GA_Size &start,
230  GA_Size &count) const
231  {
232  UT_ASSERT_P(myPolygonSizeList.getArray().entries() != 0);
233  myPolygonSizeList.getVertexRange(polygon, start, count);
234  }
235 
237  GA_Size vertexofpolygon) const
238  {
239  GA_Size start;
240  GA_Size count;
241  getPolygonVertexRange(polygon, start, count);
242  UT_ASSERT_P(vertexofpolygon < count);
243  return myPolygonVertexList(start + vertexofpolygon);
244  }
245 
247  GA_Size vertexofpolygon) const
248  {
249  return myPolygonVertexList(it.start() + vertexofpolygon);
250  }
251 
253  GA_Offset &v0,
254  GA_Offset &v1,
255  GA_Offset &v2) const
256  {
257  v0 = myPolygonVertexList(start);
258  v1 = myPolygonVertexList(start+1);
259  v2 = myPolygonVertexList(start+2);
260  }
261 
263  GA_Offset &v0,
264  GA_Offset &v1,
265  GA_Offset &v2,
266  GA_Offset &v3) const
267  {
268  v0 = myPolygonVertexList(start);
269  v1 = myPolygonVertexList(start+1);
270  v2 = myPolygonVertexList(start+2);
271  v3 = myPolygonVertexList(start+3);
272  }
273 
274  /// Return the maximum number of vertices in any face
275  inline GA_Size getMaxPolygonSize() const
276  {
278  = myPolygonSizeList.getArray();
279  if (!array.entries())
280  return -1;
281  GA_Size mx = array(0).size();
282  for (GA_Size i = 1; i < array.entries(); ++i)
283  mx = SYSmax(mx, array(i).size());
284  return mx;
285  }
286 
287  /// Return the minimum number of vertices in any face
288  inline GA_Size getMinPolygonSize() const
289  {
291  = myPolygonSizeList.getArray();
292  if (!array.entries())
293  return -1;
294  GA_Size mn = array(0).size();
295  for (GA_Size i = 1; i < array.entries(); ++i)
296  mn = SYSmin(mn, array(i).size());
297  return mn;
298  }
299 
300  /// Return the minimum and maximum number of vertices for any face
301  inline void getMinMaxPolygonSize(GA_Size &mn, GA_Size &mx) const
302  {
304  = myPolygonSizeList.getArray();
305  if (!array.entries())
306  {
307  mn = mx = -1;
308  return;
309  }
310  mn = mx = array(0).size();
311  for (GA_Size i = 1; i < array.entries(); ++i)
312  {
313  mn = SYSmin(mn, array(i).size());
314  mx = SYSmax(mx, array(i).size());
315  }
316  }
317 
318  const GA_PrimitiveJSON *getJSON() const override;
319  /// @{
320  /// Save/Load polygon list to a JSON stream
321  bool savePolygonInfo(UT_JSONWriter &w,
322  const GA_SaveMap &map) const;
323  bool loadPolygonInfo(UT_JSONParser &p,
324  const GA_LoadMap &map);
325  /// @}
326 
327  /// Appends a copy of a single polygon to this PolySoup,
328  /// with all vertices unique
329  void appendPolygonCopyUnique(const GEO_PrimPoly *polygon,
330  GA_VertexWrangler &wrangler);
331  /// Appends a copy of a single polygon to this PolySoup,
332  /// with any vertices whose attributes match being shared among
333  /// polygons in this PolySoup
334  void appendPolygonCopyShared(const GEO_PrimPoly *polygon,
335  GA_VertexWrangler &wrangler, GA_AttributeRefMap &attributemap);
336  /// Appends a copy of a single polygon to this PolySoup,
337  /// with all vertices unique
338  void appendPolygonCopyUnique(
339  const GA_OffsetListRef &polygon, const GA_Detail &srcdetail,
340  GA_VertexWrangler &wrangler);
341  /// Appends a copy of a single polygon to this PolySoup,
342  /// with any vertices whose attributes match being shared among
343  /// polygons in this PolySoup
344  void appendPolygonCopyShared(
345  const GA_OffsetListRef &polygon, const GA_Detail &srcdetail,
346  GA_VertexWrangler &wrangler, GA_AttributeRefMap &attributemap);
347  /// Appends a copy of another PolySoup to this PolySoup,
348  /// with all vertices unique
349  void appendPolySoupCopyUnique(const GEO_PrimPolySoup *that,
350  GA_VertexWrangler &wrangler);
351  /// Appends a copy of another PolySoup to this PolySoup,
352  /// with any vertices whose attributes match being shared among
353  /// polygons in this PolySoup
354  void appendPolySoupCopyShared(const GEO_PrimPolySoup *that,
355  GA_VertexWrangler &wrangler, GA_AttributeRefMap &attributemap);
356 
357  /// Appends a polygon to this PolySoup from an array of vertex offsets
358  /// NOTE: This will not wire the vertices to points or to this primitive,
359  /// so that must be done manually. This assumes the vertices have
360  /// already been added to the GEO_TriMesh level with appendVertex
361  /// or appendVertices.
362  void appendPolygon(const UT_Array<GA_Offset> &vertices);
363 
364  /// Appends polygons to this PolySoup from an array of vertex offsets
365  /// NOTE: This will not wire the vertices to points or to this primitive,
366  /// so that must be done manually. This assumes the vertices have
367  /// already been added to the GEO_TriMesh level with appendVertex
368  /// or appendVertices.
369  void appendPolygons(const GA_PolyCounts &sizes,
370  const GA_OffsetList &vertices);
371 
372  /// Returns true iff none of the vertices of the PolySoup are shared
373  /// among multiple polygons in this PolySoup.
374  /// NOTE: This assumes that every vertex of the PolySoup is in at least
375  /// one polygon in this PolySoup.
376  bool areAllVerticesUnique() const
377  { return myPolygonVertexList.entries() == myVertexList.entries(); }
378 
379  /// Forces all vertices in this polysoup to be unshared, i.e. creates
380  /// new vertices if any are used by multiple polygons in this polysoup.
381  /// NOTE: This assumes that every vertex of the PolySoup is in at least
382  /// one polygon in this PolySoup, since it calls
383  /// areAllVerticesUnique().
384  void makeAllVerticesUnique();
385 
386  /// Optimizes the internal representation of the PolySoup
387  void optimize();
388 
389  /// Remove repeated point offsets in the polygon vertices, optionally
390  /// checking distance to remove points within a specified tolerance,
391  /// then remove all degenerate polygons.
392  GA_Size cleanData(const bool remove_near_points = false, float tol = 0.001F,
393  bool deleteOrphanedPoints = true);
394 
395  /// Remove polygons that have 0, 1, or 2 vertices, optionally deleting
396  /// orphaned points.
397  GA_Size remove012(bool delete_orphaned_points = true);
398 
399  /// Remove vertices that are not used by any of the soup's polygons,
400  /// and optionally remove their points if they are also unused.
401  void deleteUnusedVertices(bool andpoints = true);
402 
403  /// Replaces specified polygons with new polygons using the same vertices,
404  /// which is necessary for convexing. polygonstoremesh must be monotone
405  /// increasing.
406  void remeshPolygons(const UT_Array<GA_Size> &polygonstoremesh,
407  const GA_OffsetList &newvertices,
408  const GA_PolyCounts &newpolygonsizelist);
409 
411  const GA_RangeMemberQuery &point_query,
412  bool dry_run) override;
413 
414  void copyPrimitive(const GEO_Primitive *psrc) override;
415  GEO_Primitive *copy(int preserve_shared_pts) const override;
416  void copySubclassData(const GA_Primitive *source) override;
417 
418  /// Defragmentation
419  void swapVertexOffsets(const GA_Defragment &defrag) override;
420 
421 #if 0
422  /// Converts myPolygonVertexList from storing GA_Offsets to storing
423  /// indices into myVertexList.
424  void offsetsToIndirection();
425  /// Converts myPolygonVertexList from indices of myVertexList back
426  /// into GA_Offsets
427  void indirectionToOffsets();
428 #endif
429 
431  {
432  return myPolygonVertexList.entries();
433  }
434 
435  /// These are only here because of C++ compilers erroring on the
436  /// appendVertex function below, thinking it should hide these.
437  /// NOTE: This will not add the vertex to myPolygonVertexList,
438  /// in case it is to be shared, so use
439  /// appendPolygon(const UT_Array<GA_Offset> &vertices)
440  /// to add a polygon with the vertex.
441  /// NOTE: If you leave vertices in the polysoup that are not used by any
442  /// polygons, areAllVerticesUnique() may return incorrect results,
443  /// since it just checks if the size of myPolygonVertexList is
444  /// larger than the size of myVertexList
446  { return GEO_TriMesh::appendVertex(ptoff); }
447 
448  /// This appends one vertex for each of nvertices points starting
449  /// from startptoff, in parallel, and wires them to the points and
450  /// this polysoup, then returns the starting vertex offset. Since
451  /// each point has only one vertex, this applies to making shared
452  /// vertices.
453  /// NOTE: The points can't be used by any other primitives at the
454  /// time that this is called.
455  /// NOTE: If you leave vertices in the polysoup that are not used by any
456  /// polygons, areAllVerticesUnique() may return incorrect results,
457  /// since it just checks if the size of myPolygonVertexList is
458  /// larger than the size of myVertexList
459  GA_Offset appendSharedVertices(GA_Offset startptoff, GA_Size nvertices);
460 
461  void iterateEdges(GA_IterateEdgesFunc apply_func) const override
462  {
463  GA_Detail &detail = getDetail();
464  for (PolygonIterator it(*this); !it.atEnd(); ++it)
465  {
466  if (it.nvertices() == 0)
467  continue;
468  VertexIterator vit(it);
469  const GA_Offset startptoff = detail.vertexPoint(vit.offset());
470  GA_Offset prevptoff = startptoff;
471  for (++vit; !vit.atEnd(); ++vit)
472  {
473  const GA_Offset currptoff = detail.vertexPoint(vit.offset());
474  if (!apply_func(GA_Edge(prevptoff, currptoff)))
475  return;
476  prevptoff = currptoff;
477  }
478  // NOTE: GEO_Face::edgeApply always has a wrapping edge for
479  // closed polygons, even with just 1 or 2 vertices.
480  //if (it.nvertices() > 2)
481  if (!apply_func(GA_Edge(prevptoff, startptoff)))
482  return;
483  }
484  }
485  void iterateEdgesByVertex(GA_IterateEdgesByVertexFunc apply_func) const override;
486 
487  /// This does a linear search through the whole soup.
488  /// You may regret calling it for each edge of a large soup.
489  bool hasEdge(const GA_Edge &edge) const override
490  {
491  GA_Offset a = edge.p0();
492  GA_Offset b = edge.p1();
493  for (PolygonIterator it(*this); !it.atEnd(); ++it)
494  {
495  GA_Size n = it.nvertices();
496  if (n == 0)
497  continue;
498  const GA_Offset startptoff = it.getPointOffset(0);
499  GA_Offset p0 = startptoff;
500  for (GA_Size i = 1; i < n; ++i)
501  {
502  GA_Offset p1 = it.getPointOffset(i);
503  if ( ((p0 == a) && (p1 == b)) || ((p0 == b) && (p1 == a)) )
504  return true;
505  p0 = p1;
506  }
507  // NOTE: GEO_Face::edgeApply always has a wrapping edge for
508  // closed polygons, even with just 1 or 2 vertices, even
509  // though GEO_Face::hasEdge doesn't accept the self-edge
510  // if there's only one vertex.
511  //if (it.nvertices() > 2)
512  GA_Offset p1 = startptoff;
513  if ( ((p0 == a) && (p1 == b)) || ((p0 == b) && (p1 == a)) )
514  return true;
515  }
516  return false;
517  }
518 
520  UT_Array<GA_Offset> &vtxlist,
521  UT_Array<float> &weightlist,
522  fpreal u, fpreal v, fpreal w) const override;
523 
524  /// Create polygon soup(s), i.e. GEO_PrimPolySoup, where possible in dest_detail.
525  /// src_detail *can* be the same as dest_detail.
526  static void convertDetail(GEO_Detail *dest_detail, const GEO_Detail *src_detail, const GEO_PolySoupParms &parms);
527 
528  virtual void convex(GA_Size maxpts = 3, const GA_Detail *restgdp = nullptr,
529  bool flipedges = false, bool avoiddegeneracy = false) = 0;
530 
531 protected:
533  { return GEO_TriMesh::buildFamilyMask(); }
534 
535  template <typename T>
536  UT_Vector3T<T> internalComputeNormal(const PolygonIterator &it) const;
537 
538  // Declare intrinsic definitions
539  GA_DECLARE_INTRINSICS(override)
540 
541  void appendUniqueVertexCopy(const GA_Offset vertex,
542  const GA_Detail &srcdetail,
543  GA_VertexWrangler &wrangler);
544  void appendSharedVertexCopy(const GA_Offset vertex,
545  const GA_Detail &srcdetail,
546  GA_VertexWrangler &wrangler,
547  GA_AttributeRefMap &attributemap);
548 
549  /// Evaluates the position at domain point (u,v) in the interior of the
550  /// geometry, rather than on the perimeter of the poly.
551  /// (Note that u, v don't have to be converted to unit domain. We assume
552  /// that the barycentric coords or bilinear interpolants are already
553  /// correctly scaled).
554  bool evaluateInteriorPointRefMap(GA_Offset result_vtx,
555  GA_AttributeRefMap &hlist,
556  fpreal u, fpreal v, fpreal w) const override;
557  int evaluateInteriorPointV4(UT_Vector4 &pos,
558  fpreal u, fpreal v, fpreal w) const override;
559  int evaluateNormalVector(UT_Vector3 &nml,
560  float u, float v, float w) const override;
561 
562  bool savePrivateH9(std::ostream &, bool binary) const override;
563  bool loadPrivateH9(UT_IStream &) override;
564 
565  GA_PolyCounts myPolygonSizeList;
566  GA_OffsetList myPolygonVertexList;
567 
568 private:
569  friend std::ostream &operator<<(std::ostream &os, const GEO_PrimPolySoup &d)
570  {
571  d.saveH9(os, 0,
574  return os;
575  }
577 };
579 
580 /// Structure for the PolySouping code
582 {
583 public:
587  int minPolys;
588  bool convex;
589  int maxSides;
593 
595  bool ignattr = false,
596  bool igngrp = false,
597  int minp = 1,
598  bool cvx = false,
599  int maxs = 3,
600  bool delprims = true,
602  bool mergeverts = true)
603  : primGroup(pg)
604  , ignorePrimAttributes(ignattr)
605  , ignorePrimGroups(igngrp)
606  , minPolys(minp)
607  , convex(cvx)
608  , maxSides(maxs)
609  , deleteSoupedPrimitives(delprims)
610  , typeMask(mask)
611  , mergeVertices(mergeverts)
612  { }
613 };
614 
615 #endif
616 
SIM_API const UT_StringHolder vertex
SYS_FORCE_INLINE float getW() const
GLuint GLsizei const GLuint const GLintptr const GLsizeiptr * sizes
Definition: glcorearb.h:2621
#define SYSmax(a, b)
Definition: SYS_Math.h:1570
fpreal calcPerimeter() const override
GA_Size getPolygonVertexCount() const
virtual GEO_Primitive * copy(int preserve_shared_pts=0) const
GA_DereferenceStatus dereferencePoints(const GA_RangeMemberQuery &pt_q, bool dry_run=false) override
SYS_FORCE_INLINE GA_Detail & getDetail() const
Definition: GA_Primitive.h:141
void getTriangleVertexOffsets(GA_Size start, GA_Offset &v0, GA_Offset &v1, GA_Offset &v2) const
virtual void copyPrimitive(const GEO_Primitive *src)=0
Used to pass options and map offset values during saving.
Definition: GA_SaveMap.h:48
SYS_FORCE_INLINE PolygonIterator & operator=(const PolygonIterator &that)
*get result *(waiting if necessary)*A common idiom is to fire a bunch of sub tasks at the and then *wait for them to all complete We provide a helper class
Definition: thread.h:623
void getQuadVertexOffsets(GA_Size start, GA_Offset &v0, GA_Offset &v1, GA_Offset &v2, GA_Offset &v3) const
UT_Vector3D baryCenterD() const override
SYS_FORCE_INLINE fpreal calcPerimeter() const
void
Definition: png.h:1083
void iterateEdges(GA_IterateEdgesFunc apply_func) const override
GA_PrimCompat::TypeMask typeMask
virtual void computeInteriorPointWeights(UT_Array< GA_Offset > &vtxlist, UT_Array< float > &weightlist, fpreal u, fpreal v, fpreal w) const
virtual UT_Vector3D computeNormalD() const =0
GA_Offset getPolygonVertexOffset(const PolygonIterator &it, GA_Size vertexofpolygon) const
const GLdouble * v
Definition: glcorearb.h:837
GA_Size getPolygonCount() const
Get number of polygons in the soup.
SYS_FORCE_INLINE GA_Offset getPointOffset(GA_Size i) const
#define SYS_DEPRECATED_PUSH_DISABLE()
void getMinMaxPolygonSize(GA_Size &mn, GA_Size &mx) const
Return the minimum and maximum number of vertices for any face.
UT_Vector4 getPos4(GA_Offset ptoff) const
The ptoff passed is the point offset.
Definition: GA_Detail.h:292
#define SYS_DEPRECATED_POP_DISABLE()
virtual void copySubclassData(const GA_Primitive *source)
Definition: GA_Primitive.h:508
GLuint start
Definition: glcorearb.h:475
SYS_FORCE_INLINE UT_Vector3 baryCenter() const
const GLuint GLenum const void * binary
Definition: glcorearb.h:1924
fpreal calcVolume(const UT_Vector3 &) const override
SYS_FORCE_INLINE GA_Index getPointIndex(GA_Size i) const
SYS_FORCE_INLINE fpreal calcVolume(const UT_Vector3 &refpt) const
A soup of polygons.
GLboolean GLboolean GLboolean GLboolean a
Definition: glcorearb.h:1222
JSON reader class which handles parsing of JSON or bJSON files.
Definition: UT_JSONParser.h:87
void reverse() override=0
Reverse the order of vertices.
#define GA_DECLARE_INTRINSICS(OVERRIDE)
Definition: GA_Primitive.h:80
SYS_FORCE_INLINE GA_Size getVertexCount() const
SYS_FORCE_INLINE UT_Vector3 getPos3(GA_Size i) const
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:37
static GA_PrimitiveFamilyMask buildFamilyMask()
Abstract base class for a range membership query object.
SYS_FORCE_INLINE UT_Vector3 getPos3(GA_Offset ptoff) const
The ptoff passed is the point offset.
Definition: GA_Detail.h:185
Structure for the PolySouping code.
GLfloat GLfloat GLfloat v2
Definition: glcorearb.h:818
UT_Function< bool(const GA_Edge &edge)> GA_IterateEdgesFunc
Definition: GA_Primitive.h:73
GA_EdgeT< GA_Offset, false > GA_Edge
Definition: GA_Edge.h:140
GLfloat GLfloat GLfloat GLfloat v3
Definition: glcorearb.h:819
SYS_FORCE_INLINE bool isClosed() const
VertexIterator operator-(GA_Size i)
fpreal calcArea() const override
virtual void swapVertexOffsets(const GA_Defragment &defrag)
exint size() const
Definition: UT_Array.h:646
exint GA_Size
Defines the bit width for index and offset types in GA.
Definition: GA_Types.h:236
GA_PrimitiveFamilyMask
virtual UT_Vector3 computeNormal() const =0
Return a normal vector for the primitive.
#define GA_INVALID_OFFSET
Definition: GA_Types.h:687
GA_Size appendVertex(GA_Offset ptoff) override
GA_Size getPolygonSize(GA_Size polygon) const
Get the number of vertices in the polygon.
GA_Size GA_Offset
Definition: GA_Types.h:646
SYS_FORCE_INLINE GA_Offset getFastVertexOffset(GA_Size i) const
These are just here for interchangeability with GEO_Face.
SYS_FORCE_INLINE GA_Offset getVertexOffset(GA_Size i) const
bool hasEdge(const GA_Edge &edge) const override
GLdouble n
Definition: glcorearb.h:2008
SYS_FORCE_INLINE UT_Vector3 computeNormalD() const
GLintptr offset
Definition: glcorearb.h:665
VertexIterator(const PolygonIterator &it, GA_Size vtxnum=0)
SYS_FORCE_INLINE UT_Vector3D baryCenterD() const
SYS_FORCE_INLINE UT_Vector4 getPos4(GA_Size i) const
~GEO_PrimPolySoup() override
SYS_FORCE_INLINE fpreal calcArea() const
UT_Vector3D baryCenterD() const override
virtual GA_Size appendVertex(GA_Offset ppt)
#define UT_ASSERT_P(ZZ)
Definition: UT_Assert.h:155
GA_Size getMaxPolygonSize() const
Return the maximum number of vertices in any face.
bool areAllVerticesUnique() const
GLuint GLuint end
Definition: glcorearb.h:475
#define SYS_FORCE_INLINE
Definition: SYS_Inline.h:45
virtual const GA_PrimitiveJSON * getJSON() const =0
GLsizei GLsizei GLchar * source
Definition: glcorearb.h:803
UT_Function< bool(GA_Size, GA_Size)> GA_IterateEdgesByVertexFunc
Definition: GA_Primitive.h:74
Provide a JSON interface to a primitive.
GLint GLuint mask
Definition: glcorearb.h:124
#define GEO_API
Definition: GEO_API.h:14
A handle to simplify manipulation of multiple attributes.
SYS_FORCE_INLINE GA_Index vertexIndex(GA_Offset offset) const
Given a vertex's data offset, return its index.
Definition: GA_Detail.h:519
Options during loading.
Definition: GA_LoadMap.h:42
T p1() const
Definition: GA_Edge.h:36
Defragmentation of IndexMaps.
Definition: GA_Defragment.h:45
SYS_FORCE_INLINE GA_Offset vertexPoint(GA_Offset vertex) const
Given a vertex, return the point it references.
Definition: GA_Detail.h:529
GLboolean GLboolean GLboolean b
Definition: glcorearb.h:1222
GA_Size GA_Index
Define the strictness of GA_Offset/GA_Index.
Definition: GA_Types.h:640
const GA_PrimitiveGroup * primGroup
GA_Offset getPolygonVertexOffset(GA_Size polygon, GA_Size vertexofpolygon) const
UT_Vector3 baryCenter() const override
SYS_FORCE_INLINE bool atEnd() const
Definition: GA_PolyCounts.h:96
SYS_FORCE_INLINE UT_Vector3 computeNormal() const
GEO_PolySoupParms(const GA_PrimitiveGroup *pg=0, bool ignattr=false, bool igngrp=false, int minp=1, bool cvx=false, int maxs=3, bool delprims=true, GA_PrimCompat::TypeMask mask=GEO_PrimTypeCompat::GEOPRIMALL, bool mergeverts=true)
SYS_FORCE_INLINE GA_Size start() const
GLfloat v0
Definition: glcorearb.h:816
exint entries() const
Alias of size(). size() is preferred.
Definition: UT_Array.h:648
SYS_FORCE_INLINE GA_Index pointIndex(GA_Offset offset) const
Given a point's data offset, return its index.
Definition: GA_Detail.h:349
Contains transitional objects to provide some backward compatibility for code that references old GEO...
GEO_API const TypeMask GEOPRIMALL
GLsizeiptr size
Definition: glcorearb.h:664
static const UT_Array< GA_AttribSaveDataH9 > & theEmptySaveAttribs
Convience objects to pass as arguments to saveH9()/loadH9().
SYS_FORCE_INLINE PolygonIterator(const GEO_PrimPolySoup &prim, GA_Size polygon)
GEO_PrimPolySoup(GA_Detail *d, GA_Offset offset=GA_INVALID_OFFSET)
fpreal64 fpreal
Definition: SYS_Types.h:277
SYS_FORCE_INLINE GA_Index getVertexIndex(GA_Size i) const
GLuint index
Definition: glcorearb.h:786
UT_Vector3 baryCenter() const override
SYS_FORCE_INLINE PolygonIterator(const GEO_PrimPolySoup &prim)
GLfloat GLfloat v1
Definition: glcorearb.h:817
VertexIterator operator+(GA_Size i)
Container class for all geometry.
Definition: GA_Detail.h:96
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:857
T p0() const
Definition: GA_Edge.h:34
SYS_FORCE_INLINE GA_Size getFastVertexCount() const
#define SYSmin(a, b)
Definition: SYS_Math.h:1571
void getPolygonVertexRange(GA_Size polygon, GA_Size &start, GA_Size &count) const
T * getArray() const
Definition: UT_Array.h:836
virtual void iterateEdgesByVertex(GA_IterateEdgesByVertexFunc apply_func) const
Definition: GA_Primitive.h:372
virtual void stashed(bool beingstashed, GA_Offset offset=GA_INVALID_OFFSET)
static GA_PrimitiveFamilyMask buildFamilyMask()
Definition: GEO_TriMesh.h:188
GLint GLsizei count
Definition: glcorearb.h:405
SYS_FORCE_INLINE const GEO_PrimPolySoup & prim() const
iteratorT< const GA_PolyCounts, const UT_Array< SizeCount > > & operator=(const iteratorT< const GA_PolyCounts, const UT_Array< SizeCount > > &that)
GA_Size getMinPolygonSize() const
Return the minimum number of vertices in any face.