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 addTriangulatedPlaneFlat(const Vector& _position = Vector(0.0,0.0,0.0),
140  const double _sizeX = 2.0, const double _sizeY = 2.0,
141  const int _segmentsX = 10, const int _segmentsY = 10 );
142 
143  int addTriangulatedPlaneBumpy(const Vector& _position = Vector(0.0,0.0,0.0),
144  const double _sizeX = 10.0, const double _sizeY = 10.0,
145  const int _segmentsX = 200, const int _segmentsY = 200 );
146 
147  int addTriangulatedPlanesNonManifold(const Vector& _position = Vector(0.0,0.0,0.0),
148  const double _sizeX = 2.0, const double _sizeY = 2.0, const double _sizeZ = 1.0,
149  const int _segmentsX = 50, const int _segmentsY = 50 , const int _segmentsZ = 50);
150 
151  int addTriangulatedCube(const Vector& _position = Vector(0.0,0.0,0.0),
152  const double _length = 2.0);
153 
154  int addIcosahedron(const Vector& _position = Vector(0.0,0.0,0.0),
155  const double _length = 2.0);
156 
157  int addOctahedron(const Vector& _position = Vector(0.0,0.0,0.0),
158  const double _length = 2.0);
159 
160  int addDodecahedron(const Vector& _position = Vector(0.0,0.0,0.0),
161  const double _length = 2.0);
162 
163 #ifdef ENABLE_BSPLINECURVE_SUPPORT
164  int addRandomBSplineCurve(const Vector& _position = Vector(0, 0, 0), int nDiv = 5);
165 #endif
166 
167 #ifdef ENABLE_BSPLINESURFACE_SUPPORT
168  int addRandomBSplineSurface(const Vector& _position = Vector(0, 0, 0), int nDiv = 5);
169 #endif
170 
171 #ifdef ENABLE_POLYHEDRALMESH_SUPPORT
172  int addTetrahedralCube(const Vector& _position = Vector(0.0,0.0,0.0),
173  const double _length = 2.0);
174 
175  int addTetrahedralCuboid(const Vector& _position = Vector(0.0,0.0,0.0),
176  const Vector& _length = Vector(4.0,6.0,12.0),
177  const unsigned int n_x = 5,
178  const unsigned int n_y = 5,
179  const unsigned int n_z = 10);
180 #endif
181 #ifdef ENABLE_HEXAHEDRALMESH_SUPPORT
182  int addHexahedralCube(const Vector& _position = Vector(0.0,0.0,0.0),
183  const double _length = 2.0);
184 #endif
185 
186 private:
187  int addTriMesh();
188  int addPolyMesh();
189  // construct Octahedron in triMesh_
190  void constructOctahedron(const Vector& _position, const double _length);
191 
192 #ifdef ENABLE_POLYHEDRALMESH_SUPPORT
193  int addPolyhedralMesh();
194 #endif
195  inline void add_face(int _vh1 , int _vh2, int _vh3);
196 
197  inline void add_face(int _vh1 , int _vh2, int _vh3 , int _vh4);
198 
199  inline void add_face( int _vh1 , int _vh2, int _vh3, int _vh4 , int _vh5 );
200 
201  inline ACG::Vec3d positionOnCylinder(const int _sliceNumber,
202  const int _stackNumber,
203  const Vector _position ,
204  const Vector _axis,
205  const double _radius,
206  const double _height);
207 
208  inline ACG::Vec3d positionOnSphere(int _sliceNumber, int _stackNumber, const double _radius, const Vector& _position);
209  inline ACG::Vec2f texCoordOnSphere(int _sliceNumber, int _stackNumber);
210 
211  std::vector<TriMesh::VertexHandle> vhandles_;
212  std::vector<PolyMesh::VertexHandle> vphandles_;
213 
214  TriMesh* triMesh_;
215  PolyMesh* polyMesh_;
216 
217  int slices_;
218  int stacks_;
219 
220  QMenu* primitivesMenu_;
221 
222 };
223 
224 #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:176
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:59
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.