HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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() 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
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 constructor creates a new curves reader.
152  //! The first argument is the parent ICompoundProperty, from which the
153  //! error handler policy for is derived. The second argument is the name
154  //! of the ICompoundProperty that contains this schemas properties. The
155  //! remaining optional arguments can be used to override the
156  //! ErrorHandlerPolicy and to specify schema interpretation matching.
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 
166  //! This constructor wraps an existing ICompoundProperty as the curves
167  //! reader, and the error handler policy is derived from it.
168  //! The remaining optional arguments can be used to override the
169  //! ErrorHandlerPolicy and to specify schema interpretation matching.
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 
178  //! Default assignment operator used.
179 
180  ICurvesSchema( const ICurvesSchema &iCopy )
181  : IGeomBaseSchema<CurvesSchemaInfo>()
182  {
183  *this = iCopy;
184  }
185 
186  size_t getNumSamples() const
187  { return m_positionsProperty.getNumSamples(); }
188 
189  //! Return the topological variance.
190  //! This indicates how the mesh may change.
191  MeshTopologyVariance getTopologyVariance() const;
192 
193  //! Ask if we're constant - no change in value amongst samples,
194  //! regardless of the time sampling.
195  bool isConstant() const
196  { return getTopologyVariance() == kConstantTopology; }
197 
198  //! Time sampling type.
199  //!
201  {
202  return m_positionsProperty.getTimeSampling();
203  }
204 
205  //-*************************************************************************
206  void get( sample_type &oSample,
207  const Abc::ISampleSelector &iSS = Abc::ISampleSelector() ) const;
208 
210  Abc::ISampleSelector() ) const
211  {
212  sample_type smp;
213  get( smp, iSS );
214  return smp;
215  }
216 
218  {
219  return m_velocitiesProperty;
220  }
221 
223  {
224  return m_positionsProperty;
225  }
226 
228  {
229  return m_nVerticesProperty;
230  }
231 
232  // if this property is invalid then the weight for every point is 1
234  {
235  return m_positionWeightsProperty;
236  }
237 
239  {
240  return m_uvsParam;
241  }
242 
244  {
245  return m_normalsParam;
246  }
247 
249  {
250  return m_widthsParam;
251  }
252 
254  {
255  return m_ordersProperty;
256  }
257 
259  {
260  return m_knotsProperty;
261  }
262 
263  //-*************************************************************************
264  // ABC BASE MECHANISMS
265  // These functions are used by Abc to deal with errors, rewrapping,
266  // and so on.
267  //-*************************************************************************
268 
269  //! Reset returns this function set to an empty, default
270  //! state.
271  void reset()
272  {
273  m_positionsProperty.reset();
274  m_velocitiesProperty.reset();
275  m_nVerticesProperty.reset();
276 
277  m_positionWeightsProperty.reset();
278  m_ordersProperty.reset();
279  m_knotsProperty.reset();
280 
281  m_uvsParam.reset();
282  m_normalsParam.reset();
283  m_widthsParam.reset();
284 
285  m_basisAndTypeProperty.reset();
286 
288  }
289 
290  //! Valid returns whether this function set is
291  //! valid.
292  bool valid() const
293  {
295  m_positionsProperty.valid() && m_nVerticesProperty.valid() );
296  }
297 
298  //! unspecified-bool-type operator overload.
299  //! ...
300  ALEMBIC_OVERRIDE_OPERATOR_BOOL( this_type::valid() );
301 
302 protected:
303  void init( const Abc::Argument &iArg0, const Abc::Argument &iArg1 );
304 
308 
309  // contains type, wrap, ubasis, and vbasis.
311 
315 
316  // optional
320 };
321 
322 //-*****************************************************************************
324 
325 typedef Util::shared_ptr< ICurves > ICurvesPtr;
326 
327 } // End namespace ALEMBIC_VERSION_NS
328 
329 using namespace ALEMBIC_VERSION_NS;
330 
331 } // End namespace AbcGeom
332 } // End namespace Alembic
333 
334 #endif
#define ALEMBIC_OPERATOR_BOOL(PASS_COND)
Definition: OperatorBool.h:42
Abc::IUcharArrayProperty getOrdersProperty() const
Definition: ICurves.h:253
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:814
ICurvesSchema(const ICompoundProperty &iProp, const Abc::Argument &iArg0=Abc::Argument(), const Abc::Argument &iArg1=Abc::Argument())
Definition: ICurves.h:170
#define ALEMBIC_EXPORT
Definition: Export.h:51
Abc::IFloatArrayProperty getPositionWeightsProperty() const
Definition: ICurves.h:233
Abc::IP3fArrayProperty getPositionsProperty() const
Definition: ICurves.h:222
Util::shared_ptr< ICurves > ICurvesPtr
Definition: ICurves.h:325
Abc::FloatArraySamplePtr getPositionWeights() const
Definition: ICurves.h:85
ICurvesSchema(const ICurvesSchema &iCopy)
Default assignment operator used.
Definition: ICurves.h:180
Alembic::Util::shared_ptr< FloatArraySample > FloatArraySamplePtr
sample_type getValue(const Abc::ISampleSelector &iSS=Abc::ISampleSelector()) const
Definition: ICurves.h:209
Abc::UcharArraySamplePtr getOrders() const
Definition: ICurves.h:80
Alembic::Util::shared_ptr< TimeSampling > TimeSamplingPtr
Definition: TimeSampling.h:137
ICurvesSchema(const ICompoundProperty &iParent, const std::string &iName, const Abc::Argument &iArg0=Abc::Argument(), const Abc::Argument &iArg1=Abc::Argument())
Definition: ICurves.h:157
Abc::FloatArraySamplePtr getKnots() const
Definition: ICurves.h:81
GLboolean reset
Definition: glad.h:5138
Alembic::Util::shared_ptr< UcharArraySample > UcharArraySamplePtr
#define ALEMBIC_OVERRIDE_OPERATOR_BOOL(PASS_COND)
Definition: OperatorBool.h:56
Abc::IFloatArrayProperty m_positionWeightsProperty
Definition: ICurves.h:317
Abc::IInt32ArrayProperty getNumVerticesProperty() const
Definition: ICurves.h:227
Box< V3d > Box3d
3D box of base type double.
Definition: ImathBox.h:167
Abc::IV3fArrayProperty getVelocitiesProperty() const
Definition: ICurves.h:217
AbcA::TimeSamplingPtr getTimeSampling() const
Definition: ICurves.h:200
Abc::ISchemaObject< ICurvesSchema > ICurves
Definition: ICurves.h:323
Abc::IFloatArrayProperty getKnotsProperty() const
Definition: ICurves.h:258
Alembic::Util::shared_ptr< P3fArraySample > P3fArraySamplePtr
#define ALEMBIC_VERSION_NS
Definition: Foundation.h:88