OpenLexocad  27.1
Builder3D.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (c) 2011 Jürgen Riegel <juergen.riegel@web.de> *
3  * *
4  * This file is part of the FreeCAD CAx development system. *
5  * *
6  * This library is free software; you can redistribute it and/or *
7  * modify it under the terms of the GNU Library General Public *
8  * License as published by the Free Software Foundation; either *
9  * version 2 of the License, or (at your option) any later version. *
10  * *
11  * This library is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14  * GNU Library General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU Library General Public *
17  * License along with this library; see the file COPYING.LIB. If not, *
18  * write to the Free Software Foundation, Inc., 59 Temple Place, *
19  * Suite 330, Boston, MA 02111-1307, USA *
20  * *
21  ***************************************************************************/
22 
23 
24 #ifndef BASE_BUILDER3D_H
25 #define BASE_BUILDER3D_H
26 
27 // Std. configurations
28 
29 #include <sstream>
30 #include <vector>
31 #include <Base/Vector3D.h>
32 
33 namespace Base
34 {
35 class Matrix4D;
61 class LX_BASE_EXPORT Builder3D
62 {
63 public:
65  Builder3D();
67  virtual ~Builder3D();
68 
71  void startPoints(short pointSize=2, float color_r=1.0,float color_g=0.0,float color_b=0.0);
74  void addPoint(float x, float y, float z);
76  void addPoint(const Vector3f &vec);
78  void endPoints(void);
80  void addSinglePoint(float x, float y, float z, short pointSize=2, float color_r=1.0,float color_g=1.0,float color_b=1.0);
82  void addSinglePoint(const Base::Vector3f &vec, short pointSize=2, float color_r=1.0,float color_g=1.0,float color_b=1.0);
84 
87  void addSingleLine(Vector3f pt1, Vector3f pt2, short lineSize=2, float color_r=1.0,float color_g=1.0,float color_b=1.0, unsigned short linePattern = 0xffff);
90  void addSingleArrow(Vector3f pt1, Vector3f pt2, short lineSize=2, float color_r=1.0,float color_g=1.0,float color_b=1.0, unsigned short linePattern = 0xffff);
92 
95  void addSingleTriangle(Vector3f pt0, Vector3f pt1, Vector3f pt2, bool filled = true, short lineSize=2, float color_r=1.0,float color_g=1.0,float color_b=1.0);
98 
101  void addTransformation(const Base::Matrix4D&);
103  void addTransformation(const Base::Vector3f& translation, const Base::Vector3f& rotationaxis, float fAngle);
105 
108  void addText(float pos_x, float pos_y , float pos_z,const char * text, float color_r=1.0,float color_g=1.0,float color_b=1.0);
111  void addText(const Base::Vector3f &vec,const char * text, float color_r=1.0,float color_g=1.0,float color_b=1.0);
113 
115  void clear (void);
116 
119  void saveToLog(void);
122  void saveToFile(const char* FileName);
124 
125 private:
127  std::stringstream result;
128 
129  bool bStartEndOpen;
130 
131 };
132 
141 class LX_BASE_EXPORT InventorBuilder
142 {
143 public:
149  InventorBuilder(std::ostream& str);
153  virtual ~InventorBuilder();
158  void close();
159 
163  void beginSeparator();
167  void endSeparator();
172  void addInfo(const char* str);
177  void addLabel(const char* str);
186  void addBaseColor(float color_r,float color_g,float color_b);
194  void addMaterial(float color_r,float color_g,float color_b,float color_a=0);
199  void beginMaterial();
203  void endMaterial();
210  void addColor(float color_r,float color_g,float color_b);
217  void addMaterialBinding(const char* binding = "OVERALL");
225  void addDrawStyle(short pointSize, short lineWidth,
226  unsigned short linePattern = 0xffff, const char* style="FILLED");
231  void addShapeHints(float crease=0.0f);
239  void addPolygonOffset(float factor=1.0f, float units=1.0f, const char* styles="FILLED", bool on=true);
241 
244  void addPoint(float x, float y, float z);
247  void addPoint(const Vector3f &vec);
249  void addPoints(const std::vector<Vector3f> &vec);
251 
254  void beginPoints();
257  void endPoints();
259  void addPointSet();
261 
264  void beginNormal();
267  void endNormal();
269  void addNormalBinding(const char*);
271 
274  void addSingleLine(const Vector3f& pt1, const Vector3f& pt2, short lineSize=2,
276  float color_r=1.0,float color_g=1.0,float color_b=1.0, unsigned short linePattern = 0xffff);
278  void addSingleArrow(const Vector3f& pt1, const Vector3f& pt2, short lineSize=2,
279  float color_r=1.0,float color_g=1.0,float color_b=1.0, unsigned short linePattern = 0xffff);
281  void addLineSet(const std::vector<Vector3f>& points, short lineSize=2,
282  float color_r=1.0,float color_g=1.0,float color_b=1.0, unsigned short linePattern = 0xffff);
284  void addLineSet();
286 
289  void addSingleTriangle(const Vector3f& pt0, const Vector3f& pt1, const Vector3f& pt2, bool filled = true, short lineSize=2,
291  float color_r=1.0,float color_g=1.0,float color_b=1.0);
292  void addSinglePlane(const Vector3f& base, const Vector3f& eX, const Vector3f& eY, float length, float width, bool filled = true,
293  short lineSize=2, float color_r=1.0,float color_g=1.0,float color_b=1.0);
294  void addIndexedFaceSet(const std::vector<int>& indices);
295  void addFaceSet(const std::vector<int>& vertices);
297 
300  void addNurbsSurface(const std::vector<Base::Vector3f>& controlPoints,
301  int numUControlPoints, int numVControlPoints,
302  const std::vector<float>& uKnots, const std::vector<float>& vKnots);
303  void addCylinder(float radius, float height);
304  void addSphere(float radius);
306 
309  void addBoundingBox(const Vector3f& pt1, const Vector3f& pt2, short lineWidth=2,
310  float color_r=1.0,float color_g=1.0,float color_b=1.0);
312 
315  void addTransformation(const Matrix4D&);
317  void addTransformation(const Vector3f& translation, const Vector3f& rotationaxis, float fAngle);
319 
322  void addText(float pos_x, float pos_y , float pos_z,const char * text,
324  float color_r=1.0,float color_g=1.0,float color_b=1.0);
326  void addText(const Vector3f &vec,const char * text, float color_r=1.0,float color_g=1.0,float color_b=1.0);
328 
329 private:
331  void operator = (const InventorBuilder&);
332 
333 private:
334  std::ostream& result;
335  int indent;
336 };
337 
338 } //namespace Base
339 
340 #endif // BASE_BUILDER3D_H
Definition: Builder3D.h:141
Definition: Matrix.h:38
Definition: Builder3D.h:61
Definition: AbstractXMLReader.h:5
Definition: Vector3D.h:78