Skip to content

Commit 719eea3

Browse files
committed
Library overhaul
1 parent b1c47dc commit 719eea3

127 files changed

Lines changed: 5189 additions & 84819 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,5 @@ _deps
4747
*.exe
4848
*.out
4949
*.app
50+
51+
build

CMakeLists.txt

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
1-
#export CMAKE_PREFIX_PATH=path to Qt/5.5/gcc_64/ (where you would find bin/qmake)
2-
cmake_minimum_required(VERSION 3.1)
3-
project(nexus)
1+
cmake_minimum_required(VERSION 3.16)
2+
project(nexus LANGUAGES CXX)
43

5-
option(BUILD_NXS_BUILD "" OFF)
6-
option(BUILD_NXS_EDIT "" OFF)
4+
option(BUILD_TESTS "Build unit tests" OFF)
75

8-
set (CMAKE_CXX_STANDARD 11)
6+
set(CMAKE_CXX_STANDARD 17)
7+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
98

109
# enable setting options with SET cmake command
1110
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
1211

1312
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
1413

15-
find_package(Qt5 COMPONENTS Core Gui REQUIRED)
14+
# --- vcpkg packages ---
15+
find_package(ZLIB REQUIRED)
16+
find_package(PNG REQUIRED)
17+
find_package(JPEG REQUIRED)
18+
find_package(plog CONFIG REQUIRED)
19+
find_package(Stb REQUIRED)
20+
find_path(BSHOSHANY_THREAD_POOL_INCLUDE_DIRS "BS_thread_pool.hpp")
1621

1722
# nexus version
1823
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/NEXUS_VERSION")
19-
file (READ "${CMAKE_CURRENT_SOURCE_DIR}/NEXUS_VERSION" NEXUS_VERSION)
24+
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/NEXUS_VERSION" NEXUS_VERSION)
25+
string(STRIP "${NEXUS_VERSION}" NEXUS_VERSION)
2026
else()
2127
message(FATAL_ERROR "NEXUS_VERSION file not found in the repository")
2228
endif()
@@ -52,11 +58,7 @@ add_subdirectory(src/corto EXCLUDE_FROM_ALL)
5258

5359
add_subdirectory(src)
5460

55-
if (BUILD_NXS_BUILD)
56-
add_subdirectory(src/nxsbuild)
61+
if(BUILD_TESTS)
62+
enable_testing()
63+
add_subdirectory(tests)
5764
endif()
58-
59-
if(BUILD_NXS_EDIT)
60-
add_subdirectory(src/nxsedit)
61-
endif()
62-

README.md

Lines changed: 79 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,106 @@
1-
# Nexus
1+
# libnexus
22

3-
Nexus is a c++/javascript library for creation and visualization of a batched multiresolution 3D model structure.
3+
**Fork of [cnr-isti-vclab/nexus](https://github.com/cnr-isti-vclab/nexus)** — restructured as a **C++ static library** (`libnexus`) for programmatic creation and compression of batched multiresolution 3D models.
44

5-
[Nexus](http://vcg.isti.cnr.it/nexus/) by [Visual Computing Laboratory](http://vcg.isti.cnr.it) - ISTI - CNR
5+
All command-line executables (`nxsbuild`, `nxscompress`, `nxsview`, `nxsedit`) and Qt dependencies have been removed. The library exposes a clean C API for integration into any C/C++ application.
66

7-
Contact me @ federico.ponchio@isti.cnr.it
7+
## Entry Points
88

9-
See [INSTALL.MD](INSTALL.md) for compilation instructions.
9+
The public API is defined in [`src/common/nxs.h`](src/common/nxs.h):
1010

11-
### Main features
11+
```c
12+
#include "common/nxs.h"
1213

13-
* Multiresolution
14-
* Large models
15-
* Textures or color per vertex
16-
* Streaming
17-
* Compression
18-
* WebGL
14+
// Simple build: input mesh → output .nxs or .nxz
15+
NXSErr nexusBuild(const char *input,
16+
const char *output,
17+
char *errorMessage,
18+
int errorMessageSize);
1919

20-
### Basic usage
20+
// Extended build with full control over all parameters
21+
NXSErr nexusBuildEx(const char *input,
22+
const char *output,
23+
const NexusBuildOptions &options,
24+
char *errorMessage,
25+
int errorMessageSize);
26+
```
2127
22-
Starting from a 3D model (.ply), drag and drop it on the **nxsbuild** executable, and it will be converted into a multiresolution nexus model (.nxs). Drag the multiresolution nexus model (.nxs) onto the **nxscompress** executable to compress it, and the result will be a compressed multiresolution nexus model (.nxz).
28+
**Return codes** (`NXSErr`):
29+
| Value | Meaning |
30+
|-------|---------|
31+
| `NXSERR_NONE` (0) | Success |
32+
| `NXSERR_EXCEPTION` (1) | Internal error |
33+
| `NXSERR_INVALID_INPUT` (2) | Invalid input file or parameters |
2334
24-
gargo.ply --> **nxsbuild** --> gargo.nxs --> **nxscompress.exe** --> gargo.nxz
35+
**`NexusBuildOptions`** controls geometry build (node size, scaling, texture quality, point cloud mode, normals/colors/texcoords toggling) and compression (corto/meco codec, quantization bits for coordinates, normals, colors, textures).
2536
26-
Drag and drop either .nxs or .nxz files on **nxsview** to interactively inspect the generated 3D multiresolution model.
37+
If the output filename ends with `.nxz`, the library automatically performs compression after the build step.
2738
28-
-----------------------------------------------------------------------------------------
39+
## Building
2940
30-
### Create the .nxs model
41+
### Prerequisites
3142
32-
Use [nxsbuild](doc/nxsbuild.md) to create a multiresolution nexus model (.nxs) out of your 3D model (.ply):
43+
- CMake ≥ 3.16
44+
- C++17 compiler
45+
- [vcpkg](https://github.com/microsoft/vcpkg) with the following packages:
46+
`zlib`, `libpng`, `libjpeg-turbo`, `stb`, `plog`, `bshoshany-thread-pool`
47+
- [VCGLib](https://github.com/cnr-isti-vclab/vcglib) (auto-detected from `../vcglib` or pass `-DVCGDIR=...`)
3348
34-
$ nxsbuild gargo.ply
49+
### Windows (PowerShell)
3550
36-
The result will be gargo.nxs. For large files this may take quite some time. See the [man](doc/nxsbuild.md) page for all the options, supported input files etc.
51+
```powershell
52+
./build.ps1 # Release build
53+
./build.ps1 -WithTests # Include unit tests
54+
./build.ps1 -Debug # Debug build
55+
```
3756

38-
### Compress the multiresolution model
57+
### Linux / macOS
3958

40-
The model can be compressed, saving aroung 90% of the size. This is most useful for streaming applications:
59+
```bash
60+
./build.sh # Release build
61+
./build.sh --with-tests # Include unit tests
62+
./build.sh --debug # Debug build
63+
```
4164

42-
$ nxcompress gargo.nxs
65+
### Manual CMake
4366

44-
The result will be gargo.nxz.
45-
Detailed information about the compression parameters can be found in the [man](doc/nxcompress.md) page.
67+
```bash
68+
cmake -B build \
69+
-DCMAKE_TOOLCHAIN_FILE=$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake \
70+
-DCMAKE_BUILD_TYPE=Release \
71+
-DBUILD_TESTS=ON
4672

73+
cmake --build build --config Release
74+
```
4775

48-
### Edit, Info and Simplify
76+
Output: `build/src/Release/libnexus.lib` (Windows) or `build/src/liblibnexus.a` (Linux/macOS).
4977

50-
[Nxsedit](doc/nxsedit.md) can be used for many editing operations on the multiresolution model.
51-
For instance, you can get some statistics on the created model (bounding sphere, list of patches, etc.):
78+
## Tests
5279

53-
$ nxsedit gargo.nxs -i
80+
Unit tests use [Google Test](https://github.com/google/googletest) and require additional vcpkg packages: `gtest`, `cpr`, `minizip-ng`.
5481

55-
Or also, you can simplify the .nxs file (pruning the lowest level of the multiresolution tree):
82+
```bash
83+
cmake -B build -DBUILD_TESTS=ON
84+
cmake --build build
85+
ctest --test-dir build -C Release --output-on-failure
86+
```
5687

57-
$ nxsedit gargo.nxs -l -o simplified_gargo.nxs
88+
## Project Structure
5889

59-
Detailed information about the editing parameters can be found in the [man](doc/nxedit.md) page.
90+
```
91+
src/
92+
common/ Core library: file I/O, image, data structures, nxs API
93+
nxsbuild/ Mesh loading, KD-tree, multiresolution builder
94+
nxsedit/ Extraction / compression
95+
nxszip/ Low-level mesh encoding/decoding (corto/meco)
96+
corto/ Corto compression library (submodule)
97+
cmake/ CMake packaging helpers
98+
tests/ Google Test unit tests
99+
```
60100

61-
### Inspect your model.
62-
63-
[Nxsview](doc/nxsview.md) is a simple program for inspecting a .nxs file:
64-
65-
$ nxsview gargo.nxs
66-
67-
You can tune various parameters through the interface, but be sure to read the available options in the [man](doc/nxsview.md) page.
68-
69-
70-
### WebGL
71-
72-
The easiest way to publish the model on the web is to use [3DHOP](http://3dhop.net) interface.
73-
Alternatively you can use Three.js: there is a minimal example in the HTML directory of the GitHub [Nexus repository](https://github.com/cnr-isti-vclab/nexus).
74-
It is strongly recommended to use compression for the models (nxscompress).
75-
76-
77-
### Library
78-
79-
The visualization algorithm can be easily used as library inside your engine, both in C++ or in JavaScript,
80-
basically the algorithm job is to send geometry to the GPU.
81-
82-
83-
### Dependencies and Licenses
84-
85-
All C++ Nexus software is free and released under the GPL license (it depends on Qt and VCG lib).
86-
All Javascript Nexus software is free and release under the MIT license.
101+
## Original Project
87102

103+
Based on [Nexus](http://vcg.isti.cnr.it/nexus/) by [Visual Computing Laboratory](http://vcg.isti.cnr.it) - ISTI - CNR.
88104

89105
### Publications
90106

@@ -94,35 +110,14 @@ Graphical Models, Volume 88, pp. 1-11, November 2016
94110

95111
[Fast decompression for web-based view-dependent 3D rendering](http://vcg.isti.cnr.it/Publications/2015/PD15/Ponchio_Compressed.pdf)
96112
Federico Ponchio, Matteo Dellepiane
97-
Web3D 2015. Proceedings of the 20th International Conference on 3D Web Technology , pp. 199-207, June 2015
113+
Web3D 2015. Proceedings of the 20th International Conference on 3D Web Technology, pp. 199-207, June 2015
98114

99115
[Multiresolution structures for interactive visualization of very large 3D datasets](http://vcg.isti.cnr.it/~ponchio/download/ponchio_phd.pdf)
100-
Federico Ponchio
101-
Phd Thesis
102-
103-
[Interactive Rendering of Dynamic Geometry](http://vcg.isti.cnr.it/Publications/2008/PH08/dynamic.pdf)
104-
F. Ponchio, K. Hormann
105-
IEEE Transaction on Visualization and Computer Graphics, Volume 14, Number 4, pp. 914-925, July 2008
106-
107-
[Batched Multi Triangulation](http://vcg.isti.cnr.it/Publications/2005/CGGMPS05/BatchedMT_Vis05.pdf)
108-
Paolo Cignoni, Fabio Ganovelli, Enrico Gobbetti, Fabio Marton, Federico Ponchio, Roberto Scopigno
109-
Proceedings IEEE Visualization, pp. 207-214, October 2005
110-
111-
[Adaptive TetraPuzzles: Efficient Out-of-Core Construction and Visualization of Gigantic Multiresolution Polygonal Models](http://vcg.isti.cnr.it/publications/papers/vbdam_sig04.pdf)
112-
P. Cignoni, F. Ganovelli, E. Gobbetti, F. Marton, F. Ponchio, R. Scopigno
113-
ACM Trans. on Graphics, vol. 23(3), pp. 796-803, August 2004 (Siggraph '04)
114-
115-
[BDAM: Batched Dynamic Adaptive Meshes for High Performance Terrain Visualization](http://vcg.isti.cnr.it/publications/papers/bdam.pdf)
116-
P.Cignoni, F.Ganovelli, E. Gobbetti, F.Marton, F. Ponchio, R. Scopigno
117-
Computer Graphics Forum, 22(3), pp. 505-514, September 2003
118-
119-
### Feedback
120-
121-
For documented and repeatable bugs, feature requests, etc., please use the [GitHub issues](https://github.com/cnr-isti-vclab/nexus/issues).
116+
Federico Ponchio, PhD Thesis
122117

123-
### Support and thanks
118+
## License
124119

125-
Thanks, support: VCL Informatic department in TU Clausthal, 3D-COFORM. Also to Kai Hormann for having me write the thesis :)
120+
GPL — see [src/LICENSE](src/LICENSE).
126121

127122

128123

build.ps1

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
# ============================================================
2+
# libnexus - Build Script for Windows (PowerShell)
3+
# ============================================================
4+
[CmdletBinding()]
5+
param(
6+
[switch]$DebugBuild,
7+
[switch]$Release,
8+
[string]$BuildDir = "build",
9+
[switch]$WithTests,
10+
[string]$VcpkgRoot = "",
11+
[string]$Generator = "",
12+
[int]$Jobs = 0,
13+
[switch]$Help
14+
)
15+
16+
Set-StrictMode -Version Latest
17+
$ErrorActionPreference = "Stop"
18+
19+
if ($Help) {
20+
Write-Host @"
21+
22+
Usage: ./build.ps1 [OPTIONS]
23+
24+
Options:
25+
-DebugBuild Build in Debug mode
26+
-Release Build in Release mode (default)
27+
-BuildDir <dir> Output build directory (default: build)
28+
-WithTests Enable unit tests (BUILD_TESTS=ON)
29+
-VcpkgRoot <path> Path to vcpkg root (auto-detected if not set)
30+
-Generator <name> CMake generator (e.g. "Ninja", "Visual Studio 17 2022")
31+
-Jobs <n> Parallel build jobs
32+
-Help Show this help message
33+
34+
"@
35+
exit 0
36+
}
37+
38+
# --- Determine build type ---
39+
$BuildType = if ($DebugBuild) { "Debug" } else { "Release" }
40+
41+
Write-Host ""
42+
Write-Host "============================================================"
43+
Write-Host " libnexus Build Script (Windows PowerShell)"
44+
Write-Host " Configuration : $BuildType"
45+
Write-Host " Build dir : $BuildDir"
46+
Write-Host " Tests : $($WithTests.IsPresent)"
47+
Write-Host "============================================================"
48+
Write-Host ""
49+
50+
# --- Detect vcpkg ---
51+
if (-not $VcpkgRoot) {
52+
if ($env:VCPKG_ROOT) {
53+
$VcpkgRoot = $env:VCPKG_ROOT
54+
} elseif (Test-Path "$env:USERPROFILE\vcpkg\vcpkg.exe") {
55+
$VcpkgRoot = "$env:USERPROFILE\vcpkg"
56+
} elseif (Test-Path "C:\vcpkg\vcpkg.exe") {
57+
$VcpkgRoot = "C:\vcpkg"
58+
} elseif (Test-Path "C:\dev\vcpkg\vcpkg.exe") {
59+
$VcpkgRoot = "C:\dev\vcpkg"
60+
}
61+
}
62+
63+
$VcpkgToolchain = ""
64+
if ($VcpkgRoot) {
65+
$VcpkgToolchain = "-DCMAKE_TOOLCHAIN_FILE=$VcpkgRoot\scripts\buildsystems\vcpkg.cmake"
66+
Write-Host "[INFO] Using vcpkg at: $VcpkgRoot"
67+
} else {
68+
Write-Host "[WARNING] vcpkg not found. Set -VcpkgRoot or VCPKG_ROOT environment variable."
69+
Write-Host " Proceeding without vcpkg toolchain."
70+
}
71+
72+
# --- Generator flag ---
73+
$GeneratorFlag = @()
74+
if ($Generator) {
75+
$GeneratorFlag = @("-G", $Generator)
76+
}
77+
78+
# --- CMake options ---
79+
$TestsFlag = if ($WithTests) { "ON" } else { "OFF" }
80+
81+
# --- Configure ---
82+
Write-Host "[INFO] Running CMake configure..."
83+
$cmakeArgs = @("-B", $BuildDir) + $GeneratorFlag
84+
if ($VcpkgToolchain) { $cmakeArgs += $VcpkgToolchain }
85+
$cmakeArgs += @(
86+
"-DCMAKE_BUILD_TYPE=$BuildType",
87+
"-DBUILD_TESTS=$TestsFlag"
88+
)
89+
& cmake @cmakeArgs
90+
if ($LASTEXITCODE -ne 0) {
91+
Write-Host ""
92+
Write-Host "[ERROR] CMake configure failed." -ForegroundColor Red
93+
exit $LASTEXITCODE
94+
}
95+
96+
# --- Build ---
97+
Write-Host ""
98+
Write-Host "[INFO] Building..."
99+
$buildArgs = @("--build", $BuildDir, "--config", $BuildType)
100+
if ($Jobs -gt 0) {
101+
$buildArgs += @("--", "/maxcpucount:$Jobs")
102+
}
103+
& cmake @buildArgs
104+
if ($LASTEXITCODE -ne 0) {
105+
Write-Host ""
106+
Write-Host "[ERROR] Build failed." -ForegroundColor Red
107+
exit $LASTEXITCODE
108+
}
109+
110+
# --- Tests ---
111+
if ($WithTests) {
112+
Write-Host ""
113+
Write-Host "[INFO] Running tests..."
114+
& ctest --test-dir $BuildDir -C $BuildType --output-on-failure
115+
if ($LASTEXITCODE -ne 0) {
116+
Write-Host ""
117+
Write-Host "[ERROR] Some tests failed." -ForegroundColor Red
118+
exit $LASTEXITCODE
119+
}
120+
}
121+
122+
Write-Host ""
123+
Write-Host "[SUCCESS] Build completed successfully." -ForegroundColor Green
124+
Write-Host " Output in: $BuildDir\"
125+
Write-Host ""

0 commit comments

Comments
 (0)