OpenMesh
|
00001 /*===========================================================================*\ 00002 * * 00003 * OpenMesh * 00004 * Copyright (C) 2001-2011 by Computer Graphics Group, RWTH Aachen * 00005 * www.openmesh.org * 00006 * * 00007 *---------------------------------------------------------------------------* 00008 * This file is part of OpenMesh. * 00009 * * 00010 * OpenMesh is free software: you can redistribute it and/or modify * 00011 * it under the terms of the GNU Lesser General Public License as * 00012 * published by the Free Software Foundation, either version 3 of * 00013 * the License, or (at your option) any later version with the * 00014 * following exceptions: * 00015 * * 00016 * If other files instantiate templates or use macros * 00017 * or inline functions from this file, or you compile this file and * 00018 * link it with other files to produce an executable, this file does * 00019 * not by itself cause the resulting executable to be covered by the * 00020 * GNU Lesser General Public License. This exception does not however * 00021 * invalidate any other reasons why the executable file might be * 00022 * covered by the GNU Lesser General Public License. * 00023 * * 00024 * OpenMesh is distributed in the hope that it will be useful, * 00025 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00026 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00027 * GNU Lesser General Public License for more details. * 00028 * * 00029 * You should have received a copy of the GNU LesserGeneral Public * 00030 * License along with OpenMesh. If not, * 00031 * see <http://www.gnu.org/licenses/>. * 00032 * * 00033 \*===========================================================================*/ 00034 00035 /*===========================================================================*\ 00036 * * 00037 * $Revision: 362 $ * 00038 * $Date: 2011-01-26 10:21:12 +0100 (Mi, 26 Jan 2011) $ * 00039 * * 00040 \*===========================================================================*/ 00041 00042 #ifndef SOOPENMESHSUPPORT_H 00043 #define SOOPENMESHSUPPORT_H 00044 00045 //== REDEFINE DEFINES SO THEY WORK WITH TEMPLATES ============================ 00046 00047 #define SO_NODE_SOURCE_TEMPLATE template <class Mesh> 00048 00049 // ----------------------------------------------------------------- COIN ---- 00050 // 00051 // define __COIN__ is set by coin headers 00052 #ifdef __COIN__ 00053 00054 #ifdef PRIVATE_NODE_TYPESYSTEM_SOURCE 00055 # undef PRIVATE_NODE_TYPESYSTEM_SOURCE 00056 #endif 00057 00058 #define PRIVATE_NODE_TYPESYSTEM_SOURCE(_class_) \ 00059 SO_NODE_SOURCE_TEMPLATE \ 00060 SoType _class_::getClassTypeId(void) { return _class_::classTypeId; } \ 00061 SO_NODE_SOURCE_TEMPLATE \ 00062 SoType _class_::getTypeId(void) const { return _class_::classTypeId; } \ 00063 /* Don't set value explicitly to SoType::badType(), to avoid a bug in */ \ 00064 /* Sun CC v4.0. (Bitpattern 0x0000 equals SoType::badType()). */ \ 00065 SO_NODE_SOURCE_TEMPLATE \ 00066 SoType _class_::classTypeId 00067 00068 // FIXME: document. 20000103 mortene. 00069 #ifdef SO_NODE_ABSTRACT_SOURCE 00070 # undef SO_NODE_ABSTRACT_SOURCE 00071 #endif 00072 00073 #define SO_NODE_ABSTRACT_SOURCE(_class_) \ 00074 PRIVATE_NODE_TYPESYSTEM_SOURCE(_class_); \ 00075 \ 00076 SO_NODE_SOURCE_TEMPLATE \ 00077 unsigned int _class_::classinstances = 0; \ 00078 SO_NODE_SOURCE_TEMPLATE \ 00079 const SoFieldData ** _class_::parentFieldData = NULL; \ 00080 SO_NODE_SOURCE_TEMPLATE \ 00081 SoFieldData * _class_::fieldData = NULL; \ 00082 \ 00083 SO_NODE_SOURCE_TEMPLATE \ 00084 const SoFieldData ** \ 00085 _class_::getFieldDataPtr(void) \ 00086 { \ 00087 return (const SoFieldData **)(&_class_::fieldData); \ 00088 } \ 00089 \ 00090 SO_NODE_SOURCE_TEMPLATE \ 00091 const SoFieldData * \ 00092 _class_::getFieldData(void) const \ 00093 { \ 00094 return _class_::fieldData; \ 00095 } 00096 00097 00098 00099 // FIXME: document. 20000103 mortene. 00100 #ifdef SO_NODE_SOURCE 00101 # undef SO_NODE_SOURCE 00102 #endif 00103 #define SO_NODE_SOURCE(_class_) \ 00104 SO_NODE_ABSTRACT_SOURCE(_class_); \ 00105 \ 00106 SO_NODE_SOURCE_TEMPLATE \ 00107 void * \ 00108 _class_::createInstance(void) \ 00109 { \ 00110 return new _class_; \ 00111 } 00112 00113 // ------------------------------------------------------------------ SGI ---- 00114 #else 00115 00116 #ifdef SO_NODE_SOURCE 00117 # undef SO_NODE_SOURCE 00118 #endif 00119 00120 #define SO_NODE_SOURCE(_class_) \ 00121 SO_NODE_SOURCE_TEMPLATE \ 00122 SoType _class_::classTypeId; \ 00123 \ 00124 SO_NODE_SOURCE_TEMPLATE \ 00125 SoFieldData *_class_::fieldData; \ 00126 \ 00127 SO_NODE_SOURCE_TEMPLATE \ 00128 const SoFieldData **_class_::parentFieldData; \ 00129 \ 00130 SO_NODE_SOURCE_TEMPLATE \ 00131 SbBool _class_::firstInstance = TRUE; \ 00132 \ 00133 SO_NODE_SOURCE_TEMPLATE \ 00134 SoType _class_::getTypeId() const { \ 00135 return classTypeId; \ 00136 } \ 00137 \ 00138 SO_NODE_SOURCE_TEMPLATE \ 00139 const SoFieldData* \ 00140 _class_::getFieldData() const { \ 00141 SO__NODE_CHECK_CONSTRUCT("SoOpenMeshNodeT"); \ 00142 return fieldData; \ 00143 } \ 00144 \ 00145 SO_NODE_SOURCE_TEMPLATE \ 00146 void* _class_::createInstance() { \ 00147 return (void *)(new _class_); \ 00148 } \ 00149 00150 #endif 00151 00152 #endif