Alembic: AbcGeom/INuPatch.h Source File

Alembic 1.8.11

Loading...
Searching...
No Matches
INuPatch.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_INuPatch_h
38#define Alembic_AbcGeom_INuPatch_h
39
40#include <Alembic/Util/Export.h>
41#include <Alembic/AbcGeom/Foundation.h>
42#include <Alembic/AbcGeom/SchemaInfoDeclarations.h>
43#include <Alembic/AbcGeom/IGeomParam.h>
44#include <Alembic/AbcGeom/IGeomBase.h>
45
46namespace Alembic {
47namespace AbcGeom {
48namespace ALEMBIC_VERSION_NS {
49
50//-*****************************************************************************
51 class ALEMBIC_EXPORT INuPatchSchema : public IGeomBaseSchema<NuPatchSchemaInfo>
52{
53public:
54 class Sample
55 {
56 public:
57 typedef Sample this_type;
58
59 // Users don't ever create this data directly.
60 Sample() { reset(); }
61
62 Abc::P3fArraySamplePtr getPositions() const { return m_positions; }
63 Abc::V3fArraySamplePtr getVelocities() const { return m_velocities; }
64 int32_t getNumU() const { return m_numU; }
65 int32_t getNumV() const { return m_numV; }
66 int32_t getUOrder() const { return m_uOrder; }
67 int32_t getVOrder() const { return m_vOrder; }
68 Abc::FloatArraySamplePtr getUKnot() const { return m_uKnot; }
69 Abc::FloatArraySamplePtr getVKnot() const { return m_vKnot; }
70
71 // if this is NULL then the weight value of the position for each
72 // point is 1
73 Abc::FloatArraySamplePtr getPositionWeights() const { return m_positionWeights; }
74
75 // trim curve
76 int32_t getTrimNumLoops() const { return m_trimNumLoops; }
77 Abc::Int32ArraySamplePtr getTrimNumVertices() const { return m_trimNumVertices; }
78 Abc::Int32ArraySamplePtr getTrimNumCurves() const { return m_trimNumCurves; }
79 Abc::Int32ArraySamplePtr getTrimOrders() const { return m_trimOrder; }
80 Abc::FloatArraySamplePtr getTrimKnots() const { return m_trimKnot; }
81 Abc::FloatArraySamplePtr getTrimMins() const { return m_trimMin; }
82 Abc::FloatArraySamplePtr getTrimMaxes() const { return m_trimMax; }
83 Abc::FloatArraySamplePtr getTrimU() const { return m_trimU; }
84 Abc::FloatArraySamplePtr getTrimV() const { return m_trimV; }
85 Abc::FloatArraySamplePtr getTrimW() const { return m_trimW; }
86
87 bool hasTrimCurve() const { return m_trimNumLoops != 0; }
88
89 bool valid() const
90 {
91 return m_positions && m_numU && m_numV && m_uOrder && m_vOrder &&
92 m_uKnot && m_vKnot;
93 }
94
95 Abc::Box3d getSelfBounds() const { return m_selfBounds; }
96
97 void reset()
98 {
99 m_positions.reset();
100 m_velocities.reset();
101 m_numU = 0;
102 m_numV = 0;
103 m_uOrder = 0;
104 m_vOrder = 0;
105 m_uKnot.reset();
106 m_vKnot.reset();
107 m_positionWeights.reset();
108
109 m_selfBounds.makeEmpty();
110
111 // trim curve
112 m_trimNumLoops = 0;
113 m_trimNumCurves.reset();
114 m_trimNumVertices.reset();
115 m_trimOrder.reset();
116 m_trimKnot.reset();
117 m_trimMin.reset();
118 m_trimMax.reset();
119 m_trimU.reset();
120 m_trimV.reset();
121 m_trimW.reset();
122 }
123
124 ALEMBIC_OPERATOR_BOOL( valid() );
125
126 protected:
127
128 friend class INuPatchSchema;
129
130 Abc::P3fArraySamplePtr m_positions;
131 Abc::V3fArraySamplePtr m_velocities;
132 int32_t m_numU;
133 int32_t m_numV;
134 int32_t m_uOrder;
135 int32_t m_vOrder;
136 Abc::FloatArraySamplePtr m_uKnot;
137 Abc::FloatArraySamplePtr m_vKnot;
138 Abc::FloatArraySamplePtr m_positionWeights;
139
140 // trim curve
141 int32_t m_trimNumLoops;
142 Abc::Int32ArraySamplePtr m_trimNumCurves;
143 Abc::Int32ArraySamplePtr m_trimNumVertices;
144 Abc::Int32ArraySamplePtr m_trimOrder;
145 Abc::FloatArraySamplePtr m_trimKnot;
146 Abc::FloatArraySamplePtr m_trimMin;
147 Abc::FloatArraySamplePtr m_trimMax;
148 Abc::FloatArraySamplePtr m_trimU;
149 Abc::FloatArraySamplePtr m_trimV;
150 Abc::FloatArraySamplePtr m_trimW;
151 bool m_hasTrimCurve;
152
153 // bounds
154 Abc::Box3d m_selfBounds;
155
156 };
157
158 //-*************************************************************************
159 // NuPatch Schema
160 //-*************************************************************************
161public:
164 typedef INuPatchSchema this_type;
165 typedef Sample sample_type;
166
167 //-*************************************************************************
168 // CONSTRUCTION, DESTRUCTION, ASSIGNMENT
169 //-*************************************************************************
170
172 INuPatchSchema()
173 {
174 m_hasTrimCurve = false;
175 }
176
183 INuPatchSchema( const ICompoundProperty &iParent,
184 const std::string &iName,
185 const Abc::Argument &iArg0 = Abc::Argument(),
186 const Abc::Argument &iArg1 = Abc::Argument() )
187 : IGeomBaseSchema<NuPatchSchemaInfo>( iParent, iName, iArg0, iArg1 )
188 {
189 init( iArg0, iArg1 );
190 }
191
196 explicit INuPatchSchema( const ICompoundProperty &iProp,
197 const Abc::Argument &iArg0 = Abc::Argument(),
198 const Abc::Argument &iArg1 = Abc::Argument() )
199
200 : IGeomBaseSchema<NuPatchSchemaInfo>( iProp, iArg0, iArg1 )
201 {
202 init( iArg0, iArg1 );
203 }
204
209 size_t getNumSamples() const
210 { return m_positionsProperty.getNumSamples(); }
211
214 MeshTopologyVariance getTopologyVariance() const;
215
218 bool isConstant() const { return getTopologyVariance() == kConstantTopology; }
219
221 AbcA::TimeSamplingPtr getTimeSampling() const
222 {
223 return m_positionsProperty.getTimeSampling();
224 }
225
226 void get( sample_type &oSample,
227 const Abc::ISampleSelector &iSS = Abc::ISampleSelector() ) const;
228
229 Sample getValue( const Abc::ISampleSelector &iSS = Abc::ISampleSelector() ) const
230 {
231 Sample smp;
232 get( smp, iSS );
233 return smp;
234 }
235
236 Abc::IP3fArrayProperty getPositionsProperty() const { return m_positionsProperty; }
237 Abc::IFloatArrayProperty getUKnotsProperty() const { return m_uKnotProperty; }
238 Abc::IFloatArrayProperty getVKnotsProperty() const { return m_vKnotProperty; }
239
240 Abc::IV3fArrayProperty getVelocitiesProperty() const
241 {
242 return m_velocitiesProperty;
243 }
244
245 // if this property is invalid then the weight for every point is 1
246 Abc::IFloatArrayProperty getPositionWeightsProperty() const
247 {
248 return m_positionWeightsProperty;
249 }
250
251 IN3fGeomParam getNormalsParam() const
252 {
253 return m_normalsParam;
254 }
255
256 IV2fGeomParam getUVsParam() const
257 {
258 return m_uvsParam;
259 }
260
261
262 bool hasTrimCurve() const { return m_hasTrimCurve; }
263 bool trimCurveTopologyIsHomogenous() const;
264 bool trimCurveTopologyIsConstant() const;
265
266
267 //-*************************************************************************
268 // ABC BASE MECHANISMS
269 // These functions are used by Abc to deal with errors, rewrapping,
270 // and so on.
271 //-*************************************************************************
272
275 void reset()
276 {
277 m_positionsProperty.reset();
278 m_velocitiesProperty.reset();
279 m_numUProperty.reset();
280 m_numVProperty.reset();
281 m_uOrderProperty.reset();
282 m_vOrderProperty.reset();
283 m_uKnotProperty.reset();
284 m_vKnotProperty.reset();
285 m_positionWeightsProperty.reset();
286
287 m_normalsParam.reset();
288 m_uvsParam.reset();
289
290 // reset trim curve attributes
291 m_trimNumLoopsProperty.reset();
292 m_trimNumCurvesProperty.reset();
293 m_trimNumVerticesProperty.reset();
294 m_trimOrderProperty.reset();
295 m_trimKnotProperty.reset();
296 m_trimMinProperty.reset();
297 m_trimMaxProperty.reset();
298 m_trimUProperty.reset();
299 m_trimVProperty.reset();
300 m_trimWProperty.reset();
301
302 IGeomBaseSchema<NuPatchSchemaInfo>::reset();
303 }
304
307 bool valid() const
308 {
309 return ( IGeomBaseSchema<NuPatchSchemaInfo>::valid() &&
310 m_positionsProperty.valid() &&
311 m_numUProperty.valid() &&
312 m_numVProperty.valid() &&
313 m_uOrderProperty.valid() &&
314 m_vOrderProperty.valid() &&
315 m_uKnotProperty.valid() &&
316 m_vKnotProperty.valid() );
317 }
318
321 ALEMBIC_OVERRIDE_OPERATOR_BOOL( INuPatchSchema::valid() );
322
323protected:
324 bool hasTrimProps() const;
325
326protected:
327 void init( const Abc::Argument &iArg0,
328 const Abc::Argument &iArg1 );
329
330 // required properties
331 Abc::IP3fArrayProperty m_positionsProperty;
332 Abc::IInt32Property m_numUProperty;
333 Abc::IInt32Property m_numVProperty;
334 Abc::IInt32Property m_uOrderProperty;
335 Abc::IInt32Property m_vOrderProperty;
336 Abc::IFloatArrayProperty m_uKnotProperty;
337 Abc::IFloatArrayProperty m_vKnotProperty;
338
339 // optional
340 Abc::IV3fArrayProperty m_velocitiesProperty;
341 Abc::IFloatArrayProperty m_positionWeightsProperty;
342 IN3fGeomParam m_normalsParam;
343 IV2fGeomParam m_uvsParam;
344
345 // optional trim curve properties
346 Abc::IInt32Property m_trimNumLoopsProperty;
347 Abc::IInt32ArrayProperty m_trimNumVerticesProperty;
348 Abc::IInt32ArrayProperty m_trimNumCurvesProperty;
349 Abc::IInt32ArrayProperty m_trimOrderProperty;
350 Abc::IFloatArrayProperty m_trimKnotProperty;
351 Abc::IFloatArrayProperty m_trimMinProperty;
352 Abc::IFloatArrayProperty m_trimMaxProperty;
353 Abc::IFloatArrayProperty m_trimUProperty;
354 Abc::IFloatArrayProperty m_trimVProperty;
355 Abc::IFloatArrayProperty m_trimWProperty;
356
357 bool m_hasTrimCurve;
358};
359
360//-*****************************************************************************
361typedef Abc::ISchemaObject<INuPatchSchema> INuPatch;
362
363typedef Util::shared_ptr< INuPatch > INuPatchPtr;
364
365} // End namespace ALEMBIC_VERSION_NS
366
367using namespace ALEMBIC_VERSION_NS;
368
369} // End namespace AbcGeom
370} // End namespace Alembic
371
372#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::ISchemaObject
Definition ISchemaObject.h:56
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IGeomBaseSchema< NuPatchSchemaInfo >::IGeomBaseSchema
IGeomBaseSchema()
Definition IGeomBase.h:76
Alembic::AbcGeom::ALEMBIC_VERSION_NS::INuPatchSchema::Sample
Definition INuPatch.h:55
Alembic::AbcGeom::ALEMBIC_VERSION_NS::INuPatchSchema::getTimeSampling
AbcA::TimeSamplingPtr getTimeSampling() const
Time information.
Definition INuPatch.h:221
Alembic::AbcGeom::ALEMBIC_VERSION_NS::INuPatchSchema::ALEMBIC_OVERRIDE_OPERATOR_BOOL
ALEMBIC_OVERRIDE_OPERATOR_BOOL(INuPatchSchema::valid())
Alembic::AbcGeom::ALEMBIC_VERSION_NS::INuPatchSchema::INuPatchSchema
INuPatchSchema(const ICompoundProperty &iProp, const Abc::Argument &iArg0=Abc::Argument(), const Abc::Argument &iArg1=Abc::Argument())
Definition INuPatch.h:196
Alembic::AbcGeom::ALEMBIC_VERSION_NS::INuPatchSchema::isConstant
bool isConstant() const
Definition INuPatch.h:218
Alembic::AbcGeom::ALEMBIC_VERSION_NS::INuPatchSchema::valid
bool valid() const
Definition INuPatch.h:307
Alembic::AbcGeom::ALEMBIC_VERSION_NS::INuPatchSchema::INuPatchSchema
INuPatchSchema()
The default constructor.
Definition INuPatch.h:172
Alembic::AbcGeom::ALEMBIC_VERSION_NS::INuPatchSchema::reset
void reset()
Definition INuPatch.h:275
Alembic::AbcGeom::ALEMBIC_VERSION_NS::INuPatchSchema::INuPatchSchema
INuPatchSchema(const ICompoundProperty &iParent, const std::string &iName, const Abc::Argument &iArg0=Abc::Argument(), const Abc::Argument &iArg1=Abc::Argument())
Definition INuPatch.h:183
Alembic::AbcGeom::ALEMBIC_VERSION_NS::INuPatchSchema::getNumSamples
size_t getNumSamples() const
Definition INuPatch.h:209
Alembic::AbcGeom::ALEMBIC_VERSION_NS::INuPatchSchema::getTopologyVariance
MeshTopologyVariance getTopologyVariance() const
Definition INuPatch.cpp:64
Alembic::AbcGeom::ALEMBIC_VERSION_NS::INuPatchSchema::this_type
INuPatchSchema this_type
Definition INuPatch.h:164
Alembic
Alembic namespace ...
Definition ArchiveInfo.cpp:39