d1a2fee8 |
1 | #### OCCT CSharp sample |
2 | |
3 | This sample demonstrates simple way of using OCCT libraries in .Net application |
4 | whitten using CSharp and Windows Forms or Windows Presentation Foundation (WPF). |
5 | |
6 | The connection between .Net and OCCT (C++) level is provided by proxy library, |
7 | OCCProxy, written in C++/CLI. The proxy library contains single ref class |
8 | encapsulating OCCT viewer and providing functionality to manipulate this viewer |
9 | and to import / export OCCT shapes from / to several supported formats of CAD |
10 | files (IGES, STEP, BREP). |
11 | |
12 | The sample implements two approaches for organizing user interface with C#. |
13 | Both applications provide the same functionality as the standard OCCT |
14 | Import/Export sample. |
15 | First project is called "IE_WinForms" and uses Windows Forms for GUI. |
16 | Second application is called "IE_WPF" and uses Windows Presentation Foundation. |
17 | |
18 | Note a few important details: |
19 | |
20 | - to encapsulate C++ class into a field of ref class, template class |
21 | NCollection_Haft provided by OCCT is used |
22 | |
23 | - in order to work consistently on 64-bit systems with OCCT libraries built in |
24 | 32-bit mode, C# assemblies need to have platform target explicitly set to "x86" |
25 | (in project Properties / Build) |
26 | |
27 | - this sample demonstrates indirect method of wrapping C++ to C# using manually |
28 | created proxy library. Alternative method is available, wrapping individual |
29 | OCCT classes to C# equivalents so that their full API is available to C# user |
30 | and the code can be programmed on C# level similarly to C++ one. See desciption |
31 | of OCCT C# Wrapper in Advanced Samples and Tools on OCCT web site at |
32 | http://www.opencascade.org/support/products/advsamples |
33 | |
34 | - in WPF sample, WinForms control is used to encapsulate OCC viewer since WPF |
35 | does not provide necessary interface to embed OpenGl view. Other possible |
36 | solution could be to render OpenGl scene in off-screen buffer and map it |
37 | to WPF control as image. That approach would allow using all WPF features in |
38 | control embedding OCCT viewer. |
39 | |
40 | Run msvc.bat to start MS Visual Studio for building the sample. |
41 | Note that project files are provided only for VS 2008, you can open them in |
42 | newer versions of Visual Studio using automatic converter. |
43 | |
44 | Run run_winforms.bat or run_wpf.bat to launch the corresponding sample. |
45 | |
46 | Note that all batch scripts use configuration defined in OCCT custom.bat file |
47 | as default; you can provide arguments specifying VS version, bitness, and mode |
48 | to override these settings, e.g.: |
49 | |
50 | > msvc.bat vc9 win64 Debug |