Skip to content

Commit 832fe68

Browse files
authored
Update precompiled headers lib (#127)
* Update shared library generation * Improve error messages * Update License * Fix logger print * Update readme and version * Add compare methodes to precompiled classes * Update contributing checklist
1 parent e330e38 commit 832fe68

Some content is hidden

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

44 files changed

+509
-313
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ install*/
66
*.vtk
77
*.vtu
88
*.vtp
9+
*_lstest*
910
*.vscode/
1011
.vs
1112
CMakeSettings.json

CMakeLists.txt

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.20 FATAL_ERROR)
22
project(
33
ViennaLS
44
LANGUAGES CXX
5-
VERSION 4.4.0)
5+
VERSION 4.5.0)
66

77
# --------------------------------------------------------------------------------------------------------
88
# Library options
@@ -103,7 +103,7 @@ include(cmake/vtk.cmake)
103103

104104
CPMAddPackage(
105105
NAME ViennaCore
106-
VERSION 1.4.4
106+
VERSION 1.5.0
107107
GIT_REPOSITORY "https://github.com/ViennaTools/ViennaCore"
108108
OPTIONS "VIENNACORE_FORMAT_EXCLUDE docs/ build/"
109109
EXCLUDE_FROM_ALL ${VIENNALS_BUILD_PYTHON})
@@ -198,12 +198,28 @@ if(VIENNALS_PRECOMPILE_HEADERS)
198198
set(VIENNALS_LINKAGE STATIC)
199199
endif()
200200

201-
add_library(${PROJECT_NAME}Lib ${VIENNALS_LINKAGE})
202-
add_library(${PROJECT_NAME}::Lib ALIAS ${PROJECT_NAME}Lib)
201+
set(LIB_NAME "viennals")
202+
add_library(${LIB_NAME} ${VIENNALS_LINKAGE})
203203

204-
target_link_libraries(${PROJECT_NAME}Lib PUBLIC ${PROJECT_NAME})
205-
target_sources(${PROJECT_NAME}Lib PUBLIC "lib/specialisations.cpp")
206-
set_target_properties(${PROJECT_NAME}Lib PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON)
204+
target_link_libraries(${LIB_NAME} PRIVATE ${PROJECT_NAME})
205+
target_compile_definitions(${LIB_NAME} PRIVATE VIENNALS_USE_PRECOMPILED)
206+
target_sources(${LIB_NAME} PRIVATE "lib/specialisations.cpp")
207+
208+
set_target_properties(
209+
${LIB_NAME}
210+
PROPERTIES VERSION ${PROJECT_VERSION} # full x.y.z appears in filename
211+
SOVERSION ${PROJECT_VERSION_MAJOR} # major version for SONAME
212+
WINDOWS_EXPORT_ALL_SYMBOLS ON)
213+
214+
target_link_libraries(${PROJECT_NAME} INTERFACE ${LIB_NAME})
215+
target_compile_definitions(${PROJECT_NAME} INTERFACE VIENNALS_USE_PRECOMPILED)
216+
217+
install(
218+
TARGETS ${LIB_NAME}
219+
EXPORT ViennaLSTargets
220+
LIBRARY DESTINATION lib
221+
ARCHIVE DESTINATION lib
222+
RUNTIME DESTINATION bin)
207223
endif()
208224

209225
# --------------------------------------------------------------------------------------------------------

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
* Make sure everything builds with & without shared libs
66

7-
* Run clang-format on ALL files of the project (use format-project.sh)
7+
* Run clang-format on ALL files of the project (use CMake target `format`)
88

9-
* Wrap all implemented interface functions for Python in Wrapping/pyWrap.cpp
9+
* Wrap all implemented interface functions for Python in python/pyWrap.cpp
1010

1111
* IMPORTANT: Check the ReadMe file in / to make sure nothing changed

LICENSE

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
Parts of the code (located in the 'external/' subfolder) have different
2-
licenses. The individual licenses apply for this specific part. Please consult
3-
the respective LICENSE files.
4-
5-
6-
Copyright (c) 2015-2023 Institute for Microelectronics, TU Wien.
1+
Copyright (c) 2015-2025 Institute for Microelectronics, TU Wien.
72

83
Permission is hereby granted, free of charge, to any person obtaining a copy
94
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,14 @@ Releases are tagged on the maser branch and available in the [releases section](
5555
5656
* [ViennaHRLE](https://github.com/ViennaTools/ViennaHRLE)
5757

58-
* [VTK](https://github.com/Kitware/VTK) (optional)
58+
* [VTK](https://github.com/Kitware/VTK) (optional, but recommended for mesh export and visualization)
5959

6060
* [pybind11](https://github.com/pybind/pybind11) (only for building Python libs)
6161

6262
## Using ViennaLS in your project
6363

6464
Have a look at the [example repo](https://github.com/ViennaTools/viennals-example) for creating a project with ViennaLS as a dependency.
6565

66-
6766
## Installing
6867

6968
Since this is a header only project, it does not require any installation.
@@ -73,11 +72,11 @@ However, we recommend the following procedure in order to set up all dependencie
7372
git clone https://github.com/ViennaTools/ViennaLS.git
7473
cd ViennaLS
7574

76-
cmake -B build -DCMAKE_INSTALL_PREFIX=/path/to/your/custom/install/
75+
cmake -B build -D CMAKE_INSTALL_PREFIX=/path/to/your/custom/install/
7776
cmake --install build
7877
```
7978

80-
This will install the necessary headers and CMake files to the specified path. If DCMAKE_INSTALL_PREFIX is not specified, it will be installed to the standard path for your system, usually /usr/local/ .
79+
This will install the necessary headers and CMake files to the specified path. If `CMAKE_INSTALL_PREFIX` is not specified, it will be installed to the standard path for your system, usually `/usr/local/`.
8180

8281
## Installing without VTK
8382

@@ -86,7 +85,7 @@ In order to install ViennaLS without VTK, run:
8685
git clone https://github.com/ViennaTools/ViennaLS.git
8786
cd ViennaLS
8887

89-
cmake -B build -DCMAKE_INSTALL_PREFIX=/path/to/your/custom/install/ -DVIENNALS_USE_VTK=OFF
88+
cmake -B build -D CMAKE_INSTALL_PREFIX=/path/to/your/custom/install/ -D VIENNALS_USE_VTK=OFF
9089
cmake --install build
9190
```
9291

@@ -97,7 +96,7 @@ The CMake configuration automatically checks if the dependencies are installed.
9796
## Building the Python package
9897

9998
> [!NOTE]
100-
> On systems that feature a package manager (e.g. Ubuntu/Debian `apt`), the dependencies can be installed beforehand (e.g. using ```sudo apt install libvtk9-dev```), which saves a considerable amount of time during compilation.
99+
> On systems that feature a package manager (e.g. Ubuntu/Debian `apt`), VTK can be installed beforehand (e.g. using ```sudo apt install libvtk9-dev```), which saves a considerable amount of time during compilation.
101100
102101
The Python package can be built and installed using the `pip` command:
103102

@@ -150,7 +149,7 @@ We recommend using [CPM.cmake](https://github.com/cpm-cmake/CPM.cmake) to consum
150149

151150
* Installation with CPM
152151
```cmake
153-
CPMAddPackage("gh:viennatools/viennals@4.4.0")
152+
CPMAddPackage("gh:viennatools/viennals@4.5.0")
154153
```
155154

156155
* With a local installation
@@ -202,4 +201,7 @@ http://www.iue.tuwien.ac.at/
202201

203202
## License
204203

205-
See file LICENSE in the base directory.
204+
ViennaLS is licensed under the [MIT License](./LICENSE).
205+
206+
Some third-party libraries used by ViennaLS are under their own permissive licenses (MIT, BSD).
207+
See [`THIRD_PARTY_LICENSES.md`](./THIRD_PARTY_LICENSES.md) for details.

THIRD_PARTY_LICENSES.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Third-Party Licenses
2+
3+
ViennaLS is licensed under the MIT License.
4+
This file lists third-party libraries used by ViennaLS and their respective licenses.
5+
6+
---
7+
8+
### ViennaCore
9+
10+
**License:** MIT
11+
**URL:** [https://github.com/ViennaTools/viennacore](https://github.com/ViennaTools/viennacore)
12+
13+
---
14+
15+
#### ViennaHRLE
16+
17+
**License:** MIT
18+
**URL:** [https://github.com/ViennaTools/viennahrle](https://github.com/ViennaTools/viennahrle)
19+
20+
---
21+
22+
#### VTK (Visualization Toolkit)
23+
24+
**License:** BSD 3-Clause
25+
**URL:** [https://vtk.org/](https://vtk.org/)
26+
**Note:** Used for mesh export and visualization.
27+
28+
---
29+
30+
### pybind11
31+
32+
**License:** BSD 3-Clause
33+
**URL:** [https://github.com/pybind/pybind11](https://github.com/pybind/pybind11)
34+
**Note:** Used only when building Python bindings.
35+
36+
---
37+
38+

include/viennals/lsAdvect.hpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -386,13 +386,13 @@ template <class T, int D> class Advect {
386386
// check whether a level set and velocities have been given
387387
if (levelSets.empty()) {
388388
Logger::getInstance()
389-
.addWarning("No level sets passed to Advect. Not advecting.")
389+
.addError("No level sets passed to Advect. Not advecting.")
390390
.print();
391391
return std::numeric_limits<double>::max();
392392
}
393393
if (velocities == nullptr) {
394394
Logger::getInstance()
395-
.addWarning("No velocity field passed to Advect. Not advecting.")
395+
.addError("No velocity field passed to Advect. Not advecting.")
396396
.print();
397397
return std::numeric_limits<double>::max();
398398
}
@@ -814,9 +814,7 @@ template <class T, int D> class Advect {
814814
void prepareLS() {
815815
// check whether a level set and velocities have been given
816816
if (levelSets.empty()) {
817-
Logger::getInstance()
818-
.addWarning("No level sets passed to Advect.")
819-
.print();
817+
Logger::getInstance().addError("No level sets passed to Advect.").print();
820818
return;
821819
}
822820

@@ -854,7 +852,7 @@ template <class T, int D> class Advect {
854852
levelSets.back());
855853
} else {
856854
Logger::getInstance()
857-
.addWarning("Advect: Integration scheme not found.")
855+
.addError("Advect: Integration scheme not found.")
858856
.print();
859857
}
860858
}
@@ -938,7 +936,7 @@ template <class T, int D> class Advect {
938936
currentTimeStep = integrateTime(is, maxTimeStep);
939937
} else {
940938
Logger::getInstance()
941-
.addWarning("Advect: Integration scheme not found. Not integrating.")
939+
.addError("Advect: Integration scheme not found.")
942940
.print();
943941
currentTimeStep = -1.;
944942
}

include/viennals/lsBooleanOperation.hpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -316,17 +316,16 @@ template <class T, int D> class BooleanOperation {
316316
void apply() {
317317
if (levelSetA == nullptr) {
318318
Logger::getInstance()
319-
.addWarning("No level set was passed to BooleanOperation. Not "
320-
"performing operation.")
319+
.addError("No level set was passed to BooleanOperation.")
321320
.print();
322321
return;
323322
}
324323

325324
if (static_cast<unsigned>(operation) < 3) {
326325
if (levelSetB == nullptr) {
327326
Logger::getInstance()
328-
.addWarning("Only one level set was passed to BooleanOperation, "
329-
"although two were required. Not performing operation.")
327+
.addError("Only one level set was passed to BooleanOperation, "
328+
"although two were required.")
330329
.print();
331330
return;
332331
}
@@ -348,8 +347,7 @@ template <class T, int D> class BooleanOperation {
348347
case BooleanOperationEnum::CUSTOM:
349348
if (operationComp == nullptr) {
350349
Logger::getInstance()
351-
.addWarning("No comparator supplied to custom BooleanOperation. "
352-
"Not performing operation.")
350+
.addError("No comparator supplied to custom BooleanOperation.")
353351
.print();
354352
return;
355353
}

include/viennals/lsCalculateCurvatures.hpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <hrleCartesianPlaneIterator.hpp>
44
#include <lsCurvatureFormulas.hpp>
55
#include <lsDomain.hpp>
6+
#include <lsExpand.hpp>
67

78
#include <vcLogger.hpp>
89
#include <vcSmartPointer.hpp>
@@ -60,7 +61,7 @@ template <class T, int D> class CalculateCurvatures {
6061
void apply() {
6162
if (levelSet == nullptr) {
6263
Logger::getInstance()
63-
.addWarning("No level set was passed to CalculateCurvatures.")
64+
.addError("No level set was passed to CalculateCurvatures.")
6465
.print();
6566
}
6667

@@ -70,8 +71,10 @@ template <class T, int D> class CalculateCurvatures {
7071
Logger::getInstance()
7172
.addWarning("CalculateCurvatures: Level set width must be "
7273
"at least " +
73-
std::to_string(minWidth) + " !")
74+
std::to_string(minWidth) + ". Expanding level set to " +
75+
std::to_string(minWidth) + ".")
7476
.print();
77+
Expand<T, D>(levelSet, minWidth).apply();
7578
}
7679

7780
std::vector<std::vector<T>> meanCurvaturesVector(

include/viennals/lsCalculateNormalVectors.hpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <hrleSparseStarIterator.hpp>
88

99
#include <lsDomain.hpp>
10+
#include <lsExpand.hpp>
1011

1112
#include <vcLogger.hpp>
1213
#include <vcSmartPointer.hpp>
@@ -44,16 +45,19 @@ template <class T, int D> class CalculateNormalVectors {
4445
void apply() {
4546
if (levelSet == nullptr) {
4647
Logger::getInstance()
47-
.addWarning("No level set was passed to CalculateNormalVectors.")
48+
.addError("No level set was passed to CalculateNormalVectors.")
4849
.print();
4950
}
5051

5152
if (levelSet->getLevelSetWidth() < (maxValue * 4) + 1) {
5253
Logger::getInstance()
5354
.addWarning("CalculateNormalVectors: Level set width must be "
5455
"greater than " +
55-
std::to_string((maxValue * 4) + 1) + "!")
56+
std::to_string((maxValue * 4) + 1) +
57+
". Expanding level set to " +
58+
std::to_string((maxValue * 4) + 1) + ".")
5659
.print();
60+
Expand<T, D>(levelSet, (maxValue * 4) + 1).apply();
5761
}
5862

5963
std::vector<std::vector<Vec3D<T>>> normalVectorsVector(
@@ -64,7 +68,7 @@ template <class T, int D> class CalculateNormalVectors {
6468

6569
auto grid = levelSet->getGrid();
6670

67-
//! Calculate Normalvectors
71+
// Calculate Normalvectors
6872
#pragma omp parallel num_threads(levelSet->getNumberOfSegments())
6973
{
7074
int p = 0;
@@ -111,10 +115,10 @@ template <class T, int D> class CalculateNormalVectors {
111115

112116
denominator = std::sqrt(denominator);
113117
if (std::abs(denominator) < 1e-12) {
114-
std::ostringstream oss;
115-
oss << "CalculateNormalVectors: Vector of length 0 at "
116-
<< neighborIt.getIndices();
117-
Logger::getInstance().addWarning(oss.str()).print();
118+
Logger::getInstance()
119+
.addWarning("CalculateNormalVectors: Vector of length 0 at " +
120+
neighborIt.getIndices().to_string())
121+
.print();
118122
for (unsigned i = 0; i < D; ++i)
119123
n[i] = 0.;
120124
} else {

0 commit comments

Comments
 (0)