1 // Created on: 1996-03-07
2 // Created by: Jean Yves LEBEY
3 // Copyright (c) 1996-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
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>
37 #include <TopOpeBRepDS_define.hxx>
38 #include <TopOpeBRepDS_HDataStructure.hxx>
39 #include <TopOpeBRepDS_PointIterator.hxx>
40 #include <TopOpeBRepDS_SurfaceIterator.hxx>
41 #include <TopOpeBRepTool_ShapeExplorer.hxx>
42
43 #ifdef OCCT_DEBUG
44 extern Standard_Integer GLOBAL_iexE;
45 extern Standard_Integer GLOBAL_iexF;
46 Standard_Boolean STATIC_trace_iexE = Standard_False;
47 Standard_Boolean STATIC_trace_iexF = Standard_False;
debkeep(const Standard_Integer i)48 Standard_EXPORT void debkeep(const Standard_Integer i) {std::cout<<"++ debkeep "<<i<<std::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 //=======================================================================
GKeepShape(const TopoDS_Shape & S,const TopTools_ListOfShape & LSclass,const TopAbs_State TB)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
GKeepShape1(const TopoDS_Shape & S,const TopTools_ListOfShape & LSclass,const TopAbs_State TB,TopAbs_State & pos)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 }
83 #ifdef OCCT_DEBUG
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) std::cout<<"EDGE exploration "<<GLOBAL_iexE;
101 else if (tSPSsoli) std::cout<<"FACE exploration "<<GLOBAL_iexF;
102 if(keep)std::cout<<" is kept";else std::cout<<" is NOT kept";
103 std::cout<<" ";TopAbs::Print(TB,std::cout);std::cout<<" / ";
104 if(LSclass.IsEmpty())std::cout<<"empty list";else GdumpLS(LSclass);std::cout<<std::endl;
105 std::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 //=======================================================================
GKeepShapes(const TopoDS_Shape & S,const TopTools_ListOfShape & LSclass,const TopAbs_State TB,const TopTools_ListOfShape & Lin,TopTools_ListOfShape & Lou)121 void TopOpeBRepBuild_Builder::GKeepShapes
122 #ifdef OCCT_DEBUG
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)
128 {
129 #ifdef OCCT_DEBUG
130 Standard_Integer iS; Standard_Boolean tSPS = GtraceSPS(S,iS);
131 if (tSPS) debkeep(iS);
132 #endif
133
134 #ifdef OCCT_DEBUG
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
147 #ifdef OCCT_DEBUG
148 TopAbs_ShapeEnum t = SL.ShapeType();
149 if(tSPS){std::cout<<"GKeepShapes : ";}
150 if(tSPS){std::cout<<"new ";TopAbs::Print(t,std::cout);std::cout<<" "<<++n;}
151 if(tSPS){std::cout<<" from ";GdumpSHA(S);if(keep)std::cout<<" is kept";else std::cout<<" is NOT kept";}
152 if(tSPS){std::cout<<" ";TopAbs::Print(TB,std::cout);std::cout<<" / ";}
153 if(tSPS){if(LSclass.IsEmpty())std::cout<<"empty list";else GdumpLS(LSclass);std::cout<<std::endl;}
154 #endif
155
156 if (keep) Lou.Append(SL);
157 }
158 }
159