SoFCMeshObject.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef MESHGUI_SOFCMESHOBJECT_H
00024 #define MESHGUI_SOFCMESHOBJECT_H
00025
00026 #include <Inventor/fields/SoSField.h>
00027 #include <Inventor/fields/SoSFUInt32.h>
00028 #include <Inventor/fields/SoSubField.h>
00029 #include <Inventor/fields/SoSFVec3f.h>
00030 #include <Inventor/fields/SoSFVec3s.h>
00031 #include <Inventor/nodes/SoSubNode.h>
00032 #include <Inventor/nodes/SoShape.h>
00033 #include <Inventor/elements/SoReplacedElement.h>
00034 #include <Mod/Mesh/App/Core/Elements.h>
00035 #include <Mod/Mesh/App/Mesh.h>
00036
00037 typedef unsigned int GLuint;
00038 typedef int GLint;
00039 typedef float GLfloat;
00040
00041 namespace MeshCore { class MeshFacetGrid; }
00042
00043 namespace MeshGui {
00044
00045 class MeshGuiExport SoSFMeshObject : public SoSField {
00046 typedef SoSField inherited;
00047
00048 SO_SFIELD_HEADER(SoSFMeshObject, const Mesh::MeshObject*, const Mesh::MeshObject*);
00049
00050 public:
00051 static void initClass(void);
00052 };
00053
00054
00055
00056 class MeshGuiExport SoFCMeshObjectElement : public SoReplacedElement {
00057 typedef SoReplacedElement inherited;
00058
00059 SO_ELEMENT_HEADER(SoFCMeshObjectElement);
00060
00061 public:
00062 static void initClass(void);
00063
00064 virtual void init(SoState * state);
00065 static void set(SoState * const state, SoNode * const node, const Mesh::MeshObject * const mesh);
00066 static const Mesh::MeshObject * get(SoState * const state);
00067 static const SoFCMeshObjectElement * getInstance(SoState * state);
00068 virtual void print(FILE * file) const;
00069
00070 protected:
00071 virtual ~SoFCMeshObjectElement();
00072 const Mesh::MeshObject *mesh;
00073 };
00074
00075
00076
00077 class MeshGuiExport SoFCMeshPickNode : public SoNode {
00078 typedef SoNode inherited;
00079
00080 SO_NODE_HEADER(SoFCMeshPickNode);
00081
00082 public:
00083 static void initClass(void);
00084 SoFCMeshPickNode(void);
00085 void notify(SoNotList *);
00086
00087 SoSFMeshObject mesh;
00088
00089 virtual void rayPick(SoRayPickAction * action);
00090 virtual void pick(SoPickAction * action);
00091
00092 protected:
00093 virtual ~SoFCMeshPickNode();
00094
00095 private:
00096 MeshCore::MeshFacetGrid* meshGrid;
00097 };
00098
00099
00100
00101 class MeshGuiExport SoFCMeshGridNode : public SoNode {
00102 typedef SoNode inherited;
00103
00104 SO_NODE_HEADER(SoFCMeshGridNode);
00105
00106 public:
00107 static void initClass(void);
00108 SoFCMeshGridNode(void);
00109 void GLRender(SoGLRenderAction * action);
00110
00111 SoSFVec3f minGrid;
00112 SoSFVec3f maxGrid;
00113 SoSFVec3s lenGrid;
00114
00115 protected:
00116 virtual ~SoFCMeshGridNode();
00117 };
00118
00119
00120
00121 class MeshGuiExport SoFCMeshObjectNode : public SoNode {
00122 typedef SoNode inherited;
00123
00124 SO_NODE_HEADER(SoFCMeshObjectNode);
00125
00126 public:
00127 static void initClass(void);
00128 SoFCMeshObjectNode(void);
00129
00130 SoSFMeshObject mesh;
00131
00132 virtual void doAction(SoAction * action);
00133 virtual void GLRender(SoGLRenderAction * action);
00134 virtual void callback(SoCallbackAction * action);
00135 virtual void getBoundingBox(SoGetBoundingBoxAction * action);
00136 virtual void pick(SoPickAction * action);
00137 virtual void getPrimitiveCount(SoGetPrimitiveCountAction * action);
00138
00139 protected:
00140 virtual ~SoFCMeshObjectNode();
00141 };
00142
00163 class MeshGuiExport SoFCMeshObjectShape : public SoShape {
00164 typedef SoShape inherited;
00165
00166 SO_NODE_HEADER(SoFCMeshObjectShape);
00167
00168 public:
00169 static void initClass();
00170 SoFCMeshObjectShape();
00171
00172 unsigned int renderTriangleLimit;
00173
00174 protected:
00175 virtual void doAction(SoAction * action);
00176 virtual void GLRender(SoGLRenderAction *action);
00177 virtual void computeBBox(SoAction *action, SbBox3f &box, SbVec3f ¢er);
00178 virtual void getPrimitiveCount(SoGetPrimitiveCountAction * action);
00179 virtual void rayPick (SoRayPickAction *action);
00180 virtual void generatePrimitives(SoAction *action);
00181 virtual SoDetail * createTriangleDetail(SoRayPickAction * action,
00182 const SoPrimitiveVertex * v1,
00183 const SoPrimitiveVertex * v2,
00184 const SoPrimitiveVertex * v3,
00185 SoPickedPoint * pp);
00186
00187 private:
00188 enum Binding {
00189 OVERALL = 0,
00190 PER_FACE_INDEXED,
00191 PER_VERTEX_INDEXED,
00192 NONE = OVERALL
00193 };
00194
00195 private:
00196
00197 virtual ~SoFCMeshObjectShape() {};
00198 virtual void notify(SoNotList * list);
00199 Binding findMaterialBinding(SoState * const state) const;
00200
00201 void drawFaces(const Mesh::MeshObject *, SoMaterialBundle* mb, Binding bind,
00202 SbBool needNormals, SbBool ccw) const;
00203 void drawPoints(const Mesh::MeshObject *, SbBool needNormals, SbBool ccw) const;
00204 unsigned int countTriangles(SoAction * action) const;
00205
00206 void startSelection(SoAction * action, const Mesh::MeshObject*);
00207 void stopSelection(SoAction * action, const Mesh::MeshObject*);
00208 void renderSelectionGeometry(const Mesh::MeshObject*);
00209
00210 private:
00211 bool meshChanged;
00212 GLuint *selectBuf;
00213 GLfloat modelview[16];
00214 GLfloat projection[16];
00215 };
00216
00217 class MeshGuiExport SoFCMeshSegmentShape : public SoShape {
00218 typedef SoShape inherited;
00219
00220 SO_NODE_HEADER(SoFCMeshSegmentShape);
00221
00222 public:
00223 static void initClass();
00224 SoFCMeshSegmentShape();
00225
00226 SoSFUInt32 index;
00227 unsigned int renderTriangleLimit;
00228
00229 protected:
00230 virtual void GLRender(SoGLRenderAction *action);
00231 virtual void computeBBox(SoAction *action, SbBox3f &box, SbVec3f ¢er);
00232 virtual void getPrimitiveCount(SoGetPrimitiveCountAction * action);
00233 virtual void generatePrimitives(SoAction *action);
00234
00235 private:
00236 enum Binding {
00237 OVERALL = 0,
00238 PER_FACE_INDEXED,
00239 PER_VERTEX_INDEXED,
00240 NONE = OVERALL
00241 };
00242
00243 private:
00244
00245 virtual ~SoFCMeshSegmentShape() {};
00246 Binding findMaterialBinding(SoState * const state) const;
00247
00248 void drawFaces(const Mesh::MeshObject *, SoMaterialBundle* mb, Binding bind,
00249 SbBool needNormals, SbBool ccw) const;
00250 void drawPoints(const Mesh::MeshObject *, SbBool needNormals, SbBool ccw) const;
00251 };
00252
00253 class MeshGuiExport SoFCMeshObjectBoundary : public SoShape {
00254 typedef SoShape inherited;
00255
00256 SO_NODE_HEADER(SoFCMeshObjectBoundary);
00257
00258 public:
00259 static void initClass();
00260 SoFCMeshObjectBoundary();
00261
00262 protected:
00263 virtual void GLRender(SoGLRenderAction *action);
00264 virtual void computeBBox(SoAction *action, SbBox3f &box, SbVec3f ¢er);
00265 virtual void getPrimitiveCount(SoGetPrimitiveCountAction * action);
00266 virtual void generatePrimitives(SoAction *action);
00267 private:
00268
00269 virtual ~SoFCMeshObjectBoundary() {};
00270 void drawLines(const Mesh::MeshObject *) const ;
00271 };
00272
00273 }
00274
00275
00276 #endif // MESHGUI_SOFCMESHOBJECT_H
00277