Developer Documentation
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 #ifndef PRIMITIVESGENERATORPLUGIN_HH
44 #define PRIMITIVESGENERATORPLUGIN_HH
45 
53 
56 
57 #ifdef ENABLE_POLYHEDRALMESH_SUPPORT
59 #endif
60 
61 
63  Q_OBJECT
64  Q_INTERFACES(BaseInterface)
65  Q_INTERFACES(LoggingInterface)
66  Q_INTERFACES(MenuInterface)
67  Q_INTERFACES(LoadSaveInterface)
68  Q_INTERFACES(RPCInterface)
69  Q_INTERFACES(BackupInterface)
70 
71  Q_PLUGIN_METADATA(IID "org.OpenFlipper.Plugins.Plugin-PrimitiveGenerator")
72 
73  signals:
74 
75  //BaseInterface
76  void updateView();
77  void updatedObject(int _id, const UpdateType& _type);
78  void setSlotDescription(QString _slotName, QString _slotDescription,
79  QStringList _parameters, QStringList _descriptions);
80  //LoggingInterface
81  void log(Logtype _type, QString _message);
82  void log(QString _message);
83 
84  // Menu Interface
85  void getMenubarMenu (QString _name, QMenu *& _menu, bool _create);
86 
87  // LoadSaveInterface
88  void addEmptyObject( DataType _type, int& _id);
89 
90  // BackupInterface
91  void createBackup( int _objectid, QString _name, UpdateType _type = UPDATE_ALL);
92 
93 public:
94 
97 
98  // BaseInterface
99  QString name() { return (QString("Primitives Generator")); } ;
100  QString description() { return (QString("Plugin used for generating basic primitives")); } ;
101 
102 private slots:
103 
105  void initializePlugin();
106  void pluginsInitialized();
107 
109  void noguiSupported( ) {} ;
110 
111 public slots:
112 
113  QString version() { return QString("1.0"); };
114 
115  int addTriangulatedCylinder(const Vector& _position = Vector(0.0,0.0,0.0),
116  const Vector& _axis = Vector(0.0,0.0,1.0),
117  const double _radius = 1.0,
118  const double _height = 5.0,
119  const bool _top = true,
120  const bool _bottom = true);
121 
122  int addSphere(const Vector& _position = Vector(0.0,0.0,0.0),
123  const double _radius = 1.0);
124 
125  int addSubdivisionSphere(const Vector& _position = Vector(0.0,0.0,0.0),
126  const double _radius = 1.0);
127 
128  int addTetrahedron(const Vector& _position = Vector(0.0,0.0,0.0),
129  const double _length = 2.0);
130 
131  int addPyramid(const Vector& _position = Vector(0.0,0.0,0.0),
132  const double _length = 2.0);
133 
134  int addCube(const Vector& _position = Vector(0.0,0.0,0.0),
135  const double _length = 2.0);
136 
137  int addTriangulatedCube(const Vector& _position = Vector(0.0,0.0,0.0),
138  const double _length = 2.0);
139 
140  int addIcosahedron(const Vector& _position = Vector(0.0,0.0,0.0),
141  const double _length = 2.0);
142 
143  int addOctahedron(const Vector& _position = Vector(0.0,0.0,0.0),
144  const double _length = 2.0);
145 
146  int addDodecahedron(const Vector& _position = Vector(0.0,0.0,0.0),
147  const double _length = 2.0);
148 
149 #ifdef ENABLE_BSPLINECURVE_SUPPORT
150  int addRandomBSplineCurve(const Vector& _position = Vector(0, 0, 0), int nDiv = 5);
151 #endif
152 
153 #ifdef ENABLE_BSPLINESURFACE_SUPPORT
154  int addRandomBSplineSurface(const Vector& _position = Vector(0, 0, 0), int nDiv = 5);
155 #endif
156 
157 #ifdef ENABLE_POLYHEDRALMESH_SUPPORT
158  int addTetrahedralCube(const Vector& _position = Vector(0.0,0.0,0.0),
159  const double _length = 2.0);
160 
161  int addTetrahedralCuboid(const Vector& _position = Vector(0.0,0.0,0.0),
162  const Vector& _length = Vector(4.0,6.0,12.0),
163  const unsigned int n_x = 5,
164  const unsigned int n_y = 5,
165  const unsigned int n_z = 10);
166 #endif
167 #ifdef ENABLE_HEXAHEDRALMESH_SUPPORT
168  int addHexahedralCube(const Vector& _position = Vector(0.0,0.0,0.0),
169  const double _length = 2.0);
170 #endif
171 
172 private:
173  int addTriMesh();
174  int addPolyMesh();
175  // construct Octahedron in triMesh_
176  void constructOctahedron(const Vector& _position, const double _length);
177 
178 #ifdef ENABLE_POLYHEDRALMESH_SUPPORT
179  int addPolyhedralMesh();
180 #endif
181  inline void add_face(int _vh1 , int _vh2, int _vh3);
182 
183  inline void add_face(int _vh1 , int _vh2, int _vh3 , int _vh4);
184 
185  inline void add_face( int _vh1 , int _vh2, int _vh3, int _vh4 , int _vh5 );
186 
187  inline ACG::Vec3d positionOnCylinder(const int _sliceNumber,
188  const int _stackNumber,
189  const Vector _position ,
190  const Vector _axis,
191  const double _radius,
192  const double _height);
193 
194  inline ACG::Vec3d positionOnSphere(int _sliceNumber, int _stackNumber, const double _radius, const Vector& _position);
195  inline ACG::Vec2f texCoordOnSphere(int _sliceNumber, int _stackNumber);
196 
197  std::vector<TriMesh::VertexHandle> vhandles_;
198  std::vector<PolyMesh::VertexHandle> vphandles_;
199 
200  TriMesh* triMesh_;
201  PolyMesh* polyMesh_;
202 
203  int slices_;
204  int stacks_;
205 
206  QMenu* primitivesMenu_;
207 
208 };
209 
210 #endif //PRIMITIVESGENERATORPLUGIN_HH
Update type class.
Definition: UpdateType.hh:60
Interface to call functions across plugins.
Definition: RPCInterface.hh:61
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
void initializePlugin()
BaseInterface.
Logtype
Log types for Message Window.
Interface for all plugins which want to Load or Save files and create Objects.
Interface for all Plugins which do logging to the logging window of the framework.
void noguiSupported()
Tell system that this plugin runs without ui.
QString name()
Return a name for the plugin.
Interface class from which all plugins have to be created.
Predefined datatypes.
Definition: DataTypes.hh:83
Interface for all plugins which provide entries to the main menubar.
ACG::Vec3d Vector
Standard Type for 3d Vector used for scripting.
Definition: DataTypes.hh:174
Interface class for backup handling.
QString description()
Return a description of what the plugin is doing.