Alembic Version 1.1
Loading...
Searching...
No Matches
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>
45
46namespace Alembic {
47namespace AbcGeom {
48namespace ALEMBIC_VERSION_NS {
49
50//-*****************************************************************************
51class ALEMBIC_EXPORT OPointsSchema : public OGeomBaseSchema<PointsSchemaInfo>
52{
53public:
54 //-*************************************************************************
55 // POINTS SCHEMA SAMPLE TYPE
56 //-*************************************************************************
57 class Sample
58 {
59 public:
62 Sample() { reset(); }
63
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
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; }
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:
137 OFloatGeomParam::Sample m_widths;
138
139 Abc::Box3d m_selfBounds;
140 };
141
142 //-*************************************************************************
143 // POINTS SCHEMA
144 //-*************************************************************************
145public:
149
150 //-*************************************************************************
151 // CONSTRUCTION, DESTRUCTION, ASSIGNMENT
152 //-*************************************************************************
153
157 {
158 m_selectiveExport = false;
159 m_numSamples = 0;
160 m_timeSamplingIndex = 0;
161 }
162
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
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
190 : OGeomBaseSchema<PointsSchemaInfo>()
191 {
192 *this = iCopy;
193 }
194
196
197 //-*************************************************************************
198 // SCHEMA STUFF
199 //-*************************************************************************
200
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
228
229 void setTimeSampling( uint32_t iIndex );
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
248 }
249
252 bool valid() const
253 {
255 m_positionsProperty.valid() &&
256 m_idsProperty.valid() )
257 || m_selectiveExport );
258 }
259
262 ALEMBIC_OVERRIDE_OPERATOR_BOOL( OPointsSchema::valid() );
263
264private:
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//-*****************************************************************************
297
298typedef Util::shared_ptr< OPoints > OPointsPtr;
299
300} // End namespace ALEMBIC_VERSION_NS
301
302using namespace ALEMBIC_VERSION_NS;
303
304} // End namespace AbcGeom
305} // End namespace Alembic
306
307#endif
#define ALEMBIC_EXPORT
Definition Export.h:51
#define ALEMBIC_VERSION_NS
Definition Foundation.h:105
void setWidths(const OFloatGeomParam::Sample &iWidths)
Definition OPoints.h:106
const OFloatGeomParam::Sample & getWidths() const
Definition OPoints.h:105
const Abc::V3fArraySample & getVelocities() const
Definition OPoints.h:100
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
Sample(const Abc::P3fArraySample &iPos, const Abc::V3fArraySample &iVelocities=Abc::V3fArraySample(), const OFloatGeomParam::Sample &iWidths=OFloatGeomParam::Sample())
Definition OPoints.h:66
void setIds(const Abc::UInt64ArraySample &iSmp)
Definition OPoints.h:96
const Abc::P3fArraySample & getPositions() const
Definition OPoints.h:90
const Abc::UInt64ArraySample & getIds() const
Definition OPoints.h:95
void setPositions(const Abc::P3fArraySample &iSmp)
Definition OPoints.h:91
void setVelocities(const Abc::V3fArraySample &iVelocities)
Definition OPoints.h:101
void set(const Sample &iSamp)
Set a sample.
AbcA::TimeSamplingPtr getTimeSampling() const
Default assignment operator used.
Definition OPoints.h:202
OPointsSchema(const OPointsSchema &iCopy)
Copy constructor.
Definition OPoints.h:189
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())
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())
void setTimeSampling(AbcA::TimeSamplingPtr iTime)
Alembic::Util::shared_ptr< CompoundPropertyWriter > CompoundPropertyWriterPtr
Alembic::Util::shared_ptr< TimeSampling > TimeSamplingPtr
Util::shared_ptr< OPoints > OPointsPtr
Definition OPoints.h:298
Alembic namespace ...
Definition ArchiveInfo.h:46