Alembic: AbcGeom/OPoints.h Source File

Alembic 1.8.11

Loading...
Searching...
No Matches
OPoints.h
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
46namespace Alembic {
47namespace AbcGeom {
48namespace ALEMBIC_VERSION_NS {
49
50//-*****************************************************************************
51 class 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
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 //-*************************************************************************
145public:
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
190 //-*************************************************************************
191 // SCHEMA STUFF
192 //-*************************************************************************
193
195 AbcA::TimeSamplingPtr getTimeSampling() const
196 {
197 if( m_positionsProperty.valid() )
198 {
199 return m_positionsProperty.getTimeSampling();
200 }
201 else
202 {
203 return getObject().getArchive().getTimeSampling( 0 );
204 }
205 }
206
207 //-*************************************************************************
208 // SAMPLE STUFF
209 //-*************************************************************************
210
213 size_t getNumSamples() const { return m_numSamples; }
214
216 void set( const Sample &iSamp );
217
220 void setFromPrevious( );
221
222 void setTimeSampling( uint32_t iIndex );
223 void setTimeSampling( AbcA::TimeSamplingPtr iTime );
224
225 //-*************************************************************************
226 // ABC BASE MECHANISMS
227 // These functions are used by Abc to deal with errors, validity,
228 // and so on.
229 //-*************************************************************************
230
233 void reset()
234 {
235 m_positionsProperty.reset();
236 m_idsProperty.reset();
237 m_velocitiesProperty.reset();
238 m_widthsParam.reset();
239
240 OGeomBaseSchema<PointsSchemaInfo>::reset();
241 }
242
245 bool valid() const
246 {
247 return ( ( OGeomBaseSchema<PointsSchemaInfo>::valid() &&
248 m_positionsProperty.valid() &&
249 m_idsProperty.valid() )
250 || m_selectiveExport );
251 }
252
255 ALEMBIC_OVERRIDE_OPERATOR_BOOL( OPointsSchema::valid() );
256
257private:
258 void init( uint32_t iTsIdx, bool isSparse );
259
263 void selectiveSet( const Sample &iSamp );
264
265 void createPositionProperty();
266 void createIdProperty();
267 void createVelocityProperty();
268 void createWidthsProperty( const Sample &iSamp );
269
270 Abc::OP3fArrayProperty m_positionsProperty;
271 Abc::OUInt64ArrayProperty m_idsProperty;
272 Abc::OV3fArrayProperty m_velocitiesProperty;
273 OFloatGeomParam m_widthsParam;
274
275 // Write out only some properties (UVs, normals).
276 // This is to export data to layer into another file later.
277 bool m_selectiveExport;
278
279 // Number of times OPolyMeshSchema::set() has been called
280 size_t m_numSamples;
281
282 uint32_t m_timeSamplingIndex;
283
284};
285
286//-*****************************************************************************
287// SCHEMA OBJECT
288//-*****************************************************************************
289typedef Abc::OSchemaObject<OPointsSchema> OPoints;
290
291typedef Util::shared_ptr< OPoints > OPointsPtr;
292
293} // End namespace ALEMBIC_VERSION_NS
294
295using namespace ALEMBIC_VERSION_NS;
296
297} // End namespace AbcGeom
298} // End namespace Alembic
299
300#endif
Alembic::Abc::ALEMBIC_VERSION_NS::Argument
Definition Argument.h:120
Alembic::Abc::ALEMBIC_VERSION_NS::OBasePropertyT< AbcA::CompoundPropertyWriterPtr >::getObject
OObject getObject() const
Definition OBaseProperty.h:225
Alembic::Abc::ALEMBIC_VERSION_NS::OCompoundProperty
Definition OCompoundProperty.h:53
Alembic::Abc::ALEMBIC_VERSION_NS::OSchemaObject
Definition OSchemaObject.h:54
Alembic::AbcCoreAbstract::ALEMBIC_VERSION_NS::ArraySample::reset
void reset()
Definition ArraySample.h:119
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OGeomBaseSchema< PointsSchemaInfo >::OGeomBaseSchema
OGeomBaseSchema()
Definition OGeomBase.h:74
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPointsSchema::Sample
Definition OPoints.h:58
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPointsSchema::Sample::Sample
Sample()
Definition OPoints.h:62
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::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
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::this_type
OPointsSchema this_type
Definition OPoints.h:148
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPointsSchema::getNumSamples
size_t getNumSamples() const
Definition OPoints.h:213
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPointsSchema::valid
bool valid() const
Definition OPoints.h:245
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPointsSchema::getTimeSampling
AbcA::TimeSamplingPtr getTimeSampling() const
Default assignment and copy operator used.
Definition OPoints.h:195
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPointsSchema::reset
void reset()
Definition OPoints.h:233
Alembic
Alembic namespace ...
Definition ArchiveInfo.cpp:39