HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
OFaceSet.h
Go to the documentation of this file.
1 //-*****************************************************************************
2 //
3 // Copyright (c) 2009-2012,
4 // Sony Pictures Imageworks, Inc. and
5 // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd.
6 //
7 // All rights reserved.
8 //
9 // Redistribution and use in source and binary forms, with or without
10 // modification, are permitted provided that the following conditions are
11 // met:
12 // * Redistributions of source code must retain the above copyright
13 // notice, this list of conditions and the following disclaimer.
14 // * Redistributions in binary form must reproduce the above
15 // copyright notice, this list of conditions and the following disclaimer
16 // in the documentation and/or other materials provided with the
17 // distribution.
18 // * Neither the name of Sony Pictures Imageworks, nor
19 // Industrial Light & Magic nor the names of their contributors may be used
20 // to endorse or promote products derived from this software without specific
21 // prior written permission.
22 //
23 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 //
35 //-*****************************************************************************
36 
37 #ifndef _Alembic_AbcGeom_OFaceSet_h_
38 #define _Alembic_AbcGeom_OFaceSet_h_
39 
40 #include <Alembic/Util/Export.h>
46 
47 namespace Alembic {
48 namespace AbcGeom {
49 namespace ALEMBIC_VERSION_NS {
50 
51 //-*****************************************************************************
52 
53 // Forward declarations of our friend classes
54 class OSubDSchema;
55 class OPolyMeshSchema;
56 
57 //-*****************************************************************************
58 class ALEMBIC_EXPORT OFaceSetSchema : public OGeomBaseSchema<FaceSetSchemaInfo>
59 {
60 public:
61  //-*************************************************************************
62  // Parition SAMPLE
63  //-*************************************************************************
64  class Sample
65  {
66  public:
67  typedef Sample this_type;
68 
69  //! Creates a default sample with no data in it.
70  //! ...
71  Sample() { reset(); }
72 
73  //! Creates a sample with the list of faces that are in this
74  //! faceset.
75  //! The array of face numbers MUST be ordered by face number.
76  //! Code that reads and works with facesets depends on this for efficency.
77  //! e.g. call std::sort (myVecOfFaces.begin (), myVecOfFaces.end ());
78  //! if you need to.
79  //! The sample must be complete like this. Subsequent samples may also
80  //! consist of faces which allows you to change of topology
81  //! of the faceset.
82  Sample( const Abc::Int32ArraySample &iFaceNums)
83  : m_faces( iFaceNums )
84  {}
85 
86  /* main accessors */
87  // Faces
88  const Abc::Int32ArraySample &getFaces() const { return m_faces; }
89  void setFaces( const Abc::Int32ArraySample &iFaces)
90  { m_faces = iFaces; }
91 
92  // Bounding boxes
93  const Abc::Box3d &getSelfBounds() const { return m_selfBounds; }
94  void setSelfBounds( const Abc::Box3d &iBnds )
95  { m_selfBounds = iBnds; }
96 
97  void reset()
98  {
99  m_faces.reset();
100 
101  m_selfBounds.makeEmpty();
102  }
103 
104  protected:
106 
107  // bounds
109  }; // end OFaceSetSchema::Sample
110 
111 
112  //-*************************************************************************
113  // FaceSet SCHEMA
114  //-*************************************************************************
115 public:
116  //! By convention we always define this_type in AbcGeom classes.
117  //! Used by unspecified-bool-type conversion below
119 
120  //-*************************************************************************
121  // CONSTRUCTION, DESTRUCTION, ASSIGNMENT
122  //-*************************************************************************
123  //! The default constructor creates an empty OFaceSetSchema.
124  //! OFaceSetSchema instances created this evaluate to a boolean value of false.
126 
127  //! This templated, primary constructor creates a new faceset writer.
128  //! The first argument is any Abc (or AbcCoreAbstract) object
129  //! which can intrusively be converted to an CompoundPropertyWriterPtr
130  //! to use as a parent, from which the error handler policy for
131  //! inheritance is also derived. The remaining optional arguments
132  //! can be used to override the ErrorHandlerPolicy, to specify
133  //! MetaData, and to set TimeSamplingType.
134  //! Most typically you won't need to use this ctor because the
135  //! name argument here is only needed if you need to specially
136  //! override the name of the compound property used internally
137  //! by Alembic (for example if you needed to created your
138  //! own dervied class from OFaceSet that needed to hold multiple
139  //! faceset schema compound properties)
140  template <class CPROP_PTR>
141  OFaceSetSchema( CPROP_PTR iParentCompound,
142  const std::string &iName,
143  const Abc::Argument &iArg0 = Abc::Argument(),
144  const Abc::Argument &iArg1 = Abc::Argument(),
145  const Abc::Argument &iArg2 = Abc::Argument() )
146  : OGeomBaseSchema<FaceSetSchemaInfo>(
147  GetCompoundPropertyWriterPtr( iParentCompound ),
148  iName, iArg0, iArg1, iArg2 )
149  {
150  _initTimeSampling ( GetCompoundPropertyWriterPtr( iParentCompound ),
151  iArg0, iArg1, iArg2 );
152  }
153 
154  template <class CPROP_PTR>
155  void _initTimeSampling ( CPROP_PTR iParentCompound,
156  const Abc::Argument &iArg0 = Abc::Argument(),
157  const Abc::Argument &iArg1 = Abc::Argument(),
158  const Abc::Argument &iArg2 = Abc::Argument() )
159  {
160  AbcA::TimeSamplingPtr tsPtr =
161  Abc::GetTimeSampling( iArg0, iArg1, iArg2 );
162  uint32_t timeSamplingID =
163  Abc::GetTimeSamplingIndex( iArg0, iArg1, iArg2 );
164 
165  // Add or find the timeSamplingID to use for our properties.
166  if (tsPtr)
167  {
168  timeSamplingID = iParentCompound->getObject()->getArchive(
169  )->addTimeSampling(*tsPtr);
170  }
171 
172  // Meta data and error handling are eaten up by
173  // the super type, so all that's left is time sampling.
174  init( timeSamplingID );
175  }
176 
177  template <class CPROP_PTR>
178  explicit OFaceSetSchema( CPROP_PTR iParentCompound,
179  const Abc::Argument &iArg0 = Abc::Argument(),
180  const Abc::Argument &iArg1 = Abc::Argument(),
181  const Abc::Argument &iArg2 = Abc::Argument() )
182  : OGeomBaseSchema<FaceSetSchemaInfo>(
183  GetCompoundPropertyWriterPtr( iParentCompound ),
184  iArg0, iArg1, iArg2 )
185  {
186  _initTimeSampling ( GetCompoundPropertyWriterPtr( iParentCompound ),
187  iArg0, iArg1, iArg2 );
188  }
189 
190  //! Copy constructor.
192  : OGeomBaseSchema<FaceSetSchemaInfo>()
193  {
194  *this = iCopy;
195  }
196 
197  //! Default assignment operator used.
198 
199  //-*************************************************************************
200  // SCHEMA STUFF
201  //-*************************************************************************
202 
203  //-*************************************************************************
204  // SAMPLE STUFF
205  //-*************************************************************************
206 
207  //! Get number of samples written so far.
208  //! ...
209  size_t getNumSamples() const
210  { return m_facesProperty.getNumSamples(); }
211 
212  //! Set a sample! First sample must have the list of faces in the faceset.
213  void set( const Sample &iSamp );
214 
215  void setTimeSampling( uint32_t iTimeSamplingID );
216  void setTimeSampling( AbcA::TimeSamplingPtr iTime );
217 
218  void setFaceExclusivity( FaceSetExclusivity iFacesExclusive );
219  FaceSetExclusivity getFaceExclusivity() { return m_facesExclusive; }
220  //-*************************************************************************
221  // ABC BASE MECHANISMS
222  // These functions are used by Abc to deal with errors, validity,
223  // and so on.
224  //-*************************************************************************
225 
226  //! Reset returns this function set to an empty, default
227  //! state.
228  void reset()
229  {
230  m_facesProperty.reset();
231 
233  }
234 
235  //! Valid returns whether this instance holds real data.
236  bool valid() const
237  {
239  m_facesProperty.valid()
240  );
241  }
242 
243  //! unspecified-bool-type operator overload.
244  //! ...
246 
247 protected:
248  void _recordExclusivityHint();
249 
250  void init( uint32_t iTimeSamplingID );
251 
253 
256 
257  friend class OSubDSchema;
258  friend class OPolyMeshSchema;
259 };
260 
261 
262 //-*****************************************************************************
263 // Nice to use typedef for users of this class.
264 //-*****************************************************************************
266 
267 typedef Util::shared_ptr< OFaceSet > OFaceSetPtr;
268 
270  const Int32ArraySample & meshFaceCounts,
271  const Int32ArraySample & vertexIndices,
272  const P3fArraySample & meshP);
273 
274 } // End namespace ALEMBIC_VERSION_NS
275 
276 using namespace ALEMBIC_VERSION_NS;
277 
278 } // End namespace AbcGeom
279 } // End namespace Alembic
280 
281 #endif
bool valid() const
Valid returns whether this instance holds real data.
Definition: OFaceSet.h:236
Abc::OSchemaObject< OFaceSetSchema > OFaceSet
Definition: OFaceSet.h:265
Abc::Box3d computeBoundsFromPositionsByFaces(const Int32ArraySample &faces, const Int32ArraySample &meshFaceCounts, const Int32ArraySample &vertexIndices, const P3fArraySample &meshP)
GLsizei const GLchar *const * string
Definition: glcorearb.h:813
OFaceSetSchema(CPROP_PTR iParentCompound, const std::string &iName, const Abc::Argument &iArg0=Abc::Argument(), const Abc::Argument &iArg1=Abc::Argument(), const Abc::Argument &iArg2=Abc::Argument())
Definition: OFaceSet.h:141
FaceSetExclusivity
Hint to indicate face membership is mutally exclusive. Some structures that group faces only allow a ...
size_t getNumSamples() const
Default assignment operator used.
Definition: OFaceSet.h:209
Alembic::Util::shared_ptr< TimeSampling > TimeSamplingPtr
Definition: TimeSampling.h:137
const Abc::Int32ArraySample & getFaces() const
Definition: OFaceSet.h:88
void _initTimeSampling(CPROP_PTR iParentCompound, const Abc::Argument &iArg0=Abc::Argument(), const Abc::Argument &iArg1=Abc::Argument(), const Abc::Argument &iArg2=Abc::Argument())
Definition: OFaceSet.h:155
OFaceSetSchema(const OFaceSetSchema &iCopy)
Copy constructor.
Definition: OFaceSet.h:191
#define ALEMBIC_OVERRIDE_OPERATOR_BOOL(PASS_COND)
Definition: OperatorBool.h:56
void setFaces(const Abc::Int32ArraySample &iFaces)
Definition: OFaceSet.h:89
Box< V3d > Box3d
Definition: ImathBox.h:139
AbcA::TimeSamplingPtr GetTimeSampling(const Argument &iArg0, const Argument &iArg1=Argument(), const Argument &iArg2=Argument())
Definition: Argument.h:259
Util::shared_ptr< OFaceSet > OFaceSetPtr
Definition: OFaceSet.h:267
OFaceSetSchema(CPROP_PTR iParentCompound, const Abc::Argument &iArg0=Abc::Argument(), const Abc::Argument &iArg1=Abc::Argument(), const Abc::Argument &iArg2=Abc::Argument())
Definition: OFaceSet.h:178
AbcA::CompoundPropertyWriterPtr GetCompoundPropertyWriterPtr(AbcA::CompoundPropertyWriterPtr iPtr)
Definition: Foundation.h:164
Sample(const Abc::Int32ArraySample &iFaceNums)
Definition: OFaceSet.h:82
#define ALEMBIC_EXPORT
Definition: Export.h:51
uint32_t GetTimeSamplingIndex(const Argument &iArg0, const Argument &iArg1=Argument(), const Argument &iArg2=Argument())
Definition: Argument.h:272
#define ALEMBIC_VERSION_NS
Definition: Foundation.h:104