Alembic Version 1.1
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
47namespace Alembic {
48namespace AbcGeom {
49namespace ALEMBIC_VERSION_NS {
50
51//-*****************************************************************************
52class ALEMBIC_EXPORT ISubDSchema : public IGeomBaseSchema<SubDSchemaInfo>
53{
54public:
55 //-*************************************************************************
56 // SUBD SCHEMA SAMPLE TYPE
57 //-*************************************************************************
58 class Sample
59 {
60 public:
62
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
102 std::string getSubdivisionScheme() const
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
141
142 protected:
143 friend class ISubDSchema;
144
149
153
154 // Creases
158
159 // Corners
162
163 // Holes
165
166 // subdivision scheme
167 std::string m_subdScheme;
168
169 // bounds
170 Abc::Box3d m_selfBounds;
171
172 }; // end ISubDSchema::Sample
173
174 //-*************************************************************************
175 // SUBD SCHEMA
176 //-*************************************************************************
177public:
181
182 //-*************************************************************************
183 // CONSTRUCTION, DESTRUCTION, ASSIGNMENT
184 //-*************************************************************************
185
189 {
190 m_faceSetsLoaded = false;
191 }
192
200 const std::string &iName,
201
202 const Abc::Argument &iArg0 = Abc::Argument(),
203 const Abc::Argument &iArg1 = Abc::Argument() )
204 : IGeomBaseSchema<SubDSchemaInfo>( iParent, iName, iArg0, iArg1 )
205 {
206 init( iArg0, iArg1 );
207 }
208
214 const Abc::Argument &iArg0 = Abc::Argument(),
215 const Abc::Argument &iArg1 = Abc::Argument() )
216 : IGeomBaseSchema<SubDSchemaInfo>( iProp, iArg0, iArg1 )
217 {
218 init( iArg0, iArg1 );
219 }
220
222
223 //-*************************************************************************
224 // SCHEMA STUFF
225 //-*************************************************************************
226
227
229
231 bool isConstant() const { return getTopologyVariance() == kConstantTopology; }
232
233 //-*************************************************************************
234 // SAMPLE STUFF
235 //-*************************************************************************
236
239 size_t getNumSamples() const;
240
243 {
244 if ( m_positionsProperty.valid() )
245 {
246 return m_positionsProperty.getTimeSampling();
247 }
248 else
249 {
250 return getObject().getArchive().getTimeSampling( 0 );
251 }
252 }
253
254 void get( Sample &iSamp,
255 const Abc::ISampleSelector &iSS = Abc::ISampleSelector() ) const;
256
258 {
259 Sample smp;
260 get( smp, iSS );
261 return smp;
262 }
263
265 { return m_faceCountsProperty; }
267 { return m_faceIndicesProperty; }
269 { return m_positionsProperty; }
270
272 { return m_faceVaryingInterpolateBoundaryProperty; }
273
275 { return m_faceVaryingPropagateCornersProperty; }
276
278 { return m_interpolateBoundaryProperty; }
279
281 { return m_creaseIndicesProperty; }
283 { return m_creaseLengthsProperty; }
285 { return m_creaseSharpnessesProperty; }
286
288 { return m_cornerIndicesProperty; }
290 { return m_cornerSharpnessesProperty; }
291
292 Abc::IInt32ArrayProperty getHolesProperty() const { return m_holesProperty; }
293
295 { return m_subdSchemeProperty; }
296
298 { return m_velocitiesProperty; }
299
301 {
302 return m_uvsParam;
303 }
304
305 //-*************************************************************************
306 // ABC BASE MECHANISMS
307 // These functions are used by Abc to deal with errors, rewrapping,
308 // and so on.
309 //-*************************************************************************
310
313 void reset()
314 {
315 m_positionsProperty.reset();
316 m_velocitiesProperty.reset();
317 m_faceIndicesProperty.reset();
318 m_faceCountsProperty.reset();
319
320 m_faceVaryingInterpolateBoundaryProperty.reset();
321 m_faceVaryingPropagateCornersProperty.reset();
322 m_interpolateBoundaryProperty.reset();
323
324 m_creaseIndicesProperty.reset();
325 m_creaseLengthsProperty.reset();
326 m_creaseSharpnessesProperty.reset();
327
328 m_cornerIndicesProperty.reset();
329 m_cornerSharpnessesProperty.reset();
330
331 m_holesProperty.reset();
332
333 m_subdSchemeProperty.reset();
334
335 m_uvsParam.reset();
336
338 }
339
342 bool valid() const
343 {
345 m_positionsProperty.valid() &&
346 m_faceIndicesProperty.valid() &&
347 m_faceCountsProperty.valid() );
348 }
349
350 // FaceSet related
352 void getFaceSetNames( std::vector <std::string> &oFaceSetNames );
353 IFaceSet getFaceSet( const std::string &iFaceSetName );
354 bool hasFaceSet( const std::string &iFaceSetName );
355
359
360 // Copy constructors
362 : IGeomBaseSchema<SubDSchemaInfo>()
363 {
364 *this = iCopy;
365 }
366 const ISubDSchema & operator=(const ISubDSchema & rhs);
367
368protected:
369 void init( const Abc::Argument &iArg0, const Abc::Argument &iArg1 );
370
374
375 // misc
379
380 // Creases
384
385 // Corners
388
389 // Holes
391
392 // subdivision scheme
394
395 // UVs
397
399
400 // FaceSets, this starts as empty until client
401 // code attempts to access facesets.
403 std::map <std::string, IFaceSet> m_faceSets;
406
407};
408
409//-*****************************************************************************
410// SCHEMA OBJECT
411//-*****************************************************************************
413
414typedef Util::shared_ptr< ISubD > ISubDPtr;
415
416} // End namespace ALEMBIC_VERSION_NS
417
418using namespace ALEMBIC_VERSION_NS;
419
420} // End namespace AbcGeom
421} // End namespace Alembic
422
423#endif
#define ALEMBIC_EXPORT
Definition: Export.h:51
#define ALEMBIC_VERSION_NS
Definition: Foundation.h:105
Abc::V3fArraySamplePtr getVelocities() const
Definition: ISubD.h:105
Abc::FloatArraySamplePtr getCreaseSharpnesses() const
Definition: ISubD.h:88
Abc::FloatArraySamplePtr getCornerSharpnesses() const
Definition: ISubD.h:95
Abc::Int32ArraySamplePtr getFaceCounts() const
Definition: ISubD.h:69
Abc::Int32ArraySamplePtr getCornerIndices() const
Definition: ISubD.h:92
Abc::Int32ArraySamplePtr getCreaseIndices() const
Definition: ISubD.h:82
Abc::P3fArraySamplePtr getPositions() const
Definition: ISubD.h:67
Sample()
Users never create this data directly.
Definition: ISubD.h:64
Abc::Int32ArraySamplePtr getHoles() const
Definition: ISubD.h:99
Abc::Int32ArraySamplePtr getFaceIndices() const
Definition: ISubD.h:68
Abc::Int32ArraySamplePtr getCreaseLengths() const
Definition: ISubD.h:85
Abc::IFloatArrayProperty getCreaseSharpnessesProperty() const
Definition: ISubD.h:284
Sample getValue(const Abc::ISampleSelector &iSS=Abc::ISampleSelector()) const
Definition: ISubD.h:257
Abc::IInt32Property getFaceVaryingInterpolateBoundaryProperty() const
Definition: ISubD.h:271
bool isConstant() const
if isConstant() is true, the mesh contains no time-varying values
Definition: ISubD.h:231
Abc::IInt32ArrayProperty getCreaseIndicesProperty() const
Definition: ISubD.h:280
Abc::IInt32ArrayProperty getCreaseLengthsProperty() const
Definition: ISubD.h:282
Abc::IInt32Property getInterpolateBoundaryProperty() const
Definition: ISubD.h:277
Abc::IInt32ArrayProperty m_creaseIndicesProperty
Definition: ISubD.h:381
Abc::IInt32ArrayProperty m_holesProperty
Definition: ISubD.h:390
Abc::IFloatArrayProperty m_cornerSharpnessesProperty
Definition: ISubD.h:387
Abc::IInt32ArrayProperty getFaceCountsProperty() const
Definition: ISubD.h:264
Abc::IP3fArrayProperty m_positionsProperty
Definition: ISubD.h:371
Abc::IFloatArrayProperty getCornerSharpnessesProperty() const
Definition: ISubD.h:289
Abc::IInt32ArrayProperty getHolesProperty() const
Definition: ISubD.h:292
Abc::IInt32Property m_interpolateBoundaryProperty
Definition: ISubD.h:378
Abc::IInt32Property m_faceVaryingPropagateCornersProperty
Definition: ISubD.h:377
void getFaceSetNames(std::vector< std::string > &oFaceSetNames)
Appends the names of any FaceSets for this SubD.
bool hasFaceSet(const std::string &iFaceSetName)
ISubDSchema(const ICompoundProperty &iProp, const Abc::Argument &iArg0=Abc::Argument(), const Abc::Argument &iArg1=Abc::Argument())
Definition: ISubD.h:213
IFaceSet getFaceSet(const std::string &iFaceSetName)
ISubDSchema(const ISubDSchema &iCopy)
Definition: ISubD.h:361
Abc::IP3fArrayProperty getPositionsProperty() const
Definition: ISubD.h:268
void init(const Abc::Argument &iArg0, const Abc::Argument &iArg1)
Abc::IInt32ArrayProperty m_cornerIndicesProperty
Definition: ISubD.h:386
Abc::IInt32Property getFaceVaryingPropagateCornersProperty() const
Definition: ISubD.h:274
AbcA::TimeSamplingPtr getTimeSampling() const
Return the time sampling.
Definition: ISubD.h:242
Abc::IInt32Property m_faceVaryingInterpolateBoundaryProperty
Definition: ISubD.h:376
Abc::IInt32ArrayProperty m_creaseLengthsProperty
Definition: ISubD.h:382
Abc::IInt32ArrayProperty getFaceIndicesProperty() const
Definition: ISubD.h:266
Abc::IInt32ArrayProperty m_faceCountsProperty
Definition: ISubD.h:373
ISubDSchema(const ICompoundProperty &iParent, const std::string &iName, const Abc::Argument &iArg0=Abc::Argument(), const Abc::Argument &iArg1=Abc::Argument())
Definition: ISubD.h:199
std::map< std::string, IFaceSet > m_faceSets
Definition: ISubD.h:403
const ISubDSchema & operator=(const ISubDSchema &rhs)
Abc::IFloatArrayProperty m_creaseSharpnessesProperty
Definition: ISubD.h:383
MeshTopologyVariance getTopologyVariance() const
Default assignment operator used.
Abc::IV3fArrayProperty getVelocitiesProperty() const
Definition: ISubD.h:297
void get(Sample &iSamp, const Abc::ISampleSelector &iSS=Abc::ISampleSelector()) const
Abc::IInt32ArrayProperty m_faceIndicesProperty
Definition: ISubD.h:372
Abc::IStringProperty getSubdivisionSchemeProperty() const
Definition: ISubD.h:294
Abc::IInt32ArrayProperty getCornerIndicesProperty() const
Definition: ISubD.h:287
Alembic::Util::shared_ptr< TimeSampling > TimeSamplingPtr
Definition: TimeSampling.h:137
Util::shared_ptr< ISubD > ISubDPtr
Definition: ISubD.h:414
Abc::ISchemaObject< ISubDSchema > ISubD
Definition: ISubD.h:412
Alembic::Util::shared_ptr< FloatArraySample > FloatArraySamplePtr
Alembic::Util::shared_ptr< Int32ArraySample > Int32ArraySamplePtr
Alembic::Util::shared_ptr< V3fArraySample > V3fArraySamplePtr
Alembic::Util::shared_ptr< P3fArraySample > P3fArraySamplePtr
Alembic namespace ...
Definition: ArchiveInfo.h:46