mudbox.h

Go to the documentation of this file.
00001 
00002 //**************************************************************************/
00003 // Copyright (c) 2008 Autodesk, Inc.
00004 // All rights reserved.
00005 //
00006 // Use of this software is subject to the terms of the Autodesk license
00007 // agreement provided at the time of installation or download, or which
00008 // otherwise accompanies this software in either electronic or hard copy form.
00009 //
00010 //**************************************************************************/
00011 // DESCRIPTION:
00012 // CREATED: October 2008
00013 //**************************************************************************/
00014 
00015 #ifndef __MUDBOXSDK_MUDBOX_H__
00016 #define __MUDBOXSDK_MUDBOX_H__
00017 
00018 #pragma once 
00019  
00020 #ifdef _WIN32
00021 #pragma warning( disable : 4251 )
00022 #endif
00023 /*****
00024  * System headers
00025  *
00026  * Usage:
00027  *   - Ensure size_t is defined properly.
00028  */
00029 #include <stdlib.h>
00030 #include <stdio.h>
00031 #ifdef _WIN32
00032 #include <intrin.h>
00033 #endif
00034 
00035 #if defined(JAMBUILD)
00036 #include <Mudbox/dllinterface.h>
00037 #else
00038 #include "dllinterface.h"
00039 #endif
00040 
00041 // defines
00042 #ifdef _DEBUG 
00043 #ifndef MB_DEBUG
00044 #define MB_DEBUG
00045 #endif
00046 #endif
00047 
00048 // version info, short & simple for, similar to Qt version info
00049 #define MB_SDK_VERSION_STRING "1.0.0"
00050 
00051 // MB_SDK_VERSION is (major << 16) + (minor << 8) + patch.
00052 //
00053 // Each pair of #s after the x represent a version # (major, minor, patch).
00054 // Hexadecimal is the base and each digit represents 4 bits, so 16 different
00055 // combinations.  So since the version takes up 2 digits = 8 bits = 256 possible
00056 // versions for each group.
00057 #define MB_SDK_VERSION 0x010000
00058 // can be used like #if (MB_SDK_VERSION >= MB_SDK_VERSION_CHECK(1, 1, 0))
00059 #define MB_SDK_VERSION_CHECK(major, minor, patch) ((major<<16)|(minor<<8)|(patch))
00060 
00061 #ifndef MB_ASSERT
00062     #if defined(MB_DEBUG)
00063         #if defined(_WIN32)
00064             #define MB_ASSERT( condition ) { if (!(condition)&&mudbox::AssertFailed( __FILE__, __LINE__, #condition, "" )) __debugbreak(); }
00065         #else
00066             #define MB_ASSERT( condition ) { if (!(condition)) mudbox::AssertFailed( __FILE__, __LINE__, #condition, "" ); }
00067         #endif
00068     #else
00069         #define MB_ASSERT( condition ) {}
00070     #endif
00071 #endif
00072 #ifndef MB_VERIFY
00073     #ifdef MB_DEBUG
00074         #define MB_VERIFY( condition ) MB_ASSERT( condition )
00075     #else
00076         #define MB_VERIFY( condition ) { bool b___ = condition; b___; }
00077     #endif
00078 #endif
00079 
00080 
00081 #ifndef MB_VERIFY_EQ
00082     #ifdef MB_DEBUG
00083         #define MB_VERIFY_EQ( condition_, value_ ) MB_ASSERT( (condition_) == (value_) )
00084     #else
00085         #define MB_VERIFY_EQ( condition_, value_ ) (condition_)
00086     #endif
00087 #endif
00088 
00089 #ifndef MB_VERIFY_TRUE
00090     #ifdef MB_DEBUG
00091         #define MB_VERIFY_TRUE( condition_ ) MB_ASSERT( (condition_) )
00092     #else
00093         #define MB_VERIFY_TRUE( condition_ ) (condition_)
00094     #endif
00095 #endif
00096 
00097 #define MB_ONBUG( condition ) MB_ASSERT( !(condition) ); if ( condition )
00098 #define MB_SAFELY( condition ) MB_ASSERT( condition ); if ( condition )
00099 
00100 #ifndef MB_DEBUG
00101 #define QT_NO_DEBUG_OUTPUT
00102 #endif
00103 
00104 #if defined( MB_TEST ) || defined( MB_DEBUG )
00105 
00106 #if defined(_MSC_VER)
00107 #define MB_TIMER( name ) static int ____iTimerIndex = -1; mudbox::Timer ____cTimer( __FUNCTION__" - "##name, ____iTimerIndex );
00108 #else
00109 #define MB_TIMER( name ) static int ____iTimerIndex = -1; mudbox::Timer ____cTimer( __FILE__ " - " name, ____iTimerIndex );
00110 #endif
00111 
00112 #else
00113 #define MB_TIMER( name ) ;
00114 #endif
00115 #if defined(__GNUC__)
00116 #define MB_ERROR throw (new mudbox::Error( "", mudbox::Error::codeUnspecified, __PRETTY_FUNCTION__, __FILE__, __LINE__ ))->Format
00117 #define MB_ERRORQ(s) throw new mudbox::Error( s, mudbox::Error::codeUnspecified, __PRETTY_FUNCTION__, __FILE__, __LINE__ )
00118 #else
00119 #define MB_ERROR throw (new mudbox::Error( "", mudbox::Error::codeUnspecified, __FUNCTION__, __FILE__, __LINE__ ))->Format
00120 #define MB_ERRORQ(s) throw new mudbox::Error( s, mudbox::Error::codeUnspecified, __FUNCTION__, __FILE__, __LINE__ )
00121 #endif
00122 
00123 #define MB_PLUGIN( name, description, author, url, initializer ) mudbox::Plugin __myplugin( name, description, author, url, __DATE__" "__TIME__, initializer );
00124 
00125 #if defined(QT_VERSION) || defined(MB_USE_QT)
00126     // Avoid X11's define clash.
00127     #include "MudBoxX11Clean.h"
00128 
00129     //#if QT_VERSION < 0x040200
00130     //  #error "Mudbox SDK needs Qt version 4.2 or later. Update your Qt or if you dont want custom widgets include mudbox.h before the Qt headers."
00131     //#endif
00132     #include <QtCore/QString>
00133     #include <QtGui/QLabel>
00134     #include <QtCore/QFileInfoList>
00135 #endif
00136 
00137 // get rid of win32 api hacks
00138 #undef MessageBox
00139 
00140 #ifndef _MSC_VER
00141 #ifndef __forceinline
00142 #define __forceinline inline
00143 #endif
00144 #endif
00145 
00146 #if defined(_MSC_VER) || defined(__INTEL_COMPILER)
00147 // "Microosft C Compiler" and "Intel C Compiler" supports OpenMP
00148 #define __MUDBOX_HAS_OPENMP_LIB__ 1
00149 #endif
00150 
00151 #if (__GNUC__ >= 4) && (__GNUC_MINOR__ >= 2)
00152 // GCC 4.2 supports OpenMP.
00153 #define __MUDBOX_HAS_OPENMP_LIB__ 1
00154 #endif
00155 
00156 class QColor;
00157 class QImage;
00158 class QString;
00159 class QWidget;
00160 class XMesh;
00161 class XSubdivisionLevel;
00162 class Manipulator;
00163 
00164 namespace mudbox
00165 {
00166     class AttributeWidget;
00167     class BrushOperation;
00168 
00169     // types
00170     typedef long long int64;
00171     typedef unsigned long long uint64;
00172 
00173     template <typename type> class Array;
00174     template <typename type> class Store;
00175 
00176     // functions
00177     template < typename type >
00178     inline type Min( type a, type b ) { return a < b ? a : b; };
00179     template < typename type >
00180     inline type Max( type a, type b ) { return a > b ? a : b; };
00181     bool MBDLL_DECL AssertFailed( const char *sSourceFile, int iSourceLine, const char *sCondition, const char *sMessage );
00182     
00183     float MBDLL_DECL Modf( float value );
00184 };
00185 
00186     // classes
00187 #if defined(JAMBUILD)
00188     #include <Mudbox/i18n.h>
00189     #include <Mudbox/error.h>
00190     #include <Mudbox/array.h>
00191     #include <Mudbox/node.h>
00192     #include <Mudbox/stream.h>
00193     #include <Mudbox/plugin.h>
00194     #include <Mudbox/treenode.h>
00195     #include <Mudbox/math.h>
00196     #include <Mudbox/topology.h>
00197     #include <Mudbox/layer.h>
00198     #include <Mudbox/mesh.h>
00199     #include <Mudbox/preferences.h>
00200     #include <Mudbox/tray.h>
00201     #include <Mudbox/transformation.h>
00202     #include <Mudbox/image.h>
00203     #include <Mudbox/imagePlane.h>
00204     #include <Mudbox/material.h>
00205     #include <Mudbox/renderer.h>
00206     #include <Mudbox/subdivision.h>
00207     #include <Mudbox/geometry.h>
00208     #include <Mudbox/light.h>
00209     #include <Mudbox/camera.h>
00210     #include <Mudbox/scene.h>
00211     #include <Mudbox/interface.h>
00212     #include <Mudbox/kernel.h>
00213     #include <Mudbox/importexport.h>
00214     #include <Mudbox/operation.h>
00215     #include <Mudbox/viewport.h>
00216     #include <Mudbox/selectionset.h>
00217     #include <Mudbox/nurbs.h>
00218     #include <Mudbox/brush.h>
00219     #include <Mudbox/brushmask.h>
00220     #include <Mudbox/ConvolutionKernel.h>
00221     #include <Mudbox/ImageFilter.h>
00222     #include <Mudbox/xref.h>
00223     #include <Mudbox/SSE.h>
00224     #include <Mudbox/UnitTest.h>
00225     // #include <Mudbox/UVMapSolver.h>
00226 #else
00227     #include "i18n.h"
00228     #include "error.h"
00229     #include "array.h"
00230     #include "node.h"
00231     #include "stream.h"
00232     #include "plugin.h"
00233     #include "treenode.h"
00234     #include "math.h"
00235     #include "topology.h"
00236     #include "layer.h"
00237     #include "mesh.h"
00238     #include "preferences.h"
00239     #include "tray.h"
00240     #include "transformation.h"
00241     #include "image.h"
00242     #include "imagePlane.h"
00243     #include "material.h"
00244     #include "renderer.h"
00245     #include "subdivision.h"
00246     #include "geometry.h"
00247     #include "light.h"
00248     #include "camera.h"
00249     #include "scene.h"
00250     #include "interface.h"
00251     #include "kernel.h"
00252     #include "importexport.h"
00253     #include "operation.h"
00254     #include "viewport.h"
00255     #include "selectionset.h"
00256     #include "nurbs.h"
00257     #include "brush.h"
00258     #include "brushmask.h"
00259     #include "ConvolutionKernel.h"
00260     #include "ImageFilter.h"
00261     #include "xref.h"
00262     #include "SSE.h"
00263     #include "UnitTest.h"
00264     // #include "UVMapSolver.h"
00265 #endif
00266 
00267 #ifdef QT_VERSION
00268 #if defined(JAMBUILD)
00269 #include <Mudbox/widgets.h>
00270 #else
00271 #include "widgets.h"
00272 #endif
00273 #endif
00274 
00275 #ifdef MB_DEBUG
00276 #define MB_CHECK_GL_ERROR Kernel()->GLCheckError( __FILE__, __FUNCTION__, __LINE__ );
00277 #define MB_CHECK_GL_STATES Kernel()->GLCheckStates( __FILE__, __FUNCTION__, __LINE__ );
00278 #define MB_CHECK_CG_ERROR {CGerror error;\
00279     const char* const lastErrorString = cgGetLastErrorString(&error); \
00280     if( error != CG_NO_ERROR ) Kernel()->Log(NTRQ("Cg error: '%1'").arg(lastErrorString));}
00281 #else
00282 #define MB_CHECK_GL_ERROR
00283 #define MB_CHECK_GL_STATES
00284 #define MB_CHECK_CG_ERROR
00285 #endif
00286 
00288 #define MB_SDN( a )     if( a ) { delete a; a = 0; };
00289 
00290 #ifdef PLUGIN
00291     #undef DLL
00292     #undef PLUGIN
00293 #endif
00294 
00295 #endif