HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GU_Detail.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: GU_Detail.h (GU Library, C++)
7  *
8  * COMMENTS:
9  * Header file for GU_Detail class...
10  *
11  */
12 
13 #pragma once
14 
15 #ifndef __GU_Detail_h__
16 #define __GU_Detail_h__
17 
18 #include "GU_API.h"
19 #include "GU_Error.h"
20 #include "GU_PrimitiveFactory.h"
21 #include "GU_SelectType.h"
22 #include "GU_Types.h"
23 
24 #include <GEO/GEO_Detail.h>
25 #include <GEO/GEO_PrimType.h>
26 #include <GEO/GEO_SurfaceType.h>
27 
28 #include <GA/GA_Detail.h>
29 #include <GA/GA_ElementGroup.h>
30 #include <GA/GA_Handle.h>
31 #include <GA/GA_IntrinsicManager.h>
32 #include <GA/GA_OffsetList.h>
33 #include <GA/GA_PrimitiveTypeId.h>
34 #include <GA/GA_Range.h>
35 #include <GA/GA_Types.h>
36 
37 #include <UT/UT_Array.h>
38 #include <UT/UT_ArraySet.h>
39 #include <UT/UT_ErrorManager.h> // for UTgetErrorManager()
40 #include <UT/UT_Map.h>
41 #include <UT/UT_OBBox.h>
42 #include <UT/UT_StringHolder.h>
43 #include <UT/UT_Vector2.h>
44 #include <UT/UT_Vector3.h>
45 #include <UT/UT_VectorTypes.h>
46 
47 #include <SYS/SYS_Deprecated.h>
48 #include <SYS/SYS_Types.h>
49 #include <SYS/SYS_Visibility.h>
50 
51 #include <iosfwd>
52 
53 
54 class UT_BitArray;
55 class UT_MemoryCounter;
56 class UT_StringArray;
57 class UT_WorkBuffer;
58 class UT_XformOrder;
59 template <typename T> class UT_RefMatrix;
60 template <typename T> class UT_VectorT;
62 
63 class GA_Attribute;
64 class GA_BreakpointGroup;
65 class GA_EdgeGroup;
67 class GA_Group;
68 class GA_IndexMap;
69 class GA_NUBBasis;
70 class GA_OffsetMatrix;
71 class GA_Primitive;
73 class GA_SaveOptions;
74 class GA_Stat;
75 namespace GA_PrimCompat { class TypeMask; }
76 
77 class GEO_ConvertParms;
78 class GEO_Curve;
79 class GEO_Delta;
80 class GEO_Face;
81 class GEO_Hull;
82 class GEO_IOTranslator;
84 class GEO_PolySoupParms;
85 class GEO_Primitive;
86 class GEO_PrimPoly;
87 class GEO_PrimPolySoup;
88 class GEO_Rolloff;
90 class GEO_TPSurf;
91 
92 class GU_EdgeDiv;
93 class GU_SplitLoc;
94 
95 class GU_PrimMesh;
96 class GU_PrimNURBSurf;
97 class GU_PrimPoly;
98 class GU_PrimPolySoup;
99 class GU_PrimRBezSurf;
100 
101 // Parameter classes for methods
102 class GU_AlignParms;
103 class GU_CameraParms;
104 class GU_CapOptions;
105 class GU_CapParms;
106 class GU_CreepParms;
107 class GU_CurveClayParms;
109 class GU_EdgeCreaseParms;
110 class GU_ExtrudeParms;
111 class GU_FilletParms;
112 class GU_GridParms;
113 class GU_JoinParms;
114 class GU_LoftParms;
115 class GU_LSystemParms;
116 class GU_MagnetParms;
117 class GU_OffsetParms;
118 class GU_PolyExtrudeParms;
119 class GU_PolypatchParms;
120 class GU_PolyReduceParms;
121 class GU_PolysplineParms;
122 class GU_RailParms;
123 class GU_RevolveParms;
124 class GU_RoundFilletParms;
125 class GU_RuledParms;
126 class GU_SkinCache;
127 class GU_SkinParms;
128 class GU_StitchParms;
129 class GU_SuperQuadParms;
130 class GU_SweepParms;
131 class GU_TorusParms;
132 class GU_TraceParms;
133 class GU_TrimFilletParms;
134 class GU_TwistParms;
136 
137 
138 
140 
141 extern "C" {
142  SYS_VISIBILITY_EXPORT extern void newGeometryIO(void *);
144 }
145 
146 class gu_ValueLookupCache;
147 
149 {
150 public:
151  /// NOTE: Need an explicit default constructor to work around internal
152  /// compiler error in Visual Studio 2015 Update 3.
153  /// See: https://connect.microsoft.com/VisualStudio/feedback/details/2869531
154  GU_Detail() : GU_Detail(true) {}
155  explicit GU_Detail(bool full_topology)
156  : GEO_Detail(GUgetFactory(), full_topology)
157  {
158  construct();
159  }
160  /// See GEO_Detail::merge() for documentation of the data_id_strategy
161  /// argument.
162  explicit GU_Detail(const GU_Detail *src, GA_PrimitiveGroup *primGroup,
163  GA_DataIdStrategy data_id_strategy = GA_DATA_ID_BUMP)
165  {
166  construct();
167  merge(*src, primGroup,
168  /*mergePrimGroup*/true, /*insertPrimsAtHead*/false,
169  /*dest_to_src_ptarray*/nullptr,
170  /*keep_internal_groups*/true,
171  data_id_strategy);
172  }
173  /// See GEO_Detail::copy() for documentation of the data_id_strategy
174  /// argument.
175  explicit GU_Detail(const GU_Detail *src,
176  GA_DataIdStrategy data_id_strategy = GA_DATA_ID_BUMP)
178  {
179  construct();
180  copy(*src, GEO_COPY_ONCE,
181  /*collapse_on_end*/false,
182  /*keep_internal_groups*/true,
183  data_id_strategy);
184  }
185 
186  ~GU_Detail() override;
187 
188  /// Compute memory usage (includes all shared memory)
189  int64 getMemoryUsage(bool inclusive) const override;
190 
191  /// Count memory usage using a UT_MemoryCounter in order to count
192  /// shared memory correctly.
193  /// If inclusive is true, the size of this object is counted,
194  /// else only memory owned by this object is counted.
195  /// If this is pointed to by the calling object, inclusive should be true.
196  /// If this is contained in the calling object, inclusive should be false.
197  /// (Its memory was already counted in the size of the calling object.)
198  void countMemory(UT_MemoryCounter &counter, bool inclusive) const override;
199 
200  /// This clears any caches that subclasses of GA_Detail may have, so that
201  /// replacing the content of the detail doesn't cause crashes.
202  void clearCaches() override;
203 
204  void duplicate(const GU_Detail& gdp, int = 0,
205  GA_DataIdStrategy data_id_strategy = GA_DATA_ID_BUMP);
206 
207  /// Create a new detail that has all the same attributes, groups, etc. but
208  /// has no elements.
209  /// Subclasses should look at: cloneCopyGroupsAndAttributes()
210  GA_Detail *cloneEmptyDetail(bool clone_attributes) const override;
211 
212  class RingRef
213  {
214  public:
216  const UT_IntArray &ringvalence)
217  : myRingZero(ringzero)
218  , myRingValence(ringvalence)
219  {
220  }
221 
223  { return myRingZero; }
224  const UT_IntArray & ringValence() const
225  { return myRingValence; }
226 
227  public:
230  };
231 
232  /// This initializes the passed in int array so it is 0 where
233  /// points are a boundary and 1 where they are not a boundary.
234  /// This handles meshes, etc, properly. It doesn't handle non-manifold
235  /// properly. The checkuv flag determines if it should check uv
236  /// boundaries, if set, it will mark as 1 any points which have
237  /// differing UV texture coordinates in their vertices.
238  /// For efficiency, you may call buildRingZero() once and pass the built
239  /// data structures to it.
240  void findBoundaryPoints(
241  UT_BitArray &isboundary,
242  bool checkuv,
243  const RingRef *ringref = nullptr,
244  const UT_StringHolder &uvattribname = "uv"_UTsh) const;
245 
246  /// This takes an array which should be the same size as the number
247  /// of points, and has 1 wherever a point is to be considered
248  /// selected. It then initializes & sets 1 in the isboundary array
249  /// any point which is on the 8-way boundary of the selection.
250  void findSelectionBoundaryPoints(
251  const UT_BitArray &pointselection,
252  UT_BitArray &isboundary) const;
253 
254  /// Fills the ringzero array, (which is indexed by point GA_Index,
255  /// not GA_Offset), with the GA_Offsets of each point's neighbours,
256  /// (i.e. they share an edge in some primitive). It avoids
257  /// duplicates within each point's list of neighbours.
258  /// If ringvalence is non-nullptr, it is filled with the number of
259  /// half-edges each point is part of, i.e. including duplicates
260  /// and both directions.
261  void buildRingZeroPoints(
262  UT_Array<GA_OffsetArray> &ringzero,
263  UT_IntArray *ringvalence = 0) const;
264 
265  /// Fills the ringzero array, (which is indexed by point GA_Index,
266  /// not GA_Offset), with the GA_Offsets of each point's neighbours,
267  /// (i.e. they share an edge in some primitive). It avoids
268  /// duplicates within each point's list of neighbours.
269  /// If ringvalence is non-nullptr, it is filled with the number of
270  /// half-edges each point is part of, i.e. including duplicates
271  /// and both directions.
272  ///
273  /// In this version, an edge is only counted if it is in a primitive
274  /// in primgroup (if non-nullptr). Although only entries for
275  /// points in ptgroup (if non-nullptr) are written-to in ringzero
276  /// and ringvalence (if non-nullptr), neighbours outside of ptgroup
277  /// will be listed.
278  void buildRingZeroPoints(
279  const GA_PointGroup *ptgroup,
280  UT_Array<GA_OffsetArray> &ringzero,
281  UT_IntArray *ringvalence = 0,
282  const GA_PrimitiveGroup *primgroup = 0) const;
283 
284  /// NOTE: Unlike buildRingZeroPoints, the array in buildRingZeroVertices
285  /// is indexed by GA_Offset, not GA_Index, for simplicity.
286  void buildRingZeroVertices(
287  UT_Array<GA_OffsetArray> &ringzero,
288  const GA_PrimitiveGroup *prims=0) const;
289 
290  void buildRingZeroPrimitives(
291  UT_Array<GA_OffsetArray> &ringzero) const;
292 
293  //
294  // Build various geometries. Returns the first primitive of the new
295  // geometry.
296  //
297 
298  /// Creates a polygon cube in this detail.
299  /// NOTE: Set doConsolidatePoints to true in order to have
300  /// correctly connected polygons. The default behaviour
301  /// produces disconnected sides!
302  GU_PrimPoly *cube(float xmin = -1, float xmax = 1,
303  float ymin = -1, float ymax = 1,
304  float zmin = -1, float zmax = 1,
305  int xdiv = 0, int ydiv = 0, int zdiv = 0,
306  int enforcementBars = 0,
307  int doConsolidatePoints = 0);
308 
309  GU_PrimNURBSurf *nurbCube(int xdiv, int ydiv, int zdiv,
310  int orderx = 4, int ordery = 4, int orderz=4,
311  float xmin = -0.5F, float xmax = 0.5F,
312  float ymin = -0.5F, float ymax = 0.5F,
313  float zmin = -0.5F, float zmax = 0.5F,
315  bool consolidate = false);
316 
317  GU_PrimRBezSurf *bezCube(int xdiv, int ydiv, int zdiv,
318  int orderx = 4, int ordery = 4, int orderz=4,
319  float xmin = -0.5F, float xmax = 0.5F,
320  float ymin = -0.5F, float ymax = 0.5F,
321  float zmin = -0.5F, float zmax = 0.5F,
323  bool consolidate = false);
324 
325  GU_PrimMesh *meshCube(int xdiv, int ydiv, int zdiv,
326  float xmin = -0.5F, float xmax = 0.5F,
327  float ymin = -0.5F, float ymax = 0.5F,
328  float zmin = -0.5F, float zmax = 0.5F,
330  bool consolidate = false);
331 
332  GU_PrimPoly *polymeshCube(int xdiv, int ydiv, int zdiv,
333  float xmin = -0.5F, float xmax = 0.5F,
334  float ymin = -0.5F, float ymax = 0.5F,
335  float zmin = -0.5F, float zmax = 0.5F,
337  bool consolidate = false);
338 
339  /// Creates a grid in this detail based on parms.
340  /// Returns the offset of the first polygon primitive.
343 
344  /// Creates a grid of points in this detail.
345  /// NOTE: If startpoint is valid, it must refer to a *contiguous*
346  /// block of rows*cols point offsets, in which case, this
347  /// just sets point positions, so can be used on polygon
348  /// or polysoup grids with a consistent point order too.
349  /// NOTE: When plane is GU_PLANE_XY, cols corresponds with x, and
350  /// rows corresponds with y.
351  GA_Offset pointGrid(int rows, int cols,
352  float xsize=1, float ysize=1,
353  float xc = 0, float yc = 0, float zc = 0,
355  GA_Offset startpoint = GA_INVALID_OFFSET);
356 
357  /// Creates a grid of polygons in this detail.
358  /// Returns the offset of the first polygon primitive.
359  GA_Offset polyGrid(int rows, int cols,
360  float xsize=1, float ysize=1,
361  float xc = 0, float yc = 0, float zc = 0,
364  /// Creates a grid that is a single polygon soup in this detail.
365  GU_PrimPolySoup *polySoupGrid(int rows, int cols,
366  float xsize=1, float ysize=1,
367  float xc = 0, float yc = 0, float zc = 0,
370  GU_PrimMesh *meshGrid(int rows, int cols,
371  float xsize=1, float ysize=1,
372  float xc = 0, float yc = 0, float zc = 0,
375  int wrapu = 0, int wrapv = 0);
376  GU_PrimNURBSurf *nurbGrid(int rows, int cols,
377  int orderu = 4, int orderv = 4,
378  int interpEndsU = 1, int interpEndsV = 1,
379  float xsize=1, float ysize=1,
380  float xc = 0, float yc = 0, float zc = 0,
383  int wrapu = 0, int wrapv = 0);
384  GU_PrimRBezSurf *bezGrid(int rows, int cols,
385  int orderu = 4, int orderv = 4,
386  float xsize=1, float ysize=1,
387  float xc = 0, float yc = 0, float zc = 0,
390  int wrapu = 0, int wrapv = 0);
391 
392  /// Creates a torus in this detail, based on parms.
393  /// type is one of the values in the enum in GA_PrimitiveTypes.h .
394  /// GA_PRIMPOLY, GA_PRIMPOLYSOUP, GA_PRIMMESH, GA_PRIMBEZSURF,
395  /// and GA_PRIMNURBSURF are supported.
396  void torus(unsigned type, GU_TorusParms &parms);
397 
398  /// poly-iso surfaces
399  /// To find the primitives created, place
400  /// GA_IndexMap::Marker marker(gdp->getPrimitiveMap());
401  /// before the call, and call marker.getRange() afterward.
402  void polyIsoSurface(
403  float (*ptOutside)(const UT_Vector3 &, void *),
404  void *data,
405  const UT_BoundingBox &bbox,
406  int xdiv, int ydiv, int zdiv,
407  bool makepolysoup = false);
408 
409  /// When building a meta-surface, the new surface is built in this
410  /// gdp. If desired, src can be "this" as well...
411  void buildMetaSurface(const GU_Detail *src, float lod,
412  const GA_PrimitiveGroup *primGroup = 0,
413  bool makepolysoup = false);
414 
415  void buildMetaSurface(const GU_Detail *src,
416  int divx, int divy, int divz,
417  const GA_PrimitiveGroup *primGroup = 0,
418  bool makepolysoup = false);
419 
420  /// A faster way of conversion is to build cross sections. However, this
421  /// doesn't build real surfaces
422  void buildMetaXsection(
423  const GU_Detail *src,
424  int nsections,
425  int axis = 2,
426  int maxdepth = 4,
427  const GA_PrimitiveGroup *primGroup = nullptr);
428 
429  //
430  // Geometry filters
431  //
432 
433 
434  /// orient all the polygonal faces to have the same winding direction
435  void orient(const GA_PrimitiveGroup *group = 0);
436 
437  /// inset and extrude a face
438  void extrude(GU_ExtrudeParms &parms);
439 
440  /// create a weighted sum of two source inputs
441  /// This bumps data IDs of any attributes that are modified, and of
442  /// the primitive list, if any primitives are modified.
443  void blend(const GU_Detail *source, float weight,
444  bool doPos, bool doClr, bool doNml, bool doTxt,
445  bool doVoxels, bool doSlerp,
446  const char *ptidattr, const char *primidattr);
447 
448 
449  /// create a weighted sum of size source inputs
450  /// Return 1 if at least one pasted surface was involved in the blend,
451  /// else 0.
452  /// This bumps data IDs of any attributes that are modified, and of
453  /// the primitive list, if any primitives are modified.
454  int blend(const GU_Detail *gdps[], const float weights[],
455  int size, bool doPos, bool doClr,
456  bool doNml, bool doTxt,
457  bool doVoxels, bool doSlerp,
458  const char *ptidattr, const char *primidattr,
459  const GA_PointGroup *ptGroup);
460 
461  /// Transform points to follow surface of path input
462  void creep(GU_CreepParms &parms);
463 
464  /// Consolidate points within a specified distance (returns num done)
465  /// If a point group is specified, then, only points in that
466  /// group are consolidated. If the forceConsAll flag is set then
467  /// all points will be consolidated in a greedy fashion using a
468  /// branch and bound algorithm.
469  SYS_DEPRECATED_HDK_REPLACE(17.5,GU_Snap)
470  GA_Size consolidatePoints(fpreal distance,
471  const GA_PointGroup *ptGrp = 0,
472  bool forceConsAll = false,
473  bool mark = false,
474  bool accurate = false);
475 
476  /// Performs fast consolidation by calling onlyConsolidatePoints.
477  /// By default, calls removeUnused when done to remove any unused points
478  /// When deleteConsOnly is set, then only consolidated points are removed.
479  SYS_DEPRECATED_HDK_REPLACE(17.5,GU_Snap)
480  GA_Size fastConsolidatePoints(fpreal distance,
481  const GA_PointGroup *ptGrp=0,
482  bool mark = false,
483  bool accurate = false);
484 
485  /// Specifies methods by which points after consolidation will
486  /// get their group names. ONLYCONS_GRP_PROP_LEAST means that the
487  /// points will belong to the same group as the original point
488  /// with least point number. ONLYCONS_GRP_PROP_UNION means that the
489  /// points will belong to the full set of groups represented
490  /// by the original points (so if orig. point 1 is in group A, B and
491  /// orig. point 2 is in group B, C, the final point will be in A B C).
492  /// INTERSECT means the point will only belong in groups that are common
493  /// to all original points. With the example above, it will belong in
494  /// B.
496  {
497  ONLYCONS_GRP_PROP_LEAST = 0,
499  ONLYCONS_GRP_PROP_INTERSECT
500  };
501  /// This does fast consolidation but does *not* call removeUnused when
502  /// done. This means that degenerate primitives will be left along
503  /// with orphaned points. If deleteconsolidated is set, the consolidated
504  /// points only will be deleted. grouppropagate controls which groups
505  /// the new points will belong to.
506  SYS_DEPRECATED_HDK_REPLACE(17.5,GU_Snap)
507  GA_Size onlyConsolidatePoints(fpreal distance,
508  const GA_PointGroup *ptgrp = 0,
509  bool mark = false,
510  bool deleteconsolidated = false,
511  OnlyConsGroupPropagateType
512  grouppropagate =
513  ONLYCONS_GRP_PROP_LEAST,
514  bool accurate = false);
515 
516  GA_Size consolidateNormals(fpreal distance,
517  const GA_PointGroup *ptGrp = 0,
518  bool forceConsAll = false,
519  bool accurate = false);
520  GA_Size fastConsolidateNormals(fpreal distance,
521  const GA_PointGroup *ptGrp = 0,
522  bool accurate = false);
523  /// Consolidate UV attributes within a specified distance.
524  /// This distance can be in UV space or XYZ space.
525  /// There are various methods of placing the consolidated UVs.
526  ///
527  /// metric: 0 => UV space
528  /// 1 => XYZ space
529  ///
530  /// method: 0 => Average
531  /// 1 => First in Group
532  /// 2 => Specify uvw coordinate
533  SYS_DEPRECATED_HDK_REPLACE(17.5,GU_Snap)
534  int fastConsolidatePointUVs(float distance,
535  const GA_PointGroup &ptGrp,
536  const GU_MetricType metric,
537  int method,
538  UT_Vector3 &uvw);
539  SYS_DEPRECATED_HDK_REPLACE(17.5,GU_Snap)
540  int fastConsolidatePointUVs(const GA_RWHandleV3 &uvattrib,
541  float distance,
542  const GA_PointGroup &ptGrp,
543  const GU_MetricType metric,
544  int method,
545  UT_Vector3 &uvw);
546  int fastConsolidateVertexUVs(float distance,
547  const GA_VertexGroup &vtxGrp,
548  const GU_MetricType metric,
549  int method,
550  UT_Vector3 &uvw);
551  int fastConsolidateVertexUVs(const GA_RWHandleV3 &uvattrib,
552  float distance,
553  const GA_VertexGroup &vtxGrp,
554  const GU_MetricType metric,
555  int method,
556  UT_Vector3 &uvw);
557 
558  /// Snap points within a specified distance (returns num done)
559  /// If a point group is specified, then, only points in that
560  /// group are consolidated.
561  /// Snapping doesn't fuse the points together, just makes their
562  /// positions match.
563  /// The type is 0 for average, 1 for round to lowest point number
564  /// and 2 for highest point number.
565  /// snappointpos controls whether the point positions will be
566  /// snapped.
567  /// snapptattribs can be set to indicate that point attributes
568  /// are to be snapped.
569  /// ptattribhandles is a list of attribute handles for the
570  /// attributes that will be snapped.
571  SYS_DEPRECATED_HDK_REPLACE(17.5,GU_Snap)
572  GA_Size snapPoints(int type, fpreal distance,
573  const GA_PointGroup *ptgrp=0,
574  bool snapptpos = true,
575  UT_Array<GA_Attribute *> *ptattribs = 0,
576  bool accurate = true);
577 
578  /// Methods for snapping attributes (for use with snapAttributes).
579  /// SNAP_ATTRIBUTE_AVERAGE averages the attributes together.
580  /// SNAP_ATTRIBUTE_INDEX tells snapAttributes to use an index
581  /// into the list of snapped points to set the attributes for
582  /// other points.
584  {
585  SNAP_ATTRIBUTES_AVERAGE = 0,
586  SNAP_ATTRIBUTES_INDEX
587  };
588 
589  /// This version of snapping snaps onto grid coordinates. You specify
590  /// the number of lines per HUnit, so "2" for example will snap to 0.5
591  /// boundaries.
592  /// type is 0 for round nearest, 1 for round down, 2 for round up.
593  /// 0.5 rounds up in nearest.
594  SYS_DEPRECATED_HDK_REPLACE(17.5,GU_Snap)
595  void snapGrid(int type,
596  float xlines, float ylines, float zlines,
597  float xoff, float yoff, float zoff,
598  float tol,
599  const GA_PointGroup *ptGrp=0);
600  /// Same as above, but with UVs...
601  SYS_DEPRECATED_HDK_REPLACE(17.5,GU_Snap)
602  void snapGridPointUVs(int type,
603  float xlines, float ylines, float zlines,
604  float xoff, float yoff, float zoff,
605  float tol,
606  const GA_PointGroup *ptGrp=0);
607  SYS_DEPRECATED_HDK_REPLACE(17.5,GU_Snap)
608  void snapGridPointUVs(
609  const GA_RWHandleV3 &uvattrib, int type,
610  float xlines, float ylines, float zlines,
611  float xoff, float yoff, float zoff,
612  float tol,
613  const GA_PointGroup *ptGrp=0);
614  SYS_DEPRECATED_HDK_REPLACE(17.5,GU_Snap)
615  void snapGridVertexUVs(int type,
616  float xlines, float ylines, float zlines,
617  float xoff, float yoff, float zoff,
618  float tol,
619  const GA_VertexGroup *vtxGrp=0);
620  SYS_DEPRECATED_HDK_REPLACE(17.5,GU_Snap)
621  void snapGridVertexUVs(
622  const GA_RWHandleV3 &uvattrib, int type,
623  float xlines, float ylines, float zlines,
624  float xoff, float yoff, float zoff,
625  float tol,
626  const GA_VertexGroup *vtxGrp=0);
627 
628  /// Build holes in the geometry by bridging the holes to their outlines
629  /// The angle should be specified as the angle (in degrees) between
630  /// the normals.
631  int buildHoles(float dist = 0.001F, float angle = 0.2F,
632  int snapFace=0,
633  const GA_PrimitiveGroup *primGroup=0);
634 
635  /// Remove bridged holes from other than polygons
636  void unHole(const GA_PrimitiveGroup *primGroup=0);
637 
638  /// Unique all points in the detail. If a point group is specified,
639  /// then only points in that group are uniqued
640  /// If a primitive group is specified, only those primitives will
641  /// have their points uniqued.
643  void uniquePoints(const GA_PointGroup *group=0);
644 
645  /// Unique all the points that are in this primitive, even if referenced
646  /// by other primitives.
648  void uniquePrimitive(GEO_Primitive *prim);
649 
650  /// Remove repeated references of vertices in the faces, then remove all
651  /// degenerate primitives regardless of their type.
652  /// Set removeRepPoints flag to remove the repeat points as well and
653  /// the deletePoints flag to delete the points that were part of the
654  /// degenerate primitive.
655  GA_Size cleanData (const GA_PrimitiveGroup *primGrp=0,
656  bool removeRepPoints = false,
657  float tol = 0.001F,
658  bool deleteDegenPrimPoints = false,
659  bool deleteOrphanedPoints = false,
660  bool deleteDegenerateBridges = false);
661 
662  /// Identify dirty data, which is the degenerate primitives that would
663  /// be deleted by cleanData. Return them in the returnGrp, and return
664  /// the number of dirty primitives. If returnGrp is nullptr then only
665  /// return the count.
666  GA_Size getDirtyData (GA_PrimitiveGroup *returnGrp,
667  const GA_PrimitiveGroup *primGrp=0,
668  bool checkRepPoints = false,
669  float tol = 0.001F);
670 
671  /// If the applyToVertex is less than 0, the "natural" place will be use,
672  /// otherwise 0 = point attrib, 1 = vertex attrib
673  /// Returns false if the attribute failed to be created, else true.
674  bool applyTexture(GU_TextureType type, GU_AxisType axis,
675  const GA_PrimitiveGroup *primGroup=0,
676  int applyToVertex = -1, int fixPolySeams = 0,
677  const GU_CameraParms *userData = 0);
678  /// If the applyToVertex is less than 0, the "natural" place will be use,
679  /// otherwise 0 = point attrib, 1 = vertex attrib
680  /// Returns false if the attribute failed to be created, else true.
681  bool applyTexture(const UT_StringRef &uvattribname,
682  GU_TextureType type, GU_AxisType axis,
683  const GA_PrimitiveGroup *primGroup=0,
684  int applyToVertex = -1, int fixPolySeams = 0,
685  const GU_CameraParms *userData = 0);
686  /// The scaleTexture() and rotateTexture() methods are depreciated. Please
687  /// use the GU_MODIFY_TEX projection and simply create the approprate
688  /// post-transform.
689  /// Returns false if the attribute failed to be created, else true.
690  bool scaleTexture(float umult = 1, float uoff = 0,
691  float vmult = 1, float voff = 0,
692  float wmult = 1, float woff = 0,
693  const GA_PrimitiveGroup *primGroup=0);
694  bool scaleTexture(const UT_StringRef &uvattribname,
695  float umult = 1, float uoff = 0,
696  float vmult = 1, float voff = 0,
697  float wmult = 1, float woff = 0,
698  const GA_PrimitiveGroup *primGroup=0);
699  bool rotateTexture(float angle,
700  const GA_PrimitiveGroup *primGroup=0);
701  bool rotateTexture(const UT_StringRef &uvattribname,
702  float angle,
703  const GA_PrimitiveGroup *primGroup=0);
704 
705  /// Methods for transforming point and vertex texture attributes:
706  void transformPointTexture(const UT_Matrix4& mat,
707  const GA_PointGroup *ptGroup=nullptr,
708  GEO_Delta *geodelta=0);
709 
710  void transformPointTexture(
711  const GA_RWHandleV3 &pth,
712  const UT_Matrix4& mat,
713  const GA_PointGroup *ptGroup=nullptr,
714  GEO_Delta *geodelta=0);
715 
716  /// Precompute a list of points to soft transform, along with
717  /// the distance (squared) to the closest "hard" point.
718  /// The metric specifies how distance is measured in space.
719  void computeSoftTransformPointTextureCache(
720  GEO_SoftTransformCache &cache,
721  const GA_PointGroup *ptgroup,
722  const GEO_Rolloff &rolloff,
723  const GU_MetricType metric) const;
724 
725  /// Precompute a list of points to soft transform, along with
726  /// the distance (squared) to the closest "hard" point.
727  /// The metric specifies how distance is measured in space.
728  void computeSoftTransformPointTextureCache(
729  const GA_ROHandleV3 &pttxth,
730  GEO_SoftTransformCache &cache,
731  const GA_PointGroup *ptgroup,
732  const GEO_Rolloff &rolloff,
733  const GU_MetricType metric) const;
734 
735  /// falloff_output - any non-zero falloffs used during this call will be
736  /// written to this attribute when provided
737  /// falloff_written - will be set to true when provided if falloff_output
738  /// is provided, and this call did not skip processing
739  /// any non-zero falloffs. If not set, you must call
740  /// computeSoftPointFalloff() to obtain the falloffs.
741  void softTransformPointTexture(
742  const UT_XformOrder &order,
743  float tx, float ty, float tz,
744  float rx, float ry, float rz,
745  float sx, float sy, float sz,
746  float s_xy, float s_xz, float s_yz,
747  float px, float py, float pz,
748  const GEO_SoftTransformCache &cache,
749  const GEO_Rolloff &rolloff,
750  GEO_Delta *geodelta = 0,
751  const GA_RWHandleF *falloff_output = nullptr,
752  bool *falloff_written = nullptr);
753 
754  /// falloff_output - any non-zero falloffs used during this call will be
755  /// written to this attribute when provided
756  /// falloff_written - will be set to true when provided if falloff_output
757  /// is provided, and this call did not skip processing
758  /// any non-zero falloffs. If not set, you must call
759  /// computeSoftPointFalloff() to obtain the falloffs.
760  void softTransformPointTexture(
761  const GA_RWHandleV3 &ptattr,
762  const UT_XformOrder &order,
763  float tx, float ty, float tz,
764  float rx, float ry, float rz,
765  float sx, float sy, float sz,
766  float s_xy, float s_xz, float s_yz,
767  float px, float py, float pz,
768  const GEO_SoftTransformCache &cache,
769  const GEO_Rolloff &rolloff,
770  GEO_Delta *geodelta = 0,
771  const GA_RWHandleF *falloff_output = nullptr,
772  bool *falloff_written = nullptr);
773 
774  void transformVertexTexture(const UT_Matrix4& mat,
775  const GA_VertexGroup *vertexGroup=nullptr,
776  GEO_Delta *geodelta=0);
777 
778  void transformVertexTexture(
779  const GA_RWHandleV3 &vtxh,
780  const UT_Matrix4& mat,
781  const GA_VertexGroup *vertexGroup=nullptr,
782  GEO_Delta *geodelta=0);
783 
784  /// Precompute a list of vertices to soft transform, along with
785  /// the distance (squared) to the closest "hard" point.
786  /// The metric specifies how distance is measured in space.
787  /// ignore_uv_connectivity controls whether we affect vertices
788  /// which are not in the same uvw-wise connected component.
789  void computeSoftTransformVertexTextureCache(
790  GEO_SoftTransformCache &cache,
791  const GA_VertexGroup *vtxgroup,
792  const GEO_Rolloff &rolloff,
793  const GU_MetricType metric,
794  bool ignore_uv_connectivity) const;
795 
796  /// Precompute a list of vertices to soft transform, along with
797  /// the distance (squared) to the closest "hard" point.
798  /// The metric specifies how distance is measured in space.
799  /// ignore_uv_connectivity controls whether we affect vertices
800  /// which are not in the same uvw-wise connected component.
801  void computeSoftTransformVertexTextureCache(
802  const GA_ROHandleV3 &vtxh,
803  GEO_SoftTransformCache &cache,
804  const GA_VertexGroup *vtxgroup,
805  const GEO_Rolloff &rolloff,
806  const GU_MetricType metric,
807  bool ignore_uv_connectivity) const;
808 
809  /// falloff_output - any non-zero falloffs used during this call will be
810  /// written to this attribute when provided
811  /// falloff_written - will be set to true when provided if falloff_output
812  /// is provided, and this call did not skip processing
813  /// any non-zero falloffs. If not set, you must call
814  /// computeSoftPointFalloff() to obtain the falloffs.
815  void softTransformVertexTexture(
816  const UT_XformOrder &order,
817  float tx, float ty, float tz,
818  float rx, float ry, float rz,
819  float sx, float sy, float sz,
820  float s_xy, float s_xz, float s_yz,
821  float px, float py, float pz,
822  const GEO_SoftTransformCache &cache,
823  const GEO_Rolloff &rolloff,
824  GEO_Delta *geodelta = 0,
825  const GA_RWHandleF *falloff_output = nullptr,
826  bool *falloff_written = nullptr);
827 
828  /// falloff_output - any non-zero falloffs used during this call will be
829  /// written to this attribute when provided
830  /// falloff_written - will be set to true when provided if falloff_output
831  /// is provided, and this call did not skip processing
832  /// any non-zero falloffs. If not set, you must call
833  /// computeSoftPointFalloff() to obtain the falloffs.
834  void softTransformVertexTexture(
835  const GA_RWHandleV3 &vtxh,
836  const UT_XformOrder &order,
837  float tx, float ty, float tz,
838  float rx, float ry, float rz,
839  float sx, float sy, float sz,
840  float s_xy, float s_xz, float s_yz,
841  float px, float py, float pz,
842  const GEO_SoftTransformCache &cache,
843  const GEO_Rolloff &rolloff,
844  GEO_Delta *geodelta = 0,
845  const GA_RWHandleF *falloff_output = nullptr,
846  bool *falloff_written = nullptr);
847 
848  /// This routine will compute the average normal of a group of points.
849  /// Returns true on success and false on failure.
850  /// NOTE: The version that doesn't take a point normal attribute handle
851  /// will temporarily create a detached point normal attribute if a point N
852  /// doesn't already exist. The caller may or may not want to cache
853  /// a detached attribute and pass it in, instead.
854  /// @{
855  bool computeAvgNormal(
856  const GA_PointGroup *group,
857  const GA_ROHandleV3 &normals,
858  UT_Vector3 &avg_normal) const;
859  bool computeAvgNormal(
860  const GA_PointGroup *group,
861  UT_Vector3 &avg_normal) const;
862  /// @}
863 
864  /// Reverse polygons
865  void reversePolys(const GA_PrimitiveGroup *prmGrp=0);
866 
867  /// Conversion Routines - to convert from one primitive to another
868  /// @{
869  void convert(GEO_ConvertParms &parms);
870  void convertNew(GEO_ConvertParms &parms);
871  /// @}
872 
873  /// This routine only converts metaballs using a more comprehensive set
874  /// of parameters.
875  void convertMetaballs(
876  GEO_MetaConvertParms &parms,
877  const GA_PrimitiveGroup *prim_grp = nullptr);
878 
879  //
880  // SORTING
881  //
882 
883  /// Sort by the specified dominant axis
884  /// @{
885  void sortPoints(GA_IndexMap &array,
886  GU_AxisType axis = GU_XAXIS);
887  void sortPoints(GA_OffsetArray &array,
888  GU_AxisType axis = GU_XAXIS);
889  void sortPrims(GA_IndexMap &array,
890  GU_AxisType axis = GU_XAXIS);
891  void sortPointList(GU_AxisType axis)
892  { sortPoints(getIndexMap(GA_ATTRIB_POINT), axis); }
894  { sortPrims(getIndexMap(GA_ATTRIB_PRIMITIVE), axis); }
895  /// @}
896 
897  /// Sorting by spatial locality. The points and primitives will be
898  /// sorted in a way that tries to assign nearby primitives closer
899  /// primitive ids.
900  /// @{
901  void sortPointsSpatial();
902  void sortPrimsSpatial();
903  /// @}
904 
905  /// Sort along an arbitrary vector
906  /// @{
907  void sortPoints(GA_IndexMap &array,
908  const UT_Vector3 &o, const UT_Vector3 &d);
909  void sortPrims(GA_IndexMap &array,
910  const UT_Vector3 &o, const UT_Vector3 &d);
911  void sortPointList(const UT_Vector3 &o, const UT_Vector3 &d)
912  { sortPoints(getIndexMap(GA_ATTRIB_POINT), o, d); }
914  const UT_Vector3 &d)
915  { sortPrims(getIndexMap(GA_ATTRIB_PRIMITIVE), o, d); }
916  /// @}
917 
918  /// Sort in random order
919  /// @{
920  void sortPoints(GA_IndexMap &array, int seed);
921  void sortPrims(GA_IndexMap &array, int seed);
922  void sortPointList(int seed)
923  { sortPoints(getIndexMap(GA_ATTRIB_POINT), seed); }
924  void sortPrimitiveList(int seed)
925  { sortPrims(getIndexMap(GA_ATTRIB_PRIMITIVE), seed); }
926  /// @}
927 
928  /// Sorting according to a provided value list
929  /// @{
930  void sortElements(GA_IndexMap &array, fpreal *order);
932  { sortElements(getIndexMap(GA_ATTRIB_POINT), order); }
934  { sortElements(getIndexMap(GA_ATTRIB_PRIMITIVE), order); }
935  /// @}
936 
937  /// "Rotate" (cycle) the order of vertices for all primitives in the group,
938  /// by the specified number of places.
939  void shift(int uoffset, int voffset,
940  const GA_PrimitiveGroup *group = nullptr);
941 
942  /// "Rotate" (cycle) the order of points or primitives in the detail, by the
943  /// specified number of places.
944  /// @{
945  void shiftPoints(GA_IndexMap &, GA_Size offset);
946  void shiftPrims(GA_IndexMap &, GA_Size offset);
947  void shiftPointList(GA_Size aoffset)
948  { shiftPoints(getIndexMap(GA_ATTRIB_POINT), aoffset); }
950  { shiftPrims(getIndexMap(GA_ATTRIB_PRIMITIVE), aoffset); }
951  /// @}
952 
953  /// Reverse vertices for all primitives in the group
954  void reverse(const GA_PrimitiveGroup *group = nullptr);
955 
956  /// Reverse order of points or primitives in the detail.
957  /// @{
958  void reversePoints(GA_IndexMap &map);
959  void reversePrims(GA_IndexMap &map);
961  { reversePoints(getIndexMap(GA_ATTRIB_POINT)); }
963  { reversePrims(getIndexMap(GA_ATTRIB_PRIMITIVE)); }
964  /// @}
965 
966  /// Sort points or primitives by proximity to a position
967  /// @{
968  void proximityPoints(GA_IndexMap &points,
969  const UT_Vector3 &point);
970  void proximityPrims(GA_IndexMap &primitives,
971  const UT_Vector3 &point);
972  void proximityToPointList(const UT_Vector3 &point)
973  { proximityPoints(getIndexMap(GA_ATTRIB_POINT), point); }
975  { proximityPrims(getIndexMap(GA_ATTRIB_PRIMITIVE), point); }
976  /// @}
977 
978  /// Sort points by the order in which they are first referred-to by
979  /// vertices.
980  /// @{
981  void vertexOrder(GA_IndexMap &points);
983  { vertexOrder(getIndexMap(GA_ATTRIB_POINT)); }
984  /// @}
985 
986  /// Create a mesh primitive or polygon primitives representing a
987  /// super-quadric surface specified by parms.
988  void superEllipsoid(const GU_SuperQuadParms &parms);
989 
990  /// Split the specified polygon into convex polygons with at most
991  /// maxpts vertices each. By default, this triangulates the polygon.
992  /// If flipedges is true, it will flip edges to get the Delaunay
993  /// triangulation, avoiding small angles where possible.
994  /// If avoiddegeneracy is true, degenerate triangles will not be generated;
995  /// note that this means that the mesh may not be watertight or even
996  /// connected.
997  void convexPoly(GEO_PrimPoly *pp, GA_ElementWranglerCache &wranglers,
998  GA_Size maxpts = 3, const GA_Detail *restgdp=0,
999  bool flipedges = false, bool avoiddegeneracy = false);
1000  /// Split polygons in the specified polygon soup into convex polygons
1001  /// with at most maxpts vertices each. By default, this triangulates the
1002  /// polygon. If flipedges is true, it will flip edges to get the Delaunay
1003  /// triangulation, avoiding small angles where possible.
1004  /// If avoiddegeneracy is true, degenerate triangles will not be generated;
1005  /// note that this means that the mesh may not be watertight or even
1006  /// connected.
1007  void convexPolySoup(GEO_PrimPolySoup *polysoup,
1008  GA_Size maxpts = 3, const GA_Detail*restgdp=0,
1009  bool flipedges = false,
1010  bool avoiddegeneracy = false);
1011  /// Split polygons (including in polygon soups) in the detail into convex
1012  /// polygons with at most maxpts vertices each. By default, this
1013  /// triangulates the polygon. If flipedges is true, it will flip edges to
1014  /// get the Delaunay triangulation, avoiding small angles where possible.
1015  /// If avoiddegeneracy is true, degenerate triangles will not be generated;
1016  /// note that this means that the mesh may not be watertight or even
1017  /// connected.
1018  void convex(GA_Size maxpts=3, GA_PrimitiveGroup *primGroup=0,
1019  const GA_Detail *restgdp=0, bool flipedges = false,
1020  bool avoiddegeneracy = false);
1021 
1022  /// Add non-planar polygon primitives to nonplanargroup.
1023  GA_Size findNonPlanar(
1024  GA_PrimitiveGroup *nonplanargroup,
1025  float tol = 0.0001F,
1026  const GA_PrimitiveGroup *searchprimgroup = nullptr);
1027 
1028  /// Clip primitives, keeping everything where dot(normal, P) >= d.
1029  /// If clippts is true, disconnected points are also clipped.
1030  void clip(UT_Vector3 &normal, float d = 0, int normlize = 0,
1031  const GA_PrimitiveGroup *primGroup = 0,
1032  bool clippts = false);
1033 
1034 //
1035 // Polygon creasing
1036  void crease(UT_Vector3 &normal, float d = 0,
1037  int normlize = 0, int outputGroups = 0,
1038  GA_PrimitiveGroup *above = 0,
1039  GA_PrimitiveGroup *below = 0,
1040  const GA_PrimitiveGroup *creaseGroup = 0);
1041 //
1042 // fractals
1043  void fractalize(int seed = 1, float roughness = 0.6F,
1044  float scaleby=1, int divs=1,
1045  int fixedBoundry = 1, int useVtxNorms = 0,
1046  float nx = 0, float ny = 0, float nz = 1,
1047  const GA_PrimitiveGroup *fractalGroup = 0);
1048 
1049  //
1050  // Shrink Wrap and tools
1051 
1052  /// This routine is originally developed for the Bullet RBD solver to adjust
1053  /// the geometry of a convex 3D polygon to remove the space around the geometry
1054  /// caused by the collision margin required for the Bullet solver.
1055  void shrink( fpreal distance,
1056  fpreal clip_tolerance = 0.0001,
1057  fpreal consilidate_tolerance = 0.001);
1058 
1059  /// preliminary routine to setup the gdp to be shrunk by the shrink routine
1060  bool tetrahedralizeForShrink( const GA_PointGroup *ptGroup = 0,
1061  GU_Detail *gdp = 0 );
1062 
1063 
1064  /// Twist operations. The method returns 0 if everything goes OK, else -1.
1065  /// "pasted" returns 1 if at least one pasted surface was involved in
1066  /// the deformation, else 0.
1067  int nonLinearDeform(GU_DeformType type,const GU_TwistParms &parms,
1068  int &pasted);
1069 
1070  /// NOTE: This is something specific to NURBS surfaces and it uses
1071  /// pasted surface primitives, so it's probably not what you want!!!
1072  /// Creates an offset surface from the specified surface & radius.
1073  GEO_Hull *offset(const GU_OffsetParms &parms);
1074 
1075  /// Create a Gordon surface out of the given bi-linear network of faces.
1076  /// The faces don't have to be the same type or order or anything.
1077  /// We return the surface if OK and 0 otherwise. If the u or v faces
1078  /// contain only one face, we automatically generate a final curve. If
1079  /// both u faces and vfaces have 1 curve or one has 2 and the other 1,
1080  /// we generate a Coons surface. "accurate" is used when the curves do not
1081  /// intersect (i.e. when we must compute their min distances).
1082  /// @{
1083  GEO_Hull *gordon(GEO_SurfaceType surftype, int accurate,
1084  const GA_PrimitiveGroup &ufaces,
1085  const GA_PrimitiveGroup &vfaces,
1086  int reparameterize = 0);
1087  GEO_Hull *gordon(GEO_SurfaceType surftype, int accurate,
1088  const UT_Array<GEO_Primitive*> &uprims_in,
1089  const UT_Array<GEO_Primitive*> &vprims_in,
1090  GU_SkinCache& skin_cache,
1091  int reparameterize = 0);
1092  /// @}
1093 
1094  /// Generate a Coons surface out of up to 4 boundary curves. Return a
1095  /// pointer to the surface if successful and 0 otherwise. The faces do
1096  /// not have to have the same type or order.
1097  GEO_Hull *coons(GEO_SurfaceType surftype,
1098  const GEO_Face &uface1, const GEO_Face &vface1,
1099  const GEO_Face *uface2 = 0, const GEO_Face *vface2 = 0);
1100 
1101  /// Generate a skinned surface out of a set of cross-sections. The faces
1102  /// don't have to be the same type or order. We return the surface is OK
1103  /// and 0 otherwise. Specifying a vorder of 0 tells the method to
1104  /// come up with a legal default value for the surface. If "doskin" is
1105  /// true, the cross-sections will be right on the surface; otherwise, we
1106  /// build a ruled surface, which simply steals the curves' CVs and assigns
1107  /// them to the surface.
1108  GEO_Hull *skin(GU_SkinParms &parms, GU_SkinCache& skin_cache);
1109 
1110  /// This restrictive skinning method assumes the faces are of the same type
1111  /// and have the same number of CVs. order 0 means pick most suitable one.
1112  /// If doskin is false, we build a ruled surface. nprims is the number
1113  /// of faces in the group; we compute it if -1. We return the resulting
1114  /// surface and do not delete the input faces. We also assume that if
1115  /// nprims > 2 and vorder != 2 and doskin, all the faces are nonrational.
1116  /// Finally, the provided vParmValues if given specifies what v coordinate
1117  /// each of the provided faces should interpolate.
1118  /// @{
1119  GEO_Hull *skin(const GA_PrimitiveGroup &ucfaces,
1120  GEO_SurfaceType surftype = GEO_PATCH_QUADS,
1121  unsigned vorder = 0, int vwrap = 0,
1122  int doskin = 1, int nprims = -1,
1123  const UT_Vector *vParmValues = 0);
1124  GEO_Hull *skin(const UT_Array<GEO_Primitive*> & prims_in,
1125  GU_SkinCache& skin_cache,
1126  GEO_SurfaceType surftype = GEO_PATCH_QUADS,
1127  unsigned vorder = 0, int vwrap = 0,
1128  int doskin = 1, int nprims = -1,
1129  const UT_Vector *vParmValues = 0);
1130  /// @}
1131 
1132  /// See GU_Ruled.h for the various closure and interpolation types
1133  /// which are valid. Specifying an orderv of 0 makes the routine
1134  /// come up with a legal default value for the surface.
1135  int ruled( GEO_Hull *&surface, const GU_RuledParms &p,
1136  const GU_CapOptions &caps);
1137 
1138  /// This is what the Skin SOP and Sweep SOP use for skinning
1139  /// cross-sections.
1140  /// See GU_CurveNetwork.h for parameter types. This method generates
1141  /// a skinned surface, a Coons surface, or a Gordon surface depending on
1142  /// the primitive groups it is given. Specifying an orderv of 0 makes the
1143  /// routine come up with a legal default value for the surface.
1144  int curveNetwork(GEO_Hull *&hull, GU_CurveNetworkParms &p,
1145  int &count, GU_SkinCache& skin_cache);
1146 
1147  GU_ERROR sweep( GU_SweepParms parms );
1148  void rails( GU_RailParms parms );
1149 
1150  /// Join more faces or surfaces together.
1152 
1153  /// Generate a fillet between two curves on surfaces:
1154  GEO_Hull *filletTrims(GU_TrimFilletParms &parms, int &count);
1155 
1156  /// Generate a rounded fillet:
1157  GEO_Hull *filletRound(GU_RoundFilletParms &parms);
1158  /// NOTE: The first 5 columns of the matrix must be GEO_Curve*,
1159  /// and the other 2 columns of the matrix must be GEO_TPSurf*.
1160  void filletRoundNetwork(
1161  const UT_RefMatrix<GEO_Primitive *> &facematrix,
1162  GU_RoundFilletParms &parms);
1163 
1164  /// Fillet a set of faces/hulls
1165  /// Return 0 if OK, -1 otherwise (non face/hull types)
1166  int fillet(GU_FilletParms &parms, int &count);
1167 
1168  /// Loft (stitch) a number of polygons together without changing the number
1169  /// of points in the detail.
1170  /// @{
1171  void loft(GU_LoftParms &p, const GA_PointGroup &g1,
1172  const GA_PointGroup &g2);
1173  void loft(GU_LoftParms &p,
1174  const GA_PrimitiveGroup *group = 0);
1175  /// @}
1176 
1177  /// Revolves all curves in the given gdp (or only curves in the
1178  /// group if the group is given) around a line given by the center
1179  /// and axis. Only polygonal curves use the divisions. NURBS and
1180  /// Bezier curves are revolved a special way to create a perfectly
1181  /// round surface with a minimum number of revolution copies.
1182  int revolve( const GU_RevolveParms &parms,
1183  const GU_CapOptions &caps, int &count);
1184 
1185  /// Warp curves or surfaces. Return 0 if successful and -1 otherwise.
1186  int warp(GU_WarpParms &parms);
1187 
1188  /// Curve Clay it!
1189  GU_ERROR curveClay(const GU_CurveClayParms &ccparm);
1190 
1191  /// This puts endcaps on the specified hull
1192  int endCap(GEO_Hull &hull, const GU_CapParms &parms);
1193  int endCap(GEO_Face &face, const GU_CapParms &parms);
1194 
1195  /// This places all caps on the hull
1196  int setCaps(GEO_Hull &hull, const GU_CapOptions &parms, int &count);
1197  int setCaps(GEO_Face &face, const GU_CapOptions &parms, int &count);
1198 
1199  /// Creates a deformed copy of a source detail given a pair of
1200  /// rest and deform details. Return 1 if a pasted surface was deformed,
1201  /// else 0. If 'deform_history' is passed in, every time we deform a point
1202  /// from our source, we mark this by setting the bit in 'deform_history'
1203  /// whose index corresponds to the point's number to 1. Useful if you want
1204  /// to know which points we deformed.
1205  int lattice(const GU_Detail *source, const GU_Detail *rest,
1206  const GU_Detail *deform, int xdiv, int ydiv, int zdiv,
1207  const GA_PointGroup *ptgroup = 0,
1208  UT_BitArray *deform_history = nullptr,
1210 
1211  /// All points of the gdp are deformed according to the meta source
1212  /// field that surrounds it. The deformation is controlled by a
1213  /// transformation matrix.
1214  int magnet( const GU_MagnetParms &parms );
1215 
1216  /// trace a raster image to form closed polygons
1217  float trace(GU_TraceParms *parms);
1218 
1219  /// add point texture attributes to traced geometry
1220  void applyTraceTexture(float xres, float yres, float resolution);
1221 
1222 
1223  /// fit a sequence of discrete points to a series of bezier curves
1224  void fit2DCurve(const GU_Detail *source, float error_squared,
1225  GA_PrimitiveGroup *primGroup = 0);
1226 
1227  /// Fit a curve through its breakpoints
1228  /// @{
1229  GEO_Curve *interpCurveBreakpoints(const GEO_Face &face,
1231  int order=4,
1233  GEO_Curve *interpCurveBreakpoints(const GA_OffsetList &point_offsets,
1235  int order=4, int wrapped=0,
1237  GEO_Curve *interpCurveBreakpoints(const UT_Vector4Array &v4Data,
1239  int order=4, int wrapped=0,
1241  /// @}
1242 
1243  /// interpolation data points
1244  /// @{
1245  GEO_Curve *interpCurveGlobal(const GEO_Face &face,
1247  int order=4,
1250  GEO_Curve *interpCurveGlobal(const GA_OffsetList &point_offsets,
1252  int order=4, int wrapped=0,
1255  GEO_Curve *interpCurveGlobal(const GA_Range &point_range,
1257  int order=4, int wrapped=0,
1260  GEO_Curve *interpCurveGlobal(const UT_Vector4Array &v4Data,
1262  int order=4, int wrapped=0,
1265  GEO_Curve *interpCurveLocal(const GEO_Face &face,
1267  int order = 4, int corner=0);
1268  GEO_Curve *interpCurveLocal(const UT_Array<GA_Offset> &goData,
1270  int order = 4, int wrapped=0, int corner=0);
1271  GEO_Curve *interpCurveLocal(const UT_Vector4Array &v4Data,
1273  int order = 4, int wrapped=0, int corner=0);
1274 
1275  GEO_TPSurf *interpSurfGlobal(const GEO_Hull &mesh,
1277  int uOrder=4, int vOrder=4,
1283  const UT_Vector *uParmValues = 0,
1284  const UT_Vector *vParmValues = 0);
1285 
1286  GEO_TPSurf *interpSurfGlobal(const GA_OffsetMatrix &goMesh,
1288  int uOrder=4, int vOrder=4,
1289  bool uWrapped=false, bool vWrapped=false,
1295  const UT_Vector *uParmValues = 0,
1296  const UT_Vector *vParmValues = 0);
1297 
1298  GEO_TPSurf *interpSurfBreakpoints(const GEO_Hull &mesh,
1300  int uOrder=4, int vOrder=4,
1306  const UT_Vector *uParmValues = 0,
1307  const UT_Vector *vParmValues = 0);
1308 
1309  GEO_TPSurf *interpSurfBreakpoints(const GA_OffsetMatrix &goMesh,
1311  int uOrder=4, int vOrder=4,
1312  bool uWrapped=false, bool vWrapped=false,
1318  const UT_Vector *uParmValues = 0,
1319  const UT_Vector *vParmValues = 0);
1320  /// @}
1321 
1322  /// Approximate data points given a tolerance.
1323  /// Only for open endinterpolated surface.
1324  /// @{
1325  GEO_Curve *approxCurveGlobal(const GEO_Face &face,
1327  int order=4,
1328  float tol=1e-1F, float smooth=0.0F,
1329  int noMultipleKnots=1);
1330  GEO_Curve *approxCurveGlobal(const UT_Vector4Array &v4Data,
1332  int order=4, int wrapped=0,
1333  float tol=1e-1F, float smooth=0.0F,
1334  int noMultipleKnots=1);
1335 
1336  GEO_TPSurf *approxSurfGlobal(const GEO_Hull &mesh,
1338  int uOrder=4, int vOrder=4,
1340  float tol=1e-1F, float smooth=0.0F,
1341  int uNoMultipleKnots=1,
1342  int vNoMultipleKnots=1);
1343  GEO_TPSurf *approxSurfGlobal(const GA_OffsetMatrix &gpMesh,
1345  int uOrder=4, int vOrder=4,
1346  int uWrapped=0, int vWrapped=0,
1348  float tol=1e-1F, float smooth=0.0F,
1349  int uNoMultipleKnots=1,
1350  int vNoMultipleKnots=1);
1351  /// @}
1352 
1353  /// methods to refine face and hull types
1354  /// @{
1355  void refine(float *uunit, int ulen,
1356  float *vunit, int vlen,
1357  int countu=1, int countv=1,
1358  int arcspacing = 0,
1359  const GA_PrimitiveGroup *primGroup = 0);
1360 
1361  void unrefine(float umin, float umax,
1362  float vmin, float vmax,
1363  int countu=1, int countv=1,
1364  float utol=0.001F, float vtol=0.001F,
1365  const GA_PrimitiveGroup *primGroup = 0);
1366 
1367  void subdivide(float *uunit, int ulen,
1368  float *vunit, int vlen,
1369  int arcspacing = 0,
1370  const GA_PrimitiveGroup *primGroup = 0);
1371 
1372  /// op = {0 = isoparms, 1 = points, 2 = profiles}
1373  int extract(float *uunit, int ulen,
1374  float *vunit, int vlen,
1375  const GA_PrimitiveGroup *primGroup = 0,
1376  GA_PointGroup *newPoints = 0,
1377  int op = 0, int keepOriginal = 0,
1378  int atbreakpoints = 0, int use_arc_length = 0);
1379 
1380  void extractIsoParms(float *uunit, int ulen,
1381  float *vunit, int vlen,
1382  GA_PrimitiveGroup *newPrims = 0,
1383  const GA_PrimitiveGroup *primGroup = 0);
1384 
1385  void extractPoints(float *uunit, int ulen,
1386  float *vunit, int vlen,
1387  GA_PointGroup *newPoints = 0,
1388  const GA_PrimitiveGroup *primGroup = 0);
1389 
1390  void extractProfiles(float *uunit, int ulen,
1391  float *vunit, int vlen,
1392  const GA_PrimitiveGroup *primGroup = 0);
1393 
1394  void extractIsoParmsAtBreak(float *uunit, int ulen,
1395  float *vunit, int vlen,
1396  GA_PrimitiveGroup *newPrims = 0,
1397  const GA_PrimitiveGroup *primGroup = 0);
1398 
1399  void extractPointsAtBreak(float *uunit, int ulen,
1400  float *vunit, int vlen,
1401  GA_PointGroup *newPoints = 0,
1402  const GA_PrimitiveGroup *primGroup = 0);
1403 
1404  void extractProfilesAtBreak(float *uunit, int ulen,
1405  float *vunit, int vlen,
1406  const GA_PrimitiveGroup *primGroup = 0);
1407 
1408 
1409  int cut(float *uunit, int ulen,
1410  float *vunit, int vlen,
1411  const GA_PrimitiveGroup *primGroup = 0,
1412  int keepin=1, int keepout=0, int atbreakpoints = 0,
1413  int allU = 0, int allV = 0, int use_arc_length = 0);
1414  /// @}
1415 
1416 
1417  /// approximate a spline by using polygonal hull inputs
1418  /// deletes existing polygons if deleteAll is true
1419  void polySpline(GU_PolysplineParms &parms,
1420  const GA_PrimitiveGroup *primGroup = 0,
1421  bool deleteAll = true);
1422 
1423  /// approximate a patch by using polygonal or mesh hull inputs
1424  /// Returns true on success, else false if an error occurred.
1425  bool polyPatch(GU_PolypatchParms &parms,
1426  const GA_PrimitiveGroup *primGroup = 0);
1427 
1428  /// reduce the number of polygons in a detail:
1429  int polyReduce(GU_PolyReduceParms &parms,
1430  const GA_PrimitiveGroup *primGroup = 0,
1431  int *pointIndexTable = 0);
1432 
1433  /// Create polygon soup(s), i.e. GU_PrimPolySoup, where possible in this detail
1434  void polySoup(const GEO_PolySoupParms &parms , const GU_Detail *srcdetail);
1435 
1436  /// Create geometry through premise and rule substitution
1437  void lsystem(GU_LSystemParms &lp);
1438 
1439  /// Get information about a GU_Detail
1440  /// If maxlines < 0, there will be no limit to the number of groups
1441  /// If overridememusage is positive, it will be used rather than the
1442  /// getMemoryUsage().
1443  int info(std::ostream &os,
1444  int max_group_lines=15,
1445  bool pretty=false,
1446  const UT::ArraySet<const void *> *dontcounttheseblocks = 0,
1447  bool instanced=false) const;
1448  /// Get information text for the geometry. This will @b append to the work
1449  /// buffer.
1450  void info(UT_WorkBuffer &wbuf,
1451  int max_group_lines=15,
1452  bool pretty=false,
1453  const UT::ArraySet<const void *> *dontcounttheseblocks = 0,
1454  bool instanced=false) const;
1455 
1456  /// Fills in a stat structure with the volume information.
1457  void statVolumes(GA_Stat &stat, uint level/*=0xffff*/) const override;
1458 
1459  /// @c intersectRay will find the closest intersection with a primitive
1460  /// in the detail. If the dist pointer is nil, then the first intersection
1461  /// found will be returned (instead of the closest). The nml will contain
1462  /// the normal for the primitive at the point of intersection.
1463  /// Accuracy of 0 is inaccurate, 1 is normal, 2 engages Algebraic pruning
1464  /// where available.
1465  ///
1466  /// @param o The ray origin
1467  /// @param d The ray directin
1468  /// @param tmax This can be used to limit the ray to intersections within
1469  /// the given radius.
1470  /// @param tol Intersection tolerance
1471  /// @param dist Return the distance from the origin to the hit
1472  /// @param pos Return the hit position (i.e. <tt>o + dist*d</tt>)
1473  /// @param nml Return the normal of the primitive at the hit position
1474  /// @param accurate Determine primitive intersection algorithms for NURBS
1475  /// @param u The u parametric coordinate of the hit surface
1476  /// @param v The v parametric coordinate of the hit surface
1477  /// @param ignoretrim Ignore trim inside/out tests for trimmed surfaces.
1478  ///
1479  /// @warning If the @c dist parameter is 0 the first hit found will be
1480  /// returned. This may @b not be the closest hit. This can be used to
1481  /// perform a quick check to see if @b any primitives intersect the ray
1482  /// (i.e. for shadow casting).
1483  ///
1484  /// @warning This function iterates over all primitives without any
1485  /// acceleration structure. If you need to send multiple rays, please see
1486  /// GU_RayIntersect.
1487  SYS_DEPRECATED_HDK(16.0)
1488  GEO_Primitive *intersectRay(const UT_Vector3 &o, const UT_Vector3 &d,
1489  float tmax = 1E17F, float tol = 1E-12F,
1490  float *dist = 0, UT_Vector3 *pos = 0,
1491  UT_Vector3 *nml = 0, int accurate = 0,
1492  float *u = 0, float *v = 0,
1493  int ignoretrim = 1) const;
1494 
1495  /// Figure out the parameters of the face/surface that all the given
1496  /// faces/surfaces should have in order to be fully compatible with one
1497  /// another. Return 0 if all the primitive types are faces/surfaces,
1498  /// and -1 otherwise.
1499  /// @{
1500  int commonFaceConfig(
1501  const GA_PrimitiveGroup &faceGroup,
1502  GA_PrimCompat::TypeMask &type, int &order,
1503  bool &open, bool &ends) const;
1504  int commonFaceConfig(
1505  const UT_Array<GEO_Primitive*> &faces_in,
1506  GA_PrimCompat::TypeMask &type, int &order,
1507  bool &open, bool &ends) const;
1508  int commonSurfaceConfig(const GA_PrimitiveGroup &surfs,
1509  GA_PrimCompat::TypeMask &type,
1510  int &orderu, int &orderv,
1511  bool &openu, bool &openv,
1512  bool &endsu, bool &endsv) const;
1513  /// @}
1514 
1515  /// Incompatible faces in infaces are made compatible and set in outfaces.
1516  /// Return 0 of OK, -1 otherwise. If extratype is not nil and the highest
1517  /// face type of the infaces is less than *extratype, replace the common
1518  /// type by *extratype. In the method that takes 2 input groups, we make
1519  /// sure that the primitives in the 2 groups have the same type. Set
1520  /// equalcvs to true make them all have the same number of CVs too.
1521  /// @{
1522  int makeFacesCompatible(
1523  const GA_PrimitiveGroup &infaces,
1524  GA_PrimitiveGroup &outfaces,
1525  bool mustopen = false,
1526  bool mustends = false,
1527  bool nonrational = false,
1528  GA_PrimCompat::TypeMask *extratype = 0,
1529  bool equalcvs = true);
1530  int makeFacesCompatible(
1531  const UT_Array<GEO_Primitive*> &prims_in,
1532  UT_Array<GEO_Primitive*>& prims_out,
1533  bool mustopen = false,
1534  bool mustends = false,
1535  bool nonrational = false,
1536  GA_PrimCompat::TypeMask *extratype = 0,
1537  bool equalcvs = true);
1538  int makeFacesCompatible(
1539  const GA_PrimitiveGroup &infacesU,
1540  const GA_PrimitiveGroup &infacesV,
1541  GA_PrimitiveGroup &outfacesU,
1542  GA_PrimitiveGroup &outfacesV,
1543  bool mustopen = false,
1544  bool mustends = false,
1545  bool nonrational = false,
1546  GA_PrimCompat::TypeMask *extratype = 0,
1547  bool equalcvs = true);
1548  int makeFacesCompatible(
1549  const UT_Array<GEO_Primitive*> &ufaces_array,
1550  const UT_Array<GEO_Primitive*> &vfaces_array,
1551  UT_Array<GEO_Primitive*> &ucfaces_array,
1552  UT_Array<GEO_Primitive*> &vcfaces_array,
1553  bool mustopen = false,
1554  bool mustends = false,
1555  bool nonrational = false,
1556  GA_PrimCompat::TypeMask *extratype = 0,
1557  bool equalcvs = true);
1558  /// @}
1559 
1560  /// Loft a subsection of each hull and update the vertex indices where
1561  /// the subsection occurs. Does partial nurb merging if the bases is given
1562  /// Assumes the two hulls have been properly reconfigured.
1563  static int loftHulls(GEO_Hull *left, GEO_Hull *right,
1564  float lwidth1, float lwidth2,
1565  float rwidth1, float rwidth2,
1566  int sharp, int &lstart, int &rstart,
1567  int &lmax, int &rmax,
1568  int loftU, GA_NUBBasis *nubbasis);
1569 
1570  /// Refine the hull at the unit domain value and return the
1571  /// row/col index where it occurs
1572  /// @{
1573  static int getSubdividedCV(GEO_Hull *hull, int udir, float unit);
1574  static int getSubdividedCV(GEO_Face *face, float unit);
1575  /// @}
1576 
1577  /// Methods for registering and unregistering geometry io converters.
1578  /// @{
1579  static void registerIOTranslator(GEO_IOTranslator *trans);
1580  static void unregisterIOTranslator(GEO_IOTranslator *trans);
1581  static exint getIOTranslatorCount();
1582  static const GEO_IOTranslator *getIOTranslator(exint i);
1583  /// @}
1584 
1585  GA_Detail::IOStatus saveH9File(const char *filename,
1586  const GA_SaveOptions *options) const;
1587  static GA_Detail::IOStatus statH9File(const char *filename,
1588  GA_Stat &sbuf, uint level);
1589 
1590  /// Returns true if filename is a recognized extension.
1591  static bool isFormatSupported(const char *filename);
1592 
1593  /// Allocate an IO handler for a filename, or return nullptr if the handler
1594  /// is the classic format. The returned translator must be deleted. The
1595  /// easiest way to do this is with a UT_UniquePtr: @code
1596  /// UT_UniquePtr<GEO_IOTranslator> xlate(getSupportedFormat(filename));
1597  /// if (xlate)
1598  /// xlate->fileSave(gdp, ...);
1599  /// @endcode
1600  static GEO_IOTranslator *getSupportedFormat(const char *filename);
1601 
1602  /// Align a set of primitives by rotation and translation
1603  void align(GU_AlignParms &parms);
1604 
1605  /// Align a set of faces/hulls at optional levels of continuity.
1606  /// face/hull pre/posttranslate + row stitching + row tangent
1607  /// Faces are aligned with faces, hulls with hulls.
1608  /// Return 0 if OK, -1 otherwise (non face/hull types)
1609  int stitch(GU_StitchParms &parms);
1610 
1611  /// Incompatible surfaces in insurfs are made compatible and set in outsurfs.
1612  /// Return 0 of OK, -1 otherwise. If extratype is not nil and the highest
1613  /// surface type of the insurfs is less than *extratype, replace the common
1614  /// type by *extratype. Set equalcvs to true make them all have the same number
1615  /// of CVs too.
1616  int makeSurfacesCompatible(
1617  const GA_PrimitiveGroup &insurfs,
1618  GA_PrimitiveGroup &outsurfs,
1619  bool mustopenu=false, bool mustopenv=false,
1620  bool mustendsu=false, bool mustendsv=false,
1621  bool equalcvsu=true, bool equalcvsv=true,
1622  GA_PrimCompat::TypeMask *extratype = 0);
1623 
1624  /// NOTE: These functions only apply to pasted surface primitives,
1625  /// so they're probably not what you want!
1626  /// Convenience wrappers for several common pasting operations. The last
1627  /// method destroys both groups:
1628  /// @{
1629  GA_PrimitiveGroup *getPastedSurfaces(const char *n = "__gu_all_pasted__");
1630  GA_PrimitiveGroup *getPastedSurfaces(GA_PrimitiveGroup *&used,
1631  const char *n = "__gu_all_pasted__",
1632  const char *u = "__gu_used_pasted__");
1633  void updatePastedDisplacement(GA_Offset ptoff,
1634  const GA_PrimitiveGroup *all,
1635  GA_PrimitiveGroup *used);
1636  int updatePastedDisplacements();
1637  int updatePastedDependents(GA_PrimitiveGroup *all,
1638  GA_PrimitiveGroup *used);
1639  /// @}
1640 
1641  /// Error Routines
1642  /// @{
1643  GU_ERROR error() const
1644  {
1645  return UTgetErrorManager()->getSeverity();
1646  }
1647 
1649  const char *msg = 0) const
1650  {
1651  UTgetErrorManager()->addMessage("GU", code, msg);
1652  }
1654  const char *msg = 0) const
1655  {
1656  UTgetErrorManager()->addWarning("GU", code, msg);
1657  }
1658  void addError(GU_ErrorCodes code, const char *msg = 0) const
1659  {
1660  UTgetErrorManager()->addError("GU", code, msg);
1661  }
1662  /// @}
1663 
1664  /// Returns a cook selection to fill in. If an already existing cook
1665  /// selection exists, of the wrong type, it is removed, and a new one
1666  /// created. Otherwise the existing cook selection is optionally cleared
1667  /// and returned.
1668  ///
1669  /// The cook selection is the selection being manipulated and displayed
1670  /// by a node.
1671  GU_SelectionHandle getOrCreateCookSelection(GA_GroupType group_type,
1672  bool ordered = false,
1673  bool clear_matching = false);
1674 
1675  /// Returns the group type of the current cook selection, or
1676  /// GA_GROUP_INVALID if there isn't one.
1677  GA_GroupType getCookSelectionGroupType() const;
1678 
1679  /// Creates a cook selection that directly references the supplied group.
1680  /// Any changes to the cook selection later will copy this group and use
1681  /// that copy.
1682  ///
1683  /// You must call removeCookSelection() if this group is later destroyed
1684  /// and the cook selection is still referencing it, which can be checked
1685  /// by calling hasShallowCookSelectionReference(group).
1686  ///
1687  /// NB: Only use this method if you know what you're doing. Any gains in
1688  /// performance are likely not to be worth the management pain.
1689  GU_SelectionHandle createShallowCookSelection(GA_Group *group);
1690 
1691  /// Returns whether this detail has a shallow cook selection referencing
1692  /// the specified group.
1693  bool hasShallowCookSelectionReference(
1694  const GA_Group *group) const;
1695 
1696  /// Returns the current cook selection;
1697  GU_SelectionHandle cookSelection() const;
1698 
1699  /// Removes the current cook selection from this detail. Since the selection
1700  /// is a shared object, there's no guarantee that it will be immediately
1701  /// destroyed, but only that this detail is no longer associated with it.
1702  void removeCookSelection();
1703 
1704  /// Do not use this method unless you know EXACTLY what you are doing. It
1705  /// forces the use of the supplied cook selection.
1706  void forceCookSelection(GU_SelectionHandle sel);
1707 
1708  /// Do not use this method unless you know EXACTLY what you are doing. It
1709  /// removes the cook selection from the detail without orphaning it so the
1710  /// only safe thing to do is to return it later using forceCookSelection().
1711  GU_SelectionHandle stealCookSelection();
1712 
1713  /// Remove points from polygons if they lie on (within a tolerance)
1714  /// the line connecting the previous and next points.
1715  void removeInlinePoints(float tol,
1716  const GA_PrimitiveGroup *prims);
1717 
1718  /// Remove zero area polygons
1719  /// Returns number of polygons removed
1720  /// @{
1721  GA_Size removeZeroAreaFaces(GA_PrimitiveGroup *grp,
1722  bool ignoreOpenFaces = false,
1723  float tolerance = 0.001F,
1724  bool onlyPolys = true);
1725  GA_Size removeZeroAreaFaces(const UT_IntArray &primlist,
1726  bool ignoreOpenFaces = false,
1727  float tolerance = 0.001F,
1728  bool onlyPolys = true);
1729  /// @}
1730 
1731  /// Deletes the geometry in the given group, unlike deleteEdges,
1732  /// it doesn't repair the holes left behind.
1733  void deleteGroupGeometry(const GA_Group &group);
1734 
1735  /// Deletes edge geometry
1736  SYS_DEPRECATED_HDK(16.0)
1737  void deleteEdges(GA_EdgeGroup &edgegroup,
1738  bool del_inline_points,
1739  float inlinetol,
1740  bool del_unused_points = true,
1741  bool del_bridges = true);
1742 
1743  /// There are three different ways of handling situations where all edges
1744  /// that connect polygon boundaries are dissolved.
1745  /// - GU_BRIDGEMODE_BRIDGE @n
1746  /// Insert bridge edges to connect the boundary loops.
1747  /// - GU_BRIDGEMODE_DISJOINT @n
1748  /// Create a separate polygon for each boundary loop.
1749  /// - GU_BRIDGEMODE_DELETE @n
1750  /// Delete the polygons.
1752  {
1755  GU_BRIDGEMODE_DELETE
1756  };
1757  void dissolveEdges(const GA_EdgeGroup &edgegroup,
1758  bool del_inline_points,
1759  fpreal inlinetol,
1760  bool del_unused_points,
1761  BridgeMode bridge_mode,
1762  bool del_degenerate_bridges,
1763  bool boundary_curves);
1764 
1765  /// Flips edges
1766  void flipEdges(const GA_EdgeGroup &edgegroup,
1767  int rotations = 1,
1768  bool rotattribs = false,
1769  GA_EdgeGroup *outedges = 0);
1770  /// Splits edges
1771  /// This is the main method for the PolySplit SOP. The splitlocs are
1772  /// the positions along which you wish to split polygons. When quadcut
1773  /// is false, the Shortest Path algorithm is used, otherwise the Quad Cut
1774  /// algorithm is used. The forcecut flag is used with the Shortest Path
1775  /// algorithm to force it to perform cuts where the initial cut has failed.
1776  /// To form a complete path of edges, supply the first location again as
1777  /// the last location in the splitlocs array. If quadcomplete is true and
1778  /// quadcut is false, then in certain cases extra edges will be inserted so
1779  /// that faces which began as quads get split into faces which are quads. If
1780  /// outPositions is set, it will be filled with a list of points in the path
1781  /// in RE_PRIM_LINES fashion. If fixEnds is set, either end of the path that
1782  /// is on a face will be given an extra segment to connect it to the nearest
1783  /// point to ensure that the resulting polygons don't self-intersect.
1784  void edgeSplit(const GU_SplitLocArray &splitlocs,
1785  bool quadcut = false,
1786  bool forcecut = true,
1787  GA_EdgeGroup *outedges = 0,
1788  float tolerance = SYS_FTOLERANCE,
1789  bool quadcomplete = false,
1790  bool modifyGdp = true,
1791  UT_Fpreal32Array *outPositions = nullptr,
1792  bool fixEnds = false);
1793 
1794  /// Inserts points on edges
1795  /// @{
1796  void divideEdges(const GA_EdgeGroup &edgegroup, int numdivs = 1,
1797  bool applytoall = true,
1798  bool use_shared_points = false,
1799  GA_EdgeGroup *outedges = 0,
1800  UT_Array<GA_Offset> *new_points = 0,
1801  bool preserve_edge_dir = false);
1802  void divideEdges(const GA_EdgeGroup &edgegroup,
1803  int numdivs,
1804  bool applytoall,
1805  bool use_shared_points,
1806  GA_EdgeGroup *outedges,
1807  UT_Array<GA_Offset> *new_points,
1808  bool preserve_edge_dir,
1809  float fraction);
1810  /// @}
1811 
1812  /// Inserts points on edges, with a different fraction and number of
1813  /// divisions per edge.
1814  void divideEdges(const UT_Array<GU_EdgeDiv *> &divlocs,
1815  GA_PointGroup &outgrp);
1816 
1817  /// Transform breakpoints
1818  void transformBreakpoints(const UT_Matrix4 &mat,
1819  const GA_BreakpointGroup *grp = 0,
1820  int quickxform = 0);
1821 
1822 
1823  /// Extrude faces, uses local face spaces and tries to mirror extrusions.
1824  void polyExtrude(const GU_PolyExtrudeParms &parms);
1825 
1826  /// Collapse Edges
1827  void edgeCollapse(const GA_EdgeGroup &edgegroup,
1828  bool removedegen = true,
1829  bool updatenmls = true,
1830  GA_PointGroup *outpoints = 0);
1831 
1832  /// Adds crease weights to edges
1833  void edgeCrease(const GU_EdgeCreaseParms &parms);
1834 
1835  /// Insets points
1836  void pointInset(const GA_PointGroup *ptgroup,
1837  float insetdist, float nmldist);
1838 
1839  /// Find the oriented bounding box that contains the given primitives.
1840  /// The box is returned as a rotate+translate matrix to the box's
1841  /// orientation and centre, and a vector containing the boxes extents
1842  /// along its primary axes. The extents are radii, ie, one-half
1843  /// of what a bounding box size() would be.
1844  ///
1845  /// Returns zero radii if the group contains no primitives.
1846  void getOBBox(const GA_PrimitiveGroup *grp,
1848  UT_Vector3 &radii) const;
1849  /// Return the oriented bounding box that contains the given primitives,
1850  /// returning a UT_OBBox, which contains translation and rotation information
1851  void getOBBoxForPrims(const GA_PrimitiveGroup *grp,
1852  UT_OBBoxD &obb) const;
1853  /// Return the oriented bounding box that contains the given points,
1854  /// returning a UT_OBBox, which contains translation and rotation information
1855  void getOBBoxForPoints(const GA_PointGroup *grp,
1856  UT_OBBoxD &obb) const;
1857 
1858  /// Get cached bounding box. This uses the meta cache count and the data
1859  /// id on P to determine whether the bounds need to be recomputed.
1860  ///
1861  /// It's possible that the cached bounds might be invalid in some cases
1862  /// (where the geometry is modified without updates to the meta cache count
1863  /// or the data id on P.
1864  bool getCachedBounds(UT_BoundingBox &box) const;
1865  /// Forcibly clear the cached bounds without having to update the meta
1866  /// cache count or data ID on P.
1867  void clearCachedBounds();
1868 
1869  /// Make each primitive planar, returns the number of primitives xformed
1870  GA_Size makePrimsPlanar(const GA_PrimitiveGroup *grp = 0);
1871 
1872  static void loadIODSOs();
1873 
1874  /// Create a list of all internal file extensions
1875  static void getFileExtensions(UT_StringArray &result);
1876 
1877  /// Check to see whether the file extension matches a known binary file
1878  /// extension. The argument is the full filename.
1879  static bool matchBinaryFileExtension(const UT_StringRef &filename);
1880 
1881  /// Check to see whether the file extension matches a known ASCII file
1882  /// extension. The argument is the full filename.
1883  static bool matchASCIIFileExtension(const UT_StringRef &filename);
1884 
1885 
1886  /// These methods assume no changes have been made to the geometry since the
1887  /// last call to incrementMetaCacheCount(). "attrib" should refer to a string
1888  /// or integer attribute.
1889  exint getUniqueValueCount(const GA_Attribute *attrib) const;
1890  exint getUniqueIntegerValue(const GA_Attribute *attrib, exint idx) const;
1891  const UT_StringHolder &getUniqueStringValue(const GA_Attribute *attrib, exint idx) const;
1892  GA_Range getRangeByValue(const GA_Attribute *attrib, exint v) const;
1893  GA_Range getRangeByValue(const GA_Attribute *attrib, const UT_StringRef &v) const;
1894 
1895 
1896  class AttribValueLookupTable;
1897  class AttribSingleValueLookupTable;
1898 
1899  const AttribValueLookupTable *getLookupTable(const GA_Attribute *attrib) const;
1900  const AttribSingleValueLookupTable *getSingleLookupTable(const GA_Attribute *attrib) const;
1901 
1902  // Creates a copy of the detail keeping the same UniqueId and MetaCacheCount
1903  // This is used by SOP_Cache to make different details act as the same.
1904  GU_Detail *cloneForCache(bool keep_unique_id) const;
1905 
1906 protected:
1907  /// Register intrinsic attributes
1910 
1911 private:
1912  int twist (const GU_TwistParms &parms, int &p);
1913  int bend (const GU_TwistParms &parms, int &p);
1914  int squashStretch (const GU_TwistParms &parms, int &p);
1915  int shear (const GU_TwistParms &parms, int &p);
1916  int taper (const GU_TwistParms &parms, int &p);
1917  int linearTaper (const GU_TwistParms &parms, int &p);
1918 
1919  template <typename ArrayType>
1920  GEO_Curve * privateInterpCurveGlobal(
1921  const ArrayType &gpData,
1922  const GA_PrimitiveTypeId &type,
1923  int order, int wrapped,
1924  GA_ParameterizationType parmType,
1925  GA_KnotSpaceType knotSpaceType);
1926 
1927  void fillGrid(GEO_Hull &hull, int rows, int cols,
1928  float x_size, float y_size,
1929  float x_center, float y_center,
1930  float z_center,
1931  GU_OrientationType plane);
1932 
1933  void convertPolysToHull(
1934  GEO_ConvertParms &parms,
1935  bool keep_original);
1936  void convertToSoups(
1937  GEO_ConvertParms &parms,
1938  bool keep_original);
1939  void convertVolumesToVDBs(
1940  GEO_ConvertParms &parms,
1941  bool keep_original);
1942  void convertVDBsToVolumes(
1943  GEO_ConvertParms &parms,
1944  bool keep_original);
1945  void convertVolumesToPolys(
1946  GEO_ConvertParms &parms,
1947  bool keep_original);
1948  void convertMetasToPolys(
1949  GEO_ConvertParms &parms,
1950  bool keep_original);
1951  void convertTetsToPolys(
1952  GEO_ConvertParms &parms,
1953  bool keep_original);
1954  void doConversion(
1955  GEO_ConvertParms &parms,
1956  bool keep_original);
1957 
1958  void orientPoly(GEO_PrimPoly *poly,
1959  UT_BitArray &process,
1960  UT_BitArray &reverse);
1961 
1962  GEO_Primitive *surfCube(int xdiv, int ydiv, int zdiv,
1963  int orderx, int ordery, int orderz,
1964  float xmin, float xmax,
1965  float ymin, float ymax,
1966  float zmin, float zmax,
1967  GEO_SurfaceType type, int kind,
1968  bool consolidate);
1969 
1970  // Checks if a single primitive is dirty (see getDirtyData).
1971  bool isDirtySinglePrimitive(GA_Primitive *prim,
1972  bool checkRepPoints,
1973  float tol);
1974 
1975  void lodConvert(GA_PrimitiveGroup *grp,
1976  UT_BoundingBox &box, int cluster, float lod,
1977  bool makepolysoup = false);
1978  void divisionConvert(GA_PrimitiveGroup *grp, int adjust,
1979  UT_BoundingBox &box, int divx,int divy,int divz,
1981  bool makepolysoup = false);
1982  int adjustStepBox(float &min, float &max, float step);
1983  void stepSizeConvert(GA_PrimitiveGroup *grp, int adjust,
1984  UT_BoundingBox &box, float sx,float sy,float sz,
1986  bool makepolysoup = false);
1987 
1988  /// makes a single primitive planar (see makePrimsPlanar)
1989  bool primToPlane(GEO_Primitive *pprim,
1990  GA_PointGroup &fixedPoints);
1991 
1992  /// Prohibited to avoid accidentally passing by value.
1993  /// Use constructor that takes a const GU_Detail * if you
1994  /// really need to construct a copied detail.
1995  GU_Detail(const GU_Detail &src);
1996 
1997  friend class GU_PrimitiveFactory; // For intrinsic registration
1998 
1999  void construct()
2000  {
2001  myBoundingCache = nullptr;
2002  myValueLookupCache = nullptr;
2003  }
2004 
2005  /// The sole cook selection associated with this detail.
2006  GU_SelectionHandle myCookSelection;
2007 
2008  class BoundingCache; // Forward declare
2009  BoundingCache *myBoundingCache;
2010 
2011  mutable gu_ValueLookupCache *myValueLookupCache;
2012 };
2013 
2014 #endif
virtual void clearCaches()
Definition: GA_Detail.h:1856
A class to manage an ordered array which has fixed offset handles.
Definition: GA_IndexMap.h:63
GLbyte * weights
Definition: glew.h:7551
ImageBuf OIIO_API warp(const ImageBuf &src, const Imath::M33f &M, string_view filtername=string_view(), float filterwidth=0.0f, bool recompute_roi=false, ImageBuf::WrapMode wrap=ImageBuf::WrapDefault, ROI roi={}, int nthreads=0)
vint4 max(const vint4 &a, const vint4 &b)
Definition: simd.h:4703
UT_ErrorSeverity getSeverity()
GA_API const UT_StringHolder dist
Definition of a geometry attribute.
Definition: GA_Attribute.h:196
SYS_VISIBILITY_EXPORT void newGeometryIO(void *)
GT_API const UT_StringHolder filename
GLsizeiptr size
Definition: glew.h:1681
GLenum src
Definition: glew.h:2410
GU_MetricType
Definition: GU_Types.h:87
GLclampd zmax
Definition: glew.h:9021
GU_DeformType
Definition: GU_Types.h:58
MatType shear(Axis axis0, Axis axis1, typename MatType::value_type shear)
Set the matrix to a shear along axis0 by a fraction of axis1.
Definition: Mat.h:693
#define SYS_VISIBILITY_EXPORT
GLuint GLenum GLenum transform
Definition: glew.h:14742
GA_DataIdStrategy
Definition: GA_Types.h:208
GLint left
Definition: glew.h:8008
const UT_IntArray & ringValence() const
Definition: GU_Detail.h:224
GLuint GLuint GLfloat weight
Definition: glew.h:13609
virtual GA_Detail * cloneEmptyDetail(bool clone_attributes) const =0
SYS_VISIBILITY_EXPORT void newGeometryPrim(GA_PrimitiveFactory *factory)
#define SYS_DEPRECATED_HDK_REPLACE(__V__, __R__)
void reversePrimitiveList()
Definition: GU_Detail.h:962
GA_API const UT_StringHolder twist
int64 exint
Definition: SYS_Types.h:125
A soup of polygons.
int64 getMemoryUsage(bool inclusive) const override
Compute memory usage (includes all shared memory)
void reversePointList()
Definition: GU_Detail.h:960
OnlyConsGroupPropagateType
Definition: GU_Detail.h:495
void reverse(I begin, I end)
Definition: pugixml.cpp:7190
UT_ErrorSeverity
Definition: UT_Error.h:25
GLsizei GLsizei GLchar * source
Definition: glew.h:1832
void shiftPrimitiveList(GA_Size aoffset)
Definition: GU_Detail.h:949
UT_API UT_ErrorManager * UTgetErrorManager()
void addWarning(GU_ErrorCodes code, const char *msg=0) const
Definition: GU_Detail.h:1653
Tto convert(const Tfrom &source)
const GLdouble * v
Definition: glew.h:1391
Structure for the PolySouping code.
GLdouble angle
Definition: glew.h:9135
GLsizei GLuint * groups
Definition: glew.h:2744
UT_ErrorSeverity addError(const char *type, int code, const char *msg=0, const UT_SourceLocation *loc=0)
exint GA_Size
Defines the bit width for index and offset types in GA.
Definition: GA_Types.h:233
SnapAttributesType
Definition: GU_Detail.h:583
GLuint GLdouble GLdouble GLint GLint order
Definition: glew.h:3446
GU_GridType
Definition: GU_Types.h:70
GLuint GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint vorder
Definition: glew.h:3448
const UT_Array< GA_OffsetArray > & myRingZero
Definition: GU_Detail.h:228
#define GA_INVALID_OFFSET
Definition: GA_Types.h:676
A range of elements in an index-map.
Definition: GA_Range.h:42
GA_ParameterizationType
Definition: GA_Types.h:195
GU_LatticeType
Definition: GU_Types.h:109
int divs(int x, int y)
Definition: ImathFun.h:180
GU_AxisType
Definition: GU_Types.h:24
GA_Size GA_Offset
Definition: GA_Types.h:639
vint4 blend(const vint4 &a, const vint4 &b, const vbool4 &mask)
Definition: simd.h:4648
GU_API void snapPoints(GU_Detail &qgdp, const GU_Detail *tgdp, const PointSnapParms &parms)
GLhalf ny
Definition: glew.h:13223
GR_API RE_Geometry * buildGrid(RE_Render *r, UT_Vector3F center, UT_Vector2F size, Orientation orient, const char *cache_name=NULL)
GLfloat GLfloat GLfloat GLfloat nx
Definition: glew.h:16287
GU_Detail(const GU_Detail *src, GA_DataIdStrategy data_id_strategy=GA_DATA_ID_BUMP)
Definition: GU_Detail.h:175
int open(float queuesize) override
GA_API const UT_StringHolder trans
GLint GLenum GLsizei GLint GLsizei const void * data
Definition: glew.h:1379
GU_API void snapGrid(GU_Detail &gdp, const GridSnapParms &parms)
bool extract(const vbool4 &a)
Definition: simd.h:3330
void
Definition: png.h:1083
GLsizei n
Definition: glew.h:4040
GLsizei GLsizei GLfloat distance
Definition: glew.h:13640
const GA_IndexMap & getIndexMap(GA_AttributeOwner owner) const
NURBS basis classes which maintain knot vectors.
Definition: GA_NUBBasis.h:44
void shiftPointList(GA_Size aoffset)
Definition: GU_Detail.h:947
virtual void statVolumes(GA_Stat &stat, uint level=0xffff) const
Fill out only the volume information.
long long int64
Definition: SYS_Types.h:116
void sortPointList(fpreal *order)
Definition: GU_Detail.h:931
png_const_structrp png_const_inforp int * unit
Definition: png.h:2161
void sortPointList(int seed)
Definition: GU_Detail.h:922
#define GU_API
Definition: GU_API.h:14
#define SYS_DEPRECATED_HDK(__V__)
GLfloat right
Definition: glew.h:15186
void sortPrimitiveList(const UT_Vector3 &o, const UT_Vector3 &d)
Definition: GU_Detail.h:913
void sortPointList(const UT_Vector3 &o, const UT_Vector3 &d)
Definition: GU_Detail.h:911
UT_Array< GU_SplitLoc * > GU_SplitLocArray
Definition: GU_Detail.h:135
bool copy(const GEO_Detail &src, GEO_CopyMethod method=GEO_COPY_ONCE, bool this_parameter_is_ignored=true, bool keep_internal_groups=true, GA_DataIdStrategy data_id_strategy=GA_DATA_ID_BUMP)
GLuint GLuint GLsizei GLenum type
Definition: glew.h:1253
UT_SharedPtr< GU_Selection > GU_SelectionHandle
GA_API const UT_StringHolder orient
GU_OrientationType
Definition: GU_Types.h:32
GU_Detail(bool full_topology)
Definition: GU_Detail.h:155
GLenum GLuint GLint GLenum face
Definition: glew.h:4616
void addMessage(GU_ErrorCodes code, const char *msg=0) const
Definition: GU_Detail.h:1648
IFDmantra py
Definition: HDK_Image.dox:266
GLhalf GLhalf nz
Definition: glew.h:13223
GLfloat GLfloat p
Definition: glew.h:16321
Class to return information about a GA_Detail.
Definition: GA_Stat.h:50
ImageBuf OIIO_API cut(const ImageBuf &src, ROI roi={}, int nthreads=0)
virtual bool smooth(GA_AttributeOperand &d, GA_AttributeOperand &min, GA_AttributeOperand &max, GA_AttributeOperand &t) const
d = SYSsmooth(min, max, t);
IMATH_INTERNAL_NAMESPACE_HEADER_ENTER T clip(const T &p, const Box< T > &box)
Definition: ImathBoxAlgo.h:89
const UT_IntArray & myRingValence
Definition: GU_Detail.h:229
GLuint counter
Definition: glew.h:2740
void sortPrimitiveList(int seed)
Definition: GU_Detail.h:924
fpreal64 fpreal
Definition: SYS_Types.h:277
GLint lod
Definition: glew.h:1385
UT_ErrorSeverity addWarning(const char *type, int code, const char *msg=0, const UT_SourceLocation *loc=0)
GA_GroupType
An ordinal enum for the different types of groups in GA.
Definition: GA_Types.h:159
RingRef(const UT_Array< GA_OffsetArray > &ringzero, const UT_IntArray &ringvalence)
Definition: GU_Detail.h:215
void countMemory(UT_MemoryCounter &counter, bool inclusive) const override
void proximityToPointList(const UT_Vector3 &point)
Definition: GU_Detail.h:972
GLuint GLdouble GLdouble GLint GLint const GLdouble * points
Definition: glew.h:3446
GLuint GLuint GLsizei count
Definition: glew.h:1253
void transformBreakpoints(const UT_Matrix4T< FLOAT_T > &mat, const GA_BreakpointGroup *grp=0, bool just_P=false, bool update_ptnormals=false, GEO_Delta *geodelta=0, bool updateaffectednormals=false, const char *attribpattern=NULL)
static GA_IntrinsicManager::Registrar registerIntrinsics(GA_PrimitiveFactory &factory)
GU_API GA_PrimitiveFactory & GUgetFactory()
void sortPrimitiveList(GU_AxisType axis)
Definition: GU_Detail.h:893
arg_join< It, char > join(It begin, It end, string_view sep)
Definition: format.h:3326
GEO_SurfaceType
GLuint64EXT * result
Definition: glew.h:14007
Container class for all geometry.
Definition: GA_Detail.h:95
const UT_Array< GA_OffsetArray > & ringZero() const
Definition: GU_Detail.h:222
#define SYS_FTOLERANCE
Definition: SYS_Types.h:208
GLenum array
Definition: glew.h:9066
void proximityToPrimitiveList(const UT_Vector3 &point)
Definition: GU_Detail.h:974
GA_Size GEO_API GEOsplitPoints(GEO_Detail *detail, const GA_ElementGroup *group=nullptr)
GU_TextureType
Definition: GU_Types.h:94
#define const
Definition: zconf.h:214
vint4 min(const vint4 &a, const vint4 &b)
Definition: simd.h:4694
void sortByVertexOrder()
Definition: GU_Detail.h:982
GU_Detail(const GU_Detail *src, GA_PrimitiveGroup *primGroup, GA_DataIdStrategy data_id_strategy=GA_DATA_ID_BUMP)
Definition: GU_Detail.h:162
void sortPrimitiveList(fpreal *order)
Definition: GU_Detail.h:933
GA_API const UT_StringHolder rest
GA_KnotSpaceType
Definition: GA_Types.h:188
bool all(const vbool4 &v)
Definition: simd.h:3371
unsigned int uint
Definition: SYS_Types.h:45
GLint level
Definition: glew.h:1252
void merge(const GEO_Detail &src, const GA_PrimitiveGroup *primGrp=nullptr, bool mergePrimGroup=true, bool insertPrimsAtHead=false, GA_GBPointRedirectArray *dest_to_src_ptarray=nullptr, bool keep_internal_groups=true, GA_DataIdStrategy data_id_strategy=GA_DATA_ID_BUMP)
GU_ErrorCodes
Definition: GU_Error.h:20
void addError(GU_ErrorCodes code, const char *msg=0) const
Definition: GU_Detail.h:1658
UT_ErrorSeverity addMessage(const char *type, int code, const char *msg=0, const UT_SourceLocation *loc=0)
GLboolean GLuint group
Definition: glew.h:2745
GLintptr offset
Definition: glew.h:1682