Developer Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
PrimitivesGenerator.hh
1 /*===========================================================================*\
2 * *
3  * OpenFlipper *
4  * Copyright (c) 2001-2015, RWTH-Aachen University *
5  * Department of Computer Graphics and Multimedia *
6  * All rights reserved. *
7  * www.openflipper.org *
8  * *
9  *---------------------------------------------------------------------------*
10  * This file is part of OpenFlipper. *
11  *---------------------------------------------------------------------------*
12  * *
13  * Redistribution and use in source and binary forms, with or without *
14  * modification, are permitted provided that the following conditions *
15  * are met: *
16  * *
17  * 1. Redistributions of source code must retain the above copyright notice, *
18  * this list of conditions and the following disclaimer. *
19  * *
20  * 2. Redistributions in binary form must reproduce the above copyright *
21  * notice, this list of conditions and the following disclaimer in the *
22  * documentation and/or other materials provided with the distribution. *
23  * *
24  * 3. Neither the name of the copyright holder nor the names of its *
25  * contributors may be used to endorse or promote products derived from *
26  * this software without specific prior written permission. *
27  * *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39  * *
40  \*===========================================================================*/
41 
42 /*===========================================================================*\
43 * *
44  * $Revision$ *
45  * $LastChangedBy$ *
46  * $Date$ *
47  * *
48  \*===========================================================================*/
49 
50 #ifndef PRIMITIVESGENERATORPLUGIN_HH
51 #define PRIMITIVESGENERATORPLUGIN_HH
52 
60 
63 
64 #ifdef ENABLE_OPENVOLUMEMESH_POLYHEDRAL_SUPPORT
66 #endif
67 
68 
70  Q_OBJECT
71  Q_INTERFACES(BaseInterface)
72  Q_INTERFACES(LoggingInterface)
73  Q_INTERFACES(MenuInterface)
74  Q_INTERFACES(LoadSaveInterface)
75  Q_INTERFACES(RPCInterface)
76  Q_INTERFACES(BackupInterface)
77 
78 #if QT_VERSION >= 0x050000
79  Q_PLUGIN_METADATA(IID "org.OpenFlipper.Plugins.Plugin-PrimitiveGenerator")
80 #endif
81 
82  signals:
83 
84  //BaseInterface
85  void updateView();
86  void updatedObject(int _id, const UpdateType& _type);
87  void setSlotDescription(QString _slotName, QString _slotDescription,
88  QStringList _parameters, QStringList _descriptions);
89  //LoggingInterface
90  void log(Logtype _type, QString _message);
91  void log(QString _message);
92 
93  // Menu Interface
94  void getMenubarMenu (QString _name, QMenu *& _menu, bool _create);
95 
96  // LoadSaveInterface
97  void addEmptyObject( DataType _type, int& _id);
98 
99  // BackupInterface
100  void createBackup( int _objectid, QString _name, UpdateType _type = UPDATE_ALL);
101 
102 public:
103 
106 
107  // BaseInterface
108  QString name() { return (QString("Primitives Generator")); } ;
109  QString description() { return (QString("Plugin used for generating basic primitives")); } ;
110 
111 private slots:
112 
114  void initializePlugin();
115  void pluginsInitialized();
116 
118  void noguiSupported( ) {} ;
119 
120 public slots:
121 
122  QString version() { return QString("1.0"); };
123 
124  int addTriangulatedCylinder(const Vector& _position = Vector(0.0,0.0,0.0),
125  const Vector& _axis = Vector(0.0,0.0,1.0),
126  const double _radius = 1.0,
127  const double _height = 5.0,
128  const bool _top = true,
129  const bool _bottom = true);
130 
131  int addSphere(const Vector& _position = Vector(0.0,0.0,0.0),
132  const double _radius = 1.0);
133 
134  int addSubdivisionSphere(const Vector& _position = Vector(0.0,0.0,0.0),
135  const double _radius = 1.0);
136 
137  int addTetrahedron(const Vector& _position = Vector(0.0,0.0,0.0),
138  const double _length = 2.0);
139 
140  int addPyramid(const Vector& _position = Vector(0.0,0.0,0.0),
141  const double _length = 2.0);
142 
143  int addTriangulatedCube(const Vector& _position = Vector(0.0,0.0,0.0),
144  const double _length = 2.0);
145 
146  int addIcosahedron(const Vector& _position = Vector(0.0,0.0,0.0),
147  const double _length = 2.0);
148 
149  int addOctahedron(const Vector& _position = Vector(0.0,0.0,0.0),
150  const double _length = 2.0);
151 
152  int addDodecahedron(const Vector& _position = Vector(0.0,0.0,0.0),
153  const double _length = 2.0);
154 
155 #ifdef ENABLE_BSPLINECURVE_SUPPORT
156  int addRandomBSplineCurve(const Vector& _position = Vector(0, 0, 0), int nDiv = 5);
157 #endif
158 
159 #ifdef ENABLE_BSPLINESURFACE_SUPPORT
160  int addRandomBSplineSurface(const Vector& _position = Vector(0, 0, 0), int nDiv = 5);
161 #endif
162 
163 #ifdef ENABLE_OPENVOLUMEMESH_POLYHEDRAL_SUPPORT
164  int addTetrahedralCube(const Vector& _position = Vector(0.0,0.0,0.0),
165  const double _length = 2.0);
166 
167  int addTetrahedralCuboid(const Vector& _position = Vector(0.0,0.0,0.0),
168  const Vector& _length = Vector(4.0,6.0,12.0),
169  const unsigned int n_x = 5,
170  const unsigned int n_y = 5,
171  const unsigned int n_z = 10);
172 #endif
173 
174 private:
175  int addTriMesh();
176  int addPolyMesh();
177  // construct Octahedron in triMesh_
178  void constructOctahedron(const Vector& _position, const double _length);
179 
180 #ifdef ENABLE_OPENVOLUMEMESH_POLYHEDRAL_SUPPORT
181  int addPolyhedralMesh();
182 #endif
183 
184  inline void add_face( int _vh1 , int _vh2, int _vh3 );
185 
186  inline void add_face( int _vh1 , int _vh2, int _vh3, int _vh4 , int _vh5 );
187 
188  inline ACG::Vec3d positionOnCylinder(const int _sliceNumber,
189  const int _stackNumber,
190  const Vector _position ,
191  const Vector _axis,
192  const double _radius,
193  const double _height);
194 
195  inline ACG::Vec3d positionOnSphere(int _sliceNumber, int _stackNumber, const double _radius, const Vector& _position);
196  inline ACG::Vec2f texCoordOnSphere(int _sliceNumber, int _stackNumber);
197 
198  std::vector<TriMesh::VertexHandle> vhandles_;
199  std::vector<PolyMesh::VertexHandle> vphandles_;
200 
201  TriMesh* triMesh_;
202  PolyMesh* polyMesh_;
203 
204  int slices_;
205  int stacks_;
206 
207  QMenu* primitivesMenu_;
208 
209 };
210 
211 #endif //PRIMITIVESGENERATORPLUGIN_HH
Interface class from which all plugins have to be created.
void noguiSupported()
Tell system that this plugin runs without ui.
QString name()
Return a name for the plugin.
Logtype
Log types for Message Window.
Update type class.
Definition: UpdateType.hh:70
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
Interface for all Plugins which do logging to the logging window of the framework.
Interface to call functions across plugins.
Definition: RPCInterface.hh:71
ACG::Vec3d Vector
Standard Type for 3d Vector used for scripting.
Definition: DataTypes.hh:187
Interface for all plugins which want to Load or Save files and create Objects.
QString description()
Return a description of what the plugin is doing.
Interface class for backup handling.
Predefined datatypes.
Definition: DataTypes.hh:96
void initializePlugin()
BaseInterface.
Interface for all plugins which provide entries to the main menubar.