GithubHelp home page GithubHelp logo

skfcz / ocxreader Goto Github PK

View Code? Open in Web Editor NEW
8.0 2.0 3.0 18.07 MB

A tool to convert vessels in OCX format into 3D geometry

License: GNU Lesser General Public License v2.1

CMake 4.40% C++ 89.28% Batchfile 2.51% Shell 1.91% Python 1.49% C 0.41%
cad shipbuilding

ocxreader's Introduction

OCXReader

OCXReader is a tool to read and parse data from OCX files and export them to different formats such as STEP, glTF, XCAF-XML or XCAF-XBF for visualization.

ocx_model

Roadmap

Read OCX

In the long term, the OCXReader shall create a product structure like this is:

${vesselname}
|__ Reference Planes
|  |__ XRefPlanes
|  |  |__ Frame 1 ... Frame N
|  |__ YRefPlanes
|  |  |__ Longitudinal 1 ... Longitudinal N
|  |__ ZRefPlanes
|     |__ Deck 1 ... Deck N
|__ Reference Surfaces
|  |__ Ref Surface 1 ... Ref Surfaces N 
|__ Panels
   |__ Panel 1 ... Panel N
      |__ Contour
      |__ Surface
      |__ ComposedOf
      |  |__ Plate 1 ... Plate N
      |  |  |__ Contour
      |  |  |__ Surface
      |  |  |__ LimitedBy
      |  |  |  |__ Limit 1 ... Limit N
      |  |  |__ CutBy
      |  |  |  |__ Cut 1 ... Cut N
      |  |__ Bracket 1 ... Bracket N
      |  |__ Pillar 1 ... Pillar N
      |__ StiffenedBy
      |  |__ Stiffener 1 ... Stiffener N
      |__ LimitedBy
      |  |__ Limit 1 ... Limit N
      |__ CutBy
         |__ Cut 1 ... Cut N

Currently, major items like reference planes, panels, and plates are already implemented. Stiffener traces are shown, but no stiffener representation.

Supported Export Formats

  • STEP
  • glTF
  • XCAF-XML
  • XCAF-XBF

Setup

Prerequisites

To build OCXReader you need to have the prerequisites set up:

Compiler

The project uses C++17 features and therefore requires a compiler that supports this standard.

Compiler compatibility:

  • Clang/LLVM >= 6
  • MSVC++ >= 14.11 / Visual Studio >= 2017
  • Xcode >= 10
  • GCC >= 9
  • MinGW >= 9

CMake

The project uses CMake as a build system. CMake version 3.24 or higher is required.

vcpkg

This project is build with CMake and uses the vcpkg package manager to install the required dependencies. You can follow the steps to set up vcpkg on your system here.

Note: For WSL users, make sure to install vcpkg in a directory which grants permission for all users. Otherwise, you will get an error when trying to access and install vcpkg packages through a non-root user.

Git submodules

Besides vcpkg the project uses git submodules to manage some of its dependencies. When checking out the project for the first time, make sure to also initialize and update the submodules:

$ git submodule update --init --recursive

Python

The OpenCascade build requires python with a version of at least 3.7. However, this is only needed when building on Linux.

To ensure your python3 points to the correct version run:

$ ls -l /usr/bin/python3
lrwxrwxrwx 1 root root 9  7. Jan 15:51 /usr/bin/python3 -> python3.7 # required python version >= 3.7

OpenCascade

The project uses OpenCascade as a geometry kernel. It is automatically downloaded and build by vcpkg package manager.

To build OpenCascade on UNIX systems, install the following packages:

Ubuntu

sudo apt-get install software-properties-common
sudo apt-get install libtool autoconf automake gfortran gdebi
sudo apt-get install gcc-multilib libxi-dev libxmu-dev libxmu-headers
sudo apt-get install libx11-dev mesa-common-dev libglu1-mesa-dev
sudo apt-get install libfontconfig1-dev

The minimum requirements for third party dependencies to run OpenCascade itself is Freetype 2.5 and Tcl/TK 8.6:

sudo apt-get install libfreetype6 libfreetype6-dev
sudo apt-get install tcl tcl-dev tk tk-dev

openSUSE

Note: The documentation is not complete yet. Feel free to contribute.

sudo zypper install libX11-devel Mesa-libHL-devel libXmu-devel libXi-devel
sudo zypper install bison fontconfig-devel 

The minimum requirements for third party dependencies to run OpenCascade itself is Freetype 2.5 and Tcl/TK 8.6:

sudo apt-get install libfreetype6 libfreetype6-devel
sudo apt-get install tcl tcl-devel tk tk-devel

OSX

Note: The documentation is not complete yet. Feel free to contribute.

Build

OCXReader comes with a cli to make the setup and build step on the command line as easy as possible. The project uses vcpkg to install the dependencies, in most cases all you need to do is to provide the path to your vcpkg installation directory.

A typical setup using the cli looks like this:

# Generate the build files (use cli.bat on Windows)
$ ./cli.sh gensln --vcpkg /path/to/vcpkg

# Build the project (use cli.bat on Windows)
$ ./cli.sh buildsln --build-type Release --build-dir ./build

The cli also provides functionality to combine the mentioned steps into one:

# Generate the build files and build the project (use cli.bat on Windows)
$ ./cli.sh gensln --vcpkg /path/to/vcpkg buildsln
#                                                ^ no need to specify --build-type and --build-dir as they get inherited from the previous gensln command

The cli gensln and buildsln commands allow to pass additional cmake options. All options after the --cmake-options flag are directly passed to the cmake command. For example, to specify a custom triplet, use the following command:

# Generate the build files
$ ./cli.sh gensln --vcpkg /path/to/vcpkg --cmake-options -DVCPKG_TARGET_TRIPLET=x64-linux-dynamic

macOS

There is currently no official support in vcpkg to build the opencascade library. This can be overridden by passing --allow-unsupported to the DVCPKG_INSTALL_OPTIONS in the CMake options.

# Generate the build files
$ ./cli.sh gensln --vcpkg /path/to/vcpkg --cmake-options -DVCPKG_INSTALL_OPTIONS=--allow-unsupported

Using an IDE

When setting up the project in an IDE, make sure to configure it by passing the mentioned variables to the CMake configuration options.

Feel free to take a look at the following IDE specific configuration examples, to get your IDE up and running:

CLion

Follow these steps to configure CMake options in CLion:

  1. Open the project in CLion.
  2. Go to File > Settings > Build, Execution, Deployment > CMake.
  3. In the CMake options field, provide the necessary options to configure the project:
-DCMAKE_TOOLCHAIN_FILE=path/to/vcpkg/scripts/buildsystems/vcpkg.cmake
  1. Click Apply and then OK to save changes.

Visual Studio

Note: The documentation is not complete yet. Feel free to contribute.

VS Code

Note: The documentation is not complete yet. Feel free to contribute.

Installation

The projects cli provides a functionality to install the project. To install the project, use the installsln command:

# Install the project (use cli.bat on Windows)
$ ./cli.sh installsln --build-type Release --build-dir ./build

Or use the installsln command along with the gensln and buildsln commands:

# Generate the build files, build and install the project (use cli.bat on Windows)
$ ./cli.sh gensln --vcpkg /path/to/vcpkg buildsln installsln
#                                                           ^ no need to specify --build-type and --build-dir as they get inherited from the previous gensln or buildsln command

Note: To pass additional cmake options to the installation step, use the --cmake-options flag. All options after the --cmake-options flag are directly passed to the cmake command.

Usage

OCXReader is a command line tool with the following options:

$ ocxreader --help
Allowed options:

Generic options:
  -v [ --version ]              print version string
  -h [ --help ]                 produce help message
  --config-file arg             The path to the file containing OCX parsing
                                options (e.g. path/to/config_file.json)

OCXReader configuration options:
  -i [ --input-file ] arg       The OCX file to read
  --export-format arg           The export format(s) to use. This can be one or
                                more of the following: STEP, SHIPXML, XCAF-XML,
                                XCAF-XBF
  -s [ --save-to ] arg          The output-file path. Defines were to write the
                                exported file(s) to. If not defined files get
                                saved relative to the program working
                                directory.
  -o [ --output-file ] arg      The output file name. This is used as the
                                filename to the defined export formats. If not
                                defined input-file is used.
  -l [ --log-config-file ] arg  The path to the file containing logging
                                configuration options options (e.g.
                                path/to/log_conf.toml)

The generic option --config-file can be used to define the OCXReader CLI options in a JSON file. A sample configuration file can be found here.

Contributors

Carsten Zerbst
Carsten Zerbst

💻 🚧 📖 🤔
Paul Büchner
Paul Büchner

💻 🚧 📖 🤔
Paul Büchner
Ozan

💻 🤔

License

This project falls under the GNU LESSER GENERAL PUBLIC LICENSE v. 2.1

ocxreader's People

Contributors

carstenzerbst avatar ozanozanozan avatar paulbuechner avatar skfcz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

ocxreader's Issues

Wrong Geom_BSplineCurve (NURBS Curve) when returning from OCAF

Description

Currently, after creating a Geom_BSplineCurve and returning it as TopoDS_Wire to save into OCAF document, a false representation of the given curve is exported to STEP:
grafik

Note: No issues seem to occur when exporting the curve directly after it was created.

Steps to reproduce

  1. Run the STEP Export with the following test data: Aveva-OHCM-MidShip_V285.3docx
  2. Open the created .stp file and view Panel (ID51)

OCXReader Version

0.1.0

Operating System

  • macOS
  • Windows
  • Linux

Additional Information

Continue here: Analysis Situs Forum

Restricted surface from non-planar surfaces (plate extraction)

Description

Currently, plate extraction features only work for planar surfaces. When trying to restrict a given non-planar surface (TopoDS_Shell) with a given contour (TopoDS_Wire), the surface extraction fails due to improper imprinting of the given contour.
grafik

Problem Statement/Justification

Surface extraction should be supported for all shape types, not just for planar surfaces.

Proposed Solution or API

Quaoar stated:

  1. Prepare the input contour to make it composed of splines instead of polylines. We had polylines mainly because it was defined like that in the target system (ship hull modeling system, where plates were captured for subsequent unfolding). With split-by-continuity you can turn it into a wire with C1 edges.
  2. Imprint the prepared contour onto the shell. Here we implemented this Contour Capture algorithm mentioned in the link above. You can try using "General Fuse" operator of OpenCascade like here: https://gitlab.com/ssv/AnalysisSitus/-/blob/master/src/asiAlgo/auxiliary/asiAlgo_Utils.cpp#L3486. Use 0.1 as a fuzzy tolerance for Booleans
  3. Once the contour is imprinted, it's necessary to filter out all faces lying outside the contour. This can be done by properly iterating the imprinted edges:
    1. Find the center point of the contour and the face closest to this center point. This would be your starting face.
    2. Iterate over the neighbor faces until you reach the imprinted contour bounds (Boolean operation would return you the images of those edges, so you can check if your next face contains these edges or not to decide whether to stop propagation).

Alternatives

No response

Additional Information

Continue here: Analysis Situs Forum

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.