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

Implements CSG objects and instructions. More...

#include <geogram/mesh/mesh_CSG_builder.h>

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

Public Member Functions

virtual std::shared_ptr< Meshsquare (vec2 size, bool center=false)
 
std::shared_ptr< Meshsquare (double size=1.0, bool center=false)
 
virtual std::shared_ptr< Meshcircle (double r=1.0, index_t nu=0)
 
virtual std::shared_ptr< Meshcube (vec3 size, bool center=false)
 
std::shared_ptr< Meshcube (double size=1.0, bool center=false)
 
virtual std::shared_ptr< Meshsphere (double r=1.0)
 
virtual std::shared_ptr< Meshcylinder (double h, double r1, double r2, bool center=false)
 
virtual std::shared_ptr< Meshimport (const std::filesystem::path &filename, const std::string &layer="", index_t timestamp=0, vec2 origin=vec2(0.0, 0.0), vec2 scale=vec2(1.0, 1.0))
 
virtual std::shared_ptr< Meshsurface (const std::filesystem::path &filename, bool center, bool invert)
 
virtual std::shared_ptr< Meshtext (const std::string &text, double size=10.0, const std::string &font="", const std::string &halign="left", const std::string &valign="baseline", double spacing=1.0, const std::string &direction="ltr", const std::string &language="en", const std::string &script="latin")
 
virtual std::shared_ptr< Meshmultmatrix (const mat4 &M, const CSGScope &scope)
 Groups several meshes into a single one and transforms them.
 
virtual std::shared_ptr< Meshunion_instr (const CSGScope &scope)
 Computes the union of two or more meshes.
 
template<typename... Types>
std::shared_ptr< Meshunion_instr (Types...args)
 Computes the union of two or more meshes.
 
virtual std::shared_ptr< Meshintersection (const CSGScope &scope)
 Computes the intersection between two or more meshes.
 
template<typename... Types>
std::shared_ptr< Meshintersection (Types...args)
 Computes the mutual intersection between meshes.
 
virtual std::shared_ptr< Meshdifference (const CSGScope &scope)
 Computes the intersection between two meshes.
 
template<typename... Types>
std::shared_ptr< Meshdifference (Types...args)
 Computes the difference between meshes.
 
virtual std::shared_ptr< Meshgroup (const CSGScope &scope)
 synonym for union.
 
virtual std::shared_ptr< Meshcolor (vec4 color, const CSGScope &scope)
 Groups several meshes into a single one and sets their color.
 
virtual std::shared_ptr< Meshhull (const CSGScope &scope)
 Computes the convex hull of several meshes.
 
virtual std::shared_ptr< Meshlinear_extrude (const CSGScope &scope, double height=1.0, bool center=false, vec2 scale=vec2(1.0, 1.0), index_t slices=0, double twist=0.0)
 Computes a 3D extrusion from a 2D shape.
 
virtual std::shared_ptr< Meshrotate_extrude (const CSGScope &scope, double angle=360.0)
 Computes a 3D extrusion from a 2D shape.
 
virtual std::shared_ptr< Meshprojection (const CSGScope &scope, bool cut)
 Creates a 2D mesh from 3D mesh.
 
virtual std::shared_ptr< Meshminkowski (const CSGScope &scope)
 Computes the Minkowski sum of meshes.
 
virtual std::shared_ptr< Meshappend (const CSGScope &scope)
 Appends all meshes in scope into a unique mesh, without testing for intersections.
 
void add_object (const std::string &object, const ArgList &args) override
 
void begin_instruction () override
 
void end_instruction (const std::string &instruction, const ArgList &args) override
 
void add_square (const ArgList &args) override
 
void add_circle (const ArgList &args) override
 
void add_cube (const ArgList &args) override
 
void add_sphere (const ArgList &args) override
 
void add_cylinder (const ArgList &args) override
 
void add_polyhedron (const ArgList &args) override
 
void add_polygon (const ArgList &args) override
 
void add_import (const ArgList &args) override
 
void add_surface (const ArgList &args) override
 
void add_text (const ArgList &args) override
 
void eval_multmatrix (const ArgList &args) override
 
void eval_translate (const ArgList &args) override
 
void eval_rotate (const ArgList &args) override
 
void eval_scale (const ArgList &args) override
 
void eval_resize (const ArgList &args) override
 
void eval_union (const ArgList &args) override
 
void eval_intersection (const ArgList &args) override
 
void eval_difference (const ArgList &args) override
 
void eval_group (const ArgList &args) override
 
void eval_color (const ArgList &args) override
 
void eval_hull (const ArgList &args) override
 
void eval_linear_extrude (const ArgList &args) override
 
void eval_rotate_extrude (const ArgList &args) override
 
void eval_projection (const ArgList &args) override
 
void eval_minkowski (const ArgList &args) override
 
void eval_render (const ArgList &args) override
 
std::shared_ptr< Meshtranslate (const vec3 &T, const CSGScope &scope)
 Commodity function for translating a CSGScope using OpenSCAD syntax.
 
std::shared_ptr< Meshrotate (double angle, const CSGScope &scope)
 Commodity function for 2D-rotating a CSGScope using OpenSCAD syntax.
 
std::shared_ptr< Meshrotate (double angle, const vec3 &axis, const CSGScope &scope)
 Commodity function for rotating a CSGScope using OpenSCAD syntax.
 
std::shared_ptr< Meshrotate (const vec3 &angles, const CSGScope &scope)
 Commodity function for rotating a CSGScope using OpenSCAD syntax.
 
std::shared_ptr< Meshscale (double sx, double sy, double sz, const CSGScope &scope)
 Commodity function for scaling a CSGScope using OpenSCAD syntax.
 
void set_delaunay (bool x)
 If set, compute constrained Delaunay triangulation in the intersected triangles. If there are intersections in coplanar facets, it guarantees uniqueness of their triangulation. Default is set.
 
void set_detect_intersecting_neighbors (bool x)
 detect and compute intersections between facets that share a facet or an edge. Set to false if input is a set of conformal meshes. Default is set.
 
void set_simplify_coplanar_facets (bool x, double angle_tolerance=0.0)
 Specifies whether coplanar facets should be simplified.
 
void set_fast_union (bool x)
 Sets fast union mode.
 
void set_noop (bool x)
 Sets noop mode.
 
- Public Member Functions inherited from GEO::AbstractCSGBuilder
 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.
 
bool is_object (const std::string &id) const
 
bool is_instruction (const std::string &id) const
 

Static Public Member Functions

static mat4 translation_matrix (const vec3 &T)
 Builds a translation matrix.
 
static mat4 scaling_matrix (double sx, double sy, double sz)
 Builds a scaling matrix.
 
static mat4 rotation_matrix (double angle, vec3 axis={0.0, 0.0, 0.0})
 Builds a rotation matrix.
 
static mat4 rotation_matrix (const vec3 &angles)
 Builds a rotation matrix.
 
static Box3d get_bbox (const std::shared_ptr< Mesh > &mesh)
 Computes the bounding box of a mesh.
 
static std::pair< vec3, vec3get_bbox_bounds (const std::shared_ptr< Mesh > &mesh)
 Computes the bounding box of a mesh.
 

Protected Member Functions

std::shared_ptr< Meshsurface_with_OpenSCAD (const std::filesystem::path &filename, bool center, bool invert)
 
std::shared_ptr< Meshtext_with_OpenSCAD (const std::string &text, double size=10.0, const std::string &font="", const std::string &halign="left", const std::string &valign="baseline", double spacing=1.0, const std::string &direction="ltr", const std::string &language="en", const std::string &script="latin")
 
bool find_file (std::filesystem::path &filename)
 Finds a file in the path.
 
const std::filesystem::path & current_path ()
 Gets the current path.
 
std::shared_ptr< Meshimport_with_openSCAD (const std::filesystem::path &filename, const std::string &layer="", index_t timestamp=0)
 For the file formats that are not supported by geogram, get help from OpenSCAD to convert them.
 
virtual void do_CSG (std::shared_ptr< Mesh > &mesh, const std::string &boolean_expr)
 Apply a CSG operation to a mesh.
 
virtual void triangulate (std::shared_ptr< Mesh > &mesh, const std::string &boolean_expr)
 Triangulates a 2D mesh.
 
virtual void triangulate (std::shared_ptr< Mesh > &mesh)
 Triangulates a 2D mesh.
 
void keep_z0_only (std::shared_ptr< Mesh > &M)
 keeps only triangles and vertices embedded in the z=0 plane, and makes the mesh 2D.
 
virtual void finalize_mesh (std::shared_ptr< Mesh > &mesh)
 Derived classes may override this function and compute some cached information, e.g. bounding boxes, stored in the mesh.
 
CSGScopetop_scope ()
 
void push_scope ()
 
void pop_scope ()
 
- Protected Member Functions inherited from GEO::AbstractCSGBuilder
void error (const char *str)
 
void error (const std::string &str)
 

Protected Attributes

double STL_epsilon_
 
index_t max_arity_
 
bool detect_intersecting_neighbors_
 
bool delaunay_
 
bool simplify_coplanar_facets_
 
double coplanar_angle_tolerance_
 
bool fast_union_
 
bool noop_
 
std::shared_ptr< Meshempty_mesh_
 
std::shared_ptr< Meshresult_
 
std::stack< CSGScopescope_stack_
 
- Protected Attributes inherited from GEO::AbstractCSGBuilder
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_
 

Friends

class CSGCompiler
 

Additional Inherited Members

- Public Types inherited from GEO::AbstractCSGBuilder
typedef GEOCSG::ArgList ArgList
 
typedef GEOCSG::Value Value
 
- Static Public Attributes inherited from GEO::AbstractCSGBuilder
static constexpr double DEFAULT_FA = 12.0
 
static constexpr double DEFAULT_FS = 2.0
 
static constexpr double DEFAULT_FN = 0.0
 
- Protected Types inherited from GEO::AbstractCSGBuilder
typedef std::function< void(const ArgList &args)> csg_builder_func
 

Detailed Description

Implements CSG objects and instructions.

Can be used to construct volumes in C++ with a syntax very similar to OpenSCAD .csg files.

Definition at line 358 of file mesh_CSG_builder.h.

Member Function Documentation

◆ add_circle()

void GEO::CSGBuilder::add_circle ( const ArgList args)
overridevirtual

Reimplemented from GEO::AbstractCSGBuilder.

◆ add_cube()

void GEO::CSGBuilder::add_cube ( const ArgList args)
overridevirtual

Reimplemented from GEO::AbstractCSGBuilder.

◆ add_cylinder()

void GEO::CSGBuilder::add_cylinder ( const ArgList args)
overridevirtual

Reimplemented from GEO::AbstractCSGBuilder.

◆ add_import()

void GEO::CSGBuilder::add_import ( const ArgList args)
overridevirtual

Reimplemented from GEO::AbstractCSGBuilder.

◆ add_object()

void GEO::CSGBuilder::add_object ( const std::string &  object,
const ArgList args 
)
overridevirtual

Reimplemented from GEO::AbstractCSGBuilder.

◆ add_polygon()

void GEO::CSGBuilder::add_polygon ( const ArgList args)
overridevirtual

Reimplemented from GEO::AbstractCSGBuilder.

◆ add_polyhedron()

void GEO::CSGBuilder::add_polyhedron ( const ArgList args)
overridevirtual

Reimplemented from GEO::AbstractCSGBuilder.

◆ add_sphere()

void GEO::CSGBuilder::add_sphere ( const ArgList args)
overridevirtual

Reimplemented from GEO::AbstractCSGBuilder.

◆ add_square()

void GEO::CSGBuilder::add_square ( const ArgList args)
overridevirtual

Reimplemented from GEO::AbstractCSGBuilder.

◆ add_surface()

void GEO::CSGBuilder::add_surface ( const ArgList args)
overridevirtual

Reimplemented from GEO::AbstractCSGBuilder.

◆ add_text()

void GEO::CSGBuilder::add_text ( const ArgList args)
overridevirtual

Reimplemented from GEO::AbstractCSGBuilder.

◆ append()

virtual std::shared_ptr< Mesh > GEO::CSGBuilder::append ( const CSGScope scope)
virtual

Appends all meshes in scope into a unique mesh, without testing for intersections.

Prepares operand bits for a subsequent CSG operation.

◆ begin_instruction()

void GEO::CSGBuilder::begin_instruction ( )
overridevirtual

Reimplemented from GEO::AbstractCSGBuilder.

◆ circle()

virtual std::shared_ptr< Mesh > GEO::CSGBuilder::circle ( double  r = 1.0,
index_t  nu = 0 
)
virtual
Parameters
[in]nunumber of fragments. If left unspecified, then it is deduced from radius and/or $fn variable.

◆ color()

virtual std::shared_ptr< Mesh > GEO::CSGBuilder::color ( vec4  color,
const CSGScope scope 
)
virtual

Groups several meshes into a single one and sets their color.

Parameters
[in]colorthe color, as r,g,b,a.

ignored for now, just behaves as group().

◆ cube()

std::shared_ptr< Mesh > GEO::CSGBuilder::cube ( double  size = 1.0,
bool  center = false 
)
inline

Definition at line 379 of file mesh_CSG_builder.h.

◆ current_path()

const std::filesystem::path & GEO::CSGBuilder::current_path ( )
inlineprotected

Gets the current path.

Returns
the latest directory pushed onto the file path

Definition at line 850 of file mesh_CSG_builder.h.

◆ difference() [1/2]

virtual std::shared_ptr< Mesh > GEO::CSGBuilder::difference ( const CSGScope scope)
virtual

Computes the intersection between two meshes.

If scope contains more than two meshes, it computes the difference between the first mesh and the union of the rest.

Parameters
[in]scopethe meshes

◆ difference() [2/2]

template<typename... Types>
std::shared_ptr< Mesh > GEO::CSGBuilder::difference ( Types...  args)
inline

Computes the difference between meshes.

If args contains more than two meshes, it computes the difference between the first mesh and the union of the rest.

Parameters
[in]argsthe list of meshes as the function parameters (this function takes an arbitrary number of parameters).
Returns
a mesh with the difference between the meshes in args

Definition at line 487 of file mesh_CSG_builder.h.

◆ do_CSG()

virtual void GEO::CSGBuilder::do_CSG ( std::shared_ptr< Mesh > &  mesh,
const std::string &  boolean_expr 
)
protectedvirtual

Apply a CSG operation to a mesh.

Default implementation works in 2D (based on triangulate()) and does nothing in 3D (to be overriden by user). Each triangle has an "operand bit" indicating to which input operand it belongs to, set to (1u << operand_id).

Parameters
[in,out]meshthe mesh
[in]boolean_exprthe operation to be applied
  • "union"
  • "intersection"
  • a general boolean expression, where:
    • variables are x0 ... x31 (they correspond to input operands)
    • operators are +,-,*
    • there can be parentheses

◆ end_instruction()

void GEO::CSGBuilder::end_instruction ( const std::string &  instruction,
const ArgList args 
)
overridevirtual

Reimplemented from GEO::AbstractCSGBuilder.

◆ eval_color()

void GEO::CSGBuilder::eval_color ( const ArgList args)
overridevirtual

Reimplemented from GEO::AbstractCSGBuilder.

◆ eval_difference()

void GEO::CSGBuilder::eval_difference ( const ArgList args)
overridevirtual

Reimplemented from GEO::AbstractCSGBuilder.

◆ eval_group()

void GEO::CSGBuilder::eval_group ( const ArgList args)
overridevirtual

Reimplemented from GEO::AbstractCSGBuilder.

◆ eval_hull()

void GEO::CSGBuilder::eval_hull ( const ArgList args)
overridevirtual

Reimplemented from GEO::AbstractCSGBuilder.

◆ eval_intersection()

void GEO::CSGBuilder::eval_intersection ( const ArgList args)
overridevirtual

Reimplemented from GEO::AbstractCSGBuilder.

◆ eval_linear_extrude()

void GEO::CSGBuilder::eval_linear_extrude ( const ArgList args)
overridevirtual

Reimplemented from GEO::AbstractCSGBuilder.

◆ eval_minkowski()

void GEO::CSGBuilder::eval_minkowski ( const ArgList args)
overridevirtual

Reimplemented from GEO::AbstractCSGBuilder.

◆ eval_multmatrix()

void GEO::CSGBuilder::eval_multmatrix ( const ArgList args)
overridevirtual

Reimplemented from GEO::AbstractCSGBuilder.

◆ eval_projection()

void GEO::CSGBuilder::eval_projection ( const ArgList args)
overridevirtual

Reimplemented from GEO::AbstractCSGBuilder.

◆ eval_render()

void GEO::CSGBuilder::eval_render ( const ArgList args)
overridevirtual

Reimplemented from GEO::AbstractCSGBuilder.

◆ eval_resize()

void GEO::CSGBuilder::eval_resize ( const ArgList args)
overridevirtual

Reimplemented from GEO::AbstractCSGBuilder.

◆ eval_rotate()

void GEO::CSGBuilder::eval_rotate ( const ArgList args)
overridevirtual

Reimplemented from GEO::AbstractCSGBuilder.

◆ eval_rotate_extrude()

void GEO::CSGBuilder::eval_rotate_extrude ( const ArgList args)
overridevirtual

Reimplemented from GEO::AbstractCSGBuilder.

◆ eval_scale()

void GEO::CSGBuilder::eval_scale ( const ArgList args)
overridevirtual

Reimplemented from GEO::AbstractCSGBuilder.

◆ eval_translate()

void GEO::CSGBuilder::eval_translate ( const ArgList args)
overridevirtual

Reimplemented from GEO::AbstractCSGBuilder.

◆ eval_union()

void GEO::CSGBuilder::eval_union ( const ArgList args)
overridevirtual

Reimplemented from GEO::AbstractCSGBuilder.

◆ find_file()

bool GEO::CSGBuilder::find_file ( std::filesystem::path &  filename)
protected

Finds a file in the path.

Parameters
[in,out]filenamethe file to be found. On exit, the complete path to the file if found
Return values
trueif the file could be found
falseotherwise

◆ get_bbox()

static Box3d GEO::CSGBuilder::get_bbox ( const std::shared_ptr< Mesh > &  mesh)
static

Computes the bounding box of a mesh.

Parameters
[in]meshthe mesh
Returns
the bounding box. If the mesh is 2D, then the z components of the bounding box are set to 0

◆ get_bbox_bounds()

static std::pair< vec3, vec3 > GEO::CSGBuilder::get_bbox_bounds ( const std::shared_ptr< Mesh > &  mesh)
inlinestatic

Computes the bounding box of a mesh.

Parameters
[in]meshthe mesh
Returns
the bounding box as a pair of minimum, maximum bounds. If the mesh is 2D, then the z components of the bounding box are set to 0

Definition at line 810 of file mesh_CSG_builder.h.

◆ group()

virtual std::shared_ptr< Mesh > GEO::CSGBuilder::group ( const CSGScope scope)
virtual

synonym for union.

Maybe there's something I did not understand in OpenSCAD, but I do not see the difference between group and union.

◆ hull()

virtual std::shared_ptr< Mesh > GEO::CSGBuilder::hull ( const CSGScope scope)
virtual

Computes the convex hull of several meshes.

Parameters
[in]scopethe meshes

◆ import_with_openSCAD()

std::shared_ptr< Mesh > GEO::CSGBuilder::import_with_openSCAD ( const std::filesystem::path &  filename,
const std::string &  layer = "",
index_t  timestamp = 0 
)
protected

For the file formats that are not supported by geogram, get help from OpenSCAD to convert them.

Converts STEP files.

◆ intersection() [1/2]

virtual std::shared_ptr< Mesh > GEO::CSGBuilder::intersection ( const CSGScope scope)
virtual

Computes the intersection between two or more meshes.

Parameters
[in]scopethe meshes
Returns
a mesh with the intersection of the meshes in scope

◆ intersection() [2/2]

template<typename... Types>
std::shared_ptr< Mesh > GEO::CSGBuilder::intersection ( Types...  args)
inline

Computes the mutual intersection between meshes.

Parameters
[in]argsthe list of meshes to be intersected as the function parameters (this function takes an arbitrary number of parameters).
Returns
a mesh with the mutual intersection of the meshes in args

Definition at line 463 of file mesh_CSG_builder.h.

◆ keep_z0_only()

void GEO::CSGBuilder::keep_z0_only ( std::shared_ptr< Mesh > &  M)
protected

keeps only triangles and vertices embedded in the z=0 plane, and makes the mesh 2D.

This also computes the border and re-triangulates it.

Parameters
[in,out]Ma shared pointer to the mesh

◆ linear_extrude()

virtual std::shared_ptr< Mesh > GEO::CSGBuilder::linear_extrude ( const CSGScope scope,
double  height = 1.0,
bool  center = false,
vec2  scale = vec2(1.0, 1.0),
index_t  slices = 0,
double  twist = 0.0 
)
virtual

Computes a 3D extrusion from a 2D shape.

Parameters
[in]scopeone or more 2D shapes
[in]heighttotal height of the extrusion
[in]centerif set, z will go from -height/2 to height/2, else from 0 to height
[in]scalescaling factor to be applied to x and y coordinates when reaching height
[in]slicesnumber of slices along the z axis
[in]twistrotation to be applied when sweeping, in degrees

◆ multmatrix()

virtual std::shared_ptr< Mesh > GEO::CSGBuilder::multmatrix ( const mat4 M,
const CSGScope scope 
)
virtual

Groups several meshes into a single one and transforms them.

Parameters
[in]Mthe transformation matrix. It follows the same convention as OpenSCAD, that is, not the OpenGL convention. For instance, a translation matrix has the translation vector as its third column.
[in]scopeone or several meshes to be merged.

◆ pop_scope()

void GEO::CSGBuilder::pop_scope ( )
inlineprotected

Definition at line 942 of file mesh_CSG_builder.h.

◆ projection()

virtual std::shared_ptr< Mesh > GEO::CSGBuilder::projection ( const CSGScope scope,
bool  cut 
)
virtual

Creates a 2D mesh from 3D mesh.

Parameters
[in]cutif set, computes the boundary of the intersection between the object and the X,Y plane, else computes the boundary of the projection.

◆ push_scope()

void GEO::CSGBuilder::push_scope ( )
inlineprotected

Definition at line 938 of file mesh_CSG_builder.h.

◆ rotate() [1/3]

std::shared_ptr< Mesh > GEO::CSGBuilder::rotate ( const vec3 angles,
const CSGScope scope 
)
inline

Commodity function for rotating a CSGScope using OpenSCAD syntax.

Parameters
[in]anglesrotation angles along the three axes in degrees
[in]scopea scope with the list of meshes to be transformed
Returns
a mesh with the union of the transformed meshes in scope
See also
multmatrix

Definition at line 718 of file mesh_CSG_builder.h.

◆ rotate() [2/3]

std::shared_ptr< Mesh > GEO::CSGBuilder::rotate ( double  angle,
const CSGScope scope 
)
inline

Commodity function for 2D-rotating a CSGScope using OpenSCAD syntax.

Parameters
[in]anglerotation angle in degrees
[in]scopea scope with the list of meshes to be transformed
Returns
a mesh with the union of the transformed meshes in scope
See also
multmatrix

Definition at line 691 of file mesh_CSG_builder.h.

◆ rotate() [3/3]

std::shared_ptr< Mesh > GEO::CSGBuilder::rotate ( double  angle,
const vec3 axis,
const CSGScope scope 
)
inline

Commodity function for rotating a CSGScope using OpenSCAD syntax.

if angle is 0, then axis corresponds to the three rotation angles around x,y and z

Parameters
[in]anglerotation angle in degrees
[in]axisrotation axis
[in]scopea scope with the list of meshes to be transformed
Returns
a mesh with the union of the transformed meshes in scope
See also
multmatrix

Definition at line 705 of file mesh_CSG_builder.h.

◆ rotate_extrude()

virtual std::shared_ptr< Mesh > GEO::CSGBuilder::rotate_extrude ( const CSGScope scope,
double  angle = 360.0 
)
virtual

Computes a 3D extrusion from a 2D shape.

Parameters
[in]scopeone or more 2D shapes. Everything should be on the same side of the Y axis, preferably the positive side.
[in]angleoptional angle

◆ rotation_matrix() [1/2]

static mat4 GEO::CSGBuilder::rotation_matrix ( const vec3 angles)
inlinestatic

Builds a rotation matrix.

Parameters
[in]anglesrotation angles around each axis in degrees
Returns
a 4x4 homogeneous coordinate rotation matrix

Definition at line 660 of file mesh_CSG_builder.h.

◆ rotation_matrix() [2/2]

static mat4 GEO::CSGBuilder::rotation_matrix ( double  angle,
vec3  axis = {0.0, 0.0, 0.0} 
)
inlinestatic

Builds a rotation matrix.

Parameters
[in]axisrotation axis
[in]anglerotation angle in degrees
Returns
a 4x4 homogeneous coordinate rotation matrix

Definition at line 637 of file mesh_CSG_builder.h.

◆ scale()

std::shared_ptr< Mesh > GEO::CSGBuilder::scale ( double  sx,
double  sy,
double  sz,
const CSGScope scope 
)
inline

Commodity function for scaling a CSGScope using OpenSCAD syntax.

Parameters
[in]sx,sy,szscaling factors along each axis
[in]scopea scope with the list of meshes to be transformed
Returns
a mesh with the union of the transformed meshes in scope
See also
multmatrix

Definition at line 729 of file mesh_CSG_builder.h.

◆ scaling_matrix()

static mat4 GEO::CSGBuilder::scaling_matrix ( double  sx,
double  sy,
double  sz 
)
inlinestatic

Builds a scaling matrix.

Parameters
[in]sx,sy,szscaling along each axis
Returns
a 4x4 homogeneous coordinate scaling matrix

Definition at line 624 of file mesh_CSG_builder.h.

◆ set_delaunay()

void GEO::CSGBuilder::set_delaunay ( bool  x)
inline

If set, compute constrained Delaunay triangulation in the intersected triangles. If there are intersections in coplanar facets, it guarantees uniqueness of their triangulation. Default is set.

Definition at line 743 of file mesh_CSG_builder.h.

◆ set_detect_intersecting_neighbors()

void GEO::CSGBuilder::set_detect_intersecting_neighbors ( bool  x)
inline

detect and compute intersections between facets that share a facet or an edge. Set to false if input is a set of conformal meshes. Default is set.

Definition at line 752 of file mesh_CSG_builder.h.

◆ set_fast_union()

void GEO::CSGBuilder::set_fast_union ( bool  x)
inline

Sets fast union mode.

In fast union mode, all intersections are computed and the external shell is kept. It may give incorrect result if an object is floating inside another one (completely included).

Parameters
[in]xtrue if fast union mode should be used, false otherwise.

Definition at line 777 of file mesh_CSG_builder.h.

◆ set_noop()

void GEO::CSGBuilder::set_noop ( bool  x)
inline

Sets noop mode.

In noop mode, all CSG operations (union, intersection, difference) are replaced with append. Useful for debugging CSG trees.

Parameters
[in]xwhether noop mode should be set

Definition at line 790 of file mesh_CSG_builder.h.

◆ set_simplify_coplanar_facets()

void GEO::CSGBuilder::set_simplify_coplanar_facets ( bool  x,
double  angle_tolerance = 0.0 
)
inline

Specifies whether coplanar facets should be simplified.

Parameters
[in]xif set, coplanar facets are simplified, else they are kept as is (faster but generates many triangles). Default is set.
[in]angle_tolerance(in degree) the pairs of adjacent facets with normals that make an angle smaller than this threshold as considered to be coplanar.

Definition at line 765 of file mesh_CSG_builder.h.

◆ square()

std::shared_ptr< Mesh > GEO::CSGBuilder::square ( double  size = 1.0,
bool  center = false 
)
inline

Definition at line 367 of file mesh_CSG_builder.h.

◆ top_scope()

CSGScope & GEO::CSGBuilder::top_scope ( )
inlineprotected

Definition at line 933 of file mesh_CSG_builder.h.

◆ translate()

std::shared_ptr< Mesh > GEO::CSGBuilder::translate ( const vec3 T,
const CSGScope scope 
)
inline

Commodity function for translating a CSGScope using OpenSCAD syntax.

Parameters
[in]Ttranslation vector
[in]scopea scope with the list of meshes to be transformed
Returns
a mesh with the union of the transformed meshes in scope
See also
multmatrix

Definition at line 680 of file mesh_CSG_builder.h.

◆ translation_matrix()

static mat4 GEO::CSGBuilder::translation_matrix ( const vec3 T)
inlinestatic

Builds a translation matrix.

Parameters
[in]Tthe translation matrix
Returns
a 4x4 homogeneous coordinate translation matrix

Definition at line 612 of file mesh_CSG_builder.h.

◆ triangulate() [1/2]

virtual void GEO::CSGBuilder::triangulate ( std::shared_ptr< Mesh > &  mesh)
protectedvirtual

Triangulates a 2D mesh.

This sets all edge operand bits to 1 and then computes a union using the other flavor of triangulate()

◆ triangulate() [2/2]

virtual void GEO::CSGBuilder::triangulate ( std::shared_ptr< Mesh > &  mesh,
const std::string &  boolean_expr 
)
protectedvirtual

Triangulates a 2D mesh.

Computes a constrained Delaunay triangulation from the edges of the mesh, then classifies the triangles using a boolean expression. Each edge has an "operand bit" indicating to which input operand it belongs to, set to (1u << operand_id). Used to implement CSG operations in 2D.

Parameters
[in,out]meshthe input is a set of vertices and edges. The output has a set of triangles inside the polygons defined by the edges.
[in]boolean_exproptional operation to be applied, can be one of
  • "union" (default)
  • "intersection"
  • a general boolean expression, where:
    • variables are x0 ... x31 (they correspond to input operands)
    • operators are +,-,*
    • there can be parentheses
  • "union_cnstr_operand_bits_is_operand_id", same as "union" but edges operand bits are set to operand_id (instead of 1u << operand_id). This allows for an unlimited number of operands (as opposed to operand bits where it is limited to 32). It is used to implement projection(cut=false).

◆ union_instr() [1/2]

virtual std::shared_ptr< Mesh > GEO::CSGBuilder::union_instr ( const CSGScope scope)
virtual

Computes the union of two or more meshes.

Parameters
[in]scopethe meshes. One can use a CSGScope object, or a curly-braced list of meshes (list of shared_ptr to meshes in fact).
Returns
a mesh with the union of the meshes in scope.

◆ union_instr() [2/2]

template<typename... Types>
std::shared_ptr< Mesh > GEO::CSGBuilder::union_instr ( Types...  args)
inline

Computes the union of two or more meshes.

Parameters
[in]argsthe list of meshes to be unioned, as the function parameters (this function takes an arbitrary number of parameters).
Returns
a mesh with the union of the meshes in args.

Definition at line 442 of file mesh_CSG_builder.h.

Friends And Related Symbol Documentation

◆ CSGCompiler

friend class CSGCompiler
friend

Definition at line 960 of file mesh_CSG_builder.h.

Member Data Documentation

◆ coplanar_angle_tolerance_

double GEO::CSGBuilder::coplanar_angle_tolerance_
protected

Definition at line 953 of file mesh_CSG_builder.h.

◆ delaunay_

bool GEO::CSGBuilder::delaunay_
protected

Definition at line 951 of file mesh_CSG_builder.h.

◆ detect_intersecting_neighbors_

bool GEO::CSGBuilder::detect_intersecting_neighbors_
protected

Definition at line 950 of file mesh_CSG_builder.h.

◆ empty_mesh_

std::shared_ptr<Mesh> GEO::CSGBuilder::empty_mesh_
protected

Definition at line 956 of file mesh_CSG_builder.h.

◆ fast_union_

bool GEO::CSGBuilder::fast_union_
protected

Definition at line 954 of file mesh_CSG_builder.h.

◆ max_arity_

index_t GEO::CSGBuilder::max_arity_
protected

Definition at line 949 of file mesh_CSG_builder.h.

◆ noop_

bool GEO::CSGBuilder::noop_
protected

Definition at line 955 of file mesh_CSG_builder.h.

◆ result_

std::shared_ptr<Mesh> GEO::CSGBuilder::result_
protected

Definition at line 957 of file mesh_CSG_builder.h.

◆ scope_stack_

std::stack<CSGScope> GEO::CSGBuilder::scope_stack_
protected

Definition at line 958 of file mesh_CSG_builder.h.

◆ simplify_coplanar_facets_

bool GEO::CSGBuilder::simplify_coplanar_facets_
protected

Definition at line 952 of file mesh_CSG_builder.h.

◆ STL_epsilon_

double GEO::CSGBuilder::STL_epsilon_
protected

Definition at line 948 of file mesh_CSG_builder.h.


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