Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ab4d/cadimporter
CadImporter import and show 3D objects from STEP (.step and .stp) files
https://github.com/ab4d/cadimporter
Last synced: about 1 month ago
JSON representation
CadImporter import and show 3D objects from STEP (.step and .stp) files
- Host: GitHub
- URL: https://github.com/ab4d/cadimporter
- Owner: ab4d
- Created: 2024-09-03T10:07:06.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2024-12-05T11:45:23.000Z (about 1 month ago)
- Last Synced: 2024-12-05T12:30:33.188Z (about 1 month ago)
- Language: C#
- Size: 25.5 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# CadImporter
![Ab3d.DXEngine.CadImporter with import settings](https://www.ab4d.com/Images/CadImporter/CadImporter_1_0-1.png)
![Ab3d.DXEngine.CadImporter with object hierarhy](https://www.ab4d.com/Images/CadImporter/CadImporter_0_2.png)
**CadImporter** shows how to use Ab4d.OpenCascade library to **import and show 3D objects from STEP (.step and .stp) and IGES (.iges and .igs) files**.
This repository contains two projects:
- **Ab3d.DXEngine.CadImporter** - shows how to use CadImporter with [Ab3d.DXEngine](https://www.ab4d.com/DXEngine.aspx) for DirectX rendering and [Ab3d.PowerToys](https://www.ab4d.com/PowerToys.aspx) for 3D helper functions.
- **Ab4d.SharpEngine.CadImporter** - shows how to use CadImporter with [Ab4d.SharpEngine](https://www.ab4d.com/SharpEngine.aspx) for Vulkan rendering (can be used only on Windows).The CadImporter reads the hierarchy of the Parts (Compound or Solid). It can use instanced Shells that are defined by a list of Faces.
Each face can be defined by many Edges. For each Edge it is possible to get the original curve with its parameters.
For example, you can get a location and a radius for a Circle; for BSpline curve you can get control points (Poles), weights and knots.The library preserves the original names from the step files. It can also calcualate the exact Part volume and surface area.
Surface area can also be calculated for each face. Also, the exact edge length can be calculated.The library can also get all the 3D meshes (positions and triangle indices) that are generated by triangulating the faces.
Also, the interpolated positions can be generated for each Edge.This allows 3D models to be shown in a 3D viewer application.
## Licenses
The Ab4d.OpenCascade is using [OpenCASCADE](https://dev.opencascade.org/) library that is licensed under [LGPL](https://github.com/Open-Cascade-SAS/OCCT/blob/master/LICENSE_LGPL_21.txt) and [an exception](https://github.com/Open-Cascade-SAS/OCCT/blob/master/OCCT_LGPL_EXCEPTION.txt).
Ab4d.OpenCascade can be used only when used with the [Ab3d.DXEngine](https://www.ab4d.com/DXEngine.aspx) or [Ab4d.SharpEngine](https://www.ab4d.com/SharpEngine.aspx) libraries.
When Ab4d.OpenCascade is used with Ab3d.DXEngine, it needs to be activated by DXScene (DXScene must be already initialized).
When Ab4d.OpenCascade is used with Ab4d.SharpEngine, it needs to be activated by SceneView or Scene (GpuDevice must be already initialized).
If you want to use Ab4d.OpenCascade without Ab3d.DXEngine or Ab4d.SharpEngine libraries, [contact support](https://www.ab4d.com/Feedback.aspx?Subject=OpenCascace_license).
## System requirements
- 64 bit Windows 10 or newer
- .NET Framework 4.8 or .NET 6 or newer
- App must be compiled with x64 only mode (AnyCpu is not supported)## Using Ab4d.OpenCascade
The CadImporter from Ab4d.OpenCascade library requires many native OpenCascade dlls.
To see a list of all required files check the "OpenCascade required files.txt" file.The required files can be downloaded from https://github.com/Open-Cascade-SAS/OCCT/releases/ web page.
To get the required OpenCascade version, you can read the static Ab4d.OpenCascade.CadImporter.OpenCascadeVersion property.
For the required version, download the occt-vc143-64.zip and 3rdparty-vc14-64.zip and extract the zip files.Then you have multiple options:
1. Copy the required dlls to the output folder of your application. This is a recommended option because you can use any type from the Ab4d.OpenCascade anywhere in the application. This is also recommended when distributing your application.
2. Copy the required dlls to a custom folder and then adjust PATH environment variable or call system's SetDllDirectory function with the path to the OpenCascade folder. Updating the PATH is also used in the sample application. There the PATH is updated at runtime after the application starts (this way is the structure of files in the output folder nicer).For both methods you can use the "copy-open-cascade-dlls.bat" batch file.
Before running it, open the file and update the OCCT and OCCT_THIRD_PARTY paths so that they point to the paths where you have extracted the zip files.To correctly load the Ab4d.OpenCascade that is a C++/CLI assembly, the Ijwhost.dll file needs to be available in the application's output path. This file is part of the Ab4d.OpenCascade NuGet package and should be automatically installed when the package is used. This file is used for finding and loading the runtime to the C++/CLI assembly.
See also the InitializeCadImporter and CreateCadImporter methods in the MainWindow.xaml.cs.
**IMPORTANT**
If the OpenCascade dlls are copied to a custom folder (2nd option above), then
no type from Ab4d.OpenCascade should be used in the MainWindow constructor or DXSceneInitialized event handler.
If it is used, then the application will try to load the OpenCascade dlls before the InitializeCadImporter method is called.
If the OpenCascade dlls are not present in the output folder, then this will throw "Cannot load file or assembly" exception.For example, in this sample the initialization of ImporterUnitsComboBox was removed from the MainWindow constructor because it uses Ab4d.OpenCascade.CadUnitTypes:
// The following line will try to use CadUnitTypes enum from Ab4d.OpenCascade library. This will load OpenCascade dlls.
ImporterUnitsComboBox.ItemsSource = Enum.GetNames();