00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
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