libslic3r
Library for generating gcode from 3d models
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
Slic3r::IO::TMFParserContext Struct Reference

3MF XML Document parser. More...

#include <TMF.hpp>

Public Types

enum  TMFNodeType {
  NODE_TYPE_UNKNOWN, NODE_TYPE_MODEL, NODE_TYPE_METADATA, NODE_TYPE_RESOURCES,
  NODE_TYPE_OBJECT, NODE_TYPE_MESH, NODE_TYPE_VERTICES, NODE_TYPE_VERTEX,
  NODE_TYPE_TRIANGLES, NODE_TYPE_TRIANGLE, NODE_TYPE_COMPONENTS, NODE_TYPE_COMPONENT,
  NODE_TYPE_BUILD, NODE_TYPE_ITEM, NODE_TYPE_SLIC3R_METADATA, NODE_TYPE_SLIC3R_VOLUMES,
  NODE_TYPE_SLIC3R_VOLUME, NODE_TYPE_SLIC3R_OBJECT_CONFIG
}
 

Public Member Functions

 TMFParserContext (XML_Parser parser, Model *model)
 
void startElement (const char *name, const char **atts)
 
void endElement ()
 
void endDocument ()
 
void characters (const XML_Char *s, int len)
 
void stop ()
 
bool get_transformations (std::string matrix, std::vector< double > &transformations)
 
ModelVolumeadd_volume (int start_offset, int end_offset, bool modifier)
 
void apply_transformation (ModelObject *object, std::vector< double > &transformations)
 
void apply_transformation (ModelInstance *instance, std::vector< double > &transformations)
 

Static Public Member Functions

static void XMLCALL startElement (void *userData, const char *name, const char **atts)
 
static void XMLCALL endElement (void *userData, const char *name)
 
static void XMLCALL characters (void *userData, const XML_Char *s, int len)
 
static const char * get_attribute (const char **atts, const char *id)
 

Public Attributes

XML_Parser m_parser
 Current Expat XML parser instance. More...
 
std::vector< TMFNodeTypem_path
 Current parsing path in the XML file. More...
 
Modelm_model
 Model to receive objects extracted from an 3MF file. More...
 
ModelObjectm_object
 Current object allocated for an model/object XML subtree. More...
 
std::map< std::string, int > m_objects_indices
 Mapping the object id in the document to the index in the model objects vector. More...
 
std::vector< bool > m_output_objects
 
std::vector< float > m_object_vertices
 Vertices parsed for the current m_object. More...
 
ModelVolumem_volume
 Volume allocated for an model/object/mesh. More...
 
std::vector< int > m_volume_facets
 Faces collected for all volumes of the current object. More...
 
std::string m_value [3]
 Generic string buffer for metadata, etc. More...
 

Detailed Description

3MF XML Document parser.

Member Enumeration Documentation

◆ TMFNodeType

Enumerator
NODE_TYPE_UNKNOWN 
NODE_TYPE_MODEL 
NODE_TYPE_METADATA 
NODE_TYPE_RESOURCES 
NODE_TYPE_OBJECT 
NODE_TYPE_MESH 
NODE_TYPE_VERTICES 
NODE_TYPE_VERTEX 
NODE_TYPE_TRIANGLES 
NODE_TYPE_TRIANGLE 
NODE_TYPE_COMPONENTS 
NODE_TYPE_COMPONENT 
NODE_TYPE_BUILD 
NODE_TYPE_ITEM 
NODE_TYPE_SLIC3R_METADATA 
NODE_TYPE_SLIC3R_VOLUMES 
NODE_TYPE_SLIC3R_VOLUME 
NODE_TYPE_SLIC3R_OBJECT_CONFIG 

Constructor & Destructor Documentation

◆ TMFParserContext()

Slic3r::IO::TMFParserContext::TMFParserContext ( XML_Parser  parser,
Model model 
)

Member Function Documentation

◆ add_volume()

ModelVolume * Slic3r::IO::TMFParserContext::add_volume ( int  start_offset,
int  end_offset,
bool  modifier 
)

Add a new volume to the current object.

Parameters
start_offsetsize_t the start index in the m_volume_facets vector.
end_offsetsize_t the end index in the m_volume_facets vector.
modifierbool whether the volume is modifier or not.
Returns
ModelVolume* a pointer to the newly added volume.

◆ apply_transformation() [1/2]

void Slic3r::IO::TMFParserContext::apply_transformation ( ModelObject object,
std::vector< double > &  transformations 
)

Apply scale, rotate & translate to the given object.

Parameters
objectModelObject*
transfornmationsvector<int>

◆ apply_transformation() [2/2]

void Slic3r::IO::TMFParserContext::apply_transformation ( ModelInstance instance,
std::vector< double > &  transformations 
)

Apply scale, rotate & translate to the given instance.

Parameters
instanceModelInstance*
transfornmationsvector<int>

◆ characters() [1/2]

void XMLCALL Slic3r::IO::TMFParserContext::characters ( void *  userData,
const XML_Char *  s,
int  len 
)
static

◆ characters() [2/2]

void Slic3r::IO::TMFParserContext::characters ( const XML_Char *  s,
int  len 
)

◆ endDocument()

void Slic3r::IO::TMFParserContext::endDocument ( )

◆ endElement() [1/2]

void XMLCALL Slic3r::IO::TMFParserContext::endElement ( void *  userData,
const char *  name 
)
static

◆ endElement() [2/2]

void Slic3r::IO::TMFParserContext::endElement ( )

◆ get_attribute()

const char * Slic3r::IO::TMFParserContext::get_attribute ( const char **  atts,
const char *  id 
)
static

◆ get_transformations()

bool Slic3r::IO::TMFParserContext::get_transformations ( std::string  matrix,
std::vector< double > &  transformations 
)

Get scale, rotation and scale transformation from affine matrix.

Parameters
matrixstring the 3D matrix where elements are separated by space.
Returns
vector<double> a vector contains [translation, scale factor, xRotation, yRotation, zRotation].

◆ startElement() [1/2]

void XMLCALL Slic3r::IO::TMFParserContext::startElement ( void *  userData,
const char *  name,
const char **  atts 
)
static

◆ startElement() [2/2]

void Slic3r::IO::TMFParserContext::startElement ( const char *  name,
const char **  atts 
)

◆ stop()

void Slic3r::IO::TMFParserContext::stop ( )

Member Data Documentation

◆ m_model

Model& Slic3r::IO::TMFParserContext::m_model

Model to receive objects extracted from an 3MF file.

◆ m_object

ModelObject* Slic3r::IO::TMFParserContext::m_object

Current object allocated for an model/object XML subtree.

◆ m_object_vertices

std::vector<float> Slic3r::IO::TMFParserContext::m_object_vertices

Vertices parsed for the current m_object.

◆ m_objects_indices

std::map<std::string, int> Slic3r::IO::TMFParserContext::m_objects_indices

Mapping the object id in the document to the index in the model objects vector.

◆ m_output_objects

std::vector<bool> Slic3r::IO::TMFParserContext::m_output_objects

a vector determines whether each read object should be ignored (1) or not (0). Ignored objects are the ones not referenced in build items.

◆ m_parser

XML_Parser Slic3r::IO::TMFParserContext::m_parser

Current Expat XML parser instance.

◆ m_path

std::vector<TMFNodeType> Slic3r::IO::TMFParserContext::m_path

Current parsing path in the XML file.

◆ m_value

std::string Slic3r::IO::TMFParserContext::m_value[3]

Generic string buffer for metadata, etc.

◆ m_volume

ModelVolume* Slic3r::IO::TMFParserContext::m_volume

Volume allocated for an model/object/mesh.

◆ m_volume_facets

std::vector<int> Slic3r::IO::TMFParserContext::m_volume_facets

Faces collected for all volumes of the current object.


The documentation for this struct was generated from the following files: