Alembic Version 1.1
Loading...
Searching...
No Matches
INuPatch.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_INuPatch_h
38#define Alembic_AbcGeom_INuPatch_h
39
40#include <Alembic/Util/Export.h>
45
46namespace Alembic {
47namespace AbcGeom {
48namespace ALEMBIC_VERSION_NS {
49
50//-*****************************************************************************
51class ALEMBIC_EXPORT INuPatchSchema : public IGeomBaseSchema<NuPatchSchemaInfo>
52{
53public:
54 class Sample
55 {
56 public:
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
125
126 protected:
127
128 friend class INuPatchSchema;
129
132 int32_t m_numU;
133 int32_t m_numV;
134 int32_t m_uOrder;
135 int32_t m_vOrder;
139
140 // trim curve
152
153 // bounds
154 Abc::Box3d m_selfBounds;
155
156 };
157
158 //-*************************************************************************
159 // NuPatch Schema
160 //-*************************************************************************
161public:
166
167 //-*************************************************************************
168 // CONSTRUCTION, DESTRUCTION, ASSIGNMENT
169 //-*************************************************************************
170
173 {
174 m_hasTrimCurve = false;
175 }
176
179 : IGeomBaseSchema<NuPatchSchemaInfo>()
180 {
181 *this = iCopy;
182 }
183
191 const std::string &iName,
192 const Abc::Argument &iArg0 = Abc::Argument(),
193 const Abc::Argument &iArg1 = Abc::Argument() )
194 : IGeomBaseSchema<NuPatchSchemaInfo>( iParent, iName, iArg0, iArg1 )
195 {
196 init( iArg0, iArg1 );
197 }
198
203 explicit INuPatchSchema( const ICompoundProperty &iProp,
204 const Abc::Argument &iArg0 = Abc::Argument(),
205 const Abc::Argument &iArg1 = Abc::Argument() )
206
207 : IGeomBaseSchema<NuPatchSchemaInfo>( iProp, iArg0, iArg1 )
208 {
209 init( iArg0, iArg1 );
210 }
211
216 size_t getNumSamples() const
217 { return m_positionsProperty.getNumSamples(); }
218
222
225 bool isConstant() const { return getTopologyVariance() == kConstantTopology; }
226
229 {
230 return m_positionsProperty.getTimeSampling();
231 }
232
233 void get( sample_type &oSample,
234 const Abc::ISampleSelector &iSS = Abc::ISampleSelector() ) const;
235
237 {
238 Sample smp;
239 get( smp, iSS );
240 return smp;
241 }
242
243 Abc::IP3fArrayProperty getPositionsProperty() const { return m_positionsProperty; }
244 Abc::IFloatArrayProperty getUKnotsProperty() const { return m_uKnotProperty; }
245 Abc::IFloatArrayProperty getVKnotsProperty() const { return m_vKnotProperty; }
246
248 {
249 return m_velocitiesProperty;
250 }
251
252 // if this property is invalid then the weight for every point is 1
254 {
255 return m_positionWeightsProperty;
256 }
257
259 {
260 return m_normalsParam;
261 }
262
264 {
265 return m_uvsParam;
266 }
267
268
269 bool hasTrimCurve() const { return m_hasTrimCurve; }
272
273
274 //-*************************************************************************
275 // ABC BASE MECHANISMS
276 // These functions are used by Abc to deal with errors, rewrapping,
277 // and so on.
278 //-*************************************************************************
279
282 void reset()
283 {
284 m_positionsProperty.reset();
285 m_velocitiesProperty.reset();
286 m_numUProperty.reset();
287 m_numVProperty.reset();
288 m_uOrderProperty.reset();
289 m_vOrderProperty.reset();
290 m_uKnotProperty.reset();
291 m_vKnotProperty.reset();
292 m_positionWeightsProperty.reset();
293
294 m_normalsParam.reset();
295 m_uvsParam.reset();
296
297 // reset trim curve attributes
298 m_trimNumLoopsProperty.reset();
299 m_trimNumCurvesProperty.reset();
300 m_trimNumVerticesProperty.reset();
301 m_trimOrderProperty.reset();
302 m_trimKnotProperty.reset();
303 m_trimMinProperty.reset();
304 m_trimMaxProperty.reset();
305 m_trimUProperty.reset();
306 m_trimVProperty.reset();
307 m_trimWProperty.reset();
308
310 }
311
314 bool valid() const
315 {
317 m_positionsProperty.valid() &&
318 m_numUProperty.valid() &&
319 m_numVProperty.valid() &&
320 m_uOrderProperty.valid() &&
321 m_vOrderProperty.valid() &&
322 m_uKnotProperty.valid() &&
323 m_vKnotProperty.valid() );
324 }
325
328 ALEMBIC_OVERRIDE_OPERATOR_BOOL( INuPatchSchema::valid() );
329
330protected:
331 bool hasTrimProps() const;
332
333protected:
334 void init( const Abc::Argument &iArg0,
335 const Abc::Argument &iArg1 );
336
337 // required properties
345
346 // optional
351
352 // optional trim curve properties
363
365};
366
367//-*****************************************************************************
369
370typedef Util::shared_ptr< INuPatch > INuPatchPtr;
371
372} // End namespace ALEMBIC_VERSION_NS
373
374using namespace ALEMBIC_VERSION_NS;
375
376} // End namespace AbcGeom
377} // End namespace Alembic
378
379#endif
#define ALEMBIC_EXPORT
Definition Export.h:51
#define ALEMBIC_VERSION_NS
Definition Foundation.h:105
Abc::FloatArraySamplePtr getPositionWeights() const
Definition INuPatch.h:73
Abc::Int32ArraySamplePtr getTrimNumVertices() const
Definition INuPatch.h:77
Abc::IV3fArrayProperty getVelocitiesProperty() const
Definition INuPatch.h:247
Abc::IFloatArrayProperty getUKnotsProperty() const
Definition INuPatch.h:244
AbcA::TimeSamplingPtr getTimeSampling() const
Time information.
Definition INuPatch.h:228
Abc::IFloatArrayProperty getVKnotsProperty() const
Definition INuPatch.h:245
INuPatchSchema(const ICompoundProperty &iProp, const Abc::Argument &iArg0=Abc::Argument(), const Abc::Argument &iArg1=Abc::Argument())
Definition INuPatch.h:203
void get(sample_type &oSample, const Abc::ISampleSelector &iSS=Abc::ISampleSelector()) const
INuPatchSchema(const INuPatchSchema &iCopy)
copy constructor
Definition INuPatch.h:178
Sample getValue(const Abc::ISampleSelector &iSS=Abc::ISampleSelector()) const
Definition INuPatch.h:236
INuPatchSchema(const ICompoundProperty &iParent, const std::string &iName, const Abc::Argument &iArg0=Abc::Argument(), const Abc::Argument &iArg1=Abc::Argument())
Definition INuPatch.h:190
Abc::IP3fArrayProperty getPositionsProperty() const
Definition INuPatch.h:243
Abc::IFloatArrayProperty getPositionWeightsProperty() const
Definition INuPatch.h:253
void init(const Abc::Argument &iArg0, const Abc::Argument &iArg1)
Alembic::Util::shared_ptr< TimeSampling > TimeSamplingPtr
Util::shared_ptr< INuPatch > INuPatchPtr
Definition INuPatch.h:370
Alembic::Util::shared_ptr< FloatArraySample > FloatArraySamplePtr
Alembic::Util::shared_ptr< Int32ArraySample > Int32ArraySamplePtr
Alembic::Util::shared_ptr< V3fArraySample > V3fArraySamplePtr
Alembic::Util::shared_ptr< P3fArraySample > P3fArraySamplePtr
Alembic namespace ...
Definition ArchiveInfo.h:46