HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
IFaceSet.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_IFaceSet_h_
38 #define _Alembic_AbcGeom_IFaceSet_h_
39 
40 #include <Alembic/Util/Export.h>
46 
47 namespace Alembic {
48 namespace AbcGeom {
49 namespace ALEMBIC_VERSION_NS {
50 
51 //-*****************************************************************************
52 class ALEMBIC_EXPORT IFaceSetSchema : public IGeomBaseSchema<FaceSetSchemaInfo>
53 {
54 public:
55  //-*************************************************************************
56  // FACESET MESH SCHEMA SAMPLE TYPE
57  //-*************************************************************************
58  class Sample
59  {
60  public:
61  typedef Sample this_type;
62 
63  //! Users never create this data directly
64  Sample() { reset(); }
65 
66  // main stuff
67  Abc::Int32ArraySamplePtr getFaces() const { return m_faces; }
68 
69  // bounds
70  Abc::Box3d getSelfBounds() const { return m_selfBounds; }
71 
72  bool valid() const
73  {
74  return m_faces.get() != 0;
75  }
76 
77  void reset()
78  {
79  m_faces.reset();
80 
81  m_selfBounds.makeEmpty();
82  }
83 
84  ALEMBIC_OPERATOR_BOOL( valid() );
85 
86  protected:
87  friend class IFaceSetSchema;
88 
90 
91 
92  // bounds
94 
95  }; // end IFaceSetSchema::Sample
96 
97  //-*************************************************************************
98  // FACESET SCHEMA
99  //-*************************************************************************
100 public:
101  //! By convention we always define this_type in AbcGeom classes.
102  //! Used by unspecified-bool-type conversion below
104 
105  //-*************************************************************************
106  // CONSTRUCTION, DESTRUCTION, ASSIGNMENT
107  //-*************************************************************************
108 
109  //! The default constructor creates an empty IFaceSetSchema
110  //! ...
112 
113  //! This templated, primary constructor creates a new faceset reader.
114  //! The first argument is any Abc (or AbcCoreAbstract) object
115  //! which can intrusively be converted to an CompoundPropertyWriterPtr
116  //! to use as a parent, from which the error handler policy for
117  //! inheritance is also derived. The remaining optional arguments
118  //! can be used to override the ErrorHandlerPolicy and to specify
119  //! schema interpretation matching.
120  template <class CPROP_PTR>
121  IFaceSetSchema( CPROP_PTR iParent,
122  const std::string &iName,
123 
124  const Abc::Argument &iArg0 = Abc::Argument(),
125  const Abc::Argument &iArg1 = Abc::Argument() )
126  : IGeomBaseSchema<FaceSetSchemaInfo>( iParent, iName,
127  iArg0, iArg1 )
128  {
129  init( iArg0, iArg1 );
130  }
131 
132  //! Same constructor as above, but use the default schema name, ie,
133  //! ".geom".
134  template <class CPROP_PTR>
135  explicit IFaceSetSchema( CPROP_PTR iParent,
136  const Abc::Argument &iArg0 = Abc::Argument(),
137  const Abc::Argument &iArg1 = Abc::Argument() )
138  : IGeomBaseSchema<FaceSetSchemaInfo>( iParent,
139  iArg0, iArg1 )
140  {
141  init( iArg0, iArg1 );
142  }
143 
144  //! wrap an existing schema object
145  template <class CPROP_PTR>
146  IFaceSetSchema( CPROP_PTR iThis,
147  Abc::WrapExistingFlag iFlag,
148 
149  const Abc::Argument &iArg0 = Abc::Argument(),
150  const Abc::Argument &iArg1 = Abc::Argument() )
151  : IGeomBaseSchema<FaceSetSchemaInfo>( iThis, iFlag, iArg0, iArg1 )
152  {
153  init( iArg0, iArg1 );
154  }
155 
156  //! Copy constructor. (explicit copy ctor for msvc bug workaround)
158  : IGeomBaseSchema<FaceSetSchemaInfo>()
159  {
160  *this = iCopy;
161  }
162 
163  //! Default assignment operator used.
164 
165  //-*************************************************************************
166  // SCHEMA STUFF
167  //-*************************************************************************
168 
169 
170  //! if isConstant() is true, the mesh contains no time-varying values
171  bool isConstant() const { return (m_facesProperty.isConstant ()); }
172 
173  //-*************************************************************************
174  // SAMPLE STUFF
175  //-*************************************************************************
176 
177  //! Get number of samples written so far.
178  //! ...
179  size_t getNumSamples() const;
180 
181  //! Return the time sampling
183  {
184  if ( m_facesProperty.valid() )
185  return m_facesProperty.getTimeSampling();
186  return getObject().getArchive().getTimeSampling(0);
187  }
188 
189  void get( Sample &iSamp,
190  const Abc::ISampleSelector &iSS = Abc::ISampleSelector() ) const;
191 
193  {
194  Sample smp;
195  get( smp, iSS );
196  return smp;
197  }
198 
199  FaceSetExclusivity getFaceExclusivity() const;
200 
202  {
203  return m_facesProperty;
204  }
205 
206  //-*************************************************************************
207  // ABC BASE MECHANISMS
208  // These functions are used by Abc to deal with errors, rewrapping,
209  // and so on.
210  //-*************************************************************************
211 
212  //! Reset returns this function set to an empty, default
213  //! state.
214  void reset()
215  {
216  m_facesProperty.reset();
217 
219  }
220 
221  //! Valid returns whether this function set is
222  //! valid.
223  bool valid() const
224  {
226  m_facesProperty.valid() );
227  }
228 
229  //! unspecified-bool-type operator overload.
230  //! ...
232 
233 protected:
234  void init( const Abc::Argument &iArg0, const Abc::Argument &iArg1 );
235 
237 };
238 
239 //-*****************************************************************************
240 // SCHEMA OBJECT
241 //-*****************************************************************************
243 
244 typedef Util::shared_ptr< IFaceSet > IFaceSetPtr;
245 
246 } // End namespace ALEMBIC_VERSION_NS
247 
248 using namespace ALEMBIC_VERSION_NS;
249 
250 } // End namespace AbcGeom
251 } // End namespace Alembic
252 
253 #endif
#define ALEMBIC_OPERATOR_BOOL(PASS_COND)
Definition: OperatorBool.h:42
Util::shared_ptr< IFaceSet > IFaceSetPtr
Definition: IFaceSet.h:244
Alembic::Util::shared_ptr< Int32ArraySample > Int32ArraySamplePtr
GLsizei const GLchar *const * string
Definition: glcorearb.h:813
FaceSetExclusivity
Hint to indicate face membership is mutally exclusive. Some structures that group faces only allow a ...
Alembic::Util::shared_ptr< TimeSampling > TimeSamplingPtr
Definition: TimeSampling.h:137
bool isConstant() const
Default assignment operator used.
Definition: IFaceSet.h:171
Sample()
Users never create this data directly.
Definition: IFaceSet.h:64
IFaceSetSchema(CPROP_PTR iThis, Abc::WrapExistingFlag iFlag, const Abc::Argument &iArg0=Abc::Argument(), const Abc::Argument &iArg1=Abc::Argument())
wrap an existing schema object
Definition: IFaceSet.h:146
AbcA::TimeSamplingPtr getTimeSampling() const
Return the time sampling.
Definition: IFaceSet.h:182
#define ALEMBIC_OVERRIDE_OPERATOR_BOOL(PASS_COND)
Definition: OperatorBool.h:56
Abc::IInt32ArrayProperty getFacesProperty() const
Definition: IFaceSet.h:201
IFaceSetSchema(const IFaceSetSchema &iCopy)
Copy constructor. (explicit copy ctor for msvc bug workaround)
Definition: IFaceSet.h:157
IFaceSetSchema(CPROP_PTR iParent, const std::string &iName, const Abc::Argument &iArg0=Abc::Argument(), const Abc::Argument &iArg1=Abc::Argument())
Definition: IFaceSet.h:121
Box< V3d > Box3d
Definition: ImathBox.h:139
#define ALEMBIC_EXPORT
Definition: Export.h:51
Abc::ISchemaObject< IFaceSetSchema > IFaceSet
Definition: IFaceSet.h:242
Sample getValue(const Abc::ISampleSelector &iSS=Abc::ISampleSelector()) const
Definition: IFaceSet.h:192
#define ALEMBIC_VERSION_NS
Definition: Foundation.h:104
IFaceSetSchema(CPROP_PTR iParent, const Abc::Argument &iArg0=Abc::Argument(), const Abc::Argument &iArg1=Abc::Argument())
Definition: IFaceSet.h:135