Alembic 1.8.11

Loading...
Searching...
No Matches
ICurves.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_ICurves_h
38#define Alembic_AbcGeom_ICurves_h
39
40#include <Alembic/Util/Export.h>
41#include <Alembic/AbcGeom/Foundation.h>
42#include <Alembic/AbcGeom/Basis.h>
43#include <Alembic/AbcGeom/CurveType.h>
44#include <Alembic/AbcGeom/SchemaInfoDeclarations.h>
45#include <Alembic/AbcGeom/IGeomParam.h>
46#include <Alembic/AbcGeom/IGeomBase.h>
47
48 namespace Alembic {
49 namespace AbcGeom {
50 namespace ALEMBIC_VERSION_NS {
51
52//-*****************************************************************************
53 class ALEMBIC_EXPORT ICurvesSchema : public IGeomBaseSchema<CurvesSchemaInfo>
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
66 std::size_t getNumCurves() const
67 {
68 if ( m_nVertices ) { return m_nVertices->size(); }
69 else { return 0; }
70 }
71
72 Abc::Int32ArraySamplePtr getCurvesNumVertices() const
73 { return m_nVertices; }
74
75 CurveType getType() const { return m_type; }
76 CurvePeriodicity getWrap() const { return m_wrap; }
77 BasisType getBasis() const { return m_basis; }
78
79 // the should not be null if the curve type is kVariableOrder
80 Abc::UcharArraySamplePtr getOrders() const { return m_orders; }
81 Abc::FloatArraySamplePtr getKnots() const { return m_knots; }
82
83 // if this is NULL then the weight value of the position for each
84 // point is 1
85 Abc::FloatArraySamplePtr getPositionWeights() const
86 { return m_positionWeights; }
87
88 Abc::Box3d getSelfBounds() const { return m_selfBounds; }
89 Abc::V3fArraySamplePtr getVelocities() const { return m_velocities; }
90
91 bool valid() const
92 {
93 return m_positions.get() != 0 &&
94 (m_type != kVariableOrder || m_orders);
95 }
96
97 void reset()
98 {
99 m_positions.reset();
100 m_nVertices.reset();
101 m_positionWeights.reset();
102
103 m_type = kCubic;
104 m_wrap = kNonPeriodic;
105 m_basis = kBezierBasis;
106
107 m_orders.reset();
108 m_knots.reset();
109
110 m_selfBounds.makeEmpty();
111 }
112
113 ALEMBIC_OPERATOR_BOOL( valid() );
114
115 protected:
116 friend class ICurvesSchema;
117 Abc::P3fArraySamplePtr m_positions;
118 Abc::V3fArraySamplePtr m_velocities;
119 Abc::FloatArraySamplePtr m_positionWeights;
120
121 Abc::Box3d m_selfBounds;
122
123 // type, wrap, and nVertices
124 Abc::Int32ArraySamplePtr m_nVertices;
125 Abc::UcharArraySamplePtr m_orders;
126 Abc::FloatArraySamplePtr m_knots;
127
128 CurveType m_type;
129 BasisType m_basis;
130 CurvePeriodicity m_wrap;
131 };
132
133 //-*************************************************************************
134 // CURVE SCHEMA
135 //-*************************************************************************
136 public:
139 typedef ICurvesSchema this_type;
140
141 typedef ICurvesSchema::Sample sample_type;
142
143 //-*************************************************************************
144 // CONSTRUCTION, DESTRUCTION, ASSIGNMENT
145 //-*************************************************************************
146
149 ICurvesSchema() {}
150
157 ICurvesSchema( const ICompoundProperty & iParent,
158 const std::string &iName,
159 const Abc::Argument &iArg0 = Abc::Argument(),
160 const Abc::Argument &iArg1 = Abc::Argument() )
161 : IGeomBaseSchema<CurvesSchemaInfo>( iParent, iName, iArg0, iArg1 )
162 {
163 init( iArg0, iArg1 );
164 }
165
170 ICurvesSchema( const ICompoundProperty & iProp,
171 const Abc::Argument &iArg0 = Abc::Argument(),
172 const Abc::Argument &iArg1 = Abc::Argument() )
173 : IGeomBaseSchema<CurvesSchemaInfo>( iProp, iArg0, iArg1 )
174 {
175 init( iArg0, iArg1 );
176 }
177
179
180 size_t getNumSamples() const
181 { return m_positionsProperty.getNumSamples(); }
182
185 MeshTopologyVariance getTopologyVariance() const;
186
189 bool isConstant() const
190 { return getTopologyVariance() == kConstantTopology; }
191
194 AbcA::TimeSamplingPtr getTimeSampling() const
195 {
196 return m_positionsProperty.getTimeSampling();
197 }
198
199 //-*************************************************************************
200 void get( sample_type &oSample,
201 const Abc::ISampleSelector &iSS = Abc::ISampleSelector() ) const;
202
203 sample_type getValue( const Abc::ISampleSelector &iSS =
204 Abc::ISampleSelector() ) const
205 {
206 sample_type smp;
207 get( smp, iSS );
208 return smp;
209 }
210
211 Abc::IV3fArrayProperty getVelocitiesProperty() const
212 {
213 return m_velocitiesProperty;
214 }
215
216 Abc::IP3fArrayProperty getPositionsProperty() const
217 {
218 return m_positionsProperty;
219 }
220
221 Abc::IInt32ArrayProperty getNumVerticesProperty() const
222 {
223 return m_nVerticesProperty;
224 }
225
226 // if this property is invalid then the weight for every point is 1
227 Abc::IFloatArrayProperty getPositionWeightsProperty() const
228 {
229 return m_positionWeightsProperty;
230 }
231
232 IV2fGeomParam getUVsParam() const
233 {
234 return m_uvsParam;
235 }
236
237 IN3fGeomParam getNormalsParam() const
238 {
239 return m_normalsParam;
240 }
241
242 IFloatGeomParam getWidthsParam() const
243 {
244 return m_widthsParam;
245 }
246
247 Abc::IUcharArrayProperty getOrdersProperty() const
248 {
249 return m_ordersProperty;
250 }
251
252 Abc::IFloatArrayProperty getKnotsProperty() const
253 {
254 return m_knotsProperty;
255 }
256
257 //-*************************************************************************
258 // ABC BASE MECHANISMS
259 // These functions are used by Abc to deal with errors, rewrapping,
260 // and so on.
261 //-*************************************************************************
262
265 void reset()
266 {
267 m_positionsProperty.reset();
268 m_velocitiesProperty.reset();
269 m_nVerticesProperty.reset();
270
271 m_positionWeightsProperty.reset();
272 m_ordersProperty.reset();
273 m_knotsProperty.reset();
274
275 m_uvsParam.reset();
276 m_normalsParam.reset();
277 m_widthsParam.reset();
278
279 m_basisAndTypeProperty.reset();
280
281 IGeomBaseSchema<CurvesSchemaInfo>::reset();
282 }
283
286 bool valid() const
287 {
288 return ( IGeomBaseSchema<CurvesSchemaInfo>::valid() &&
289 m_positionsProperty.valid() && m_nVerticesProperty.valid() );
290 }
291
294 ALEMBIC_OVERRIDE_OPERATOR_BOOL( this_type::valid() );
295
296 protected:
297 void init( const Abc::Argument &iArg0, const Abc::Argument &iArg1 );
298
299 Abc::IP3fArrayProperty m_positionsProperty;
300 Abc::IV3fArrayProperty m_velocitiesProperty;
301 Abc::IInt32ArrayProperty m_nVerticesProperty;
302
303 // contains type, wrap, ubasis, and vbasis.
304 Abc::IScalarProperty m_basisAndTypeProperty;
305
306 IFloatGeomParam m_widthsParam;
307 IV2fGeomParam m_uvsParam;
308 IN3fGeomParam m_normalsParam;
309
310 // optional
311 Abc::IFloatArrayProperty m_positionWeightsProperty;
312 Abc::IUcharArrayProperty m_ordersProperty;
313 Abc::IFloatArrayProperty m_knotsProperty;
314};
315
316//-*****************************************************************************
317 typedef Abc::ISchemaObject<ICurvesSchema> ICurves;
318
319 typedef Util::shared_ptr< ICurves > ICurvesPtr;
320
321} // End namespace ALEMBIC_VERSION_NS
322
323 using namespace ALEMBIC_VERSION_NS;
324
325} // End namespace AbcGeom
326} // End namespace Alembic
327
328#endif
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::IScalarProperty
Definition IScalarProperty.h:54
Alembic::Abc::ALEMBIC_VERSION_NS::ISchemaObject
Definition ISchemaObject.h:56
Alembic::AbcGeom::ALEMBIC_VERSION_NS::ICurvesSchema::Sample
Definition ICurves.h:57
Alembic::AbcGeom::ALEMBIC_VERSION_NS::ICurvesSchema::ALEMBIC_OVERRIDE_OPERATOR_BOOL
ALEMBIC_OVERRIDE_OPERATOR_BOOL(this_type::valid())
Alembic::AbcGeom::ALEMBIC_VERSION_NS::ICurvesSchema::ICurvesSchema
ICurvesSchema(const ICompoundProperty &iProp, const Abc::Argument &iArg0=Abc::Argument(), const Abc::Argument &iArg1=Abc::Argument())
Definition ICurves.h:170
Alembic::AbcGeom::ALEMBIC_VERSION_NS::ICurvesSchema::getNumSamples
size_t getNumSamples() const
Default assignment and copy operator used.
Definition ICurves.h:180
Alembic::AbcGeom::ALEMBIC_VERSION_NS::ICurvesSchema::isConstant
bool isConstant() const
Definition ICurves.h:189
Alembic::AbcGeom::ALEMBIC_VERSION_NS::ICurvesSchema::valid
bool valid() const
Definition ICurves.h:286
Alembic::AbcGeom::ALEMBIC_VERSION_NS::ICurvesSchema::this_type
ICurvesSchema this_type
Definition ICurves.h:139
Alembic::AbcGeom::ALEMBIC_VERSION_NS::ICurvesSchema::getTimeSampling
AbcA::TimeSamplingPtr getTimeSampling() const
Definition ICurves.h:194
Alembic::AbcGeom::ALEMBIC_VERSION_NS::ICurvesSchema::reset
void reset()
Definition ICurves.h:265
Alembic::AbcGeom::ALEMBIC_VERSION_NS::ICurvesSchema::getTopologyVariance
MeshTopologyVariance getTopologyVariance() const
Definition ICurves.cpp:44
Alembic::AbcGeom::ALEMBIC_VERSION_NS::ICurvesSchema::ICurvesSchema
ICurvesSchema(const ICompoundProperty &iParent, const std::string &iName, const Abc::Argument &iArg0=Abc::Argument(), const Abc::Argument &iArg1=Abc::Argument())
Definition ICurves.h:157
Alembic::AbcGeom::ALEMBIC_VERSION_NS::ICurvesSchema::ICurvesSchema
ICurvesSchema()
Definition ICurves.h:149
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IGeomBaseSchema< CurvesSchemaInfo >::IGeomBaseSchema
IGeomBaseSchema()
Definition IGeomBase.h:76
Alembic
Alembic namespace ...
Definition ArchiveInfo.cpp:39