HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GT_PrimFragments.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_PrimFragments.h (GT Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __GT_PrimFragments__
12 #define __GT_PrimFragments__
13 
14 #include "GT_API.h"
15 #include "GT_Primitive.h"
16 #include "GT_TransformArray.h"
17 #include "GT_GEODetailList.h"
18 
19 class UT_StringRef;
20 
21 
22 /// A primitive made of multiple fragments that are coalesced into one geometry
23 ///
24 /// For each fragment, you can query:
25 /// - The transform for the fragment
26 /// - The untransformed bounding box
27 /// - The transformed bounding box
28 /// - The fragment's __primitive_id
29 /// - The fragment's __point_id
30 /// These properties are only used for information, not for refinement or
31 /// rendering. The single geometry is composed of the transformed fragments.
32 ///
33 /// Attributes are:
34 /// - detail: one for the whole primitive
35 /// The instance primitive does *not* pass these down when it refines.
37 {
38 public:
40  GT_PrimFragments(const GT_PrimitiveHandle &geometry,
43  ~GT_PrimFragments() override;
44 
45  /// @{
46  /// Interface from GT_Primitive
47  const char *className() const override;
48  int getPrimitiveType() const override;
50  int nsegs) const override
51  { doEnlargeBounds(boxes, nsegs, false); }
53  int nsegs) const override
54  { doEnlargeBounds(boxes, nsegs, true); }
55  void getVelocityRange(
56  UT_Vector3 &vmin, UT_Vector3 &vmax,
57  const UT_StringRef &attribute_name
58  ) const override;
59  bool refine(GT_Refine &refiner,
60  const GT_RefineParms *parms=NULL) const override;
61  int getMotionSegments() const override;
62  int64 getMemoryUsage() const override;
63  bool save(UT_JSONWriter &w) const override;
64  fpreal computePerimeter(int seg=0) const override;
65  fpreal computeSurfaceArea(int seg=0) const override;
66  fpreal computeVolume(const UT_Vector3 &ref_P,
67  int seg=0) const override;
68  GT_PrimitiveHandle doHarden() const override;
69  GT_PrimitiveHandle doSoftCopy() const override;
70  const GT_ViewportRefineOptions &viewportRefineOptions() const override;
72  { return myAttributes; }
73  /// @}
74 
75  /// Set up __primitive_id, __point_id and transforms based on fragment
76  /// primitives. This assumes that the primitives are all packed primitives
77  /// of some kind (and have a single point).
78  ///
79  /// The centroids should likely be in the center of the transformed
80  /// bounding box.
81  void setupFragments(const GT_GEOOffsetList &primitives,
82  const GT_GEOOffsetList &vertices,
83  const GT_GEOOffsetList &points,
84  const GT_DataArrayHandle &centroids);
85 
86  /// Return number of fragments
87  GT_Size entries() const
88  { return myCentroids ? myCentroids->entries():0; }
89 
90  /// Return combined geometry
92  { return myGeometry; }
93 
94  /// Return fragment centroids (where to render decorations)
96  { return myCentroids; }
97  /// @{
98  /// If the geometry being instanced comes from a GU_Detail, then the source
99  /// geometry should be set to point to this geometry. This lets viewport
100  /// decorations be rendered properly.
102  { return mySourceGeometry; }
104  { mySourceGeometry = g; }
105  /// @}
106 
107 protected:
108  /// Set up __primitive_id, __point_id and __vertex_id explicitly
109  /// The arrays can be NULL.
110  void setFragmentAttributes(const GT_DataArrayHandle &prim_ids,
111  const GT_DataArrayHandle &vertex_ids,
112  const GT_DataArrayHandle &point_ids);
113 
114  void doEnlargeBounds(UT_BoundingBox boxes[], int nsegs,
115  bool forrender) const;
120 };
121 
122 #endif
virtual int getMotionSegments() const =0
virtual bool refine(GT_Refine &refiner, const GT_RefineParms *parms=NULL) const
GLdouble GLdouble GLint GLint const GLdouble * points
Definition: glad.h:2676
virtual const GT_ViewportRefineOptions & viewportRefineOptions() const
virtual int getPrimitiveType() const
virtual fpreal computePerimeter(int seg=0) const
const GT_AttributeListHandle & getUniformAttributes() const override
virtual fpreal computeVolume(const UT_Vector3 &ref_P, int seg=0) const
const GT_GEODetailListHandle & sourceGeometry() const
GLboolean GLboolean g
Definition: glcorearb.h:1222
#define GT_API
Definition: GT_API.h:13
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:37
GT_AttributeListHandle myAttributes
virtual GT_PrimitiveHandle doSoftCopy() const =0
GT_GEODetailListHandle mySourceGeometry
virtual fpreal computeSurfaceArea(int seg=0) const
virtual void getVelocityRange(UT_Vector3 &min, UT_Vector3 &max, const UT_StringRef &attribute_name=GA_Names::v) const
GLsizei GLsizei GLchar * source
Definition: glcorearb.h:803
long long int64
Definition: SYS_Types.h:116
The base class for all GT primitive types.
Definition: GT_Primitive.h:43
virtual GT_PrimitiveHandle doHarden() const
virtual int64 getMemoryUsage() const =0
void enlargeBounds(UT_BoundingBox boxes[], int nsegs) const override
Processes primitives generated by refinement process.
Definition: GT_Refine.h:20
const GT_PrimitiveHandle & geometry() const
Return combined geometry.
int64 GT_Size
Definition: GT_Types.h:128
const GT_DataArrayHandle & centroids() const
Return fragment centroids (where to render decorations)
GT_Size entries() const
Return number of fragments.
fpreal64 fpreal
Definition: SYS_Types.h:277
GT_PrimitiveHandle myGeometry
virtual bool save(UT_JSONWriter &w) const
void enlargeRenderBounds(UT_BoundingBox boxes[], int nsegs) const override
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:857
GT_DataArrayHandle myCentroids
UT_SharedPtr< GT_GEODetailList > GT_GEODetailListHandle
virtual const char * className() const =0
void setSourceGeometry(const GT_GEODetailListHandle &g)
GLenum src
Definition: glcorearb.h:1793