Skip to content

Latest commit

 

History

History
127 lines (87 loc) · 4.59 KB

README.md

File metadata and controls

127 lines (87 loc) · 4.59 KB

LineArcOffsetDemo

A demo program written with C++/Qt to show offsetting of shapes comprised of line and arc segments. It also can do boolean operations on these shapes.

It currently has two backends supporting arc segments: CGAL (used by OpenSCAD), and Open CASCADE (used by FreeCAD).

And three backends that approximate arcs with line segments: Clipper, Boost, and GEOS.

Screenshots

offset shapes combined shapes overlapping shapes

Dependencies

Mandatory dependencies:

  • Qt 5 (widgets and xml modules)

Optional dependencies for different engines:

NOTE: the version numbers are for reference, other versions may work too.

The relevant development packages to install on Ubuntu 18.04 (bionic) are:

  • qt5-default
  • libcgal-dev
  • libocct-modeling-algorithms-dev and libocct-modeling-data-dev and libocct-data-exchange-dev
  • liboce-modeling-dev
  • libpolyclipping-dev
  • libboost-dev
  • libgeos++-dev

NOTE: libocct is only available on newer Debian/Ubuntu distributions, so you'll either have to use liboce instead, or compile/install OCCT manually (see the instructions further down).

Open CACADE Technology (OCCT) vs. Open CASCADE Community Edition (OCE)

Open CASCADE Technology was forked at version 6.9.0 into a "Community Edition" that has a different version number scheme. The motivation was to more actively integrate user submitted patches. FreeCAD uses OCE and not official OCCT, and Debian/Ubuntu provide packages for OCE but not OCCT, making it more convenient to install.

https://en.wikipedia.org/wiki/Open_Cascade_Technology#Community_fork

Building Open CASCADE Technology

Official Open CASCADE Technology (not the Community Edition) packages are not available in Ubuntu's package repositories. You must instead compile it from the source.

For Debian 9 (stretch) and likely Ubuntu 18.04 (bionic), the following dependencies need to be installed to build Open CACADE 7.4.0:

sudo apt-get install cmake tk-dev libxmu-dev libxi-dev

The official website (linked earlier) wants you to log in with an account before allowing you to download any files. There is however a GitHub mirror with the sourcecode packages: https://github.com/tpaviot/oce/releases

Here are example commands for downloading, unpacking, compiling, and installing Open CASCADE 7.4.0:

cd ~/Downloads
wget -c https://github.com/tpaviot/oce/releases/download/official-upstream-packages/opencascade-7.4.0.tgz
tar xf opencascade-7.4.0.tgz
cd opencascade-7.4.0
mkdir build
cd build
cmake ..
make
make install

Configuring

You will want to edit the linearcoffsetdemo.pro file and choose which goemetry backends to use by commenting or uncommenting the appropriate lines. It is fine to have multiple engines enabled at the same time, the active engine can be chosen by passing the --engine command line option with the appropriate engine name.

This example shows using only OCE:

# GEOMETRY_ENGINES += cgal
# GEOMETRY_ENGINES += occt
GEOMETRY_ENGINES += oce
# GEOMETRY_ENGINES += clipper
# GEOMETRY_ENGINES += boost
# GEOMETRY_ENGINES += geos

This example shows using both CGAL and GEOS:

GEOMETRY_ENGINES += cgal
# GEOMETRY_ENGINES += occt
# GEOMETRY_ENGINES += oce
# GEOMETRY_ENGINES += clipper
# GEOMETRY_ENGINES += boost
GEOMETRY_ENGINES += geos

NOTE: both OCCT and OCE can be enabled at the same time, but only OCCT will actually be used (it overrides the other).

You may also need to modify the appropriate LIBS and QXX_CFLAGS lines for CGAL and OCCT/OCE depending on your platform.

Compiling

On Linux, run the following commands in the top-level directory with the linearcoffsetdemo.pro file:

qmake
make

Running

On Linux, you can launch the built LineArcOffsetDemo executable that will be put in the same directory as the linearcoffsetdemo.pro file:

./LineArcOffsetDemo

An example of manually specifying the engine to use (useful if multiple engines are enabled):

./LineArcOffsetDemo --engine geos