OpenLexocad  28.0
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 #pragma once
25 
26 #include <sstream>
27 #include <vector>
28 #include <Base/Vector3D.h>
29 
30 namespace Base
31 {
32 class Matrix4D;
58 class LX_BASE_EXPORT Builder3D
59 {
60 public:
62  Builder3D();
64  virtual ~Builder3D();
65 
68  void startPoints(short pointSize=2, float color_r=1.0,float color_g=0.0,float color_b=0.0);
71  void addPoint(float x, float y, float z);
73  void addPoint(const Vector3f &vec);
75  void endPoints(void);
77  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);
79  void addSinglePoint(const Base::Vector3f &vec, short pointSize=2, float color_r=1.0,float color_g=1.0,float color_b=1.0);
81 
84  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);
87  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);
89 
92  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);
95 
98  void addTransformation(const Base::Matrix4D&);
100  void addTransformation(const Base::Vector3f& translation, const Base::Vector3f& rotationaxis, float fAngle);
102 
105  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);
108  void addText(const Base::Vector3f &vec,const char * text, float color_r=1.0,float color_g=1.0,float color_b=1.0);
110 
112  void clear (void);
113 
116  void saveToLog(void);
119  void saveToFile(const char* FileName);
121 
122 private:
124  std::stringstream result;
125 
126  bool bStartEndOpen;
127 
128 };
129 
138 class LX_BASE_EXPORT InventorBuilder
139 {
140 public:
146  InventorBuilder(std::ostream& str);
150  virtual ~InventorBuilder();
155  void close();
156 
160  void beginSeparator();
164  void endSeparator();
169  void addInfo(const char* str);
174  void addLabel(const char* str);
183  void addBaseColor(float color_r,float color_g,float color_b);
191  void addMaterial(float color_r,float color_g,float color_b,float color_a=0);
196  void beginMaterial();
200  void endMaterial();
207  void addColor(float color_r,float color_g,float color_b);
214  void addMaterialBinding(const char* binding = "OVERALL");
222  void addDrawStyle(short pointSize, short lineWidth,
223  unsigned short linePattern = 0xffff, const char* style="FILLED");
228  void addShapeHints(float crease=0.0f);
236  void addPolygonOffset(float factor=1.0f, float units=1.0f, const char* styles="FILLED", bool on=true);
238 
241  void addPoint(float x, float y, float z);
244  void addPoint(const Vector3f &vec);
246  void addPoints(const std::vector<Vector3f> &vec);
248 
251  void beginPoints();
254  void endPoints();
256  void addPointSet();
258 
261  void beginNormal();
264  void endNormal();
266  void addNormalBinding(const char*);
268 
271  void addSingleLine(const Vector3f& pt1, const Vector3f& pt2, short lineSize=2,
273  float color_r=1.0,float color_g=1.0,float color_b=1.0, unsigned short linePattern = 0xffff);
275  void addSingleArrow(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 addLineSet(const std::vector<Vector3f>& points, 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();
283 
286  void addSingleTriangle(const Vector3f& pt0, const Vector3f& pt1, const Vector3f& pt2, bool filled = true, short lineSize=2,
288  float color_r=1.0,float color_g=1.0,float color_b=1.0);
289  void addSinglePlane(const Vector3f& base, const Vector3f& eX, const Vector3f& eY, float length, float width, bool filled = true,
290  short lineSize=2, float color_r=1.0,float color_g=1.0,float color_b=1.0);
291  void addIndexedFaceSet(const std::vector<int>& indices);
292  void addFaceSet(const std::vector<int>& vertices);
294 
297  void addNurbsSurface(const std::vector<Base::Vector3f>& controlPoints,
298  int numUControlPoints, int numVControlPoints,
299  const std::vector<float>& uKnots, const std::vector<float>& vKnots);
300  void addCylinder(float radius, float height);
301  void addSphere(float radius);
303 
306  void addBoundingBox(const Vector3f& pt1, const Vector3f& pt2, short lineWidth=2,
307  float color_r=1.0,float color_g=1.0,float color_b=1.0);
309 
312  void addTransformation(const Matrix4D&);
314  void addTransformation(const Vector3f& translation, const Vector3f& rotationaxis, float fAngle);
316 
319  void addText(float pos_x, float pos_y , float pos_z,const char * text,
321  float color_r=1.0,float color_g=1.0,float color_b=1.0);
323  void addText(const Vector3f &vec,const char * text, float color_r=1.0,float color_g=1.0,float color_b=1.0);
325 
326 private:
328  void operator = (const InventorBuilder&);
329 
330 private:
331  std::ostream& result;
332  int indent;
333 };
334 
335 } //namespace Base
Base::InventorBuilder
Definition: Builder3D.h:159
Base::Vector3
Definition: Vector3D.h:77
Vector3D.h
Base::Matrix4D
Definition: Matrix.h:55
Base::Vector3f
Vector3< float > Vector3f
Definition: Vector3D.h:245
Base
Definition: AbstractXMLReader.h:5