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
6 // This file is part of Open CASCADE Technology software library.
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
19 #include <Standard_NoSuchObject.hxx>
20 #include <TCollection_AsciiString.hxx>
22 #include <TopoDS_Edge.hxx>
23 #include <TopoDS_Face.hxx>
24 #include <TopoDS_Shape.hxx>
25 #include <TopoDS_Vertex.hxx>
26 #include <TopOpeBRepBuild_Builder.hxx>
27 #include <TopOpeBRepBuild_define.hxx>
28 #include <TopOpeBRepBuild_EdgeBuilder.hxx>
29 #include <TopOpeBRepBuild_FaceBuilder.hxx>
30 #include <TopOpeBRepBuild_GTopo.hxx>
31 #include <TopOpeBRepBuild_HBuilder.hxx>
32 #include <TopOpeBRepBuild_PaveSet.hxx>
33 #include <TopOpeBRepBuild_ShapeSet.hxx>
34 #include <TopOpeBRepBuild_ShellFaceSet.hxx>
35 #include <TopOpeBRepBuild_SolidBuilder.hxx>
36 #include <TopOpeBRepBuild_WireEdgeSet.hxx>
37 #include <TopOpeBRepDS.hxx>
38 #include <TopOpeBRepDS_BuildTool.hxx>
39 #include <TopOpeBRepDS_CurveIterator.hxx>
40 #include <TopOpeBRepDS_EXPORT.hxx>
41 #include <TopOpeBRepDS_HDataStructure.hxx>
42 #include <TopOpeBRepDS_PointIterator.hxx>
43 #include <TopOpeBRepDS_SurfaceIterator.hxx>
44 #include <TopOpeBRepTool_2d.hxx>
45 #include <TopOpeBRepTool_EXPORT.hxx>
46 #include <TopOpeBRepTool_ShapeExplorer.hxx>
49 Standard_EXPORT void debfctwesmess(const Standard_Integer i,const TCollection_AsciiString& s = "");
50 Standard_EXPORT void debffwesON(const Standard_Integer i);
51 Standard_EXPORT void debffwesk(const Standard_Integer i) {cout<<"++ debffwesk "<<i<<endl;}
54 Standard_Boolean TopOpeBRepBuild_FUN_aresamegeom(const TopoDS_Shape& S1,const TopoDS_Shape& S2);
56 #define M_IN(st ) (st == TopAbs_IN)
57 #define M_OUT(st) (st == TopAbs_OUT)
58 #define M_FORWARD(st ) (st == TopAbs_FORWARD)
59 #define M_REVERSED(st) (st == TopAbs_REVERSED)
60 #define M_INTERNAL(st) (st == TopAbs_INTERNAL)
61 #define M_EXTERNAL(st) (st == TopAbs_EXTERNAL)
63 //=======================================================================
64 //function : GFillFacesWESK
66 //=======================================================================
67 void TopOpeBRepBuild_Builder::GFillFacesWESK(const TopTools_ListOfShape& LS1,const TopTools_ListOfShape& LS2,const TopOpeBRepBuild_GTopo& G1,TopOpeBRepBuild_WireEdgeSet& WES,const Standard_Integer Kfill)
69 if ( LS1.IsEmpty() ) return;
70 TopAbs_State TB1,TB2; G1.StatesON(TB1,TB2);
72 const TopOpeBRepDS_DataStructure& BDS = myDataStructure->DS();
74 const TopoDS_Shape& F1 = LS1.First();
75 myFaceReference = TopoDS::Face(F1);
77 Standard_Integer iF1 =
80 Standard_Integer iref = BDS.SameDomainRef(F1);
81 TopAbs_Orientation oref = BDS.Shape(iref).Orientation();
84 Standard_Boolean tSPS = GtraceSPS(F1,iF1);
85 if(tSPS) cout<<"\n%%%%%%%%%%%%% K = "<<Kfill<<" %%%%%%%%%%%%% ";
86 if(tSPS) GdumpSHASTA(iF1,TB1,WES,"GFillFacesWESK","myFaceReference");
87 if(tSPS) debffwesk(iF1);
91 TopOpeBRepBuild_GTopo G;
92 TopTools_ListIteratorOfListOfShape it;
93 Standard_Boolean gistoreverse1;
96 gistoreverse1 = G.IsToReverse1();
102 cout<<"\n^^^^^^^^ GFillFacesWESK : traitement de 1/2";
103 TopAbs_State TB11,TB21; G.StatesON(TB11,TB21);
104 cout<<" TB = ";TopAbs::Print(TB,cout); cout<<" ";
105 cout<<"(TB1 = ";TopAbs::Print(TB11,cout);cout<<",";
106 cout<<" TB2 = ";TopAbs::Print(TB21,cout);cout<<")\n\n";
110 for(; it.More(); it.Next()) {
111 const TopoDS_Shape& S = it.Value(); Standard_Integer iS = myDataStructure->Shape(S);
112 Standard_Boolean tomerge = !IsMerged(S,TB);
113 if (!tomerge) continue;
115 // lors de l'insertion des composantes (edges splitees) de S dans le WES :
116 // - faces de meme orientation geometrique :
117 // la grille indique l'orientation des composantes
118 // - faces d'orientation geometrique != :
119 // les aretes de S sont exprimees dans une surface
120 // d'orientation opposee a la surface de la face de reference.
121 // Leur orientation dans la face resultat (reference) est le contraire
123 // Modified by Sergey KHROMOV - Sat Apr 27 14:40:35 2002 Begin
124 // const TopoDS_Shape& Fref = WES.Face();
125 // const TopoDS_Shape& F = S;
126 // Standard_Boolean samegeom = ::TopOpeBRepBuild_FUN_aresamegeom(Fref,F);
127 // Standard_Boolean r = gistoreverse1;
128 // if ( !samegeom ) { r = !r; G.SetReverse(r); }
130 // Standard_Boolean rev = Standard_False;
131 // Modified by Sergey KHROMOV - Sat Apr 27 14:40:36 2002 End
132 TopAbs_Orientation oS = BDS.Shape(iS).Orientation();
133 TopOpeBRepDS_Config conf = BDS.SameDomainOri(S);
134 Standard_Boolean b1 = (conf == TopOpeBRepDS_DIFFORIENTED && (oS == oref));
135 Standard_Boolean b2 = (conf == TopOpeBRepDS_SAMEORIENTED && (oS != oref));
136 Standard_Boolean b = b1 || b2;
137 // Modified by Sergey KHROMOV - Sat Apr 27 14:40:01 2002 Begin
139 // rev = Standard_True;
140 // G.SetReverse(rev);
143 G.SetReverse(!gistoreverse1);
144 // Modified by Sergey KHROMOV - Sat Apr 27 14:40:03 2002 End
147 GFillFaceWES(S,LS2,G,WES);
149 else if (Kfill == 2) {
151 if (tSPS) debfctwesmess(iF1);
153 GFillCurveTopologyWES(S,G,WES);
155 else if (Kfill == 3) {
157 if (tSPS) debffwesON(iF1);
159 GFillONPartsWES(S,G,LS2,WES);
167 G = G1.CopyPermuted();
168 gistoreverse1 = G.IsToReverse1();
174 cout<<"\n^^^^^^^^ GFillFacesWESK : traitement de 2/1";
175 TopAbs_State TB12,TB22; G.StatesON(TB12,TB22);
176 cout<<" TB = ";TopAbs::Print(TB,cout); cout<<" ";
177 cout<<"(TB1 = ";TopAbs::Print(TB12,cout);cout<<",";
178 cout<<" TB2 = ";TopAbs::Print(TB22,cout);cout<<")\n\n";
182 for (; it.More(); it.Next()) {
183 const TopoDS_Shape& S = it.Value(); Standard_Integer iS = myDataStructure->Shape(S);
184 Standard_Boolean tomerge = !IsMerged(S,TB);
185 if (!tomerge) continue;
187 // Modified by Sergey KHROMOV - Sat Apr 27 14:38:33 2002 Begin
188 // const TopoDS_Shape& Fref = WES.Face();
189 // const TopoDS_Shape& F = S;
190 // Standard_Boolean samegeom = ::TopOpeBRepBuild_FUN_aresamegeom(Fref,F);
191 // Standard_Boolean r = gistoreverse1;
192 // if ( !samegeom ) { r = !r; G.SetReverse(r); }
194 // Standard_Boolean rev = Standard_False;
195 // Modified by Sergey KHROMOV - Sat Apr 27 14:38:30 2002 End
196 TopAbs_Orientation oS = BDS.Shape(iS).Orientation();
197 TopOpeBRepDS_Config conf = BDS.SameDomainOri(S);
198 Standard_Boolean b1 = (conf == TopOpeBRepDS_DIFFORIENTED && (oS == oref));
199 Standard_Boolean b2 = (conf == TopOpeBRepDS_SAMEORIENTED && (oS != oref));
200 Standard_Boolean b = b1 || b2;
201 // Modified by Sergey KHROMOV - Sat Apr 27 14:39:04 2002 Begin
203 // rev = Standard_True;
204 // G.SetReverse(rev);
207 G.SetReverse(!gistoreverse1);
208 // Modified by Sergey KHROMOV - Sat Apr 27 14:39:08 2002 End
211 GFillFaceWES(S,LS1,G,WES);
213 else if (Kfill == 2) {
214 GFillCurveTopologyWES(S,G,WES);
216 else if (Kfill == 3) {
218 if(tSPS) debffwesON(iF1);
220 GFillONPartsWES(S,G,LS1,WES);