H3D API  2.4.1
NurbsTrimmedSurface.h
Go to the documentation of this file.
1 // Copyright 2004-2019, SenseGraphics AB
3 //
4 // This file is part of H3D API.
5 //
6 // H3D API is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
10 //
11 // H3D API is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with H3D API; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 //
20 // A commercial license is also available. Please contact us at
21 // www.sensegraphics.com for more information.
22 //
23 //
27 //
29 #ifndef __NURBSTRIMMEDSURFACE_H__
30 #define __NURBSTRIMMEDSURFACE_H__
31 
33 #include <H3D/Contour2D.h>
34 
35 namespace H3D {
36 
58  public:
59 
63  class H3DAPI_API AddContour: public MFNode {
64  public:
65 
66  virtual void onAdd( Node *n ) {
67  MFNode::onAdd( n );
68  Contour2D *contour_2D =
69  dynamic_cast< Contour2D * >( n );
70 
71  if( !contour_2D ) {
72  stringstream s;
73  s << "Expecting Contour2D";
74  throw InvalidNodeType( n->getTypeName(),
75  s.str(),
77  }
78  else {
79  NurbsTrimmedSurface * nurbs_trimmed_surface =
80  static_cast< NurbsTrimmedSurface * >( getOwner() );
81  nurbs_trimmed_surface->trimmingContour->push_back( n );
82  }
83  }
84  };
85 #ifdef __BORLANDC__
86  friend class AddContour;
87 #endif
88 
92  class H3DAPI_API RemoveContour: public MFNode {
93  public:
94 
95 
96  virtual void onRemove( Node *n ) {
97  Contour2D *contour_2D =
98  dynamic_cast< Contour2D * >( n );
99 
100  if( !contour_2D ) {
101  stringstream s;
102  s << "Expecting Contour2D";
103  throw InvalidNodeType( n->getTypeName(),
104  s.str(),
106  }
107  else {
108  NurbsTrimmedSurface * nurbs_trimmed_surface =
109  static_cast< NurbsTrimmedSurface * >( getOwner() );
110  nurbs_trimmed_surface->trimmingContour->erase( n );
111  }
112 
113  MFNode::onRemove( n );
114  }
115  };
116 #ifdef __BORLANDC__
117  friend class RemoveContour;
118 #endif
119 
122  class H3DAPI_API CheckContour: public MFNode {
123  public:
124 
125  virtual void onAdd( Node *n ) {
126  MFNode::onAdd( n );
127  Contour2D *contour_2D =
128  dynamic_cast< Contour2D * >( n );
129 
130  if( !contour_2D ) {
131  stringstream s;
132  s << "Expecting Contour2D";
133  throw InvalidNodeType( n->getTypeName(),
134  s.str(),
136  }
137  }
138 
139  virtual void onRemove( Node *n ) {
140  Contour2D *contour_2D =
141  dynamic_cast< Contour2D * >( n );
142 
143  if( !contour_2D ) {
144  stringstream s;
145  s << "Expecting Contour2D";
146  throw InvalidNodeType( n->getTypeName(),
147  s.str(),
149  }
150 
151  MFNode::onRemove( n );
152  }
153  };
154 #ifdef __BORLANDC__
155  friend class CheckContour;
156 #endif
158  NurbsTrimmedSurface( Inst< SFNode > _metadata = 0,
159  Inst< SFBound > _bound = 0,
160  Inst< DisplayList > _displayList = 0,
161  Inst< MFBool > _isTouched = 0,
162  Inst< MFVec3f > _force = 0,
163  Inst< MFVec3f > _contactPoint = 0,
164  Inst< MFVec3f > _contactNormal = 0,
165  Inst< AddContour > _addTrimmingContour = 0,
166  Inst< RemoveContour > _removeTrimmingContour = 0,
167  Inst< SFCoordinateNode > _controlPoint = 0,
168  Inst< TexCoordOrNurbsTex > _texCoord = 0,
169  Inst< CheckContour > _trimmingContour = 0,
170  Inst< SFInt32 > _uTessellation = 0,
171  Inst< SFInt32 > _vTessellation = 0,
172  Inst< MFDouble > _weight = 0,
173  Inst< SFBool > _solid = 0,
174  Inst< SFBool > _uClosed = 0,
175  Inst< SFBool > _vClosed = 0,
176  Inst< SFInt32 > _uDimension = 0,
177  Inst< SFInt32 > _vDimension = 0,
178  Inst< MFDouble > _uKnot = 0,
179  Inst< MFDouble > _vKnot = 0,
180  Inst< SFInt32 > _uOrder = 0,
181  Inst< SFInt32 > _vOrder = 0 );
182 
186  virtual void renderBetweenBeginEnd(
187  GLUnurbsObj *_nurbs_object,
188  X3DTextureCoordinateNode *tex_coord_node,
189  TextureCoordinateGenerator *tex_coord_gen,
190  NurbsTextureCoordinate *nurbs_tex_coord,
191  GLfloat *texKnotU,
192  GLfloat *texKnotV,
193  GLfloat *texCoordinates,
194  GLfloat *u_knots,
195  GLfloat *v_knots,
196  H3DInt32 &sizeOfVertex,
197  GLfloat *withWeights,
198  H3DInt32 &uSizeToUse,
199  H3DInt32 &vSizeToUse,
200  H3DInt32 &map2Vertex3Or4 );
201 
207  H3DUniquePtr< AddContour > addTrimmingContour;
208 
214  H3DUniquePtr< RemoveContour > removeTrimmingContour;
215 
222  H3DUniquePtr< CheckContour > trimmingContour;
223 
226  };
227 }
228 
229 #endif
Header file for Contour2D, X3D scene-graph node.
#define H3D_FULL_LOCATION
Header file for X3DNurbsSurfaceGeometryNode, X3D scene-graph node.
std::string getTypeName() const
The Contour2D node groups a set of curve segments to a composite contour.
Definition: Contour2D.h:62
MFNode is almost like any MField but it encapsulates a vector of Node pointers.
Definition: MFNode.h:44
Node is the base class for all classes that can be part of the H3D scene-graph.
Definition: Node.h:46
The NurbsTextureCoordinate node is a NURBS surface existing in the parametric domain of its surface h...
Definition: NurbsTextureCoordinate.h:71
This field class checks whether the given node is of the right type (Contour2D).
Definition: NurbsTrimmedSurface.h:63
virtual void onAdd(Node *n)
This function will be called when values of RefCountMField changes.
Definition: NurbsTrimmedSurface.h:66
This field class checks whether the given node is of the right type (Contour2D) for adding or removin...
Definition: NurbsTrimmedSurface.h:122
virtual void onAdd(Node *n)
This function will be called when values of RefCountMField changes.
Definition: NurbsTrimmedSurface.h:125
virtual void onRemove(Node *n)
This function will be called when values of RefCountMField changes.
Definition: NurbsTrimmedSurface.h:139
This field class checks whether the given node is of the right type (Contour2D).
Definition: NurbsTrimmedSurface.h:92
virtual void onRemove(Node *n)
This function will be called when values of RefCountMField changes.
Definition: NurbsTrimmedSurface.h:96
The NurbsTrimmedSurface node defines a NURBS surface that is trimmed by a set of trimming loops.
Definition: NurbsTrimmedSurface.h:57
virtual void renderBetweenBeginEnd(GLUnurbsObj *_nurbs_object, X3DTextureCoordinateNode *tex_coord_node, TextureCoordinateGenerator *tex_coord_gen, NurbsTextureCoordinate *nurbs_tex_coord, GLfloat *texKnotU, GLfloat *texKnotV, GLfloat *texCoordinates, GLfloat *u_knots, GLfloat *v_knots, H3DInt32 &sizeOfVertex, GLfloat *withWeights, H3DInt32 &uSizeToUse, H3DInt32 &vSizeToUse, H3DInt32 &map2Vertex3Or4)
Function called by render to render the small part that differs between NurbsPatchSurface and NurbsTr...
Definition: NurbsTrimmedSurface.cpp:90
static H3DNodeDatabase database
The H3DNodeDatabase for this node.
Definition: NurbsTrimmedSurface.h:225
NurbsTrimmedSurface(Inst< SFNode > _metadata=0, Inst< SFBound > _bound=0, Inst< DisplayList > _displayList=0, Inst< MFBool > _isTouched=0, Inst< MFVec3f > _force=0, Inst< MFVec3f > _contactPoint=0, Inst< MFVec3f > _contactNormal=0, Inst< AddContour > _addTrimmingContour=0, Inst< RemoveContour > _removeTrimmingContour=0, Inst< SFCoordinateNode > _controlPoint=0, Inst< TexCoordOrNurbsTex > _texCoord=0, Inst< CheckContour > _trimmingContour=0, Inst< SFInt32 > _uTessellation=0, Inst< SFInt32 > _vTessellation=0, Inst< MFDouble > _weight=0, Inst< SFBool > _solid=0, Inst< SFBool > _uClosed=0, Inst< SFBool > _vClosed=0, Inst< SFInt32 > _uDimension=0, Inst< SFInt32 > _vDimension=0, Inst< MFDouble > _uKnot=0, Inst< MFDouble > _vKnot=0, Inst< SFInt32 > _uOrder=0, Inst< SFInt32 > _vOrder=0)
Constructor.
Definition: NurbsTrimmedSurface.cpp:50
H3DUniquePtr< AddContour > addTrimmingContour
This field adds specified Contour2D nodes to the trimmingContour field.
Definition: NurbsTrimmedSurface.h:207
H3DUniquePtr< RemoveContour > removeTrimmingContour
This field removes Contour2D nodes from the trimmingContour field.
Definition: NurbsTrimmedSurface.h:214
H3DUniquePtr< CheckContour > trimmingContour
The trimmingContour field, if specified, shall contain a set of Contour2D nodes.
Definition: NurbsTrimmedSurface.h:222
virtual void onRemove(Node *n)
This function will be called when values of RefCountMField changes.
Definition: RefCountMField.h:233
virtual void onAdd(Node *n)
This function will be called when values of RefCountMField changes.
Definition: RefCountMField.h:222
TextureCoordinateGenerator supports the automatic generation of texture coodinates for geometric shap...
Definition: TextureCoordinateGenerator.h:92
The X3DNurbsSurfaceGeometryNode represents the abstract geometry type for all types of NURBS surfaces...
Definition: X3DNurbsSurfaceGeometryNode.h:126
This abstract node type is the base type for all node types which specify texture coordinates.
Definition: X3DTextureCoordinateNode.h:55
int H3DInt32
H3D API namespace.
Definition: Anchor.h:38
The H3DNodeDatabase contains a mapping between a name of a Node and the constructor for the Node with...
Definition: H3DNodeDatabase.h:194