HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 
46 namespace Alembic {
47 namespace AbcGeom {
48 namespace ALEMBIC_VERSION_NS {
49 
50 //-*****************************************************************************
51 class ALEMBIC_EXPORT INuPatchSchema : public IGeomBaseSchema<NuPatchSchemaInfo>
52 {
53 public:
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 
132  int32_t m_numU;
133  int32_t m_numV;
134  int32_t m_uOrder;
135  int32_t m_vOrder;
139 
140  // trim curve
141  int32_t m_trimNumLoops;
152 
153  // bounds
155 
156  };
157 
158  //-*************************************************************************
159  // NuPatch Schema
160  //-*************************************************************************
161 public:
162  //! By convention we always define this_type in AbcGeom classes.
163  //! Used by unspecified-bool-type conversion below
166 
167  //-*************************************************************************
168  // CONSTRUCTION, DESTRUCTION, ASSIGNMENT
169  //-*************************************************************************
170 
171  //! The default constructor
173 
174  //! copy constructor
176  : IGeomBaseSchema<NuPatchSchemaInfo>()
177  {
178  *this = iCopy;
179  }
180 
181  //! This templated, explicit function creates a new scalar property reader.
182  //! The first argument is any Abc (or AbcCoreAbstract) object
183  //! which can intrusively be converted to an CompoundPropertyReaderPtr
184  //! to use as a parent, from which the error handler policy for
185  //! inheritance is also derived. The remaining optional arguments
186  //! can be used to override the ErrorHandlerPolicy and to specify
187  //! schema interpretation matching.
188  template <class CPROP_PTR>
189  INuPatchSchema( CPROP_PTR iParent,
190  const std::string &iName,
191  const Abc::Argument &iArg0 = Abc::Argument(),
192  const Abc::Argument &iArg1 = Abc::Argument() )
193  : IGeomBaseSchema<NuPatchSchemaInfo>( iParent, iName,
194  iArg0, iArg1 )
195  {
196  init( iArg0, iArg1 );
197  }
198 
199  //! This constructor is the same as above, but with default
200  //! schema name used.
201  template <class CPROP_PTR>
202  explicit INuPatchSchema( CPROP_PTR iParent,
203  const Abc::Argument &iArg0 = Abc::Argument(),
204  const Abc::Argument &iArg1 = Abc::Argument() )
205 
206  : IGeomBaseSchema<NuPatchSchemaInfo>( iParent,
207  iArg0, iArg1 )
208  {
209  init( iArg0, iArg1 );
210  }
211 
212  //! Wrap an existing schema object
213  template <class CPROP_PTR>
214  INuPatchSchema( CPROP_PTR iThis,
215  Abc::WrapExistingFlag iFlag,
216  const Abc::Argument &iArg0 = Abc::Argument(),
217  const Abc::Argument &iArg1 = Abc::Argument() )
218 
219  : IGeomBaseSchema<NuPatchSchemaInfo>( iThis, iFlag, iArg0, iArg1 )
220  {
221  init( iArg0, iArg1 );
222  }
223 
224  //! Return the number of samples contained in the property.
225  //! This can be any number, including zero.
226  //! This returns the number of samples that were written, independently
227  //! of whether or not they were constant.
228  size_t getNumSamples() const
229  { return m_positionsProperty.getNumSamples(); }
230 
231  //! Return the topological variance.
232  //! This indicates how the mesh may change.
233  MeshTopologyVariance getTopologyVariance() const;
234 
235  //! Ask if we're constant - no change in value amongst samples,
236  //! regardless of the time sampling.
237  bool isConstant() const { return getTopologyVariance() == kConstantTopology; }
238 
239  //! Time information.
241  {
242  return m_positionsProperty.getTimeSampling();
243  }
244 
245  void get( sample_type &oSample,
246  const Abc::ISampleSelector &iSS = Abc::ISampleSelector() ) const;
247 
249  {
250  Sample smp;
251  get( smp, iSS );
252  return smp;
253  }
254 
255  Abc::IP3fArrayProperty getPositionsProperty() const { return m_positionsProperty; }
256  Abc::IFloatArrayProperty getUKnotsProperty() const { return m_uKnotProperty; }
257  Abc::IFloatArrayProperty getVKnotsProperty() const { return m_vKnotProperty; }
258 
260  {
261  return m_velocitiesProperty;
262  }
263 
264  // if this property is invalid then the weight for every point is 1
266  {
267  return m_positionWeightsProperty;
268  }
269 
271  {
272  return m_normalsParam;
273  }
274 
276  {
277  return m_uvsParam;
278  }
279 
280 
281  bool hasTrimCurve() const { return m_hasTrimCurve; }
282  bool trimCurveTopologyIsHomogenous() const;
283  bool trimCurveTopologyIsConstant() const;
284 
285 
286  //-*************************************************************************
287  // ABC BASE MECHANISMS
288  // These functions are used by Abc to deal with errors, rewrapping,
289  // and so on.
290  //-*************************************************************************
291 
292  //! Reset returns this function set to an empty, default
293  //! state.
294  void reset()
295  {
296  m_positionsProperty.reset();
297  m_velocitiesProperty.reset();
298  m_numUProperty.reset();
299  m_numVProperty.reset();
300  m_uOrderProperty.reset();
301  m_vOrderProperty.reset();
302  m_uKnotProperty.reset();
303  m_vKnotProperty.reset();
304  m_positionWeightsProperty.reset();
305 
306  m_normalsParam.reset();
307  m_uvsParam.reset();
308 
309  // reset trim curve attributes
310  m_trimNumLoopsProperty.reset();
311  m_trimNumCurvesProperty.reset();
312  m_trimNumVerticesProperty.reset();
313  m_trimOrderProperty.reset();
314  m_trimKnotProperty.reset();
315  m_trimMinProperty.reset();
316  m_trimMaxProperty.reset();
317  m_trimUProperty.reset();
318  m_trimVProperty.reset();
319  m_trimWProperty.reset();
320 
322  }
323 
324  //! Valid returns whether this function set is
325  //! valid.
326  bool valid() const
327  {
329  m_positionsProperty.valid() &&
330  m_numUProperty.valid() &&
331  m_numVProperty.valid() &&
332  m_uOrderProperty.valid() &&
333  m_vOrderProperty.valid() &&
334  m_uKnotProperty.valid() &&
335  m_vKnotProperty.valid() );
336  }
337 
338  //! unspecified-bool-type operator overload.
339  //! ...
341 
342 protected:
343  bool hasTrimProps() const;
344 
345 protected:
346  void init( const Abc::Argument &iArg0,
347  const Abc::Argument &iArg1 );
348 
349  // required properties
357 
358  // optional
363 
364  // optional trim curve properties
375 
377 };
378 
379 //-*****************************************************************************
381 
382 typedef Util::shared_ptr< INuPatch > INuPatchPtr;
383 
384 } // End namespace ALEMBIC_VERSION_NS
385 
386 using namespace ALEMBIC_VERSION_NS;
387 
388 } // End namespace AbcGeom
389 } // End namespace Alembic
390 
391 #endif
#define ALEMBIC_OPERATOR_BOOL(PASS_COND)
Definition: OperatorBool.h:42
INuPatchSchema(CPROP_PTR iParent, const std::string &iName, const Abc::Argument &iArg0=Abc::Argument(), const Abc::Argument &iArg1=Abc::Argument())
Definition: INuPatch.h:189
Abc::FloatArraySamplePtr getTrimKnots() const
Definition: INuPatch.h:80
Alembic::Util::shared_ptr< Int32ArraySample > Int32ArraySamplePtr
Sample getValue(const Abc::ISampleSelector &iSS=Abc::ISampleSelector()) const
Definition: INuPatch.h:248
Alembic::Util::shared_ptr< V3fArraySample > V3fArraySamplePtr
GLsizei const GLchar *const * string
Definition: glcorearb.h:813
Util::shared_ptr< INuPatch > INuPatchPtr
Definition: INuPatch.h:382
INuPatchSchema(CPROP_PTR iParent, const Abc::Argument &iArg0=Abc::Argument(), const Abc::Argument &iArg1=Abc::Argument())
Definition: INuPatch.h:202
AbcA::TimeSamplingPtr getTimeSampling() const
Time information.
Definition: INuPatch.h:240
Abc::Int32ArraySamplePtr getTrimNumCurves() const
Definition: INuPatch.h:78
Abc::Int32ArraySamplePtr getTrimOrders() const
Definition: INuPatch.h:79
Alembic::Util::shared_ptr< FloatArraySample > FloatArraySamplePtr
Abc::IInt32ArrayProperty m_trimNumVerticesProperty
Definition: INuPatch.h:366
Alembic::Util::shared_ptr< TimeSampling > TimeSamplingPtr
Definition: TimeSampling.h:137
INuPatchSchema(CPROP_PTR iThis, Abc::WrapExistingFlag iFlag, const Abc::Argument &iArg0=Abc::Argument(), const Abc::Argument &iArg1=Abc::Argument())
Wrap an existing schema object.
Definition: INuPatch.h:214
Abc::FloatArraySamplePtr getPositionWeights() const
Definition: INuPatch.h:73
Abc::IFloatArrayProperty getUKnotsProperty() const
Definition: INuPatch.h:256
Abc::IFloatArrayProperty m_positionWeightsProperty
Definition: INuPatch.h:360
#define ALEMBIC_OVERRIDE_OPERATOR_BOOL(PASS_COND)
Definition: OperatorBool.h:56
Abc::IV3fArrayProperty getVelocitiesProperty() const
Definition: INuPatch.h:259
Box< V3d > Box3d
Definition: ImathBox.h:139
Abc::IFloatArrayProperty getPositionWeightsProperty() const
Definition: INuPatch.h:265
Abc::ISchemaObject< INuPatchSchema > INuPatch
Definition: INuPatch.h:380
INuPatchSchema(const INuPatchSchema &iCopy)
copy constructor
Definition: INuPatch.h:175
Abc::FloatArraySamplePtr getTrimMaxes() const
Definition: INuPatch.h:82
Abc::IFloatArrayProperty getVKnotsProperty() const
Definition: INuPatch.h:257
#define ALEMBIC_EXPORT
Definition: Export.h:51
Abc::Int32ArraySamplePtr getTrimNumVertices() const
Definition: INuPatch.h:77
Abc::IP3fArrayProperty getPositionsProperty() const
Definition: INuPatch.h:255
Alembic::Util::shared_ptr< P3fArraySample > P3fArraySamplePtr
#define ALEMBIC_VERSION_NS
Definition: Foundation.h:104