00001 //-***************************************************************************** 00002 // 00003 // Copyright (c) 2009-2011, 00004 // Sony Pictures Imageworks, Inc. and 00005 // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. 00006 // 00007 // All rights reserved. 00008 // 00009 // Redistribution and use in source and binary forms, with or without 00010 // modification, are permitted provided that the following conditions are 00011 // met: 00012 // * Redistributions of source code must retain the above copyright 00013 // notice, this list of conditions and the following disclaimer. 00014 // * Redistributions in binary form must reproduce the above 00015 // copyright notice, this list of conditions and the following disclaimer 00016 // in the documentation and/or other materials provided with the 00017 // distribution. 00018 // * Neither the name of Sony Pictures Imageworks, nor 00019 // Industrial Light & Magic nor the names of their contributors may be used 00020 // to endorse or promote products derived from this software without specific 00021 // prior written permission. 00022 // 00023 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00024 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00025 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 00026 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 00027 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00028 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00029 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00030 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 00031 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00032 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00033 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00034 // 00035 //-***************************************************************************** 00036 00037 #ifndef _Alembic_AbcGeom_Foundation_h_ 00038 #define _Alembic_AbcGeom_Foundation_h_ 00039 00040 #include <Alembic/Abc/All.h> 00041 00042 #include <ImathMatrixAlgo.h> 00043 #include <ImathEuler.h> 00044 00045 00046 namespace Alembic { 00047 namespace AbcGeom { 00048 namespace ALEMBIC_VERSION_NS { 00049 00050 namespace Abc = ::Alembic::Abc::ALEMBIC_VERSION_NS; 00051 using namespace Abc; 00052 00053 //-***************************************************************************** 00054 //! Meshes have topology, which can be either unchanging (constant) 00055 //! homogeneous, which indicates that the connectivity is unchanging, 00056 //! but the positions may change, and finally heterogeneous, which indicates 00057 //! that the connectivity and positions may change. 00058 enum MeshTopologyVariance 00059 { 00060 kConstantTopology, 00061 kHomogenousTopology, 00062 kHeterogenousTopology 00063 }; 00064 00065 //-***************************************************************************** 00066 //! \brief Enum that indicates the type of transformational operation. 00067 //! This enum is used when encoding and decoding the transform operation data. 00068 enum XformOperationType 00069 { 00070 kScaleOperation = 0, 00071 kTranslateOperation = 1, 00072 kRotateOperation = 2, 00073 kMatrixOperation = 3, 00074 kRotateXOperation = 4, 00075 kRotateYOperation = 5, 00076 kRotateZOperation = 6 00077 }; 00078 00079 //-***************************************************************************** 00080 //! \brief Enum that indicates the type of 2d operation for cameras. 00081 //! This enum is used when encoding and decoding the 2d filmback data for 00082 //! cameras. 00083 enum FilmBackXformOperationType 00084 { 00085 kScaleFilmBackOperation = 0, 00086 kTranslateFilmBackOperation = 1, 00087 kMatrixFilmBackOperation = 2 00088 }; 00089 00090 //-***************************************************************************** 00091 //! This utility function sets an array prorperty sample using "set" if 00092 //! the sample is non-null, otherwise calls setFromPrevious. 00093 template <class PROP, class SAMP> 00094 inline void SetPropUsePrevIfNull( PROP iProp, SAMP iSamp ) 00095 { 00096 if ( iProp ) 00097 { 00098 // really only valid with array properties 00099 assert( iProp.isArray() ); 00100 00101 if ( iSamp ) { iProp.set( iSamp ); } 00102 else { iProp.setFromPrevious(); } 00103 } 00104 } 00105 00106 template <> 00107 inline void SetPropUsePrevIfNull<Abc::OStringProperty, std::string>( 00108 Abc::OStringProperty iProp, std::string iSamp ) 00109 { 00110 if ( ! iProp ) { return; } 00111 if ( iSamp != "" ) { iProp.set( iSamp ); } 00112 else { iProp.setFromPrevious(); } 00113 } 00114 00115 template <> 00116 inline void SetPropUsePrevIfNull<Abc::OWstringProperty, Alembic::Util::wstring>( 00117 Abc::OWstringProperty iProp, Alembic::Util::wstring iSamp ) 00118 { 00119 if ( ! iProp ) { return; } 00120 if ( iSamp != L"" ) { iProp.set( iSamp ); } 00121 else { iProp.setFromPrevious(); } 00122 } 00123 00124 template <> 00125 inline void SetPropUsePrevIfNull<Abc::OBox3dProperty, Abc::Box3d>( 00126 Abc::OBox3dProperty iProp, Abc::Box3d iSamp ) 00127 { 00128 if ( ! iProp ) { return; } 00129 if ( iSamp.hasVolume() ) { iProp.set( iSamp ); } 00130 else { iProp.setFromPrevious(); } 00131 } 00132 00133 //-***************************************************************************** 00134 //! This utility function computes an axis-aligned bounding box from a 00135 //! positions sample 00136 template <class ARRAYSAMP> 00137 static Abc::Box3d ComputeBoundsFromPositions( const ARRAYSAMP &iSamp ) 00138 { 00139 Abc::Box3d ret; 00140 size_t size = iSamp.size(); 00141 for ( size_t i = 0 ; i < size ; ++i ) 00142 { 00143 ret.extendBy( iSamp[i] ); 00144 } 00145 00146 return ret; 00147 } 00148 00149 //-***************************************************************************** 00150 //! used in xform rotation conversion 00151 inline double DegreesToRadians( double iDegrees ) 00152 { 00153 return ( iDegrees * M_PI ) / 180.0; 00154 } 00155 00156 inline double RadiansToDegrees( double iRadians ) 00157 { 00158 return iRadians * ( 180.0 / M_PI ); 00159 } 00160 00161 //-***************************************************************************** 00162 //! A couple simple tests for if something is a GeomParam 00163 inline bool IsGeomParam( const AbcA::MetaData &iMetaData ) 00164 { 00165 return iMetaData.get( "isGeomParam" ) == "true"; 00166 } 00167 00168 inline bool IsGeomParam( const AbcA::PropertyHeader &iHeader ) 00169 { 00170 return IsGeomParam( iHeader.getMetaData() ); 00171 } 00172 00173 } // End namespace ALEMBIC_VERSION_NS 00174 00175 using namespace ALEMBIC_VERSION_NS; 00176 00177 } // End namespace AbcGeom 00178 } // End namespace Alembic 00179 00180 #endif
1.5.9