Alembic Version 1.1

Foundation.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_Foundation_h
38#define Alembic_AbcGeom_Foundation_h
39
40#include <Alembic/Abc/All.h>
41
42#include <ImathMatrixAlgo.h>
43#include <ImathEuler.h>
44
45
46 namespace Alembic {
47 namespace AbcGeom {
48 namespace ALEMBIC_VERSION_NS {
49
50 namespace Abc = ::Alembic::Abc::ALEMBIC_VERSION_NS;
51 using namespace Abc;
52
53//-*****************************************************************************
58 enum MeshTopologyVariance
59{
60 kConstantTopology = 0,
61 kHomogenousTopology = 1,
62 kHomogeneousTopology = 1,
63 kHeterogenousTopology = 2,
64 kHeterogeneousTopology = 2
65};
66
67//-*****************************************************************************
70 enum XformOperationType
71{
72 kScaleOperation = 0,
73 kTranslateOperation = 1,
74 kRotateOperation = 2,
75 kMatrixOperation = 3,
76 kRotateXOperation = 4,
77 kRotateYOperation = 5,
78 kRotateZOperation = 6
79};
80
81//-*****************************************************************************
85 enum FilmBackXformOperationType
86{
87 kScaleFilmBackOperation = 0,
88 kTranslateFilmBackOperation = 1,
89 kMatrixFilmBackOperation = 2
90};
91
92//-*****************************************************************************
95 template <class PROP, class SAMP>
96 inline void SetPropUsePrevIfNull( PROP iProp, SAMP iSamp )
97{
98 if ( iProp )
99 {
100 // really only valid with array properties
101 assert( iProp.isArray() );
102
103 if ( iSamp ) { iProp.set( iSamp ); }
104 else { iProp.setFromPrevious(); }
105 }
106}
107
108 template <>
109 inline void SetPropUsePrevIfNull<Abc::OStringProperty, std::string>(
110 Abc::OStringProperty iProp, std::string iSamp )
111{
112 if ( ! iProp ) { return; }
113 if ( iSamp != "" ) { iProp.set( iSamp ); }
114 else { iProp.setFromPrevious(); }
115}
116
117 template <>
118 inline void SetPropUsePrevIfNull<Abc::OWstringProperty, Alembic::Util::wstring>(
119 Abc::OWstringProperty iProp, Alembic::Util::wstring iSamp )
120{
121 if ( ! iProp ) { return; }
122 if ( iSamp != L"" ) { iProp.set( iSamp ); }
123 else { iProp.setFromPrevious(); }
124}
125
126 template <>
127 inline void SetPropUsePrevIfNull<Abc::OBox3dProperty, Abc::Box3d>(
128 Abc::OBox3dProperty iProp, Abc::Box3d iSamp )
129{
130 if ( ! iProp ) { return; }
131 if ( iSamp.hasVolume() ) { iProp.set( iSamp ); }
132 else { iProp.setFromPrevious(); }
133}
134
135//-*****************************************************************************
138 template <class ARRAYSAMP>
139 static Abc::Box3d ComputeBoundsFromPositions( const ARRAYSAMP &iSamp )
140{
141 Abc::Box3d ret;
142 size_t size = iSamp.size();
143 for ( size_t i = 0 ; i < size ; ++i )
144 {
145 ret.extendBy( iSamp[i] );
146 }
147
148 return ret;
149}
150
151//-*****************************************************************************
153 inline double DegreesToRadians( double iDegrees )
154{
155 return ( iDegrees * M_PI ) / 180.0;
156}
157
158 inline double RadiansToDegrees( double iRadians )
159{
160 return iRadians * ( 180.0 / M_PI );
161}
162
163//-*****************************************************************************
165
166 inline bool IsGeomParam( const AbcA::PropertyHeader &iHeader )
167{
168 return iHeader.isArray() || ( iHeader.isCompound() &&
169 iHeader.getMetaData().get( "podName" ) != "" &&
170 iHeader.getMetaData().get( "podExtent" ) != "" );
171}
172
173} // End namespace ALEMBIC_VERSION_NS
174
175 using namespace ALEMBIC_VERSION_NS;
176
177} // End namespace AbcGeom
178} // End namespace Alembic
179
180#endif
All.h
ALEMBIC_VERSION_NS
#define ALEMBIC_VERSION_NS
Definition: Foundation.h:105
Alembic::AbcCoreAbstract::ALEMBIC_VERSION_NS::MetaData::get
std::string get(const std::string &iKey) const
Definition: MetaData.h:192
Alembic::AbcCoreAbstract::ALEMBIC_VERSION_NS::PropertyHeader
Definition: PropertyHeader.h:79
Alembic::AbcCoreAbstract::ALEMBIC_VERSION_NS::PropertyHeader::isCompound
bool isCompound() const
Definition: PropertyHeader.h:157
Alembic::AbcCoreAbstract::ALEMBIC_VERSION_NS::PropertyHeader::getMetaData
const MetaData & getMetaData() const
Definition: PropertyHeader.h:165
Alembic::AbcCoreAbstract::ALEMBIC_VERSION_NS::PropertyHeader::isArray
bool isArray() const
Definition: PropertyHeader.h:153
Alembic::Abc::ALEMBIC_VERSION_NS::OScalarProperty::setFromPrevious
void setFromPrevious()
Alembic::Abc::ALEMBIC_VERSION_NS::OTypedScalarProperty< StringTPTraits >
Alembic::Abc::ALEMBIC_VERSION_NS::OTypedScalarProperty::set
void set(const value_type &iVal)
Definition: OTypedScalarProperty.h:173
Alembic::AbcGeom::ALEMBIC_VERSION_NS::MeshTopologyVariance
MeshTopologyVariance
Definition: Foundation.h:59
Alembic::AbcGeom::ALEMBIC_VERSION_NS::kHomogeneousTopology
@ kHomogeneousTopology
Definition: Foundation.h:62
Alembic::AbcGeom::ALEMBIC_VERSION_NS::kHeterogeneousTopology
@ kHeterogeneousTopology
Definition: Foundation.h:64
Alembic::AbcGeom::ALEMBIC_VERSION_NS::kHeterogenousTopology
@ kHeterogenousTopology
Definition: Foundation.h:63
Alembic::AbcGeom::ALEMBIC_VERSION_NS::kHomogenousTopology
@ kHomogenousTopology
Definition: Foundation.h:61
Alembic::AbcGeom::ALEMBIC_VERSION_NS::kConstantTopology
@ kConstantTopology
Definition: Foundation.h:60
Alembic::AbcGeom::ALEMBIC_VERSION_NS::DegreesToRadians
double DegreesToRadians(double iDegrees)
used in xform rotation conversion
Definition: Foundation.h:153
Alembic::AbcGeom::ALEMBIC_VERSION_NS::XformOperationType
XformOperationType
Enum that indicates the type of transformational operation. This enum is used when encoding and decod...
Definition: Foundation.h:71
Alembic::AbcGeom::ALEMBIC_VERSION_NS::kScaleOperation
@ kScaleOperation
Definition: Foundation.h:72
Alembic::AbcGeom::ALEMBIC_VERSION_NS::kMatrixOperation
@ kMatrixOperation
Definition: Foundation.h:75
Alembic::AbcGeom::ALEMBIC_VERSION_NS::kTranslateOperation
@ kTranslateOperation
Definition: Foundation.h:73
Alembic::AbcGeom::ALEMBIC_VERSION_NS::kRotateOperation
@ kRotateOperation
Definition: Foundation.h:74
Alembic::AbcGeom::ALEMBIC_VERSION_NS::kRotateZOperation
@ kRotateZOperation
Definition: Foundation.h:78
Alembic::AbcGeom::ALEMBIC_VERSION_NS::kRotateXOperation
@ kRotateXOperation
Definition: Foundation.h:76
Alembic::AbcGeom::ALEMBIC_VERSION_NS::kRotateYOperation
@ kRotateYOperation
Definition: Foundation.h:77
Alembic::AbcGeom::ALEMBIC_VERSION_NS::FilmBackXformOperationType
FilmBackXformOperationType
Enum that indicates the type of 2d operation for cameras. This enum is used when encoding and decodin...
Definition: Foundation.h:86
Alembic::AbcGeom::ALEMBIC_VERSION_NS::kScaleFilmBackOperation
@ kScaleFilmBackOperation
Definition: Foundation.h:87
Alembic::AbcGeom::ALEMBIC_VERSION_NS::kTranslateFilmBackOperation
@ kTranslateFilmBackOperation
Definition: Foundation.h:88
Alembic::AbcGeom::ALEMBIC_VERSION_NS::kMatrixFilmBackOperation
@ kMatrixFilmBackOperation
Definition: Foundation.h:89
Alembic::AbcGeom::ALEMBIC_VERSION_NS::RadiansToDegrees
double RadiansToDegrees(double iRadians)
Definition: Foundation.h:158
Alembic::AbcGeom::ALEMBIC_VERSION_NS::IsGeomParam
bool IsGeomParam(const AbcA::PropertyHeader &iHeader)
A couple simple tests for if something is a GeomParam.
Definition: Foundation.h:166
Alembic::AbcGeom::ALEMBIC_VERSION_NS::ComputeBoundsFromPositions
static Abc::Box3d ComputeBoundsFromPositions(const ARRAYSAMP &iSamp)
Definition: Foundation.h:139
Alembic::AbcGeom::ALEMBIC_VERSION_NS::SetPropUsePrevIfNull
void SetPropUsePrevIfNull(PROP iProp, SAMP iSamp)
Definition: Foundation.h:96
Alembic::Abc::ALEMBIC_VERSION_NS
Definition: ArchiveInfo.h:48
Alembic
Alembic namespace ...
Definition: ArchiveInfo.h:46