NurbsTrimmedSurface.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 __NURBSTRIMMEDSURFACE_H__
00030 #define __NURBSTRIMMEDSURFACE_H__
00031 
00032 #include "X3DNurbsSurfaceGeometryNode.h"
00033 #include "Contour2D.h"
00034 
00035 namespace H3D {
00036 
00051   class NurbsTrimmedSurface : 
00052     public X3DNurbsSurfaceGeometryNode {
00053   public:
00054 
00058                 class H3DAPI_API AddContour: public MFNode {
00059                 public:
00060 
00061                         virtual void onAdd( Node *n ) {
00062                                 MFNode::onAdd( n );
00063                                 Contour2D *contour_2D = 
00064                                         dynamic_cast< Contour2D * >( n );
00065 
00066                                 if( !contour_2D ) {
00067                                         stringstream s;
00068                                         s << "Expecting Contour2D";
00069                                         throw InvalidNodeType( n->getTypeName(),
00070                                                 s.str(),
00071                                                 H3D_FULL_LOCATION );
00072                                 }
00073                                 else {
00074                                         NurbsTrimmedSurface * nurbs_trimmed_surface = 
00075           static_cast< NurbsTrimmedSurface * >( getOwner() );
00076                                                 nurbs_trimmed_surface->trimmingContour->push_back( n );
00077                                 }
00078                         }
00079                 };
00080     friend class AddContour;
00081 
00085                 class H3DAPI_API RemoveContour: public MFNode {
00086                 public:
00087 
00088                         
00089                         virtual void onRemove( Node *n ) {
00090                                 Contour2D *contour_2D = 
00091                                         dynamic_cast< Contour2D * >( n );
00092 
00093                                 if( !contour_2D ) {
00094                                         stringstream s;
00095                                         s << "Expecting Contour2D";
00096                                         throw InvalidNodeType( n->getTypeName(),
00097                                                 s.str(),
00098                                                 H3D_FULL_LOCATION );
00099                                 }
00100                                 else {
00101                                         NurbsTrimmedSurface * nurbs_trimmed_surface = 
00102           static_cast< NurbsTrimmedSurface * >( getOwner() );
00103                                         nurbs_trimmed_surface->trimmingContour->erase( n );
00104                                 }
00105 
00106                                 MFNode::onRemove( n );
00107                         }
00108                 };
00109     friend class RemoveContour;
00110 
00113                 class H3DAPI_API CheckContour: public MFNode {
00114                 public:
00115 
00116                         virtual void onAdd( Node *n ) {
00117                                 MFNode::onAdd( n );
00118                                 Contour2D *contour_2D = 
00119                                         dynamic_cast< Contour2D * >( n );
00120 
00121                                 if( !contour_2D ) {
00122                                         stringstream s;
00123                                         s << "Expecting Contour2D";
00124                                         throw InvalidNodeType( n->getTypeName(),
00125                                                 s.str(),
00126                                                 H3D_FULL_LOCATION );
00127                                 }
00128                         }
00129 
00130                         virtual void onRemove( Node *n ) {
00131                                 Contour2D *contour_2D = 
00132                                         dynamic_cast< Contour2D * >( n );
00133 
00134                                 if( !contour_2D ) {
00135                                         stringstream s;
00136                                         s << "Expecting Contour2D";
00137                                         throw InvalidNodeType( n->getTypeName(),
00138                                                 s.str(),
00139                                                 H3D_FULL_LOCATION );
00140                                 }
00141 
00142                                 MFNode::onRemove( n );
00143                         }
00144                 };
00145     friend class CheckContour;
00146     
00148     NurbsTrimmedSurface( Inst< SFNode      >  _metadata = 0,
00149                                                                                                  Inst< SFBound     > _bound = 0,
00150                                                                                                  Inst< DisplayList > _displayList = 0,
00151                                                                                                  Inst< MFBool      > _isTouched = 0,
00152                                                                                                  Inst< MFVec3f     > _force = 0,
00153                                                                                                  Inst< MFVec3f     > _contactPoint = 0,
00154                                                                                                  Inst< MFVec3f     > _contactNormal = 0,
00155                                                                                                  Inst< AddContour        > _addTrimmingContour = 0,
00156                                                                                                  Inst< RemoveContour > _removeTrimmingContour = 0,
00157                                                                                                  Inst< SFCoordinateNode > _controlPoint = 0,
00158                                                                                                  Inst< TexCoordOrNurbsTex >     _texCoord = 0,
00159                                                                                                  Inst< CheckContour > _trimmingContour = 0,
00160                                                                                                  Inst< SFInt32     > _uTessellation = 0,
00161                                                                                                  Inst< SFInt32     > _vTessellation = 0,
00162                                                                                                  Inst< MFDouble    > _weight = 0,
00163                                                                                                  Inst< SFBool      > _solid = 0,
00164                                                                                                  Inst< SFBool      > _uClosed = 0,
00165                                                                                                  Inst< SFBool      > _vClosed = 0,
00166                                                                                                  Inst< SFInt32     > _uDimension = 0,
00167                                                                                                  Inst< SFInt32     > _vDimension = 0,
00168                                                                                                  Inst< MFDouble    > _uKnot = 0,
00169                                                                                                  Inst< MFDouble    > _vKnot = 0,
00170                                                                                                  Inst< SFInt32     > _uOrder = 0,
00171                                                                                                  Inst< SFInt32     > _vOrder = 0 );
00172 
00175                 virtual void renderBetweenBeginEnd(
00176                                                                                                                                 GLUnurbsObj *nurbs_object,
00177                                                                                                                                 X3DTextureCoordinateNode *tex_coord_node,
00178                                                                                                                                 TextureCoordinateGenerator *tex_coord_gen,
00179                                                                                                                                 NurbsTextureCoordinate *nurbs_tex_coord, 
00180                                                                                                                                 GLfloat *texKnotU,
00181                                                                                                                                 GLfloat *texKnotV,
00182                                                                                                                                 GLfloat *texCoordinates, 
00183                                                                                                                                 GLfloat *u_knots, 
00184                                                                                                                                 GLfloat *v_knots, 
00185                                                                                                                                 H3DInt32 &sizeOfVertex,
00186                                                                                                                                 GLfloat *withWeights, 
00187                                                                                                                                 H3DInt32 &uSizeToUse, 
00188                                                                                                                                 H3DInt32 &vSizeToUse, 
00189                                                                                                                                 H3DInt32 &map2Vertex3Or4 );
00190 
00191 #ifdef USE_HAPTICS
00194     virtual void traverseSG( TraverseInfo &ti );
00195 #endif
00196 
00202     auto_ptr< AddContour >  addTrimmingContour;
00203 
00209     auto_ptr< RemoveContour >  removeTrimmingContour;
00210 
00217     auto_ptr< CheckContour >  trimmingContour;
00218     
00220     static H3DNodeDatabase database;
00221   };
00222 }
00223 
00224 #endif

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