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
106
107
108
|
//szv#4 S4163
#include <ShapeUpgrade_ShellSewing.ixx>
#include <TopoDS.hxx>
#include <TopoDS_Shell.hxx>
#include <TopoDS_Solid.hxx>
#include <TopExp_Explorer.hxx>
#include <BRepBuilderAPI_Sewing.hxx>
#include <BRepClass3d_SolidClassifier.hxx>
#include <ShapeAnalysis_ShapeTolerance.hxx>
//=======================================================================
//function : ShapeUpgrade_ShellSewing
//purpose :
//=======================================================================
ShapeUpgrade_ShellSewing::ShapeUpgrade_ShellSewing()
{
myReShape = new ShapeBuild_ReShape;
}
//=======================================================================
//function : ApplySewing
//purpose :
//=======================================================================
void ShapeUpgrade_ShellSewing::Init (const TopoDS_Shape& shape)
{
if (shape.IsNull()) return;
if (shape.ShapeType() == TopAbs_SHELL) myShells.Add (shape);
else {
for (TopExp_Explorer exs (shape,TopAbs_SHELL); exs.More(); exs.Next()) {
myShells.Add (exs.Current());
}
}
}
//=======================================================================
//function : Prepare
//purpose :
//=======================================================================
Standard_Integer ShapeUpgrade_ShellSewing::Prepare (const Standard_Real tol)
{
Standard_Integer nb = myShells.Extent(), ns = 0;
for ( Standard_Integer i = 1; i <= nb; i ++) {
TopoDS_Shell sl = TopoDS::Shell ( myShells.FindKey (i) );
BRepBuilderAPI_Sewing ss ( tol );
TopExp_Explorer exp(sl,TopAbs_FACE);
for (; exp.More(); exp.Next()) ss.Add(exp.Current());
ss.Perform();
TopoDS_Shape newsh = ss.SewedShape();
if (!newsh.IsNull()) { myReShape->Replace (sl,newsh); ns ++; }
}
return ns;
}
//=======================================================================
//function : Apply
//purpose :
//=======================================================================
TopoDS_Shape ShapeUpgrade_ShellSewing::Apply (const TopoDS_Shape& shape,
const Standard_Real tol)
{
if ( shape.IsNull() || myShells.Extent() == 0 ) return shape;
TopoDS_Shape res = myReShape->Apply ( shape, TopAbs_FACE, 2 );
// A present orienter les solides correctement
myReShape->Clear();
Standard_Integer ns = 0;
for (TopExp_Explorer exd (shape,TopAbs_SOLID); exd.More(); exd.Next()) {
TopoDS_Solid sd = TopoDS::Solid ( exd.Current() );
BRepClass3d_SolidClassifier bsc3d (sd);
bsc3d.PerformInfinitePoint ( tol );
if (bsc3d.State() == TopAbs_IN) { myReShape->Replace (sd,sd.Reversed()); ns++; }
}
//szv#4:S4163:12Mar99 optimized
if (ns != 0) res = myReShape->Apply( res, TopAbs_SHELL, 2 );
return res;
}
//=======================================================================
//function : ApplySewing
//purpose :
//=======================================================================
TopoDS_Shape ShapeUpgrade_ShellSewing::ApplySewing (const TopoDS_Shape& shape,
const Standard_Real tol)
{
if (shape.IsNull()) return shape;
Standard_Real t = tol;
if (t <= 0.) {
ShapeAnalysis_ShapeTolerance stu;
t = stu.Tolerance (shape,0); // tolerance moyenne
}
Init ( shape );
if ( Prepare ( t ) ) return Apply ( shape, t );
return TopoDS_Shape();
}
|