### Install Python dependencies and run exported samples Source: https://github.com/weianweigan/manifold-csharp/blob/dev-csharp/README.md Install Python dependencies and run the exported samples for the python binding. Requires pkg-config, libpython3-dev, python3, python3-distutils, and python3-pip, then installs trimesh and pytest before running run_all.py with the -e flag. ```bash sudo apt install pkg-config libpython3-dev python3 python3-distutils python3-pip pip install trimesh pytest python3 run_all.py -e ``` -------------------------------- ### Install and test JS bindings Source: https://github.com/weianweigan/manifold-csharp/blob/dev-csharp/bindings/wasm/examples/README.md Install dependencies and run the test suite for the WASM/JS bindings from the bindings/wasm/examples/ directory. ```bash npm install npm test ``` -------------------------------- ### Run development server Source: https://github.com/weianweigan/manifold-csharp/blob/dev-csharp/bindings/wasm/examples/README.md Serve the example pages, watch for changes, and automatically rebuild and refresh. This build step does not do TS type-checking. ```bash npm run dev ``` -------------------------------- ### Verify Python docs with pip install and help Source: https://github.com/weianweigan/manifold-csharp/blob/dev-csharp/bindings/python/README.md Run from the manifold repo root to install the package and display the Python API help. Confirms that the autogenerated doc-strings are correct. ```bash pip install . python -c 'import manifold3d; help(manifold3d)' ``` -------------------------------- ### Configure vcpkg and install assimp Source: https://github.com/weianweigan/manifold-csharp/blob/dev-csharp/bindings/csharp/Build.md Configures vcpkg for the Windows-MeshExport build, installing the assimp dependency. Sets VCPKG_ROOT and PATH environment variables. ```shell git clone https://github.com/microsoft/vcpkg.git cd vcpkg; .\bootstrap-vcpkg.bat $path = (Get-Location).Path $env:VCPKG_ROOT = "$path\vcpkg" $env:PATH = "$env:VCPKG_ROOT;$env:PATH" vcpkg install assimp ``` -------------------------------- ### Install ManifoldNET.Notebooks package Source: https://github.com/weianweigan/manifold-csharp/blob/dev-csharp/bindings/csharp/ManifoldNET.Notebooks/Readme.md Adds the ManifoldNET.Notebooks NuGet package (version 1.0.4-alpha) to the notebook. Required before using the library. ```csharp #r "nuget: ManifoldNET.Notebooks, 1.0.4-alpha" ``` -------------------------------- ### Generate stubs with nanobind-stubgen Source: https://github.com/weianweigan/manifold-csharp/blob/dev-csharp/bindings/python/README.md Install nanobind-stubgen and the package, then generate a manifold3d.pyi stub file. Emits warnings and writes the stub showing function signatures and docstrings. ```bash pip install nanobind-stubgen pip install . nanobind-stubgen manifold3d ``` -------------------------------- ### Set up emscripten on Linux for WASM build Source: https://github.com/weianweigan/manifold-csharp/blob/dev-csharp/README.md Install NodeJS and set up emscripten on Linux using the emsdk. This prepares the environment for building the JS WASM library. ```bash sudo apt install nodejs git clone https://github.com/emscripten-core/emsdk.git cd emsdk ./emsdk install latest ./emsdk activate latest source ./emsdk/emsdk_env.sh ``` -------------------------------- ### Configure Windows build with CMake Source: https://github.com/weianweigan/manifold-csharp/blob/dev-csharp/README.md Example CMake command for Windows builds. Uses -DBUILD_SHARED_LIBS=OFF as recommended for Windows. The resulting manifoldc.dll is located at build/bin/Release/manifoldc.dll relative to the project root. ```sh cmake . -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DMANIFOLD_DEBUG=ON -DMANIFOLD_PAR=${{matrix.parallel_backend}} -A x64 -B build ``` -------------------------------- ### Build Windows-MeshExport Release with CMake Source: https://github.com/weianweigan/manifold-csharp/blob/dev-csharp/bindings/csharp/Build.md Builds the manifold C# bindings for Windows with mesh export enabled (MANIFOLD_EXPORT=ON) in Release configuration. Requires vcpkg and assimp installed. Produces manifoldc.dll in \build\bin\Release. ```shell cmake . -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DMANIFOLD_DEBUG=ON -DMANIFOLD_PAR=NONE -DMANIFOLD_EXPORT=ON -DCMAKE_PREFIX_PATH=${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/installed/x64-windows/share -A x64 -B build cd build cmake --build . --target ALL_BUILD --config Release ``` -------------------------------- ### Build Windows-MeshExport Debug with CMake Source: https://github.com/weianweigan/manifold-csharp/blob/dev-csharp/bindings/csharp/Build.md Builds the manifold C# bindings for Windows with mesh export enabled (MANIFOLD_EXPORT=ON) in Debug configuration. Requires vcpkg and assimp installed. Produces manifoldc.dll in \build\bin\Debug. ```shell cmake . -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=OFF -DMANIFOLD_DEBUG=ON -DMANIFOLD_PAR=NONE -DMANIFOLD_EXPORT=ON -DCMAKE_PREFIX_PATH=${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/installed/x64-windows/share -A x64 -B build cd build cmake --build . --target ALL_BUILD --config Debug ``` -------------------------------- ### Build and test WASM library with emscripten Source: https://github.com/weianweigan/manifold-csharp/blob/dev-csharp/README.md Build the JS WASM library after installing NodeJS and emscripten. Uses emcmake and emmake to configure and compile, then runs the JavaScript test file. ```bash cd manifold mkdir buildWASM cd buildWASM emcmake cmake -DCMAKE_BUILD_TYPE=Release .. && emmake make node test/manifold_test.js ``` -------------------------------- ### Install emscripten on macOS for WASM build Source: https://github.com/weianweigan/manifold-csharp/blob/dev-csharp/README.md Install NodeJS and emscripten on macOS to prepare for building the JS WASM library. Only emscripten version 3.1.45 has been tested; 3.1.48 is known to have compilation issues. ```bash brew install nodejs brew install emscripten ``` -------------------------------- ### Build project Source: https://github.com/weianweigan/manifold-csharp/blob/dev-csharp/bindings/wasm/examples/README.md Build the project to verify everything is correct beyond VSCode's TS linting. ```bash npm run build ``` -------------------------------- ### Output of package reference Source: https://github.com/weianweigan/manifold-csharp/blob/dev-csharp/bindings/csharp/ManifoldNotebooksExtension.ipynb Confirms the package was loaded by showing the loading script for the interactive extensions. ```text Result: Loading extension script from `C:\Users\18311\.nuget\packages\manifoldnet.notebooks\1.0.0-alpha\interactive-extensions\dotnet\extension.dib` ``` -------------------------------- ### Create and export a cube as GLB Source: https://github.com/weianweigan/manifold-csharp/blob/dev-csharp/bindings/csharp/ManifoldNotebooksExtension.ipynb Creates a unit cube via Manifold.Cube(1,1,1), exports it to cube.glb using ExportMeshGL, and displays it in the notebook with the #!glb magic command. ```csharp var cube = Manifold.Cube(1,1,1); cube.MeshGL.ExportMeshGL("cube.glb"); #!glb -f cube.glb ``` -------------------------------- ### Check for built NuGet package and define NuGet source Source: https://github.com/weianweigan/manifold-csharp/blob/dev-csharp/bindings/csharp/ManifoldNotebooksExtension.ipynb Uses System.IO to find the built .nupkg file in the Debug_MeshExport folder and prints a success or failure message. Then constructs a NuGet source string pointing to the folder. ```csharp using System.IO; // Create an absolute path since #i doesn't like var debugOutputFolder = new DirectoryInfo(@".\ManifoldNET.Notebooks\bin\Release_MeshExport\").FullName; var file = Directory.GetFiles(debugOutputFolder, "ManifoldNET.Notebooks*.nupkg").FirstOrDefault(); if (File.Exists(file)) { "✅ The package is there!".Display(); } else { "❌ Something must have gone wrong with the build. The package isn't there.".Display(); } var nugetSource = $"nuget:{debugOutputFolder}"; ``` -------------------------------- ### Create and display a sphere with Manifold.Sphere Source: https://github.com/weianweigan/manifold-csharp/blob/dev-csharp/bindings/csharp/notebooks/01.GetStarted.ipynb Creates a sphere with radius 0.6 and 100 segments, then displays it in the notebook. ```python var sphere = Manifold.Sphere(0.6f, 100); sphere ``` -------------------------------- ### Build output of ManifoldNET.Notebooks Source: https://github.com/weianweigan/manifold-csharp/blob/dev-csharp/bindings/csharp/ManifoldNotebooksExtension.ipynb Shows the console output and directory listings after a successful build. The build produces ManifoldNET.Notebooks.1.0.0-alpha.nupkg and ManifoldNET.Notebooks.1.0.0.nupkg in the Release_MeshExport folder. ```text Output: Determining projects to restore... 所有项目均是最新的,无法还原。 ManifoldNET -> C:\Users\18311\source\repos\manifold-csharp\bindings\csharp\ManifoldNET\bin\Release_MeshExport\net8.0\ManifoldNET.dll ManifoldNET.Notebooks -> C:\Users\18311\source\repos\manifold-csharp\bindings\csharp\ManifoldNET.Notebooks\bin\Release_MeshExport\net8.0\ManifoldNET.Notebooks.dll 包 ManifoldNET.Notebooks.1.0.0-alpha 缺少自述文件。转到 https://aka.ms/nuget/authoring-best-practices/readme 了解为什么包阅读主题很重要。 已成功创建包“C:\Users\18311\source\repos\manifold-csharp\bindings\csharp\ManifoldNET.Notebooks\bin\Release_MeshExport\ManifoldNET.Notebooks.1.0.0-alpha.nupkg”。 已成功生成。 0 个警告 0 个错误 已用时间 00:00:01.18 Directory: C:\Users\18311\source\repos\manifold-csharp\bindings\csharp\ManifoldNET.Notebooks\bi n\Debug Mode  LastWriteTime Length Name ----   ------------- ------ ---- -a--- 2024/8/15 11:34 5843 ManifoldNET.Notebooks.1.0.0-alpha.nupkg Directory: C:\Users\18311\source\repos\manifold-csharp\bindings\csharp\ManifoldNET.Notebooks\bi n\Debug_MeshExport Mode  LastWriteTime Length Name ----   ------------- ------ ---- -a--- 2024/8/15 10:52 6394 ManifoldNET.Notebooks.1.0.0-alpha.nupkg Directory: C:\Users\18311\source\repos\manifold-csharp\bindings\csharp\ManifoldNET.Notebooks\bi n\Release Mode  LastWriteTime Length Name ----   ------------- ------ ---- -a--- 2024/8/15 11:32 5731 ManifoldNET.Notebooks.1.0.0-alpha.nupkg Directory: C:\Users\18311\source\repos\manifold-csharp\bindings\csharp\ManifoldNET.Notebooks\bi n\Release_MeshExport Mode  LastWriteTime Length Name ----   ------------- ------ ---- -a--- 2024/8/15 11:52 7078 ManifoldNET.Notebooks.1.0.0-alpha.nupkg -a--- 2024/8/15 11:01 6427 ManifoldNET.Notebooks.1.0.0.nupkg ``` -------------------------------- ### Build Windows Release with CMake Source: https://github.com/weianweigan/manifold-csharp/blob/dev-csharp/bindings/csharp/Build.md Builds the manifold C# bindings for Windows in Release configuration. Produces the manifoldc.dll in \build\bin\Release. ```shell cmake . -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DMANIFOLD_DEBUG=ON -DMANIFOLD_PAR=NONE -A x64 -B build cd build cmake --build . --target ALL_BUILD --config Release ``` -------------------------------- ### Build and test manifold with CMake Source: https://github.com/weianweigan/manifold-csharp/blob/dev-csharp/README.md Build and test the library on Ubuntu or similar systems. Requires CMake, a C++ compiler, and Python. The command clones the repository with submodules, configures a Release build with shared libraries, compiles, and runs the test binary. ```bash git clone --recurse-submodules https://github.com/elalish/manifold.git cd manifold mkdir build cd build cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON .. && make test/manifold_test ``` -------------------------------- ### Reference the ManifoldNET.Notebooks package Source: https://github.com/weianweigan/manifold-csharp/blob/dev-csharp/bindings/csharp/ManifoldNotebooksExtension.ipynb References the built ManifoldNET.Notebooks package version 1.0.0-alpha in the notebook. ```csharp #r "nuget:ManifoldNET.Notebooks, 1.0.0-alpha" ``` -------------------------------- ### Add ManifoldNET.MeshIO NuGet package Source: https://github.com/weianweigan/manifold-csharp/blob/dev-csharp/bindings/csharp/Readme.md Command to add the ManifoldNET.MeshIO package, which supports exporting glb files. ```bash dotnet add package ManifoldNET.MeshIO ``` -------------------------------- ### Execute Run and display result Source: https://github.com/weianweigan/manifold-csharp/blob/dev-csharp/bindings/csharp/notebooks/04.CubeWithDents.ipynb Calls the Run function with default parameters and displays the resulting manifold. The output is a 3D visualization of the cube with dents. ```python var result = Run(); result ``` -------------------------------- ### Define brick-building methods Source: https://github.com/weianweigan/manifold-csharp/blob/dev-csharp/bindings/csharp/notebooks/05.Bricks.ipynb Defines methods to create bricks, rows, walls, and floors using ManifoldNET. Includes Brack, HalfBrick, Row, Walls, Floor, and Wall methods. ```python // Next, define some methods for creating basic elements. using ManifoldNET; public static Manifold Brack() => Manifold.Cube(BrickLength, BrickDepth, BrickHeight); public static Manifold HalfBrick() => Manifold.Cube((BrickLength - MortarGap) / 2f, BrickDepth, BrickHeight); public static Manifold Row(int length) { var items = new List(length); for (int i = 0; i < length; i++) { items.Add(Brack().Translate((BrickLength + MortarGap) * i, 0, 0)); } return items.Aggregate(Manifold.Union); } public static Manifold Walls(int length, int width, int height) { return ( (Manifold[])( [ Wall(length, width), Wall(width, height, 1).Rotate(0f, 0f, 90f).Translate(BrickDepth, 0, 0), Wall(length, height, 1).Translate(0f, (width) * (BrickLength + MortarGap), 0), Wall(width, height) .Rotate(0f, 0f, 90f) .Translate((length + 0.5f) * (BrickLength + MortarGap) - MortarGap, 0f, 0f) ] ) ).Aggregate(Manifold.Union); } public static Manifold Floor(int length, int width) { List results = [Walls(length, width, 1)]; if (length > 1 && width > 1) { results.Add( Floor(length - 1, width - 1) .Translate(BrickDepth + MortarGap, BrickDepth + MortarGap, 0) ); } if (length == 1 && width > 1) { results.Add(Row(width - 1).Rotate(0f, 0f, 90f)); } if (width == 1 && length > 1) { results.Add( Row(length - 1).Translate(2 * (BrickDepth + MortarGap), BrickDepth + MortarGap, 0) ); } results.Add(HalfBrick().Translate(BrickDepth + MortarGap, BrickDepth + MortarGap, 0)); return results.Aggregate(Manifold.Union); } public static Manifold Wall(int length, int height, int alternate = 0) { var items = new List(length * height); for (int i = 0; i < height; i++) { items.Add( Row(length) .Translate( ((i + alternate) % 2) * (BrickDepth + MortarGap), 0, (BrickHeight + MortarGap) * i ) ); } return items.Aggregate(Manifold.Union); } ``` -------------------------------- ### Execute Run() to generate Gyroid module Source: https://github.com/weianweigan/manifold-csharp/blob/dev-csharp/bindings/csharp/notebooks/06.GyroidModule.ipynb Invokes the `Run` method to generate the Gyroid module manifold. This is the entry point for producing the 3D model in the notebook. ```python Run() ``` -------------------------------- ### Create a cube geometry Source: https://github.com/weianweigan/manifold-csharp/blob/dev-csharp/bindings/csharp/ManifoldNET.Notebooks/Readme.md Creates a cube with side length 1, centered at the origin (center=true). ```csharp Manifold.Cube(1, 1, 1, true); ``` -------------------------------- ### Build ManifoldNET.Notebooks and clear NuGet cache Source: https://github.com/weianweigan/manifold-csharp/blob/dev-csharp/bindings/csharp/ManifoldNotebooksExtension.ipynb Builds the ManifoldNET.Notebooks project in Release_MeshExport configuration. Removes any older versions of the package from the NuGet cache, then lists the generated .nupkg files to confirm the build succeeded. ```powershell # 1. Build the project dotnet build ManifoldNET.Notebooks -c Release_MeshExport # Clear any older versions of this extension package from your NuGet cache rm ~/.nuget/packages/ManifoldNET.Notebooks -Force -Recurse -ErrorAction Ignore # 3. Check that the package is there Get-ChildItem -Recurse ManifoldNET.Notebooks*.nupkg ``` -------------------------------- ### Add NuGet source to notebook Source: https://github.com/weianweigan/manifold-csharp/blob/dev-csharp/bindings/csharp/ManifoldNotebooksExtension.ipynb Uses the #i directive to add the local NuGet folder as a package source for the notebook session. ```csharp #i @csharp:nugetSource ``` -------------------------------- ### Result of package check Source: https://github.com/weianweigan/manifold-csharp/blob/dev-csharp/bindings/csharp/ManifoldNotebooksExtension.ipynb Displays the output from the package existence check: the package is present. ```text Result: ✅ The package is there! ``` -------------------------------- ### Display the cube in the notebook Source: https://github.com/weianweigan/manifold-csharp/blob/dev-csharp/bindings/csharp/notebooks/01.GetStarted.ipynb Displays the cube mesh in the notebook for visualization. ```python cube ``` -------------------------------- ### Add ManifoldNET.Notebooks NuGet package Source: https://github.com/weianweigan/manifold-csharp/blob/dev-csharp/bindings/csharp/notebooks/02.Extrude.ipynb Adds the ManifoldNET.Notebooks NuGet package with a wildcard version. The output shows the loading of the extension script from the package cache. ```python #r "nuget: ManifoldNET.Notebooks, *-*" ``` -------------------------------- ### Build Windows Debug with CMake Source: https://github.com/weianweigan/manifold-csharp/blob/dev-csharp/bindings/csharp/Build.md Builds the manifold C# bindings for Windows in Debug configuration. Produces the manifoldc.dll in \build\bin\Debug. ```shell cmake . -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=OFF -DMANIFOLD_DEBUG=ON -DMANIFOLD_PAR=NONE -A x64 -B build cd build cmake --build . --target ALL_BUILD --config Debug ``` -------------------------------- ### Create a cube with ManifoldNET Source: https://github.com/weianweigan/manifold-csharp/blob/dev-csharp/bindings/csharp/Readme.md C# code to create a cube manifold using the Manifold.Cube method. ```csharp using ManifoldNET; Manifold cube = Manifold.Cube(1, 1, 1, true); ``` -------------------------------- ### Run and minimize fuzzer testcase Source: https://github.com/weianweigan/manifold-csharp/blob/dev-csharp/README.md Runs the fuzzer and minimizes the testcase for the triangulator. Requires clang compiler, Linux, and the MANIFOLD_FUZZ cmake option enabled. ```bash ../minimizer.sh ./test/polygon_fuzz --fuzz=PolygonFuzz.TriangulationNoCrash ``` -------------------------------- ### Import ManifoldNET namespaces Source: https://github.com/weianweigan/manifold-csharp/blob/dev-csharp/bindings/csharp/notebooks/02.Extrude.ipynb Imports the ManifoldNET namespace and the static Manifold class for use in the notebook. ```python using ManifoldNET; using static ManifoldNET.Manifold; ``` -------------------------------- ### Reference ManifoldNET NuGet package Source: https://github.com/weianweigan/manifold-csharp/blob/dev-csharp/bindings/csharp/notebooks/05.Bricks.ipynb Adds the ManifoldNET.Notebooks NuGet package to the notebook. The output shows the loading of the extension script from the package path. ```python #r "nuget: ManifoldNET.Notebooks, *-*" ``` ```text Result: Loading extension script from `C:\Users\18311\.nuget\packages\manifoldnet.notebooks\1.0.4-alpha\interactive-extensions\dotnet\extension.dib` ```