A Builder class for 3D representations on App level On application level is nothing known of the visual representation of data. More...
#include <Builder3D.h>
Public Member Functions | |
Builder3D () | |
Construction. | |
void | clear (void) |
clear the string buffer | |
virtual | ~Builder3D () |
Destruction. | |
point set handling | |
void | addPoint (const Vector3f &vec) |
add a vector to a point set | |
void | addPoint (float x, float y, float z) |
insert a point in an point set | |
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() ) | |
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() ) | |
void | endPoints (void) |
ends the points set operation | |
void | startPoints (short pointSize=2, float color_r=1.0, float color_g=0.0, float color_b=0.0) |
starts a point set | |
line/direction handling | |
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. | |
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 | |
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 | |
text handling | |
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 | |
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 | |
Transformation | |
void | addTransformation (const Base::Vector3f &translation, const Base::Vector3f &rotationaxis, float fAngle) |
void | addTransformation (const Base::Matrix4D &) |
adds a transformation | |
write the result | |
void | saveToFile (const char *FileName) |
save the result to a file (*.iv) | |
void | saveToLog (void) |
puts the result to the log and gui |
A Builder class for 3D representations on App level On application level is nothing 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. For that purpose Builder3D was made. This class allows you to build up easily a 3D representation of some math and algorithm internals. You can save this representation to a file and see it in an Inventor viewer, or put it to the log. In case of the log and a debug FreeCAD the representation will be loaded into the active viewer.
Base::Builder3D log3D; for ( unsigned long i=0; i<pMesh->CountPoints(); i++ ) { log3D.addSinglePoint(pMesh->GetPoint(i)); log3D.addText(pMesh->GetPoint(i),"Point"); ... } log3D.saveToLog();
Definition at line 61 of file Builder3D.h.
Builder3D::Builder3D | ( | ) |
Construction.
A constructor.
A more elaborate description of the constructor.
Definition at line 51 of file Builder3D.cpp.
References result.
Builder3D::~Builder3D | ( | ) | [virtual] |
Destruction.
A destructor.
A more elaborate description of the destructor.
Definition at line 62 of file Builder3D.cpp.
void Builder3D::addPoint | ( | const Vector3f & | vec | ) |
add a vector to a point set
Definition at line 101 of file Builder3D.cpp.
References addPoint(), Base::Vector3< _Precision >::x, Base::Vector3< _Precision >::y, and Base::Vector3< _Precision >::z.
void Builder3D::addPoint | ( | float | x, | |
float | y, | |||
float | z | |||
) |
insert a point in an point set
Definition at line 94 of file Builder3D.cpp.
References result.
Referenced by addPoint().
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.
Definition at line 208 of file Builder3D.cpp.
References cr, SketcherExample::f, Base::Vector3< _Precision >::GetAngle(), RobotExample::l, Base::Length, Base::Vector3< _Precision >::Normalize(), result, Base::Vector3< _Precision >::Scale(), Base::Vector3< _Precision >::x, Base::Vector3< _Precision >::y, and Base::Vector3< _Precision >::z.
Referenced by SpringbackCorrection::CalcCurv(), best_fit::Comp_Normals(), best_fit::CompTotalError(), Deviation::Compute(), SpringbackCorrection::FaceCheck(), Deviation::GenNormals(), SpringbackCorrection::InitFaceCheck(), best_fit::MeshFit_Coarse(), offset_mesh(), SpringbackCorrection::Perform(), best_fit::PointCloud_Coarse(), and SpringbackCorrection::SmoothMesh().
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
Definition at line 187 of file Builder3D.cpp.
References result, Base::Vector3< _Precision >::x, Base::Vector3< _Precision >::y, and Base::Vector3< _Precision >::z.
Referenced by best_fit::ANN(), UniGridApprox::CompMeshError(), SpringbackCorrection::GetCurvature(), UniGridApprox::MatComp(), MeshPart::MeshAlgos::offsetSpecial2(), and Mesh::MeshObject::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() )
Definition at line 139 of file Builder3D.cpp.
References addSinglePoint(), Base::Vector3< _Precision >::x, Base::Vector3< _Precision >::y, and Base::Vector3< _Precision >::z.
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() )
Definition at line 118 of file Builder3D.cpp.
References result.
Referenced by addSinglePoint(), SpringbackCorrection::CalcCurv(), fit_iter(), UniGridApprox::MatComp(), best_fit::MeshFit_Coarse(), UniGridApprox::MeshOffset(), MeshPart::MeshAlgos::offsetSpecial2(), Mesh::MeshObject::offsetSpecial2(), SpringbackCorrection::Perform(), best_fit::PointCloud_Coarse(), and SpringbackCorrection::SmoothMesh().
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
Definition at line 248 of file Builder3D.cpp.
References result, 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
Definition at line 170 of file Builder3D.cpp.
References addText(), Base::Vector3< _Precision >::x, Base::Vector3< _Precision >::y, and Base::Vector3< _Precision >::z.
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 origion 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). |
Definition at line 157 of file Builder3D.cpp.
References result.
Referenced by addText(), and SpringbackCorrection::CalcCurv().
void Builder3D::addTransformation | ( | const Base::Vector3f & | translation, | |
const Base::Vector3f & | rotationaxis, | |||
float | fAngle | |||
) |
Definition at line 283 of file Builder3D.cpp.
References result, Base::Vector3< _Precision >::x, Base::Vector3< _Precision >::y, and Base::Vector3< _Precision >::z.
void Builder3D::addTransformation | ( | const Base::Matrix4D & | transform | ) |
adds a transformation
Definition at line 272 of file Builder3D.cpp.
References Base::Matrix4D::toAxisAngle(), Base::Vector3< _Precision >::x, Base::Vector3< _Precision >::y, and Base::Vector3< _Precision >::z.
void Builder3D::clear | ( | void | ) |
void Builder3D::endPoints | ( | void | ) |
ends the points set operation
Ends the point set operations and write the resulting inventor string.
Definition at line 109 of file Builder3D.cpp.
References result.
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 eneables you to show the result in a Inventor Viewer or in FreeCAD by: /code Gui.document().addAnnotation("Debug","MyFile.iv") /endcode
Definition at line 320 of file Builder3D.cpp.
References DrawingExample::file, and result.
Referenced by best_fit::ANN(), SpringbackCorrection::CalcCurv(), best_fit::Comp_Normals(), UniGridApprox::CompMeshError(), best_fit::CompTotalError(), Deviation::Compute(), SpringbackCorrection::FaceCheck(), fit_iter(), Deviation::GenNormals(), SpringbackCorrection::InitFaceCheck(), UniGridApprox::MatComp(), best_fit::MeshFit_Coarse(), UniGridApprox::MeshOffset(), offset_mesh(), cutting_tools::OffsetWires_Spiral(), SpringbackCorrection::Perform(), best_fit::PointCloud_Coarse(), and SpringbackCorrection::SmoothMesh().
void Builder3D::saveToLog | ( | void | ) |
puts 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.
Definition at line 301 of file Builder3D.cpp.
References Base::Console(), Base::ConsoleSingleton::Get(), Base::ConsoleObserver::Log(), and result.
Referenced by MeshPart::MeshAlgos::offsetSpecial2(), and Mesh::MeshObject::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 posible make not to much startPoints() and endPoints() calls. Try to put all points in one set.
pointSize | the point size in pixel the points are showed. | |
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). |
Definition at line 80 of file Builder3D.cpp.
References result.