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