HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
OPoints.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_OPoints_h_
38 #define _Alembic_AbcGeom_OPoints_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 OPointsSchema : public OGeomBaseSchema<PointsSchemaInfo>
52 {
53 public:
54  //-*************************************************************************
55  // POINTS SCHEMA SAMPLE TYPE
56  //-*************************************************************************
57  class Sample
58  {
59  public:
60  //! Creates a default sample with no data in it.
61  //! ...
62  Sample() { reset(); }
63 
64  //! Creates a sample with position data but no id
65  //! data. For specifying samples after the first one
67  const Abc::V3fArraySample &iVelocities = Abc::V3fArraySample(),
68  const OFloatGeomParam::Sample &iWidths = \
69  OFloatGeomParam::Sample() )
70  : m_positions( iPos )
71  , m_velocities( iVelocities )
72  , m_widths( iWidths )
73  {}
74 
75  //! Creates a sample with position data and id data. The first
76  //! sample must be full like this. Subsequent samples may also
77  //! be full like this, which would indicate a change of topology
79  const Abc::UInt64ArraySample &iId,
80  const Abc::V3fArraySample &iVelocities = Abc::V3fArraySample(),
81  const OFloatGeomParam::Sample &iWidths = \
82  OFloatGeomParam::Sample() )
83  : m_positions( iPos )
84  , m_velocities( iVelocities )
85  , m_ids( iId )
86  , m_widths( iWidths )
87  {}
88 
89  // positions accessor
90  const Abc::P3fArraySample &getPositions() const { return m_positions; }
91  void setPositions( const Abc::P3fArraySample &iSmp )
92  { m_positions = iSmp; }
93 
94  // ids accessor
95  const Abc::UInt64ArraySample &getIds() const { return m_ids; }
96  void setIds( const Abc::UInt64ArraySample &iSmp )
97  { m_ids = iSmp; }
98 
99  // velocities accessor
100  const Abc::V3fArraySample &getVelocities() const { return m_velocities; }
101  void setVelocities( const Abc::V3fArraySample &iVelocities )
102  { m_velocities = iVelocities; }
103 
104  // widths accessor
105  const OFloatGeomParam::Sample &getWidths() const { return m_widths; }
106  void setWidths( const OFloatGeomParam::Sample &iWidths )
107  { m_widths = iWidths; }
108 
109  const Abc::Box3d &getSelfBounds() const { return m_selfBounds; }
110  void setSelfBounds( const Abc::Box3d &iBnds )
111  { m_selfBounds = iBnds; }
112 
113  void reset()
114  {
115  m_positions.reset();
116  m_velocities.reset();
117  m_ids.reset();
118  m_widths.reset();
119 
120  m_selfBounds.makeEmpty();
121  }
122 
123  protected:
127  OFloatGeomParam::Sample m_widths;
128 
130  };
131 
132  //-*************************************************************************
133  // POINTS SCHEMA
134  //-*************************************************************************
135 public:
136  //! By convention we always define this_type in AbcGeom classes.
137  //! Used by unspecified-bool-type conversion below
139 
140  //-*************************************************************************
141  // CONSTRUCTION, DESTRUCTION, ASSIGNMENT
142  //-*************************************************************************
143 
144  //! The default constructor creates an empty OPointsSchema
145  //! ...
147 
148  //! This templated, primary constructor creates a new poly mesh writer.
149  //! The first argument is any Abc (or AbcCoreAbstract) object
150  //! which can intrusively be converted to an CompoundPropertyWriterPtr
151  //! to use as a parent, from which the error handler policy for
152  //! inheritance is also derived. The remaining optional arguments
153  //! can be used to override the ErrorHandlerPolicy, to specify
154  //! MetaData, and to set TimeSamplingType.
155  template <class CPROP_PTR>
156  OPointsSchema( CPROP_PTR iParent,
157  const std::string &iName,
158 
159  const Abc::Argument &iArg0 = Abc::Argument(),
160  const Abc::Argument &iArg1 = Abc::Argument(),
161  const Abc::Argument &iArg2 = Abc::Argument() )
162  : OGeomBaseSchema<PointsSchemaInfo>(
163  GetCompoundPropertyWriterPtr( iParent ),
164  iName, iArg0, iArg1, iArg2 )
165  {
166  AbcA::TimeSamplingPtr tsPtr =
167  Abc::GetTimeSampling( iArg0, iArg1, iArg2 );
168  uint32_t tsIndex =
169  Abc::GetTimeSamplingIndex( iArg0, iArg1, iArg2 );
170 
171  // if we specified a valid TimeSamplingPtr, use it to determine the
172  // index otherwise we'll use the index, which defaults to the intrinsic
173  // 0 index
174  if (tsPtr)
175  {
176  tsIndex = GetCompoundPropertyWriterPtr( iParent )->getObject(
177  )->getArchive()->addTimeSampling(*tsPtr);
178  }
179 
180  // Meta data and error handling are eaten up by
181  // the super type, so all that's left is time sampling.
182  init( tsIndex );
183  }
184 
185  template <class CPROP_PTR>
186  explicit OPointsSchema( CPROP_PTR iParent,
187  const Abc::Argument &iArg0 = Abc::Argument(),
188  const Abc::Argument &iArg1 = Abc::Argument(),
189  const Abc::Argument &iArg2 = Abc::Argument() )
190  : OGeomBaseSchema<PointsSchemaInfo>(
191  GetCompoundPropertyWriterPtr( iParent ),
192  iArg0, iArg1, iArg2 )
193  {
194  AbcA::TimeSamplingPtr tsPtr =
195  Abc::GetTimeSampling( iArg0, iArg1, iArg2 );
196  uint32_t tsIndex =
197  Abc::GetTimeSamplingIndex( iArg0, iArg1, iArg2 );
198 
199  // if we specified a valid TimeSamplingPtr, use it to determine the
200  // index otherwise we'll use the index, which defaults to the intrinsic
201  // 0 index
202  if (tsPtr)
203  {
204  tsIndex = GetCompoundPropertyWriterPtr( iParent )->getObject(
205  )->getArchive()->addTimeSampling(*tsPtr);
206  }
207 
208  // Meta data and error handling are eaten up by
209  // the super type, so all that's left is time sampling.
210  init( tsIndex );
211  }
212 
213  //! Copy constructor.
215  : OGeomBaseSchema<PointsSchemaInfo>()
216  {
217  *this = iCopy;
218  }
219 
220  //! Default assignment operator used.
221 
222  //-*************************************************************************
223  // SCHEMA STUFF
224  //-*************************************************************************
225 
226  //! Return the time sampling
228  { return m_positionsProperty.getTimeSampling(); }
229 
230  //-*************************************************************************
231  // SAMPLE STUFF
232  //-*************************************************************************
233 
234  //! Get number of samples written so far.
235  //! ...
236  size_t getNumSamples() const
237  { return m_positionsProperty.getNumSamples(); }
238 
239  //! Set a sample
240  void set( const Sample &iSamp );
241 
242  //! Set from previous sample. Will apply to each of positions,
243  //! ids, velocities, and widths
244  void setFromPrevious( );
245 
246  void setTimeSampling( uint32_t iIndex );
247  void setTimeSampling( AbcA::TimeSamplingPtr iTime );
248 
249  //-*************************************************************************
250  // ABC BASE MECHANISMS
251  // These functions are used by Abc to deal with errors, validity,
252  // and so on.
253  //-*************************************************************************
254 
255  //! Reset returns this function set to an empty, default
256  //! state.
257  void reset()
258  {
259  m_positionsProperty.reset();
260  m_idsProperty.reset();
261  m_velocitiesProperty.reset();
262  m_widthsParam.reset();
263 
265  }
266 
267  //! Valid returns whether this function set is
268  //! valid.
269  bool valid() const
270  {
272  m_positionsProperty.valid() &&
273  m_idsProperty.valid() );
274  }
275 
276  //! unspecified-bool-type operator overload.
277  //! ...
279 
280 protected:
281  void init( uint32_t iTsIdx );
282 
287 
288 };
289 
290 //-*****************************************************************************
291 // SCHEMA OBJECT
292 //-*****************************************************************************
294 
295 typedef Util::shared_ptr< OPoints > OPointsPtr;
296 
297 } // End namespace ALEMBIC_VERSION_NS
298 
299 using namespace ALEMBIC_VERSION_NS;
300 
301 } // End namespace AbcGeom
302 } // End namespace Alembic
303 
304 #endif
Sample(const Abc::P3fArraySample &iPos, const Abc::V3fArraySample &iVelocities=Abc::V3fArraySample(), const OFloatGeomParam::Sample &iWidths=OFloatGeomParam::Sample())
Definition: OPoints.h:66
void setWidths(const OFloatGeomParam::Sample &iWidths)
Definition: OPoints.h:106
OPointsSchema(CPROP_PTR iParent, const Abc::Argument &iArg0=Abc::Argument(), const Abc::Argument &iArg1=Abc::Argument(), const Abc::Argument &iArg2=Abc::Argument())
Definition: OPoints.h:186
GLsizei const GLchar *const * string
Definition: glcorearb.h:813
void setIds(const Abc::UInt64ArraySample &iSmp)
Definition: OPoints.h:96
const Abc::V3fArraySample & getVelocities() const
Definition: OPoints.h:100
void setVelocities(const Abc::V3fArraySample &iVelocities)
Definition: OPoints.h:101
AbcA::TimeSamplingPtr getTimeSampling() const
Default assignment operator used.
Definition: OPoints.h:227
const OFloatGeomParam::Sample & getWidths() const
Definition: OPoints.h:105
Alembic::Util::shared_ptr< TimeSampling > TimeSamplingPtr
Definition: TimeSampling.h:137
Abc::OSchemaObject< OPointsSchema > OPoints
Definition: OPoints.h:293
OPointsSchema(const OPointsSchema &iCopy)
Copy constructor.
Definition: OPoints.h:214
#define ALEMBIC_OVERRIDE_OPERATOR_BOOL(PASS_COND)
Definition: OperatorBool.h:56
void setPositions(const Abc::P3fArraySample &iSmp)
Definition: OPoints.h:91
const Abc::P3fArraySample & getPositions() const
Definition: OPoints.h:90
Box< V3d > Box3d
Definition: ImathBox.h:139
AbcA::TimeSamplingPtr GetTimeSampling(const Argument &iArg0, const Argument &iArg1=Argument(), const Argument &iArg2=Argument())
Definition: Argument.h:259
Util::shared_ptr< OPoints > OPointsPtr
Definition: OPoints.h:295
AbcA::CompoundPropertyWriterPtr GetCompoundPropertyWriterPtr(AbcA::CompoundPropertyWriterPtr iPtr)
Definition: Foundation.h:164
Sample(const Abc::P3fArraySample &iPos, const Abc::UInt64ArraySample &iId, const Abc::V3fArraySample &iVelocities=Abc::V3fArraySample(), const OFloatGeomParam::Sample &iWidths=OFloatGeomParam::Sample())
Definition: OPoints.h:78
#define ALEMBIC_EXPORT
Definition: Export.h:51
OPointsSchema(CPROP_PTR iParent, const std::string &iName, const Abc::Argument &iArg0=Abc::Argument(), const Abc::Argument &iArg1=Abc::Argument(), const Abc::Argument &iArg2=Abc::Argument())
Definition: OPoints.h:156
uint32_t GetTimeSamplingIndex(const Argument &iArg0, const Argument &iArg1=Argument(), const Argument &iArg2=Argument())
Definition: Argument.h:272
const Abc::UInt64ArraySample & getIds() const
Definition: OPoints.h:95
#define ALEMBIC_VERSION_NS
Definition: Foundation.h:104