00001 #ifndef _TRIANGLE_EXTRACTOR_ 00002 #define _TRIANGLE_EXTRACTOR_ 00003 /* 00004 * TriangleExtractor.h 00005 * 00006 * Copyright (c) 2007, 2008, 2009, University of Karlsruhe (for members see AUTHORS file) 00007 * 00008 * ISC License 00009 * 00010 * Permission to use, copy, modify, and/or distribute this software for any 00011 * purpose with or without fee is hereby granted, provided that the above 00012 * copyright notice and this permission notice appear in all copies. 00013 * 00014 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 00015 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 00016 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 00017 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 00018 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 00019 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 00020 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 00021 * 00022 * Created by Manfred Kroehnert on 14.11.07. 00023 * 00024 */ 00025 00026 #include <Inventor/nodes/SoCoordinate3.h> 00027 #include <Inventor/nodes/SoIndexedFaceSet.h> 00028 00029 #include <ode/ode.h> 00030 00031 class SoSeparator; 00032 template <typename T> class VertexStorage; 00033 00034 //typedef dVector3 odeVertexType; 00035 typedef dReal odeVertexType[3]; 00036 00037 class TriangleCallbackResult{ 00038 public: 00039 TriangleCallbackResult() 00040 { 00041 coord3 = new SoCoordinate3; 00042 coord3->point.setNum(0); 00043 ifs = new SoIndexedFaceSet; 00044 ifs->coordIndex.setNum(0); 00045 coord3idx = 0; 00046 }; 00047 inline ~TriangleCallbackResult() 00048 { 00049 if ( NULL != coord3 ) 00050 coord3->unref(); 00051 if ( NULL != ifs ) 00052 ifs->unref(); 00053 }; 00054 SoCoordinate3* coord3; 00055 SoIndexedFaceSet* ifs; 00056 int coord3idx; 00057 }; 00058 00059 class TriangleExtractor { 00060 public: 00061 TriangleExtractor(SoNode* object = NULL); 00062 ~TriangleExtractor(); 00063 void execute(const SbVec3f& transvec = SbVec3f(0.0f, 0.0f, 0.0f)); 00064 VertexStorage<odeVertexType>* getResult(); 00065 private: 00066 SoNode* ivModel; 00067 TriangleCallbackResult* result; 00068 00069 static void TriangleCB(void* data, SoCallbackAction* action, 00070 const SoPrimitiveVertex* v1, 00071 const SoPrimitiveVertex* v2, 00072 const SoPrimitiveVertex* v3); 00073 }; 00074 00075 #endif // _TRIANGLE_EXTRACTOR_
Generated on Sat Mar 10 20:00:14 2012 for IPSA by 1.5.8 |