SoFCMeshNode.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (c) 2006 Werner Mayer <werner.wm.mayer@gmx.de>              *
00003  *                                                                         *
00004  *   This file is part of the FreeCAD CAx development system.              *
00005  *                                                                         *
00006  *   This library is free software; you can redistribute it and/or         *
00007  *   modify it under the terms of the GNU Library General Public           *
00008  *   License as published by the Free Software Foundation; either          *
00009  *   version 2 of the License, or (at your option) any later version.      *
00010  *                                                                         *
00011  *   This library  is distributed in the hope that it will be useful,      *
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00014  *   GNU Library General Public License for more details.                  *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU Library General Public     *
00017  *   License along with this library; see the file COPYING.LIB. If not,    *
00018  *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
00019  *   Suite 330, Boston, MA  02111-1307, USA                                *
00020  *                                                                         *
00021  ***************************************************************************/
00022 
00023 #ifndef MESHGUI_SOFC_MESH_NODE_H
00024 #define MESHGUI_SOFC_MESH_NODE_H
00025 
00026 #include <Inventor/nodes/SoNode.h>
00027 #include <Inventor/nodes/SoShape.h>
00028 #include <Inventor/fields/SoMFVec3f.h>
00029 #include <Inventor/fields/SoMFInt32.h>
00030 
00031 namespace Mesh {
00032 class MeshObject;
00033 }
00034 
00035 namespace MeshGui {
00036 
00037 class MeshGuiExport SoFCMeshNode : public SoShape {
00038     typedef SoShape inherited;
00039 
00040     SO_NODE_HEADER(SoFCMeshNode);
00041 
00042 public:
00043     static void initClass();
00044     SoFCMeshNode();
00045     void setMesh(const Mesh::MeshObject* mesh);
00046 
00047     virtual void write( SoWriteAction* action );
00048     unsigned int MaximumTriangles;
00049 
00050 protected:
00051     virtual void GLRender(SoGLRenderAction *action);
00052     virtual void computeBBox(SoAction *action, SbBox3f &box, SbVec3f &center);
00053     virtual void getPrimitiveCount(SoGetPrimitiveCountAction * action);
00054     virtual void generatePrimitives(SoAction *action);
00055     virtual SoDetail * createTriangleDetail(SoRayPickAction * action,
00056                                             const SoPrimitiveVertex * v1,
00057                                             const SoPrimitiveVertex * v2,
00058                                             const SoPrimitiveVertex * v3,
00059                                             SoPickedPoint * pp);
00060 
00061     virtual SbBool readInstance( SoInput* in, unsigned short  flags );
00062 
00063 private:
00064     // Force using the reference count mechanism.
00065     virtual ~SoFCMeshNode() {};
00066     virtual void notify(SoNotList * list);
00067     // Draw faces
00068     void drawFaces(SbBool needNormals) const;
00069     void drawPoints(SbBool needNormals) const;
00070     unsigned int countTriangles() const;
00071     void createRoughModel(bool simplest);
00072 
00073 private:
00074     const Mesh::MeshObject*  _mesh;
00075     unsigned int _ctPrimitives;
00076     SoMFVec3f point;
00077     SoMFInt32 coordIndex;
00078 };
00079 
00080 // ------------------------------------------------------------
00081 
00082 class MeshGuiExport SoFCMeshOpenEdge : public SoShape {
00083     typedef SoShape inherited;
00084 
00085     SO_NODE_HEADER(SoFCMeshOpenEdge);
00086     
00087 public:
00088     static void initClass();
00089     SoFCMeshOpenEdge();
00090     void setMesh(const Mesh::MeshObject* mesh);
00091 
00092 protected:
00093     virtual void GLRender(SoGLRenderAction *action);
00094     virtual void computeBBox(SoAction *action, SbBox3f &box, SbVec3f &center);
00095     virtual void getPrimitiveCount(SoGetPrimitiveCountAction * action);
00096     virtual void generatePrimitives(SoAction *action);
00097 private:
00098     // Force using the reference count mechanism.
00099     virtual ~SoFCMeshOpenEdge() {};
00100     void drawLines() const ;
00101 
00102 private:
00103     const Mesh::MeshObject*  _mesh;
00104 };
00105 
00106 } // namespace MeshGui
00107 
00108 
00109 #endif // MESHGUI_SOFC_MESH_NODE_H
00110 

Generated on Wed Nov 23 19:00:39 2011 for FreeCAD by  doxygen 1.6.1