Contour2D.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 __CONTOUR2D_H__
00030 #define __CONTOUR2D_H__
00031 
00032 #include "X3DNode.h"
00033 #include "MFNode.h"
00034 #include "NurbsCurve2D.h"
00035 #include "ContourPolyline2D.h"
00036 #include "GL/glew.h"
00037 
00038 namespace H3D {
00039 
00056 
00057   class H3DAPI_API Contour2D : 
00058     public X3DNode {
00059   public:
00060 
00061 
00065                 class H3DAPI_API AddTheChildren: public MFNode {
00066                 public:
00067 
00068                         virtual void onAdd( Node *n ) {
00069                                 MFNode::onAdd( n );
00070                                 NurbsCurve2D *nurbs_curve_2D = 
00071                                         dynamic_cast< NurbsCurve2D * >( n );
00072 
00073                                 ContourPolyline2D *contour_poly_line_2D = 
00074                                         dynamic_cast< ContourPolyline2D * >( n );
00075 
00076                                 if( !nurbs_curve_2D && !contour_poly_line_2D ) {
00077                                         stringstream s;
00078                                         s << "Expecting NurbsCurve2D or ContourPolyline2D";
00079                                         throw InvalidNodeType( n->getTypeName(),
00080                                                 s.str(),
00081                                                 H3D_FULL_LOCATION );
00082                                 }
00083                                 else{
00084                                         Contour2D * contourNode2D = 
00085           static_cast< Contour2D * >( getOwner() );
00086                                                 contourNode2D->children->push_back( n );
00087                                 }
00088                         }
00089                 };
00090     friend class AddTheChildren;
00091 
00095                 class H3DAPI_API RemoveTheChildren: public MFNode {
00096                 public:
00097 
00098                         
00099                         virtual void onRemove( Node *n ) {
00100                                 NurbsCurve2D *nurbs_curve_2D = 
00101                                         dynamic_cast< NurbsCurve2D * >( n );
00102 
00103                                 ContourPolyline2D *contour_poly_line_2D = 
00104                                         dynamic_cast< ContourPolyline2D * >( n );
00105 
00106                                 if( !nurbs_curve_2D && !contour_poly_line_2D ) {
00107                                         stringstream s;
00108                                         s << "Expecting NurbsCurve2D or ContourPolyline2D";
00109                                         throw InvalidNodeType( n->getTypeName(),
00110                                                 s.str(),
00111                                                 H3D_FULL_LOCATION );
00112                                 }
00113                                 else {
00114                                         Contour2D * contourNode2D = 
00115           static_cast< Contour2D * >( getOwner() );
00116                                         contourNode2D->children->erase( n );
00117                                 }
00118 
00119                                 MFNode::onRemove( n );
00120                         }
00121                 };
00122     friend class RemoveTheChildren;
00123 
00127                 class H3DAPI_API CheckTheChildren: public MFNode {
00128                 public:
00129 
00130                         virtual void onAdd( Node *n ) {
00131                                 MFNode::onAdd( n );
00132                                 NurbsCurve2D *nurbs_curve_2D = 
00133                                         dynamic_cast< NurbsCurve2D * >( n );
00134 
00135                                 ContourPolyline2D *contour_poly_line_2D = 
00136                                         dynamic_cast< ContourPolyline2D * >( n );
00137 
00138                                 if( !nurbs_curve_2D && !contour_poly_line_2D ) {
00139                                         stringstream s;
00140                                         s << "Expecting NurbsCurve2D or ContourPolyline2D";
00141                                         throw InvalidNodeType( n->getTypeName(),
00142                                                 s.str(),
00143                                                 H3D_FULL_LOCATION );
00144                                 }
00145                         }
00146 
00147                         virtual void onRemove( Node *n ) {
00148                                 NurbsCurve2D *nurbs_curve_2D = 
00149                                         dynamic_cast< NurbsCurve2D * >( n );
00150 
00151                                 ContourPolyline2D *contour_poly_line_2D = 
00152                                         dynamic_cast< ContourPolyline2D * >( n );
00153 
00154                                 if( !nurbs_curve_2D && !contour_poly_line_2D ) {
00155                                         stringstream s;
00156                                         s << "Expecting NurbsCurve2D or ContourPolyline2D";
00157                                         throw InvalidNodeType( n->getTypeName(),
00158                                                 s.str(),
00159                                                 H3D_FULL_LOCATION );
00160                                 }
00161 
00162                                 MFNode::onRemove( n );
00163                         }
00164                 };
00165     friend class CheckTheChildren;
00166 
00168                 void renderTrimmedCurve( GLUnurbsObj *nurbs_object );
00169 
00171     Contour2D( Inst< SFNode >                                            _metadata                       = 0,
00172                Inst< AddTheChildren              > _addChildren          = 0,
00173                Inst< RemoveTheChildren > _removeChildren = 0,
00174                Inst< CheckTheChildren    > _children                     = 0 );
00175 
00181     auto_ptr< AddTheChildren >  addChildren;
00182 
00189     auto_ptr< RemoveTheChildren > removeChildren;
00190 
00196     auto_ptr< CheckTheChildren > children;
00197 
00199     static H3DNodeDatabase database;
00200   };
00201 }
00202 
00203 #endif

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