Skip to content

Commit

Permalink
Updating example files
Browse files Browse the repository at this point in the history
  • Loading branch information
3dJan committed Oct 16, 2024
1 parent 0e27e96 commit a23ad7a
Show file tree
Hide file tree
Showing 17 changed files with 56 additions and 18 deletions.
Binary file modified gladius/examples/implicit/3mf-implicit.3mf
Binary file not shown.
Binary file modified gladius/examples/implicit/RadialRadiator.3mf
Binary file not shown.
Binary file modified gladius/examples/implicit/SphereInACage.3mf
Binary file not shown.
Binary file modified gladius/examples/implicit/keyboard/2x_tpu_attachablefoot.3mf
Binary file not shown.
Binary file modified gladius/examples/implicit/keyboard/2x_tpu_bottomcover.3mf
Binary file not shown.
Binary file modified gladius/examples/implicit/keyboard/2x_tpu_pla_jogwheel_color.3mf
Binary file not shown.
Binary file modified gladius/examples/implicit/keyboard/2x_wing.3mf
Binary file not shown.
Binary file modified gladius/examples/implicit/keyboard/2xmirrored_honeycombecase.3mf
Binary file not shown.
Binary file modified gladius/examples/template.3mf
Binary file not shown.
2 changes: 2 additions & 0 deletions gladius/src/Document.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ namespace gladius
[[nodiscard]] nodes::BuildItems const & getBuildItems() const;

void replaceMeshResource(ResourceKey const & key, SharedMesh mesh);

void deleteFunction(ResourceId id);
private:
[[nodiscard]] nodes::VariantParameter &
findParameterOrThrow(ResourceId modelId,
Expand Down
2 changes: 1 addition & 1 deletion gladius/src/io/3mf/Importer3mf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ namespace gladius::io
if (!resourceNode3mf)
{
throw std::runtime_error(
fmt::format("Could not cast node {} to ResourceIdNode", node->getUniqueName()));
fmt::format("Could not cast node {} to ResourceIdNode", node3mf.GetIdentifier()));
}
auto resourceNode = dynamic_cast<nodes::Resource *>(&*node);
if (!resourceNode)
Expand Down
19 changes: 13 additions & 6 deletions gladius/src/io/3mf/Writer3mf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ namespace gladius::io
{
return Lib3MF::eImplicitPortType::Matrix;
}
else if ((typeIndex == gladius::nodes::ParameterTypeIndex::ResourceId) || (typeIndex == typeid(int)))
else if ((typeIndex == gladius::nodes::ParameterTypeIndex::ResourceId) ||
(typeIndex == typeid(int)))
{
return Lib3MF::eImplicitPortType::ResourceID;
}
Expand Down Expand Up @@ -282,7 +283,7 @@ namespace gladius::io
node.getUniqueName(), node.getDisplayName(), node.getTag());

initNode(node, functioncallNode);

auto & funcIdParam = node.parameter().at(nodes::FieldNames::FunctionId);
if (!funcIdParam.getSource().has_value())
{
Expand Down Expand Up @@ -336,14 +337,18 @@ namespace gladius::io
throw std::runtime_error(fmt::format(
"Could not add input {} to node {}", portName, node.getUniqueName()));
}
try
try
{
input3mf->SetType(convertPortType(input.getTypeIndex()));
}
catch (std::exception & e)
{
throw std::runtime_error(fmt::format(
"Could not set type of input {} of node {}: {}\t typeindex:{}", portName, node.getUniqueName(), e.what(), input.getTypeIndex().name()));
throw std::runtime_error(
fmt::format("Could not set type of input {} of node {}: {}\t typeindex:{}",
portName,
node.getUniqueName(),
e.what(),
input.getTypeIndex().name()));
}
}

Expand Down Expand Up @@ -544,6 +549,7 @@ namespace gladius::io
return;
}


for (auto & [name, model] : doc.getAssembly()->getFunctions())
{
if (model->isManaged())
Expand All @@ -560,7 +566,8 @@ namespace gladius::io
}
else
{
addFunctionTo3mf(*model, model3mf);
throw std::runtime_error("Function not found in 3mf model");
// addFunctionTo3mf(*model, model3mf);
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions gladius/src/nodes/Assembly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ namespace gladius::nodes
return;
}
m_subModels.erase(modelToDeleteIter);


}

bool Assembly::equals(Assembly const & other)
Expand Down
34 changes: 29 additions & 5 deletions gladius/src/nodes/Validator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace gladius::nodes
m_errors.clear();
for (auto & [name, function] : assembly.getFunctions())
{
validateModel(*function);
validateModel(*function, assembly);
}
return m_errors.empty();
}
Expand All @@ -18,7 +18,7 @@ namespace gladius::nodes
return m_errors;
}

void Validator::validateModel(Model & model)
void Validator::validateModel(Model & model, Assembly & assembly)
{
model.updateGraphAndOrderIfNeeded();
model.updateTypes();
Expand All @@ -36,13 +36,18 @@ namespace gladius::nodes

for (auto & [nodeId, node] : model)
{
validateNode(*node, model);
validateNode(*node, model, assembly);
}
}

void Validator::validateNode(NodeBase & node, Model & model)
void Validator::validateNode(NodeBase & node, Model & model, Assembly & assembly)
{
for (auto & [parameterName, parameter] : node.parameter())
validateNodeImpl(node, model);
}

void Validator::validateNodeImpl(NodeBase & node, Model & model)
{
for (auto & [parameterName, parameter] : node.parameter())
{
if (!parameter.getConstSource().has_value() && parameter.isInputSourceRequired())
{
Expand Down Expand Up @@ -87,4 +92,23 @@ namespace gladius::nodes
}
}
}

void Validator::validateNode(FunctionCall & node, Model & model, Assembly & assembly)
{
validateNodeImpl(node, model);
node.resolveFunctionId();
auto referencedId = node.getFunctionId();
auto referencedModel = assembly.findModel(referencedId);
if (!referencedModel)
{
m_errors.push_back(ValidationError{"Function reference not found",
model.getDisplayName().value_or("unknown"),
node.getDisplayName(),
"unknown",
"FunctionId"});
model.setIsValid(false);
}


}
}
8 changes: 6 additions & 2 deletions gladius/src/nodes/Validator.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "Assembly.h"
#include "Parameter.h"
#include "nodesfwd.h"

namespace gladius::nodes
{
Expand All @@ -27,8 +28,11 @@ namespace gladius::nodes
[[nodiscard]] ValidationErrors const & getErrors() const;

private:
void validateModel(Model & model);
void validateNode(NodeBase & node, Model & model);
void validateModel(Model & model, Assembly & assembly);
void validateNode(NodeBase & node, Model & model, Assembly & assembly);
void validateNodeImpl(NodeBase & node, Model & model);

void validateNode(FunctionCall & node, Model & model, Assembly & assembly);
ValidationErrors m_errors;
};
}
3 changes: 1 addition & 2 deletions gladius/src/ui/ModelEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,7 @@ namespace gladius::ui
if (ImGui::MenuItem(
reinterpret_cast<const char *>(ICON_FA_MINUS "\tDelete Function")))
{

m_assembly->deleteModel(m_currentModel->getResourceId());
m_doc->deleteFunction(m_currentModel->getResourceId());
m_currentModel = m_assembly->assemblyModel();
m_dirty = true;
}
Expand Down
4 changes: 2 additions & 2 deletions gladius/vcpkg-overlay-ports/lib3mf/portfile.cmake
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO 3MFConsortium/lib3mf
REF 80ecd20460f4b951cb0c0f6f35c2cbfd5466384d
SHA512 778c455badde41092ca4b4e5e9788ce2e6fd05998927c23c21ac010bc09857bb8659c72cdd67a8c149adcb355d155b264ca39f6ac061745f12c6065f8a495261
REF a12a270f79ebf1b04d2d03fa8b49e1aa8061aa56
SHA512 99d30bd6babf0670994927c2162fdb31b11f2568a9b26d0305592dffa193f2a08f9dbc7bd80188288f090c6bedc1aa7da4640c019c545bfd93bfbc49fdb70953
HEAD_REF implicit
)

Expand Down

0 comments on commit a23ad7a

Please sign in to comment.