Skip to content

Commit ad36890

Browse files
author
Matthias Peschke
committed
Refactoring.
1 parent 9bfb305 commit ad36890

32 files changed

+1771
-1180
lines changed

.clang-format

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
# Checkout config tool: https://zed0.co.uk/clang-format-configurator/
2+
# Or http://cf.monofraps.net/
3+
# https://clang.llvm.org/docs/ClangFormatStyleOptions.html
4+
# https://github.com/01org/parameter-framework/blob/master/.clang-format
5+
6+
# Tested on: clang-format version 6.0.1
7+
8+
9+
# Common settings
10+
BasedOnStyle: LLVM
11+
TabWidth: 4
12+
IndentWidth: 4
13+
UseTab: Never
14+
ColumnLimit: 150
15+
16+
# Other languages JavaScript, Proto
17+
18+
Language: Cpp
19+
20+
# http://releases.llvm.org/6.0.1/tools/clang/docs/ClangFormatStyleOptions.html#disabling-formatting-on-a-piece-of-code
21+
# int formatted_code;
22+
# // clang-format off
23+
# void unformatted_code ;
24+
# // clang-format on
25+
# void formatted_code_again;
26+
27+
DisableFormat: false
28+
Standard: Cpp11
29+
30+
AccessModifierOffset: -4
31+
AlignAfterOpenBracket: Align
32+
AlignConsecutiveDeclarations: false
33+
AlignEscapedNewlinesLeft: DontAlign
34+
AlignOperands: true
35+
AlignTrailingComments: false
36+
AllowAllParametersOfDeclarationOnNextLine: false
37+
AllowShortBlocksOnASingleLine: true
38+
AllowShortCaseLabelsOnASingleLine: true
39+
AllowShortFunctionsOnASingleLine: All
40+
AllowShortIfStatementsOnASingleLine: true
41+
AllowShortLoopsOnASingleLine: true
42+
AllowShortLambdasOnASingleLine: All
43+
AlwaysBreakAfterDefinitionReturnType: false
44+
AlwaysBreakAfterReturnType: None
45+
AlwaysBreakBeforeMultilineStrings: false
46+
AlwaysBreakTemplateDeclarations: true
47+
BinPackArguments: false
48+
BinPackParameters: false
49+
50+
# Configure each individual brace in BraceWrapping
51+
BreakBeforeBraces: Custom
52+
# Control of individual brace wrapping cases
53+
BraceWrapping: {
54+
AfterClass: 'true'
55+
AfterControlStatement: 'false'
56+
AfterEnum : 'true'
57+
AfterFunction : 'true'
58+
AfterNamespace : 'false'
59+
AfterStruct : 'true'
60+
AfterUnion : 'true'
61+
BeforeCatch : 'false'
62+
BeforeElse : 'false'
63+
IndentBraces : 'false'
64+
AfterExternBlock : 'true'
65+
SplitEmptyFunction : 'false'
66+
SplitEmptyRecord : 'false'
67+
SplitEmptyNamespace : 'true'
68+
}
69+
70+
BreakAfterJavaFieldAnnotations: true
71+
BreakBeforeInheritanceComma: false
72+
BreakBeforeBinaryOperators: None
73+
BreakBeforeTernaryOperators: true
74+
BreakConstructorInitializersBeforeComma: true
75+
BreakStringLiterals: false
76+
77+
CommentPragmas: '^ IWYU pragma:'
78+
CompactNamespaces: false
79+
ConstructorInitializerAllOnOneLineOrOnePerLine: false
80+
ConstructorInitializerIndentWidth: 4
81+
ContinuationIndentWidth: 4
82+
Cpp11BracedListStyle: true
83+
SpaceBeforeCpp11BracedList: false
84+
DerivePointerAlignment: false
85+
ExperimentalAutoDetectBinPacking: false
86+
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
87+
IndentCaseLabels: false
88+
FixNamespaceComments: true
89+
IndentWrappedFunctionNames: false
90+
KeepEmptyLinesAtTheStartOfBlocks: true
91+
MacroBlockBegin: ''
92+
MacroBlockEnd: ''
93+
JavaScriptQuotes: Double
94+
MaxEmptyLinesToKeep: 1
95+
NamespaceIndentation: None
96+
ObjCBlockIndentWidth: 4
97+
ObjCSpaceAfterProperty: true
98+
ObjCSpaceBeforeProtocolList: true
99+
PenaltyBreakBeforeFirstCallParameter: 19
100+
PenaltyBreakComment: 300
101+
PenaltyBreakFirstLessLess: 120
102+
PenaltyBreakString: 1000
103+
104+
PenaltyExcessCharacter: 1000000
105+
PenaltyReturnTypeOnItsOwnLine: 60
106+
PointerAlignment: Left
107+
SpaceAfterCStyleCast: false
108+
SpaceBeforeAssignmentOperators: true
109+
SpaceBeforeParens: Never
110+
SpaceInEmptyParentheses: false
111+
SpacesBeforeTrailingComments: 1
112+
SpacesInAngles: false
113+
SpacesInContainerLiterals: true
114+
SpacesInCStyleCastParentheses: false
115+
SpacesInParentheses: false
116+
SpacesInSquareBrackets: false
117+
SpaceAfterTemplateKeyword: true
118+
SpaceBeforeInheritanceColon: true
119+
120+
SortUsingDeclarations: true
121+
SortIncludes: true
122+
123+
# Comments are for developers, they should arrange them
124+
ReflowComments: true
125+
126+
IncludeBlocks: Preserve
127+
IndentPPDirectives: AfterHash
128+
129+
130+
131+
---
132+
133+
...

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ option(LIBIGL_WITH_EMBREE "Use Embree" ON)
2828
option(LIBIGL_WITH_PNG "Use png" ON)
2929
option(LIBIGL_WITH_XML "Use xml" OFF)
3030
option(LIBIGL_WITH_OPENGL_GLFW_IMGUI "Use ImGui" ON)
31+
option(LIBIGL_WITH_STL "Use stl" ON)
3132

3233
find_package(LIBIGL REQUIRED QUIET)
3334

@@ -60,3 +61,7 @@ include(cmake/addGitLibs.cmake)
6061
option(QUVIZ_BUILD_EXAMPLES "Build examples" ON)
6162

6263
add_subdirectory(src)
64+
65+
if (QUVIZ_BUILD_EXAMPLES)
66+
add_subdirectory(examples)
67+
endif()

examples/CMakeLists.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
include_directories(${GIFANIM_INCLUDE_DIR} ${QUVIZ_DIR}/src)
2+
3+
file(GLOB SRCFILES
4+
"../src/util/*.cpp"
5+
"../src/IO/*.cpp"
6+
"../src/shapes/*.cpp"
7+
"../src/lattices/*.cpp"
8+
"../src/molecules/*.cpp"
9+
"../src/fonts/*.cpp"
10+
"../src/render/*.cpp"
11+
)
12+
13+
if (LIBIGL_WITH_EMBREE AND LIBIGL_WITH_PNG)
14+
add_subdirectory(gif)
15+
add_subdirectory(png)
16+
endif()
17+
18+
if (LIBIGL_WITH_EMBREE AND LIBIGL_WITH_PNG)
19+
add_subdirectory(stl)
20+
endif()
21+
22+
if (LIBIGL_WITH_OPENGL AND LIBIGL_WITH_OPENGL_GLFW AND LIBIGL_WITH_OPENGL_GLFW_IMGUI AND LIBIGL_WITH_PNG)
23+
add_subdirectory(viewer)
24+
endif()
File renamed without changes.

examples/gif/gif.cpp

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#include <cstdint>
2+
#include <algorithm>
3+
#include <iostream>
4+
5+
#include <igl/png/render_to_png.h>
6+
#include <igl/png/writePNG.h>
7+
#include <igl/embree/EmbreeRenderer.h>
8+
9+
#include "util/Export.h"
10+
#include "IO/Io.h"
11+
12+
#include "shapes/Tube.h"
13+
#include "shapes/Sphere.h"
14+
15+
#include "molecules/C60.h"
16+
#include "molecules/SOD20.h"
17+
#include "molecules/SOD60.h"
18+
#include "molecules/Drawing.h"
19+
20+
Eigen::Matrix<double,Eigen::Dynamic,3> V;
21+
Eigen::Matrix<int,Eigen::Dynamic,3> F;
22+
Eigen::Matrix<double,Eigen::Dynamic,3> C;
23+
24+
int main(int argc, char* argv[])
25+
{
26+
std::string example_data = "/home/user/__LIBS__/QuViz/example-data";
27+
C60 mol;
28+
auto [pos1, obs1] = IO::loadSiteObs(example_data + "/C60_triplet_S.dat");
29+
auto [start, end, Scorr] = IO::loadBondObs(example_data + "/C60_triplet_Scorr.dat");
30+
Mol::plotSiteObs(mol, pos1, obs1, V, F, C, vivid::ColorMap::Preset::Viridis);
31+
Mol::plotBondObs(mol, start, end, Scorr, V, F, C);
32+
Mol::drawFaces(mol, V, F, C);
33+
34+
std::cout << V.rows() << ", " << F.rows() << ", " << C.rows() << std::endl;
35+
36+
// Plot the mesh
37+
igl::embree::EmbreeRenderer er;
38+
er.set_mesh(V, F, true);
39+
er.set_colors(C);
40+
er.set_zoom(1.2);
41+
er.set_orthographic(false);
42+
Point translation;
43+
translation << 0., 0., -0.5;
44+
er.set_translation(translation);
45+
46+
FileFormats::GifOptions gifOptions;
47+
gifOptions.framedelay = 5;
48+
gifOptions.loopcount = 2;
49+
Eigen::Vector3d axis = (std::sqrt(1. / 9.) * Eigen::Vector3d::UnitY() + std::sqrt(3. / 9.) * Eigen::Vector3d::UnitY() +
50+
std::sqrt(5. / 9.) * Eigen::Vector3d::UnitZ());
51+
axis /= axis.norm();
52+
Export::GIF(mol.name() + ".gif", gifOptions, 100, axis, er);
53+
}

examples/png/.#png.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
user@UHH.1599:1617695758
File renamed without changes.

examples/png/png.cpp

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#include <cstdint>
2+
#include <algorithm>
3+
#include <iostream>
4+
5+
#include <igl/png/render_to_png.h>
6+
#include <igl/png/writePNG.h>
7+
#include <igl/embree/EmbreeRenderer.h>
8+
9+
#include "util/ColorLegend.h"
10+
#include "util/Export.h"
11+
#include "IO/Io.h"
12+
13+
#include "shapes/Tube.h"
14+
#include "shapes/Sphere.h"
15+
16+
#include "molecules/C60.h"
17+
#include "molecules/SOD20.h"
18+
#include "molecules/SOD60.h"
19+
#include "molecules/Drawing.h"
20+
21+
Eigen::Matrix<double,Eigen::Dynamic,3> V;
22+
Eigen::Matrix<int,Eigen::Dynamic,3> F;
23+
Eigen::Matrix<double,Eigen::Dynamic,3> C;
24+
25+
int main(int argc, char* argv[])
26+
{
27+
std::string example_data = "/home/user/__LIBS__/QuViz/example-data";
28+
C60 mol;
29+
mol.colors_f.resize(mol.faces.size());
30+
for(std::size_t i = 0; i < mol.faces.size(); i++) { mol.colors_f[i] = (i < 14) ? vivid::Color("grey") : vivid::Color("blue"); }
31+
auto [pos1, obs1] = IO::loadSiteObs(example_data + "/C60_triplet_S.dat");
32+
auto [start, end, Scorr] = IO::loadBondObs(example_data + "/C60_triplet_Scorr.dat");
33+
Mol::plotSiteObs(mol, pos1, obs1, V, F, C, vivid::ColorMap::Preset::Viridis);
34+
Mol::plotBondObs(mol, start, end, Scorr, V, F, C);
35+
Mol::drawVertices(mol, V, F, C);
36+
Mol::drawFaces(mol, V, F, C);
37+
38+
// Plot the mesh
39+
igl::embree::EmbreeRenderer er;
40+
er.set_mesh(V, F, true);
41+
er.set_colors(C);
42+
er.set_zoom(1.5);
43+
er.set_orthographic(false);
44+
Point translation;
45+
translation << 0., 0., -0.5;
46+
er.set_translation(translation);
47+
48+
FileFormats::PNGOptions pngOptions;
49+
Export::PNG("legend_SdagS.png", pngOptions, 0., 1. / std::sqrt(2.) * (Eigen::Vector3d::UnitY() + Eigen::Vector3d::UnitX()), er);
50+
}

examples/stl/CMakeLists.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
add_executable(createSTL stl.cpp ${SRCFILES})
2+
3+
# add_dependencies(
4+
# createSTL
5+
# gifanim)
6+
7+
target_link_libraries(
8+
createSTL
9+
project_options
10+
project_warnings
11+
igl::core
12+
vivid
13+
hdf5
14+
hdf5_cpp)

src/examples/png/png.cpp renamed to examples/stl/stl.cpp

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,15 @@
22
#include <algorithm>
33
#include <iostream>
44

5-
#include <igl/png/render_to_png.h>
6-
#include <igl/png/writePNG.h>
7-
#include <igl/embree/EmbreeRenderer.h>
5+
#include <igl/writeSTL.h>
86

9-
#include "util/Export.h"
107
#include "IO/Io.h"
118

129
#include "shapes/Tube.h"
1310
#include "shapes/Sphere.h"
1411

1512
#include "molecules/C60.h"
13+
#include "molecules/SOD20.h"
1614
#include "molecules/Drawing.h"
1715

1816
Eigen::Matrix<double,Eigen::Dynamic,3> V;
@@ -21,27 +19,21 @@ Eigen::Matrix<double,Eigen::Dynamic,3> C;
2119

2220
int main(int argc, char *argv[])
2321
{
24-
std::string example_data = "/home/user/__LIBS__/QuViz/example-data";
2522
// C60 mol;
2623
SOD20 mol;
24+
mol.colors_f.resize(30);
25+
for (std::size_t i=0; i<30; i++) {
26+
mol.colors_f[i] = (i<6) ? vivid::Color("grey") : vivid::Color("blue");
27+
}
2728
// auto [pos1,obs1] = IO::loadSiteObs(example_data+"/C60_triplet_S.dat");
2829
// auto [start, end, Scorr] = IO::loadBondObs(example_data+"/C60_triplet_Scorr.dat");
2930
// Mol::plotSiteObs(mol,pos1,obs1,V,F,C,vivid::ColorMap::Preset::Viridis);
3031
// Mol::plotBondObs(mol,start,end,Scorr,V,F,C);
31-
// Mol::drawFaces(mol,V,F,C);
3232
Mol::drawVertices(mol,V,F,C);
33+
Mol::drawFaces(mol,V,F,C);
3334

3435
std::cout << V.rows() << ", " << F.rows() << ", " << C.rows() << std::endl;
3536

36-
// Plot the mesh
37-
igl::embree::EmbreeRenderer er;
38-
er.set_mesh(V,F,true);
39-
er.set_colors(C);
40-
er.set_zoom(1.5);
41-
er.set_orthographic(false);
42-
Point translation; translation << 0.,0.,-0.5;
43-
er.set_translation(translation);
44-
45-
FileFormats::PNGOptions pngOptions;
46-
Export::PNG("C60.png", pngOptions, 0., 1./std::sqrt(2.)*(Eigen::Vector3d::UnitY()+Eigen::Vector3d::UnitX()), er);
37+
// Export the mesh to stl
38+
igl::writeSTL(mol.name()+".stl", V, F);
4739
}

0 commit comments

Comments
 (0)