-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathStaircaseMesher.cpp
More file actions
105 lines (74 loc) · 2.83 KB
/
Copy pathStaircaseMesher.cpp
File metadata and controls
105 lines (74 loc) · 2.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#include "StaircaseMesher.h"
#include <iostream>
#include "core/Slicer.h"
#include "core/Collapser.h"
#include "core/Staircaser.h"
#include "cgal/filler/Filler.h"
#include "utils/RedundancyCleaner.h"
#include "utils/MeshTools.h"
#include "utils/GridTools.h"
namespace meshlib::meshers {
using namespace utils;
using namespace core;
using namespace meshTools;
StaircaseMesher::StaircaseMesher(const Mesh& inputMesh, int decimalPlacesInCollapser, StaircaseMesherOptions opts) :
MesherBase(inputMesh),
decimalPlacesInCollapser_(decimalPlacesInCollapser),
opts_(opts)
{
log("Preparing surfaces.");
surfaceMesh_ = buildMeshFilteringElements(inputMesh, isNotTetrahedron);
log("Processing surface mesh.");
process(surfaceMesh_);
log("Surface mesh built succesfully.", 1);
}
Mesh StaircaseMesher::buildSurfaceMesh(const Mesh& inputMesh, const Mesh & volumeSurface)
{
auto resultMesh = buildMeshFilteringElements(inputMesh, isNotTetrahedron);
mergeMesh(resultMesh, volumeSurface);
return resultMesh;
}
void StaircaseMesher::process(Mesh& mesh) const
{
const auto slicingGrid{ buildSlicingGrid(originalGrid_, enlargedGrid_) };
if (mesh.countElems() == 0) {
mesh.grid = slicingGrid;
return;
}
auto dimensions = getHighestDimensionByGroup(mesh);
if (opts_.isVolume){
if (meshTools::isAClosedTopology(mesh.groups[0].elements)){
meshlib::cgal::filler::Filler f{ mesh };
auto filling = f.getMeshFilling();
mergeMesh(mesh, filling);
} else {
throw std::runtime_error("Input object marked to be meshed as a volume, but surface is not closed");
}
}
log("Slicing.", 1);
mesh.grid = slicingGrid;
mesh = Slicer{ mesh, dimensions }.getMesh();
logNumberOfTriangles(countMeshElementsIf(mesh, isTriangle));
log("Collapsing.", 1);
mesh = Collapser(mesh, decimalPlacesInCollapser_, dimensions).getMesh();
logNumberOfTriangles(countMeshElementsIf(mesh, isTriangle));
log("Staircasing.", 1);
mesh = Staircaser(mesh).getMesh();
logNumberOfQuads(countMeshElementsIf(mesh, isQuad));
logNumberOfLines(countMeshElementsIf(mesh, isLine));
log("Removing repeated and overlapping elements.", 1);
RedundancyCleaner::removeOverlappedElementsByDimension(mesh, dimensions);
logNumberOfQuads(countMeshElementsIf(mesh, isQuad));
logNumberOfLines(countMeshElementsIf(mesh, isLine));
log("Recovering original grid size.", 1);
reduceGrid(mesh, originalGrid_);
log("Converting relative to absolute coordinates.", 1);
utils::meshTools::convertToAbsoluteCoordinates(mesh);
logNumberOfQuads(countMeshElementsIf(mesh, isQuad));
logNumberOfLines(countMeshElementsIf(mesh, isLine));
}
Mesh StaircaseMesher::mesh() const
{
return surfaceMesh_;
}
}