Cortex  10.0.0-a4
GEO_CortexPrimitive.h
1 //
3 // Copyright (c) 2013-2015, Image Engine Design Inc. All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 //
12 // * Redistributions in binary form must reproduce the above copyright
13 // notice, this list of conditions and the following disclaimer in the
14 // documentation and/or other materials provided with the distribution.
15 //
16 // * Neither the name of Image Engine Design nor the names of any
17 // other contributors to this software may be used to endorse or
18 // promote products derived from this software without specific prior
19 // written permission.
20 //
21 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
22 // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
23 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
25 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
28 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 //
34 
35 #ifndef IECOREHOUDINI_GEOCORTEXPRIMITIVE_H
36 #define IECOREHOUDINI_GEOCORTEXPRIMITIVE_H
37 
38 #include "GA/GA_Defines.h"
39 #include "GEO/GEO_Primitive.h"
40 #include "GU/GU_Detail.h"
41 #include "GEO/GEO_Point.h"
42 #include "OP/OP_Context.h"
43 #include "OP/OP_NodeInfoParms.h"
44 #include "UT/UT_Version.h"
45 #include "UT/UT_ParallelUtil.h"
46 #include "GA/GA_Primitive.h"
47 #if UT_MAJOR_VERSION_INT >= 14
48 
49 typedef GEO_ConvertParms ConvertParms;
50 
51 #else
52 
53 #include "GU/GU_Prim.h"
54 
55 typedef GU_Primitive::NormalComp NormalComp;
56 typedef GU_ConvertParms ConvertParms;
57 
58 #endif
59 
60 #include "IECore/Object.h"
61 
62 namespace IECoreHoudini
63 {
64 
66 class GEO_CortexPrimitive : public GEO_Primitive
67 {
68  public :
69 
70  GEO_CortexPrimitive( GA_Detail *detail, GA_Offset offset = GA_INVALID_OFFSET );
71  GEO_CortexPrimitive( GEO_Detail *detail, GA_Offset offset = GA_INVALID_OFFSET );
72 #if UT_MAJOR_VERSION_INT < 16
73  GEO_CortexPrimitive( const GA_MergeMap &map, GA_Detail &detail, GA_Offset offset, const GA_Primitive &src );
74 #endif
75  virtual ~GEO_CortexPrimitive();
76 
77 #if UT_MAJOR_VERSION_INT < 16
78  virtual void swapVertexOffsets( const GA_Defragment &defrag );
79  virtual GA_Size getVertexCount() const;
80  virtual GA_Offset getVertexOffset( GA_Size index ) const;
81 #endif
82  virtual GA_DereferenceStatus dereferencePoint( GA_Offset point, bool dry_run = false );
83  virtual GA_DereferenceStatus dereferencePoints( const GA_RangeMemberQuery &pt_q, bool dry_run = false );
84 
85 #if UT_MAJOR_VERSION_INT >= 13
86 
87  virtual void stashed( bool beingstashed, GA_Offset offset=GA_INVALID_OFFSET );
88 
89 #endif
90 
91  // \todo: This signature is for Houdini 12.5 and earlier. Remove when we drop support
92  virtual void stashed( int onoff, GA_Offset offset=GA_INVALID_OFFSET );
93  virtual void clearForDeletion();
94  virtual bool isDegenerate() const;
95  virtual void copyUnwiredForMerge( const GA_Primitive *src, const GA_MergeMap &map );
96  virtual void transform( const UT_Matrix4 &xform );
97  virtual const GA_PrimitiveJSON* getJSON() const;
98  virtual void reverse();
99 
100  virtual GEO_Primitive * copy( int preserve_shared_pts ) const;
101  virtual void copyPrimitive( const GEO_Primitive *src, GEO_Point **ptredirect );
102  virtual int getBBox( UT_BoundingBox *bbox ) const;
103  virtual void enlargePointBounds( UT_BoundingBox &box ) const;
104  virtual UT_Vector3 computeNormal() const;
105  virtual int detachPoints( GA_PointGroup &grp );
106 #if UT_MAJOR_VERSION_INT >= 16
107 
108  bool saveVertexArray( UT_JSONWriter &w, const GA_SaveMap &map ) const;
109  bool loadVertexArray( UT_JSONParser &p, const GA_LoadMap &map );
110 
111 #endif
112 
113  static const char *typeName;
114 
115 #if UT_MAJOR_VERSION_INT >=16
116 
117  static void create(GA_Primitive **new_prims, GA_Size nprimitives, GA_Detail &detail, GA_Offset start_offset, const GA_PrimitiveDefinition &def);
118 
119 #elif UT_MAJOR_VERSION_INT >= 14
120 
121  static GA_Primitive *create( GA_Detail &detail, GA_Offset offset, const GA_PrimitiveDefinition &definition );
122  // merge constructor
123  static GA_Primitive *create( const GA_MergeMap &map, GA_Detail &detail, GA_Offset offset, const GA_Primitive &src );
124 
125 #endif
126 
127  // factory
128  static GEO_CortexPrimitive *build( GU_Detail *geo, const IECore::Object *object );
129 
130  virtual int64 getMemoryUsage() const;
131  virtual void countMemory( UT_MemoryCounter &counter ) const;
132  virtual void copyPrimitive( const GEO_Primitive *src );
133 
134  virtual const GA_PrimitiveDefinition &getTypeDef() const;
137  static void setTypeDef( GA_PrimitiveDefinition *def );
138  static GA_PrimitiveTypeId typeId();
139 
140  virtual GEO_Primitive *convert( ConvertParms &parms, GA_PointGroup *usedpts = 0 );
141  virtual GEO_Primitive *convertNew( ConvertParms &parms );
142  virtual void normal( NormalComp &output ) const;
143  virtual int intersectRay( const UT_Vector3 &o, const UT_Vector3 &d, float tmax=1E17F, float tol=1E-12F, float *distance=0, UT_Vector3 *pos=0, UT_Vector3 *nml=0, int accurate=0, float *u=0, float *v=0, int ignoretrim=1 ) const;
144 
148  void setObject( const IECore::Object *object );
150  const IECore::Object *getObject() const;
154 
157  static void infoText( const GU_Detail *geo, OP_Context &context, OP_NodeInfoParms &parms );
158 
159  protected :
160 
161 #if (UT_VERSION_INT >= 0x0c050132) // 12.5.306 or later
162  virtual void copyOffsetPrimitive( const GEO_Primitive *src, GA_Index basept );
163 #else
164  virtual void copyOffsetPrimitive( const GEO_Primitive *src, int basept );
165 #endif
166 
167  virtual bool evaluatePointRefMap( GA_Offset result_vtx, GA_AttributeRefMap &map, fpreal u, fpreal v=0, uint du=0, uint dv=0 ) const;
168 
169  IECore::ObjectPtr m_object;
170 #if UT_MAJOR_VERSION_INT < 16
171  // offset for the representative vertex
172  GA_Offset m_offset;
173 #endif
174 
175  private :
176 
177  class geo_CortexPrimitiveJSON;
178 
179  GEO_Primitive *doConvert( ConvertParms &parms );
180 
181  static GA_PrimitiveDefinition *m_definition;
182 
183 };
184 
185 } // namespace IECoreHoudini
186 
187 #endif // IECOREHOUDINI_GEOCORTEXPRIMITIVE_H
188 
static void infoText(const GU_Detail *geo, OP_Context &context, OP_NodeInfoParms &parms)
The IECoreHoudini namespace holds all the functionality of libIECoreHoudini.
Definition: CoreHoudini.h:51
Definition: Object.h:104
const IECore::Object * getObject() const
Get the IECore::Object contained by this GEO_Primitive.
Wrapper for hosting IECore::Objects natively in Houdini.
Definition: GEO_CortexPrimitive.h:66
static void setTypeDef(GA_PrimitiveDefinition *def)
void setObject(const IECore::Object *object)