Skip to content

Commit a61b088

Browse files
committed
Fix bug splitFaces for version 2.6.0
1 parent 871a841 commit a61b088

File tree

5 files changed

+97
-11
lines changed

5 files changed

+97
-11
lines changed

src/Core/Internal/Context.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1879,7 +1879,7 @@ void Context::clearIdToEntity()
18791879
TkUtil::AutoMutex autoMutex (&_entitiesMutex);
18801880
#ifdef _DEBUG
18811881
if (0 != _entities.size ( ))
1882-
std::cerr << __FILE__ << ' ' << __LINE__ << " Context::clearIdToEntity : "
1882+
std::cout << __FILE__ << ' ' << __LINE__ << " Context::clearIdToEntity : "
18831883
<< "la liste contient " << _entities.size ( ) << " entités."
18841884
<< std::endl;
18851885
//showAllEntities(std::cout);

src/Core/Topo/CommandSplitFaces.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ CommandSplitFaces(Internal::Context& c, std::vector<Topo::CoFace* > &cofaces, Co
2323
, m_ratio_dec(ratio_dec)
2424
, m_ratio_ogrid(ratio_ogrid)
2525
, m_project_on_meshing_edges(project_on_meshing_edges)
26+
, m_cas_2D(true)
2627
{
2728
#ifdef _DEBUG_SPLIT
2829
std::cout<<"CommandSplitFaces::CommandSplitFaces("<<cofaces.size()<<" cofaces, "<<arete->getName()<<", "<<ratio_dec<<", "<<ratio_ogrid<<", "<<project_on_meshing_edges<<")"<<std::endl;
@@ -49,6 +50,7 @@ CommandSplitFaces(Internal::Context& c, std::vector<Topo::CoFace* > &cofaces, Co
4950
, m_ratio_dec(0)
5051
, m_ratio_ogrid(ratio_ogrid)
5152
, m_project_on_meshing_edges(project_on_meshing_edges)
53+
, m_cas_2D(true)
5254
{
5355
m_ratio_dec = arete->computeRatio(pt);
5456

@@ -77,6 +79,7 @@ CommandSplitFaces(Internal::Context& c, CoEdge* arete, double ratio_dec, double
7779
, m_ratio_dec(ratio_dec)
7880
, m_ratio_ogrid(ratio_ogrid)
7981
, m_project_on_meshing_edges(project_on_meshing_edges)
82+
, m_cas_2D(true)
8083
{
8184
#ifdef _DEBUG_SPLIT
8285
std::cout<<"CommandSplitFaces::CommandSplitFaces("<<arete->getName()<<", "<<ratio_dec<<", "<<ratio_ogrid<<", "<<project_on_meshing_edges<<")"<<std::endl;
@@ -93,6 +96,7 @@ CommandSplitFaces(Internal::Context& c, CoEdge* arete, const Point& pt, double r
9396
, m_ratio_dec(0)
9497
, m_ratio_ogrid(ratio_ogrid)
9598
, m_project_on_meshing_edges(project_on_meshing_edges)
99+
, m_cas_2D(true)
96100
{
97101
m_ratio_dec = arete->computeRatio(pt);
98102
#ifdef _DEBUG_SPLIT
@@ -114,6 +118,11 @@ void CommandSplitFaces::init(std::vector<Topo::CoFace* > &cofaces)
114118
Topo::CoFace* hcf = *iter;
115119

116120
if (hcf->isStructured()){
121+
if (hcf->getNbFaces()) {
122+
// si hcf est 2D, elle n'a pas de face
123+
// et si au moins une coface est 3D, le cas est 3D
124+
m_cas_2D = false;
125+
}
117126
m_cofaces.push_back(hcf);
118127
verif(hcf);
119128
#ifdef _DEBUG_SPLIT
@@ -290,7 +299,9 @@ internalExecute()
290299

291300
std::vector<Edge*> splitingEdges;
292301

293-
try {
302+
// if (m_cas_2D) {
303+
// TopoHelper::splitFaces(m_cofaces, m_arete, m_ratio_dec, m_ratio_ogrid, false, true, splitingEdges, &getInfoCommand());
304+
// } else {
294305
do {
295306
Vertex* sommet = 0;
296307
CoFace* coface = 0;
@@ -348,10 +359,7 @@ internalExecute()
348359
}
349360

350361
} while (nb_faces_dep != nb_faces_split);
351-
}
352-
catch (const TkUtil::Exception& exc){
353-
throw TkUtil::Exception(exc);
354-
}
362+
//}
355363

356364
// on replace les sommets en fonction de m_ratio_dec
357365
if (!m_project_on_meshing_edges)

src/Core/Topo/TopoHelper.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -712,9 +712,9 @@ void TopoHelper::splitFaces(std::vector<CoFace* > cofaces,
712712
|| coedge_dep->getVertex(1) == arete->getVertex(0)
713713
|| coedge_dep->getVertex(1) == arete->getVertex(1)
714714
|| !boucleDemandee){
715-
boucleTerminee = true;
716-
continue;
717-
}
715+
boucleTerminee = true;
716+
continue;
717+
}
718718
else
719719
throw TkUtil::Exception (TkUtil::UTF8String ("Erreur interne, Topo::splitFaces ne retrouve pas de face commune pour avancer", TkUtil::Charset::UTF_8));
720720
}
@@ -723,7 +723,7 @@ void TopoHelper::splitFaces(std::vector<CoFace* > cofaces,
723723
#endif
724724
// pour ne pas réutiliser cette coface
725725
if (boucleDemandee)
726-
filtre_cofaces[coface] = 2;
726+
filtre_cofaces[coface] = 2;
727727
else if (0 == coface_begin)
728728
coface_begin = coface;
729729

src/Core/protected/Topo/CommandSplitFaces.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ class CommandSplitFaces: public Topo::CommandEditTopo {
108108
/// activation ou non de la projection des sommets créés sur la discrétisation initiale
109109
bool m_project_on_meshing_edges;
110110

111+
/// vrai si le cas ne contient que des cofaces 2D
112+
bool m_cas_2D;
113+
111114
bool
112115
findFaceUnmarkedWithVertexMarked(std::set<CoFace *> &filtre_faces, std::set<Vertex *> &filtre_vertices,
113116
CoFace *&face,

test_link/test_split_faces.py

Lines changed: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,81 @@
11
import pyMagix3D as Mgx3D
22
import math
3+
import pytest
34

5+
def test_extend_split_face():
6+
ctx = Mgx3D.getStdContext()
7+
ctx.clearSession() # Clean the session after the previous test
8+
tm = ctx.getTopoManager()
9+
# Création d'une boite avec une topologie
10+
tm.newBoxWithTopo (Mgx3D.Point(0, 0, 0), Mgx3D.Point(1, 1, 1), 10, 10, 10)
11+
# Découpage de la face Fa0003
12+
tm.splitFace ("Fa0003", "Ar0002", .3, True)
13+
assert tm.getNbFaces() == 7
14+
with pytest.raises(RuntimeError) as excinfo:
15+
# Découpage de la face Fa0001 par prolongation
16+
tm.extendSplitFace ("Fa0001", "Som0007")
17+
expected = "La face ne peut être découpée avec un sommet au sommet de la face (en prendre un sur un côté)"
18+
assert expected in str(excinfo.value)
19+
with pytest.raises(RuntimeError) as excinfo:
20+
# Découpage de la face Fa0002 par prolongation
21+
tm.extendSplitFace ("Fa0002", "Som0009")
22+
expected = "La face ne peut être découpée avec ce sommet, on ne trouve pas d'arête contenant ce sommet"
23+
assert expected in str(excinfo.value)
24+
# Découpage de la face Fa0001 par prolongation
25+
tm.extendSplitFace ("Fa0001", "Som0009")
26+
assert tm.getNbFaces() == 8
27+
28+
def test_extend_split_face_with_degenerated_face():
29+
ctx = Mgx3D.getStdContext()
30+
ctx.clearSession() # Clean the session after the previous test
31+
tm = ctx.getTopoManager()
32+
# Création d'une boite avec une topologie
33+
tm.newBoxWithTopo (Mgx3D.Point(0, 0, 0), Mgx3D.Point(1, 1, 1), 10, 10, 10)
34+
# Suppression d'entités géométriques et suppression des liens topologiques
35+
ctx.getGeomManager().destroy(["Vol0000"], True)
36+
# Destruction des entités topologiques Bl0000
37+
tm.destroy(["Bl0000"], False)
38+
# Découpage de la face Fa0000
39+
tm.splitFace ("Fa0000", "Ar0000", .5, True)
40+
assert tm.getNbFaces() == 7
41+
# Fusion de sommets Som0007 avec Som0006
42+
tm.snapVertices ("Som0007", "Som0006", True)
43+
# Découpage de la face Fa0003 par prolongation
44+
# On est en face de la dégénérescence
45+
tm.extendSplitFace ("Fa0003", "Som0009")
46+
assert tm.getNbFaces() == 8
47+
# Découpage de la face Fa0009
48+
# On n'est pas en face de la dégénérescence mais coupe OK
49+
tm.splitFace ("Fa0009", "Ar0010", .5, True)
50+
assert tm.getNbFaces() == 9
51+
52+
def test_no_more_infinite_loop():
53+
ctx = Mgx3D.getStdContext()
54+
ctx.clearSession() # Clean the session after the previous test
55+
gm = ctx.getGeomManager()
56+
tm = ctx.getTopoManager()
57+
# Création d'une boite avec une topologie
58+
tm.newBoxWithTopo (Mgx3D.Point(0, 0, 0), Mgx3D.Point(1, 1, 1), 10, 10, 10)
59+
# Suppression d'entités géométriques et suppression des liens topologiques
60+
gm.destroy(["Vol0000"], True)
61+
# Destruction des entités topologiques Bl0000
62+
tm.destroy(["Bl0000"], False)
63+
tm.splitFaces (["Fa0005", "Fa0001", "Fa0004", "Fa0000"], "Ar0005", .5, .5)
64+
assert tm.getNbFaces() == 10
65+
66+
def test_split_adjacent_faces_with_common_edge():
67+
ctx = Mgx3D.getStdContext()
68+
ctx.clearSession() # Clean the session after the previous test
69+
tm = ctx.getTopoManager()
70+
# Création d'une boite avec une topologie
71+
ctx.getTopoManager().newBoxWithTopo (Mgx3D.Point(0, 0, 0), Mgx3D.Point(1, 1, 1), 10, 10, 10)
72+
# Suppression d'entités géométriques et suppression des entités topologiques dépendantes
73+
ctx.getGeomManager().destroyWithTopo(["Vol0000"], False)
74+
assert tm.getNbFaces() == 6
75+
# Découpage des faces 2D structurées Fa0005 Fa0001 suivant l'arête Ar0005 avec comme ratio 5.000000e-01
76+
ctx.getTopoManager().splitFaces (["Fa0005","Fa0001"], "Ar0005", .5, .5)
77+
assert tm.getNbFaces() == 8
78+
479
def test_split_faces2D_1(capfd):
580
ctx = Mgx3D.getStdContext()
681
gm = ctx.getGeomManager()
@@ -77,7 +152,7 @@ def test_split_faces2D_4(capfd):
77152
# Suppression d'entités géométriques et suppression des liens topologiques
78153
gm.destroy(["Vol0000"], True)
79154
# Destruction des entités topologiques Bl0000
80-
ctx.getTopoManager ( ).destroy (["Bl0000"], False)
155+
tm.destroy(["Bl0000"], False)
81156
# Découpage de la face Fa0000
82157
tm.splitFaces (["Fa0000"], "Ar0000", .5, 0, True)
83158
assert tm.getNbFaces() == 7

0 commit comments

Comments
 (0)