Graphite  Version 3
An experimental 3D geometry processing program
GEO::CSGCompiler Class Reference

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

#include <geogram/mesh/mesh_CSG.h>

Classes

class  ArgList
 A parsed argument list in a .csg file. More...
 
struct  Token
 
struct  Value
 A parsed value in a .csg file. More...
 

Public Member Functions

CSGMesh_var compile_file (const std::string &input_filename)
 
CSGMesh_var compile_string (const std::string &source)
 
void set_verbose (bool x)
 Displays (lots of) additional information. More...
 
CSGBuilderbuilder ()
 Gets the CSGbuilder. More...
 

Protected Member Functions

CSGMesh_var square (const ArgList &args)
 
CSGMesh_var circle (const ArgList &args)
 
CSGMesh_var cube (const ArgList &args)
 
CSGMesh_var sphere (const ArgList &args)
 
CSGMesh_var cylinder (const ArgList &args)
 
CSGMesh_var polyhedron (const ArgList &args)
 
CSGMesh_var polygon (const ArgList &args)
 
CSGMesh_var import (const ArgList &args)
 
CSGMesh_var surface (const ArgList &args)
 
CSGMesh_var multmatrix (const ArgList &args, const CSGScope &scope)
 
CSGMesh_var resize (const ArgList &args, const CSGScope &scope)
 
CSGMesh_var union_instr (const ArgList &args, const CSGScope &scope)
 
CSGMesh_var intersection (const ArgList &args, const CSGScope &scope)
 
CSGMesh_var difference (const ArgList &args, const CSGScope &scope)
 
CSGMesh_var group (const ArgList &args, const CSGScope &scope)
 
CSGMesh_var color (const ArgList &args, const CSGScope &scope)
 
CSGMesh_var hull (const ArgList &args, const CSGScope &scope)
 
CSGMesh_var linear_extrude (const ArgList &args, const CSGScope &scope)
 
CSGMesh_var rotate_extrude (const ArgList &args, const CSGScope &scope)
 
CSGMesh_var projection (const ArgList &args, const CSGScope &scope)
 
CSGMesh_var parse_instruction_or_object ()
 
CSGMesh_var parse_object ()
 
CSGMesh_var 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. More...
 
void next_token_check (char c)
 Checks that the next token is a given character. More...
 
Token next_token ()
 Gets the next token. More...
 
Token lookahead_token ()
 Gets the next token without any side effect. More...
 
Token next_token_internal ()
 Function to actually get the next token from the stream. More...
 
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. More...
 
void syntax_error (const char *msg, const Token &tok)
 Throws an exception with an error message. More...
 

Detailed Description

Creates meshes from OpenSCAD .csg files.

Understands a subset of OpenSCAD .csg format.

Definition at line 465 of file mesh_CSG.h.

Member Function Documentation

◆ builder()

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

Gets the CSGbuilder.

Returns
a reference to the CSGBuilder

Definition at line 485 of file mesh_CSG.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_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 477 of file mesh_CSG.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: