Alembic Version 1.1

OPoints.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_OPoints_h
38#define Alembic_AbcGeom_OPoints_h
39
40#include <Alembic/Util/Export.h>
41#include <Alembic/AbcGeom/Foundation.h>
42#include <Alembic/AbcGeom/SchemaInfoDeclarations.h>
43#include <Alembic/AbcGeom/OGeomParam.h>
44#include <Alembic/AbcGeom/OGeomBase.h>
45
46 namespace Alembic {
47 namespace AbcGeom {
48 namespace ALEMBIC_VERSION_NS {
49
50//-*****************************************************************************
51 class ALEMBIC_EXPORT OPointsSchema : public OGeomBaseSchema<PointsSchemaInfo>
52{
53 public:
54 //-*************************************************************************
55 // POINTS SCHEMA SAMPLE TYPE
56 //-*************************************************************************
57 class Sample
58 {
59 public:
62 Sample() { reset(); }
63
66 Sample( const Abc::P3fArraySample &iPos,
67 const Abc::V3fArraySample &iVelocities = Abc::V3fArraySample(),
68 const OFloatGeomParam::Sample &iWidths = \
69 OFloatGeomParam::Sample() )
70 : m_positions( iPos )
71 , m_velocities( iVelocities )
72 , m_widths( iWidths )
73 {}
74
78 Sample( const Abc::P3fArraySample &iPos,
79 const Abc::UInt64ArraySample &iId,
80 const Abc::V3fArraySample &iVelocities = Abc::V3fArraySample(),
81 const OFloatGeomParam::Sample &iWidths = \
82 OFloatGeomParam::Sample() )
83 : m_positions( iPos )
84 , m_velocities( iVelocities )
85 , m_ids( iId )
86 , m_widths( iWidths )
87 {}
88
89 // positions accessor
90 const Abc::P3fArraySample &getPositions() const { return m_positions; }
91 void setPositions( const Abc::P3fArraySample &iSmp )
92 { m_positions = iSmp; }
93
94 // ids accessor
95 const Abc::UInt64ArraySample &getIds() const { return m_ids; }
96 void setIds( const Abc::UInt64ArraySample &iSmp )
97 { m_ids = iSmp; }
98
99 // velocities accessor
100 const Abc::V3fArraySample &getVelocities() const { return m_velocities; }
101 void setVelocities( const Abc::V3fArraySample &iVelocities )
102 { m_velocities = iVelocities; }
103
104 // widths accessor
105 const OFloatGeomParam::Sample &getWidths() const { return m_widths; }
106 void setWidths( const OFloatGeomParam::Sample &iWidths )
107 { m_widths = iWidths; }
108
109 const Abc::Box3d &getSelfBounds() const { return m_selfBounds; }
110 void setSelfBounds( const Abc::Box3d &iBnds )
111 { m_selfBounds = iBnds; }
112
113 void reset()
114 {
115 m_positions.reset();
116 m_velocities.reset();
117 m_ids.reset();
118 m_widths.reset();
119
120 m_selfBounds.makeEmpty();
121 }
122
123 bool isPartialSample() const
124 {
125 if( !m_positions.getData() )
126 {
127 return true;
128 }
129
130 return false;
131 }
132
133 protected:
134 Abc::P3fArraySample m_positions;
135 Abc::V3fArraySample m_velocities;
136 Abc::UInt64ArraySample m_ids;
137 OFloatGeomParam::Sample m_widths;
138
139 Abc::Box3d m_selfBounds;
140 };
141
142 //-*************************************************************************
143 // POINTS SCHEMA
144 //-*************************************************************************
145 public:
148 typedef OPointsSchema this_type;
149
150 //-*************************************************************************
151 // CONSTRUCTION, DESTRUCTION, ASSIGNMENT
152 //-*************************************************************************
153
156 OPointsSchema()
157 {
158 m_selectiveExport = false;
159 m_numSamples = 0;
160 m_timeSamplingIndex = 0;
161 }
162
169 OPointsSchema( AbcA::CompoundPropertyWriterPtr iParent,
170 const std::string &iName,
171 const Abc::Argument &iArg0 = Abc::Argument(),
172 const Abc::Argument &iArg1 = Abc::Argument(),
173 const Abc::Argument &iArg2 = Abc::Argument(),
174 const Abc::Argument &iArg3 = Abc::Argument() );
175
182 OPointsSchema( Abc::OCompoundProperty iParent,
183 const std::string &iName,
184 const Abc::Argument &iArg0 = Abc::Argument(),
185 const Abc::Argument &iArg1 = Abc::Argument(),
186 const Abc::Argument &iArg2 = Abc::Argument() );
187
189 OPointsSchema(const OPointsSchema& iCopy)
190 : OGeomBaseSchema<PointsSchemaInfo>()
191 {
192 *this = iCopy;
193 }
194
196
197 //-*************************************************************************
198 // SCHEMA STUFF
199 //-*************************************************************************
200
202 AbcA::TimeSamplingPtr getTimeSampling() const
203 {
204 if( m_positionsProperty.valid() )
205 {
206 return m_positionsProperty.getTimeSampling();
207 }
208 else
209 {
210 return getObject().getArchive().getTimeSampling( 0 );
211 }
212 }
213
214 //-*************************************************************************
215 // SAMPLE STUFF
216 //-*************************************************************************
217
220 size_t getNumSamples() const { return m_numSamples; }
221
223 void set( const Sample &iSamp );
224
227 void setFromPrevious( );
228
229 void setTimeSampling( uint32_t iIndex );
230 void setTimeSampling( AbcA::TimeSamplingPtr iTime );
231
232 //-*************************************************************************
233 // ABC BASE MECHANISMS
234 // These functions are used by Abc to deal with errors, validity,
235 // and so on.
236 //-*************************************************************************
237
240 void reset()
241 {
242 m_positionsProperty.reset();
243 m_idsProperty.reset();
244 m_velocitiesProperty.reset();
245 m_widthsParam.reset();
246
247 OGeomBaseSchema<PointsSchemaInfo>::reset();
248 }
249
252 bool valid() const
253 {
254 return ( ( OGeomBaseSchema<PointsSchemaInfo>::valid() &&
255 m_positionsProperty.valid() &&
256 m_idsProperty.valid() )
257 || m_selectiveExport );
258 }
259
262 ALEMBIC_OVERRIDE_OPERATOR_BOOL( OPointsSchema::valid() );
263
264 private:
265 void init( uint32_t iTsIdx, bool isSparse );
266
270 void selectiveSet( const Sample &iSamp );
271
272 void createPositionProperty();
273 void createIdProperty();
274 void createVelocityProperty();
275 void createWidthsProperty( const Sample &iSamp );
276
277 Abc::OP3fArrayProperty m_positionsProperty;
278 Abc::OUInt64ArrayProperty m_idsProperty;
279 Abc::OV3fArrayProperty m_velocitiesProperty;
280 OFloatGeomParam m_widthsParam;
281
282 // Write out only some properties (UVs, normals).
283 // This is to export data to layer into another file later.
284 bool m_selectiveExport;
285
286 // Number of times OPolyMeshSchema::set() has been called
287 size_t m_numSamples;
288
289 uint32_t m_timeSamplingIndex;
290
291};
292
293//-*****************************************************************************
294// SCHEMA OBJECT
295//-*****************************************************************************
296 typedef Abc::OSchemaObject<OPointsSchema> OPoints;
297
298 typedef Util::shared_ptr< OPoints > OPointsPtr;
299
300} // End namespace ALEMBIC_VERSION_NS
301
302 using namespace ALEMBIC_VERSION_NS;
303
304} // End namespace AbcGeom
305} // End namespace Alembic
306
307#endif
Foundation.h
SchemaInfoDeclarations.h
Export.h
ALEMBIC_EXPORT
#define ALEMBIC_EXPORT
Definition: Export.h:51
OGeomBase.h
OGeomParam.h
ALEMBIC_VERSION_NS
#define ALEMBIC_VERSION_NS
Definition: Foundation.h:105
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OGeomBaseSchema
Definition: OGeomBase.h:59
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OGeomBaseSchema::reset
virtual void reset()
Definition: OGeomBase.h:110
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OGeomBaseSchema::valid
virtual bool valid() const
Definition: OGeomBase.h:119
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPointsSchema::Sample
Definition: OPoints.h:58
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPointsSchema::Sample::getSelfBounds
const Abc::Box3d & getSelfBounds() const
Definition: OPoints.h:109
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPointsSchema::Sample::setWidths
void setWidths(const OFloatGeomParam::Sample &iWidths)
Definition: OPoints.h:106
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPointsSchema::Sample::isPartialSample
bool isPartialSample() const
Definition: OPoints.h:123
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPointsSchema::Sample::getWidths
const OFloatGeomParam::Sample & getWidths() const
Definition: OPoints.h:105
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPointsSchema::Sample::m_positions
Abc::P3fArraySample m_positions
Definition: OPoints.h:134
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPointsSchema::Sample::Sample
Sample()
Definition: OPoints.h:62
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPointsSchema::Sample::getVelocities
const Abc::V3fArraySample & getVelocities() const
Definition: OPoints.h:100
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPointsSchema::Sample::reset
void reset()
Definition: OPoints.h:113
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPointsSchema::Sample::Sample
Sample(const Abc::P3fArraySample &iPos, const Abc::UInt64ArraySample &iId, const Abc::V3fArraySample &iVelocities=Abc::V3fArraySample(), const OFloatGeomParam::Sample &iWidths=OFloatGeomParam::Sample())
Definition: OPoints.h:78
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPointsSchema::Sample::m_selfBounds
Abc::Box3d m_selfBounds
Definition: OPoints.h:139
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPointsSchema::Sample::setSelfBounds
void setSelfBounds(const Abc::Box3d &iBnds)
Definition: OPoints.h:110
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPointsSchema::Sample::m_widths
OFloatGeomParam::Sample m_widths
Definition: OPoints.h:137
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPointsSchema::Sample::m_velocities
Abc::V3fArraySample m_velocities
Definition: OPoints.h:135
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPointsSchema::Sample::Sample
Sample(const Abc::P3fArraySample &iPos, const Abc::V3fArraySample &iVelocities=Abc::V3fArraySample(), const OFloatGeomParam::Sample &iWidths=OFloatGeomParam::Sample())
Definition: OPoints.h:66
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPointsSchema::Sample::setIds
void setIds(const Abc::UInt64ArraySample &iSmp)
Definition: OPoints.h:96
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPointsSchema::Sample::getPositions
const Abc::P3fArraySample & getPositions() const
Definition: OPoints.h:90
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPointsSchema::Sample::m_ids
Abc::UInt64ArraySample m_ids
Definition: OPoints.h:136
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPointsSchema::Sample::getIds
const Abc::UInt64ArraySample & getIds() const
Definition: OPoints.h:95
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPointsSchema::Sample::setPositions
void setPositions(const Abc::P3fArraySample &iSmp)
Definition: OPoints.h:91
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPointsSchema::Sample::setVelocities
void setVelocities(const Abc::V3fArraySample &iVelocities)
Definition: OPoints.h:101
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPointsSchema
Definition: OPoints.h:52
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPointsSchema::OPointsSchema
OPointsSchema()
Definition: OPoints.h:156
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPointsSchema::ALEMBIC_OVERRIDE_OPERATOR_BOOL
ALEMBIC_OVERRIDE_OPERATOR_BOOL(OPointsSchema::valid())
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPointsSchema::setTimeSampling
void setTimeSampling(uint32_t iIndex)
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPointsSchema::set
void set(const Sample &iSamp)
Set a sample.
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPointsSchema::this_type
OPointsSchema this_type
Definition: OPoints.h:148
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPointsSchema::getNumSamples
size_t getNumSamples() const
Definition: OPoints.h:220
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPointsSchema::valid
bool valid() const
Definition: OPoints.h:252
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPointsSchema::getTimeSampling
AbcA::TimeSamplingPtr getTimeSampling() const
Default assignment operator used.
Definition: OPoints.h:202
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPointsSchema::setFromPrevious
void setFromPrevious()
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPointsSchema::OPointsSchema
OPointsSchema(const OPointsSchema &iCopy)
Copy constructor.
Definition: OPoints.h:189
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPointsSchema::OPointsSchema
OPointsSchema(AbcA::CompoundPropertyWriterPtr iParent, const std::string &iName, const Abc::Argument &iArg0=Abc::Argument(), const Abc::Argument &iArg1=Abc::Argument(), const Abc::Argument &iArg2=Abc::Argument(), const Abc::Argument &iArg3=Abc::Argument())
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPointsSchema::reset
void reset()
Definition: OPoints.h:240
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPointsSchema::OPointsSchema
OPointsSchema(Abc::OCompoundProperty iParent, const std::string &iName, const Abc::Argument &iArg0=Abc::Argument(), const Abc::Argument &iArg1=Abc::Argument(), const Abc::Argument &iArg2=Abc::Argument())
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPointsSchema::setTimeSampling
void setTimeSampling(AbcA::TimeSamplingPtr iTime)
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OTypedGeomParam< Float32TPTraits >
Alembic::Abc::ALEMBIC_VERSION_NS::Argument
Definition: Argument.h:120
Alembic::Abc::ALEMBIC_VERSION_NS::OCompoundProperty
Definition: OCompoundProperty.h:53
Alembic::Abc::ALEMBIC_VERSION_NS::OSchemaObject
Definition: OSchemaObject.h:54
Alembic::Abc::ALEMBIC_VERSION_NS::OTypedArrayProperty< P3fTPTraits >
Alembic::Abc::ALEMBIC_VERSION_NS::TypedArraySample< P3fTPTraits >
Alembic::AbcCoreAbstract::ALEMBIC_VERSION_NS::CompoundPropertyWriterPtr
Alembic::Util::shared_ptr< CompoundPropertyWriter > CompoundPropertyWriterPtr
Definition: ForwardDeclarations.h:83
Alembic::AbcCoreAbstract::ALEMBIC_VERSION_NS::TimeSamplingPtr
Alembic::Util::shared_ptr< TimeSampling > TimeSamplingPtr
Definition: TimeSampling.h:137
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPointsPtr
Util::shared_ptr< OPoints > OPointsPtr
Definition: OPoints.h:298
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPoints
Abc::OSchemaObject< OPointsSchema > OPoints
Definition: OPoints.h:296
Alembic
Alembic namespace ...
Definition: ArchiveInfo.h:46