b311480e |
1 | // Created on: 1996-03-07 |
2 | // Created by: Jean Yves LEBEY |
3 | // Copyright (c) 1996-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
d5f74e42 |
8 | // This library is free software; you can redistribute it and/or modify it under |
9 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
10 | // by the Free Software Foundation, with special exception defined in the file |
11 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
12 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
7fd59977 |
16 | |
42cf5bc1 |
17 | |
18 | #include <gp_Pnt.hxx> |
19 | #include <Standard_NoSuchObject.hxx> |
20 | #include <TCollection_AsciiString.hxx> |
21 | #include <TopoDS_Edge.hxx> |
22 | #include <TopoDS_Face.hxx> |
23 | #include <TopoDS_Shape.hxx> |
24 | #include <TopoDS_Vertex.hxx> |
25 | #include <TopOpeBRepBuild_Builder.hxx> |
26 | #include <TopOpeBRepBuild_EdgeBuilder.hxx> |
27 | #include <TopOpeBRepBuild_FaceBuilder.hxx> |
28 | #include <TopOpeBRepBuild_GTopo.hxx> |
29 | #include <TopOpeBRepBuild_HBuilder.hxx> |
30 | #include <TopOpeBRepBuild_PaveSet.hxx> |
31 | #include <TopOpeBRepBuild_ShapeSet.hxx> |
32 | #include <TopOpeBRepBuild_ShellFaceSet.hxx> |
33 | #include <TopOpeBRepBuild_SolidBuilder.hxx> |
34 | #include <TopOpeBRepBuild_WireEdgeSet.hxx> |
35 | #include <TopOpeBRepDS_BuildTool.hxx> |
36 | #include <TopOpeBRepDS_CurveIterator.hxx> |
7fd59977 |
37 | #include <TopOpeBRepDS_define.hxx> |
42cf5bc1 |
38 | #include <TopOpeBRepDS_HDataStructure.hxx> |
39 | #include <TopOpeBRepDS_PointIterator.hxx> |
40 | #include <TopOpeBRepDS_SurfaceIterator.hxx> |
41 | #include <TopOpeBRepTool_ShapeExplorer.hxx> |
7fd59977 |
42 | |
0797d9d3 |
43 | #ifdef OCCT_DEBUG |
1d0a9d4d |
44 | extern Standard_Integer GLOBAL_iexE; |
45 | extern Standard_Integer GLOBAL_iexF; |
7fd59977 |
46 | Standard_Boolean STATIC_trace_iexE = Standard_False; |
47 | Standard_Boolean STATIC_trace_iexF = Standard_False; |
48 | Standard_EXPORT void debkeep(const Standard_Integer i) {cout<<"++ debkeep "<<i<<endl;} |
49 | #endif |
50 | |
51 | //======================================================================= |
52 | //function : GKeepShape |
53 | //purpose : |
54 | // compute position of shape <S> / shapes of list <LSclass> |
55 | // return true if LS is not empty && (position == TB) |
56 | // (return always true if LS is empty) |
57 | //======================================================================= |
58 | Standard_Boolean TopOpeBRepBuild_Builder::GKeepShape |
59 | (const TopoDS_Shape& S, const TopTools_ListOfShape& LSclass, const TopAbs_State TB) |
60 | { |
61 | TopAbs_State pos; |
62 | return GKeepShape1(S,LSclass,TB,pos); |
63 | } |
64 | |
65 | Standard_Boolean TopOpeBRepBuild_Builder::GKeepShape1 |
66 | (const TopoDS_Shape& S, const TopTools_ListOfShape& LSclass, const TopAbs_State TB, |
67 | TopAbs_State& pos) |
68 | { |
69 | Standard_Boolean keep = Standard_True; |
70 | pos = TopAbs_UNKNOWN; |
71 | Standard_Boolean toclassify = Standard_True; |
72 | if (S.ShapeType() == TopAbs_FACE && |
73 | !myDataStructure->HasShape(S) && |
74 | myClassifyDef) { |
75 | toclassify = myClassifyVal; |
76 | } |
77 | |
78 | toclassify = (toclassify && !LSclass.IsEmpty()); |
79 | if (toclassify) { |
80 | pos = ShapePosition(S,LSclass); |
81 | if ( pos != TB ) keep = Standard_False; |
82 | } |
0797d9d3 |
83 | #ifdef OCCT_DEBUG |
7fd59977 |
84 | Standard_Integer iS; Standard_Boolean tSPS = GtraceSPS(S,iS); |
85 | Standard_Integer iface = 0, isoli = 0; |
86 | Standard_Boolean tSPSface = Standard_False; |
87 | Standard_Boolean tSPSsoli = Standard_False; |
88 | if ( S.ShapeType() == TopAbs_EDGE ) { |
89 | tSPSface = GtraceSPS(myFaceToFill,iface); |
90 | tSPSface = tSPSface && STATIC_trace_iexE; |
91 | } |
92 | else if ( S.ShapeType() == TopAbs_FACE ) { |
93 | tSPSsoli = GtraceSPS(mySolidToFill,isoli); |
94 | tSPSsoli = tSPSsoli && STATIC_trace_iexF; |
95 | } |
96 | |
97 | Standard_Boolean tr = tSPS || tSPSface || tSPSsoli; |
98 | if(tr){ |
99 | if (tSPS) GdumpSHA(S); |
100 | else if (tSPSface) cout<<"EDGE exploration "<<GLOBAL_iexE; |
101 | else if (tSPSsoli) cout<<"FACE exploration "<<GLOBAL_iexF; |
102 | if(keep)cout<<" is kept";else cout<<" is NOT kept"; |
103 | cout<<" ";TopAbs::Print(TB,cout);cout<<" / "; |
104 | if(LSclass.IsEmpty())cout<<"empty list";else GdumpLS(LSclass);cout<<endl; |
105 | cout.flush(); |
106 | } |
107 | #endif |
108 | |
109 | return keep; |
110 | } |
111 | |
112 | //======================================================================= |
113 | //function : GKeepShapes |
114 | //purpose : |
115 | // select shapes to keep from list Lin located TB compared with LSclass shapes |
116 | // selected shapes are stored in list Lou |
117 | // (apply GKeepShape on Lin shapes) |
118 | // Lou is not cleared |
119 | // S is used for trace only |
120 | //======================================================================= |
121 | void TopOpeBRepBuild_Builder::GKeepShapes |
0797d9d3 |
122 | #ifdef OCCT_DEBUG |
498ce76b |
123 | (const TopoDS_Shape& S, |
124 | #else |
125 | (const TopoDS_Shape&, |
126 | #endif |
127 | const TopTools_ListOfShape& LSclass,const TopAbs_State TB,const TopTools_ListOfShape& Lin,TopTools_ListOfShape& Lou) |
7fd59977 |
128 | { |
0797d9d3 |
129 | #ifdef OCCT_DEBUG |
7fd59977 |
130 | Standard_Integer iS; Standard_Boolean tSPS = GtraceSPS(S,iS); |
131 | if (tSPS) debkeep(iS); |
132 | #endif |
133 | |
0797d9d3 |
134 | #ifdef OCCT_DEBUG |
7fd59977 |
135 | Standard_Integer n = 0; |
136 | #endif |
137 | TopTools_ListIteratorOfListOfShape it(Lin); |
138 | for (; it.More(); it.Next() ) { |
139 | const TopoDS_Shape& SL = it.Value(); |
140 | |
141 | Standard_Boolean keep = Standard_True; |
142 | if ( ! LSclass.IsEmpty() ) { |
143 | TopAbs_State pos = ShapePosition(SL,LSclass); |
144 | if ( pos != TB ) keep = Standard_False; |
145 | } |
146 | |
0797d9d3 |
147 | #ifdef OCCT_DEBUG |
7fd59977 |
148 | TopAbs_ShapeEnum t = SL.ShapeType(); |
149 | if(tSPS){cout<<"GKeepShapes : ";} |
150 | if(tSPS){cout<<"new ";TopAbs::Print(t,cout);cout<<" "<<++n;} |
151 | if(tSPS){cout<<" from ";GdumpSHA(S);if(keep)cout<<" is kept";else cout<<" is NOT kept";} |
152 | if(tSPS){cout<<" ";TopAbs::Print(TB,cout);cout<<" / ";} |
153 | if(tSPS){if(LSclass.IsEmpty())cout<<"empty list";else GdumpLS(LSclass);cout<<endl;} |
154 | #endif |
155 | |
156 | if (keep) Lou.Append(SL); |
157 | } |
158 | } |