HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ICurves.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_ICurves_h_
38 #define _Alembic_AbcGeom_ICurves_h_
39 
40 #include <Alembic/Util/Export.h>
42 #include <Alembic/AbcGeom/Basis.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 
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() { return m_orders; }
81  Abc::FloatArraySamplePtr getKnots() { return m_knots; }
82 
83  // if this is NULL then the weight value of the position for each
84  // point is 1
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;
120 
122 
123  // type, wrap, and nVertices
127 
131  };
132 
133  //-*************************************************************************
134  // CURVE SCHEMA
135  //-*************************************************************************
136 public:
137  //! By convention we always define this_type in AbcGeom classes.
138  //! Used by unspecified-bool-type conversion below
140 
142 
143  //-*************************************************************************
144  // CONSTRUCTION, DESTRUCTION, ASSIGNMENT
145  //-*************************************************************************
146 
147  //! The default constructor creates an empty ICurvesSchema
148  //! ...
150 
151  //! This templated, explicit function creates a new scalar property reader.
152  //! The first argument is any Abc (or AbcCoreAbstract) object
153  //! which can intrusively be converted to an CompoundPropertyReaderPtr
154  //! to use as a parent, from which the error handler policy for
155  //! inheritance is also derived. The remaining optional arguments
156  //! can be used to override the ErrorHandlerPolicy and to specify
157  //! schema interpretation matching.
158  template <class CPROP_PTR>
159  ICurvesSchema( CPROP_PTR iParent,
160  const std::string &iName,
161  const Abc::Argument &iArg0 = Abc::Argument(),
162  const Abc::Argument &iArg1 = Abc::Argument() )
163  : IGeomBaseSchema<CurvesSchemaInfo>( iParent, iName, iArg0, iArg1 )
164  {
165  init( iArg0, iArg1 );
166  }
167 
168  //! This constructor is the same as above, but with default
169  //! schema name used.
170  template <class CPROP_PTR>
171  explicit ICurvesSchema( CPROP_PTR iParent,
172  const Abc::Argument &iArg0 = Abc::Argument(),
173  const Abc::Argument &iArg1 = Abc::Argument() )
174  : IGeomBaseSchema<CurvesSchemaInfo>( iParent, iArg0, iArg1 )
175  {
176  init( iArg0, iArg1 );
177  }
178 
179  //! Wrap an existing schema object
180  template <class CPROP_PTR>
181  ICurvesSchema( CPROP_PTR iThis,
182  Abc::WrapExistingFlag iFlag,
183  const Abc::Argument &iArg0 = Abc::Argument(),
184  const Abc::Argument &iArg1 = Abc::Argument() )
185  : IGeomBaseSchema<CurvesSchemaInfo>( iThis, iFlag, iArg0, iArg1 )
186  {
187  init( iArg0, iArg1 );
188  }
189 
190  //! Default assignment operator used.
191 
192  ICurvesSchema( const ICurvesSchema &iCopy )
193  : IGeomBaseSchema<CurvesSchemaInfo>()
194  {
195  *this = iCopy;
196  }
197 
198  size_t getNumSamples() const
199  { return m_positionsProperty.getNumSamples(); }
200 
201  //! Return the topological variance.
202  //! This indicates how the mesh may change.
203  MeshTopologyVariance getTopologyVariance() const;
204 
205  //! Ask if we're constant - no change in value amongst samples,
206  //! regardless of the time sampling.
207  bool isConstant() const
208  { return getTopologyVariance() == kConstantTopology; }
209 
210  //! Time sampling type.
211  //!
213  {
214  return m_positionsProperty.getTimeSampling();
215  }
216 
217  //-*************************************************************************
218  void get( sample_type &oSample,
219  const Abc::ISampleSelector &iSS = Abc::ISampleSelector() ) const;
220 
222  Abc::ISampleSelector() ) const
223  {
224  sample_type smp;
225  get( smp, iSS );
226  return smp;
227  }
228 
230  {
231  return m_velocitiesProperty;
232  }
233 
235  {
236  return m_positionsProperty;
237  }
238 
240  {
241  return m_nVerticesProperty;
242  }
243 
244  // if this property is invalid then the weight for every point is 1
246  {
247  return m_positionWeightsProperty;
248  }
249 
251  {
252  return m_uvsParam;
253  }
254 
256  {
257  return m_normalsParam;
258  }
259 
261  {
262  return m_widthsParam;
263  }
264 
266  {
267  return m_ordersProperty;
268  }
269 
271  {
272  return m_knotsProperty;
273  }
274 
275  //-*************************************************************************
276  // ABC BASE MECHANISMS
277  // These functions are used by Abc to deal with errors, rewrapping,
278  // and so on.
279  //-*************************************************************************
280 
281  //! Reset returns this function set to an empty, default
282  //! state.
283  void reset()
284  {
285  m_positionsProperty.reset();
286  m_velocitiesProperty.reset();
287  m_nVerticesProperty.reset();
288 
289  m_positionWeightsProperty.reset();
290  m_ordersProperty.reset();
291  m_knotsProperty.reset();
292 
293  m_uvsParam.reset();
294  m_normalsParam.reset();
295  m_widthsParam.reset();
296 
297  m_basisAndTypeProperty.reset();
298 
300  }
301 
302  //! Valid returns whether this function set is
303  //! valid.
304  bool valid() const
305  {
307  m_positionsProperty.valid() && m_nVerticesProperty.valid() );
308  }
309 
310  //! unspecified-bool-type operator overload.
311  //! ...
312  ALEMBIC_OVERRIDE_OPERATOR_BOOL( this_type::valid() );
313 
314 protected:
315  void init( const Abc::Argument &iArg0, const Abc::Argument &iArg1 );
316 
320 
321  // contains type, wrap, ubasis, and vbasis.
323 
327 
328  // optional
332 };
333 
334 //-*****************************************************************************
336 
337 typedef Util::shared_ptr< ICurves > ICurvesPtr;
338 
339 } // End namespace ALEMBIC_VERSION_NS
340 
341 using namespace ALEMBIC_VERSION_NS;
342 
343 } // End namespace AbcGeom
344 } // End namespace Alembic
345 
346 #endif
#define ALEMBIC_OPERATOR_BOOL(PASS_COND)
Definition: OperatorBool.h:42
Abc::IUcharArrayProperty getOrdersProperty() const
Definition: ICurves.h:265
Abc::Int32ArraySamplePtr getCurvesNumVertices() const
Definition: ICurves.h:72
Alembic::Util::shared_ptr< Int32ArraySample > Int32ArraySamplePtr
Alembic::Util::shared_ptr< V3fArraySample > V3fArraySamplePtr
GLsizei const GLchar *const * string
Definition: glcorearb.h:813
Abc::IFloatArrayProperty getPositionWeightsProperty() const
Definition: ICurves.h:245
ICurvesSchema(CPROP_PTR iParent, const std::string &iName, const Abc::Argument &iArg0=Abc::Argument(), const Abc::Argument &iArg1=Abc::Argument())
Definition: ICurves.h:159
Abc::IP3fArrayProperty getPositionsProperty() const
Definition: ICurves.h:234
Util::shared_ptr< ICurves > ICurvesPtr
Definition: ICurves.h:337
Abc::FloatArraySamplePtr getPositionWeights() const
Definition: ICurves.h:85
ICurvesSchema(const ICurvesSchema &iCopy)
Default assignment operator used.
Definition: ICurves.h:192
Alembic::Util::shared_ptr< FloatArraySample > FloatArraySamplePtr
sample_type getValue(const Abc::ISampleSelector &iSS=Abc::ISampleSelector()) const
Definition: ICurves.h:221
Alembic::Util::shared_ptr< TimeSampling > TimeSamplingPtr
Definition: TimeSampling.h:137
Alembic::Util::shared_ptr< UcharArraySample > UcharArraySamplePtr
ICurvesSchema(CPROP_PTR iThis, Abc::WrapExistingFlag iFlag, const Abc::Argument &iArg0=Abc::Argument(), const Abc::Argument &iArg1=Abc::Argument())
Wrap an existing schema object.
Definition: ICurves.h:181
#define ALEMBIC_OVERRIDE_OPERATOR_BOOL(PASS_COND)
Definition: OperatorBool.h:56
Abc::IFloatArrayProperty m_positionWeightsProperty
Definition: ICurves.h:329
Abc::IInt32ArrayProperty getNumVerticesProperty() const
Definition: ICurves.h:239
Box< V3d > Box3d
Definition: ImathBox.h:139
Abc::IV3fArrayProperty getVelocitiesProperty() const
Definition: ICurves.h:229
ICurvesSchema(CPROP_PTR iParent, const Abc::Argument &iArg0=Abc::Argument(), const Abc::Argument &iArg1=Abc::Argument())
Definition: ICurves.h:171
AbcA::TimeSamplingPtr getTimeSampling() const
Definition: ICurves.h:212
Abc::ISchemaObject< ICurvesSchema > ICurves
Definition: ICurves.h:335
Abc::IFloatArrayProperty getKnotsProperty() const
Definition: ICurves.h:270
#define ALEMBIC_EXPORT
Definition: Export.h:51
Alembic::Util::shared_ptr< P3fArraySample > P3fArraySamplePtr
#define ALEMBIC_VERSION_NS
Definition: Foundation.h:104