Visualization Library 2.0.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 {
54  {
56 
57  public:
60  {
61  VL_DEBUG_SET_OBJECT_NAME()
62  mSmooth = false;
63  mFillBottom = true;
64  mFillTop = true;
65  mSilhouetteMode = SilhouetteClosed;
66  }
67 
69  vl::ref<vl::Geometry> extrude(bool compatibilityProfile = true);
70 
72  void setSilhouettes(const std::vector<unsigned int>& silhouettes) { mSilhouettes = silhouettes; }
74  const std::vector<unsigned int>& silhouettes() const { return mSilhouettes; }
76  std::vector<unsigned int>& silhouettes() { return mSilhouettes;}
77 
79  void setSilhouette(const std::vector<vl::fvec2>& silhouette) { mSilhouette = silhouette; }
81  const std::vector<vl::fvec2>& silhouette() const { return mSilhouette; }
83  std::vector<vl::fvec2>& silhouette() { return mSilhouette; }
84 
86  void setSilhouetteMode(ESilhouetteMode mode) { mSilhouetteMode = mode; }
88  ESilhouetteMode silhouetteMode() const { return mSilhouetteMode; }
89 
91  void setSmooth(bool smooth) { mSmooth = smooth; }
93  bool smooth() const { return mSmooth; }
94 
96  void setFillBottom(bool fill) { mFillBottom = fill; }
98  bool fillBottom() const { return mFillBottom; }
99 
101  void setFillTop(bool fill) { mFillTop = fill; }
103  bool fillTop() const { return mFillTop; }
104 
107  const std::vector<vl::fvec3>& positionPath() const { return mPositionPath; }
110  std::vector<vl::fvec3>& positionPath() { return mPositionPath; }
114  const std::vector<float>& scalingPath() const { return mScalingPath; }
118  std::vector<float>& scalingPath() { return mScalingPath; }
122  const std::vector<float>& rotationPath() const { return mRotationPath; }
126  std::vector<float>& rotationPath() { return mRotationPath; }
130  const std::vector<vl::fvec4>& colorPath() const { return mColorPath; }
134  std::vector<vl::fvec4>& colorPath() { return mColorPath; }
135 
136  protected:
137  std::vector<unsigned int> mSilhouettes;
138  std::vector<vl::fvec2> mSilhouette;
139  std::vector<vl::fvec3> mPositionPath;
140  std::vector<float> mScalingPath;
141  std::vector<float> mRotationPath;
142  std::vector<vl::fvec4> mColorPath;
143  ESilhouetteMode mSilhouetteMode;
144  bool mSmooth;
146  bool mFillTop;
147  };
148 }
149 
150 #endif
151 
const std::vector< vl::fvec3 > & positionPath() const
The path along which the silhouette is extruded.
Definition: Extrusions.hpp:107
const std::vector< float > & scalingPath() const
The scaling to be applied along the extrusion.
Definition: Extrusions.hpp:114
bool fillBottom() const
Whether a set of triangles should be generated to fill the beginning of the extrusion (default is tru...
Definition: Extrusions.hpp:98
bool smooth() const
If true the normals of the geometry are smoothed.
Definition: Extrusions.hpp:93
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:101
std::vector< float > & rotationPath()
The rotation to be applied along the extrusion.
Definition: Extrusions.hpp:126
const std::vector< vl::fvec4 > & colorPath() const
The color to be applied to the extrusion.
Definition: Extrusions.hpp:130
Extrusions()
Constructor.
Definition: Extrusions.hpp:59
std::vector< unsigned int > mSilhouettes
Definition: Extrusions.hpp:137
#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:79
Visualization Library main namespace.
void setSmooth(bool smooth)
If true the normals of the geometry are smoothed.
Definition: Extrusions.hpp:91
const std::vector< vl::fvec2 > & silhouette() const
Returns the silhouette to be extruded.
Definition: Extrusions.hpp:81
std::vector< float > mRotationPath
Definition: Extrusions.hpp:141
std::vector< unsigned int > & silhouettes()
Return the number of points in each silhouette.
Definition: Extrusions.hpp:76
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:86
ESilhouetteMode silhouetteMode() const
Wether the silhouette is considered closed, i.e. a line-loop, or open.
Definition: Extrusions.hpp:88
ESilhouetteMode mSilhouetteMode
Definition: Extrusions.hpp:143
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:96
void setSilhouettes(const std::vector< unsigned int > &silhouettes)
Sets the number of points in each silhouette.
Definition: Extrusions.hpp:72
std::vector< float > & scalingPath()
The scaling to be applied along the extrusion.
Definition: Extrusions.hpp:118
const std::vector< unsigned int > & silhouettes() const
Return the number of points in each silhouette.
Definition: Extrusions.hpp:74
std::vector< vl::fvec3 > mPositionPath
Definition: Extrusions.hpp:139
The Extrusion class generates a Geometry extruding a silhouette along a path.
Definition: Extrusions.hpp:53
std::vector< vl::fvec3 > & positionPath()
The path along which the silhouette is extruded.
Definition: Extrusions.hpp:110
std::vector< vl::fvec2 > mSilhouette
Definition: Extrusions.hpp:138
std::vector< float > mScalingPath
Definition: Extrusions.hpp:140
bool fillTop() const
Whether a set of triangles should be generated to fill the ending of the extrusion (default is true)...
Definition: Extrusions.hpp:103
std::vector< vl::fvec4 > mColorPath
Definition: Extrusions.hpp:142
std::vector< vl::fvec2 > & silhouette()
Returns the silhouette to be extruded.
Definition: Extrusions.hpp:83
const std::vector< float > & rotationPath() const
The rotation to be applied along the extrusion.
Definition: Extrusions.hpp:122
std::vector< vl::fvec4 > & colorPath()
The color to be applied to the extrusion.
Definition: Extrusions.hpp:134
ESilhouetteMode
Definition: Extrusion.hpp:43