Base::Builder3D Class Reference

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:
for ( unsigned long i=0; i<pMesh->CountPoints(); i++ )
{
log3D.addSinglePoint(pMesh->GetPoint(i));
log3D.addText(pMesh->GetPoint(i),"Point");
...
}
log3D.saveToLog();
A Builder class for 3D representations on App level On the application level nothing is known of the ...
Definition: Builder3D.h:62
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() )
Definition: Builder3D.cpp:118
void saveToLog(void)
sends the result to the log and gui
Definition: Builder3D.cpp:301
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
Definition: Builder3D.cpp:157
int i
Definition: SplineSurface.py:40
See also
Base::ConsoleSingleton

Constructor & Destructor Documentation

◆ Builder3D()

Builder3D::Builder3D ( )

Construction.

A constructor.

A more elaborate description of the constructor.

◆ ~Builder3D()

Builder3D::~Builder3D ( )
virtual

Destruction.

A destructor.

A more elaborate description of the destructor.

Member Function Documentation

◆ addPoint() [1/2]

◆ addPoint() [2/2]

void Builder3D::addPoint ( float  x,
float  y,
float  z 
)

◆ 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 
)

◆ 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 
)

◆ 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(), and draftgeoutils.general::vec().

◆ 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 
)

◆ 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(), and draftgeoutils.general::vec().

◆ 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_zorigin of the text
textthe text to display.
color_rred part of the text color (0.0 - 1.0).
color_ggreen part of the text color (0.0 - 1.0).
color_bblue part of the text color (0.0 - 1.0).

Referenced by addText().

◆ addTransformation() [1/2]

void Builder3D::addTransformation ( const Base::Matrix4D transform)

◆ 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 Mesh::MeshObject::offsetSpecial2(), and MeshPart::MeshAlgos::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
pointSizethe point size in pixel that are displayed.
color_rred part of the point color (0.0 - 1.0).
color_ggreen part of the point color (0.0 - 1.0).
color_bblue part of the point color (0.0 - 1.0).

The documentation for this class was generated from the following files:
  • Sources/FreeCAD/src/Base/Builder3D.h
  • Sources/FreeCAD/src/Base/Builder3D.cpp