00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef BASE_BUILDER3D_H
00025 #define BASE_BUILDER3D_H
00026
00027
00028
00029 #include <sstream>
00030 #include <vector>
00031 #include "Vector3D.h"
00032
00033 namespace Base
00034 {
00035 class Matrix4D;
00061 class BaseExport Builder3D
00062 {
00063 public:
00065 Builder3D();
00067 virtual ~Builder3D();
00068
00071
00072 void startPoints(short pointSize=2, float color_r=1.0,float color_g=0.0,float color_b=0.0);
00074 void addPoint(float x, float y, float z);
00076 void addPoint(const Vector3f &vec);
00078 void endPoints(void);
00080 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);
00082 void addSinglePoint(const Base::Vector3f &vec, short pointSize=2, float color_r=1.0,float color_g=1.0,float color_b=1.0);
00084
00087
00088 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);
00090 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);
00092
00095
00096 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);
00098
00101
00102 void addTransformation(const Base::Matrix4D&);
00103 void addTransformation(const Base::Vector3f& translation, const Base::Vector3f& rotationaxis, float fAngle);
00105
00108
00109 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);
00111 void addText(const Base::Vector3f &vec,const char * text, float color_r=1.0,float color_g=1.0,float color_b=1.0);
00113
00115 void clear (void);
00116
00119
00120 void saveToLog(void);
00122 void saveToFile(const char* FileName);
00124
00125 private:
00127 std::stringstream result;
00128
00129 bool bStartEndOpen;
00130
00131 };
00132
00141 class BaseExport InventorBuilder
00142 {
00143 public:
00145 InventorBuilder(std::ostream&);
00147 virtual ~InventorBuilder();
00148 void close();
00149
00150 void beginSeparator();
00151 void endSeparator();
00152 void addMaterial(float color_r,float color_g,float color_b);
00153 void addMaterialBinding(const char* = "OVERALL");
00154 void addDrawStyle(short pointSize, short lineWidth,
00155 unsigned short linePattern = 0xffff, const char* style="FILLED");
00156
00159
00160 void beginPoints();
00162 void addPoint(float x, float y, float z);
00164 void addPoint(const Vector3f &vec);
00166 void endPoints(void);
00168
00171
00172 void addSingleLine(const Vector3f& pt1, const Vector3f& pt2, short lineSize=2,
00173 float color_r=1.0,float color_g=1.0,float color_b=1.0, unsigned short linePattern = 0xffff);
00175 void addSingleArrow(const Vector3f& pt1, const Vector3f& pt2, short lineSize=2,
00176 float color_r=1.0,float color_g=1.0,float color_b=1.0, unsigned short linePattern = 0xffff);
00178 void addLineSet(const std::vector<Vector3f>& points, short lineSize=2,
00179 float color_r=1.0,float color_g=1.0,float color_b=1.0, unsigned short linePattern = 0xffff);
00180 void addIndexedFaceSet(const std::vector<Vector3f>& points, const std::vector<int>& indices, float crease);
00182
00185
00186 void addSingleTriangle(const Vector3f& pt0, const Vector3f& pt1, const Vector3f& pt2, bool filled = true, short lineSize=2,
00187 float color_r=1.0,float color_g=1.0,float color_b=1.0);
00188 void addSinglePlane(const Vector3f& base, const Vector3f& eX, const Vector3f& eY, float length, float width, bool filled = true,
00189 short lineSize=2, float color_r=1.0,float color_g=1.0,float color_b=1.0);
00191
00194 void addNurbsSurface(const std::vector<Base::Vector3f>& controlPoints,
00195 int numUControlPoints, int numVControlPoints,
00196 const std::vector<float>& uKnots, const std::vector<float>& vKnots);
00197 void addCylinder(float radius, float height);
00199
00202 void addBoundingBox(const Vector3f& pt1, const Vector3f& pt2, short lineWidth=2,
00203 float color_r=1.0,float color_g=1.0,float color_b=1.0);
00205
00208
00209 void addTransformation(const Matrix4D&);
00210 void addTransformation(const Vector3f& translation, const Vector3f& rotationaxis, float fAngle);
00212
00215
00216 void addText(float pos_x, float pos_y , float pos_z,const char * text,
00217 float color_r=1.0,float color_g=1.0,float color_b=1.0);
00219 void addText(const Vector3f &vec,const char * text, float color_r=1.0,float color_g=1.0,float color_b=1.0);
00221
00222 private:
00223 InventorBuilder (const InventorBuilder&);
00224 void operator = (const InventorBuilder&);
00225
00226 private:
00227 std::ostream& result;
00228 bool bStartEndOpen;
00229 bool bClosed;
00230 int indent;
00231 };
00232
00233 }
00234
00235 #endif // BASE_BUILDER3D_H