项目作者: mbitsnbites

项目描述 :
A library for quick and robust constructive solid geometry (CSG) operations on triangle meshes
高级语言: C++
项目地址: git://github.com/mbitsnbites/solidaritycsg.git
创建时间: 2020-05-28T04:28:52Z
项目社区:https://github.com/mbitsnbites/solidaritycsg

开源协议:GNU Lesser General Public License v3.0

下载


⚠️ This repository has moved to: https://gitlab.com/mbitsnbites/solidaritycsg

SolidarityCSG" class="reference-link">Logo SolidarityCSG

SolidarityCSG is a library for quick and robust constructive solid geometry (CSG) operations.

As input and output, the library supports triangle geometries (meshes), and internally the library uses a voxelized representation of the volumes.

Building

Use CMake to build the library, tools and docs:

  1. mkdir out && cd out
  2. cmake -G Ninja ..
  3. ninja
  4. ninja doc

Using the library

The SolidarityCSG library can be used by applications to perform CSG. See the Doxygen documentation for more details.

Using the csg tool

A small demonstration tool that uses the SolidarityCSG can be found in the tools directory. After building, it can be found in out/tools/csg.

The csg tool takes one or more scene description XML files as input:

  1. $ tools/csg myscene.xml

Example scene XML file

  1. <?xml version="1.0" encoding='UTF-8'?>
  2. <csg>
  3. <settings>
  4. <resolution x="0.01" y="0.01" z="0.01" ></resolution>
  5. <output name="example" type="mesh" format="stl" ></output>
  6. </settings>
  7. <volume>
  8. <difference>
  9. <box cx="0.0" cy="0.0" cz="0.0" sx="1.0" sy="1.0" sz="1.0" ></box>
  10. <mesh src="3d-models/bunny.stl" ></mesh>
  11. </difference>
  12. </volume>
  13. </csg>

About the resolution

Be careful when selecting the resolution. Since the entire scene is sampled and reproduced at the given resoltuion, a too fine resolution will lead to high memory usage and very large output files. On the other hand, a to coarse resolution will lead to a poor result.

Example outputs

  • 3D model in STL format:
    • <output name="example" type="mesh" format="stl" ></output>
  • 2D slices (many TGA files):
    • <output name="example" type="slice" format="tga" ></output>

Valid CSG operations

There are three supported CSG operations:

  • <union>
  • <difference>
  • <intersection>

Valid shapes

There are three supported shape types: two mathematical shapes (sphere and box) and one triangle mesh shape (mesh):

  • <sphere cx="0.0" cy="0.0" cz="0.0" r="0.6" ></sphere>
  • <box cx="0.0" cy="0.0" cz="0.0" sx="1.0" sy="1.0" sz="1.0" ></box>
  • <mesh src="3d-models/bunny.stl" ></mesh>

License

The library is released uneder the GNU LESSER GENERAL PUBLIC LICENSE. See COPYING.LESSER and COPYING for more information.