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

Creates meshes from OpenSCAD .csg files. More...

#include <geogram/mesh/mesh_CSG_compiler.h>

Classes

struct  Token
 

Public Types

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

Public Member Functions

std::shared_ptr< Meshcompile_file (const std::filesystem::path &input_filename)
 
std::shared_ptr< Meshcompile_string (const std::string &source)
 
void set_verbose (bool x)
 Displays (lots of) additional information.
 
void set_detailed_verbose (bool x)
 Displays (even more) additional information.
 
CSGBuilderbuilder ()
 Gets the CSGbuilder.
 
const CSGBuilderbuilder () const
 Gets the CSGbuilder.
 

Protected Member Functions

void parse_instruction_or_object ()
 
void parse_object ()
 
void parse_instruction ()
 
ArgList parse_arg_list ()
 
Value parse_value ()
 
Value parse_array ()
 
bool is_object (const std::string &id) const
 
bool is_instruction (const std::string &id) const
 
bool is_modifier (int toktype) const
 Checks if a token corresponds to an instruction or object modifier.
 
void next_token_check (char c)
 Checks that the next token is a given character.
 
Token next_token ()
 Gets the next token.
 
Token lookahead_token ()
 Gets the next token without any side effect.
 
Token next_token_internal ()
 Function to actually get the next token from the stream.
 
int lines () const
 Gets the total number of lines of the currently parsed source.
 
int line () const
 Gets the currently parsed line source.
 
void syntax_error (const char *msg)
 Throws an exception with an error message.
 
void syntax_error (const char *msg, const Token &tok)
 Throws an exception with an error message.
 
void compute_lines () const
 

Detailed Description

Creates meshes from OpenSCAD .csg files.

Understands a subset of OpenSCAD .csg format.

Definition at line 57 of file mesh_CSG_compiler.h.

Member Typedef Documentation

◆ ArgList

Definition at line 61 of file mesh_CSG_compiler.h.

◆ Value

Definition at line 60 of file mesh_CSG_compiler.h.

Member Function Documentation

◆ builder() [1/2]

CSGBuilder & GEO::CSGCompiler::builder ( )
inline

Gets the CSGbuilder.

Returns
a reference to the CSGBuilder

Definition at line 92 of file mesh_CSG_compiler.h.

◆ builder() [2/2]

const CSGBuilder & GEO::CSGCompiler::builder ( ) const
inline

Gets the CSGbuilder.

Returns
a const reference to the CSGBuilder

Definition at line 100 of file mesh_CSG_compiler.h.

◆ is_modifier()

bool GEO::CSGCompiler::is_modifier ( int  toktype) const
protected

Checks if a token corresponds to an instruction or object modifier.

A modifier is one of '','#','!','*', where '' and '*' discard the subtree, '#' does not change anything and '!' replaces the result with the subtree (re-root). Note: in OpenSCAD, '' and '#' display the subtree as a transparent object.

◆ lookahead_token()

Token GEO::CSGCompiler::lookahead_token ( )
protected

Gets the next token without any side effect.

Parsing position remains at the same token.

◆ next_token()

Token GEO::CSGCompiler::next_token ( )
protected

Gets the next token.

Parsing proceeds to the next token.

◆ next_token_check()

void GEO::CSGCompiler::next_token_check ( char  c)
protected

Checks that the next token is a given character.

If the next token is something else than the given character, then parsing stops with an error message.

Parameters
[in]cthe character

◆ next_token_internal()

Token GEO::CSGCompiler::next_token_internal ( )
protected

Function to actually get the next token from the stream.

next_token() and lookahead_token() use a 1-token buffer to pretend that one can look at a token in advance without consuming it.

◆ set_detailed_verbose()

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

Displays (even more) additional information.

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

Definition at line 84 of file mesh_CSG_compiler.h.

◆ set_verbose()

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

Displays (lots of) additional information.

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

Definition at line 75 of file mesh_CSG_compiler.h.

◆ syntax_error() [1/2]

void GEO::CSGCompiler::syntax_error ( const char *  msg)
protected

Throws an exception with an error message.

Parameters
[in]msgthe error message to be displayed

◆ syntax_error() [2/2]

void GEO::CSGCompiler::syntax_error ( const char *  msg,
const Token tok 
)
protected

Throws an exception with an error message.

Parameters
[in]msgthe error message to be displayed
[in]tokthe currently parsed token, will be appended to the error message

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