Alembic Version 1.1

IPolyMesh.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_IPolyMesh_h
38#define Alembic_AbcGeom_IPolyMesh_h
39
40#include <Alembic/Util/Export.h>
41#include <Alembic/AbcGeom/Foundation.h>
42#include <Alembic/AbcGeom/SchemaInfoDeclarations.h>
43#include <Alembic/AbcGeom/IFaceSet.h>
44#include <Alembic/AbcGeom/IGeomParam.h>
45#include <Alembic/AbcGeom/IGeomBase.h>
46
47 namespace Alembic {
48 namespace AbcGeom {
49 namespace ALEMBIC_VERSION_NS {
50
51//-*****************************************************************************
52 class ALEMBIC_EXPORT IPolyMeshSchema
53 : public IGeomBaseSchema<PolyMeshSchemaInfo>
54{
55 public:
56 class Sample
57 {
58 public:
59 typedef Sample this_type;
60
61 // Users don't ever create this data directly.
62 Sample() { reset(); }
63
64 Abc::P3fArraySamplePtr getPositions() const { return m_positions; }
65 Abc::V3fArraySamplePtr getVelocities() const { return m_velocities; }
66 Abc::Int32ArraySamplePtr getFaceIndices() const { return m_indices; }
67 Abc::Int32ArraySamplePtr getFaceCounts() const { return m_counts; }
68 Abc::Box3d getSelfBounds() const { return m_selfBounds; }
69
70 bool valid() const
71 {
72 return m_positions && m_indices && m_counts;
73 }
74
75 void reset()
76 {
77 m_positions.reset();
78 m_velocities.reset();
79 m_indices.reset();
80 m_counts.reset();
81 m_selfBounds.makeEmpty();
82 }
83
84 ALEMBIC_OPERATOR_BOOL( valid() );
85
86 protected:
87 friend class IPolyMeshSchema;
88 Abc::P3fArraySamplePtr m_positions;
89 Abc::V3fArraySamplePtr m_velocities;
90 Abc::Int32ArraySamplePtr m_indices;
91 Abc::Int32ArraySamplePtr m_counts;
92 Abc::Box3d m_selfBounds;
93 };
94
95 //-*************************************************************************
96 // POLY MESH SCHEMA
97 //-*************************************************************************
98 public:
101 typedef IPolyMeshSchema this_type;
102
103 //-*************************************************************************
104 // CONSTRUCTION, DESTRUCTION, ASSIGNMENT
105 //-*************************************************************************
106
109 IPolyMeshSchema() {}
110
117 IPolyMeshSchema( const ICompoundProperty &iParent,
118 const std::string &iName,
119
120 const Abc::Argument &iArg0 = Abc::Argument(),
121 const Abc::Argument &iArg1 = Abc::Argument() )
122 : IGeomBaseSchema<PolyMeshSchemaInfo>( iParent, iName, iArg0, iArg1 )
123 {
124 init( iArg0, iArg1 );
125 }
126
131 IPolyMeshSchema( const ICompoundProperty &iProp,
132 const Abc::Argument &iArg0 = Abc::Argument(),
133 const Abc::Argument &iArg1 = Abc::Argument() )
134 : IGeomBaseSchema<PolyMeshSchemaInfo>( iProp, iArg0, iArg1 )
135 {
136 init( iArg0, iArg1 );
137 }
138
140 IPolyMeshSchema(const IPolyMeshSchema& iCopy)
141 : IGeomBaseSchema<PolyMeshSchemaInfo>()
142 {
143 *this = iCopy;
144 }
145 const IPolyMeshSchema & operator=(const IPolyMeshSchema & rhs);
146
147
152 size_t getNumSamples() const
153 { return m_positionsProperty.getNumSamples(); }
154
157 MeshTopologyVariance getTopologyVariance() const;
158
161 bool isConstant() const { return getTopologyVariance() == kConstantTopology; }
162
166 AbcA::TimeSamplingPtr getTimeSampling() const
167 {
168 if ( m_positionsProperty.valid() )
169 {
170 return m_positionsProperty.getTimeSampling();
171 }
172 else
173 {
174 return getObject().getArchive().getTimeSampling( 0 );
175 }
176 }
177
178 //-*************************************************************************
179 void get( Sample &oSample,
180 const Abc::ISampleSelector &iSS = Abc::ISampleSelector() ) const
181 {
182 ALEMBIC_ABC_SAFE_CALL_BEGIN( "IPolyMeshSchema::get()" );
183
184 m_positionsProperty.get( oSample.m_positions, iSS );
185 m_indicesProperty.get( oSample.m_indices, iSS );
186 m_countsProperty.get( oSample.m_counts, iSS );
187
188 m_selfBoundsProperty.get( oSample.m_selfBounds, iSS );
189
190 if ( m_velocitiesProperty && m_velocitiesProperty.getNumSamples() > 0 )
191 {
192 m_velocitiesProperty.get( oSample.m_velocities, iSS );
193 }
194
195 // Could error check here.
196
197 ALEMBIC_ABC_SAFE_CALL_END();
198 }
199
200 Sample getValue( const Abc::ISampleSelector &iSS = Abc::ISampleSelector() ) const
201 {
202 Sample smp;
203 get( smp, iSS );
204 return smp;
205 }
206
207 IV2fGeomParam getUVsParam() const
208 {
209 return m_uvsParam;
210 }
211
212 IN3fGeomParam getNormalsParam() const
213 {
214 return m_normalsParam;
215 }
216
217 Abc::IInt32ArrayProperty getFaceCountsProperty() const
218 {
219 return m_countsProperty;
220 }
221
222 Abc::IInt32ArrayProperty getFaceIndicesProperty() const
223 {
224 return m_indicesProperty;
225 }
226
227 Abc::IP3fArrayProperty getPositionsProperty() const
228 {
229 return m_positionsProperty;
230 }
231
232 Abc::IV3fArrayProperty getVelocitiesProperty() const
233 {
234 return m_velocitiesProperty;
235 }
236
237 //-*************************************************************************
238 // ABC BASE MECHANISMS
239 // These functions are used by Abc to deal with errors, rewrapping,
240 // and so on.
241 //-*************************************************************************
242
245 void reset()
246 {
247 m_positionsProperty.reset();
248 m_velocitiesProperty.reset();
249 m_indicesProperty.reset();
250 m_countsProperty.reset();
251
252 m_uvsParam.reset();
253 m_normalsParam.reset();
254
255 IGeomBaseSchema<PolyMeshSchemaInfo>::reset();
256 }
257
260 bool valid() const
261 {
262 return ( IGeomBaseSchema<PolyMeshSchemaInfo>::valid() &&
263 m_positionsProperty.valid() &&
264 m_indicesProperty.valid() &&
265 m_countsProperty.valid() );
266 }
267
268 // FaceSet related
270 void getFaceSetNames (std::vector <std::string> & oFaceSetNames);
271 IFaceSet getFaceSet( const std::string &iFaceSetName );
272 bool hasFaceSet( const std::string &iFaceSetName );
273
276 ALEMBIC_OVERRIDE_OPERATOR_BOOL( IPolyMeshSchema::valid() );
277
278 protected:
279 void init( const Abc::Argument &iArg0,
280 const Abc::Argument &iArg1 );
281
282 Abc::IP3fArrayProperty m_positionsProperty;
283 Abc::IV3fArrayProperty m_velocitiesProperty;
284 Abc::IInt32ArrayProperty m_indicesProperty;
285 Abc::IInt32ArrayProperty m_countsProperty;
286
287 IV2fGeomParam m_uvsParam;
288 IN3fGeomParam m_normalsParam;
289
290 // FaceSets, this starts as empty until client
291 // code attempts to access facesets.
292 bool m_faceSetsLoaded;
293 std::map <std::string, IFaceSet> m_faceSets;
294 Alembic::Util::mutex m_faceSetsMutex;
295 void loadFaceSetNames();
296};
297
298//-*****************************************************************************
299 typedef Abc::ISchemaObject<IPolyMeshSchema> IPolyMesh;
300
301 typedef Util::shared_ptr< IPolyMesh > IPolyMeshPtr;
302
303} // End namespace ALEMBIC_VERSION_NS
304
305 using namespace ALEMBIC_VERSION_NS;
306
307} // End namespace AbcGeom
308} // End namespace Alembic
309
310#endif
Foundation.h
SchemaInfoDeclarations.h
ALEMBIC_ABC_SAFE_CALL_END
#define ALEMBIC_ABC_SAFE_CALL_END()
Definition: ErrorHandler.h:198
ALEMBIC_ABC_SAFE_CALL_BEGIN
#define ALEMBIC_ABC_SAFE_CALL_BEGIN(CONTEXT)
Definition: ErrorHandler.h:172
Export.h
ALEMBIC_EXPORT
#define ALEMBIC_EXPORT
Definition: Export.h:51
IFaceSet.h
IGeomBase.h
IGeomParam.h
ALEMBIC_VERSION_NS
#define ALEMBIC_VERSION_NS
Definition: Foundation.h:105
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IGeomBaseSchema
Definition: IGeomBase.h:61
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IGeomBaseSchema::reset
virtual void reset()
Definition: IGeomBase.h:147
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IGeomBaseSchema::valid
virtual bool valid() const
Definition: IGeomBase.h:156
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IPolyMeshSchema::Sample
Definition: IPolyMesh.h:57
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IPolyMeshSchema::Sample::this_type
Sample this_type
Definition: IPolyMesh.h:59
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IPolyMeshSchema::Sample::m_selfBounds
Abc::Box3d m_selfBounds
Definition: IPolyMesh.h:92
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IPolyMeshSchema::Sample::getSelfBounds
Abc::Box3d getSelfBounds() const
Definition: IPolyMesh.h:68
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IPolyMeshSchema::Sample::valid
bool valid() const
Definition: IPolyMesh.h:70
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IPolyMeshSchema::Sample::ALEMBIC_OPERATOR_BOOL
ALEMBIC_OPERATOR_BOOL(valid())
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IPolyMeshSchema::Sample::m_positions
Abc::P3fArraySamplePtr m_positions
Definition: IPolyMesh.h:88
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IPolyMeshSchema::Sample::m_indices
Abc::Int32ArraySamplePtr m_indices
Definition: IPolyMesh.h:90
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IPolyMeshSchema::Sample::getPositions
Abc::P3fArraySamplePtr getPositions() const
Definition: IPolyMesh.h:64
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IPolyMeshSchema::Sample::Sample
Sample()
Definition: IPolyMesh.h:62
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IPolyMeshSchema::Sample::getFaceIndices
Abc::Int32ArraySamplePtr getFaceIndices() const
Definition: IPolyMesh.h:66
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IPolyMeshSchema::Sample::getVelocities
Abc::V3fArraySamplePtr getVelocities() const
Definition: IPolyMesh.h:65
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IPolyMeshSchema::Sample::getFaceCounts
Abc::Int32ArraySamplePtr getFaceCounts() const
Definition: IPolyMesh.h:67
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IPolyMeshSchema::Sample::m_velocities
Abc::V3fArraySamplePtr m_velocities
Definition: IPolyMesh.h:89
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IPolyMeshSchema::Sample::reset
void reset()
Definition: IPolyMesh.h:75
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IPolyMeshSchema::Sample::m_counts
Abc::Int32ArraySamplePtr m_counts
Definition: IPolyMesh.h:91
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IPolyMeshSchema
Definition: IPolyMesh.h:54
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IPolyMeshSchema::m_countsProperty
Abc::IInt32ArrayProperty m_countsProperty
Definition: IPolyMesh.h:285
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IPolyMeshSchema::loadFaceSetNames
void loadFaceSetNames()
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IPolyMeshSchema::IPolyMeshSchema
IPolyMeshSchema(const IPolyMeshSchema &iCopy)
Copy constructor.
Definition: IPolyMesh.h:140
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IPolyMeshSchema::m_faceSets
std::map< std::string, IFaceSet > m_faceSets
Definition: IPolyMesh.h:293
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IPolyMeshSchema::m_uvsParam
IV2fGeomParam m_uvsParam
Definition: IPolyMesh.h:287
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IPolyMeshSchema::getUVsParam
IV2fGeomParam getUVsParam() const
Definition: IPolyMesh.h:207
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IPolyMeshSchema::ALEMBIC_OVERRIDE_OPERATOR_BOOL
ALEMBIC_OVERRIDE_OPERATOR_BOOL(IPolyMeshSchema::valid())
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IPolyMeshSchema::getValue
Sample getValue(const Abc::ISampleSelector &iSS=Abc::ISampleSelector()) const
Definition: IPolyMesh.h:200
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IPolyMeshSchema::getTopologyVariance
MeshTopologyVariance getTopologyVariance() const
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IPolyMeshSchema::m_positionsProperty
Abc::IP3fArrayProperty m_positionsProperty
Definition: IPolyMesh.h:282
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IPolyMeshSchema::getFaceSetNames
void getFaceSetNames(std::vector< std::string > &oFaceSetNames)
Appends the names of any FaceSets for this PolyMesh.
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IPolyMeshSchema::getVelocitiesProperty
Abc::IV3fArrayProperty getVelocitiesProperty() const
Definition: IPolyMesh.h:232
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IPolyMeshSchema::getTimeSampling
AbcA::TimeSamplingPtr getTimeSampling() const
Definition: IPolyMesh.h:166
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IPolyMeshSchema::IPolyMeshSchema
IPolyMeshSchema()
Definition: IPolyMesh.h:109
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IPolyMeshSchema::getPositionsProperty
Abc::IP3fArrayProperty getPositionsProperty() const
Definition: IPolyMesh.h:227
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IPolyMeshSchema::reset
void reset()
Definition: IPolyMesh.h:245
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IPolyMeshSchema::getFaceSet
IFaceSet getFaceSet(const std::string &iFaceSetName)
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IPolyMeshSchema::IPolyMeshSchema
IPolyMeshSchema(const ICompoundProperty &iParent, const std::string &iName, const Abc::Argument &iArg0=Abc::Argument(), const Abc::Argument &iArg1=Abc::Argument())
Definition: IPolyMesh.h:117
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IPolyMeshSchema::getFaceIndicesProperty
Abc::IInt32ArrayProperty getFaceIndicesProperty() const
Definition: IPolyMesh.h:222
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IPolyMeshSchema::m_faceSetsLoaded
bool m_faceSetsLoaded
Definition: IPolyMesh.h:292
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IPolyMeshSchema::get
void get(Sample &oSample, const Abc::ISampleSelector &iSS=Abc::ISampleSelector()) const
Definition: IPolyMesh.h:179
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IPolyMeshSchema::isConstant
bool isConstant() const
Definition: IPolyMesh.h:161
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IPolyMeshSchema::m_faceSetsMutex
Alembic::Util::mutex m_faceSetsMutex
Definition: IPolyMesh.h:294
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IPolyMeshSchema::init
void init(const Abc::Argument &iArg0, const Abc::Argument &iArg1)
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IPolyMeshSchema::valid
bool valid() const
Definition: IPolyMesh.h:260
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IPolyMeshSchema::getFaceCountsProperty
Abc::IInt32ArrayProperty getFaceCountsProperty() const
Definition: IPolyMesh.h:217
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IPolyMeshSchema::this_type
IPolyMeshSchema this_type
Definition: IPolyMesh.h:101
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IPolyMeshSchema::hasFaceSet
bool hasFaceSet(const std::string &iFaceSetName)
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IPolyMeshSchema::m_normalsParam
IN3fGeomParam m_normalsParam
Definition: IPolyMesh.h:288
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IPolyMeshSchema::getNormalsParam
IN3fGeomParam getNormalsParam() const
Definition: IPolyMesh.h:212
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IPolyMeshSchema::m_indicesProperty
Abc::IInt32ArrayProperty m_indicesProperty
Definition: IPolyMesh.h:284
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IPolyMeshSchema::IPolyMeshSchema
IPolyMeshSchema(const ICompoundProperty &iProp, const Abc::Argument &iArg0=Abc::Argument(), const Abc::Argument &iArg1=Abc::Argument())
Definition: IPolyMesh.h:131
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IPolyMeshSchema::operator=
const IPolyMeshSchema & operator=(const IPolyMeshSchema &rhs)
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IPolyMeshSchema::getNumSamples
size_t getNumSamples() const
Definition: IPolyMesh.h:152
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IPolyMeshSchema::m_velocitiesProperty
Abc::IV3fArrayProperty m_velocitiesProperty
Definition: IPolyMesh.h:283
Alembic::AbcGeom::ALEMBIC_VERSION_NS::ITypedGeomParam< V2fTPTraits >
Alembic::Abc::ALEMBIC_VERSION_NS::Argument
Definition: Argument.h:120
Alembic::Abc::ALEMBIC_VERSION_NS::ICompoundProperty
Definition: ICompoundProperty.h:53
Alembic::Abc::ALEMBIC_VERSION_NS::ISampleSelector
Definition: ISampleSelector.h:49
Alembic::Abc::ALEMBIC_VERSION_NS::ISchemaObject
Definition: ISchemaObject.h:56
Alembic::Abc::ALEMBIC_VERSION_NS::ITypedArrayProperty< Int32TPTraits >
Alembic::Util::ALEMBIC_VERSION_NS::mutex
Definition: Foundation.h:250
Alembic::AbcCoreAbstract::ALEMBIC_VERSION_NS::TimeSamplingPtr
Alembic::Util::shared_ptr< TimeSampling > TimeSamplingPtr
Definition: TimeSampling.h:137
Alembic::AbcGeom::ALEMBIC_VERSION_NS::MeshTopologyVariance
MeshTopologyVariance
Definition: Foundation.h:59
Alembic::AbcGeom::ALEMBIC_VERSION_NS::kConstantTopology
@ kConstantTopology
Definition: Foundation.h:60
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IPolyMesh
Abc::ISchemaObject< IPolyMeshSchema > IPolyMesh
Definition: IPolyMesh.h:299
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IPolyMeshPtr
Util::shared_ptr< IPolyMesh > IPolyMeshPtr
Definition: IPolyMesh.h:301
Alembic::Abc::ALEMBIC_VERSION_NS::Int32ArraySamplePtr
Alembic::Util::shared_ptr< Int32ArraySample > Int32ArraySamplePtr
Definition: TypedArraySample.h:224
Alembic::Abc::ALEMBIC_VERSION_NS::V3fArraySamplePtr
Alembic::Util::shared_ptr< V3fArraySample > V3fArraySamplePtr
Definition: TypedArraySample.h:240
Alembic::Abc::ALEMBIC_VERSION_NS::P3fArraySamplePtr
Alembic::Util::shared_ptr< P3fArraySample > P3fArraySamplePtr
Definition: TypedArraySample.h:250
Alembic
Alembic namespace ...
Definition: ArchiveInfo.h:46