OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::_BBS_3MF_Importer::ObjectImporter Struct Reference
Collaboration diagram for Slic3r::_BBS_3MF_Importer::ObjectImporter:

Public Member Functions

 ObjectImporter (_BBS_3MF_Importer *importer, std::string file_path, std::string obj_path)
 ~ObjectImporter ()
void _destroy_object_xml_parser ()
void _stop_object_xml_parser (const std::string &msg=std::string())
bool object_parse_error () const
const char * object_parse_error_message () const
bool _extract_object_from_archive (mz_zip_archive &archive, const mz_zip_archive_file_stat &stat)
bool extract_object_model ()
bool _handle_object_start_model (const char **attributes, unsigned int num_attributes)
bool _handle_object_end_model ()
bool _handle_object_start_resources (const char **attributes, unsigned int num_attributes)
bool _handle_object_end_resources ()
bool _handle_object_start_object (const char **attributes, unsigned int num_attributes)
bool _handle_object_end_object ()
bool _handle_object_start_color_group (const char **attributes, unsigned int num_attributes)
bool _handle_object_end_color_group ()
bool _handle_object_start_color (const char **attributes, unsigned int num_attributes)
bool _handle_object_end_color ()
bool _handle_object_start_mesh (const char **attributes, unsigned int num_attributes)
bool _handle_object_end_mesh ()
bool _handle_object_start_vertices (const char **attributes, unsigned int num_attributes)
bool _handle_object_end_vertices ()
bool _handle_object_start_vertex (const char **attributes, unsigned int num_attributes)
bool _handle_object_end_vertex ()
bool _handle_object_start_triangles (const char **attributes, unsigned int num_attributes)
bool _handle_object_end_triangles ()
bool _handle_object_start_triangle (const char **attributes, unsigned int num_attributes)
bool _handle_object_end_triangle ()
bool _handle_object_start_components (const char **attributes, unsigned int num_attributes)
bool _handle_object_end_components ()
bool _handle_object_start_component (const char **attributes, unsigned int num_attributes)
bool _handle_object_end_component ()
bool _handle_object_start_metadata (const char **attributes, unsigned int num_attributes)
bool _handle_object_end_metadata ()
void _handle_object_start_model_xml_element (const char *name, const char **attributes)
void _handle_object_end_model_xml_element (const char *name)
void _handle_object_xml_characters (const XML_Char *s, int len)

Static Public Member Functions

static void XMLCALL _handle_object_start_model_xml_element (void *userData, const char *name, const char **attributes)
static void XMLCALL _handle_object_end_model_xml_element (void *userData, const char *name)
static void XMLCALL _handle_object_xml_characters (void *userData, const XML_Char *s, int len)

Public Attributes

IdToCurrentObjectMap object_list
CurrentObject * current_object {nullptr}
std::string object_path
std::string zip_path
_BBS_3MF_Importer * top_importer {nullptr}
XML_Parser object_xml_parser
bool obj_parse_error { false }
std::string obj_parse_error_message
std::string obj_curr_metadata_name
std::string obj_curr_characters
float object_unit_factor
int object_current_color_group {-1}
std::map< int, std::string > object_group_id_to_color
bool is_bbl_3mf { false }

Detailed Description

Constructor & Destructor Documentation

◆ ObjectImporter()

Slic3r::_BBS_3MF_Importer::ObjectImporter::ObjectImporter ( _BBS_3MF_Importer * importer,
std::string file_path,
std::string obj_path )
inline
1044 {
1045 top_importer = importer;
1046 object_path = obj_path;
1047 zip_path = file_path;
1048 }
std::string object_path
Definition bbs_3mf.cpp:1028
_BBS_3MF_Importer * top_importer
Definition bbs_3mf.cpp:1030
std::string zip_path
Definition bbs_3mf.cpp:1029

References Slic3r::_BBS_3MF_Importer::_BBS_3MF_Importer(), object_path, top_importer, and zip_path.

Referenced by _handle_object_end_model_xml_element(), _handle_object_start_model_xml_element(), and _handle_object_xml_characters().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ~ObjectImporter()

Slic3r::_BBS_3MF_Importer::ObjectImporter::~ObjectImporter ( )
inline
1051 {
1053 }
void _destroy_object_xml_parser()
Definition bbs_3mf.cpp:1055

References _destroy_object_xml_parser().

Here is the call graph for this function:

Member Function Documentation

◆ _destroy_object_xml_parser()

void Slic3r::_BBS_3MF_Importer::ObjectImporter::_destroy_object_xml_parser ( )
inline
1056 {
1057 if (object_xml_parser != nullptr) {
1058 XML_ParserFree(object_xml_parser);
1059 object_xml_parser = nullptr;
1060 }
1061 }
XML_Parser object_xml_parser
Definition bbs_3mf.cpp:1031

References object_xml_parser.

Referenced by ~ObjectImporter().

Here is the caller graph for this function:

◆ _extract_object_from_archive()

bool Slic3r::_BBS_3MF_Importer::ObjectImporter::_extract_object_from_archive ( mz_zip_archive & archive,
const mz_zip_archive_file_stat & stat )
6104 {
6105 if (stat.m_uncomp_size == 0) {
6106 top_importer->add_error("Found invalid size for "+object_path);
6107 return false;
6108 }
6109
6110 object_xml_parser = XML_ParserCreate(nullptr);
6111 if (object_xml_parser == nullptr) {
6112 top_importer->add_error("Unable to create parser for "+object_path);
6113 return false;
6114 }
6115
6116 XML_SetUserData(object_xml_parser, (void*)this);
6119 XML_SetEntityDeclHandler(object_xml_parser, nullptr);
6120 XML_SetExternalEntityRefHandler(object_xml_parser, nullptr);
6121
6122 struct CallbackData
6123 {
6124 XML_Parser& parser;
6125 _BBS_3MF_Importer::ObjectImporter& importer;
6126 const mz_zip_archive_file_stat& stat;
6127
6128 CallbackData(XML_Parser& parser, _BBS_3MF_Importer::ObjectImporter& importer, const mz_zip_archive_file_stat& stat) : parser(parser), importer(importer), stat(stat) {}
6129 };
6130
6131 CallbackData data(object_xml_parser, *this, stat);
6132
6133 mz_bool res = 0;
6134
6135 try
6136 {
6137 mz_file_write_func callback = [](void* pOpaque, mz_uint64 file_ofs, const void* pBuf, size_t n)->size_t {
6138 CallbackData* data = (CallbackData*)pOpaque;
6139 if (!XML_Parse(data->parser, (const char*)pBuf, (int)n, (file_ofs + n == data->stat.m_uncomp_size) ? 1 : 0) || data->importer.object_parse_error()) {
6140 char error_buf[1024];
6141 ::snprintf(error_buf, 1024, "Error (%s) while parsing '%s' at line %d", data->importer.object_parse_error_message(), data->stat.m_filename, (int)XML_GetCurrentLineNumber(data->parser));
6142 throw Slic3r::FileIOError(error_buf);
6143 }
6144 return n;
6145 };
6146 void* opaque = &data;
6147 res = mz_zip_reader_extract_to_callback(&archive, stat.m_file_index, callback, opaque, 0);
6148 }
6149 catch (const version_error& e)
6150 {
6151 // rethrow the exception
6152 std::string error_message = std::string(e.what()) + " for " + object_path;
6153 throw Slic3r::FileIOError(error_message);
6154 }
6155 catch (std::exception& e)
6156 {
6157 std::string error_message = std::string(e.what()) + " for " + object_path;
6158 top_importer->add_error(error_message);
6159 return false;
6160 }
6161
6162 if (res == 0) {
6163 top_importer->add_error("Error while extracting model data from zip archive for "+object_path);
6164 return false;
6165 }
6166
6167 return true;
6168 }
void _handle_object_end_model_xml_element(const char *name)
Definition bbs_3mf.cpp:6039
void _handle_object_start_model_xml_element(const char *name, const char **attributes)
Definition bbs_3mf.cpp:6000
void _handle_object_xml_characters(const XML_Char *s, int len)
Definition bbs_3mf.cpp:6077

References _extract_object_from_archive(), _handle_object_end_model_xml_element(), _handle_object_start_model_xml_element(), _handle_object_xml_characters(), object_path, object_xml_parser, and top_importer.

Referenced by _extract_object_from_archive().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _handle_object_end_color()

bool Slic3r::_BBS_3MF_Importer::ObjectImporter::_handle_object_end_color ( )
5827 {
5828 // do nothing
5829 return true;
5830 }

References _handle_object_end_color().

Referenced by _handle_object_end_color(), and _handle_object_end_model_xml_element().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _handle_object_end_color_group()

bool Slic3r::_BBS_3MF_Importer::ObjectImporter::_handle_object_end_color_group ( )
5814 {
5815 // do nothing
5816 return true;
5817 }

References _handle_object_end_color_group().

Referenced by _handle_object_end_color_group(), and _handle_object_end_model_xml_element().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _handle_object_end_component()

bool Slic3r::_BBS_3MF_Importer::ObjectImporter::_handle_object_end_component ( )
5976 {
5977 // do nothing
5978 return true;
5979 }

References _handle_object_end_component().

Referenced by _handle_object_end_component(), and _handle_object_end_model_xml_element().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _handle_object_end_components()

bool Slic3r::_BBS_3MF_Importer::ObjectImporter::_handle_object_end_components ( )
5947 {
5948 // do nothing
5949 return true;
5950 }

References _handle_object_end_components().

Referenced by _handle_object_end_components(), and _handle_object_end_model_xml_element().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _handle_object_end_mesh()

bool Slic3r::_BBS_3MF_Importer::ObjectImporter::_handle_object_end_mesh ( )
5841 {
5842 // do nothing
5843 return true;
5844 }

References _handle_object_end_mesh().

Referenced by _handle_object_end_mesh(), and _handle_object_end_model_xml_element().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _handle_object_end_metadata()

bool Slic3r::_BBS_3MF_Importer::ObjectImporter::_handle_object_end_metadata ( )
5994 {
5996 is_bbl_3mf = true;
5997 }
5998 return true;
5999 }
const char * BBS_3MF_VERSION1
Definition bbs_3mf.cpp:172
const char * BBS_3MF_VERSION
Definition bbs_3mf.cpp:173
bool is_bbl_3mf
Definition bbs_3mf.cpp:1041
std::string obj_curr_metadata_name
Definition bbs_3mf.cpp:1036

References _handle_object_end_metadata(), BBS_3MF_VERSION, BBS_3MF_VERSION1, is_bbl_3mf, and obj_curr_metadata_name.

Referenced by _handle_object_end_metadata(), and _handle_object_end_model_xml_element().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _handle_object_end_model()

bool Slic3r::_BBS_3MF_Importer::ObjectImporter::_handle_object_end_model ( )
5699 {
5700 // do nothing
5701 return true;
5702 }

References _handle_object_end_model().

Referenced by _handle_object_end_model(), and _handle_object_end_model_xml_element().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _handle_object_end_model_xml_element() [1/2]

void Slic3r::_BBS_3MF_Importer::ObjectImporter::_handle_object_end_model_xml_element ( const char * name)
6040 {
6041 if (object_xml_parser == nullptr)
6042 return;
6043
6044 bool res = true;
6045
6046 if (::strcmp(MODEL_TAG, name) == 0)
6048 else if (::strcmp(RESOURCES_TAG, name) == 0)
6050 else if (::strcmp(OBJECT_TAG, name) == 0)
6052 else if (::strcmp(COLOR_GROUP_TAG, name) == 0)
6054 else if (::strcmp(COLOR_TAG, name) == 0)
6056 else if (::strcmp(MESH_TAG, name) == 0)
6058 else if (::strcmp(VERTICES_TAG, name) == 0)
6060 else if (::strcmp(VERTEX_TAG, name) == 0)
6062 else if (::strcmp(TRIANGLES_TAG, name) == 0)
6064 else if (::strcmp(TRIANGLE_TAG, name) == 0)
6066 else if (::strcmp(COMPONENTS_TAG, name) == 0)
6068 else if (::strcmp(COMPONENT_TAG, name) == 0)
6070 else if (::strcmp(METADATA_TAG, name) == 0)
6072
6073 if (!res)
6075 }
static constexpr const char * TRIANGLES_TAG
Definition 3mf.cpp:115
static constexpr const char * RESOURCES_TAG
Definition 3mf.cpp:110
static constexpr const char * VERTEX_TAG
Definition 3mf.cpp:114
static constexpr const char * MESH_TAG
Definition 3mf.cpp:112
static constexpr const char * COMPONENTS_TAG
Definition 3mf.cpp:117
static constexpr const char * COMPONENT_TAG
Definition 3mf.cpp:118
static constexpr const char * MODEL_TAG
Definition 3mf.cpp:109
static constexpr const char * METADATA_TAG
Definition 3mf.cpp:121
static constexpr const char * VERTICES_TAG
Definition 3mf.cpp:113
static constexpr const char * TRIANGLE_TAG
Definition 3mf.cpp:116
static constexpr const char * OBJECT_TAG
Definition 3mf.cpp:111
static constexpr const char * COLOR_GROUP_TAG
Definition bbs_3mf.cpp:258
static constexpr const char * COLOR_TAG
Definition bbs_3mf.cpp:259
bool _handle_object_end_model()
Definition bbs_3mf.cpp:5698
bool _handle_object_end_component()
Definition bbs_3mf.cpp:5975
bool _handle_object_end_color_group()
Definition bbs_3mf.cpp:5813
bool _handle_object_end_triangles()
Definition bbs_3mf.cpp:5893
bool _handle_object_end_mesh()
Definition bbs_3mf.cpp:5840
bool _handle_object_end_object()
Definition bbs_3mf.cpp:5744
bool _handle_object_end_components()
Definition bbs_3mf.cpp:5946
bool _handle_object_end_vertex()
Definition bbs_3mf.cpp:5879
bool _handle_object_end_vertices()
Definition bbs_3mf.cpp:5854
bool _handle_object_end_color()
Definition bbs_3mf.cpp:5826
void _stop_object_xml_parser(const std::string &msg=std::string())
Definition bbs_3mf.cpp:1063
bool _handle_object_end_resources()
Definition bbs_3mf.cpp:5710
bool _handle_object_end_metadata()
Definition bbs_3mf.cpp:5993
bool _handle_object_end_triangle()
Definition bbs_3mf.cpp:5932

References _handle_object_end_color(), _handle_object_end_color_group(), _handle_object_end_component(), _handle_object_end_components(), _handle_object_end_mesh(), _handle_object_end_metadata(), _handle_object_end_model(), _handle_object_end_model_xml_element(), _handle_object_end_object(), _handle_object_end_resources(), _handle_object_end_triangle(), _handle_object_end_triangles(), _handle_object_end_vertex(), _handle_object_end_vertices(), _stop_object_xml_parser(), COLOR_GROUP_TAG, COLOR_TAG, COMPONENT_TAG, COMPONENTS_TAG, MESH_TAG, METADATA_TAG, MODEL_TAG, OBJECT_TAG, object_xml_parser, RESOURCES_TAG, TRIANGLE_TAG, TRIANGLES_TAG, VERTEX_TAG, and VERTICES_TAG.

Referenced by _extract_object_from_archive(), _handle_object_end_model_xml_element(), and _handle_object_end_model_xml_element().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _handle_object_end_model_xml_element() [2/2]

void XMLCALL Slic3r::_BBS_3MF_Importer::ObjectImporter::_handle_object_end_model_xml_element ( void * userData,
const char * name )
static
6090 {
6091 ObjectImporter* importer = (ObjectImporter*)userData;
6092 if (importer != nullptr)
6093 importer->_handle_object_end_model_xml_element(name);
6094 }
ObjectImporter(_BBS_3MF_Importer *importer, std::string file_path, std::string obj_path)
Definition bbs_3mf.cpp:1043

References ObjectImporter(), and _handle_object_end_model_xml_element().

Here is the call graph for this function:

◆ _handle_object_end_object()

bool Slic3r::_BBS_3MF_Importer::ObjectImporter::_handle_object_end_object ( )
5745 {
5746 if (!current_object || (current_object->id == -1)) {
5747 top_importer->add_error("Found invalid object for "+ object_path);
5748 return false;
5749 }
5750 else {
5751 if (is_bbl_3mf && boost::ends_with(current_object->uuid, OBJECT_UUID_SUFFIX) && top_importer->m_load_restore) {
5752 std::istringstream iss(current_object->uuid);
5753 int backup_id;
5754 bool need_replace = false;
5755 if (iss >> std::hex >> backup_id) {
5756 need_replace = (current_object->id != backup_id);
5757 current_object->id = backup_id;
5758 }
5759 //if (need_replace)
5760 {
5761 for (int index = 0; index < current_object->components.size(); index++)
5762 {
5763 int temp_id = (index + 1) << 16 | backup_id;
5764 Component& component = current_object->components[index];
5765 std::string new_path = component.object_id.first;
5766 Id new_id = std::make_pair(new_path, temp_id);
5767 IdToCurrentObjectMap::iterator object_it = object_list.find(component.object_id);
5768 if (object_it != object_list.end()) {
5769 CurrentObject new_object;
5770 new_object.geometry = std::move(object_it->second.geometry);
5771 new_object.id = temp_id;
5772 new_object.model_object_idx = object_it->second.model_object_idx;
5773 new_object.name = object_it->second.name;
5774 new_object.uuid = object_it->second.uuid;
5775
5776 object_list.erase(object_it);
5777 object_list.insert({ new_id, std::move(new_object) });
5778 }
5779 else {
5780 top_importer->add_error("can not find object for component, id=" + std::to_string(component.object_id.second));
5781 delete current_object;
5782 current_object = nullptr;
5783 return false;
5784 }
5785
5786 component.object_id.second = temp_id;
5787 }
5788 }
5789 }
5790 Id id = std::make_pair(object_path, current_object->id);
5791 if (object_list.find(id) == object_list.end()) {
5792 object_list.insert({ id, std::move(*current_object) });
5793 delete current_object;
5794 current_object = nullptr;
5795 }
5796 else {
5797 top_importer->add_error("Found object with duplicate id for "+object_path);
5798 delete current_object;
5799 current_object = nullptr;
5800 return false;
5801 }
5802 }
5803
5804 return true;
5805 }
static constexpr const char * OBJECT_UUID_SUFFIX
Definition bbs_3mf.cpp:328
std::pair< std::string, int > Id
Definition bbs_3mf.cpp:829
CurrentObject * current_object
Definition bbs_3mf.cpp:1027
IdToCurrentObjectMap object_list
Definition bbs_3mf.cpp:1026

References _handle_object_end_object(), current_object, Slic3r::_BBS_3MF_Importer::CurrentObject::geometry, Slic3r::_BBS_3MF_Importer::CurrentObject::id, is_bbl_3mf, Slic3r::_BBS_3MF_Importer::CurrentObject::model_object_idx, Slic3r::_BBS_3MF_Importer::CurrentObject::name, Slic3r::_BBS_3MF_Importer::Component::object_id, object_list, object_path, OBJECT_UUID_SUFFIX, top_importer, and Slic3r::_BBS_3MF_Importer::CurrentObject::uuid.

Referenced by _handle_object_end_model_xml_element(), and _handle_object_end_object().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _handle_object_end_resources()

bool Slic3r::_BBS_3MF_Importer::ObjectImporter::_handle_object_end_resources ( )
5711 {
5712 // do nothing
5713 return true;
5714 }

References _handle_object_end_resources().

Referenced by _handle_object_end_model_xml_element(), and _handle_object_end_resources().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _handle_object_end_triangle()

bool Slic3r::_BBS_3MF_Importer::ObjectImporter::_handle_object_end_triangle ( )
5933 {
5934 // do nothing
5935 return true;
5936 }

References _handle_object_end_triangle().

Referenced by _handle_object_end_model_xml_element(), and _handle_object_end_triangle().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _handle_object_end_triangles()

bool Slic3r::_BBS_3MF_Importer::ObjectImporter::_handle_object_end_triangles ( )
5894 {
5895 // do nothing
5896 return true;
5897 }

References _handle_object_end_triangles().

Referenced by _handle_object_end_model_xml_element(), and _handle_object_end_triangles().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _handle_object_end_vertex()

bool Slic3r::_BBS_3MF_Importer::ObjectImporter::_handle_object_end_vertex ( )
5880 {
5881 // do nothing
5882 return true;
5883 }

References _handle_object_end_vertex().

Referenced by _handle_object_end_model_xml_element(), and _handle_object_end_vertex().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _handle_object_end_vertices()

bool Slic3r::_BBS_3MF_Importer::ObjectImporter::_handle_object_end_vertices ( )
5855 {
5856 // do nothing
5857 return true;
5858 }

References _handle_object_end_vertices().

Referenced by _handle_object_end_model_xml_element(), and _handle_object_end_vertices().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _handle_object_start_color()

bool Slic3r::_BBS_3MF_Importer::ObjectImporter::_handle_object_start_color ( const char ** attributes,
unsigned int num_attributes )
5820 {
5821 std::string color = bbs_get_attribute_value_string(attributes, num_attributes, COLOR_ATTR);
5823 return true;
5824 }
static constexpr const char * COLOR_ATTR
Definition bbs_3mf.cpp:339
std::string bbs_get_attribute_value_string(const char **attributes, unsigned int attributes_size, const char *attribute_key)
Definition bbs_3mf.cpp:538
int object_current_color_group
Definition bbs_3mf.cpp:1039
std::map< int, std::string > object_group_id_to_color
Definition bbs_3mf.cpp:1040

References _handle_object_start_color(), bbs_get_attribute_value_string(), COLOR_ATTR, object_current_color_group, and object_group_id_to_color.

Referenced by _handle_object_start_color(), and _handle_object_start_model_xml_element().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _handle_object_start_color_group()

bool Slic3r::_BBS_3MF_Importer::ObjectImporter::_handle_object_start_color_group ( const char ** attributes,
unsigned int num_attributes )
5808 {
5809 object_current_color_group = bbs_get_attribute_value_int(attributes, num_attributes, ID_ATTR);
5810 return true;
5811 }
static constexpr const char * ID_ATTR
Definition 3mf.cpp:129
int bbs_get_attribute_value_int(const char **attributes, unsigned int attributes_size, const char *attribute_key)
Definition bbs_3mf.cpp:552

References _handle_object_start_color_group(), bbs_get_attribute_value_int(), ID_ATTR, and object_current_color_group.

Referenced by _handle_object_start_color_group(), and _handle_object_start_model_xml_element().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _handle_object_start_component()

bool Slic3r::_BBS_3MF_Importer::ObjectImporter::_handle_object_start_component ( const char ** attributes,
unsigned int num_attributes )
5953 {
5954 int object_id = bbs_get_attribute_value_int(attributes, num_attributes, OBJECTID_ATTR);
5956
5957 /*Id id = std::make_pair(m_sub_model_path, object_id);
5958 IdToModelObjectMap::iterator object_item = m_objects.find(id);
5959 if (object_item == m_objects.end()) {
5960 IdToAliasesMap::iterator alias_item = m_objects_aliases.find(id);
5961 if (alias_item == m_objects_aliases.end()) {
5962 add_error("Found component with invalid object id");
5963 return false;
5964 }
5965 }*/
5966
5967 if (current_object) {
5968 Id id = std::make_pair(object_path, object_id);
5969 current_object->components.emplace_back(id, transform);
5970 }
5971
5972 return true;
5973 }
static constexpr const char * TRANSFORM_ATTR
Definition 3mf.cpp:137
static constexpr const char * OBJECTID_ATTR
Definition 3mf.cpp:136
Slic3r::Transform3d bbs_get_transform_from_3mf_specs_string(const std::string &mat_str)
Definition bbs_3mf.cpp:637
Eigen::Transform< double, 3, Eigen::Affine, Eigen::DontAlign > Transform3d
Definition Point.hpp:96
Linef3 transform(const Linef3 &line, const Transform3d &t)
Definition Line.cpp:15

References _handle_object_start_component(), bbs_get_attribute_value_int(), bbs_get_attribute_value_string(), bbs_get_transform_from_3mf_specs_string(), current_object, object_path, OBJECTID_ATTR, Slic3r::transform(), and TRANSFORM_ATTR.

Referenced by _handle_object_start_component(), and _handle_object_start_model_xml_element().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _handle_object_start_components()

bool Slic3r::_BBS_3MF_Importer::ObjectImporter::_handle_object_start_components ( const char ** attributes,
unsigned int num_attributes )
5939 {
5940 // reset current components
5941 if (current_object)
5942 current_object->components.clear();
5943 return true;
5944 }

References _handle_object_start_components(), and current_object.

Referenced by _handle_object_start_components(), and _handle_object_start_model_xml_element().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _handle_object_start_mesh()

bool Slic3r::_BBS_3MF_Importer::ObjectImporter::_handle_object_start_mesh ( const char ** attributes,
unsigned int num_attributes )
5833 {
5834 // reset current geometry
5835 if (current_object)
5836 current_object->geometry.reset();
5837 return true;
5838 }

References _handle_object_start_mesh(), and current_object.

Referenced by _handle_object_start_mesh(), and _handle_object_start_model_xml_element().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _handle_object_start_metadata()

bool Slic3r::_BBS_3MF_Importer::ObjectImporter::_handle_object_start_metadata ( const char ** attributes,
unsigned int num_attributes )
5982 {
5983 obj_curr_metadata_name.clear();
5984
5985 std::string name = bbs_get_attribute_value_string(attributes, num_attributes, NAME_ATTR);
5986 if (!name.empty()) {
5988 }
5989
5990 return true;
5991 }
static constexpr const char * NAME_ATTR
Definition 3mf.cpp:127

References _handle_object_start_metadata(), bbs_get_attribute_value_string(), NAME_ATTR, and obj_curr_metadata_name.

Referenced by _handle_object_start_metadata(), and _handle_object_start_model_xml_element().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _handle_object_start_model()

bool Slic3r::_BBS_3MF_Importer::ObjectImporter::_handle_object_start_model ( const char ** attributes,
unsigned int num_attributes )
5692 {
5694
5695 return true;
5696 }
static constexpr const char * UNIT_ATTR
Definition 3mf.cpp:126
float bbs_get_unit_factor(const std::string &unit)
Definition bbs_3mf.cpp:689
float object_unit_factor
Definition bbs_3mf.cpp:1038

References _handle_object_start_model(), bbs_get_attribute_value_string(), bbs_get_unit_factor(), object_unit_factor, and UNIT_ATTR.

Referenced by _handle_object_start_model(), and _handle_object_start_model_xml_element().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _handle_object_start_model_xml_element() [1/2]

void Slic3r::_BBS_3MF_Importer::ObjectImporter::_handle_object_start_model_xml_element ( const char * name,
const char ** attributes )
6001 {
6002 if (object_xml_parser == nullptr)
6003 return;
6004
6005 bool res = true;
6006 unsigned int num_attributes = (unsigned int)XML_GetSpecifiedAttributeCount(object_xml_parser);
6007
6008 if (::strcmp(MODEL_TAG, name) == 0)
6009 res = _handle_object_start_model(attributes, num_attributes);
6010 else if (::strcmp(RESOURCES_TAG, name) == 0)
6011 res = _handle_object_start_resources(attributes, num_attributes);
6012 else if (::strcmp(OBJECT_TAG, name) == 0)
6013 res = _handle_object_start_object(attributes, num_attributes);
6014 else if (::strcmp(COLOR_GROUP_TAG, name) == 0)
6015 res = _handle_object_start_color_group(attributes, num_attributes);
6016 else if (::strcmp(COLOR_TAG, name) == 0)
6017 res = _handle_object_start_color(attributes, num_attributes);
6018 else if (::strcmp(MESH_TAG, name) == 0)
6019 res = _handle_object_start_mesh(attributes, num_attributes);
6020 else if (::strcmp(VERTICES_TAG, name) == 0)
6021 res = _handle_object_start_vertices(attributes, num_attributes);
6022 else if (::strcmp(VERTEX_TAG, name) == 0)
6023 res = _handle_object_start_vertex(attributes, num_attributes);
6024 else if (::strcmp(TRIANGLES_TAG, name) == 0)
6025 res = _handle_object_start_triangles(attributes, num_attributes);
6026 else if (::strcmp(TRIANGLE_TAG, name) == 0)
6027 res = _handle_object_start_triangle(attributes, num_attributes);
6028 else if (::strcmp(COMPONENTS_TAG, name) == 0)
6029 res = _handle_object_start_components(attributes, num_attributes);
6030 else if (::strcmp(COMPONENT_TAG, name) == 0)
6031 res = _handle_object_start_component(attributes, num_attributes);
6032 else if (::strcmp(METADATA_TAG, name) == 0)
6033 res = _handle_object_start_metadata(attributes, num_attributes);
6034
6035 if (!res)
6037 }
bool _handle_object_start_triangle(const char **attributes, unsigned int num_attributes)
Definition bbs_3mf.cpp:5899
bool _handle_object_start_triangles(const char **attributes, unsigned int num_attributes)
Definition bbs_3mf.cpp:5885
bool _handle_object_start_component(const char **attributes, unsigned int num_attributes)
Definition bbs_3mf.cpp:5952
bool _handle_object_start_model(const char **attributes, unsigned int num_attributes)
Definition bbs_3mf.cpp:5691
bool _handle_object_start_resources(const char **attributes, unsigned int num_attributes)
Definition bbs_3mf.cpp:5704
bool _handle_object_start_color(const char **attributes, unsigned int num_attributes)
Definition bbs_3mf.cpp:5819
bool _handle_object_start_components(const char **attributes, unsigned int num_attributes)
Definition bbs_3mf.cpp:5938
bool _handle_object_start_vertices(const char **attributes, unsigned int num_attributes)
Definition bbs_3mf.cpp:5846
bool _handle_object_start_vertex(const char **attributes, unsigned int num_attributes)
Definition bbs_3mf.cpp:5860
bool _handle_object_start_metadata(const char **attributes, unsigned int num_attributes)
Definition bbs_3mf.cpp:5981
bool _handle_object_start_mesh(const char **attributes, unsigned int num_attributes)
Definition bbs_3mf.cpp:5832
bool _handle_object_start_color_group(const char **attributes, unsigned int num_attributes)
Definition bbs_3mf.cpp:5807
bool _handle_object_start_object(const char **attributes, unsigned int num_attributes)
Definition bbs_3mf.cpp:5716

References _handle_object_start_color(), _handle_object_start_color_group(), _handle_object_start_component(), _handle_object_start_components(), _handle_object_start_mesh(), _handle_object_start_metadata(), _handle_object_start_model(), _handle_object_start_model_xml_element(), _handle_object_start_object(), _handle_object_start_resources(), _handle_object_start_triangle(), _handle_object_start_triangles(), _handle_object_start_vertex(), _handle_object_start_vertices(), _stop_object_xml_parser(), COLOR_GROUP_TAG, COLOR_TAG, COMPONENT_TAG, COMPONENTS_TAG, MESH_TAG, METADATA_TAG, MODEL_TAG, OBJECT_TAG, object_xml_parser, RESOURCES_TAG, TRIANGLE_TAG, TRIANGLES_TAG, VERTEX_TAG, and VERTICES_TAG.

Referenced by _extract_object_from_archive(), _handle_object_start_model_xml_element(), and _handle_object_start_model_xml_element().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _handle_object_start_model_xml_element() [2/2]

void XMLCALL Slic3r::_BBS_3MF_Importer::ObjectImporter::_handle_object_start_model_xml_element ( void * userData,
const char * name,
const char ** attributes )
static
6083 {
6084 ObjectImporter* importer = (ObjectImporter*)userData;
6085 if (importer != nullptr)
6086 importer->_handle_object_start_model_xml_element(name, attributes);
6087 }

References ObjectImporter(), and _handle_object_start_model_xml_element().

Here is the call graph for this function:

◆ _handle_object_start_object()

bool Slic3r::_BBS_3MF_Importer::ObjectImporter::_handle_object_start_object ( const char ** attributes,
unsigned int num_attributes )
5717 {
5718 // reset current object data
5719 if (current_object) {
5720 delete current_object;
5721 current_object = nullptr;
5722 }
5723
5724 std::string object_type = bbs_get_attribute_value_string(attributes, num_attributes, TYPE_ATTR);
5725
5726 if (bbs_is_valid_object_type(object_type)) {
5727 if (!current_object) {
5728 current_object = new CurrentObject();
5729 }
5730
5731 current_object->id = bbs_get_attribute_value_int(attributes, num_attributes, ID_ATTR);
5732 current_object->name = bbs_get_attribute_value_string(attributes, num_attributes, NAME_ATTR);
5733
5734 current_object->uuid = bbs_get_attribute_value_string(attributes, num_attributes, PUUID_ATTR);
5735 if (current_object->uuid.empty()) {
5736 current_object->uuid = bbs_get_attribute_value_string(attributes, num_attributes, PUUID_LOWER_ATTR);
5737 }
5738 current_object->pid = bbs_get_attribute_value_int(attributes, num_attributes, PID_ATTR);
5739 }
5740
5741 return true;
5742 }
static constexpr const char * TYPE_ATTR
Definition 3mf.cpp:128
bool bbs_is_valid_object_type(const std::string &type)
Definition bbs_3mf.cpp:708
static constexpr const char * PUUID_LOWER_ATTR
Definition bbs_3mf.cpp:326
static constexpr const char * PID_ATTR
Definition bbs_3mf.cpp:324
static constexpr const char * PUUID_ATTR
Definition bbs_3mf.cpp:325

References _handle_object_start_object(), bbs_get_attribute_value_int(), bbs_get_attribute_value_string(), bbs_is_valid_object_type(), current_object, ID_ATTR, NAME_ATTR, PID_ATTR, PUUID_ATTR, PUUID_LOWER_ATTR, and TYPE_ATTR.

Referenced by _handle_object_start_model_xml_element(), and _handle_object_start_object().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _handle_object_start_resources()

bool Slic3r::_BBS_3MF_Importer::ObjectImporter::_handle_object_start_resources ( const char ** attributes,
unsigned int num_attributes )
5705 {
5706 // do nothing
5707 return true;
5708 }

References _handle_object_start_resources().

Referenced by _handle_object_start_model_xml_element(), and _handle_object_start_resources().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _handle_object_start_triangle()

bool Slic3r::_BBS_3MF_Importer::ObjectImporter::_handle_object_start_triangle ( const char ** attributes,
unsigned int num_attributes )
5900 {
5901 // we are ignoring the following attributes:
5902 // p1
5903 // p2
5904 // p3
5905 // pid
5906 // see specifications
5907
5908 // appends the triangle's vertices indices
5909 // missing values are set equal to ZERO
5910 if (current_object) {
5911 current_object->geometry.triangles.emplace_back(
5912 bbs_get_attribute_value_int(attributes, num_attributes, V1_ATTR),
5913 bbs_get_attribute_value_int(attributes, num_attributes, V2_ATTR),
5914 bbs_get_attribute_value_int(attributes, num_attributes, V3_ATTR));
5915
5916 current_object->geometry.custom_supports.push_back(bbs_get_attribute_value_string(attributes, num_attributes, CUSTOM_SUPPORTS_ATTR));
5917 current_object->geometry.custom_seam.push_back(bbs_get_attribute_value_string(attributes, num_attributes, CUSTOM_SEAM_ATTR));
5918 current_object->geometry.mmu_segmentation.push_back(bbs_get_attribute_value_string(attributes, num_attributes, MMU_SEGMENTATION_ATTR));
5919 current_object->geometry.fuzzy_skin.push_back(bbs_get_attribute_value_string(attributes, num_attributes, CUSTOM_FUZZY_SKIN_ATTR));
5920 for (int slot = 0; slot < int(TEXTURE_DISPLACEMENT_MAX_LAYERS); ++slot)
5921 if (const char *paint = bbs_get_attribute_value_charptr(attributes, num_attributes, TEXTURE_DISPLACEMENT_ATTRS[slot])) {
5922 std::vector<std::string> &mask = current_object->geometry.texture_displacement[slot];
5923 mask.resize(current_object->geometry.triangles.size());
5924 mask.back() = paint;
5925 }
5926 // BBS
5927 current_object->geometry.face_properties.push_back(bbs_get_attribute_value_string(attributes, num_attributes, FACE_PROPERTY_ATTR));
5928 }
5929 return true;
5930 }
static constexpr const char * MMU_SEGMENTATION_ATTR
Definition 3mf.cpp:142
static constexpr const char * CUSTOM_SEAM_ATTR
Definition 3mf.cpp:141
static constexpr const char * CUSTOM_SUPPORTS_ATTR
Definition 3mf.cpp:140
static constexpr const char * V3_ATTR
Definition 3mf.cpp:135
static constexpr const char * V1_ATTR
Definition 3mf.cpp:133
static constexpr const char * V2_ATTR
Definition 3mf.cpp:134
const char * bbs_get_attribute_value_charptr(const char **attributes, unsigned int attributes_size, const char *attribute_key)
Definition bbs_3mf.cpp:525
static constexpr const char * TEXTURE_DISPLACEMENT_ATTRS[Slic3r::TEXTURE_DISPLACEMENT_MAX_LAYERS]
Definition bbs_3mf.cpp:361
static constexpr const char * CUSTOM_FUZZY_SKIN_ATTR
Definition bbs_3mf.cpp:356
static constexpr const char * FACE_PROPERTY_ATTR
Definition bbs_3mf.cpp:367
static constexpr size_t TEXTURE_DISPLACEMENT_MAX_LAYERS
Definition TextureDisplacement.hpp:44

References _handle_object_start_triangle(), bbs_get_attribute_value_charptr(), bbs_get_attribute_value_int(), bbs_get_attribute_value_string(), current_object, CUSTOM_FUZZY_SKIN_ATTR, CUSTOM_SEAM_ATTR, CUSTOM_SUPPORTS_ATTR, FACE_PROPERTY_ATTR, MMU_SEGMENTATION_ATTR, TEXTURE_DISPLACEMENT_ATTRS, Slic3r::TEXTURE_DISPLACEMENT_MAX_LAYERS, V1_ATTR, V2_ATTR, and V3_ATTR.

Referenced by _handle_object_start_model_xml_element(), and _handle_object_start_triangle().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _handle_object_start_triangles()

bool Slic3r::_BBS_3MF_Importer::ObjectImporter::_handle_object_start_triangles ( const char ** attributes,
unsigned int num_attributes )
5886 {
5887 // reset current triangles
5888 if (current_object)
5889 current_object->geometry.triangles.clear();
5890 return true;
5891 }

References _handle_object_start_triangles(), and current_object.

Referenced by _handle_object_start_model_xml_element(), and _handle_object_start_triangles().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _handle_object_start_vertex()

bool Slic3r::_BBS_3MF_Importer::ObjectImporter::_handle_object_start_vertex ( const char ** attributes,
unsigned int num_attributes )
5861 {
5862 // appends the vertex coordinates
5863 // missing values are set equal to ZERO
5864 if (current_object) {
5865 const Vec3f v(object_unit_factor * bbs_get_attribute_value_float(attributes, num_attributes, X_ATTR),
5866 object_unit_factor * bbs_get_attribute_value_float(attributes, num_attributes, Y_ATTR),
5867 object_unit_factor * bbs_get_attribute_value_float(attributes, num_attributes, Z_ATTR));
5868 // See _BBS_3MF_Importer::_handle_start_vertex: a non-finite coordinate
5869 // crashed qhull while the file loaded. The dispatcher stops this parser on `false`.
5870 if (! v.allFinite()) {
5871 obj_parse_error_message = "Invalid vertex coordinate: not a finite number";
5872 return false;
5873 }
5874 current_object->geometry.vertices.emplace_back(v);
5875 }
5876 return true;
5877 }
static constexpr const char * X_ATTR
Definition 3mf.cpp:130
static constexpr const char * Y_ATTR
Definition 3mf.cpp:131
static constexpr const char * Z_ATTR
Definition 3mf.cpp:132
float bbs_get_attribute_value_float(const char **attributes, unsigned int attributes_size, const char *attribute_key)
Definition bbs_3mf.cpp:544
Eigen::Matrix< float, 3, 1, Eigen::DontAlign > Vec3f
Definition Point.hpp:65
std::string obj_parse_error_message
Definition bbs_3mf.cpp:1033

References _handle_object_start_vertex(), bbs_get_attribute_value_float(), current_object, obj_parse_error_message, object_unit_factor, X_ATTR, Y_ATTR, and Z_ATTR.

Referenced by _handle_object_start_model_xml_element(), and _handle_object_start_vertex().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _handle_object_start_vertices()

bool Slic3r::_BBS_3MF_Importer::ObjectImporter::_handle_object_start_vertices ( const char ** attributes,
unsigned int num_attributes )
5847 {
5848 // reset current vertices
5849 if (current_object)
5850 current_object->geometry.vertices.clear();
5851 return true;
5852 }

References _handle_object_start_vertices(), and current_object.

Referenced by _handle_object_start_model_xml_element(), and _handle_object_start_vertices().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _handle_object_xml_characters() [1/2]

void Slic3r::_BBS_3MF_Importer::ObjectImporter::_handle_object_xml_characters ( const XML_Char * s,
int len )
6078 {
6079 obj_curr_characters.append(s, len);
6080 }
std::string obj_curr_characters
Definition bbs_3mf.cpp:1037

References _handle_object_xml_characters(), and obj_curr_characters.

Referenced by _extract_object_from_archive(), _handle_object_xml_characters(), and _handle_object_xml_characters().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _handle_object_xml_characters() [2/2]

void XMLCALL Slic3r::_BBS_3MF_Importer::ObjectImporter::_handle_object_xml_characters ( void * userData,
const XML_Char * s,
int len )
static
6097 {
6098 ObjectImporter* importer = (ObjectImporter*)userData;
6099 if (importer != nullptr)
6100 importer->_handle_object_xml_characters(s, len);
6101 }

References ObjectImporter(), and _handle_object_xml_characters().

Here is the call graph for this function:

◆ _stop_object_xml_parser()

void Slic3r::_BBS_3MF_Importer::ObjectImporter::_stop_object_xml_parser ( const std::string & msg = std::string())
inline
1064 {
1065 assert(! obj_parse_error);
1066 assert(object_xml_parser != nullptr);
1067 obj_parse_error = true;
1068 if (! msg.empty() || obj_parse_error_message.empty()) // a handler may have set the message already
1070 XML_StopParser(object_xml_parser, false);
1071 }
bool obj_parse_error
Definition bbs_3mf.cpp:1032

References obj_parse_error, obj_parse_error_message, and object_xml_parser.

Referenced by _handle_object_end_model_xml_element(), and _handle_object_start_model_xml_element().

Here is the caller graph for this function:

◆ extract_object_model()

bool Slic3r::_BBS_3MF_Importer::ObjectImporter::extract_object_model ( )
inline
1085 {
1086 mz_zip_archive archive;
1087 mz_zip_zero_struct(&archive);
1088
1089 if (!open_zip_reader(&archive, zip_path)) {
1090 top_importer->add_error("Unable to open the zipfile "+ zip_path);
1091 return false;
1092 }
1093
1094 if (!top_importer->_extract_from_archive(archive, object_path, [this] (mz_zip_archive& archive, const mz_zip_archive_file_stat& stat) {
1095 return _extract_object_from_archive(archive, stat);
1096 }, top_importer->m_load_restore)) {
1097 std::string error_msg = std::string("Archive does not contain a valid model for ") + object_path;
1098 top_importer->add_error(error_msg);
1099
1100 close_zip_reader(&archive);
1101 return false;
1102 }
1103
1104 close_zip_reader(&archive);
1105
1106 if (obj_parse_error) {
1107 //already add_error inside
1108 //top_importer->add_error(object_parse_error_message());
1109 BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ":" << __LINE__ << boost::format(", Found error while extrace object %1%\n")%object_path;
1110 return false;
1111 }
1112 return true;
1113 }
bool open_zip_reader(mz_zip_archive *zip, const std::string &fname)
Definition miniz_extension.cpp:119
bool close_zip_reader(mz_zip_archive *zip)
Definition miniz_extension.cpp:129

References Slic3r::close_zip_reader(), obj_parse_error, object_path, Slic3r::open_zip_reader(), top_importer, and zip_path.

Here is the call graph for this function:

◆ object_parse_error()

bool Slic3r::_BBS_3MF_Importer::ObjectImporter::object_parse_error ( ) const
inline
1073{ return obj_parse_error; }

References obj_parse_error.

◆ object_parse_error_message()

const char * Slic3r::_BBS_3MF_Importer::ObjectImporter::object_parse_error_message ( ) const
inline
1074 {
1075 return obj_parse_error ?
1076 // The error was signalled by the user code, not the expat parser.
1077 (obj_parse_error_message.empty() ? "Invalid 3MF format" : obj_parse_error_message.c_str()) :
1078 // The error was signalled by the expat parser.
1079 XML_ErrorString(XML_GetErrorCode(object_xml_parser));
1080 }

References obj_parse_error, obj_parse_error_message, and object_xml_parser.

Member Data Documentation

◆ current_object

◆ is_bbl_3mf

bool Slic3r::_BBS_3MF_Importer::ObjectImporter::is_bbl_3mf { false }
1041{ false };

Referenced by _handle_object_end_metadata(), and _handle_object_end_object().

◆ obj_curr_characters

std::string Slic3r::_BBS_3MF_Importer::ObjectImporter::obj_curr_characters

◆ obj_curr_metadata_name

std::string Slic3r::_BBS_3MF_Importer::ObjectImporter::obj_curr_metadata_name

◆ obj_parse_error

bool Slic3r::_BBS_3MF_Importer::ObjectImporter::obj_parse_error { false }

◆ obj_parse_error_message

std::string Slic3r::_BBS_3MF_Importer::ObjectImporter::obj_parse_error_message

◆ object_current_color_group

int Slic3r::_BBS_3MF_Importer::ObjectImporter::object_current_color_group {-1}

◆ object_group_id_to_color

std::map<int, std::string> Slic3r::_BBS_3MF_Importer::ObjectImporter::object_group_id_to_color

◆ object_list

IdToCurrentObjectMap Slic3r::_BBS_3MF_Importer::ObjectImporter::object_list

◆ object_path

std::string Slic3r::_BBS_3MF_Importer::ObjectImporter::object_path

◆ object_unit_factor

float Slic3r::_BBS_3MF_Importer::ObjectImporter::object_unit_factor

◆ object_xml_parser

◆ top_importer

_BBS_3MF_Importer* Slic3r::_BBS_3MF_Importer::ObjectImporter::top_importer {nullptr}

◆ zip_path

std::string Slic3r::_BBS_3MF_Importer::ObjectImporter::zip_path

The documentation for this struct was generated from the following file:
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/libslic3r/Format/bbs_3mf.cpp