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 (void) |
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 (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) |
add a line defined by 2 Vector3D More... | |
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) |
add a arrow (directed line) by 2 Vector3D. The arrow shows in direction of point 2. More... | |
triangle handling | |
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) |
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 (void) |
clear the string buffer More... | |
write the result | |
void | saveToLog (void) |
sends the result to the log and gui More... | |
void | saveToFile (const char *FileName) |
save the result to a file (*.iv) More... | |
Detailed Description
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.
- The workflow goes as follows: Create the a Builder3D object and call the methods to insert the graphical elements. After that call either saveToLog() or saveToFile().
- Usage: Base::Builder3D log3D;{log3D.addSinglePoint(pMesh->GetPoint(i));log3D.addText(pMesh->GetPoint(i),"Point");...}log3D.saveToLog();
- See also
- Base::ConsoleSingleton
Constructor & Destructor Documentation
◆ Builder3D()
Builder3D::Builder3D | ( | ) |
Construction.
A constructor.
A more elaborate description of the constructor.
◆ ~Builder3D()
|
virtual |
Destruction.
A destructor.
A more elaborate description of the destructor.
Member Function Documentation
◆ addPoint() [1/2]
void Builder3D::addPoint | ( | const Vector3f & | vec | ) |
add a vector to a point set
References addPoint().
Referenced by draftguitools.gui_stretch.Stretch::action(), draftguitools.gui_edit.Edit::evaluate_menu_action(), and draftguitools.gui_stretch.Stretch::numericInput().
◆ addPoint() [2/2]
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(), draftguitools.gui_edit.Edit::evaluate_menu_action(), and draftguitools.gui_stretch.Stretch::numericInput().
◆ addSingleArrow()
void Builder3D::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 |
||
) |
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.
◆ addSingleLine()
void Builder3D::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 |
||
) |
add a line defined by 2 Vector3D
References Base::Vector3< _Precision >::x, Base::Vector3< _Precision >::y, and Base::Vector3< _Precision >::z.
Referenced by MeshPart::MeshAlgos::offsetSpecial2(), and Mesh::MeshObject::offsetSpecial2().
◆ addSinglePoint() [1/2]
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().
◆ addSinglePoint() [2/2]
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(), MeshPart::MeshAlgos::offsetSpecial2(), and Mesh::MeshObject::offsetSpecial2().
◆ addSingleTriangle()
void Builder3D::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 |
||
) |
add a (filled) triangle defined by 3 vectors
References Base::Vector3< _Precision >::x, Base::Vector3< _Precision >::y, and Base::Vector3< _Precision >::z.
◆ addText() [1/2]
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().
◆ addText() [2/2]
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.
- Parameters
-
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().
◆ addTransformation() [1/2]
void Builder3D::addTransformation | ( | const Base::Matrix4D & | transform | ) |
adds a transformation
References Base::Vector3< _Precision >::x, Base::Vector3< _Precision >::y, and Base::Vector3< _Precision >::z.
◆ addTransformation() [2/2]
void Builder3D::addTransformation | ( | const Base::Vector3f & | translation, |
const Base::Vector3f & | rotationaxis, | ||
float | fAngle | ||
) |
◆ clear()
void Builder3D::clear | ( | void | ) |
clear the string buffer
◆ endPoints()
void Builder3D::endPoints | ( | void | ) |
ends the points set operation
Ends the point set operations and write the resulting inventor string.
- See also
- startPoints()
◆ saveToFile()
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
- See also
- saveToFile()
◆ saveToLog()
void Builder3D::saveToLog | ( | void | ) |
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.
- See also
- saveToFile()
References Base::Console(), Base::ConsoleSingleton::Get(), Base::Log, and Base::ILogger::SendLog().
Referenced by MeshPart::MeshAlgos::offsetSpecial2(), and Mesh::MeshObject::offsetSpecial2().
◆ startPoints()
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.
- See also
- endPoints()
- Parameters
-
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).
The documentation for this class was generated from the following files:
- src/Base/Builder3D.h
- src/Base/Builder3D.cpp