Skip to content

Commit 7cd63fe

Browse files
mpoudotnicolaslg
authored andcommitted
Temporary commit
1 parent 49c5a09 commit 7cd63fe

6 files changed

Lines changed: 150 additions & 67 deletions

File tree

src/Core/Geom/OCCHelper.cpp

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,17 +1002,60 @@ computeArea(const TopoDS_Shape& volume)
10021002
void OCCHelper::
10031003
computeBoundingBox(const TopoDS_Shape& shape, gp_Pnt& pmin, gp_Pnt& pmax)
10041004
{
1005+
Bnd_Box box0;
1006+
double xmin, ymin, zmin, xmax, ymax, zmax;
1007+
BRepBndLib::Add(shape, box0);
1008+
box0.Get(xmin, ymin, zmin, xmax, ymax, zmax);
1009+
std::cout << "Avec Add : box(["<<xmin<<", "<<ymin<<", "<<zmin<<"],["<<xmax<<", "<<ymax<<", "<<zmax<<"])"<<std::endl;
1010+
1011+
Bnd_Box box4;
1012+
BRepBndLib::Add(shape, box4, false);
1013+
box4.Get(xmin, ymin, zmin, xmax, ymax, zmax);
1014+
std::cout << "Avec Add false : box(["<<xmin<<", "<<ymin<<", "<<zmin<<"],["<<xmax<<", "<<ymax<<", "<<zmax<<"])"<<std::endl;
1015+
1016+
Bnd_Box box5;
1017+
BRepBndLib::Add(shape, box5);
1018+
box5.SetGap(0.0);
1019+
box5.Get(xmin, ymin, zmin, xmax, ymax, zmax);
1020+
std::cout << "Avec Add set Gap à 0 : box(["<<xmin<<", "<<ymin<<", "<<zmin<<"],["<<xmax<<", "<<ymax<<", "<<zmax<<"])"<<std::endl;
1021+
1022+
Bnd_Box box1;
1023+
BRepBndLib::AddClose(shape, box1);
1024+
box1.Get(xmin, ymin, zmin, xmax, ymax, zmax);
1025+
std::cout << "Avec AddClose: box(["<<xmin<<", "<<ymin<<", "<<zmin<<"],["<<xmax<<", "<<ymax<<", "<<zmax<<"])"<<std::endl;
1026+
1027+
Bnd_Box box2;
1028+
BRepBndLib::AddOptimal(shape, box2);
1029+
box2.Get(xmin, ymin, zmin, xmax, ymax, zmax);
1030+
std::cout << "Avec AddOptimal : box(["<<xmin<<", "<<ymin<<", "<<zmin<<"],["<<xmax<<", "<<ymax<<", "<<zmax<<"])"<<std::endl;
1031+
1032+
Bnd_Box box3;
1033+
BRepBndLib::AddOptimal(shape, box3, false, false);
1034+
box3.Get(xmin, ymin, zmin, xmax, ymax, zmax);
1035+
std::cout << "Avec AddOptimal false false : box(["<<xmin<<", "<<ymin<<", "<<zmin<<"],["<<xmax<<", "<<ymax<<", "<<zmax<<"])"<<std::endl;
1036+
1037+
Bnd_Box box6;
1038+
BRepBndLib::AddOptimal(shape, box6, false, false);
1039+
box6.Get(xmin, ymin, zmin, xmax, ymax, zmax);
1040+
box6.SetGap(0.0);
1041+
std::cout << "Avec AddOptimal false false setGap à 0 : box(["<<xmin<<", "<<ymin<<", "<<zmin<<"],["<<xmax<<", "<<ymax<<", "<<zmax<<"])"<<std::endl;
1042+
10051043
Bnd_Box box;
1044+
/*
10061045
BRepCheck_Analyzer analyzer(shape);
1007-
10081046
if (analyzer.IsValid()) {
1047+
std::cout << "On utilise AddClose" << std::endl;
10091048
BRepBndLib::AddClose(shape, box);
1049+
box.Get(xmin, ymin, zmin, xmax, ymax, zmax);
1050+
std::cout << "Dans le if: box(["<<xmin<<", "<<ymin<<", "<<zmin<<"],["<<xmax<<", "<<ymax<<", "<<zmax<<"])"<<std::endl;
10101051
} else {
1052+
std::cout << "On utilise AddOptimal" << std::endl;
10111053
BRepBndLib::AddOptimal(shape, box);
10121054
}
10131055
10141056
if (box.IsVoid())
10151057
{
1058+
std::cout << "On utilise Add" << std::endl;
10161059
BRepBndLib::Add(shape, box);
10171060
}
10181061
@@ -1032,11 +1075,19 @@ computeBoundingBox(const TopoDS_Shape& shape, gp_Pnt& pmin, gp_Pnt& pmax)
10321075
// Vérifier si l'une des dimensions est nulle ou quasi-nulle
10331076
double tolerance = 1e-7;
10341077
if (width < tolerance || height < tolerance || depth < tolerance) {
1078+
std::cout << "On utilise Add" << std::endl;
10351079
BRepBndLib::Add(shape, box);
10361080
}
10371081
}
1038-
double xmin, ymin, zmin, xmax, ymax, zmax;
1082+
*/
1083+
//BRepBndLib::AddOptimal(shape, box);
1084+
BRepBndLib::AddOptimal(shape, box);
1085+
box.SetGap(0.0);
1086+
1087+
//double xmin, ymin, zmin, xmax, ymax, zmax;
10391088
box.Get(xmin, ymin, zmin, xmax, ymax, zmax);
1089+
std::cout << "Au final: box(["<<xmin<<", "<<ymin<<", "<<zmin<<"],["<<xmax<<", "<<ymax<<", "<<zmax<<"])"<<std::endl;
1090+
10401091
pmin.SetCoord(xmin, ymin, zmin);
10411092
pmax.SetCoord(xmax, ymax, zmax);
10421093
}

test_link/test_bounding_box.py

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
import math
2+
import os
3+
import pyMagix3D as Mgx3D
4+
import pytest
5+
6+
step_file_name = "mambo/Basic/B18.step"
7+
8+
def assertPoint(tm, name, x, y, z):
9+
p = tm.getCoord(name)
10+
assert math.isclose(p.getX(), x, rel_tol=1e-10)
11+
assert math.isclose(p.getY(), y, rel_tol=1e-10)
12+
assert math.isclose(p.getZ(), z, rel_tol=1e-10)
13+
14+
# Issue 225 : Le bloc créé par boite englobante d'un volume peut avoir de mauvaises dimensions
15+
def test_issue225(capfd):
16+
ctx = Mgx3D.getStdContext()
17+
ctx.clearSession() # Clean the session after the previous test
18+
gm = ctx.getGeomManager()
19+
tm = ctx.getTopoManager ()
20+
21+
magix3d_test_data_dir = os.environ['MAGIX3D_TEST_DATA_DIR']
22+
full_path = os.path.join(magix3d_test_data_dir, step_file_name)
23+
24+
ctx.setLengthUnit(Mgx3D.Unit.centimeter)
25+
gm.importSTEP(full_path)
26+
assert gm.getNbVolumes()==1
27+
tm.newFreeTopoOnGeometry("Vol0000")
28+
assert math.isclose(tm.getEdgeLength("Ar0002"), 0.1, abs_tol=1e-7) #0.1
29+
assert math.isclose(tm.getEdgeLength("Ar0007"), 0.1, abs_tol=1e-7) #0.10003610119179525
30+
assert math.isclose(tm.getEdgeLength("Ar0009"), 0.05, abs_tol=1e-7) #0.05000000000000623
31+
32+
# Issue 262 : Le bloc créé par boite englobante d'un volume peut avoir de mauvaises dimensions
33+
# la création d'un bloc sur une sphère crée un bloc plat
34+
def test_issue262():
35+
ctx = Mgx3D.getStdContext()
36+
ctx.clearSession() # Clean the session after the previous test
37+
gm = ctx.getGeomManager()
38+
tm = ctx.getTopoManager()
39+
# Création du volume Vol0000
40+
gm.newSphere (Mgx3D.Point(0, 0, 0), 1, Mgx3D.Portion.ENTIER)
41+
# Création d'un bloc topologique structuré sans projection (Vol0000)
42+
tm.newFreeTopoOnGeometry ("Vol0000")
43+
44+
assertPoint(tm, "Som0000", -1, -1, -1)
45+
assertPoint(tm, "Som0007", 1, 1, 1)
46+
47+
# Annulation de : Création d'un bloc topologique structuré sans projection (Vol0000)
48+
ctx.undo()
49+
# Création d'un bloc unitaire mis dans le groupe AAA
50+
ctx.getTopoManager().newFreeBoundedTopoInGroup ("AAA", 3, ["Vol0000"])
51+
52+
assertPoint(tm, "Som0000", -1, -1, -1)
53+
assertPoint(tm, "Som0007", 1, 1, 1)
54+
55+
def test_freeboundedtopoForPoints():
56+
ctx = Mgx3D.getStdContext()
57+
ctx.clearSession() # Clean the session after the previous test
58+
gm = ctx.getGeomManager ()
59+
tm = ctx.getTopoManager ()
60+
61+
gm.newVertex(Mgx3D.Point(-1.8, -.7, 1.2))
62+
gm.newVertex(Mgx3D.Point(-.7, .45, -.1))
63+
tm.newFreeBoundedTopoInGroup ("aaa", 3, ["Pt0000","Pt0001"])
64+
assertPoint(tm, "Som0007", -0.7, 0.45, 1.2)
65+
66+
def test_freeboundedtopoForSphere():
67+
ctx = Mgx3D.getStdContext()
68+
ctx.clearSession() # Clean the session after the previous test
69+
gm = ctx.getGeomManager ()
70+
tm = ctx.getTopoManager ()
71+
72+
gm.newSphere (Mgx3D.Point(0, 0, 0), 1, 150)
73+
tm.newFreeTopoOnGeometry ("Vol0000")
74+
assertPoint(tm, "Som0007", 1.0, 1.0, 1.0)
75+
76+
def test_freeboundedtopoForCylinder():
77+
ctx = Mgx3D.getStdContext()
78+
ctx.clearSession() # Clean the session after the previous test
79+
gm = ctx.getGeomManager ()
80+
tm = ctx.getTopoManager ()
81+
82+
gm.newCylinder (Mgx3D.Point(0, 0, 0), 1, Mgx3D.Vector(10, 0, 0), 360)
83+
tm.newFreeTopoOnGeometry ("Vol0000")
84+
assertPoint(tm, "Som0007", 10, 1.0, 1.0)
85+
86+
def test_bounding_box_with_scale():
87+
ctx = Mgx3D.getStdContext()
88+
ctx.clearSession() # Clean the session after the previous test
89+
gm = ctx.getGeomManager ()
90+
tm = ctx.getTopoManager ()
91+
92+
gm.newSphere (Mgx3D.Point(0, 0, 0), 1, 125)
93+
gm.scaleAll(10, 20, 10)
94+
tm.newFreeTopoOnGeometry ("Vol0000")
95+
assertPoint(tm, "Som0007", 10.0, 20.0, 10.0)

test_link/test_free_bounded_topo.py

Lines changed: 0 additions & 16 deletions
This file was deleted.

test_link/test_issue225.py

Lines changed: 0 additions & 21 deletions
This file was deleted.

test_link/test_issue262.py

Lines changed: 0 additions & 28 deletions
This file was deleted.

test_link/test_order_join_curves.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import pyMagix3D as Mgx3D
22

3+
# Issue 228 : L'ordre des entités créées par la commande sectionByPlane peut varier d'une exécution à l'autre
4+
# Corrigé par le nouveau calcul de boite englobante
35
def test_order_join_curves():
46
ctx = Mgx3D.getStdContext()
57
ctx.clearSession() # Clean the session after the previous test

0 commit comments

Comments
 (0)