Alembic 1.8.11
Loading...
Searching...
No Matches
Foundation.h
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 <Imath/ImathMatrixAlgo.h>
43#include <Imath/ImathEuler.h>
44
45
46namespace Alembic {
47namespace AbcGeom {
48namespace ALEMBIC_VERSION_NS {
49
50namespace Abc = ::Alembic::Abc::ALEMBIC_VERSION_NS;
51using namespace Abc;
52
53//-*****************************************************************************
58enum MeshTopologyVariance
59{
60 kConstantTopology = 0,
61 kHomogenousTopology = 1,
62 kHomogeneousTopology = 1,
63 kHeterogenousTopology = 2,
64 kHeterogeneousTopology = 2
65};
66
67//-*****************************************************************************
70enum 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//-*****************************************************************************
85enum FilmBackXformOperationType
86{
87 kScaleFilmBackOperation = 0,
88 kTranslateFilmBackOperation = 1,
89 kMatrixFilmBackOperation = 2
90};
91
92//-*****************************************************************************
95template <class PROP, class SAMP>
96inline 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
108template <>
109inline 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
117template <>
118inline 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
126template <>
127inline 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//-*****************************************************************************
138template <class ARRAYSAMP>
139static 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//-*****************************************************************************
153inline double DegreesToRadians( double iDegrees )
154{
155 return ( iDegrees * M_PI ) / 180.0;
156}
157
158inline double RadiansToDegrees( double iRadians )
159{
160 return iRadians * ( 180.0 / M_PI );
161}
162
163//-*****************************************************************************
165
166inline 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
175using namespace ALEMBIC_VERSION_NS;
176
177} // End namespace AbcGeom
178} // End namespace Alembic
179
180#endif
Alembic namespace ...
Definition ArchiveInfo.cpp:39