Extrusion.h

Go to the documentation of this file.
00001 
00002 //    Copyright 2004, SenseGraphics AB
00003 //
00004 //    This file is part of H3D API.
00005 //
00006 //    H3D API is free software; you can redistribute it and/or modify
00007 //    it under the terms of the GNU General Public License as published by
00008 //    the Free Software Foundation; either version 2 of the License, or
00009 //    (at your option) any later version.
00010 //
00011 //    H3D API 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 General Public License for more details.
00015 //
00016 //    You should have received a copy of the GNU General Public License
00017 //    along with H3D API; if not, write to the Free Software
00018 //    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 //
00020 //    A commercial license is also available. Please contact us at 
00021 //    www.sensegraphics.com for more information.
00022 //
00023 //
00027 //
00029 #ifndef __EXTRUSION_H__
00030 #define __EXTRUSION_H__
00031 
00032 #include "X3DGeometryNode.h"
00033 #include "SFInt32.h"
00034 #include "SFFloat.h"
00035 #include "MFRotation.h"
00036 #include "MFVec2f.h"
00037 
00038 namespace H3D {
00039 
00048   class H3DAPI_API Extrusion : public X3DGeometryNode {
00049         protected:
00050                 
00052                 template <typename T>
00053                 inline bool coinc(T a , T b) 
00054                                         { return H3DAbs( ( a - b ).lengthSqr()) < Constants::f_epsilon; }
00055                 
00057                 inline Vec3f calculateNormal( const vector < Vec3f > &vertex_vector,
00058                                                                                                                                         H3DInt32 right,
00059                                                                                                                                         H3DInt32 middle,
00060                                                                                                                                         H3DInt32 left) {
00061                         return ( vertex_vector[ right ] - vertex_vector[ middle ] ).crossProduct(
00062                                                          vertex_vector[ left ] - vertex_vector[ middle ] ); }
00063 
00065                 vector< H3DInt32 > findSurroundingFaces( 
00066                                                                                                 H3DInt32 i,
00067                                                                                                 H3DInt32 j,
00068                                                                                                 bool closedSpine,
00069                                                                                                 H3DInt32 nrOfSpinePoints,
00070                                                                                                 bool closedCrossSection,
00071                                                                                                 H3DInt32 nrOfCrossSectionPoints);
00072 
00076                 void generateNormalsPerVertex( 
00077                       vector < Vec3f > &normalVector,
00078                                                                                         const vector < Vec3f > &vertex_vector,
00079                                                                                         const vector < Vec2f > &cross_section,
00080                                                                                         vector < Vec3f > &yAxis,
00081                                                                                         bool ccwcheck,
00082                                                                                         H3DInt32 nrOfCrossSectionPoints,
00083                                                                                         H3DInt32 nrOfSpinePoints,
00084                                                                                         bool closedSpine,
00085                                                                                         H3DFloat crease_angle,
00086                                                                                         H3DInt32 &ifCapsAdd );
00087                 
00092     void generateNormalsPerVertex( 
00093                       vector < Vec3f > &normalVector,
00094                                                                                         const vector < Vec3f > &vertex_vector,
00095                                                                                         const vector < Vec2f > &cross_section,
00096                                                                                         vector < Vec3f > &yAxis,
00097                                                                                         bool ccwcheck,
00098                                                                                         H3DInt32 nrOfCrossSectionPoints,
00099                                                                                         H3DInt32 nrOfSpinePoints,
00100                                                                                         bool closedSpine,
00101                                                                                         H3DInt32 &ifCapsAdd );
00102 
00105                 vector< Vec3f > generateNormalsPerFace(  
00106                                                                                         const vector < Vec3f > &vertex_vector,
00107                                                                                         const vector < Vec2f > &cross_section,
00108                                                                                         vector < Vec3f > &yAxis,
00109                                                                                         bool ccwcheck,
00110                                                                                         H3DInt32 nrOfCrossSectionPoints,
00111                                                                                         H3DInt32 nrOfSpinePoints,
00112                                                                                         bool closedCrossSection,
00113                                                                                         H3DInt32 &ifCapsAdd );
00114 
00115   public:
00116 
00122     class H3DAPI_API SFBound: public TypedField< X3DGeometryNode::SFBound,
00123                                       Types< MFVec3f > >{
00124       virtual void update();
00125     };
00126 
00134     class H3DAPI_API VertexVectors: 
00135       public TypedField< MFVec3f,
00136                          Types< MFVec2f, 
00137                                 MFRotation, 
00138                                 MFVec2f, 
00139                                 MFVec3f > > {
00140       virtual void update();
00141                 };
00142 
00144     virtual void render();
00145 
00146 #ifdef USE_HAPTICS
00149     virtual void traverseSG( TraverseInfo &ti );  
00150 #endif
00151 
00153     Extrusion( Inst< SFNode           > _metadata        = 0,
00154                Inst< SFBound          > _bound           = 0,
00155                Inst< DisplayList      > _displayList     = 0,
00156                Inst< SFBool           > _beginCap                                = 0,
00157                                                          Inst< SFBool           > _ccw             = 0,
00158                Inst< SFBool           > _convex                                  = 0,
00159                Inst< SFFloat          > _creaseAngle     = 0,
00160                Inst< MFVec2f          > _crossSection    = 0,
00161                Inst< SFBool                                             > _endCap                = 0,
00162                Inst< MFRotation       > _orientation     = 0,
00163                Inst< MFVec2f          > _scale           = 0,
00164                Inst< SFBool           > _solid           = 0,
00165                                                          Inst< MFVec3f          > _spine           = 0,
00166                                                          Inst< VertexVectors    > _vertexVector    = 0 );
00167 
00182     auto_ptr< SFBool >  beginCap;
00183 
00184         
00202     auto_ptr< SFBool >  ccw;
00203     
00214     auto_ptr< SFBool >  convex;
00215 
00228     auto_ptr< SFFloat > creaseAngle;
00229 
00239     auto_ptr< MFVec2f >  crossSection;
00240 
00255     auto_ptr< SFBool >  endCap;
00256 
00268     auto_ptr< MFRotation >  orientation;
00269 
00281     auto_ptr< MFVec2f >  scale;
00282 
00294     auto_ptr< SFBool >  solid;
00295 
00303     auto_ptr< MFVec3f >  spine;
00304 
00309     auto_ptr< VertexVectors  >  vertexVector;
00310 
00312     static H3DNodeDatabase database;
00313   };
00314 }
00315 
00316 #endif

Generated on Thu Aug 24 12:38:32 2006 for H3D API by  doxygen 1.4.5