HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ISubD.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_ISubD_h_
38 #define _Alembic_AbcGeom_ISubD_h_
39 
40 #include <Alembic/Util/Export.h>
46 
47 namespace Alembic {
48 namespace AbcGeom {
49 namespace ALEMBIC_VERSION_NS {
50 
51 //-*****************************************************************************
52 class ALEMBIC_EXPORT ISubDSchema : public IGeomBaseSchema<SubDSchemaInfo>
53 {
54 public:
55  //-*************************************************************************
56  // SUBD SCHEMA SAMPLE TYPE
57  //-*************************************************************************
58  class Sample
59  {
60  public:
61  typedef Sample this_type;
62 
63  //! Users never create this data directly
64  Sample() { reset(); }
65 
66  // main stuff
67  Abc::P3fArraySamplePtr getPositions() const { return m_positions; }
68  Abc::Int32ArraySamplePtr getFaceIndices() const { return m_faceIndices; }
69  Abc::Int32ArraySamplePtr getFaceCounts() const { return m_faceCounts; }
70 
71  // misc subd stuff
73  { return m_faceVaryingInterpolateBoundary; }
74 
76  { return m_faceVaryingPropagateCorners; }
77 
78  int32_t getInterpolateBoundary() const
79  { return m_interpolateBoundary; }
80 
81  // creases
83  { return m_creaseIndices; }
84 
86  { return m_creaseLengths; }
87 
89  { return m_creaseSharpnesses; }
90 
91  // corners
93  { return m_cornerIndices; }
94 
96  { return m_cornerSharpnesses; }
97 
98  // Holes
99  Abc::Int32ArraySamplePtr getHoles() const { return m_holes; }
100 
101  // subdivision scheme
103  { return m_subdScheme; }
104 
105  Abc::V3fArraySamplePtr getVelocities() const { return m_velocities; }
106 
107  // bounds
108  Abc::Box3d getSelfBounds() const { return m_selfBounds; }
109 
110  bool valid() const
111  {
112  return m_positions && m_faceIndices && m_faceCounts;
113  }
114 
115  void reset()
116  {
117  m_positions.reset();
118  m_velocities.reset();
119  m_faceIndices.reset();
120  m_faceCounts.reset();
121 
122  m_faceVaryingInterpolateBoundary = 0;
123  m_faceVaryingPropagateCorners = 0;
124  m_interpolateBoundary = 0;
125 
126  m_creaseIndices.reset();
127  m_creaseLengths.reset();
128  m_creaseSharpnesses.reset();
129 
130  m_cornerIndices.reset();
131  m_cornerSharpnesses.reset();
132 
133  m_holes.reset();
134 
135  m_subdScheme = "catmull-clark";
136 
137  m_selfBounds.makeEmpty();
138  }
139 
140  ALEMBIC_OPERATOR_BOOL( valid() );
141 
142  protected:
143  friend class ISubDSchema;
144 
149 
153 
154  // Creases
158 
159  // Corners
162 
163  // Holes
165 
166  // subdivision scheme
168 
169  // bounds
171 
172  }; // end ISubDSchema::Sample
173 
174  //-*************************************************************************
175  // SUBD SCHEMA
176  //-*************************************************************************
177 public:
178  //! By convention we always define this_type in AbcGeom classes.
179  //! Used by unspecified-bool-type conversion below
181 
182  //-*************************************************************************
183  // CONSTRUCTION, DESTRUCTION, ASSIGNMENT
184  //-*************************************************************************
185 
186  //! The default constructor creates an empty ISubDSchema
187  //! ...
189 
190  //! This templated, primary constructor creates a new subd reader.
191  //! The first argument is any Abc (or AbcCoreAbstract) object
192  //! which can intrusively be converted to an CompoundPropertyWriterPtr
193  //! to use as a parent, from which the error handler policy for
194  //! inheritance is also derived. The remaining optional arguments
195  //! can be used to override the ErrorHandlerPolicy and to specify
196  //! schema interpretation matching.
197  template <class CPROP_PTR>
198  ISubDSchema( CPROP_PTR iParent,
199  const std::string &iName,
200 
201  const Abc::Argument &iArg0 = Abc::Argument(),
202  const Abc::Argument &iArg1 = Abc::Argument() )
203  : IGeomBaseSchema<SubDSchemaInfo>( iParent, iName,
204  iArg0, iArg1 )
205  {
206  init( iArg0, iArg1 );
207  }
208 
209  //! Same constructor as above, but use the default schema name, ie,
210  //! ".geom".
211  template <class CPROP_PTR>
212  explicit ISubDSchema( CPROP_PTR iParent,
213  const Abc::Argument &iArg0 = Abc::Argument(),
214  const Abc::Argument &iArg1 = Abc::Argument() )
215  : IGeomBaseSchema<SubDSchemaInfo>( iParent,
216  iArg0, iArg1 )
217  {
218  init( iArg0, iArg1 );
219  }
220 
221  //! wrap an existing schema object
222  template <class CPROP_PTR>
223  ISubDSchema( CPROP_PTR iThis,
224  Abc::WrapExistingFlag iFlag,
225 
226  const Abc::Argument &iArg0 = Abc::Argument(),
227  const Abc::Argument &iArg1 = Abc::Argument() )
228  : IGeomBaseSchema<SubDSchemaInfo>( iThis, iFlag, iArg0, iArg1 )
229  {
230  init( iArg0, iArg1 );
231  }
232 
233 
234  //! Default assignment operator used.
235 
236  //-*************************************************************************
237  // SCHEMA STUFF
238  //-*************************************************************************
239 
240 
241  MeshTopologyVariance getTopologyVariance() const;
242 
243  //! if isConstant() is true, the mesh contains no time-varying values
244  bool isConstant() const { return getTopologyVariance() == kConstantTopology; }
245 
246  //-*************************************************************************
247  // SAMPLE STUFF
248  //-*************************************************************************
249 
250  //! Get number of samples written so far.
251  //! ...
252  size_t getNumSamples() const;
253 
254  //! Return the time sampling
256  {
257  if ( m_positionsProperty.valid() )
258  {
259  return m_positionsProperty.getTimeSampling();
260  }
261  else
262  {
263  return getObject().getArchive().getTimeSampling( 0 );
264  }
265  }
266 
267  void get( Sample &iSamp,
268  const Abc::ISampleSelector &iSS = Abc::ISampleSelector() ) const;
269 
271  {
272  Sample smp;
273  get( smp, iSS );
274  return smp;
275  }
276 
278  { return m_faceCountsProperty; }
280  { return m_faceIndicesProperty; }
282  { return m_positionsProperty; }
283 
285  { return m_faceVaryingInterpolateBoundaryProperty; }
286 
288  { return m_faceVaryingPropagateCornersProperty; }
289 
291  { return m_interpolateBoundaryProperty; }
292 
294  { return m_creaseIndicesProperty; }
296  { return m_creaseLengthsProperty; }
298  { return m_creaseSharpnessesProperty; }
299 
301  { return m_cornerIndicesProperty; }
303  { return m_cornerSharpnessesProperty; }
304 
305  Abc::IInt32ArrayProperty getHolesProperty() const { return m_holesProperty; }
306 
308  { return m_subdSchemeProperty; }
309 
311  { return m_velocitiesProperty; }
312 
314  {
315  return m_uvsParam;
316  }
317 
318  //-*************************************************************************
319  // ABC BASE MECHANISMS
320  // These functions are used by Abc to deal with errors, rewrapping,
321  // and so on.
322  //-*************************************************************************
323 
324  //! Reset returns this function set to an empty, default
325  //! state.
326  void reset()
327  {
328  m_positionsProperty.reset();
329  m_velocitiesProperty.reset();
330  m_faceIndicesProperty.reset();
331  m_faceCountsProperty.reset();
332 
333  m_faceVaryingInterpolateBoundaryProperty.reset();
334  m_faceVaryingPropagateCornersProperty.reset();
335  m_interpolateBoundaryProperty.reset();
336 
337  m_creaseIndicesProperty.reset();
338  m_creaseLengthsProperty.reset();
339  m_creaseSharpnessesProperty.reset();
340 
341  m_cornerIndicesProperty.reset();
342  m_cornerSharpnessesProperty.reset();
343 
344  m_holesProperty.reset();
345 
346  m_subdSchemeProperty.reset();
347 
348  m_uvsParam.reset();
349 
351  }
352 
353  //! Valid returns whether this function set is
354  //! valid.
355  bool valid() const
356  {
358  m_positionsProperty.valid() &&
359  m_faceIndicesProperty.valid() &&
360  m_faceCountsProperty.valid() );
361  }
362 
363  // FaceSet related
364  //! Appends the names of any FaceSets for this SubD.
365  void getFaceSetNames( std::vector <std::string> &oFaceSetNames );
366  IFaceSet getFaceSet( const std::string &iFaceSetName );
367  bool hasFaceSet( const std::string &iFaceSetName );
368 
369  //! unspecified-bool-type operator overload.
370  //! ...
372 
373  // Copy constructors
374  ISubDSchema(const ISubDSchema& iCopy)
375  : IGeomBaseSchema<SubDSchemaInfo>()
376  {
377  *this = iCopy;
378  }
379  const ISubDSchema & operator=(const ISubDSchema & rhs);
380 
381 protected:
382  void init( const Abc::Argument &iArg0, const Abc::Argument &iArg1 );
383 
387 
388  // misc
392 
393  // Creases
397 
398  // Corners
401 
402  // Holes
404 
405  // subdivision scheme
407 
408  // UVs
410 
412 
413  // FaceSets, this starts as empty until client
414  // code attempts to access facesets.
416  std::map <std::string, IFaceSet> m_faceSets;
418  void loadFaceSetNames();
419 
420 };
421 
422 //-*****************************************************************************
423 // SCHEMA OBJECT
424 //-*****************************************************************************
426 
427 typedef Util::shared_ptr< ISubD > ISubDPtr;
428 
429 } // End namespace ALEMBIC_VERSION_NS
430 
431 using namespace ALEMBIC_VERSION_NS;
432 
433 } // End namespace AbcGeom
434 } // End namespace Alembic
435 
436 #endif
#define ALEMBIC_OPERATOR_BOOL(PASS_COND)
Definition: OperatorBool.h:42
Abc::IInt32Property getFaceVaryingPropagateCornersProperty() const
Definition: ISubD.h:287
Abc::Int32ArraySamplePtr getFaceCounts() const
Definition: ISubD.h:69
Alembic::Util::shared_ptr< Int32ArraySample > Int32ArraySamplePtr
Abc::Int32ArraySamplePtr getHoles() const
Definition: ISubD.h:99
Abc::IP3fArrayProperty m_positionsProperty
Definition: ISubD.h:384
Alembic::Util::shared_ptr< V3fArraySample > V3fArraySamplePtr
Sample()
Users never create this data directly.
Definition: ISubD.h:64
GLsizei const GLchar *const * string
Definition: glcorearb.h:813
ISubDSchema(const ISubDSchema &iCopy)
Definition: ISubD.h:374
Abc::Int32ArraySamplePtr getCreaseLengths() const
Definition: ISubD.h:85
Abc::IFloatArrayProperty m_cornerSharpnessesProperty
Definition: ISubD.h:400
Abc::IInt32Property m_faceVaryingPropagateCornersProperty
Definition: ISubD.h:390
Abc::IStringProperty getSubdivisionSchemeProperty() const
Definition: ISubD.h:307
ISubDSchema(CPROP_PTR iParent, const Abc::Argument &iArg0=Abc::Argument(), const Abc::Argument &iArg1=Abc::Argument())
Definition: ISubD.h:212
Abc::IInt32ArrayProperty m_creaseIndicesProperty
Definition: ISubD.h:394
Abc::Int32ArraySamplePtr getFaceIndices() const
Definition: ISubD.h:68
Abc::IInt32ArrayProperty m_holesProperty
Definition: ISubD.h:403
Sample getValue(const Abc::ISampleSelector &iSS=Abc::ISampleSelector()) const
Definition: ISubD.h:270
Alembic::Util::shared_ptr< FloatArraySample > FloatArraySamplePtr
Abc::Int32ArraySamplePtr getCreaseIndices() const
Definition: ISubD.h:82
Abc::IInt32Property m_faceVaryingInterpolateBoundaryProperty
Definition: ISubD.h:389
Abc::FloatArraySamplePtr getCreaseSharpnesses() const
Definition: ISubD.h:88
Util::shared_ptr< ISubD > ISubDPtr
Definition: ISubD.h:427
ISubDSchema(CPROP_PTR iParent, const std::string &iName, const Abc::Argument &iArg0=Abc::Argument(), const Abc::Argument &iArg1=Abc::Argument())
Definition: ISubD.h:198
ISubDSchema(CPROP_PTR iThis, Abc::WrapExistingFlag iFlag, const Abc::Argument &iArg0=Abc::Argument(), const Abc::Argument &iArg1=Abc::Argument())
wrap an existing schema object
Definition: ISubD.h:223
Abc::V3fArraySamplePtr getVelocities() const
Definition: ISubD.h:105
Abc::IInt32ArrayProperty getHolesProperty() const
Definition: ISubD.h:305
Alembic::Util::shared_ptr< TimeSampling > TimeSamplingPtr
Definition: TimeSampling.h:137
Abc::IInt32ArrayProperty getCornerIndicesProperty() const
Definition: ISubD.h:300
Abc::IV3fArrayProperty getVelocitiesProperty() const
Definition: ISubD.h:310
Abc::IFloatArrayProperty m_creaseSharpnessesProperty
Definition: ISubD.h:396
#define ALEMBIC_OVERRIDE_OPERATOR_BOOL(PASS_COND)
Definition: OperatorBool.h:56
Abc::ISchemaObject< ISubDSchema > ISubD
Definition: ISubD.h:425
Abc::IInt32Property m_interpolateBoundaryProperty
Definition: ISubD.h:391
Abc::IInt32Property getInterpolateBoundaryProperty() const
Definition: ISubD.h:290
Abc::IInt32ArrayProperty m_cornerIndicesProperty
Definition: ISubD.h:399
Abc::IInt32ArrayProperty getCreaseLengthsProperty() const
Definition: ISubD.h:295
AbcA::TimeSamplingPtr getTimeSampling() const
Return the time sampling.
Definition: ISubD.h:255
Abc::IInt32ArrayProperty m_creaseLengthsProperty
Definition: ISubD.h:395
Abc::IInt32ArrayProperty m_faceIndicesProperty
Definition: ISubD.h:385
Box< V3d > Box3d
Definition: ImathBox.h:139
Abc::P3fArraySamplePtr getPositions() const
Definition: ISubD.h:67
Abc::IInt32ArrayProperty getCreaseIndicesProperty() const
Definition: ISubD.h:293
Abc::FloatArraySamplePtr getCornerSharpnesses() const
Definition: ISubD.h:95
Abc::IP3fArrayProperty getPositionsProperty() const
Definition: ISubD.h:281
Abc::IFloatArrayProperty getCornerSharpnessesProperty() const
Definition: ISubD.h:302
Abc::IInt32ArrayProperty getFaceIndicesProperty() const
Definition: ISubD.h:279
bool isConstant() const
if isConstant() is true, the mesh contains no time-varying values
Definition: ISubD.h:244
Abc::IInt32ArrayProperty getFaceCountsProperty() const
Definition: ISubD.h:277
ITypedArrayProperty< V3fTPTraits > IV3fArrayProperty
Abc::IFloatArrayProperty getCreaseSharpnessesProperty() const
Definition: ISubD.h:297
#define ALEMBIC_EXPORT
Definition: Export.h:51
std::map< std::string, IFaceSet > m_faceSets
Definition: ISubD.h:416
Abc::Int32ArraySamplePtr getCornerIndices() const
Definition: ISubD.h:92
Abc::IInt32ArrayProperty m_faceCountsProperty
Definition: ISubD.h:386
Abc::IInt32Property getFaceVaryingInterpolateBoundaryProperty() const
Definition: ISubD.h:284
Alembic::Util::shared_ptr< P3fArraySample > P3fArraySamplePtr
#define ALEMBIC_VERSION_NS
Definition: Foundation.h:104