C# Interfacing of OpenCascade 3d kernel.
The SearchAThing.Solid library is licensed under MIT.
Follow thirdy part libraries are used:
- OpenCascade LGPL-2.1
- FreeImage FreeImage Public License - Version 1.0
- FreeType The FreeType Project LICENSE
- GL2PS GL2PS LICENSE - Version 2, November 2003
- Qt486 LGPL 2.1
- tbb GPL with exceptions
- tcltk ActiveTcl Community License Agreement
- vtk Copyright (c) 1993-2008 Ken Martin, Will Schroeder, Bill Lorensen
This project is a working in progress and only some entities from the OpenCascade kernel are mapped ( actually there are fews and only those I need for my own projects ).
IGESControl_Controller.Init();
var writer = new IGESControl_Writer("MM", 0);
var face1 = Toolkit.FromEdges(
new Line3D(new Vector3D(-10, 0, 0), new Vector3D(20, 0, 0)),
new Line3D(new Vector3D(-10, 10, 0), new Vector3D(20, 10, 15)));
writer.AddShape(face1);
var face2 = Toolkit.FromEdges(
new Line3D(new Vector3D(7.5, -5, -5), new Vector3D(7.5, 15, -5)),
new Line3D(new Vector3D(7.5, -5, 15), new Vector3D(7.5, 15, 15)));
writer.AddShape(face2);
var s1 = face1.Surface();
var s2 = face2.Surface();
var a = new GeomAPI_IntSS(s1, s2, 1e-1);
var C = a.Line(1);
var edge = new BRepBuilderAPI_MakeEdge(C, C.FirstParameter(), C.LastParameter());
var v1 = edge.Vertex1();
var v2 = edge.Vertex2();
var i1 = BRep_Tool.Pnt(v1);
var i2 = BRep_Tool.Pnt(v2);
Console.WriteLine($"Intersection line = {i1}-{i2}");
writer.AddGeom(C.This());
writer.ComputeModel();
writer.Write("MyFile.igs");
Process.Start(AppDomain.CurrentDomain.BaseDirectory);
This example shows how to offset a Face
using the Offset
extension method specifying an offset reference point. In the example:
- magenta face has a
sideRefPt
of (0,0,1) - cyan face has a
sideRefPt
of (0,0,-1)
Console.WriteLine(Environment.CurrentDirectory);
IGESControl_Controller.Init();
var writer = new IGESControl_Writer("MM", 0);
var face = Toolkit.FromEdges(
new Line3D(new Vector3D(0, 0, 0), new Vector3D(10, 0, 0)),
new Line3D(new Vector3D(0, 10, 0), new Vector3D(30, 10, 0)));
writer.AddShape(face);
writer.AddShape(face.Offset(5, new Vector3D(0, 0, 1)));
writer.AddShape(face.Offset(15, new Vector3D(0, 0, -1)));
writer.ComputeModel();
writer.Write("MyFile.igs");
Process.Start(AppDomain.CurrentDomain.BaseDirectory);
Before you start with use of this library you need to:
- download and install opencascade VC++ 2013 64 bit.
- adjust reference libreries on the
SearchAThing.Solid.Wrapper
library in the Property Page :- C/C++ -> Additional Include Directories (
C:\OpenCASCADE7.1.0-vc10-64\opencascade-7.1.0\inc
) - Linker -> Additional Library Directories
- if use the distribution libraries (w/out debug symbol) :
C:\OpenCASCADE7.1.0-vc10-64\opencascade-7.1.0\win64\vc10\lib
- if use a built from source version :
C:\occt-amd64\win64\vc14\libd
- if use the distribution libraries (w/out debug symbol) :
- Linker -> Input -> Additional Dependencies :
- C/C++ -> Additional Include Directories (
TKBin.lib
TKBinL.lib
TKBinTObj.lib
TKBinXCAF.lib
TKBO.lib
TKBool.lib
TKBRep.lib
TKCAF.lib
TKCDF.lib
TKDCAF.lib
TKDraw.lib
TKernel.lib
TKFeat.lib
TKFillet.lib
TKG2d.lib
TKG3d.lib
TKGeomAlgo.lib
TKGeomBase.lib
TKHLR.lib
TKIGES.lib
TKLCAF.lib
TKMath.lib
TKMesh.lib
TKMeshVS.lib
TKOffset.lib
TKOpenGl.lib
TKPrim.lib
TKQADraw.lib
TKService.lib
TKShHealing.lib
TKStd.lib
TKStdL.lib
TKSTEP.lib
TKSTEP209.lib
TKSTEPAttr.lib
TKSTEPBase.lib
TKSTL.lib
TKTObj.lib
TKTObjDRAW.lib
TKTopAlgo.lib
TKTopTest.lib
TKV3d.lib
TKVCAF.lib
TKViewerTest.lib
TKVRML.lib
TKXCAF.lib
TKXDEDRAW.lib
TKXDEIGES.lib
TKXDESTEP.lib
TKXMesh.lib
TKXml.lib
TKXmlL.lib
TKXmlTObj.lib
TKXmlXCAF.lib
TKXSBase.lib
TKXSDRAW.lib
-
Setup environment variable PATH to point
C:\occt-amd64\win64\vc14\bind
bind folder through control panel set env var, then restart visual studio -
Enable native code debugging in your C# Project Properties -> Debug to enable debug of C++ code from
SearchAThing.Solid.Wrapper
This pre-build action ensure all required dll files available where the exe application will run.
In order to build a distribution with debugging symbol useful to coding you need to install CMake-3.6 and start the GUI then choose:
- Where is the source code :
C:\OpenCASCADE7.1.0-vc10-64\opencascade-7.1.0
- Where to build the binaries :
c:\occt-amd64
- Start the Configure a first time and a set of RED will appears, now sets:
- 3RDPARTY_DIR :
C:\OpenCASCADE7.1.0-vc10-64
- enable modules you want to include
- retry Configure until all reds goes away
- 3RDPARTY_DIR :
- Start the Generate and choose
Visual Studio 14 2015 Win64
- Close the CMake GUI and open the solution file
C:\occt-amd64\OCCT.sln
: build the solution takes about 1 hour
More informations about build opencascade with cmake available here.