A Builder class for 3D representations on App level On the application level nothing is known of the visual representation of data. More...
#include <Builder3D.h>
Public Member Functions | |
Builder3D () | |
Construction. More... | |
virtual | ~Builder3D () |
Destruction. More... | |
point set handling | |
void | startPoints (short pointSize=2, float color_r=1.0, float color_g=0.0, float color_b=0.0) |
starts a point set More... | |
void | addPoint (float x, float y, float z) |
insert a point in an point set More... | |
void | addPoint (const Vector3f &vec) |
add a vector to a point set More... | |
void | endPoints () |
ends the points set operation More... | |
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) |
add a singular point (without startPoints() & endPoints() ) More... | |
void | addSinglePoint (const Base::Vector3f &vec, short pointSize=2, float color_r=1.0, float color_g=1.0, float color_b=1.0) |
add a singular point (without startPoints() & endPoints() ) More... | |
line/direction handling | |
void | addSingleLine (const Vector3f &pt1, const Vector3f &pt2, short lineSize=2, float color_r=1.0, float color_g=1.0, float color_b=1.0, unsigned short linePattern=0xffff) |
add a line defined by 2 Vector3D More... | |
void | addSingleArrow (const Vector3f &pt1, const Vector3f &pt2, short lineSize=2, float color_r=1.0, float color_g=1.0, float color_b=1.0, unsigned short linePattern=0xffff) |
add a arrow (directed line) by 2 Vector3D. The arrow shows in direction of point 2. More... | |
triangle handling | |
void | addSingleTriangle (const Vector3f &pt0, const Vector3f &pt1, const Vector3f &pt2, bool filled=true, short lineSize=2, float color_r=1.0, float color_g=1.0, float color_b=1.0) |
add a (filled) triangle defined by 3 vectors More... | |
Transformation | |
void | addTransformation (const Base::Matrix4D &) |
adds a transformation More... | |
void | addTransformation (const Base::Vector3f &translation, const Base::Vector3f &rotationaxis, float fAngle) |
text handling | |
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) |
add a text More... | |
void | addText (const Base::Vector3f &vec, const char *text, float color_r=1.0, float color_g=1.0, float color_b=1.0) |
add a text More... | |
void | clear () |
clear the string buffer More... | |
write the result | |
void | saveToLog () |
sends the result to the log and gui More... | |
void | saveToFile (const char *FileName) |
save the result to a file (*.iv) More... | |
A Builder class for 3D representations on App level On the application level nothing is known of the visual representation of data.
Nevertheless it's often needed to see some 3D information, e.g. points, directions, when you program or debug an algorithm. Builder3D was made for this specific purpose. This class allows you to easily build up a 3D representation of some mathematical and algorithm internals. You can save this representation to a file and view it in an Inventor viewer, or send it to the log. In the case of using the log and a debug FreeCAD the representation will be loaded into the active viewer.
Builder3D::Builder3D | ( | ) |
Construction.
A constructor.
A more elaborate description of the constructor.
|
virtual |
Destruction.
A destructor.
A more elaborate description of the destructor.
void Builder3D::addPoint | ( | const Vector3f & | vec | ) |
add a vector to a point set
References addPoint(), and draftgeoutils.general::vec().
Referenced by draftguitools.gui_stretch.Stretch::action(), and draftguitools.gui_stretch.Stretch::numericInput().
void Builder3D::addPoint | ( | float | x, |
float | y, | ||
float | z | ||
) |
insert a point in an point set
insert a point in a point set
Referenced by draftguitools.gui_stretch.Stretch::action(), addPoint(), and draftguitools.gui_stretch.Stretch::numericInput().
void Builder3D::addSingleArrow | ( | const Vector3f & | pt1, |
const Vector3f & | pt2, | ||
short | lineSize = 2 , |
||
float | color_r = 1.0 , |
||
float | color_g = 1.0 , |
||
float | color_b = 1.0 , |
||
unsigned short | linePattern = 0xffff |
||
) |
add a arrow (directed line) by 2 Vector3D. The arrow shows in direction of point 2.
References Base::Vector3< _Precision >::GetAngle(), Base::Vector3< _Precision >::Normalize(), Base::Vector3< _Precision >::Scale(), Base::Vector3< _Precision >::x, Base::Vector3< _Precision >::y, and Base::Vector3< _Precision >::z.
void Builder3D::addSingleLine | ( | const Vector3f & | pt1, |
const Vector3f & | pt2, | ||
short | lineSize = 2 , |
||
float | color_r = 1.0 , |
||
float | color_g = 1.0 , |
||
float | color_b = 1.0 , |
||
unsigned short | linePattern = 0xffff |
||
) |
add a line defined by 2 Vector3D
References Base::Vector3< _Precision >::x, Base::Vector3< _Precision >::y, and Base::Vector3< _Precision >::z.
Referenced by Mesh::MeshObject::offsetSpecial2(), and MeshPart::MeshAlgos::offsetSpecial2().
void Builder3D::addSinglePoint | ( | const Base::Vector3f & | vec, |
short | pointSize = 2 , |
||
float | color_r = 1.0 , |
||
float | color_g = 1.0 , |
||
float | color_b = 1.0 |
||
) |
add a singular point (without startPoints() & endPoints() )
References addSinglePoint(), and draftgeoutils.general::vec().
void Builder3D::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 |
||
) |
add a singular point (without startPoints() & endPoints() )
Referenced by addSinglePoint(), Mesh::MeshObject::offsetSpecial2(), and MeshPart::MeshAlgos::offsetSpecial2().
void Builder3D::addSingleTriangle | ( | const Vector3f & | pt0, |
const Vector3f & | pt1, | ||
const Vector3f & | pt2, | ||
bool | filled = true , |
||
short | lineSize = 2 , |
||
float | color_r = 1.0 , |
||
float | color_g = 1.0 , |
||
float | color_b = 1.0 |
||
) |
add a (filled) triangle defined by 3 vectors
References Base::Vector3< _Precision >::x, Base::Vector3< _Precision >::y, and Base::Vector3< _Precision >::z.
void Builder3D::addText | ( | const Base::Vector3f & | vec, |
const char * | text, | ||
float | color_r = 1.0 , |
||
float | color_g = 1.0 , |
||
float | color_b = 1.0 |
||
) |
add a text
References addText(), and draftgeoutils.general::vec().
void Builder3D::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 |
||
) |
add a text
Add a Text with a given position to the 3D set.
The origin is the lower leftmost corner.
pos_x,pos_y,pos_z | origin of the text |
text | the text to display. |
color_r | red part of the text color (0.0 - 1.0). |
color_g | green part of the text color (0.0 - 1.0). |
color_b | blue part of the text color (0.0 - 1.0). |
Referenced by addText().
void Builder3D::addTransformation | ( | const Base::Matrix4D & | transform | ) |
adds a transformation
References addTransformation(), Base::Vector3< _Precision >::x, Base::Vector3< _Precision >::y, and Base::Vector3< _Precision >::z.
Referenced by addTransformation().
void Builder3D::addTransformation | ( | const Base::Vector3f & | translation, |
const Base::Vector3f & | rotationaxis, | ||
float | fAngle | ||
) |
void Builder3D::clear | ( | ) |
clear the string buffer
void Builder3D::endPoints | ( | ) |
ends the points set operation
Ends the point set operations and write the resulting inventor string.
void Builder3D::saveToFile | ( | const char * | FileName | ) |
save the result to a file (*.iv)
Save the resulting inventor 3D representation to a file.
Ending should be *.iv. That enables you to show the result in a Inventor Viewer or in FreeCAD by: /code Gui.document().addAnnotation("Debug","MyFile.iv") /endcode
void Builder3D::saveToLog | ( | ) |
sends the result to the log and gui
Save the resulting inventor 3D representation to the Console().Log() facility.
In DEBUG mode the Gui (if running) will trigger on that and show the representation in the active Viewer/Document. It shows only one representation on time. If you need to show more then one representation use saveToFile() instead.
References Base::Console(), Base::ConsoleSingleton::Get(), Base::Log, and Base::ILogger::SendLog().
Referenced by Mesh::MeshObject::offsetSpecial2(), and MeshPart::MeshAlgos::offsetSpecial2().
void Builder3D::startPoints | ( | short | pointSize = 2 , |
float | color_r = 1.0 , |
||
float | color_g = 0.0 , |
||
float | color_b = 0.0 |
||
) |
starts a point set
Starts the definition of point set with the given point size and color.
If possible don't make too many startPoints() and endPoints() calls. Try to put all points in one set.
pointSize | the point size in pixel that are displayed. |
color_r | red part of the point color (0.0 - 1.0). |
color_g | green part of the point color (0.0 - 1.0). |
color_b | blue part of the point color (0.0 - 1.0). |