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  virtual ~GT_PrimMeshSplitParent();
31 
32  virtual const char *className() const { return "GT_PrimMeshSplitParent"; }
33 
34  /// @{
35  /// Methods from GT_Primitive
36  virtual bool refine(GT_Refine &refiner,
37  const GT_RefineParms *parms) const;
38  virtual void enlargeBounds(UT_BoundingBox boxes[], int nsegs) const;
39  virtual int getMotionSegments() const;
40  virtual int64 getMemoryUsage() const;
41  /// @}
42 
43  /// The range refine method should refine a range of elements into
44  /// individual elements. If the method returns false, the mesh will be
45  /// split into sub-meshes with smaller ranges.
46  virtual bool rangeRefine(const GT_PrimMeshSplitRange &range,
47  GT_Refine &refiner,
48  const GT_RefineParms *parms) const = 0;
49 
50  /// Enlarge bounding boxes for each segment over the range of elements
51  /// There is be a bounding box for each segment.
52  virtual void rangeEnlargeBounds(const GT_PrimMeshSplitRange &range,
53  UT_BoundingBox &full,
54  UT_BoundingBox boxes[], int nsegs) const = 0;
55 
56  /// Enlarge the bounding boxes for each element in the range. There is a
57  /// bounding box for each element. Only the motion segment given should be
58  /// considered.
59  virtual void rangeElementBounds(const GT_PrimMeshSplitRange &range,
60  UT_BoundingBox boxes[], int segment) const = 0;
61 
62  /// Given a bounding box for the range of primitives, partition
63  /// the range of primitives by pivoting the indices.
64  /// The default behaviour relies on the bounding boxes of primtives at
65  /// segment 0.
66  virtual bool partitionRange(const GT_PrimMeshSplitRange &range,
67  const UT_BoundingBox &full_box,
69  GT_PrimMeshSplitRange &right,
70  int start_segment=0, int end_segment=0);
71  /// Lookup an index
73  {
74  myIndices->import(index, &index, 1);
75  return index;
76  }
77 
78  /// Access parent primitive
79  const GT_PrimitiveHandle &getBaseMesh() const { return myMesh; }
80 protected:
81  /// Determine which elements should be on the left side and which should be
82  /// on the right side.
83  /// By default, this will compute bounding boxes for the elements and split
84  /// based on the largest box dimension.
85  virtual void partitionElements(const GT_PrimMeshSplitRange &range,
86  const UT_BoundingBox &full, bool *left,
87  int start_seg=0, int end_seg=0) const;
88 
89 
92 };
93 
95 {
96 public:
97  /// Create a split primitive for the given mesh
101  /// d-tor
102  virtual ~GT_PrimMeshSplitChild();
103 
104  virtual const char *className() const { return "GT_PrimMeshSplitChild"; }
105 
106  /// It's up the subclass to perform refinement. But, to implement a simple
107  /// split into further children, you might do something like: @code
108  /// GT_Offset l0, l1, r0, r1;
109  /// if (getParent()->rangePartition(myBox, myRange, l0, l1, r0, r1))
110  /// {
111  /// if (l1 >= l0)
112  /// refiner.addPrimitive(new SplitPrimitive(getParent(), l0, l1))
113  /// if (r1 >= r0)
114  /// refiner.addPrimitive(new SplitPrimitive(getParent(), r0, r1))
115  /// }
116  /// @endcode
117  virtual bool refine(GT_Refine &refiner,
118  const GT_RefineParms *parms) const;
119 
120  /// @{
121  /// Methods from GT_Primitive
122  virtual void enlargeBounds(UT_BoundingBox boxes[], int nsegs) const;
123  virtual int getMotionSegments() const;
124  virtual int64 getMemoryUsage() const;
126  { return new GT_PrimMeshSplitChild(*this); }
127  /// @}
128 
129  /// Convenience method to get the entries
130  GT_Size entries() const
131  { return myRange.size(); }
132  /// Convenience method to map from the index in this list to the parent's
133  /// index.
135  {
136  return getParent()->getIndex(myRange.begin()+index);
137  }
138 
139  /// Get bounding box.
140  /// @note This is only valid after @c enlargeBounds() has been called.
141  const UT_BoundingBox getBox() const { return myBox; }
142 
143 protected:
145  {
146  return static_cast
147  <const GT_PrimMeshSplitParent *>
148  (myParent.get());
149  }
151  {
152  return static_cast
154  (myParent.get());
155  }
156 
160 };
161 
162 #endif
virtual int getMotionSegments() const =0
GLenum GLint * range
Definition: glcorearb.h:1924
virtual bool refine(GT_Refine &refiner, const GT_RefineParms *parms=NULL) const
GLint left
Definition: glcorearb.h:2004
GT_Offset getIndex(GT_Offset index) const
Lookup an index.
GT_PrimitiveHandle myParent
virtual const char * className() const
#define GT_API
Definition: GT_API.h:11
GT_DataArrayHandle myIndices
GT_PrimitiveHandle myMesh
const GT_PrimMeshSplitParent * getParent() const
GT_PrimMeshSplitParent * getParent()
virtual const char * className() const
UT_BlockedRange< GT_Offset > GT_PrimMeshSplitRange
GT_Offset getIndex(GT_Offset index) const
long long int64
Definition: SYS_Types.h:107
const GT_PrimitiveHandle & getBaseMesh() const
Access parent primitive.
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
GLuint index
Definition: glcorearb.h:785
const UT_BoundingBox getBox() const
GT_Size entries() const
Convenience method to get the entries.
int64 GT_Offset
Definition: GT_Types.h:113
int64 GT_Size
Definition: GT_Types.h:112
Parent class to split a mesh.
GT_PrimMeshSplitRange myRange
virtual void enlargeBounds(UT_BoundingBox boxes[], int nsegments) const =0
virtual GT_PrimitiveHandle doSoftCopy() const
GLenum src
Definition: glcorearb.h:1792