Geogram Version 1.9.7
A programming library of geometric algorithms
Loading...
Searching...
No Matches
GEO::AbstractCSGBuilder Class Reference

Base class for implementing CSG objects and instructions. More...

#include <geogram/mesh/mesh_CSG_builder.h>

Inheritance diagram for GEO::AbstractCSGBuilder:
GEO::CSGBuilder

Public Types

typedef GEOCSG::ArgList ArgList
 
typedef GEOCSG::Value Value
 

Public Member Functions

 AbstractCSGBuilder ()
 AbstractCSGBuilder constructor.
 
virtual ~AbstractCSGBuilder ()
 AbstractCSGBuilder destructor.
 
void reset_defaults ()
 Resets defaults value for fn, fs, fa.
 
void set_fn (double fn)
 Sets the number of fragments.
 
void set_fs (double fs)
 Sets the minimum size for a fragment.
 
void set_fa (double fa)
 Sets the minimum angle for a fragment.
 
void set_verbose (bool x)
 Displays (lots of) additional information.
 
void set_detailed_verbose (bool x)
 Displays (even more) additional information.
 
bool verbose () const
 Tests wheter verbose mode is set.
 
void add_file_path (const std::filesystem::path &path)
 Adds a path to the file path.
 
void reset_file_path ()
 Resets the file path to its default value, with only the current directory ".".
 
void push_file_path (const std::filesystem::path &path)
 Adds a path to the file path.
 
void pop_file_path ()
 Removes the latest pushed file path.
 
virtual void add_object (const std::string &object, const ArgList &args)
 
virtual void begin_instruction ()
 
virtual void end_instruction (const std::string &instruction, const ArgList &args)
 
bool is_object (const std::string &id) const
 
bool is_instruction (const std::string &id) const
 

Static Public Attributes

static constexpr double DEFAULT_FA = 12.0
 
static constexpr double DEFAULT_FS = 2.0
 
static constexpr double DEFAULT_FN = 0.0
 

Protected Types

typedef std::function< void(const ArgList &args)> csg_builder_func
 

Protected Member Functions

virtual void add_square (const ArgList &args)
 
virtual void add_circle (const ArgList &args)
 
virtual void add_cube (const ArgList &args)
 
virtual void add_sphere (const ArgList &args)
 
virtual void add_cylinder (const ArgList &args)
 
virtual void add_polyhedron (const ArgList &args)
 
virtual void add_polygon (const ArgList &args)
 
virtual void add_import (const ArgList &args)
 
virtual void add_surface (const ArgList &args)
 
virtual void add_text (const ArgList &args)
 
virtual void eval_multmatrix (const ArgList &args)
 
virtual void eval_resize (const ArgList &args)
 
virtual void eval_union (const ArgList &args)
 
virtual void eval_intersection (const ArgList &args)
 
virtual void eval_difference (const ArgList &args)
 
virtual void eval_group (const ArgList &args)
 
virtual void eval_color (const ArgList &args)
 
virtual void eval_hull (const ArgList &args)
 
virtual void eval_linear_extrude (const ArgList &args)
 
virtual void eval_rotate_extrude (const ArgList &args)
 
virtual void eval_projection (const ArgList &args)
 
virtual void eval_minkowski (const ArgList &args)
 
virtual void eval_render (const ArgList &args)
 
void error (const char *str)
 
void error (const std::string &str)
 

Protected Attributes

double fn_
 
double fs_
 
double fa_
 
std::vector< std::filesystem::path > file_path_
 
bool warnings_
 
bool verbose_
 
bool detailed_verbose_
 
std::map< std::string, csg_builder_func > object_funcs_
 
std::map< std::string, csg_builder_func > instruction_funcs_
 

Detailed Description

Base class for implementing CSG objects and instructions.

AbstractCSGBuilder implement the basic mechanism for calling generic objects and CSG instructions that take an ArgList (name value pairs) as arguments. It dispatches objects/instructions from their name (as a string) and unpacks the arguments from the ArgList. It is interesting to have an abstract base class for that, because one can have a subclass that records the CSG abstract syntax tree, for subsequently optimizing it before playing it back.

Definition at line 62 of file mesh_CSG_builder.h.

Member Typedef Documentation

◆ ArgList

◆ csg_builder_func

typedef std::function<void(const ArgList& args)> GEO::AbstractCSGBuilder::csg_builder_func
protected

Definition at line 269 of file mesh_CSG_builder.h.

◆ Value

Member Function Documentation

◆ add_file_path()

void GEO::AbstractCSGBuilder::add_file_path ( const std::filesystem::path &  path)
inline

Adds a path to the file path.

The file path is where import() searches files. The default file path contains the current directory "."

Parameters
[in]paththe file path to be added, without trailing '/'

Definition at line 167 of file mesh_CSG_builder.h.

◆ error() [1/2]

void GEO::AbstractCSGBuilder::error ( const char *  str)
inlineprotected

Definition at line 252 of file mesh_CSG_builder.h.

◆ error() [2/2]

void GEO::AbstractCSGBuilder::error ( const std::string &  str)
inlineprotected

Definition at line 256 of file mesh_CSG_builder.h.

◆ is_instruction()

bool GEO::AbstractCSGBuilder::is_instruction ( const std::string &  id) const
inline

Definition at line 215 of file mesh_CSG_builder.h.

◆ is_object()

bool GEO::AbstractCSGBuilder::is_object ( const std::string &  id) const
inline

Definition at line 211 of file mesh_CSG_builder.h.

◆ pop_file_path()

void GEO::AbstractCSGBuilder::pop_file_path ( )
inline

Removes the latest pushed file path.

Definition at line 193 of file mesh_CSG_builder.h.

◆ push_file_path()

void GEO::AbstractCSGBuilder::push_file_path ( const std::filesystem::path &  path)
inline

Adds a path to the file path.

The file path is where import() searches files. The default file path contains the current directory "."

Parameters
[in]paththe file path to be added, without trailing '/'

Definition at line 186 of file mesh_CSG_builder.h.

◆ reset_defaults()

void GEO::AbstractCSGBuilder::reset_defaults ( )

Resets defaults value for fn, fs, fa.

See also
set_fn(), set_fs(), set_fa()

◆ reset_file_path()

void GEO::AbstractCSGBuilder::reset_file_path ( )
inline

Resets the file path to its default value, with only the current directory ".".

Definition at line 175 of file mesh_CSG_builder.h.

◆ set_detailed_verbose()

void GEO::AbstractCSGBuilder::set_detailed_verbose ( bool  x)
inline

Displays (even more) additional information.

Parameters
[in]xwhether even more information should be displayed. Default is off

Definition at line 144 of file mesh_CSG_builder.h.

◆ set_fa()

void GEO::AbstractCSGBuilder::set_fa ( double  fa)
inline

Sets the minimum angle for a fragment.

Parameters
[in]faminimum angle for a fragment, in degrees.

This determines the number of edges in a polygonal approximation of a circle.

Definition at line 123 of file mesh_CSG_builder.h.

◆ set_fn()

void GEO::AbstractCSGBuilder::set_fn ( double  fn)
inline

Sets the number of fragments.

This corresponds to the number of edges in a polygonal approximation of a circle. If left to 0, it is automatically computed from fs and fa

Parameters
[in]fnthe number of fragments.
See also
set_fs(), set_fa()

Definition at line 103 of file mesh_CSG_builder.h.

◆ set_fs()

void GEO::AbstractCSGBuilder::set_fs ( double  fs)
inline

Sets the minimum size for a fragment.

Parameters
[in]fsminimum size for a fragment.

This determines the number of edges in a polygonal approximation of a circle.

Definition at line 113 of file mesh_CSG_builder.h.

◆ set_verbose()

void GEO::AbstractCSGBuilder::set_verbose ( bool  x)
inline

Displays (lots of) additional information.

Parameters
[in]xwhether additional information should be displayed. Default is off

Definition at line 132 of file mesh_CSG_builder.h.

◆ verbose()

bool GEO::AbstractCSGBuilder::verbose ( ) const
inline

Tests wheter verbose mode is set.

Return values
trueif additional information will be displayed.
falseotherwise.

Definition at line 156 of file mesh_CSG_builder.h.

Member Data Documentation

◆ DEFAULT_FA

constexpr double GEO::AbstractCSGBuilder::DEFAULT_FA = 12.0
staticconstexpr
See also
set_fa()

Definition at line 68 of file mesh_CSG_builder.h.

◆ DEFAULT_FN

constexpr double GEO::AbstractCSGBuilder::DEFAULT_FN = 0.0
staticconstexpr
See also
set_fn()

Definition at line 74 of file mesh_CSG_builder.h.

◆ DEFAULT_FS

constexpr double GEO::AbstractCSGBuilder::DEFAULT_FS = 2.0
staticconstexpr
See also
set_fs()

Definition at line 71 of file mesh_CSG_builder.h.

◆ detailed_verbose_

bool GEO::AbstractCSGBuilder::detailed_verbose_
protected

Definition at line 267 of file mesh_CSG_builder.h.

◆ fa_

double GEO::AbstractCSGBuilder::fa_
protected

Definition at line 262 of file mesh_CSG_builder.h.

◆ file_path_

std::vector<std::filesystem::path> GEO::AbstractCSGBuilder::file_path_
protected

Definition at line 264 of file mesh_CSG_builder.h.

◆ fn_

double GEO::AbstractCSGBuilder::fn_
protected

Definition at line 260 of file mesh_CSG_builder.h.

◆ fs_

double GEO::AbstractCSGBuilder::fs_
protected

Definition at line 261 of file mesh_CSG_builder.h.

◆ instruction_funcs_

std::map<std::string, csg_builder_func> GEO::AbstractCSGBuilder::instruction_funcs_
protected

Definition at line 271 of file mesh_CSG_builder.h.

◆ object_funcs_

std::map<std::string, csg_builder_func> GEO::AbstractCSGBuilder::object_funcs_
protected

Definition at line 270 of file mesh_CSG_builder.h.

◆ verbose_

bool GEO::AbstractCSGBuilder::verbose_
protected

Definition at line 266 of file mesh_CSG_builder.h.

◆ warnings_

bool GEO::AbstractCSGBuilder::warnings_
protected

Definition at line 265 of file mesh_CSG_builder.h.


The documentation for this class was generated from the following file: