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  GA_Size consolidatePoints(fpreal distance,
454  const GA_PointGroup *ptGrp = 0,
455  bool forceConsAll = false,
456  bool mark = false,
457  bool accurate = false);
458 
459  /// Performs fast consolidation by calling onlyConsolidatePoints.
460  /// By default, calls removeUnused when done to remove any unused points
461  /// When deleteConsOnly is set, then only consolidated points are removed.
462  GA_Size fastConsolidatePoints(fpreal distance,
463  const GA_PointGroup *ptGrp=0,
464  bool mark = false,
465  bool accurate = false);
466 
467  /// Specifies methods by which points after consolidation will
468  /// get their group names. ONLYCONS_GRP_PROP_LEAST means that the
469  /// points will belong to the same group as the original point
470  /// with least point number. ONLYCONS_GRP_PROP_UNION means that the
471  /// points will belong to the full set of groups represented
472  /// by the original points (so if orig. point 1 is in group A, B and
473  /// orig. point 2 is in group B, C, the final point will be in A B C).
474  /// INTERSECT means the point will only belong in groups that are common
475  /// to all original points. With the example above, it will belong in
476  /// B.
478  {
479  ONLYCONS_GRP_PROP_LEAST = 0,
481  ONLYCONS_GRP_PROP_INTERSECT
482  };
483  /// This does fast consolidation but does *not* call removeUnused when
484  /// done. This means that degenerate primitives will be left along
485  /// with orphaned points. If deleteconsolidated is set, the consolidated
486  /// points only will be deleted. grouppropagate controls which groups
487  /// the new points will belong to.
488  GA_Size onlyConsolidatePoints(fpreal distance,
489  const GA_PointGroup *ptgrp = 0,
490  bool mark = false,
491  bool deleteconsolidated = false,
492  OnlyConsGroupPropagateType
493  grouppropagate =
494  ONLYCONS_GRP_PROP_LEAST,
495  bool accurate = false);
496 
497  GA_Size consolidateNormals(fpreal distance,
498  const GA_PointGroup *ptGrp = 0,
499  bool forceConsAll = false,
500  bool accurate = false);
501  GA_Size fastConsolidateNormals(fpreal distance,
502  const GA_PointGroup *ptGrp = 0,
503  bool accurate = false);
504  /// Consolidate UV attributes within a specified distance.
505  /// This distance can be in UV space or XYZ space.
506  /// There are various methods of placing the consolidated UVs.
507  ///
508  /// metric: 0 => UV space
509  /// 1 => XYZ space
510  ///
511  /// method: 0 => Average
512  /// 1 => First in Group
513  /// 2 => Specify uvw coordinate
514  int fastConsolidatePointUVs(float distance,
515  const GA_PointGroup &ptGrp,
516  const GU_MetricType metric,
517  int method,
518  UT_Vector3 &uvw);
519  int fastConsolidatePointUVs(const GA_RWHandleV3 &uvattrib,
520  float distance,
521  const GA_PointGroup &ptGrp,
522  const GU_MetricType metric,
523  int method,
524  UT_Vector3 &uvw);
525  int fastConsolidateVertexUVs(float distance,
526  const GA_VertexGroup &vtxGrp,
527  const GU_MetricType metric,
528  int method,
529  UT_Vector3 &uvw);
530  int fastConsolidateVertexUVs(const GA_RWHandleV3 &uvattrib,
531  float distance,
532  const GA_VertexGroup &vtxGrp,
533  const GU_MetricType metric,
534  int method,
535  UT_Vector3 &uvw);
536 
537  /// Snap points within a specified distance (returns num done)
538  /// If a point group is specified, then, only points in that
539  /// group are consolidated.
540  /// Snapping doesn't fuse the points together, just makes their
541  /// positions match.
542  /// The type is 0 for average, 1 for round to lowest point number
543  /// and 2 for highest point number.
544  /// snappointpos controls whether the point positions will be
545  /// snapped.
546  /// snapptattribs can be set to indicate that point attributes
547  /// are to be snapped.
548  /// ptattribhandles is a list of attribute handles for the
549  /// attributes that will be snapped.
550  GA_Size snapPoints(int type, fpreal distance,
551  const GA_PointGroup *ptgrp=0,
552  bool snapptpos = true,
553  UT_Array<GA_Attribute *> *ptattribs = 0,
554  bool accurate = true);
555 
556  /// Methods for snapping attributes (for use with snapAttributes).
557  /// SNAP_ATTRIBUTE_AVERAGE averages the attributes together.
558  /// SNAP_ATTRIBUTE_INDEX tells snapAttributes to use an index
559  /// into the list of snapped points to set the attributes for
560  /// other points.
562  {
563  SNAP_ATTRIBUTES_AVERAGE = 0,
564  SNAP_ATTRIBUTES_INDEX
565  };
566 
567  /// This version of snapping snaps onto grid coordinates. You specify
568  /// the number of lines per HUnit, so "2" for example will snap to 0.5
569  /// boundaries.
570  /// type is 0 for round nearest, 1 for round down, 2 for round up.
571  /// 0.5 rounds up in nearest.
572  void snapGrid(int type,
573  float xlines, float ylines, float zlines,
574  float xoff, float yoff, float zoff,
575  float tol,
576  const GA_PointGroup *ptGrp=0);
577  /// Same as above, but with UVs...
578  void snapGridPointUVs(int type,
579  float xlines, float ylines, float zlines,
580  float xoff, float yoff, float zoff,
581  float tol,
582  const GA_PointGroup *ptGrp=0);
583  void snapGridPointUVs(
584  const GA_RWHandleV3 &uvattrib, int type,
585  float xlines, float ylines, float zlines,
586  float xoff, float yoff, float zoff,
587  float tol,
588  const GA_PointGroup *ptGrp=0);
589  void snapGridVertexUVs(int type,
590  float xlines, float ylines, float zlines,
591  float xoff, float yoff, float zoff,
592  float tol,
593  const GA_VertexGroup *vtxGrp=0);
594  void snapGridVertexUVs(
595  const GA_RWHandleV3 &uvattrib, int type,
596  float xlines, float ylines, float zlines,
597  float xoff, float yoff, float zoff,
598  float tol,
599  const GA_VertexGroup *vtxGrp=0);
600 
601  /// Build holes in the geometry by bridging the holes to their outlines
602  /// The angle should be specified as the angle (in degrees) between
603  /// the normals.
604  int buildHoles(float dist = 0.001F, float angle = 0.2F,
605  int snapFace=0,
606  const GA_PrimitiveGroup *primGroup=0);
607 
608  /// Remove bridged holes from other than polygons
609  void unHole(const GA_PrimitiveGroup *primGroup=0);
610 
611  /// Unique all points in the detail. If a point group is specified,
612  /// then only points in that group are uniqued
613  /// If a primitive group is specified, only those primitives will
614  /// have their points uniqued.
615  void uniquePoints(const GA_PointGroup *group=0);
616 
617  /// Unique all the points that are in this primitive, even if referenced
618  /// by other primitives.
619  void uniquePrimitive(GEO_Primitive *prim);
620 
621  /// Remove repeated references of vertices in the faces, then remove all
622  /// degenerate primitives regardless of their type.
623  /// Set removeRepPoints flag to remove the repeat points as well and
624  /// the deletePoints flag to delete the points that were part of the
625  /// degenerate primitive.
626  GA_Size cleanData (const GA_PrimitiveGroup *primGrp=0,
627  bool removeRepPoints = false,
628  float tol = 0.001F,
629  bool deleteDegenPrimPoints = false,
630  bool deleteOrphanedPoints = false);
631 
632  /// Identify dirty data, which is the degenerate primitives that would
633  /// be deleted by cleanData. Return them in the returnGrp, and return
634  /// the number of dirty primitives. If returnGrp is NULL then only
635  /// return the count.
636  GA_Size getDirtyData (GA_PrimitiveGroup *returnGrp,
637  const GA_PrimitiveGroup *primGrp=0,
638  bool checkRepPoints = false,
639  float tol = 0.001F);
640 
641  /// If the applyToVertex is less than 0, the "natural" place will be use,
642  /// otherwise 0 = point attrib, 1 = vertex attrib
643  /// Returns false if the attribute failed to be created, else true.
644  bool applyTexture(GU_TextureType type, GU_AxisType axis,
645  const GA_PrimitiveGroup *primGroup=0,
646  int applyToVertex = -1, int fixPolySeams = 0,
647  const GU_CameraParms *userData = 0);
648  /// If the applyToVertex is less than 0, the "natural" place will be use,
649  /// otherwise 0 = point attrib, 1 = vertex attrib
650  /// Returns false if the attribute failed to be created, else true.
651  bool applyTexture(const UT_StringRef &uvattribname,
653  const GA_PrimitiveGroup *primGroup=0,
654  int applyToVertex = -1, int fixPolySeams = 0,
655  const GU_CameraParms *userData = 0);
656  /// The scaleTexture() and rotateTexture() methods are depreciated. Please
657  /// use the GU_MODIFY_TEX projection and simply create the approprate
658  /// post-transform.
659  /// Returns false if the attribute failed to be created, else true.
660  bool scaleTexture(float umult = 1, float uoff = 0,
661  float vmult = 1, float voff = 0,
662  float wmult = 1, float woff = 0,
663  const GA_PrimitiveGroup *primGroup=0);
664  bool scaleTexture(const UT_StringRef &uvattribname,
665  float umult = 1, float uoff = 0,
666  float vmult = 1, float voff = 0,
667  float wmult = 1, float woff = 0,
668  const GA_PrimitiveGroup *primGroup=0);
669  bool rotateTexture(float angle,
670  const GA_PrimitiveGroup *primGroup=0);
671  bool rotateTexture(const UT_StringRef &uvattribname,
672  float angle,
673  const GA_PrimitiveGroup *primGroup=0);
674 
675  /// Methods for transforming point and vertex texture attributes:
676  void transformPointTexture(const UT_Matrix4& mat,
677  const GA_PointGroup *ptGroup=nullptr,
678  GEO_Delta *geodelta=0);
679 
680  void transformPointTexture(
681  const GA_RWHandleV3 &pth,
682  const UT_Matrix4& mat,
683  const GA_PointGroup *ptGroup=nullptr,
684  GEO_Delta *geodelta=0);
685 
686  /// Precompute a list of points to soft transform, along with
687  /// the distance (squared) to the closest "hard" point.
688  /// The metric specifies how distance is measured in space.
689  void computeSoftTransformPointTextureCache(
690  GEO_SoftTransformCache &cache,
691  const GA_PointGroup *ptgroup,
692  const GEO_Rolloff &rolloff,
693  const GU_MetricType metric) const;
694 
695  /// Precompute a list of points to soft transform, along with
696  /// the distance (squared) to the closest "hard" point.
697  /// The metric specifies how distance is measured in space.
698  void computeSoftTransformPointTextureCache(
699  const GA_ROHandleV3 &pttxth,
700  GEO_SoftTransformCache &cache,
701  const GA_PointGroup *ptgroup,
702  const GEO_Rolloff &rolloff,
703  const GU_MetricType metric) const;
704 
705  /// falloff_output - any non-zero falloffs used during this call will be
706  /// written to this attribute when provided
707  /// falloff_written - will be set to true when provided if falloff_output
708  /// is provided, and this call did not skip processing
709  /// any non-zero falloffs. If not set, you must call
710  /// computeSoftPointFalloff() to obtain the falloffs.
711  void softTransformPointTexture(
712  const UT_XformOrder &order,
713  float tx, float ty, float tz,
714  float rx, float ry, float rz,
715  float sx, float sy, float sz,
716  float s_xy, float s_xz, float s_yz,
717  float px, float py, float pz,
718  const GEO_SoftTransformCache &cache,
719  const GEO_Rolloff &rolloff,
720  GEO_Delta *geodelta = 0,
721  const GA_RWHandleF *falloff_output = NULL,
722  bool *falloff_written = NULL);
723 
724  /// falloff_output - any non-zero falloffs used during this call will be
725  /// written to this attribute when provided
726  /// falloff_written - will be set to true when provided if falloff_output
727  /// is provided, and this call did not skip processing
728  /// any non-zero falloffs. If not set, you must call
729  /// computeSoftPointFalloff() to obtain the falloffs.
730  void softTransformPointTexture(
731  const GA_RWHandleV3 &ptattr,
732  const UT_XformOrder &order,
733  float tx, float ty, float tz,
734  float rx, float ry, float rz,
735  float sx, float sy, float sz,
736  float s_xy, float s_xz, float s_yz,
737  float px, float py, float pz,
738  const GEO_SoftTransformCache &cache,
739  const GEO_Rolloff &rolloff,
740  GEO_Delta *geodelta = 0,
741  const GA_RWHandleF *falloff_output = NULL,
742  bool *falloff_written = NULL);
743 
744  void transformVertexTexture(const UT_Matrix4& mat,
745  const GA_VertexGroup *vertexGroup=nullptr,
746  GEO_Delta *geodelta=0);
747 
748  void transformVertexTexture(
749  const GA_RWHandleV3 &vtxh,
750  const UT_Matrix4& mat,
751  const GA_VertexGroup *vertexGroup=nullptr,
752  GEO_Delta *geodelta=0);
753 
754  /// Precompute a list of vertices to soft transform, along with
755  /// the distance (squared) to the closest "hard" point.
756  /// The metric specifies how distance is measured in space.
757  /// ignore_uv_connectivity controls whether we affect vertices
758  /// which are not in the same uvw-wise connected component.
759  void computeSoftTransformVertexTextureCache(
760  GEO_SoftTransformCache &cache,
761  const GA_VertexGroup *vtxgroup,
762  const GEO_Rolloff &rolloff,
763  const GU_MetricType metric,
764  bool ignore_uv_connectivity) const;
765 
766  /// Precompute a list of vertices to soft transform, along with
767  /// the distance (squared) to the closest "hard" point.
768  /// The metric specifies how distance is measured in space.
769  /// ignore_uv_connectivity controls whether we affect vertices
770  /// which are not in the same uvw-wise connected component.
771  void computeSoftTransformVertexTextureCache(
772  const GA_ROHandleV3 &vtxh,
773  GEO_SoftTransformCache &cache,
774  const GA_VertexGroup *vtxgroup,
775  const GEO_Rolloff &rolloff,
776  const GU_MetricType metric,
777  bool ignore_uv_connectivity) const;
778 
779  /// falloff_output - any non-zero falloffs used during this call will be
780  /// written to this attribute when provided
781  /// falloff_written - will be set to true when provided if falloff_output
782  /// is provided, and this call did not skip processing
783  /// any non-zero falloffs. If not set, you must call
784  /// computeSoftPointFalloff() to obtain the falloffs.
785  void softTransformVertexTexture(
786  const UT_XformOrder &order,
787  float tx, float ty, float tz,
788  float rx, float ry, float rz,
789  float sx, float sy, float sz,
790  float s_xy, float s_xz, float s_yz,
791  float px, float py, float pz,
792  const GEO_SoftTransformCache &cache,
793  const GEO_Rolloff &rolloff,
794  GEO_Delta *geodelta = 0,
795  const GA_RWHandleF *falloff_output = NULL,
796  bool *falloff_written = NULL);
797 
798  /// falloff_output - any non-zero falloffs used during this call will be
799  /// written to this attribute when provided
800  /// falloff_written - will be set to true when provided if falloff_output
801  /// is provided, and this call did not skip processing
802  /// any non-zero falloffs. If not set, you must call
803  /// computeSoftPointFalloff() to obtain the falloffs.
804  void softTransformVertexTexture(
805  const GA_RWHandleV3 &vtxh,
806  const UT_XformOrder &order,
807  float tx, float ty, float tz,
808  float rx, float ry, float rz,
809  float sx, float sy, float sz,
810  float s_xy, float s_xz, float s_yz,
811  float px, float py, float pz,
812  const GEO_SoftTransformCache &cache,
813  const GEO_Rolloff &rolloff,
814  GEO_Delta *geodelta = 0,
815  const GA_RWHandleF *falloff_output = NULL,
816  bool *falloff_written = NULL);
817 
818  /// This routine will compute the average normal of a group of points.
819  /// Returns true on success and false on failure.
820  /// NOTE: The version that doesn't take a point normal attribute handle
821  /// will temporarily create a detached point normal attribute if a point N
822  /// doesn't already exist. The caller may or may not want to cache
823  /// a detached attribute and pass it in, instead.
824  /// @{
825  bool computeAvgNormal(
826  const GA_PointGroup *group,
827  const GA_ROHandleV3 &normals,
828  UT_Vector3 &avg_normal) const;
829  bool computeAvgNormal(
830  const GA_PointGroup *group,
831  UT_Vector3 &avg_normal) const;
832  /// @}
833 
834  /// Reverse polygons
835  void reversePolys(const GA_PrimitiveGroup *prmGrp=0);
836 
837  /// Conversion Routines - to convert from one primitive to another
838  /// @{
839  void convert(GEO_ConvertParms &parms);
840  void convertNew(GEO_ConvertParms &parms);
841  /// @}
842 
843  /// This routine only converts metaballs using a more comprehensive set
844  /// of parameters.
845  void convertMetaballs(GEO_MetaConvertParms& parms, const GA_PrimitiveGroup* prim_grp = NULL);
846 
847  //
848  // SORTING
849  //
850 
851  /// Sort by the specified dominant axis
852  /// @{
853  void sortPoints(GA_IndexMap &array,
854  GU_AxisType axis = GU_XAXIS);
855  void sortPoints(GA_OffsetArray &array,
856  GU_AxisType axis = GU_XAXIS);
857  void sortPrims(GA_IndexMap &array,
858  GU_AxisType axis = GU_XAXIS);
860  { sortPoints(getIndexMap(GA_ATTRIB_POINT), axis); }
862  { sortPrims(getIndexMap(GA_ATTRIB_PRIMITIVE), axis); }
863  /// @}
864 
865  /// Sorting by spatial locality. The points and primitives will be
866  /// sorted in a way that tries to assign nearby primitives closer
867  /// primitive ids.
868  /// @{
869  void sortPointsSpatial();
870  void sortPrimsSpatial();
871  /// @}
872 
873  /// Sort along an arbitrary vector
874  /// @{
875  void sortPoints(GA_IndexMap &array,
876  const UT_Vector3 &o, const UT_Vector3 &d);
877  void sortPrims(GA_IndexMap &array,
878  const UT_Vector3 &o, const UT_Vector3 &d);
879  void sortPointList(const UT_Vector3 &o, const UT_Vector3 &d)
880  { sortPoints(getIndexMap(GA_ATTRIB_POINT), o, d); }
882  const UT_Vector3 &d)
883  { sortPrims(getIndexMap(GA_ATTRIB_PRIMITIVE), o, d); }
884  /// @}
885 
886  /// Sort in random order
887  /// @{
888  void sortPoints(GA_IndexMap &array, int seed);
889  void sortPrims(GA_IndexMap &array, int seed);
890  void sortPointList(int seed)
891  { sortPoints(getIndexMap(GA_ATTRIB_POINT), seed); }
892  void sortPrimitiveList(int seed)
893  { sortPrims(getIndexMap(GA_ATTRIB_PRIMITIVE), seed); }
894  /// @}
895 
896  /// Sorting according to a provided value list
897  /// @{
898  void sortElements(GA_IndexMap &array, fpreal *order);
899  void sortPointList(fpreal *order)
900  { sortElements(getIndexMap(GA_ATTRIB_POINT), order); }
902  { sortElements(getIndexMap(GA_ATTRIB_PRIMITIVE), order); }
903  /// @}
904 
905  /// "Rotate" (cycle) the order of vertices for all primitives in the group,
906  /// by the specified number of places.
907  void shift(int uoffset, int voffset,
908  const GA_PrimitiveGroup *group=NULL);
909 
910  /// "Rotate" (cycle) the order of points or primitives in the detail, by the
911  /// specified number of places.
912  /// @{
913  void shiftPoints(GA_IndexMap &, GA_Size offset);
914  void shiftPrims(GA_IndexMap &, GA_Size offset);
915  void shiftPointList(GA_Size aoffset)
916  { shiftPoints(getIndexMap(GA_ATTRIB_POINT), aoffset); }
918  { shiftPrims(getIndexMap(GA_ATTRIB_PRIMITIVE), aoffset); }
919  /// @}
920 
921  /// Reverse vertices for all primitives in the group
922  void reverse(const GA_PrimitiveGroup *group=NULL);
923 
924  /// Reverse order of points or primitives in the detail.
925  /// @{
926  void reversePoints(GA_IndexMap &map);
927  void reversePrims(GA_IndexMap &map);
929  { reversePoints(getIndexMap(GA_ATTRIB_POINT)); }
931  { reversePrims(getIndexMap(GA_ATTRIB_PRIMITIVE)); }
932  /// @}
933 
934  /// Sort points or primitives by proximity to a position
935  /// @{
936  void proximityPoints(GA_IndexMap &points,
937  const UT_Vector3 &point);
938  void proximityPrims(GA_IndexMap &primitives,
939  const UT_Vector3 &point);
940  void proximityToPointList(const UT_Vector3 &point)
941  { proximityPoints(getIndexMap(GA_ATTRIB_POINT), point); }
943  { proximityPrims(getIndexMap(GA_ATTRIB_PRIMITIVE), point); }
944  /// @}
945 
946  /// Sort points by the order in which they are first referred-to by
947  /// vertices.
948  /// @{
949  void vertexOrder(GA_IndexMap &points);
951  { vertexOrder(getIndexMap(GA_ATTRIB_POINT)); }
952  /// @}
953 
954  /// Create a mesh primitive or polygon primitives representing a
955  /// super-quadric surface specified by parms.
956  void superEllipsoid(const GU_SuperQuadParms &parms);
957 
958  /// Split the specified polygon into convex polygons with at most
959  /// maxpts vertices each. By default, this triangulates the polygon.
960  /// If flipedges is true, it will flip edges to get the Delaunay
961  /// triangulation, avoiding small angles where possible.
962  /// If avoiddegeneracy is true, degenerate triangles will not be generated;
963  /// note that this means that the mesh may not be watertight or even
964  /// connected.
965  void convexPoly(GEO_PrimPoly *pp, GA_ElementWranglerCache &wranglers,
966  GA_Size maxpts = 3, const GA_Detail *restgdp=0,
967  bool flipedges = false, bool avoiddegeneracy = false);
968  /// Split polygons in the specified polygon soup into convex polygons
969  /// with at most maxpts vertices each. By default, this triangulates the
970  /// polygon. If flipedges is true, it will flip edges to get the Delaunay
971  /// triangulation, avoiding small angles where possible.
972  /// If avoiddegeneracy is true, degenerate triangles will not be generated;
973  /// note that this means that the mesh may not be watertight or even
974  /// connected.
975  void convexPolySoup(GEO_PrimPolySoup *polysoup,
976  GA_Size maxpts = 3, const GA_Detail*restgdp=0,
977  bool flipedges = false,
978  bool avoiddegeneracy = false);
979  /// Split polygons (including in polygon soups) in the detail into convex
980  /// polygons with at most maxpts vertices each. By default, this
981  /// triangulates the polygon. If flipedges is true, it will flip edges to
982  /// get the Delaunay triangulation, avoiding small angles where possible.
983  /// If avoiddegeneracy is true, degenerate triangles will not be generated;
984  /// note that this means that the mesh may not be watertight or even
985  /// connected.
986  void convex(GA_Size maxpts=3, GA_PrimitiveGroup *primGroup=0,
987  const GA_Detail *restgdp=0, bool flipedges = false,
988  bool avoiddegeneracy = false);
989 
990  /// Add non-planar polygon primitives to nonplanargroup.
991  GA_Size findNonPlanar(GA_PrimitiveGroup *nonplanargroup, float tol = 0.0001F,
992  const GA_PrimitiveGroup *searchprimgroup = NULL);
993 
994  /// Clip primitives, keeping everything where dot(normal, P) >= d.
995  /// If clippts is true, disconnected points are also clipped.
996  void clip(UT_Vector3 &normal, float d = 0, int normlize = 0,
997  const GA_PrimitiveGroup *primGroup = 0,
998  bool clippts = false);
999 
1000 //
1001 // Polygon creasing
1002  void crease(UT_Vector3 &normal, float d = 0,
1003  int normlize = 0, int outputGroups = 0,
1004  GA_PrimitiveGroup *above = 0,
1005  GA_PrimitiveGroup *below = 0,
1006  const GA_PrimitiveGroup *creaseGroup = 0);
1007 //
1008 // fractals
1009  void fractalize(int seed = 1, float roughness = 0.6F,
1010  float scaleby=1, int divs=1,
1011  int fixedBoundry = 1, int useVtxNorms = 0,
1012  float nx = 0, float ny = 0, float nz = 1,
1013  const GA_PrimitiveGroup *fractalGroup = 0);
1014 
1015  //
1016  // Shrink Wrap and tools
1017 
1018  /// This routine is originally developed for the Bullet RBD solver to adjust
1019  /// the geometry of a convex 3D polygon to remove the space around the geometry
1020  /// caused by the collision margin required for the Bullet solver.
1021  void shrink( fpreal distance,
1022  fpreal clip_tolerance = 0.0001,
1023  fpreal consilidate_tolerance = 0.001);
1024 
1025  /// preliminary routine to setup the gdp to be shrunk by the shrink routine
1026  bool tetrahedralizeForShrink( const GA_PointGroup *ptGroup = 0,
1027  GU_Detail *gdp = 0 );
1028 
1029 
1030  /// Twist operations. The method returns 0 if everything goes OK, else -1.
1031  /// "pasted" returns 1 if at least one pasted surface was involved in
1032  /// the deformation, else 0.
1033  int nonLinearDeform(GU_DeformType type,const GU_TwistParms &parms,
1034  int &pasted);
1035 
1036  /// NOTE: This is something specific to NURBS surfaces and it uses
1037  /// pasted surface primitives, so it's probably not what you want!!!
1038  /// Creates an offset surface from the specified surface & radius.
1039  GEO_Hull *offset(const GU_OffsetParms &parms);
1040 
1041  /// Create a Gordon surface out of the given bi-linear network of faces.
1042  /// The faces don't have to be the same type or order or anything.
1043  /// We return the surface if OK and 0 otherwise. If the u or v faces
1044  /// contain only one face, we automatically generate a final curve. If
1045  /// both u faces and vfaces have 1 curve or one has 2 and the other 1,
1046  /// we generate a Coons surface. "accurate" is used when the curves do not
1047  /// intersect (i.e. when we must compute their min distances).
1048  /// @{
1049  GEO_Hull *gordon(GEO_SurfaceType surftype, int accurate,
1050  const GA_PrimitiveGroup &ufaces,
1051  const GA_PrimitiveGroup &vfaces,
1052  int reparameterize = 0);
1053  GEO_Hull *gordon(GEO_SurfaceType surftype, int accurate,
1054  const UT_Array<GEO_Primitive*> &uprims_in,
1055  const UT_Array<GEO_Primitive*> &vprims_in,
1056  GU_SkinCache& skin_cache,
1057  int reparameterize = 0);
1058  /// @}
1059 
1060  /// Generate a Coons surface out of up to 4 boundary curves. Return a
1061  /// pointer to the surface if successful and 0 otherwise. The faces do
1062  /// not have to have the same type or order.
1063  GEO_Hull *coons(GEO_SurfaceType surftype,
1064  const GEO_Face &uface1, const GEO_Face &vface1,
1065  const GEO_Face *uface2 = 0, const GEO_Face *vface2 = 0);
1066 
1067  /// Generate a skinned surface out of a set of cross-sections. The faces
1068  /// don't have to be the same type or order. We return the surface is OK
1069  /// and 0 otherwise. Specifying a vorder of 0 tells the method to
1070  /// come up with a legal default value for the surface. If "doskin" is
1071  /// true, the cross-sections will be right on the surface; otherwise, we
1072  /// build a ruled surface, which simply steals the curves' CVs and assigns
1073  /// them to the surface.
1074  GEO_Hull *skin(GU_SkinParms &parms, GU_SkinCache& skin_cache);
1075 
1076  /// This restrictive skinning method assumes the faces are of the same type
1077  /// and have the same number of CVs. order 0 means pick most suitable one.
1078  /// If doskin is false, we build a ruled surface. nprims is the number
1079  /// of faces in the group; we compute it if -1. We return the resulting
1080  /// surface and do not delete the input faces. We also assume that if
1081  /// nprims > 2 and vorder != 2 and doskin, all the faces are nonrational.
1082  /// Finally, the provided vParmValues if given specifies what v coordinate
1083  /// each of the provided faces should interpolate.
1084  /// @{
1085  GEO_Hull *skin(const GA_PrimitiveGroup &ucfaces,
1086  GEO_SurfaceType surftype = GEO_PATCH_QUADS,
1087  unsigned vorder = 0, int vwrap = 0,
1088  int doskin = 1, int nprims = -1,
1089  const UT_Vector *vParmValues = 0);
1090  GEO_Hull *skin(const UT_Array<GEO_Primitive*> & prims_in,
1091  GU_SkinCache& skin_cache,
1092  GEO_SurfaceType surftype = GEO_PATCH_QUADS,
1093  unsigned vorder = 0, int vwrap = 0,
1094  int doskin = 1, int nprims = -1,
1095  const UT_Vector *vParmValues = 0);
1096  /// @}
1097 
1098  /// See GU_Ruled.h for the various closure and interpolation types
1099  /// which are valid. Specifying an orderv of 0 makes the routine
1100  /// come up with a legal default value for the surface.
1101  int ruled( GEO_Hull *&surface, const GU_RuledParms &p,
1102  const GU_CapOptions &caps);
1103 
1104  /// This is what the Skin SOP and Sweep SOP use for skinning
1105  /// cross-sections.
1106  /// See GU_CurveNetwork.h for parameter types. This method generates
1107  /// a skinned surface, a Coons surface, or a Gordon surface depending on
1108  /// the primitive groups it is given. Specifying an orderv of 0 makes the
1109  /// routine come up with a legal default value for the surface.
1110  int curveNetwork(GEO_Hull *&hull, GU_CurveNetworkParms &p,
1111  int &count, GU_SkinCache& skin_cache);
1112 
1113  GU_ERROR sweep( GU_SweepParms parms );
1114  void rails( GU_RailParms parms );
1115 
1116  /// Join more faces or surfaces together.
1117  GEO_Primitive *join( GU_JoinParms &p, int &count);
1118 
1119  /// Generate a fillet between two curves on surfaces:
1120  GEO_Hull *filletTrims(GU_TrimFilletParms &parms, int &count);
1121 
1122  /// Generate a rounded fillet:
1123  GEO_Hull *filletRound(GU_RoundFilletParms &parms);
1124  /// NOTE: The first 5 columns of the matrix must be GEO_Curve*,
1125  /// and the other 2 columns of the matrix must be GEO_TPSurf*.
1126  void filletRoundNetwork(UT_RefMatrix<GEO_Primitive *>,
1127  GU_RoundFilletParms &parms);
1128 
1129  /// Fillet a set of faces/hulls
1130  /// Return 0 if OK, -1 otherwise (non face/hull types)
1131  int fillet(GU_FilletParms &parms, int &count);
1132 
1133  /// Loft (stitch) a number of polygons together without changing the number
1134  /// of points in the detail.
1135  /// @{
1136  void loft(GU_LoftParms &p, const GA_PointGroup &g1,
1137  const GA_PointGroup &g2);
1138  void loft(GU_LoftParms &p,
1139  const GA_PrimitiveGroup *group = 0);
1140  /// @}
1141 
1142  /// Revolves all curves in the given gdp (or only curves in the
1143  /// group if the group is given) around a line given by the center
1144  /// and axis. Only polygonal curves use the divisions. NURBS and
1145  /// Bezier curves are revolved a special way to create a perfectly
1146  /// round surface with a minimum number of revolution copies.
1147  int revolve( const GU_RevolveParms &parms,
1148  const GU_CapOptions &caps, int &count);
1149 
1150  /// Warp curves or surfaces. Return 0 if successful and -1 otherwise.
1151  int warp(GU_WarpParms &parms);
1152 
1153  /// Curve Clay it!
1154  GU_ERROR curveClay(const GU_CurveClayParms &ccparm);
1155 
1156  /// This puts endcaps on the specified hull
1157  int endCap(GEO_Hull &hull, const GU_CapParms &parms);
1158  int endCap(GEO_Face &face, const GU_CapParms &parms);
1159 
1160  /// This places all caps on the hull
1161  int setCaps(GEO_Hull &hull, const GU_CapOptions &parms, int &count);
1162  int setCaps(GEO_Face &face, const GU_CapOptions &parms, int &count);
1163 
1164  /// Creates a deformed copy of a source detail given a pair of
1165  /// rest and deform details. Return 1 if a pasted surface was deformed,
1166  /// else 0. If 'deform_history' is passed in, every time we deform a point
1167  /// from our source, we mark this by setting the bit in 'deform_history'
1168  /// whose index corresponds to the point's number to 1. Useful if you want
1169  /// to know which points we deformed.
1170  int lattice(const GU_Detail *source, const GU_Detail *rest,
1171  const GU_Detail *deform, int xdiv, int ydiv, int zdiv,
1172  const GA_PointGroup *ptgroup = 0,
1173  UT_BitArray *deform_history = NULL,
1175 
1176  /// All points of the gdp are deformed according to the meta source
1177  /// field that surrounds it. The deformation is controlled by a
1178  /// transformation matrix.
1179  int magnet( const GU_MagnetParms &parms );
1180 
1181  /// trace a raster image to form closed polygons
1182  float trace(GU_TraceParms *parms);
1183 
1184  /// add point texture attributes to traced geometry
1185  void applyTraceTexture(float xres, float yres, float resolution);
1186 
1187 
1188  /// fit a sequence of discrete points to a series of bezier curves
1189  void fit2DCurve(const GU_Detail *source, float error_squared,
1190  GA_PrimitiveGroup *primGroup = 0);
1191 
1192  /// Fit a curve through its breakpoints
1193  /// @{
1194  GEO_Curve *interpCurveBreakpoints(const GEO_Face &face,
1196  int order=4,
1198  GEO_Curve *interpCurveBreakpoints(const GA_OffsetList &point_offsets,
1200  int order=4, int wrapped=0,
1202  GEO_Curve *interpCurveBreakpoints(const UT_Vector4Array &v4Data,
1204  int order=4, int wrapped=0,
1206  /// @}
1207 
1208  /// interpolation data points
1209  /// @{
1210  GEO_Curve *interpCurveGlobal(const GEO_Face &face,
1212  int order=4,
1215  GEO_Curve *interpCurveGlobal(const GA_OffsetList &point_offsets,
1217  int order=4, int wrapped=0,
1220  GEO_Curve *interpCurveGlobal(const GA_Range &point_range,
1222  int order=4, int wrapped=0,
1225  GEO_Curve *interpCurveGlobal(const UT_Vector4Array &v4Data,
1227  int order=4, int wrapped=0,
1230  GEO_Curve *interpCurveLocal(const GEO_Face &face,
1232  int order = 4, int corner=0);
1233  GEO_Curve *interpCurveLocal(const UT_Array<GA_Offset> &goData,
1235  int order = 4, int wrapped=0, int corner=0);
1236  GEO_Curve *interpCurveLocal(const UT_Vector4Array &v4Data,
1238  int order = 4, int wrapped=0, int corner=0);
1239 
1240  GEO_TPSurf *interpSurfGlobal(const GEO_Hull &mesh,
1242  int uOrder=4, int vOrder=4,
1248  const UT_Vector *uParmValues = 0,
1249  const UT_Vector *vParmValues = 0);
1250 
1251  GEO_TPSurf *interpSurfGlobal(const GA_OffsetMatrix &goMesh,
1253  int uOrder=4, int vOrder=4,
1254  bool uWrapped=false, bool vWrapped=false,
1260  const UT_Vector *uParmValues = 0,
1261  const UT_Vector *vParmValues = 0);
1262 
1263  GEO_TPSurf *interpSurfBreakpoints(const GEO_Hull &mesh,
1265  int uOrder=4, int vOrder=4,
1271  const UT_Vector *uParmValues = 0,
1272  const UT_Vector *vParmValues = 0);
1273 
1274  GEO_TPSurf *interpSurfBreakpoints(const GA_OffsetMatrix &goMesh,
1276  int uOrder=4, int vOrder=4,
1277  bool uWrapped=false, bool vWrapped=false,
1283  const UT_Vector *uParmValues = 0,
1284  const UT_Vector *vParmValues = 0);
1285  /// @}
1286 
1287  /// Approximate data points given a tolerance.
1288  /// Only for open endinterpolated surface.
1289  /// @{
1290  GEO_Curve *approxCurveGlobal(const GEO_Face &face,
1292  int order=4,
1293  float tol=1e-1F, float smooth=0.0F,
1294  int noMultipleKnots=1);
1295  GEO_Curve *approxCurveGlobal(const UT_Vector4Array &v4Data,
1297  int order=4, int wrapped=0,
1298  float tol=1e-1F, float smooth=0.0F,
1299  int noMultipleKnots=1);
1300 
1301  GEO_TPSurf *approxSurfGlobal(const GEO_Hull &mesh,
1303  int uOrder=4, int vOrder=4,
1305  float tol=1e-1F, float smooth=0.0F,
1306  int uNoMultipleKnots=1,
1307  int vNoMultipleKnots=1);
1308  GEO_TPSurf *approxSurfGlobal(const GA_OffsetMatrix &gpMesh,
1310  int uOrder=4, int vOrder=4,
1311  int uWrapped=0, int vWrapped=0,
1313  float tol=1e-1F, float smooth=0.0F,
1314  int uNoMultipleKnots=1,
1315  int vNoMultipleKnots=1);
1316  /// @}
1317 
1318  /// methods to refine face and hull types
1319  /// @{
1320  void refine(float *uunit, int ulen,
1321  float *vunit, int vlen,
1322  int countu=1, int countv=1,
1323  int arcspacing = 0,
1324  const GA_PrimitiveGroup *primGroup = 0);
1325 
1326  void unrefine(float umin, float umax,
1327  float vmin, float vmax,
1328  int countu=1, int countv=1,
1329  float utol=0.001F, float vtol=0.001F,
1330  const GA_PrimitiveGroup *primGroup = 0);
1331 
1332  void subdivide(float *uunit, int ulen,
1333  float *vunit, int vlen,
1334  int arcspacing = 0,
1335  const GA_PrimitiveGroup *primGroup = 0);
1336 
1337  /// op = {0 = isoparms, 1 = points, 2 = profiles}
1338  int extract(float *uunit, int ulen,
1339  float *vunit, int vlen,
1340  const GA_PrimitiveGroup *primGroup = 0,
1341  GA_PointGroup *newPoints = 0,
1342  int op = 0, int keepOriginal = 0,
1343  int atbreakpoints = 0, int use_arc_length = 0);
1344 
1345  void extractIsoParms(float *uunit, int ulen,
1346  float *vunit, int vlen,
1347  GA_PrimitiveGroup *newPrims = 0,
1348  const GA_PrimitiveGroup *primGroup = 0);
1349 
1350  void extractPoints(float *uunit, int ulen,
1351  float *vunit, int vlen,
1352  GA_PointGroup *newPoints = 0,
1353  const GA_PrimitiveGroup *primGroup = 0);
1354 
1355  void extractProfiles(float *uunit, int ulen,
1356  float *vunit, int vlen,
1357  const GA_PrimitiveGroup *primGroup = 0);
1358 
1359  void extractIsoParmsAtBreak(float *uunit, int ulen,
1360  float *vunit, int vlen,
1361  GA_PrimitiveGroup *newPrims = 0,
1362  const GA_PrimitiveGroup *primGroup = 0);
1363 
1364  void extractPointsAtBreak(float *uunit, int ulen,
1365  float *vunit, int vlen,
1366  GA_PointGroup *newPoints = 0,
1367  const GA_PrimitiveGroup *primGroup = 0);
1368 
1369  void extractProfilesAtBreak(float *uunit, int ulen,
1370  float *vunit, int vlen,
1371  const GA_PrimitiveGroup *primGroup = 0);
1372 
1373 
1374  int cut(float *uunit, int ulen,
1375  float *vunit, int vlen,
1376  const GA_PrimitiveGroup *primGroup = 0,
1377  int keepin=1, int keepout=0, int atbreakpoints = 0,
1378  int allU = 0, int allV = 0, int use_arc_length = 0);
1379  /// @}
1380 
1381 
1382  /// approximate a spline by using polygonal hull inputs
1383  /// deletes existing polygons if deleteAll is true
1384  void polySpline(GU_PolysplineParms &parms,
1385  const GA_PrimitiveGroup *primGroup = 0,
1386  bool deleteAll = true);
1387 
1388  /// approximate a patch by using polygonal or mesh hull inputs
1389  /// Returns true on success, else false if an error occurred.
1390  bool polyPatch(GU_PolypatchParms &parms,
1391  const GA_PrimitiveGroup *primGroup = 0);
1392 
1393  /// reduce the number of polygons in a detail:
1394  int polyReduce(GU_PolyReduceParms &parms,
1395  const GA_PrimitiveGroup *primGroup = 0,
1396  int *pointIndexTable = 0);
1397 
1398  /// Create polygon soup(s), i.e. GU_PrimPolySoup, where possible in this detail
1399  void polySoup(const GEO_PolySoupParms &parms , const GU_Detail *srcdetail);
1400 
1401  /// Create geometry through premise and rule substitution
1402  void lsystem(GU_LSystemParms &lp);
1403 
1404  /// Get information about a GU_Detail
1405  /// If maxlines < 0, there will be no limit to the number of groups
1406  /// If overridememusage is positive, it will be used rather than the
1407  /// getMemoryUsage().
1408  int info(std::ostream &os,
1409  int max_group_lines=15,
1410  bool pretty=false,
1411  const UT::ArraySet<const void *> *dontcounttheseblocks = 0,
1412  bool instanced=false) const;
1413  /// Get information text for the geometry. This will @b append to the work
1414  /// buffer.
1415  void info(UT_WorkBuffer &wbuf,
1416  int max_group_lines=15,
1417  bool pretty=false,
1418  const UT::ArraySet<const void *> *dontcounttheseblocks = 0,
1419  bool instanced=false) const;
1420 
1421  /// Fills in a stat structure with the volume information.
1422  virtual void statVolumes(GA_Stat &stat, uint level/*=0xffff*/) const;
1423 
1424  /// @c intersectRay will find the closest intersection with a primitive
1425  /// in the detail. If the dist pointer is nil, then the first intersection
1426  /// found will be returned (instead of the closest). The nml will contain
1427  /// the normal for the primitive at the point of intersection.
1428  /// Accuracy of 0 is inaccurate, 1 is normal, 2 engages Algebraic pruning
1429  /// where available.
1430  ///
1431  /// @param o The ray origin
1432  /// @param d The ray directin
1433  /// @param tmax This can be used to limit the ray to intersections within
1434  /// the given radius.
1435  /// @param tol Intersection tolerance
1436  /// @param dist Return the distance from the origin to the hit
1437  /// @param pos Return the hit position (i.e. <tt>o + dist*d</tt>)
1438  /// @param nml Return the normal of the primitive at the hit position
1439  /// @param accurate Determine primitive intersection algorithms for NURBS
1440  /// @param u The u parametric coordinate of the hit surface
1441  /// @param v The v parametric coordinate of the hit surface
1442  /// @param ignoretrim Ignore trim inside/out tests for trimmed surfaces.
1443  ///
1444  /// @warning If the @c dist parameter is 0 the first hit found will be
1445  /// returned. This may @b not be the closest hit. This can be used to
1446  /// perform a quick check to see if @b any primitives intersect the ray
1447  /// (i.e. for shadow casting).
1448  ///
1449  /// @warning This function iterates over all primitives without any
1450  /// acceleration structure. If you need to send multiple rays, please see
1451  /// GU_RayIntersect.
1452  SYS_DEPRECATED_HDK(16.0)
1453  GEO_Primitive *intersectRay(const UT_Vector3 &o, const UT_Vector3 &d,
1454  float tmax = 1E17F, float tol = 1E-12F,
1455  float *dist = 0, UT_Vector3 *pos = 0,
1456  UT_Vector3 *nml = 0, int accurate = 0,
1457  float *u = 0, float *v = 0,
1458  int ignoretrim = 1) const;
1459 
1460  /// Figure out the parameters of the face/surface that all the given
1461  /// faces/surfaces should have in order to be fully compatible with one
1462  /// another. Return 0 if all the primitive types are faces/surfaces,
1463  /// and -1 otherwise.
1464  /// @{
1465  int commonFaceConfig(
1466  const GA_PrimitiveGroup &faceGroup,
1467  GA_PrimCompat::TypeMask &type, int &order,
1468  bool &open, bool &ends) const;
1469  int commonFaceConfig(
1470  const UT_Array<GEO_Primitive*> &faces_in,
1471  GA_PrimCompat::TypeMask &type, int &order,
1472  bool &open, bool &ends) const;
1473  int commonSurfaceConfig(const GA_PrimitiveGroup &surfs,
1474  GA_PrimCompat::TypeMask &type,
1475  int &orderu, int &orderv,
1476  bool &openu, bool &openv,
1477  bool &endsu, bool &endsv) const;
1478  /// @}
1479 
1480  /// Incompatible faces in infaces are made compatible and set in outfaces.
1481  /// Return 0 of OK, -1 otherwise. If extratype is not nil and the highest
1482  /// face type of the infaces is less than *extratype, replace the common
1483  /// type by *extratype. In the method that takes 2 input groups, we make
1484  /// sure that the primitives in the 2 groups have the same type. Set
1485  /// equalcvs to true make them all have the same number of CVs too.
1486  /// @{
1487  int makeFacesCompatible(
1488  const GA_PrimitiveGroup &infaces,
1489  GA_PrimitiveGroup &outfaces,
1490  bool mustopen = false,
1491  bool mustends = false,
1492  bool nonrational = false,
1493  GA_PrimCompat::TypeMask *extratype = 0,
1494  bool equalcvs = true);
1495  int makeFacesCompatible(
1496  const UT_Array<GEO_Primitive*> &prims_in,
1497  UT_Array<GEO_Primitive*>& prims_out,
1498  bool mustopen = false,
1499  bool mustends = false,
1500  bool nonrational = false,
1501  GA_PrimCompat::TypeMask *extratype = 0,
1502  bool equalcvs = true);
1503  int makeFacesCompatible(
1504  const GA_PrimitiveGroup &infacesU,
1505  const GA_PrimitiveGroup &infacesV,
1506  GA_PrimitiveGroup &outfacesU,
1507  GA_PrimitiveGroup &outfacesV,
1508  bool mustopen = false,
1509  bool mustends = false,
1510  bool nonrational = false,
1511  GA_PrimCompat::TypeMask *extratype = 0,
1512  bool equalcvs = true);
1513  int makeFacesCompatible(
1514  const UT_Array<GEO_Primitive*> &ufaces_array,
1515  const UT_Array<GEO_Primitive*> &vfaces_array,
1516  UT_Array<GEO_Primitive*> &ucfaces_array,
1517  UT_Array<GEO_Primitive*> &vcfaces_array,
1518  bool mustopen = false,
1519  bool mustends = false,
1520  bool nonrational = false,
1521  GA_PrimCompat::TypeMask *extratype = 0,
1522  bool equalcvs = true);
1523  /// @}
1524 
1525  /// Loft a subsection of each hull and update the vertex indices where
1526  /// the subsection occurs. Does partial nurb merging if the bases is given
1527  /// Assumes the two hulls have been properly reconfigured.
1528  static int loftHulls(GEO_Hull *left, GEO_Hull *right,
1529  float lwidth1, float lwidth2,
1530  float rwidth1, float rwidth2,
1531  int sharp, int &lstart, int &rstart,
1532  int &lmax, int &rmax,
1533  int loftU, GA_NUBBasis *nubbasis);
1534 
1535  /// Refine the hull at the unit domain value and return the
1536  /// row/col index where it occurs
1537  /// @{
1538  static int getSubdividedCV(GEO_Hull *hull, int udir, float unit);
1539  static int getSubdividedCV(GEO_Face *face, float unit);
1540  /// @}
1541 
1542  /// Methods for registering and unregistering geometry io converters.
1543  /// @{
1544  static void registerIOTranslator(GEO_IOTranslator *trans);
1545  static void unregisterIOTranslator(GEO_IOTranslator *trans);
1546  static exint getIOTranslatorCount();
1547  static const GEO_IOTranslator *getIOTranslator(exint i);
1548  /// @}
1549 
1550  GA_Detail::IOStatus saveH9File(const char *filename,
1551  const GA_SaveOptions *options) const;
1552  static GA_Detail::IOStatus statH9File(const char *filename,
1553  GA_Stat &sbuf, uint level);
1554 
1555  /// Returns true if filename is a recognized extension.
1556  static bool isFormatSupported(const char *filename);
1557 
1558  /// Allocate an IO handler for a filename, or return NULL if the handler is
1559  /// the classic format. The returned translator must be deleted. The
1560  /// easiest way to do this is with a UT_UniquePtr: @code
1561  /// UT_UniquePtr<GEO_IOTranslator> xlate(getSupportedFormat(filename));
1562  /// if (xlate)
1563  /// xlate->fileSave(gdp, ...);
1564  /// @endcode
1565  static GEO_IOTranslator *getSupportedFormat(const char *filename);
1566 
1567  /// Align a set of primitives by rotation and translation
1568  void align(GU_AlignParms &parms);
1569 
1570  /// Align a set of faces/hulls at optional levels of continuity.
1571  /// face/hull pre/posttranslate + row stitching + row tangent
1572  /// Faces are aligned with faces, hulls with hulls.
1573  /// Return 0 if OK, -1 otherwise (non face/hull types)
1574  int stitch(GU_StitchParms &parms);
1575 
1576  /// Incompatible surfaces in insurfs are made compatible and set in outsurfs.
1577  /// Return 0 of OK, -1 otherwise. If extratype is not nil and the highest
1578  /// surface type of the insurfs is less than *extratype, replace the common
1579  /// type by *extratype. Set equalcvs to true make them all have the same number
1580  /// of CVs too.
1581  int makeSurfacesCompatible(
1582  const GA_PrimitiveGroup &insurfs,
1583  GA_PrimitiveGroup &outsurfs,
1584  bool mustopenu=false, bool mustopenv=false,
1585  bool mustendsu=false, bool mustendsv=false,
1586  bool equalcvsu=true, bool equalcvsv=true,
1587  GA_PrimCompat::TypeMask *extratype = 0);
1588 
1589  /// NOTE: These functions only apply to pasted surface primitives,
1590  /// so they're probably not what you want!
1591  /// Convenience wrappers for several common pasting operations. The last
1592  /// method destroys both groups:
1593  /// @{
1594  GA_PrimitiveGroup *getPastedSurfaces(const char *n = "__gu_all_pasted__");
1595  GA_PrimitiveGroup *getPastedSurfaces(GA_PrimitiveGroup *&used,
1596  const char *n = "__gu_all_pasted__",
1597  const char *u = "__gu_used_pasted__");
1598  void updatePastedDisplacement(GA_Offset ptoff,
1599  const GA_PrimitiveGroup *all,
1600  GA_PrimitiveGroup *used);
1601  int updatePastedDisplacements(void);
1602  int updatePastedDependents(GA_PrimitiveGroup *all,
1603  GA_PrimitiveGroup *used);
1604  /// @}
1605 
1606  /// Error Routines
1607  /// @{
1608  GU_ERROR error() const
1609  {
1610  return UTgetErrorManager()->getSeverity();
1611  }
1612 
1614  const char *msg = 0) const
1615  {
1616  UTgetErrorManager()->addMessage("GU", code, msg);
1617  }
1619  const char *msg = 0) const
1620  {
1621  UTgetErrorManager()->addWarning("GU", code, msg);
1622  }
1623  void addError(GU_ErrorCodes code, const char *msg = 0) const
1624  {
1625  UTgetErrorManager()->addError("GU", code, msg);
1626  }
1627  /// @}
1628 
1629  /// Returns a cook selection to fill in. If an already existing cook
1630  /// selection exists, of the wrong type, it is removed, and a new one
1631  /// created. Otherwise the existing cook selection is optionally cleared
1632  /// and returned.
1633  ///
1634  /// The cook selection is the selection being manipulated and displayed
1635  /// by a node.
1636  GU_SelectionHandle getOrCreateCookSelection(GA_GroupType group_type,
1637  bool ordered = false,
1638  bool clear_matching = false);
1639 
1640  /// Returns the group type of the current cook selection, or
1641  /// GA_GROUP_INVALID if there isn't one.
1642  GA_GroupType getCookSelectionGroupType() const;
1643 
1644  /// Creates a cook selection that directly references the supplied group.
1645  /// Any changes to the cook selection later will copy this group and use
1646  /// that copy.
1647  ///
1648  /// You must call removeCookSelection() if this group is later destroyed
1649  /// and the cook selection is still referencing it, which can be checked
1650  /// by calling hasShallowCookSelectionReference(group).
1651  ///
1652  /// NB: Only use this method if you know what you're doing. Any gains in
1653  /// performance are likely not to be worth the management pain.
1654  GU_SelectionHandle createShallowCookSelection(GA_Group *group);
1655 
1656  /// Returns whether this detail has a shallow cook selection referencing
1657  /// the specified group.
1658  bool hasShallowCookSelectionReference(
1659  const GA_Group *group) const;
1660 
1661  /// Returns the current cook selection;
1662  GU_SelectionHandle cookSelection() const;
1663 
1664  /// Removes the current cook selection from this detail. Since the selection
1665  /// is a shared object, there's no guarantee that it will be immediately
1666  /// destroyed, but only that this detail is no longer associated with it.
1667  void removeCookSelection();
1668 
1669  /// Do not use this method unless you know EXACTLY what you are doing. It
1670  /// forces the use of the supplied cook selection.
1671  void forceCookSelection(GU_SelectionHandle sel);
1672 
1673  /// Do not use this method unless you know EXACTLY what you are doing. It
1674  /// removes the cook selection from the detail without orphaning it so the
1675  /// only safe thing to do is to return it later using forceCookSelection().
1676  GU_SelectionHandle stealCookSelection();
1677 
1678  /// Remove points from polygons if they lie on (within a tolerance)
1679  /// the line connecting the previous and next points.
1680  void removeInlinePoints(float tol,
1681  const GA_PrimitiveGroup *prims);
1682 
1683  /// Remove zero area polygons
1684  /// Returns number of polygons removed
1685  /// @{
1686  GA_Size removeZeroAreaFaces(GA_PrimitiveGroup *grp,
1687  bool ignoreOpenFaces = false,
1688  float tolerance = 0.001F,
1689  bool onlyPolys = true);
1690  GA_Size removeZeroAreaFaces(const UT_IntArray &primlist,
1691  bool ignoreOpenFaces = false,
1692  float tolerance = 0.001F,
1693  bool onlyPolys = true);
1694  /// @}
1695 
1696  /// Deletes the geometry in the given group, unlike deleteEdges,
1697  /// it doesn't repair the holes left behind.
1698  void deleteGroupGeometry(const GA_Group &group);
1699 
1700  /// Deletes edge geometry
1701  SYS_DEPRECATED_HDK(16.0)
1702  void deleteEdges(GA_EdgeGroup &edgegroup,
1703  bool del_inline_points,
1704  float inlinetol,
1705  bool del_unused_points = true,
1706  bool del_bridges = true);
1707 
1708  /// There are three different ways of handling situations where all edges
1709  /// that connect polygon boundaries are dissolved.
1710  /// - GU_BRIDGEMODE_BRIDGE @n
1711  /// Insert bridge edges to connect the boundary loops.
1712  /// - GU_BRIDGEMODE_DISJOINT @n
1713  /// Create a separate polygon for each boundary loop.
1714  /// - GU_BRIDGEMODE_DELETE @n
1715  /// Delete the polygons.
1717  {
1720  GU_BRIDGEMODE_DELETE
1721  };
1722  void dissolveEdges(const GA_EdgeGroup &edgegroup,
1723  bool del_inline_points,
1724  fpreal inlinetol,
1725  bool del_unused_points,
1726  BridgeMode bridge_mode,
1727  bool del_degenerate_bridges,
1728  bool boundary_curves);
1729 
1730  /// Flips edges
1731  void flipEdges(const GA_EdgeGroup &edgegroup,
1732  int rotations = 1,
1733  bool rotattribs = false,
1734  GA_EdgeGroup *outedges = 0);
1735  /// Splits edges
1736  /// This is the main method for the PolySplit SOP. The splitlocs are
1737  /// the positions along which you wish to split polygons. When quadcut
1738  /// is false, the Shortest Path algorithm is used, otherwise the Quad Cut
1739  /// algorithm is used. The forcecut flag is used with the Shortest Path
1740  /// algorithm to force it to perform cuts where the initial cut has failed.
1741  /// To form a complete path of edges, supply the first location again as
1742  /// the last location in the splitlocs array. If quadcomplete is true and
1743  /// quadcut is false, then in certain cases extra edges will be inserted so
1744  /// that faces which began as quads get split into faces which are quads. If
1745  /// outPositions is set, it will be filled with a list of points in the path
1746  /// in RE_PRIM_LINES fashion. If fixEnds is set, either end of the path that
1747  /// is on a face will be given an extra segment to connect it to the nearest
1748  /// point to ensure that the resulting polygons don't self-intersect.
1749  void edgeSplit(const GU_SplitLocArray &splitlocs,
1750  bool quadcut = false,
1751  bool forcecut = true,
1752  GA_EdgeGroup *outedges = 0,
1753  float tolerance = SYS_FTOLERANCE,
1754  bool quadcomplete = false,
1755  bool modifyGdp = true,
1756  UT_Fpreal32Array *outPositions = NULL,
1757  bool fixEnds = false);
1758 
1759  /// Inserts points on edges
1760  /// @{
1761  void divideEdges(const GA_EdgeGroup &edgegroup, int numdivs = 1,
1762  bool applytoall = true,
1763  bool use_shared_points = false,
1764  GA_EdgeGroup *outedges = 0,
1765  UT_Array<GA_Offset> *new_points = 0,
1766  bool preserve_edge_dir = false);
1767  void divideEdges(const GA_EdgeGroup &edgegroup,
1768  int numdivs,
1769  bool applytoall,
1770  bool use_shared_points,
1771  GA_EdgeGroup *outedges,
1772  UT_Array<GA_Offset> *new_points,
1773  bool preserve_edge_dir,
1774  float fraction);
1775  /// @}
1776 
1777  /// Inserts points on edges, with a different fraction and number of
1778  /// divisions per edge.
1779  void divideEdges(const UT_Array<GU_EdgeDiv *> &divlocs,
1780  GA_PointGroup &outgrp);
1781 
1782  /// Transform breakpoints
1783  void transformBreakpoints(const UT_Matrix4 &mat,
1784  const GA_BreakpointGroup *grp = 0,
1785  int quickxform = 0);
1786 
1787 
1788  /// Extrude faces, uses local face spaces and tries to mirror extrusions.
1789  void polyExtrude(const GU_PolyExtrudeParms &parms);
1790 
1791  /// Collapse Edges
1792  void edgeCollapse(const GA_EdgeGroup &edgegroup,
1793  bool removedegen = true,
1794  bool updatenmls = true,
1795  GA_PointGroup *outpoints = 0);
1796 
1797  /// Adds crease weights to edges
1798  void edgeCrease(const GU_EdgeCreaseParms &parms);
1799 
1800  /// Insets points
1801  void pointInset(const GA_PointGroup *ptgroup,
1802  float insetdist, float nmldist);
1803 
1804  /// Find the oriented bounding box that contains the given primitives.
1805  /// The box is returned as a rotate+translate matrix to the box's
1806  /// orientation and centre, and a vector containing the boxes extents
1807  /// along its primary axes. The extents are radii, ie, one-half
1808  /// of what a bounding box size() would be.
1809  ///
1810  /// Returns zero radii if the group contains no primitives.
1811  void getOBBox(const GA_PrimitiveGroup *grp,
1813  UT_Vector3 &radii) const;
1814  /// Return the oriented bounding box that contains the given points,
1815  /// returning a UT_OBBox, which contains translation and rotation information
1816  void getOBBoxForPoints(const GA_PointGroup *grp,
1817  UT_OBBoxD &obb) const;
1818 
1819  /// Get cached bounding box. This uses the meta cache count and the data
1820  /// id on P to determine whether the bounds need to be recomputed.
1821  ///
1822  /// It's possible that the cached bounds might be invalid in some cases
1823  /// (where the geometry is modified without updates to the meta cache count
1824  /// or the data id on P.
1825  bool getCachedBounds(UT_BoundingBox &box) const;
1826  /// Forcibly clear the cached bounds without having to update the meta
1827  /// cache count or data ID on P.
1828  void clearCachedBounds();
1829 
1830  /// Make each primitive planar, returns the number of primitives xformed
1831  GA_Size makePrimsPlanar(const GA_PrimitiveGroup *grp = 0);
1832 
1833  static void loadIODSOs();
1834 
1835  /// Create a list of all internal file extensions
1836  static void getFileExtensions(UT_StringArray &result);
1837 
1838  /// Check to see whether the file extension matches a known binary file
1839  /// extension. The argument is the full filename.
1840  static bool matchBinaryFileExtension(const UT_StringRef &filename);
1841 
1842  /// Check to see whether the file extension matches a known ASCII file
1843  /// extension. The argument is the full filename.
1844  static bool matchASCIIFileExtension(const UT_StringRef &filename);
1845 
1846 
1847  /// These methods assume no changes have been made to the geometry since the
1848  /// last call to incrementMetaCacheCount(). "attrib" should refer to a string
1849  /// or integer attribute.
1850  int getUniqueValueCount(const GA_Attribute *attrib) const;
1851  int getUniqueIntegerValue(const GA_Attribute *attrib, int idx) const;
1852  const char *getUniqueStringValue(const GA_Attribute *attrib, int idx) const;
1853  GA_Range getRangeByValue(const GA_Attribute *attrib, int v) const;
1854  GA_Range getRangeByValue(const GA_Attribute *attrib, const char *v) const;
1855 
1856 
1857  class AttribValueLookupTable;
1858  class AttribSingleValueLookupTable;
1859 
1860  const AttribValueLookupTable *getLookupTable(const GA_Attribute *attrib) const;
1861  const AttribSingleValueLookupTable *getSingleLookupTable(const GA_Attribute *attrib) const;
1862 
1863 protected:
1864  /// Register intrinsic attributes
1867 
1868 private:
1869  int twist (const GU_TwistParms &parms, int &p);
1870  int bend (const GU_TwistParms &parms, int &p);
1871  int squashStretch (const GU_TwistParms &parms, int &p);
1872  int shear (const GU_TwistParms &parms, int &p);
1873  int taper (const GU_TwistParms &parms, int &p);
1874  int linearTaper (const GU_TwistParms &parms, int &p);
1875 
1876  template <typename ArrayType>
1877  GEO_Curve * privateInterpCurveGlobal(
1878  const ArrayType &gpData,
1879  const GA_PrimitiveTypeId &type,
1880  int order, int wrapped,
1881  GA_ParameterizationType parmType,
1882  GA_KnotSpaceType knotSpaceType);
1883 
1884  void fillGrid(GEO_Hull &hull, int rows, int cols,
1885  float x_size, float y_size,
1886  float x_center, float y_center,
1887  float z_center,
1888  GU_OrientationType plane);
1889 
1890  void convertPolysToHull(
1891  GEO_ConvertParms &parms,
1892  bool keep_original);
1893  void convertToSoups(
1894  GEO_ConvertParms &parms,
1895  bool keep_original);
1896  void convertVolumesToVDBs(
1897  GEO_ConvertParms &parms,
1898  bool keep_original);
1899  void convertVDBsToVolumes(
1900  GEO_ConvertParms &parms,
1901  bool keep_original);
1902  void convertVolumesToPolys(
1903  GEO_ConvertParms &parms,
1904  bool keep_original);
1905  void convertMetasToPolys(
1906  GEO_ConvertParms &parms,
1907  bool keep_original);
1908  void convertTetsToPolys(
1909  GEO_ConvertParms &parms,
1910  bool keep_original);
1911  void doConversion(
1912  GEO_ConvertParms &parms,
1913  bool keep_original);
1914 
1915  void orientPoly(GEO_PrimPoly *poly,
1916  UT_BitArray &process,
1917  UT_BitArray &reverse);
1918 
1919  GEO_Primitive *surfCube(int xdiv, int ydiv, int zdiv,
1920  int orderx, int ordery, int orderz,
1921  float xmin, float xmax,
1922  float ymin, float ymax,
1923  float zmin, float zmax,
1924  GEO_SurfaceType type, int kind,
1925  bool consolidate);
1926 
1927  // Checks if a single primitive is dirty (see getDirtyData).
1928  bool isDirtySinglePrimitive(GA_Primitive *prim,
1929  bool checkRepPoints,
1930  float tol);
1931 
1932  void lodConvert(GA_PrimitiveGroup *grp,
1933  UT_BoundingBox &box, int cluster, float lod,
1934  bool makepolysoup = false);
1935  void divisionConvert(GA_PrimitiveGroup *grp, int adjust,
1936  UT_BoundingBox &box, int divx,int divy,int divz,
1937  const UT_Array<GA_PrimitiveGroup *> &groups,
1938  bool makepolysoup = false);
1939  int adjustStepBox(float &min, float &max, float step);
1940  void stepSizeConvert(GA_PrimitiveGroup *grp, int adjust,
1941  UT_BoundingBox &box, float sx,float sy,float sz,
1942  const UT_Array<GA_PrimitiveGroup *> &groups,
1943  bool makepolysoup = false);
1944 
1945  /// makes a single primitive planar (see makePrimsPlanar)
1946  bool primToPlane(GEO_Primitive *pprim,
1947  GA_PointGroup &fixedPoints);
1948 
1949  /// Prohibited to avoid accidentally passing by value.
1950  /// Use constructor that takes a const GU_Detail * if you
1951  /// really need to construct a copied detail.
1952  GU_Detail(const GU_Detail &src);
1953 
1954  friend class GU_PrimitiveFactory; // For intrinsic registration
1955 
1956  void construct()
1957  {
1958  myBoundingCache = NULL;
1959  myValueLookupCache = NULL;
1960  }
1961 
1962  /// The sole cook selection associated with this detail.
1963  GU_SelectionHandle myCookSelection;
1964 
1965  class BoundingCache; // Forward declare
1966  BoundingCache *myBoundingCache;
1967 
1968  mutable gu_ValueLookupCache *myValueLookupCache;
1969 };
1970 
1971 #endif
virtual void clearCaches()
Definition: GA_Detail.h:1819
A class to manage an ordered array which has fixed offset handles.
Definition: GA_IndexMap.h:63
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
GU_MetricType
Definition: GU_Types.h:87
GU_DeformType
Definition: GU_Types.h:58
void merge(const GEO_Detail &src, const GA_PrimitiveGroup *primGrp=0, int mergePrimGroup=1, int insertPrimsAtHead=0, GA_GBPointRedirectArray *dest_to_src_ptarray=0, bool keep_internal_groups=true, GA_DataIdStrategy data_id_strategy=GA_DATA_ID_BUMP)
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
GLint left
Definition: glcorearb.h:2004
GA_DataIdStrategy
Definition: GA_Types.h:186
const GLdouble * v
Definition: glcorearb.h:836
png_infop int * unit
Definition: png.h:2536
const UT_IntArray & ringValence() const
Definition: GU_Detail.h:212
virtual GA_Detail * cloneEmptyDetail(bool clone_attributes) const =0
SYS_VISIBILITY_EXPORT void newGeometryPrim(GA_PrimitiveFactory *factory)
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
void reversePrimitiveList()
Definition: GU_Detail.h:930
GA_API const UT_StringHolder twist
Arbitrarily Oriented Bounding (OBB)
Definition: UT_OBBox.h:25
GLint level
Definition: glcorearb.h:107
A soup of polygons.
void reversePointList()
Definition: GU_Detail.h:928
OnlyConsGroupPropagateType
Definition: GU_Detail.h:477
UT_ErrorSeverity
Definition: UT_Error.h:25
void shiftPrimitiveList(GA_Size aoffset)
Definition: GU_Detail.h:917
UT_API UT_ErrorManager * UTgetErrorManager()
void addWarning(GU_ErrorCodes code, const char *msg=0) const
Definition: GU_Detail.h:1618
Structure for the PolySouping code.
png_uint_32 i
Definition: png.h:2877
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:211
SnapAttributesType
Definition: GU_Detail.h:561
GLsizeiptr size
Definition: glcorearb.h:663
GU_GridType
Definition: GU_Types.h:70
const UT_Array< GA_OffsetArray > & myRingZero
Definition: GU_Detail.h:216
#define GA_INVALID_OFFSET
Definition: GA_Types.h:654
png_infop png_bytep * trans
Definition: png.h:2520
A range of elements in an index-map.
Definition: GA_Range.h:42
GA_ParameterizationType
Definition: GA_Types.h:173
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:617
long long int64
Definition: SYS_Types.h:107
GLdouble n
Definition: glcorearb.h:2007
GR_API RE_Geometry * buildGrid(RE_Render *r, UT_Vector3F center, UT_Vector2F size, Orientation orient, const char *cache_name=NULL)
GU_Detail(const GU_Detail *src, GA_DataIdStrategy data_id_strategy=GA_DATA_ID_BUMP)
Definition: GU_Detail.h:163
T distance(const UT_Vector4T< T > &v1, const UT_Vector4T< T > &v2)
Definition: UT_Vector4.h:698
int64 exint
Definition: SYS_Types.h:116
virtual void countMemory(UT_MemoryCounter &counter, bool inclusive) const
const std::enable_if<!VecTraits< T >::IsVec, T >::type & max(const T &a, const T &b)
Definition: Composite.h:133
int method
Definition: png.h:1924
GLsizei GLsizei GLchar * source
Definition: glcorearb.h:802
GLintptr offset
Definition: glcorearb.h:664
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:915
virtual void statVolumes(GA_Stat &stat, uint level=0xffff) const
Fill out only the volume information.
T angle(const Vec2< T > &v1, const Vec2< T > &v2)
Definition: Vec2.h:472
void sortPointList(fpreal *order)
Definition: GU_Detail.h:899
void sortPointList(int seed)
Definition: GU_Detail.h:890
#define GU_API
Definition: GU_API.h:12
GLboolean * data
Definition: glcorearb.h:130
#define SYS_DEPRECATED_HDK(__V__)
void sortPrimitiveList(const UT_Vector3 &o, const UT_Vector3 &d)
Definition: GU_Detail.h:881
void sortPointList(const UT_Vector3 &o, const UT_Vector3 &d)
Definition: GU_Detail.h:879
UT_Array< GU_SplitLoc * > GU_SplitLocArray
Definition: GU_Detail.h:123
virtual int open(float queuesize)
GA_API const UT_StringHolder transform
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)
UT_SharedPtr< GU_Selection > GU_SelectionHandle
GA_API const UT_StringHolder orient
unsigned int uint
Definition: SYS_Types.h:40
GU_OrientationType
Definition: GU_Types.h:32
GLint GLsizei count
Definition: glcorearb.h:404
GU_Detail(bool full_topology)
Definition: GU_Detail.h:143
void addMessage(GU_ErrorCodes code, const char *msg=0) const
Definition: GU_Detail.h:1613
IFDmantra py
Definition: HDK_Image.dox:266
double fpreal
Definition: SYS_Types.h:270
Class to return information about a GA_Detail.
Definition: GA_Stat.h:50
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
void sortPrimitiveList(int seed)
Definition: GU_Detail.h:892
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:138
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:940
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:861
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:107
GEO_SurfaceType
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:203
void proximityToPrimitiveList(const UT_Vector3 &point)
Definition: GU_Detail.h:942
void sortPointList(GU_AxisType axis)
Definition: GU_Detail.h:859
GU_TextureType
Definition: GU_Types.h:94
#define const
Definition: zconf.h:214
void sortByVertexOrder()
Definition: GU_Detail.h:950
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:901
const std::enable_if<!VecTraits< T >::IsVec, T >::type & min(const T &a, const T &b)
Definition: Composite.h:129
GA_API const UT_StringHolder rest
GA_KnotSpaceType
Definition: GA_Types.h:166
GLint lod
Definition: glcorearb.h:2764
GU_ErrorCodes
Definition: GU_Error.h:20
void addError(GU_ErrorCodes code, const char *msg=0) const
Definition: GU_Detail.h:1623
UT_ErrorSeverity addMessage(const char *type, int code, const char *msg=0, const UT_SourceLocation *loc=0)
GLenum src
Definition: glcorearb.h:1792