-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce a set of Cpp examples for the new volumetric extension #400
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #400 +/- ##
========================================
Coverage 66.09% 66.09%
========================================
Files 395 395
Lines 44642 44642
========================================
Hits 29506 29506
Misses 15136 15136 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The examples do not run on my machine due to the use of r-values in the AddLink method. Or maybe it is a lifetime issue of the shared ptr loosing references to early.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This version crashes at least on windows with msvc. AddLink(...) only works with l-values, an act issue I could not resolve.
cosNode is missing an input.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might work:
int main() {
Lib3MF::PWrapper wrapper = Lib3MF::CWrapper::loadLibrary();
auto model = wrapper->CreateModel();
auto gyroidFunction = model->AddImplicitFunction();
gyroidFunction->SetDisplayName("Gyroid");
auto input = gyroidFunction->AddInput("pos", "position", Lib3MF::eImplicitPortType::Vector);
auto sinNode = gyroidFunction->AddSinNode("sin", Lib3MF::eImplicitNodeConfiguration::VectorToVector, "Sine of Position", "group");
auto cosNode = gyroidFunction->AddCosNode("cos", Lib3MF::eImplicitNodeConfiguration::VectorToVector, "Cosine of Transformed Position", "group");
auto dotNode = gyroidFunction->AddDotNode("dot", "Dot Product", "group");
auto sinInputA = sinNode->GetInputA();
gyroidFunction->AddLink(input, sinInputA);
auto cosInputA = cosNode->GetInputA();
gyroidFunction->AddLink(input, cosInputA);
auto dotInputA = dotNode->GetInputA();
auto dotInputB = dotNode->GetInputB();
auto cosResult = cosNode->GetOutputResult();
auto sinResult = sinNode->GetOutputResult();
gyroidFunction->AddLink(cosResult, dotInputB);
gyroidFunction->AddLink(sinResult, dotInputA);
auto output = gyroidFunction->AddOutput("shape", "Signed Distance Field", Lib3MF::eImplicitPortType::Scalar);
auto dotResult = dotNode->GetOutputResult();
gyroidFunction->AddLink(dotResult, output);
auto writer = model->QueryWriter("3mf");
writer->WriteToFile("Gyroid.3mf");
std::cout << "Saved Gyroid.3mf" << std::endl;
return 0;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just created a PR to ACT for the fix: PR in ACT
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@3dJan How come the unit tests run then ? They also link to the same library right ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vijaiaeroastro The unit tests don't use the return value directly, but store the return value, a shared_ptr, in a variable. That keeps the shared_ptr alive, otherwise it would currently go out of scope without the suggested fix. The API tries to access the already stored raw pointer and fails. See also my comment in PR in ACT.
… node for thickness adjustment
…ples 3d jan/extend volumetric examples
This PR introduces the following Cpp volumetric examples to the develop branch
Creating implicit shapes- Sphere
- Torus
- Gyroid
- Cylinder
Then two additional examples
These have been build using the unit tests created by @3dJan. I can add more examples based on your suggestions.