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