Visualization Library 2.0.0-b3

A lightweight C++ OpenGL middleware for 2D/3D graphics

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
BezierSurface.hpp
Go to the documentation of this file.
1 /**************************************************************************************/
2 /* */
3 /* Visualization Library */
4 /* http://visualizationlibrary.org */
5 /* */
6 /* Copyright (c) 2005-2017, Michele Bosi */
7 /* All rights reserved. */
8 /* */
9 /* Redistribution and use in source and binary forms, with or without modification, */
10 /* are permitted provided that the following conditions are met: */
11 /* */
12 /* - Redistributions of source code must retain the above copyright notice, this */
13 /* list of conditions and the following disclaimer. */
14 /* */
15 /* - Redistributions in binary form must reproduce the above copyright notice, this */
16 /* list of conditions and the following disclaimer in the documentation and/or */
17 /* other materials provided with the distribution. */
18 /* */
19 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND */
20 /* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED */
21 /* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
22 /* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR */
23 /* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */
24 /* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
25 /* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON */
26 /* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
27 /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
28 /* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
29 /* */
30 /**************************************************************************************/
31 
32 #ifndef BezierSurface_INCLUDE_ONCE
33 #define BezierSurface_INCLUDE_ONCE
34 
35 #include <vlGraphics/Geometry.hpp>
36 
37 namespace vl
38 {
45  {
47 
48  public:
50  typedef std::vector< vec3 > Points;
52  BezierPatch(): mX(0), mY(0)
53  {
54  VL_DEBUG_SET_OBJECT_NAME()
55  }
57  BezierPatch(int x, int y): mX(0), mY(0)
58  {
59  VL_DEBUG_SET_OBJECT_NAME()
60  resize(x,y);
61  }
64  void resize(int x, int y);
66  int x() const { return mX; }
68  int y() const { return mY; }
70  Points& points() { return mControlPoints; }
72  const Points& points() const { return mControlPoints; }
74  vec3& at(int i, int j) { return mControlPoints[i + mX*j]; }
76  const vec3& at(int i, int j) const { return mControlPoints[i + mX*j]; }
77  protected:
79  int mX;
80  int mY;
81  };
82 
95  {
97 
98  public:
100  BezierSurface(): mDetail(16)
101  {
102  VL_DEBUG_SET_OBJECT_NAME()
103  }
104 
106  std::vector< ref<BezierPatch> >& patches() { return mPatches; }
108  const std::vector< ref<BezierPatch> >& patches() const { return mPatches; }
109 
111  void setDetail(unsigned i) { mDetail = i; }
112 
114  unsigned detail() const { return mDetail; }
115 
120  void updateBezierSurface(bool gen_tex_coords=true);
121 
122  protected:
123  std::vector< ref<BezierPatch> > mPatches;
124  unsigned mDetail;
125  };
126 }
127 
128 #endif
const std::vector< ref< BezierPatch > > & patches() const
Returns the Bézier patches that are part of this Bézier surface.
std::vector< ref< BezierPatch > > mPatches
int x() const
Returns the x dimension of the patch as specified by resize().
std::vector< vec3 > Points
The control points grid defining the bicubic Bézier patch(es).
vec3 & at(int i, int j)
Returns the i/j control point.
unsigned detail() const
The sampling level of the patch, must not be less than 2. The higher the sampling level...
#define VL_INSTRUMENT_CLASS(ClassName, BaseClass)
Definition: TypeInfo.hpp:122
The Geometry class is a Renderable that implements a polygonal mesh made of polygons, lines and points.
Definition: Geometry.hpp:66
Points & points()
The control points grid defining the bicubic Bézier patch(es).
Visualization Library main namespace.
int y() const
Returns the y dimension of the patch as specified by resize().
The Vector3 class is a template class that implements a generic 3 components vector, see also vl::fvec3, vl::dvec3, vl::uvec3, vl::ivec3, vl::svec3, vl::usvec3, vl::bvec3, vl::ubvec3.
Definition: Vector3.hpp:44
Defines one or more concatenated bicubic Bézier patches to be used with the BezierSurface class...
The base class for all the reference counted objects.
Definition: Object.hpp:158
The BezierSurface class implements a Geometry that is capable of visualizing multiple bicubic Bézier ...
void setDetail(unsigned i)
The sampling level of the patch, must not be less than 2. The higher the sampling level...
std::vector< ref< BezierPatch > > & patches()
Returns the Bézier patches that are part of this Bézier surface.
BezierPatch(int x, int y)
Constructor.
BezierPatch()
Constructor.
const Points & points() const
The control points grid defining the bicubic Bézier patch(es).
const vec3 & at(int i, int j) const
Returns the i/j control point.
BezierSurface()
Constructor.