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 | // |
973c2be1 |
8 | // This library is free software; you can redistribute it and / or modify it |
9 | // under the terms of the GNU Lesser General Public 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. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
7fd59977 |
16 | |
17 | #include <TopOpeBRepBuild_Builder.ixx> |
18 | |
19 | #include <TopOpeBRepBuild_define.hxx> |
20 | #include <TopOpeBRepDS_EXPORT.hxx> |
21 | #include <TopOpeBRepDS.hxx> |
22 | #include <TopOpeBRepTool_2d.hxx> |
23 | #include <TopOpeBRepTool_EXPORT.hxx> |
24 | #include <TopOpeBRepTool_defineG.hxx> |
25 | #include <TopoDS.hxx> |
26 | #include <BRep_Tool.hxx> |
27 | #include <Standard_ProgramError.hxx> |
28 | |
29 | #ifdef DEB |
30 | Standard_EXPORT void debfctwes(const Standard_Integer /*i*/) {} |
31 | Standard_EXPORT void debfctwesmess(const Standard_Integer i,const TCollection_AsciiString& s = "") |
32 | {cout<<"+ + + debfctwes "<<s<<"F"<<i<<endl;debfctwes(i);} |
1d0a9d4d |
33 | extern void debaddpwes(const Standard_Integer iFOR,const TopAbs_State TB1,const Standard_Integer iEG,const TopAbs_Orientation neworiE, |
34 | const TopOpeBRepBuild_PBuilder& PB,const TopOpeBRepBuild_PWireEdgeSet& PWES,const TCollection_AsciiString& str1,const TCollection_AsciiString& str2); |
7fd59977 |
35 | #endif |
36 | |
1d0a9d4d |
37 | Standard_Boolean TopOpeBRepBuild_FUN_aresamegeom(const TopoDS_Shape& S1,const TopoDS_Shape& S2); |
7fd59977 |
38 | |
39 | #define M_IN(st ) (st == TopAbs_IN) |
40 | #define M_OUT(st) (st == TopAbs_OUT) |
41 | #define M_FORWARD(st ) (st == TopAbs_FORWARD) |
42 | #define M_REVERSED(st) (st == TopAbs_REVERSED) |
43 | #define M_INTERNAL(st) (st == TopAbs_INTERNAL) |
44 | #define M_EXTERNAL(st) (st == TopAbs_EXTERNAL) |
45 | |
46 | //======================================================================= |
47 | //function : GFillCurveTopologyWES |
48 | //purpose : |
49 | //======================================================================= |
50 | void TopOpeBRepBuild_Builder::GFillCurveTopologyWES(const TopoDS_Shape& F1,const TopOpeBRepBuild_GTopo& G1,TopOpeBRepBuild_WireEdgeSet& WES) |
51 | { |
52 | TopAbs_State TB1,TB2; G1.StatesON(TB1,TB2); |
53 | TopAbs_ShapeEnum t1,t2,ShapeInterf; G1.Type(t1,t2); ShapeInterf = t1; |
54 | |
55 | #ifdef DEB |
56 | Standard_Integer iF; Standard_Boolean tSPS = GtraceSPS(F1,iF); |
57 | if(tSPS) GdumpSHASTA(iF,TB1,WES,"--- GFillCurveTopologyWES"); |
58 | if(tSPS) {cout<<" ShapeInterf ";TopAbs::Print(ShapeInterf,cout);cout<<endl;} |
59 | if(tSPS) {debfctwesmess(iF);} |
60 | #endif |
61 | |
62 | TopOpeBRepDS_CurveIterator FCit(myDataStructure->FaceCurves(F1)); |
63 | myFaceReference = TopoDS::Face(F1); |
64 | myFaceToFill = TopoDS::Face(F1); |
65 | //modified by NIZHNY-MZV Thu Feb 24 09:15:33 2000 |
66 | //sometimes by the problem of tolerances we have intersection |
67 | //lines between SameDomain faces, but Same domain faces can not |
68 | //have intersection lines other than by its original edges |
69 | //so we skip it if we find that two SameDomain faces have |
70 | //new intersection edge |
71 | Standard_Boolean hsd = myDataStructure->HasSameDomain(F1); |
72 | TopTools_IndexedMapOfShape aSDMap; |
73 | if(hsd) { |
74 | TopTools_ListIteratorOfListOfShape it = myDataStructure -> SameDomain(F1); |
75 | for(; it.More(); it.Next()) { |
76 | const TopoDS_Shape& SDF = it.Value(); |
77 | aSDMap.Add(SDF); |
78 | } |
79 | } |
80 | //End modified by NIZHNY-MZV Thu Feb 24 09:21:08 2000 |
81 | |
82 | for (; FCit.More(); FCit.Next()) { |
83 | if ( ShapeInterf != TopAbs_SHAPE ) { |
84 | const Handle(TopOpeBRepDS_Interference)& I = FCit.Value(); |
85 | const TopOpeBRepDS_Transition& T = I->Transition(); |
86 | TopAbs_ShapeEnum shab = T.ShapeBefore(),shaa = T.ShapeAfter(); |
87 | if ( (shaa != ShapeInterf) || (shab != ShapeInterf) ) continue; |
88 | //modified by NIZHNY-MZV Thu Feb 24 09:14:31 2000 |
89 | |
90 | Standard_Integer si = I -> Support(); |
91 | TopoDS_Shape SS = myDataStructure -> Shape(si); |
92 | //see comment above |
93 | if(aSDMap.Contains(SS)) |
94 | continue; |
95 | //End modified by NIZHNY-MZV Thu Feb 24 09:21:34 2000 |
96 | } |
97 | GFillCurveTopologyWES(FCit,G1,WES); |
98 | } |
99 | |
100 | return; |
101 | } // GFillCurveTopologyWES |
102 | |
103 | //======================================================================= |
104 | //function : GFillCurveTopologyWES |
105 | //purpose : |
106 | //======================================================================= |
107 | void TopOpeBRepBuild_Builder::GFillCurveTopologyWES(const TopOpeBRepDS_CurveIterator& FCit,const TopOpeBRepBuild_GTopo& G1,TopOpeBRepBuild_WireEdgeSet& WES) const |
108 | { |
109 | Standard_Boolean more = FCit.More(); |
110 | if (!more) return; |
111 | |
112 | TopAbs_State TB1,TB2; G1.StatesON(TB1,TB2); |
113 | TopOpeBRepDS_Config Conf = G1.Config1(); |
114 | TopAbs_State TB = TB1; |
115 | if ( Conf == TopOpeBRepDS_DIFFORIENTED ) { // -jyl980525 |
116 | // if (TB1 == TopAbs_OUT) TB = TopAbs_IN; |
117 | // else if (TB1 == TopAbs_IN ) TB = TopAbs_OUT; |
118 | } |
119 | |
120 | TopoDS_Face& WESF = *((TopoDS_Face*)((void*)&WES.Face())); |
121 | TopoDS_Face& FTF = *((TopoDS_Face*)((void*)&myFaceToFill)); |
122 | #ifdef DEB |
123 | // Standard_Boolean FTFeqWESF = myFaceReference.IsEqual(WESF); |
124 | #endif |
125 | |
126 | #ifdef DEB |
127 | Standard_Integer iWESF = myDataStructure->Shape(WESF); |
128 | Standard_Integer iref = myDataStructure->Shape(myFaceReference); |
129 | Standard_Integer ifil = myDataStructure->Shape(myFaceToFill); |
130 | #endif |
131 | |
132 | Standard_Boolean opeCut = Opec12() || Opec21(); |
133 | Standard_Boolean ComOfCut = opeCut && (TB1 == TB2)&& (TB1 == TopAbs_IN); |
134 | |
135 | const TopOpeBRepDS_Transition& T = FCit.Value()->Transition(); |
136 | TopAbs_Orientation neworiE = T.Orientation(TB); |
137 | Standard_Boolean samegeom = TopOpeBRepBuild_FUN_aresamegeom(FTF,WESF); |
138 | if (!samegeom) { |
139 | neworiE = TopAbs::Complement(neworiE); |
140 | } |
141 | |
142 | #ifdef DEB |
143 | Standard_Boolean tSPS = GtraceSPS(iWESF); |
144 | if(tSPS){ |
145 | cout<<"ifil : "<<ifil<<" iref : "<<iref<<" iwes : "<<iWESF<<endl; |
146 | cout<<"face "<<ifil<<" is ";TopOpeBRepDS::Print(Conf,cout);cout<<endl; |
147 | cout<<"ComOfCut "<<ComOfCut<<endl; |
148 | debfctwesmess(iWESF); |
149 | } |
150 | #endif |
151 | |
152 | if (ComOfCut) return; |
153 | |
154 | Standard_Integer iG = FCit.Current(); |
155 | const TopTools_ListOfShape& LnewE = NewEdges(iG); |
156 | TopTools_ListIteratorOfListOfShape Iti(LnewE); |
157 | for (; Iti.More(); Iti.Next()) { |
158 | TopoDS_Shape EE = Iti.Value(); |
159 | TopoDS_Edge& E = TopoDS::Edge(EE); |
160 | |
161 | //modified by NIZHNY-MZV Fri Mar 17 12:51:03 2000 |
162 | if(BRep_Tool::Degenerated(E)) |
163 | continue; |
164 | |
165 | // TopAbs_Orientation neworiE = FCit.Orientation(TB); |
166 | E.Orientation(neworiE); |
167 | |
168 | const Handle(Geom2d_Curve)& PC = FCit.PCurve(); |
169 | |
170 | Standard_Boolean EhasPConFTF = |
171 | |
172 | FC2D_HasCurveOnSurface(E,FTF); |
173 | //modified by NIZHNY-MZV Mon Mar 27 15:24:39 2000 |
174 | if(!EhasPConFTF) |
175 | myBuildTool.PCurve(FTF,E,PC); |
176 | |
177 | Standard_Boolean EhasPConWESF = FC2D_HasCurveOnSurface(E,WESF); |
178 | |
179 | if ( !EhasPConWESF) { |
180 | // Standard_Real tolE = BRep_Tool::Tolerance(E); |
181 | Standard_Real f2,l2,tolpc; Handle(Geom2d_Curve) C2D; |
182 | C2D = FC2D_CurveOnSurface(E,WESF,f2,l2,tolpc); |
183 | if (C2D.IsNull()) Standard_ProgramError::Raise("GFillCurveTopologyWES"); |
184 | #ifdef DEB |
185 | // Standard_Real tol = Max(tolE,tolpc); |
186 | #endif |
187 | |
188 | myBuildTool.PCurve(WESF,E,C2D); |
189 | |
190 | #ifdef DEB |
191 | EhasPConWESF = FC2D_HasCurveOnSurface(E,WESF); |
192 | if (!EhasPConWESF) cout<<"TopOpeBRepBuild_Builder::GFillCurveTopologyWES : Null PCurve on F"<<iWESF<<endl; |
193 | #endif |
194 | } |
195 | |
196 | #ifdef DEB |
197 | if (tSPS) debaddpwes(iWESF,TB,iG,neworiE,(TopOpeBRepBuild_Builder* const)this,&WES,"GFillCurveTopology " ,"WES+ EofC "); |
198 | #endif |
199 | |
200 | WES.AddStartElement(E); |
201 | } |
202 | |
203 | } // GFillCurveTopologyWES |