# msraig/ce-polycube architecture

> Architecture diagram of the GitHub repository msraig/ce-polycube, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/msraig/ce-polycube
- Repository: https://github.com/msraig/ce-polycube

## Overview

##### Project type and purpose
- This is a research-grade C++ command‐line meshing pipeline (“CE-PolyCube”), producing feature‐aware all‐hex meshes from tetrahedral inputs by combining PolyCube deformation, cut‐enhancement, and hex‐element optimization.
- The README describes a data‐processing pipeline driven by Windows batch scripts and multiple compiled executables, leveraging external libraries (Boost, CGAL, MOSEK, etc.) and in‐repo modules (HexOptimizer, ScissorPoly, PolyCubeCut, various Utils).

##### File structure
- Top‐level folders:
- Bin – prebuilt executables (HexaConvert.exe, ScissorPoly.exe, etc.)
- HexOptimizer – library + driver code for hex‐mesh smoothing/refinement
- PolyCubeCut – implements cut‐enhanced polycube map logic
- ScissorPoly – code for initial polycube deformation and flattening
- Utils – small standalone tools (SplitTet, TetHexFeatureTransfer, format converters)
- Scripts – orchestration scripts (gen_hex.bat, gen_hex_nodeform.bat)
- extern & cmake – vendored external dependencies and CMake find scripts
- Build orchestrated by CMakeLists.txt in root and subdirectories; finds external libs, builds modules into executables under Bin.

##### README for additional insights
- Pipeline stages:
a. Start from tetrahedral mesh (.vtk) + feature file (.fea).
b. Run ScissorPoly to deform/flatten initial PolyCube.
c. Run PolyCubeCut to perform cut‐enhancement.
d. Run HexOptimizer to optimize final all‐hex mesh.
e. Utility tools convert between formats (VTK→OBJ, etc.).
- Batch scripts glue executables together and set environment variables (DATA_ROOT_PATH, HEXEX_PATH, POLYCUT_PATH).

##### Detailed capture of essential architectural elements
- Be explicit about data formats (input .vtk + .fea, output .vtk).
- Role of batch scripts in configuring and chaining stages.
- CMake as a component that resolves and links all modules and externals into binaries.
- Optional flows (e.g., gen_hex_nodeform.bat using PolyCut directly, alternative parameter tuning).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Script Layer
    subgraph "Script Layer"
        S1["gen_hex.bat"]:::script
        S2["gen_hex_nodeform.bat"]:::script
    end

    %% Executables
    subgraph "Executables"
        spExe["ScissorPoly.exe"]:::exec
        pcExe["PolyCubeCut.exe"]:::exec
        hcExe["HexaConvert.exe"]:::exec
        hrExe["HexaRefiner.exe"]:::exec
        stExe["SplitTet.exe"]:::exec
        ftExe["TetHexFeatureTransfer.exe"]:::exec
        vk1["vtk2obj.exe"]:::exec
        vk2["vtk2ovm.exe"]:::exec
        vk3["tetovm2vtk.exe"]:::exec
        vk4["tetvtk2mesh.exe"]:::exec
        vk5["vtu2vtklabel.exe"]:::exec
        vk6["vtudecode.exe"]:::exec
    end

    %% Core Libraries
    subgraph "Core Libraries"
        scLib["ScissorPoly Module"]:::module
        pcLib["PolyCubeCut Module"]:::module
        hoLib["HexOptimizer Module"]:::module
    end

    %% Utils Tools
    subgraph "Utils Tools"
        ut1["SplitTet Tool"]:::utils
        ut2["TetHexFeatureTransfer Tool"]:::utils
        ut3["tetovm2vtk Converter"]:::utils
        ut4["tetvtk2mesh Converter"]:::utils
        ut5["vtk2obj Converter"]:::utils
        ut6["vtk2ovm Converter"]:::utils
        ut7["vtu2vtklabel Converter"]:::utils
        ut8["vtudecode Converter"]:::utils
    end

    %% External Dependencies
    subgraph "External Dependencies"
        ext1["Boost, Eigen, SuiteSparse, LAPACK"]:::external
        ext2["CGAL, TetGen"]:::external
        ext3["OpenMesh, OpenVolumeMesh"]:::external
        ext4["MOSEK, HLBFGS"]:::external
        ext5["gflags, CXXOPTS, rapidxml"]:::external
        ext6["ANN, SUS"]:::external
    end

    %% Build System
    subgraph "Build System"
        cmRoot["CMakeLists.txt Root"]:::build
        cmHex["HexOptimizer/CMakeLists.txt"]:::build
        cmPC["PolyCubeCut/CMakeLists.txt"]:::build
        cmSP["ScissorPoly/CMakeLists.txt"]:::build
        cmU["Utils/CMakeLists.txt"]:::build
        cmFind["cmake/"]:::build
    end

    %% File System
    subgraph "File System"
        inp["Input: .vtk, .fea"]:::data
        mid["Intermediate Files"]:::data
        out["Output: .vtk"]:::data
    end

    %% Sequence Flow
    S1 --> spExe --> pcExe --> hcExe --> out
    S2 --> pcExe
    S1 --> stExe
    S1 --> ftExe
    S1 --> vk1
    S1 --> vk2
    S1 --> vk3
    S1 --> vk4
    S1 --> vk5
    S1 --> vk6

    %% Data Flow
    inp --> spExe
    pcExe --> mid
    mid --> hcExe

    %% Module Calls
    spExe --> scLib
    pcExe --> pcLib
    hcExe --> hoLib
    hrExe --> hoLib
    stExe --> ut1
    ftExe --> ut2
    vk3 --> ut3
    vk4 --> ut4
    vk1 --> ut5
    vk2 --> ut6
    vk5 --> ut7
    vk6 --> ut8

    %% Dependencies
    scLib --> ext2
    scLib --> ext3
    scLib --> ext5
    pcLib --> ext2
    pcLib --> ext3
    pcLib --> ext4
    hoLib --> ext1
    hoLib --> ext3
    hoLib --> ext4
    hoLib --> ext5
    hoLib --> ext6

    %% Build Links
    cmRoot --> cmHex
    cmRoot --> cmPC
    cmRoot --> cmSP
    cmRoot --> cmU
    cmRoot --> cmFind
    cmSP --> spExe
    cmPC --> pcExe
    cmHex --> hcExe
    cmHex --> hrExe
    cmU --> stExe
    cmU --> ftExe
    cmU --> vk1
    cmU --> vk2
    cmU --> vk3
    cmU --> vk4
    cmU --> vk5
    cmU --> vk6

    %% Click Events
    click S1 "https://github.com/msraig/ce-polycube/blob/master/Scripts/gen_hex.bat"
    click S2 "https://github.com/msraig/ce-polycube/blob/master/Scripts/gen_hex_nodeform.bat"
    click spExe "https://github.com/msraig/ce-polycube/blob/master/Bin/ScissorPoly.exe"
    click pcExe "https://github.com/msraig/ce-polycube/blob/master/Bin/ScissorPoly.exe"
    click hcExe "https://github.com/msraig/ce-polycube/blob/master/Bin/HexaConvert.exe"
    click hrExe "https://github.com/msraig/ce-polycube/blob/master/Bin/HexaRefiner.exe"
    click stExe "https://github.com/msraig/ce-polycube/blob/master/Bin/SplitTet.exe"
    click ftExe "https://github.com/msraig/ce-polycube/blob/master/Bin/TetHexFeatureTransfer.exe"
    click vk1 "https://github.com/msraig/ce-polycube/blob/master/Bin/vtk2obj.exe"
    click vk2 "https://github.com/msraig/ce-polycube/blob/master/Bin/vtk2ovm.exe"
    click vk3 "https://github.com/msraig/ce-polycube/blob/master/Bin/tetovm2vtk.exe"
    click vk4 "https://github.com/msraig/ce-polycube/blob/master/Bin/tetvtk2mesh.exe"
    click vk5 "https://github.com/msraig/ce-polycube/blob/master/Bin/vtu2vtklabel.exe"
    click vk6 "https://github.com/msraig/ce-polycube/blob/master/Bin/vtudecode.exe"
    click scLib "https://github.com/msraig/ce-polycube/tree/master/ScissorPoly/"
    click pcLib "https://github.com/msraig/ce-polycube/tree/master/PolyCubeCut/"
    click hoLib "https://github.com/msraig/ce-polycube/tree/master/HexOptimizer/"
    click ut1 "https://github.com/msraig/ce-polycube/blob/master/Utils/SplitTet/splittet.cpp"
    click ut2 "https://github.com/msraig/ce-polycube/blob/master/Utils/TetHexFeatureTransfer/TetHexFeatureTransfer.cpp"
    click ut3 "https://github.com/msraig/ce-polycube/blob/master/Utils/tetovm2vtk/tetovm2vtk.cpp"
    click ut4 "https://github.com/msraig/ce-polycube/blob/master/Utils/tetvtk2mesh/tetvtk2mesh.cpp"
    click ut5 "https://github.com/msraig/ce-polycube/blob/master/Utils/vtk2obj/vtk2obj.cpp"
    click ut6 "https://github.com/msraig/ce-polycube/blob/master/Utils/vtk2ovm/vtk2ovm.cpp"
    click ut7 "https://github.com/msraig/ce-polycube/blob/master/Utils/vtu2vtklabel/vtu2vtklabel.cpp"
    click ut8 "https://github.com/msraig/ce-polycube/blob/master/Utils/vtudecode/vtudecode.cxx"
    click cmRoot "https://github.com/msraig/ce-polycube/blob/master/CMakeLists.txt"
    click cmHex "https://github.com/msraig/ce-polycube/blob/master/HexOptimizer/CMakeLists.txt"
    click cmPC "https://github.com/msraig/ce-polycube/blob/master/PolyCubeCut/CMakeLists.txt"
    click cmSP "https://github.com/msraig/ce-polycube/blob/master/ScissorPoly/CMakeLists.txt"
    click cmU "https://github.com/msraig/ce-polycube/blob/master/Utils/CMakeLists.txt"
    click cmFind "https://github.com/msraig/ce-polycube/tree/master/cmake/"

    %% Styles
    classDef script fill:#f9f,stroke:#333,stroke-width:1px
    classDef exec fill:#bbf,stroke:#333,stroke-width:1px
    classDef module fill:#88f,stroke:#333,stroke-width:1px
    classDef utils fill:#8f8,stroke:#333,stroke-width:1px
    classDef external fill:#afa,stroke:#333,stroke-width:1px
    classDef build fill:#fc8,stroke:#333,stroke-width:1px
    classDef data fill:#ff8,stroke:#333,stroke-width:1px
```
