HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OFaceSet.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_OFaceSet_h
38 #define Alembic_AbcGeom_OFaceSet_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 OFaceSetSchema : public OGeomBaseSchema<FaceSetSchemaInfo>
53 {
54 public:
55  //-*************************************************************************
56  // Parition SAMPLE
57  //-*************************************************************************
58  class Sample
59  {
60  public:
61  typedef Sample this_type;
62 
63  //! Creates a default sample with no data in it.
64  //! ...
65  Sample() { reset(); }
66 
67  //! Creates a sample with the list of faces that are in this
68  //! faceset.
69  //! The array of face numbers MUST be ordered by face number.
70  //! Code that reads and works with facesets depends on this for efficency.
71  //! e.g. call std::sort (myVecOfFaces.begin (), myVecOfFaces.end ());
72  //! if you need to.
73  //! The sample must be complete like this. Subsequent samples may also
74  //! consist of faces which allows you to change of topology
75  //! of the faceset.
76  Sample( const Abc::Int32ArraySample &iFaceNums)
77  : m_faces( iFaceNums )
78  {}
79 
80  /* main accessors */
81  // Faces
82  const Abc::Int32ArraySample &getFaces() const { return m_faces; }
83  void setFaces( const Abc::Int32ArraySample &iFaces)
84  { m_faces = iFaces; }
85 
86  // Bounding boxes
87  const Abc::Box3d &getSelfBounds() const { return m_selfBounds; }
88  void setSelfBounds( const Abc::Box3d &iBnds )
89  { m_selfBounds = iBnds; }
90 
91  void reset()
92  {
93  m_faces.reset();
94 
95  m_selfBounds.makeEmpty();
96  }
97 
98  protected:
100 
101  // bounds
103  }; // end OFaceSetSchema::Sample
104 
105 
106  //-*************************************************************************
107  // FaceSet SCHEMA
108  //-*************************************************************************
109 public:
110  //! By convention we always define this_type in AbcGeom classes.
111  //! Used by unspecified-bool-type conversion below
113 
114  //-*************************************************************************
115  // CONSTRUCTION, DESTRUCTION, ASSIGNMENT
116  //-*************************************************************************
117  //! The default constructor creates an empty OFaceSetSchema.
118  //! OFaceSetSchema instances created this evaluate to a boolean value of false.
120 
121  //! This constructor creates a new faceset writer.
122  //! The first argument is an CompoundPropertyWriterPtr to use as a parent.
123  //! The next is the name to give the schema which is usually the default
124  //! name given by OFaceSet (.faceset) The remaining optional arguments
125  //! can be used to override the ErrorHandlerPolicy, to specify
126  //! MetaData, specify sparse sampling and to set TimeSampling.
128  const std::string &iName,
129  const Abc::Argument &iArg0 = Abc::Argument(),
130  const Abc::Argument &iArg1 = Abc::Argument(),
131  const Abc::Argument &iArg2 = Abc::Argument(),
132  const Abc::Argument &iArg3 = Abc::Argument() );
133 
134  //! This constructor creates a new faceset writer.
135  //! The first argument is an OCompundProperty to use as a parent, and from
136  //! which the ErrorHandlerPolicy is derived. The next is the name to give
137  //! the schema which is usually the default name given by OFaceSet
138  //! (.faceset) The remaining optional arguments can be used to specify
139  //! MetaData, specify sparse sampling and to set TimeSampling.
141  const std::string &iName,
142  const Abc::Argument &iArg0 = Abc::Argument(),
143  const Abc::Argument &iArg1 = Abc::Argument(),
144  const Abc::Argument &iArg2 = Abc::Argument() );
145 
146  //! Copy constructor.
148  : OGeomBaseSchema<FaceSetSchemaInfo>()
149  {
150  *this = iCopy;
151  }
152 
153  //! Default assignment operator used.
154 
155  //-*************************************************************************
156  // SCHEMA STUFF
157  //-*************************************************************************
158 
159  //-*************************************************************************
160  // SAMPLE STUFF
161  //-*************************************************************************
162 
163  //! Get number of samples written so far.
164  //! ...
165  size_t getNumSamples() const
166  { return m_facesProperty.getNumSamples(); }
167 
168  //! Set a sample! First sample must have the list of faces in the faceset.
169  void set( const Sample &iSamp );
170 
171  void setTimeSampling( uint32_t iTimeSamplingID );
172  void setTimeSampling( AbcA::TimeSamplingPtr iTime );
173 
174  void setFaceExclusivity( FaceSetExclusivity iFacesExclusive );
175  FaceSetExclusivity getFaceExclusivity() { return m_facesExclusive; }
176  //-*************************************************************************
177  // ABC BASE MECHANISMS
178  // These functions are used by Abc to deal with errors, validity,
179  // and so on.
180  //-*************************************************************************
181 
182  //! Reset returns this function set to an empty, default
183  //! state.
184  void reset()
185  {
186  m_facesProperty.reset();
187 
189  }
190 
191  //! Valid returns whether this instance holds real data.
192  bool valid() const
193  {
195  m_facesProperty.valid()
196  );
197  }
198 
199  //! unspecified-bool-type operator overload.
200  //! ...
202 
203 protected:
204  void _recordExclusivityHint();
205 
206  void init( AbcA::CompoundPropertyWriterPtr iParent,
207  const Abc::Argument &iArg0, const Abc::Argument &iArg1,
208  const Abc::Argument &iArg2, const Abc::Argument &iArg3 );
209 
211 
214 };
215 
216 
217 //-*****************************************************************************
218 // Nice to use typedef for users of this class.
219 //-*****************************************************************************
221 
222 typedef Util::shared_ptr< OFaceSet > OFaceSetPtr;
223 
225  const Int32ArraySample & meshFaceCounts,
226  const Int32ArraySample & vertexIndices,
227  const P3fArraySample & meshP);
228 
229 } // End namespace ALEMBIC_VERSION_NS
230 
231 using namespace ALEMBIC_VERSION_NS;
232 
233 } // End namespace AbcGeom
234 } // End namespace Alembic
235 
236 #endif
bool valid() const
Valid returns whether this instance holds real data.
Definition: OFaceSet.h:192
Abc::OSchemaObject< OFaceSetSchema > OFaceSet
Definition: OFaceSet.h:220
Abc::Box3d computeBoundsFromPositionsByFaces(const Int32ArraySample &faces, const Int32ArraySample &meshFaceCounts, const Int32ArraySample &vertexIndices, const P3fArraySample &meshP)
GLsizei const GLchar *const * string
Definition: glcorearb.h:814
#define ALEMBIC_EXPORT
Definition: Export.h:51
FaceSetExclusivity
Hint to indicate face membership is mutally exclusive. Some structures that group faces only allow a ...
size_t getNumSamples() const
Default assignment operator used.
Definition: OFaceSet.h:165
Alembic::Util::shared_ptr< TimeSampling > TimeSamplingPtr
Definition: TimeSampling.h:137
const Abc::Int32ArraySample & getFaces() const
Definition: OFaceSet.h:82
GLboolean reset
Definition: glad.h:5138
OFaceSetSchema(const OFaceSetSchema &iCopy)
Copy constructor.
Definition: OFaceSet.h:147
#define ALEMBIC_OVERRIDE_OPERATOR_BOOL(PASS_COND)
Definition: OperatorBool.h:56
void setFaces(const Abc::Int32ArraySample &iFaces)
Definition: OFaceSet.h:83
Box< V3d > Box3d
3D box of base type double.
Definition: ImathBox.h:167
Util::shared_ptr< OFaceSet > OFaceSetPtr
Definition: OFaceSet.h:222
Sample(const Abc::Int32ArraySample &iFaceNums)
Definition: OFaceSet.h:76
#define ALEMBIC_VERSION_NS
Definition: Foundation.h:88
Alembic::Util::shared_ptr< CompoundPropertyWriter > CompoundPropertyWriterPtr