HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GT_PrimMeshSplit.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: GT_PrimMeshSplit.h ( GT Library, C++)
7  *
8  * COMMENTS: Mesh splitting class
9  */
10 
11 #ifndef __GT_PrimMeshSplit__
12 #define __GT_PrimMeshSplit__
13 
14 #include "GT_API.h"
15 #include "GT_Primitive.h"
16 #include "GT_DataArray.h"
17 #include <UT/UT_BoundingBox.h>
18 #include <UT/UT_ParallelUtil.h> // For UT_BlockedRange
19 
21 
22 /// Parent class to split a mesh.
24 {
25 public:
26  /// Create a split parent for the mesh given N elemental primitives
29  /// d-tor
30  ~GT_PrimMeshSplitParent() override;
31 
32  const char *className() const override
33  { return "GT_PrimMeshSplitParent"; }
34 
35  /// @{
36  /// Methods from GT_Primitive
37  bool refine(GT_Refine &refiner,
38  const GT_RefineParms *parms) const override;
39  void enlargeBounds(UT_BoundingBox boxes[],
40  int nsegs) const override;
41  int getMotionSegments() const override;
42  int64 getMemoryUsage() const override;
43  /// @}
44 
45  /// The range refine method should refine a range of elements into
46  /// individual elements. If the method returns false, the mesh will be
47  /// split into sub-meshes with smaller ranges.
48  virtual bool rangeRefine(const GT_PrimMeshSplitRange &range,
49  GT_Refine &refiner,
50  const GT_RefineParms *parms) const = 0;
51 
52  /// Enlarge bounding boxes for each segment over the range of elements
53  /// There is be a bounding box for each segment.
54  virtual void rangeEnlargeBounds(const GT_PrimMeshSplitRange &range,
55  UT_BoundingBox &full,
56  UT_BoundingBox boxes[], int nsegs) const = 0;
57 
58  /// Enlarge the bounding boxes for each element in the range. There is a
59  /// bounding box for each element. Only the motion segment given should be
60  /// considered.
61  virtual void rangeElementBounds(const GT_PrimMeshSplitRange &range,
62  UT_BoundingBox boxes[], int segment) const = 0;
63 
64  /// Given a bounding box for the range of primitives, partition
65  /// the range of primitives by pivoting the indices.
66  /// The default behaviour relies on the bounding boxes of primitives at
67  /// segment 0.
68  virtual bool partitionRange(const GT_PrimMeshSplitRange &range,
69  const UT_BoundingBox &full_box,
72  int start_segment=0, int end_segment=0);
73  /// Lookup an index
75  {
76  myIndices->import(index, &index, 1);
77  return index;
78  }
79 
80  /// Access parent primitive
81  const GT_PrimitiveHandle &getBaseMesh() const { return myMesh; }
82 protected:
83  /// Determine which elements should be on the left side and which should be
84  /// on the right side.
85  /// By default, this will compute bounding boxes for the elements and split
86  /// based on the largest box dimension.
87  virtual void partitionElements(const GT_PrimMeshSplitRange &range,
88  const UT_BoundingBox &full, bool *left,
89  int start_seg=0, int end_seg=0) const;
90 
91 
94 };
95 
97 {
98 public:
99  /// Create a split primitive for the given mesh
103  /// d-tor
104  ~GT_PrimMeshSplitChild() override;
105 
106  const char *className() const override { return "GT_PrimMeshSplitChild"; }
107 
108  /// It's up the subclass to perform refinement. But, to implement a simple
109  /// split into further children, you might do something like: @code
110  /// GT_Offset l0, l1, r0, r1;
111  /// if (getParent()->rangePartition(myBox, myRange, l0, l1, r0, r1))
112  /// {
113  /// if (l1 >= l0)
114  /// refiner.addPrimitive(new SplitPrimitive(getParent(), l0, l1))
115  /// if (r1 >= r0)
116  /// refiner.addPrimitive(new SplitPrimitive(getParent(), r0, r1))
117  /// }
118  /// @endcode
119  bool refine(GT_Refine &refiner,
120  const GT_RefineParms *parms) const override;
121 
122  /// @{
123  /// Methods from GT_Primitive
124  void enlargeBounds(UT_BoundingBox boxes[],
125  int nsegs) const override;
126  int getMotionSegments() const override;
127  int64 getMemoryUsage() const override;
129  { return new GT_PrimMeshSplitChild(*this); }
130  /// @}
131 
132  /// Convenience method to get the entries
133  GT_Size entries() const
134  { return myRange.size(); }
135  /// Convenience method to map from the index in this list to the parent's
136  /// index.
138  {
139  return getParent()->getIndex(myRange.begin()+index);
140  }
141 
142  /// Get bounding box.
143  /// @note This is only valid after @c enlargeBounds() has been called.
144  const UT_BoundingBox getBox() const { return myBox; }
145 
146 protected:
148  {
149  return static_cast
150  <const GT_PrimMeshSplitParent *>
151  (myParent.get());
152  }
154  {
155  return static_cast
157  (myParent.get());
158  }
159 
163 };
164 
165 #endif
virtual int getMotionSegments() const =0
GLenum GLint * range
Definition: glcorearb.h:1925
virtual bool refine(GT_Refine &refiner, const GT_RefineParms *parms=NULL) const
GLint left
Definition: glcorearb.h:2005
GT_Offset getIndex(GT_Offset index) const
Lookup an index.
GLdouble right
Definition: glad.h:2817
GT_PrimitiveHandle myParent
#define GT_API
Definition: GT_API.h:13
GT_DataArrayHandle myIndices
GT_PrimitiveHandle myMesh
const GT_PrimMeshSplitParent * getParent() const
GT_PrimMeshSplitParent * getParent()
UT_BlockedRange< GT_Offset > GT_PrimMeshSplitRange
GU_API GA_Offset getParent(const GU_Detail *gdp, const GA_Offset &node)
GT_Offset getIndex(GT_Offset index) const
const char * className() const override
int64 GT_Offset
Definition: GT_Types.h:129
const GT_PrimitiveHandle & getBaseMesh() const
Access parent primitive.
long long int64
Definition: SYS_Types.h:116
GT_PrimitiveHandle doSoftCopy() const override
The base class for all GT primitive types.
Definition: GT_Primitive.h:43
virtual int64 getMemoryUsage() const =0
Processes primitives generated by refinement process.
Definition: GT_Refine.h:20
int64 GT_Size
Definition: GT_Types.h:128
GLuint index
Definition: glcorearb.h:786
const UT_BoundingBox getBox() const
GT_Size entries() const
Convenience method to get the entries.
Parent class to split a mesh.
const char * className() const override
GT_PrimMeshSplitRange myRange
virtual void enlargeBounds(UT_BoundingBox boxes[], int nsegments) const =0
GLenum src
Definition: glcorearb.h:1793