b311480e |
1 | // Created on: 1995-09-12 |
2 | // Created by: Jean Yves LEBEY |
3 | // Copyright (c) 1995-1999 Matra Datavision |
4 | // Copyright (c) 1999-2012 OPEN CASCADE SAS |
5 | // |
6 | // The content of this file is subject to the Open CASCADE Technology Public |
7 | // License Version 6.5 (the "License"). You may not use the content of this file |
8 | // except in compliance with the License. Please obtain a copy of the License |
9 | // at http://www.opencascade.org and read it completely before using this file. |
10 | // |
11 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
12 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
13 | // |
14 | // The Original Code and all software distributed under the License is |
15 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
16 | // Initial Developer hereby disclaims all such warranties, including without |
17 | // limitation, any warranties of merchantability, fitness for a particular |
18 | // purpose or non-infringement. Please see the License for the specific terms |
19 | // and conditions governing the rights and limitations under the License. |
20 | |
7fd59977 |
21 | |
22 | #ifndef TopOpeBRepBuild_SplitSolid_INCLUDED |
23 | #define TopOpeBRepBuild_SplitSolid_INCLUDED |
24 | |
25 | #include <TopOpeBRepBuild_ShellFaceSet.hxx> |
26 | #include <TopOpeBRepBuild_SolidBuilder.hxx> |
27 | #include <TopOpeBRepBuild_define.hxx> |
28 | |
29 | #ifdef DEB |
30 | #define DEBSHASET(sarg,meth,shaset,str) TCollection_AsciiString sarg((meth));(sarg)=(sarg)+(shaset).DEBNumber()+(str); |
31 | Standard_EXPORT Standard_Boolean TopOpeBRepDS_GettraceSTRANGE(); |
32 | Standard_EXPORT void debsplitf(const Standard_Integer i); |
33 | Standard_EXPORT void debspanc(const Standard_Integer i); |
34 | //Standard_IMPORT extern Standard_Integer GLOBAL_iexF; |
35 | Standard_IMPORT Standard_Integer GLOBAL_iexF; |
36 | #endif |
37 | |
38 | //======================================================================= |
39 | //function : SplitSolid |
40 | //purpose : |
41 | //======================================================================= |
42 | |
43 | void TopOpeBRepBuild_Builder::SplitSolid(const TopoDS_Shape& S1oriented, |
44 | const TopAbs_State ToBuild1, |
45 | const TopAbs_State ToBuild2) |
46 | { |
47 | //modified by IFV for treating shell |
48 | Standard_Boolean tosplit = Standard_False; |
49 | Standard_Boolean IsShell = (S1oriented.ShapeType() == TopAbs_SHELL); |
50 | if(IsShell) { |
51 | TopExp_Explorer ex; |
52 | ex.Init(S1oriented, TopAbs_FACE); |
53 | for (; ex.More(); ex.Next()) { |
54 | const TopoDS_Shape& sh = ex.Current(); |
55 | tosplit = ToSplit(sh,ToBuild1); |
56 | if(tosplit) break; |
57 | } |
58 | } |
59 | else tosplit = ToSplit(S1oriented,ToBuild1); |
60 | |
61 | if ( ! tosplit ) return; |
62 | // end IFV |
63 | |
64 | Standard_Boolean RevOri1 = Reverse(ToBuild1,ToBuild2); |
65 | Standard_Boolean RevOri2 = Reverse(ToBuild2,ToBuild1); |
66 | Standard_Boolean ConnectTo1 = Standard_True; |
67 | Standard_Boolean ConnectTo2 = Standard_False; |
68 | |
69 | // work on a FORWARD solid <S1forward> |
70 | TopoDS_Shape S1forward = S1oriented; |
71 | myBuildTool.Orientation(S1forward,TopAbs_FORWARD); |
72 | |
73 | // build the list of solids to split : LS1, LS2 |
74 | TopTools_ListOfShape LS1,LS2; |
75 | LS1.Append(S1forward); |
76 | FindSameDomain(LS1,LS2); |
77 | Standard_Integer n1 = LS1.Extent(); |
78 | Standard_Integer n2 = LS2.Extent(); |
79 | |
80 | if (!n2) RevOri1 = Standard_False; |
81 | if (!n1) RevOri2 = Standard_False; |
82 | |
83 | // Create a face set <FS> connected by edges |
84 | // ----------------------------------------- |
85 | TopOpeBRepBuild_ShellFaceSet SFS; |
86 | |
87 | #ifdef DEB |
88 | Standard_Boolean tSPS = TopOpeBRepBuild_GettraceSPS(); |
89 | // Standard_Integer iSolid = myDataStructure->Shape(S1oriented); |
90 | if (tSPS) { |
91 | cout<<endl; |
92 | GdumpSHASTA(S1oriented,ToBuild1,"___ SplitSolid "); |
93 | GdumpSAMDOM(LS1, (char *) "1 : "); |
94 | GdumpSAMDOM(LS2, (char *) "2 : "); |
95 | } |
96 | SFS.DEBNumber(GdumpSHASETindex()); |
97 | #endif |
98 | |
99 | STATIC_SOLIDINDEX = 1; |
100 | TopTools_ListIteratorOfListOfShape itLS1; |
101 | for (itLS1.Initialize(LS1); itLS1.More(); itLS1.Next()) { |
102 | TopoDS_Shape Scur = itLS1.Value(); |
103 | FillSolid(Scur,ToBuild1,LS2,ToBuild2,SFS,RevOri1); |
104 | } |
105 | |
106 | STATIC_SOLIDINDEX = 2; |
107 | TopTools_ListIteratorOfListOfShape itLS2; |
108 | for (itLS2.Initialize(LS2); itLS2.More(); itLS2.Next()) { |
109 | TopoDS_Shape Scur = itLS2.Value(); |
110 | FillSolid(Scur,ToBuild2,LS1,ToBuild1,SFS,RevOri2); |
111 | } |
112 | |
113 | // Add the intersection surfaces |
114 | // ----------------------------- |
115 | if (myDataStructure->NbSurfaces() > 0) { |
116 | TopOpeBRepDS_SurfaceIterator SSurfaces = myDataStructure->SolidSurfaces(S1forward); |
117 | for (; SSurfaces.More(); SSurfaces.Next()) { |
118 | Standard_Integer iS = SSurfaces.Current(); |
119 | const TopTools_ListOfShape& LnewF = NewFaces(iS); |
120 | for (TopTools_ListIteratorOfListOfShape Iti(LnewF); Iti.More(); Iti.Next()) { |
121 | TopoDS_Shape aFace = Iti.Value(); |
122 | TopAbs_Orientation ori = SSurfaces.Orientation(ToBuild1); |
123 | myBuildTool.Orientation(aFace,ori); |
124 | |
125 | #ifdef DEB |
126 | if (tSPS){ |
127 | DEBSHASET(ss,"--- SplitSolid ",SFS," AddElement SFS+ face "); |
128 | GdumpSHA(aFace,(Standard_Address)ss.ToCString()); |
129 | cout<<" ";TopAbs::Print(ToBuild1,cout)<<" : 1 face "; |
130 | TopAbs::Print(ori,cout); cout<<endl; |
131 | } |
132 | #endif |
133 | SFS.AddElement(aFace); |
134 | } |
135 | } |
136 | } |
137 | |
138 | // Create a Solid Builder SOBU |
139 | // ------------------------- |
140 | TopOpeBRepBuild_SolidBuilder SOBU(SFS); |
141 | |
142 | // Build the new solids on S1 |
143 | // -------------------------- |
144 | TopTools_ListOfShape& SolidList = ChangeMerged(S1oriented,ToBuild1); |
145 | if(IsShell) |
146 | MakeShells(SOBU,SolidList); |
147 | else |
148 | MakeSolids(SOBU,SolidList); |
149 | |
150 | // connect list of new solids <SolidList> as solids built on LS1 solids |
151 | // -------------------------------------------------------------------- |
152 | |
153 | for (itLS1.Initialize(LS1); itLS1.More(); itLS1.Next()) { |
154 | TopoDS_Shape Scur = itLS1.Value(); |
155 | MarkSplit(Scur,ToBuild1); |
156 | TopTools_ListOfShape& SL = ChangeSplit(Scur,ToBuild1); |
157 | if ( ConnectTo1 ) SL = SolidList; |
158 | |
159 | } |
160 | |
161 | // connect list of new solids <SolidList> as solids built on LS2 solids |
162 | // -------------------------------------------------------------------- |
163 | for (itLS2.Initialize(LS2); itLS2.More(); itLS2.Next()) { |
164 | TopoDS_Shape Scur = itLS2.Value(); |
165 | MarkSplit(Scur,ToBuild2); |
166 | TopTools_ListOfShape& SL = ChangeSplit(Scur,ToBuild2); |
167 | if ( ConnectTo2 ) SL = SolidList; |
168 | } |
169 | |
170 | } // SplitSolid |
171 | |
172 | //#ifndef TopOpeBRepBuild_SplitSolid_INCLUDED |
173 | #endif |