Skip to content

Commit 0c695dc

Browse files
committed
medialaxis: dev from nancy
1 parent e94a55c commit 0c695dc

31 files changed

Lines changed: 12654 additions & 2190 deletions

core/ig/inc/gmds/ig/Face.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,13 @@ namespace gmds{
116116
*/
117117
TCoord area() const;
118118

119+
/*------------------------------------------------------------------------*/
120+
/** \brief Compute the signed area of the face
121+
*
122+
* \return the signed area of the face
123+
*/
124+
TCoord signedArea() const;
125+
119126
/*------------------------------------------------------------------------*/
120127
/** \brief Compute the scaled jacobian of the face
121128
*

core/ig/src/Face.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,38 @@ namespace gmds {
157157
}
158158
}
159159
/*----------------------------------------------------------------------------*/
160+
TCoord
161+
Face::signedArea() const {
162+
math::Vector3d n;
163+
std::vector<Node> nodes = this->get<Node>();
164+
auto nb_nodes = nodes.size();
165+
166+
if (nb_nodes == 3) {
167+
168+
Node n1 = nodes[0];
169+
Node n2 = nodes[1];
170+
Node n3 = nodes[2];
171+
math::Triangle t(n1.point(),n2.point(),n3.point());
172+
return t.signedArea();
173+
174+
} else if (nb_nodes == 4) {
175+
math::Point p1 = nodes[0].point();
176+
math::Point p2 = nodes[1].point();
177+
math::Point p3 = nodes[2].point();
178+
math::Point p4 = nodes[3].point();
179+
math::Point c = center();
180+
math::Triangle t1(p1,p2,c);
181+
math::Triangle t2(p2,p3,c);
182+
math::Triangle t3(p3,p4,c);
183+
math::Triangle t4(p4,p1,c);
184+
185+
return t1.signedArea()+t2.signedArea()+t3.signedArea()+t4.signedArea();
186+
} else {
187+
throw GMDSException("Not yet implemented!");
188+
189+
}
190+
}
191+
/*----------------------------------------------------------------------------*/
160192
math::Point
161193
Face::center() const
162194
{

modules/medialaxis/CMakeLists.txt

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@ set(GMDS_INC
1313
inc/gmds/medialaxis/MedialAxis3D.h
1414
inc/gmds/medialaxis/MedialAxis3DBuilder.h
1515
inc/gmds/medialaxis/CrossField.h
16+
inc/gmds/medialaxis/NonConformalHalfEdge.h
17+
inc/gmds/medialaxis/QuantizationSolver.h
18+
inc/gmds/medialaxis/QuantizationGraph.h
19+
inc/gmds/medialaxis/ConformalMeshBuilder.h
20+
inc/gmds/medialaxis/BlockStructureSimplifier.h
21+
inc/gmds/medialaxis/MinDelaunayCleaner.h
22+
inc/gmds/medialaxis/Conformalizer.h
23+
inc/gmds/medialaxis/MedaxBasedTMeshBuilder.h
24+
inc/gmds/medialaxis/TrianglesRemover.h
1625
)
1726
set(GMDS_SRC
1827
src/MedialAxis2D.cpp
@@ -22,11 +31,14 @@ set(GMDS_SRC
2231
src/MedialAxis3DBuilder.cpp
2332
src/CrossField.cpp
2433
src/NonConformalHalfEdge.cpp
25-
inc/gmds/medialaxis/NonConformalHalfEdge.h
26-
src/QuantizationSolver.cpp
27-
inc/gmds/medialaxis/QuantizationSolver.h
34+
src/QuantizationSolver.cpp
2835
src/QuantizationGraph.cpp
29-
inc/gmds/medialaxis/QuantizationGraph.h
36+
src/ConformalMeshBuilder.cpp
37+
src/BlockStructureSimplifier.cpp
38+
src/MinDelaunayCleaner.cpp
39+
src/Conformalizer.cpp
40+
src/MedaxBasedTMeshBuilder.cpp
41+
src/TrianglesRemover.cpp
3042
)
3143
#==============================================================================
3244
add_library(${GMDS_LIB} ${GMDS_INC} ${GMDS_SRC})
Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
#ifndef GMDS_BLOCKSTRUCTURESIMPLIFIER_H
2+
#define GMDS_BLOCKSTRUCTURESIMPLIFIER_H
3+
/*----------------------------------------------------------------------------*/
4+
#include "LIB_GMDS_MEDIALAXIS_export.h"
5+
#include "gmds/medialaxis/MedialAxis2D.h"
6+
#include "gmds/medialaxis/NonConformalHalfEdge.h"
7+
#include "gmds/medialaxis/MedialAxisMath.h"
8+
#include "gmds/medialaxis/QuantizationGraph.h"
9+
#include "gmds/io/IGMeshIOService.h"
10+
#include "gmds/io/VTKWriter.h"
11+
#include "gmds/ig/MeshDoctor.h"
12+
#include <gmds/ig/Mesh.h>
13+
/*----------------------------------------------------------------------------*/
14+
namespace gmds{
15+
/** \class dummy
16+
* \brief dummy class.
17+
*/
18+
class LIB_GMDS_MEDIALAXIS_API BlockStructureSimplifier
19+
{
20+
private:
21+
// Non conformal quad block decomposition
22+
Mesh* m_mesh;
23+
// Corresponding non-conformal half edges
24+
std::vector<NonConformalHalfEdge> m_half_edges;
25+
// Quantization graph
26+
QuantizationGraph* m_quantization_graph;
27+
// Half edges length
28+
std::vector<int> m_half_edges_lengths;
29+
// Mesh after removing half edges of length zero
30+
Mesh* m_simplified_mesh;
31+
32+
public:
33+
34+
/*-------------------------------------------------------------------------*/
35+
/** @brief Constructor.
36+
* @param AMesh
37+
*/
38+
explicit BlockStructureSimplifier(Mesh &AMesh);
39+
40+
/*-------------------------------------------------------------------------*/
41+
/** @brief Default destructor.
42+
* @param
43+
*/
44+
virtual ~BlockStructureSimplifier()=default;
45+
46+
/*-------------------------------------------------------------------------*/
47+
/** @brief Getters.
48+
* @param
49+
*/
50+
std::vector<NonConformalHalfEdge> halfEdges(){return m_half_edges;}
51+
std::vector<int> halfEdgesLengths(){return m_half_edges_lengths;}
52+
53+
/*-------------------------------------------------------------------------*/
54+
/** @brief Build the half edges.
55+
* @param
56+
*/
57+
void buildHalfEdges();
58+
59+
/*-------------------------------------------------------------------------*/
60+
/** @brief Build the quantization graph nodes.
61+
* @param
62+
*/
63+
void buildQuantizationGraphNodes();
64+
65+
/*-------------------------------------------------------------------------*/
66+
/** @brief Build the connected component of the given half edge.
67+
* @param AHalfEdgeID an half edge ID
68+
*/
69+
void buildConnectedComponent(int AHalfEdgeID);
70+
71+
/*-------------------------------------------------------------------------*/
72+
/** @brief Return the next of the next half edge of the given half edge.
73+
* @param AHalfEdgeID an half edge ID
74+
*/
75+
int oppositeInQuad(int AHalfEdgeID);
76+
77+
/*-------------------------------------------------------------------------*/
78+
/** @brief Build the connected component graph.
79+
* @param
80+
*/
81+
void buildQuantizationGraph();
82+
83+
/*-------------------------------------------------------------------------*/
84+
/** @brief Get the quantization graph.
85+
* @param
86+
*/
87+
QuantizationGraph* getQuantizationGraph();
88+
89+
/*-------------------------------------------------------------------------*/
90+
/** @brief Set half edges length.
91+
* @param
92+
*/
93+
void setHalfEdgesLength();
94+
95+
/*-------------------------------------------------------------------------*/
96+
/** @brief Return the set of sides of the input geometry, each side being a set of half-edge Ids.
97+
* @param
98+
*/
99+
std::vector<std::vector<TCellID>> sides();
100+
101+
/*-------------------------------------------------------------------------*/
102+
/** @brief Mark the T-junctions.
103+
* @param
104+
*/
105+
void markTJunctions();
106+
107+
/*-------------------------------------------------------------------------*/
108+
/** @brief Return true if the given node is on the boundary.
109+
* @param
110+
*/
111+
bool isOnBoundary(Node AN);
112+
113+
/*-------------------------------------------------------------------------*/
114+
/** @brief Return the set of half-edges that must be non zero, ie that are adjacent to a singularity.
115+
* @param
116+
*/
117+
std::vector<TCellID> nonZeroHalfEdges();
118+
119+
/*-------------------------------------------------------------------------*/
120+
/** @brief Return the set of groups of nodes, each group being a set of nodes connected by half-edges of length 0.
121+
* @param
122+
*/
123+
std::vector<std::vector<Node>> groupsOfConfundedNodes();
124+
125+
/*-------------------------------------------------------------------------*/
126+
/** @brief Return true if the given node is a corner of the boundary.
127+
* @param
128+
*/
129+
bool isABoundaryCorner(Node AN);
130+
131+
/*-------------------------------------------------------------------------*/
132+
/** @brief Compute the disappearance gain for each node.
133+
* @param
134+
*/
135+
void computeChosingGains();
136+
137+
/*-------------------------------------------------------------------------*/
138+
/** @brief Return a representative for the given group of confunded nodes.
139+
* @param AV
140+
*/
141+
Node representative(std::vector<Node> AV);
142+
143+
/*-------------------------------------------------------------------------*/
144+
/** @brief Build the simplified mesh.
145+
* @param
146+
*/
147+
void buildSimplifiedMesh();
148+
149+
/*-------------------------------------------------------------------------*/
150+
/** @brief Set the connectivity of the simplified mesh.
151+
* @param
152+
*/
153+
void setSimplifiedMeshConnectivity();
154+
155+
/*-------------------------------------------------------------------------*/
156+
/** @brief Get the simplified mesh.
157+
* @param
158+
*/
159+
Mesh getSimplifiedMesh();
160+
161+
/*-------------------------------------------------------------------------*/
162+
/** @brief Write the simplified mesh.
163+
* @param
164+
*/
165+
void writeSimplifiedMesh(std::basic_string<char> AFileName);
166+
167+
/*-------------------------------------------------------------------------*/
168+
/** @brief Execute.
169+
* @param
170+
*/
171+
void execute();
172+
173+
/*-------------------------------------------------------------------------*/
174+
/** @brief Attach 1 to edges belonging to separatricies.
175+
* @param
176+
*/
177+
void markSeparatrices();
178+
179+
/*-------------------------------------------------------------------------*/
180+
/** @brief Attach to each face the id of the block it belongs to.
181+
* @param
182+
*/
183+
void setBlocksIDs();
184+
185+
/*-------------------------------------------------------------------------*/
186+
/** @brief Trace the outlines of the TopMaker blocks.
187+
* @param
188+
*/
189+
void traceTopMakerBlocksOutlines();
190+
191+
/*-------------------------------------------------------------------------*/
192+
/** @brief Attach to each face the id of the TopMaker block it belongs to.
193+
* @param
194+
*/
195+
void setTopMakerBlocksIDs();
196+
};
197+
/*----------------------------------------------------------------------------*/
198+
} // end namespace gmds
199+
/*----------------------------------------------------------------------------*/
200+
#endif // GMDS_BLOCKSTRUCTURESIMPLIFIER_H
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
#ifndef GMDS_CONFORMALMESHBUILDER_H
2+
#define GMDS_CONFORMALMESHBUILDER_H
3+
/*----------------------------------------------------------------------------*/
4+
#include "LIB_GMDS_MEDIALAXIS_export.h"
5+
#include "gmds/medialaxis/NonConformalHalfEdge.h"
6+
#include "gmds/medialaxis/MedialAxisMath.h"
7+
#include "gmds/io/IGMeshIOService.h"
8+
#include "gmds/io/VTKWriter.h"
9+
#include "gmds/ig/MeshDoctor.h"
10+
#include <gmds/ig/Mesh.h>
11+
/*----------------------------------------------------------------------------*/
12+
namespace gmds{
13+
/** \class dummy
14+
* \brief dummy class.
15+
*/
16+
class LIB_GMDS_MEDIALAXIS_API ConformalMeshBuilder
17+
{
18+
private:
19+
// Non conformal quad block decomposition
20+
Mesh* m_mesh;
21+
// Corresponding non-conformal half edges
22+
std::vector<NonConformalHalfEdge> m_half_edges;
23+
// Half edges length
24+
std::vector<int> m_half_edges_lengths;
25+
// Quantized mesh
26+
Mesh* m_quantized_mesh;
27+
// New nodes corresponding to half edges
28+
std::vector<std::vector<TCellID>> m_half_edges_to_new_nodes;
29+
30+
public:
31+
32+
/*-------------------------------------------------------------------------*/
33+
/** @brief Constructor.
34+
* @param AMesh
35+
*/
36+
explicit ConformalMeshBuilder(Mesh &AMesh, std::vector<NonConformalHalfEdge> AHalfEdges, std::vector<int> ALengths);
37+
38+
/*-------------------------------------------------------------------------*/
39+
/** @brief Default destructor.
40+
* @param
41+
*/
42+
virtual ~ConformalMeshBuilder()=default;
43+
44+
/*-------------------------------------------------------------------------*/
45+
/** @brief Write the quantized mesh.
46+
* @param
47+
*/
48+
void writeQuantizedMesh(std::basic_string<char> AFileName);
49+
50+
/*-------------------------------------------------------------------------*/
51+
/** @brief Get the quantized mesh.
52+
* @param
53+
*/
54+
Mesh getQuantizedMesh();
55+
56+
/*-------------------------------------------------------------------------*/
57+
/** @brief Set the connectivity of the quantized mesh.
58+
* @param
59+
*/
60+
void setQuantizedMeshConnectivity();
61+
62+
/*-------------------------------------------------------------------------*/
63+
/** @brief Build the nodes of the quantized mesh that are on edges of the non-conformal mesh.
64+
* @param
65+
*/
66+
void buildQuantizedMeshNodesOnEdges();
67+
68+
/*-------------------------------------------------------------------------*/
69+
/** @brief Build the nodes of the quantized mesh that are internal to the faces of the non-conformal mesh.
70+
* @param
71+
*/
72+
void buildQuantizedMeshInternalNodes();
73+
74+
/*-------------------------------------------------------------------------*/
75+
/** @brief Build quantized mesh faces.
76+
* @param
77+
*/
78+
void buildQuantizedMeshFaces();
79+
80+
/*-------------------------------------------------------------------------*/
81+
/** @brief Build the group of half edges.
82+
* @param AID, AV a half edge ID and a vector to mark already seen half edges
83+
*/
84+
std::vector<std::vector<int>> halfEdgesGroup(int AID, std::vector<int> &AV);
85+
86+
/*-------------------------------------------------------------------------*/
87+
/** @brief Build the groups of half edges.
88+
* @param
89+
*/
90+
std::vector<std::vector<std::vector<int>>> halfEdgesGroups();
91+
92+
/*-------------------------------------------------------------------------*/
93+
/** @brief Execute.
94+
* @param
95+
*/
96+
void execute();
97+
98+
};
99+
/*----------------------------------------------------------------------------*/
100+
} // end namespace gmds
101+
/*----------------------------------------------------------------------------*/
102+
#endif // GMDS_CONFORMALMESHBUILDER_H

0 commit comments

Comments
 (0)