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
109
110
111
112
113
114
115
116
117
118
|
// File: BRepTest_ShellCommands.cxx
// Created: Mon Dec 21 10:19:27 1998
// Author: Michael KAZAKOV
// <mko@vladox.nnov.matra-dtv.fr>
#include <BRepTest.hxx>
#include <Draw_Interpretor.hxx>
#include <Draw_Appli.hxx>
#include <DBRep.hxx>
#include <BRepTools.hxx>
#include <BRepOffset.hxx>
#include <BRepOffsetAPI_MakeThickSolid.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopoDS_Shape.hxx>
#include <TopExp_Explorer.hxx>
#include <TopAbs.hxx>
#include <BRep_Tool.hxx>
#include <gp_Pnt.hxx>
#include <TopExp_Explorer.hxx>
#include <TopAbs.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS.hxx>
static Standard_Boolean issame(TopoDS_Face& face, TopoDS_Face& newface)
{
TopExp_Explorer exp(face,TopAbs_VERTEX),newexp(newface,TopAbs_VERTEX);
Standard_Integer newcounter=0,counter=0;
for (;exp.More();exp.Next())
{
counter++;
gp_Pnt p(BRep_Tool::Pnt(TopoDS::Vertex(exp.Current())));
for (;newexp.More();newexp.Next())
{
gp_Pnt newp(BRep_Tool::Pnt(TopoDS::Vertex(newexp.Current())));
if (p.IsEqual(newp,1e-7))
{
newcounter++;
break;
};
};
};
if (counter==newcounter)
return Standard_True;
return Standard_False;
}
static TopoDS_Face findface(TopoDS_Shape& shape, TopoDS_Face& face)
{
TopoDS_Face newface;
TopExp_Explorer exp(shape,TopAbs_FACE);
for (;exp.More();exp.Next())
{
newface = TopoDS::Face(exp.Current());
if (issame(face,newface))
{
break;
};
};
return newface;
}
static Standard_Integer shell(Draw_Interpretor& di, Standard_Integer n, const char** a)
{
TopoDS_Shape Shape = DBRep::Get(a[1]);
TopTools_ListOfShape ListOfCorks;
//cout <<"You have "<<n-2<<" of the reference faces" << endl;
di <<"You have "<<n-2<<" of the reference faces" << "\n";
Standard_Integer i=2;
for (;i<n;i++)
{
//cout <<i-1<<"th element"<< endl;
di <<i-1<<"th element"<< "\n";
// ListOfCorks.Append(findface(Shape,TopoDS::Face(DBRep::Get(a[i]))));
TopoDS_Shape aLocalFace(DBRep::Get(a[i]));
ListOfCorks.Append(findface(Shape,(TopoDS_Face &) TopoDS::Face(aLocalFace)));
// ListOfCorks.Append(findface(Shape,(TopoDS_Face &) TopoDS::Face(DBRep::Get(a[i]))));
}
Standard_Real Tol = 1e-5;
Standard_Real OffsetValue = 1;
OffsetValue = -OffsetValue; // Offset > 0 = Interior.
BRepOffsetAPI_MakeThickSolid MKTS (Shape,
ListOfCorks,
OffsetValue,
Tol,
BRepOffset_Skin,
1, Standard_False);
DBRep::Set("Result.brep",MKTS.Shape());
TopTools_ListOfShape Larg;
Larg.Append(Shape);
//Check if the shape has at least one face
TopExp_Explorer FExp (MKTS.Shape (), TopAbs_FACE);
if (FExp.More ()) {
//cout << "Standard_True"<<endl;
di << "Standard_True"<<"\n";
}
DBRep::Set("S",MKTS.Shape());
return 0;
}
/*********************************************************************************/
void BRepTest::ShellCommands(Draw_Interpretor& theCommands)
{
static Standard_Boolean loaded = Standard_False;
if (loaded) return;
loaded = Standard_True;
const char* g = "Projection of wire commands";
theCommands.Add("shell","Make shell on bugged object",
__FILE__,
shell,g);
}
|