b311480e |
1 | // Created on: 1995-09-12 |
2 | // Created by: Jean Yves LEBEY |
3 | // Copyright (c) 1995-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 | |
17 | #ifndef TopOpeBRepBuild_SplitSolid_INCLUDED |
18 | #define TopOpeBRepBuild_SplitSolid_INCLUDED |
19 | |
20 | #include <TopOpeBRepBuild_ShellFaceSet.hxx> |
21 | #include <TopOpeBRepBuild_SolidBuilder.hxx> |
22 | #include <TopOpeBRepBuild_define.hxx> |
23 | |
0797d9d3 |
24 | #ifdef OCCT_DEBUG |
7fd59977 |
25 | #define DEBSHASET(sarg,meth,shaset,str) TCollection_AsciiString sarg((meth));(sarg)=(sarg)+(shaset).DEBNumber()+(str); |
26 | Standard_EXPORT Standard_Boolean TopOpeBRepDS_GettraceSTRANGE(); |
27 | Standard_EXPORT void debsplitf(const Standard_Integer i); |
28 | Standard_EXPORT void debspanc(const Standard_Integer i); |
29 | //Standard_IMPORT extern Standard_Integer GLOBAL_iexF; |
30 | Standard_IMPORT Standard_Integer GLOBAL_iexF; |
31 | #endif |
32 | |
33 | //======================================================================= |
34 | //function : SplitSolid |
35 | //purpose : |
36 | //======================================================================= |
37 | |
38 | void TopOpeBRepBuild_Builder::SplitSolid(const TopoDS_Shape& S1oriented, |
39 | const TopAbs_State ToBuild1, |
40 | const TopAbs_State ToBuild2) |
41 | { |
42 | //modified by IFV for treating shell |
43 | Standard_Boolean tosplit = Standard_False; |
44 | Standard_Boolean IsShell = (S1oriented.ShapeType() == TopAbs_SHELL); |
45 | if(IsShell) { |
46 | TopExp_Explorer ex; |
47 | ex.Init(S1oriented, TopAbs_FACE); |
48 | for (; ex.More(); ex.Next()) { |
49 | const TopoDS_Shape& sh = ex.Current(); |
50 | tosplit = ToSplit(sh,ToBuild1); |
51 | if(tosplit) break; |
52 | } |
53 | } |
54 | else tosplit = ToSplit(S1oriented,ToBuild1); |
55 | |
56 | if ( ! tosplit ) return; |
57 | // end IFV |
58 | |
59 | Standard_Boolean RevOri1 = Reverse(ToBuild1,ToBuild2); |
60 | Standard_Boolean RevOri2 = Reverse(ToBuild2,ToBuild1); |
61 | Standard_Boolean ConnectTo1 = Standard_True; |
62 | Standard_Boolean ConnectTo2 = Standard_False; |
63 | |
64 | // work on a FORWARD solid <S1forward> |
65 | TopoDS_Shape S1forward = S1oriented; |
66 | myBuildTool.Orientation(S1forward,TopAbs_FORWARD); |
67 | |
68 | // build the list of solids to split : LS1, LS2 |
69 | TopTools_ListOfShape LS1,LS2; |
70 | LS1.Append(S1forward); |
71 | FindSameDomain(LS1,LS2); |
72 | Standard_Integer n1 = LS1.Extent(); |
73 | Standard_Integer n2 = LS2.Extent(); |
74 | |
75 | if (!n2) RevOri1 = Standard_False; |
76 | if (!n1) RevOri2 = Standard_False; |
77 | |
78 | // Create a face set <FS> connected by edges |
79 | // ----------------------------------------- |
80 | TopOpeBRepBuild_ShellFaceSet SFS; |
81 | |
0797d9d3 |
82 | #ifdef OCCT_DEBUG |
7fd59977 |
83 | Standard_Boolean tSPS = TopOpeBRepBuild_GettraceSPS(); |
84 | // Standard_Integer iSolid = myDataStructure->Shape(S1oriented); |
85 | if (tSPS) { |
86 | cout<<endl; |
87 | GdumpSHASTA(S1oriented,ToBuild1,"___ SplitSolid "); |
88 | GdumpSAMDOM(LS1, (char *) "1 : "); |
89 | GdumpSAMDOM(LS2, (char *) "2 : "); |
90 | } |
91 | SFS.DEBNumber(GdumpSHASETindex()); |
92 | #endif |
93 | |
94 | STATIC_SOLIDINDEX = 1; |
95 | TopTools_ListIteratorOfListOfShape itLS1; |
96 | for (itLS1.Initialize(LS1); itLS1.More(); itLS1.Next()) { |
97 | TopoDS_Shape Scur = itLS1.Value(); |
98 | FillSolid(Scur,ToBuild1,LS2,ToBuild2,SFS,RevOri1); |
99 | } |
100 | |
101 | STATIC_SOLIDINDEX = 2; |
102 | TopTools_ListIteratorOfListOfShape itLS2; |
103 | for (itLS2.Initialize(LS2); itLS2.More(); itLS2.Next()) { |
104 | TopoDS_Shape Scur = itLS2.Value(); |
105 | FillSolid(Scur,ToBuild2,LS1,ToBuild1,SFS,RevOri2); |
106 | } |
107 | |
108 | // Add the intersection surfaces |
109 | // ----------------------------- |
110 | if (myDataStructure->NbSurfaces() > 0) { |
111 | TopOpeBRepDS_SurfaceIterator SSurfaces = myDataStructure->SolidSurfaces(S1forward); |
112 | for (; SSurfaces.More(); SSurfaces.Next()) { |
113 | Standard_Integer iS = SSurfaces.Current(); |
114 | const TopTools_ListOfShape& LnewF = NewFaces(iS); |
115 | for (TopTools_ListIteratorOfListOfShape Iti(LnewF); Iti.More(); Iti.Next()) { |
116 | TopoDS_Shape aFace = Iti.Value(); |
117 | TopAbs_Orientation ori = SSurfaces.Orientation(ToBuild1); |
118 | myBuildTool.Orientation(aFace,ori); |
119 | |
0797d9d3 |
120 | #ifdef OCCT_DEBUG |
7fd59977 |
121 | if (tSPS){ |
122 | DEBSHASET(ss,"--- SplitSolid ",SFS," AddElement SFS+ face "); |
123 | GdumpSHA(aFace,(Standard_Address)ss.ToCString()); |
124 | cout<<" ";TopAbs::Print(ToBuild1,cout)<<" : 1 face "; |
125 | TopAbs::Print(ori,cout); cout<<endl; |
126 | } |
127 | #endif |
128 | SFS.AddElement(aFace); |
129 | } |
130 | } |
131 | } |
132 | |
133 | // Create a Solid Builder SOBU |
134 | // ------------------------- |
135 | TopOpeBRepBuild_SolidBuilder SOBU(SFS); |
136 | |
137 | // Build the new solids on S1 |
138 | // -------------------------- |
139 | TopTools_ListOfShape& SolidList = ChangeMerged(S1oriented,ToBuild1); |
140 | if(IsShell) |
141 | MakeShells(SOBU,SolidList); |
142 | else |
143 | MakeSolids(SOBU,SolidList); |
144 | |
145 | // connect list of new solids <SolidList> as solids built on LS1 solids |
146 | // -------------------------------------------------------------------- |
147 | |
148 | for (itLS1.Initialize(LS1); itLS1.More(); itLS1.Next()) { |
149 | TopoDS_Shape Scur = itLS1.Value(); |
150 | MarkSplit(Scur,ToBuild1); |
151 | TopTools_ListOfShape& SL = ChangeSplit(Scur,ToBuild1); |
152 | if ( ConnectTo1 ) SL = SolidList; |
153 | |
154 | } |
155 | |
156 | // connect list of new solids <SolidList> as solids built on LS2 solids |
157 | // -------------------------------------------------------------------- |
158 | for (itLS2.Initialize(LS2); itLS2.More(); itLS2.Next()) { |
159 | TopoDS_Shape Scur = itLS2.Value(); |
160 | MarkSplit(Scur,ToBuild2); |
161 | TopTools_ListOfShape& SL = ChangeSplit(Scur,ToBuild2); |
162 | if ( ConnectTo2 ) SL = SolidList; |
163 | } |
164 | |
165 | } // SplitSolid |
166 | |
167 | //#ifndef TopOpeBRepBuild_SplitSolid_INCLUDED |
168 | #endif |