Visualization Library 2.1.0

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

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
Extrusions.hpp
Go to the documentation of this file.
1 /**************************************************************************************/
2 /* */
3 /* Visualization Library */
4 /* http://visualizationlibrary.org */
5 /* */
6 /* Copyright (c) 2005-2020, 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 Extrusions_INCLUDE_ONCE
33 #define Extrusions_INCLUDE_ONCE
34 
35 #include <vlGraphics/Geometry.hpp>
36 #include <vlCore/Vector4.hpp>
37 #include <vlCore/Vector3.hpp>
38 #include <vlCore/Matrix4.hpp>
39 #include <vector>
40 
41 namespace vl
42 {
56  {
58 
59  public:
62  {
63  VL_DEBUG_SET_OBJECT_NAME()
64  mSmooth = false;
65  mFillBottom = true;
66  mFillTop = true;
67  mSilhouetteMode = SilhouetteClosed;
68  }
69 
71  vl::ref<vl::Geometry> extrude(bool compatibilityProfile = true);
72 
74  void setSilhouettes(const std::vector<unsigned int>& silhouettes) { mSilhouettes = silhouettes; }
76  const std::vector<unsigned int>& silhouettes() const { return mSilhouettes; }
78  std::vector<unsigned int>& silhouettes() { return mSilhouettes;}
79 
81  void setSilhouette(const std::vector<vl::fvec2>& silhouette) { mSilhouette = silhouette; }
83  const std::vector<vl::fvec2>& silhouette() const { return mSilhouette; }
85  std::vector<vl::fvec2>& silhouette() { return mSilhouette; }
86 
88  void setSilhouetteMode(ESilhouetteMode mode) { mSilhouetteMode = mode; }
90  ESilhouetteMode silhouetteMode() const { return mSilhouetteMode; }
91 
93  void setSmooth(bool smooth) { mSmooth = smooth; }
95  bool smooth() const { return mSmooth; }
96 
98  void setFillBottom(bool fill) { mFillBottom = fill; }
100  bool fillBottom() const { return mFillBottom; }
101 
103  void setFillTop(bool fill) { mFillTop = fill; }
105  bool fillTop() const { return mFillTop; }
106 
109  const std::vector<vl::fvec3>& positionPath() const { return mPositionPath; }
112  std::vector<vl::fvec3>& positionPath() { return mPositionPath; }
116  const std::vector<float>& scalingPath() const { return mScalingPath; }
120  std::vector<float>& scalingPath() { return mScalingPath; }
124  const std::vector<float>& rotationPath() const { return mRotationPath; }
128  std::vector<float>& rotationPath() { return mRotationPath; }
132  const std::vector<vl::fvec4>& colorPath() const { return mColorPath; }
136  std::vector<vl::fvec4>& colorPath() { return mColorPath; }
137 
138  protected:
139  std::vector<unsigned int> mSilhouettes;
140  std::vector<vl::fvec2> mSilhouette;
141  std::vector<vl::fvec3> mPositionPath;
142  std::vector<float> mScalingPath;
143  std::vector<float> mRotationPath;
144  std::vector<vl::fvec4> mColorPath;
146  bool mSmooth;
148  bool mFillTop;
149  };
150 }
151 
152 #endif
153 
const std::vector< vl::fvec3 > & positionPath() const
The path along which the silhouette is extruded.
Definition: Extrusions.hpp:109
const std::vector< float > & scalingPath() const
The scaling to be applied along the extrusion.
Definition: Extrusions.hpp:116
bool fillBottom() const
Whether a set of triangles should be generated to fill the beginning of the extrusion (default is tru...
Definition: Extrusions.hpp:100
bool smooth() const
If true the normals of the geometry are smoothed.
Definition: Extrusions.hpp:95
void setFillTop(bool fill)
Whether a set of triangles should be generated to fill the ending of the extrusion (default is true)...
Definition: Extrusions.hpp:103
std::vector< float > & rotationPath()
The rotation to be applied along the extrusion.
Definition: Extrusions.hpp:128
const std::vector< vl::fvec4 > & colorPath() const
The color to be applied to the extrusion.
Definition: Extrusions.hpp:132
Extrusions()
Constructor.
Definition: Extrusions.hpp:61
std::vector< unsigned int > mSilhouettes
Definition: Extrusions.hpp:139
#define VL_INSTRUMENT_CLASS(ClassName, BaseClass)
Definition: TypeInfo.hpp:122
void setSilhouette(const std::vector< vl::fvec2 > &silhouette)
Sets the silhouette to be extruded.
Definition: Extrusions.hpp:81
Visualization Library main namespace.
void setSmooth(bool smooth)
If true the normals of the geometry are smoothed.
Definition: Extrusions.hpp:93
const std::vector< vl::fvec2 > & silhouette() const
Returns the silhouette to be extruded.
Definition: Extrusions.hpp:83
std::vector< float > mRotationPath
Definition: Extrusions.hpp:143
std::vector< unsigned int > & silhouettes()
Return the number of points in each silhouette.
Definition: Extrusions.hpp:78
The base class for all the reference counted objects.
Definition: Object.hpp:158
void setSilhouetteMode(ESilhouetteMode mode)
Wether the silhouette is considered closed, i.e. a line-loop, or open.
Definition: Extrusions.hpp:88
ESilhouetteMode silhouetteMode() const
Wether the silhouette is considered closed, i.e. a line-loop, or open.
Definition: Extrusions.hpp:90
ESilhouetteMode mSilhouetteMode
Definition: Extrusions.hpp:145
void setFillBottom(bool fill)
Whether a set of triangles should be generated to fill the beginning of the extrusion (default is tru...
Definition: Extrusions.hpp:98
void setSilhouettes(const std::vector< unsigned int > &silhouettes)
Sets the number of points in each silhouette.
Definition: Extrusions.hpp:74
std::vector< float > & scalingPath()
The scaling to be applied along the extrusion.
Definition: Extrusions.hpp:120
const std::vector< unsigned int > & silhouettes() const
Return the number of points in each silhouette.
Definition: Extrusions.hpp:76
std::vector< vl::fvec3 > mPositionPath
Definition: Extrusions.hpp:141
The Extrusions class generates a Geometry extruding a silhouette along a path.
Definition: Extrusions.hpp:55
std::vector< vl::fvec3 > & positionPath()
The path along which the silhouette is extruded.
Definition: Extrusions.hpp:112
std::vector< vl::fvec2 > mSilhouette
Definition: Extrusions.hpp:140
std::vector< float > mScalingPath
Definition: Extrusions.hpp:142
bool fillTop() const
Whether a set of triangles should be generated to fill the ending of the extrusion (default is true)...
Definition: Extrusions.hpp:105
std::vector< vl::fvec4 > mColorPath
Definition: Extrusions.hpp:144
std::vector< vl::fvec2 > & silhouette()
Returns the silhouette to be extruded.
Definition: Extrusions.hpp:85
const std::vector< float > & rotationPath() const
The rotation to be applied along the extrusion.
Definition: Extrusions.hpp:124
std::vector< vl::fvec4 > & colorPath()
The color to be applied to the extrusion.
Definition: Extrusions.hpp:136
ESilhouetteMode