Skip to content

Commit c9fecec

Browse files
authored
Merge pull request #55 from Ultimaker/CURA-12099_export-and-import-to-bambu-3mf
CURA-12099 export and import to bambu 3mf
2 parents 28e0e4d + 031a70a commit c9fecec

3 files changed

Lines changed: 53 additions & 1 deletion

File tree

conandata.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version: "5.10.0"
1+
version: "5.11.0-alpha.0"

include/Savitar/SceneNode.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ class SceneNode
3636
*/
3737
void fillByXMLNode(pugi::xml_node xml_node);
3838

39+
/**
40+
* Parses the (mesh) data stored in the external component file
41+
*/
42+
void parseComponentData(const std::string& xml_string);
43+
3944
/**
4045
* Get the (unique) identifier of the node.
4146
*/
@@ -69,6 +74,8 @@ class SceneNode
6974

7075
[[nodiscard]] SceneNode* getMeshNode();
7176

77+
[[nodiscard]] std::string getComponentPath() const;
78+
7279
private:
7380
std::string transformation_{ "1.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0" };
7481
std::vector<SceneNode*> children_;
@@ -77,6 +84,7 @@ class SceneNode
7784
std::string id_;
7885
std::string name_;
7986
std::string type_{ "model" };
87+
std::string component_path_;
8088

8189
// 3MF does not support having an Object that has a mesh and components.
8290
// This is solved by the concept of the "mesh" node, which is added as a child.

src/SceneNode.cpp

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ SceneNode* SceneNode::getMeshNode()
2323
return mesh_node_;
2424
}
2525

26+
std::string SceneNode::getComponentPath() const
27+
{
28+
return component_path_;
29+
}
30+
2631
std::vector<SceneNode*> SceneNode::getChildren()
2732
{
2833
return children_;
@@ -125,6 +130,45 @@ void SceneNode::fillByXMLNode(pugi::xml_node xml_node)
125130
setSetting(key, value, type, preserve);
126131
}
127132
}
133+
134+
// Read components
135+
const pugi::xml_node components_node = xml_node.child("components");
136+
if (components_node != nullptr)
137+
{
138+
for (pugi::xml_node component = components_node.child("component"); component != nullptr; component = component.next_sibling("component"))
139+
{
140+
std::string path = component.attribute("p:path").as_string();
141+
if (! path.empty())
142+
{
143+
component_path_ = path;
144+
}
145+
146+
std::string transformation = component.attribute("transform").as_string();
147+
if (! transformation.empty())
148+
{
149+
transformation_ = transformation;
150+
}
151+
}
152+
}
153+
}
154+
155+
void SceneNode::parseComponentData(const std::string& xml_string)
156+
{
157+
pugi::xml_document document;
158+
document.load_string(xml_string.c_str());
159+
160+
pugi::xml_node xml_node = document;
161+
for (const std::string child_name : {"model", "resources", "object", "mesh"})
162+
{
163+
xml_node = xml_node.child(child_name.c_str());
164+
if (xml_node == nullptr)
165+
{
166+
return;
167+
}
168+
}
169+
170+
mesh_data_.clear();
171+
mesh_data_.fillByXMLNode(xml_node);
128172
}
129173

130174
std::string SceneNode::getId()

0 commit comments

Comments
 (0)