-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Include first set of volumetric examples
- Loading branch information
1 parent
2c008ec
commit beaa92c
Showing
18 changed files
with
213 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include "lib3mf_implicit.hpp" | ||
#include <iostream> | ||
|
||
int main() { | ||
Lib3MF::PWrapper wrapper = Lib3MF::CWrapper::loadLibrary(); | ||
auto model = wrapper->CreateModel(); | ||
|
||
auto funcA = model->AddImplicitFunction(); | ||
auto funcB = model->AddImplicitFunction(); | ||
funcA->SetDisplayName("FunctionA"); | ||
funcB->SetDisplayName("FunctionB"); | ||
|
||
auto inputA = funcA->AddInput("x", "Position X", Lib3MF::eImplicitPortType::Scalar); | ||
auto sinNode = funcA->AddSinNode("sinA", Lib3MF::eImplicitNodeConfiguration::ScalarToScalar, "Sine Node", "group"); | ||
funcA->AddLink(inputA, sinNode->GetInputA()); | ||
funcA->AddOutput("outputA", "Output A", Lib3MF::eImplicitPortType::Scalar); | ||
|
||
auto inputB = funcB->AddInput("y", "Position Y", Lib3MF::eImplicitPortType::Scalar); | ||
auto cosNode = funcB->AddCosNode("cosB", Lib3MF::eImplicitNodeConfiguration::ScalarToScalar, "Cosine Node", "group"); | ||
funcB->AddLink(inputB, cosNode->GetInputA()); | ||
funcB->AddOutput("outputB", "Output B", Lib3MF::eImplicitPortType::Scalar); | ||
|
||
auto writer = model->QueryWriter("3mf"); | ||
writer->WriteToFile("CombinedFunctions.3mf"); | ||
|
||
std::cout << "Saved CombinedFunctions.3mf" << std::endl; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include "lib3mf_implicit.hpp" | ||
#include <iostream> | ||
|
||
int main() { | ||
Lib3MF::PWrapper wrapper = Lib3MF::CWrapper::loadLibrary(); | ||
auto model = wrapper->CreateModel(); | ||
|
||
auto newFunction = model->AddImplicitFunction(); | ||
newFunction->SetDisplayName("Cylinder"); | ||
|
||
auto input = newFunction->AddInput("pos", "Position", Lib3MF::eImplicitPortType::Vector); | ||
auto cylinderNode = newFunction->AddLengthNode("cylinderNode", "Length", "group"); | ||
newFunction->AddLink(input, cylinderNode->GetInputA()); | ||
|
||
auto output = newFunction->AddOutput("shape", "Cylinder Shape", Lib3MF::eImplicitPortType::Scalar); | ||
newFunction->AddLink(cylinderNode->GetOutputResult(), output); | ||
|
||
auto writer = model->QueryWriter("3mf"); | ||
writer->WriteToFile("Cylinder.3mf"); | ||
|
||
std::cout << "Saved Cylinder.3mf" << std::endl; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include "lib3mf_implicit.hpp" | ||
#include <iostream> | ||
|
||
int main() { | ||
Lib3MF::PWrapper wrapper = Lib3MF::CWrapper::loadLibrary(); | ||
auto model = wrapper->CreateModel(); | ||
|
||
auto newFunction = model->AddImplicitFunction(); | ||
newFunction->SetDisplayName("Sphere"); | ||
|
||
auto input = newFunction->AddInput("pos", "position", Lib3MF::eImplicitPortType::Vector); | ||
auto constantNode = newFunction->AddConstantNode("radius", "Sphere Radius", "group"); | ||
constantNode->SetConstant(15.0); | ||
|
||
auto lengthNode = newFunction->AddLengthNode("distance", "Distance to sphere", "group"); | ||
newFunction->AddLink(input, lengthNode->GetInputA()); | ||
|
||
auto subtractNode = newFunction->AddSubtractionNode("offset", Lib3MF::eImplicitNodeConfiguration::ScalarToScalar, "Offset Radius", "group"); | ||
newFunction->AddLink(lengthNode->GetOutputResult(), subtractNode->GetInputA()); | ||
newFunction->AddLink(constantNode->GetOutputValue(), subtractNode->GetInputB()); | ||
|
||
auto output = newFunction->AddOutput("shape", "Signed Distance Field", Lib3MF::eImplicitPortType::Scalar); | ||
newFunction->AddLink(subtractNode->GetOutputResult(), output); | ||
|
||
auto writer = model->QueryWriter("3mf"); | ||
writer->WriteToFile("ImplicitSphere.3mf"); | ||
|
||
std::cout << "Saved ImplicitSphere.3mf" << std::endl; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include "lib3mf_implicit.hpp" | ||
#include <iostream> | ||
|
||
int main() { | ||
Lib3MF::PWrapper wrapper = Lib3MF::CWrapper::loadLibrary(); | ||
auto model = wrapper->CreateModel(); | ||
|
||
auto torusFunction = model->AddImplicitFunction(); | ||
torusFunction->SetDisplayName("Torus"); | ||
|
||
auto input = torusFunction->AddInput("pos", "Position", Lib3MF::eImplicitPortType::Vector); | ||
auto lengthNode = torusFunction->AddLengthNode("length", "Length", "group"); | ||
torusFunction->AddLink(input, lengthNode->GetInputA()); | ||
|
||
auto radiusNode = torusFunction->AddConstantNode("radius", "Radius", "group"); | ||
radiusNode->SetConstant(10.0); | ||
|
||
auto subtractNode = torusFunction->AddSubtractionNode("subtract", Lib3MF::eImplicitNodeConfiguration::ScalarToScalar, "Subtract Radius", "group"); | ||
torusFunction->AddLink(lengthNode->GetOutputResult(), subtractNode->GetInputA()); | ||
torusFunction->AddLink(radiusNode->GetOutputValue(), subtractNode->GetInputB()); | ||
|
||
auto output = torusFunction->AddOutput("shape", "Torus Shape", Lib3MF::eImplicitPortType::Scalar); | ||
torusFunction->AddLink(subtractNode->GetOutputResult(), output); | ||
|
||
auto writer = model->QueryWriter("3mf"); | ||
writer->WriteToFile("Torus.3mf"); | ||
|
||
std::cout << "Saved Torus.3mf" << std::endl; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include "lib3mf_implicit.hpp" | ||
#include <iostream> | ||
|
||
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"); | ||
gyroidFunction->AddLink(input, sinNode->GetInputA()); | ||
gyroidFunction->AddLink(cosNode->GetOutputResult(), dotNode->GetInputB()); | ||
gyroidFunction->AddLink(sinNode->GetOutputResult(), dotNode->GetInputA()); | ||
|
||
auto output = gyroidFunction->AddOutput("shape", "Signed Distance Field", Lib3MF::eImplicitPortType::Scalar); | ||
gyroidFunction->AddLink(dotNode->GetOutputResult(), output); | ||
|
||
auto writer = model->QueryWriter("3mf"); | ||
writer->WriteToFile("Gyroid.3mf"); | ||
|
||
std::cout << "Saved Gyroid.3mf" << std::endl; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#include "lib3mf_implicit.hpp" | ||
#include <iostream> | ||
#include <filesystem> | ||
|
||
int main() { | ||
Lib3MF::PWrapper wrapper = Lib3MF::CWrapper::loadLibrary(); | ||
auto model = wrapper->CreateModel(); | ||
|
||
constexpr int layers = 11; | ||
|
||
auto pImageStack = model->AddImageStack(821, 819, layers); | ||
|
||
// Resolve the path to the volumetricImages folder relative to the source file | ||
std::string sVolumeImagesFolder = VOLUME_IMAGES_PATH; | ||
std::filesystem::path sourceDir(sVolumeImagesFolder); | ||
sourceDir = std::filesystem::canonical(sourceDir); | ||
|
||
if (!std::filesystem::exists(sourceDir)) { | ||
std::cerr << "Error: Base folder not found - " << sourceDir << "\n"; | ||
return 1; | ||
} | ||
|
||
for (int i = 0; i < layers; ++i) { | ||
std::string sNumber = "_"; | ||
if (i + 1 < 10) sNumber += "0"; | ||
sNumber += std::to_string(i + 1); | ||
|
||
std::string internalPath = "/volume/layer" + sNumber + ".png"; | ||
std::filesystem::path filePath = sourceDir / ("img" + sNumber + ".png"); | ||
|
||
if (!std::filesystem::exists(filePath)) { | ||
std::cerr << "Error: File not found - " << filePath << "\n"; | ||
return 1; | ||
} | ||
|
||
pImageStack->CreateSheetFromFile(i, internalPath, filePath.string()); | ||
} | ||
|
||
// Set up a function from the image stack | ||
auto funcFromImageStack = model->AddFunctionFromImage3D(pImageStack.get()); | ||
funcFromImageStack->SetDisplayName("Function from Image Stack"); | ||
|
||
// Example of setting tile styles (can be customized) | ||
funcFromImageStack->SetTileStyles( | ||
Lib3MF::eTextureTileStyle::Wrap, | ||
Lib3MF::eTextureTileStyle::Clamp, | ||
Lib3MF::eTextureTileStyle::Mirror); | ||
|
||
auto writer = model->QueryWriter("3mf"); | ||
writer->WriteToFile("ImageStack.3mf"); | ||
|
||
std::cout << "Saved ImageStack.3mf\n"; | ||
return 0; | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.