Name Date Size

..29-Nov-20194 KiB

.gitignoreH A D24-Oct-2019102

.travis.ymlH A D25-Oct-20196.2 KiB

appveyor.ymlH A D20-Oct-20194.6 KiB

cmake/H06-Sep-20194 KiB

CMakeLists.txtH A D21-Oct-20191.7 KiB

LICENSEH A D06-Sep-20197.5 KiB

README.mdH A D10-Nov-20196.7 KiB

resources/H06-Sep-20194 KiB

src/H21-Nov-20194 KiB

test-suite/H28-Oct-20194 KiB

THIRDPARTY-LICENSESH A D06-Sep-201929.2 KiB

README.md

1# OCC-CSG
2
3[![Build Status](https://travis-ci.org/miho/OCC-CSG.svg?branch=master)](https://travis-ci.org/miho/OCC-CSG) [![Build status](https://ci.appveyor.com/api/projects/status/k4lxqsej71ughs48?svg=true)](https://ci.appveyor.com/project/miho/occ-csg)
4
5
6Simple but powerful CSG tool based on the [OpenCascade](https://www.opencascade.com/content/overview) CAD Kernel
7
8This tool provides a simple command-line interface for applying boolean operations and transformations to 3D objects specified in either BREP/STEP or STL format. It contains a convenient STL importer for converting mesh based geometries to an eqivalent BREP representation (might cause performance issues for large STL files). Geometries can be exported as STL files as well.
9
10There is a Java library [VCSG](https://github.com/miho/VCSG) and the corresponding [VRL-Studio plugin](https://github.com/miho/VRL-VCSG) for using OCC-CSG from Java and [VRL-Studio](https://vrl-studio.mihosoft.eu/).
11
12## Installation
13
14To get started quickly, download a [binary release](https://github.com/miho/OCC-CSG/releases) (available for Linux, macOS and Windows on x64). On macOS occ-csg can be installed via [Homebrew](https://brew.sh):
15
16    brew install miho/tap/occ-csg
17
18## Sample
19
20These three lines
21
22    occ-csg --create box -5,-5,-5,5,5,5 box.stp
23    occ-csg --create sphere 0,0,0,6.5 sphere.stp
24    occ-csg --csg difference box.stp sphere.stp cut.stp
25    
26produce this hollow cube:
27
28<img src="resources/img/sample.jpg" width="400px">
29
30To convert this resolution independent geometry to a triangulated STL file use:
31
32    occ-csg --convert cut.stp cut.stl 0.1
33
34The number at the end specifies the tolerance for the STL triangulation. Smaller values lead to better approximations. If the value is ommitted a default value (currently 0.5) will be used. This is how the resulting STL might look like:
35
36<img src="resources/img/sample-stl.jpg" width="400px">
37
38## CLI
39
40To get an overview over the CLI type `./occ-csg --help`:
41
42```
43-------------------------------------------------------------
44----        CSG Tool based on the OCCT CAD Kernel        ----
45----                    Version 0.9.9                    ----
46---- 2018-2019 by Michael Hoffer (info@michaelhoffer.de) ----
47----                   www.mihosoft.eu                   ----
48-------------------------------------------------------------
49
50USAGE: 
51
52Help & Info:
53
54 occ-csg --help
55 occ-csg --version
56
57Creating Primitives:
58
59 occ-csg --create box x1,y1,z1,x2,y2,z2                            box.stp
60 occ-csg --create sphere x1,y1,z1,r                                sphere.stp
61 occ-csg --create cyl x1,y1,z1,r,h                                 cyl.stp
62 occ-csg --create cone x1,y1,z1,r1,r2,h                            cone.stp
63 occ-csg --create helix r,profile_r,pitch,num_revolutions          helix.stp
64 occ-csg --create helix r,profile_face.stp,pitch,num_revolutions   helix.stp
65 occ-csg --create polygons x1,y1,z1,x2,y2,z2,... p1v1,p1v2,p1v3,...:p2v1,p2v2,p2v3,... polygons.stp
66 occ-csg --create 2d:circle x,y,r                                  2dcircle.stp
67 occ-csg --create 2d:polygon x1,y1,x2,y2,...                       2dpolygon.stp
68 occ-csg --create 2d:rect x1,y1,x2,y2                              2drectangle.stp
69 occ-csg --create 2d:round-rect x,y,width,height,corner_r          2drectangle.stp
70 occ-csg --create extrusion:polygon ex,ey,ez,x1,y1,z1,x2,y2,z2,... extrude.stp
71 occ-csg --create extrusion:file ex,ey,ez                          2dpath.stp extrude.stp
72
73Format Conversion:
74
75 occ-csg --convert file1.stl file1.stp
76 occ-csg --convert file1.stp file1.stl 0.1
77
78Geometric Transformation:
79
80 occ-csg --transform translate x,y,z                               file1.stp file1-translated.stp
81 occ-csg --transform scale     sx,sy,sz                            file1.stp file1-scaled.stp
82 occ-csg --transform rot       dir_x,dir_y,dir_z,angle file1.stp   file1-rotated.stp
83 occ-csg --transform matrix    t1,t2,t3,...,t12 file1.stp          file1-transformed.stp
84
85Boolean Operators, Constructive Solid Geometry (CSG):
86
87 occ-csg --csg union file1.stp file2.stp file-out.stp
88 occ-csg --csg difference file1.stp file2.stp file-out.stp
89 occ-csg --csg intersection file1.stp file2.stp file-out.stp
90
91Shape Editing:
92
93 occ-csg --edit split-shape shape.stp stp
94 occ-csg --edit round-edges radius shape.stp shape-rounded.stp
95 occ-csg --edit chamfer-edges radius shape.stp shape-chamfered.stp
96
97
98Shape Info:
99
100 occ-csg --info bounds file.stp      
101 occ-csg --info bounds file.stp      bounds.stp
102 occ-csg --info volume file.stp tol
103```
104
105## How to build OCC-CSG
106
107### Requirements
108
109- C+\+ Compiler with C+\+11 support (tested with Clang, GCC, MSVC+\+ 2017 on x64)
110- CMake >= 3.1
111- [OCC](https://github.com/miho/occ-for-occ-csg) >= 7.3.0.x (official version is currently built with 7.4.0)
112
113#### Hints for building OCC:
114
115For using `occ-csg` as independent command-line tool it is recommended to compile OCC as static library. This will increase the `occ-csg` file size but ensures the tool can be used without carrying too many additional libraries around. `occ-csg` comes with the freetype headers to simplify the build process on Windows. The recommended settings are:
116
117##### Dependencies required by OCC:
118
119- FreeType: if freetype cannot be found on Ubuntu then install libfreetype6-dev, we use freetype-2.7 on Windows and macOS, to build static freetype on macOS, make sure to build without zlib, libpng, bzip2 and harfbuzz (otherwise it will have dynamic dependencies to these libraries)
120- OpenGL:   if GL/GLU cannot be found on Unbuntu then install libglu1-mesa-dev and libgl1-mesa-dev
121- XQuartz:  only necessary on macOS. Whether XQuartz is necessary depends on the version of macOS and OCC, see OCC documentation. It might be necessary to adjust the X11 include path via `ln -s /opt/X11/include/X11 /usr/local/include/X11`
122
123#### Bash (Linux/macOS/Cygwin/other Unix-like Shell)
124
125    cd /path/to/project
126    mkdir build && cd build
127    cmake .. -DOpenCASCADE_DIR=/path/to/occ
128    make -j4
129
130On Linux, it might be necessary to install fontconfig-devel to successfully link the executable. On Ubuntu the precise package name is libfontconfig-dev.
131
132#### Windows (CMD)
133
134    "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools\vsdevcmd" -arch=x64
135    cd \path\to\project
136    mkdir build
137    cd build
138    cmake .. -DOpenCASCADE_DIR=\path\to\occ
139    MSBuild .\occ-csg-prj.sln  /property:Configuration=Release /property:Platform=x64
140    
141For building large projects on Windows it might be preferable to use the x64 host compiler instead of the x86 compiler. Note that both compilers are able to produce x64 binaries. But the x64 compiler can use more memory during compilation. To really prevent that CMake picks the 64bit x86 host compiler just force cmake to use the x64 host compiler via
142
143    -DCMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE=X64 -G "Visual Studio 15 2017 Win64"
144