1 Direct3D CSharp sample {#samples_csharp_direct3d}
4 This sample demonstrates simple way of using OCCT and DirectX libraries in .Net application
5 whitten using CSharp and Windows Presentation Foundation (WPF).
7 The connection between .Net, OCCT (C++) and DirectX level is provided by proxy libraies,
8 OCCProxy and D3DProxy, written in C++/CLI. The proxy OCCProxy library contains single ref class
9 encapsulating OCCT viewer and providing functionality to manipulate this viewer
10 and to import / export OCCT shapes from / to several supported formats of CAD
11 files (IGES, STEP, BREP). And the proxy D3DProxy library contains helper methods for rendering
14 Organizing of user interface in this sample is provided by Windows Presentation Foundation (WPF).
15 And it has the same functionality as the standard OCCT Import/Export sample. The project is
18 Note a few important details:
20 - to build this sample you should to download and install DirectX SDK
21 http://www.microsoft.com/en-us/download/details.aspx?id=6812
23 - to encapsulate C++ class into a field of ref class, template class
24 NCollection_Haft provided by OCCT is used
26 - in order to work consistently on 64-bit systems with OCCT libraries built in
27 32-bit mode, C# assemblies need to have platform target explicitly set to "x86"
28 (in project Properties / Build)
30 - this sample demonstrates indirect method of wrapping C++ to C# using manually
31 created proxy library. Alternative method is available, wrapping individual
32 OCCT classes to C# equivalents so that their full API is available to C# user
33 and the code can be programmed on C# level similarly to C++ one. See desciption
34 of OCCT C# Wrapper in Advanced Samples and Tools on OCCT web site at
35 http://www.opencascade.org/support/products/advsamples
37 - in WPF sample, WinForms control is used to encapsulate OCC viewer since WPF
38 does not provide necessary interface to embed OpenGl view. Other possible
39 solution could be to render OpenGl scene in off-screen buffer and map it
40 to WPF control as image. That approach would allow using all WPF features in
41 control embedding OCCT viewer.
43 Run msvc.bat to start MS Visual Studio for building the sample.
44 Note that project files are provided only for VS 2010, you can open them in
45 newer versions of Visual Studio using automatic converter.
46 After conversion check option "Target framework" in properties of C# projects
47 (tab "Application") to ensure that it corresponds to the version set in
48 the properties of the C++ projects (e.g. ".Net Framework 4.0" for VS 2010).
50 Run run_wpf-D3D.bat to launch the corresponding sample.
52 Note that all batch scripts use configuration defined in OCCT custom.bat file
53 as default; you can provide arguments specifying VS version, bitness, and mode
54 to override these settings, e.g.:
56 > msvc.bat vc10 win64 Debug