1 // Created on: 1995-09-12
2 // Created by: Jean Yves LEBEY
3 // Copyright (c) 1995-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
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef TopOpeBRepBuild_SplitSolid_INCLUDED
18 #define TopOpeBRepBuild_SplitSolid_INCLUDED
20 #include <TopOpeBRepBuild_ShellFaceSet.hxx>
21 #include <TopOpeBRepBuild_SolidBuilder.hxx>
22 #include <TopOpeBRepBuild_define.hxx>
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;
33 //=======================================================================
34 //function : SplitSolid
36 //=======================================================================
38 void TopOpeBRepBuild_Builder::SplitSolid(const TopoDS_Shape& S1oriented,
39 const TopAbs_State ToBuild1,
40 const TopAbs_State ToBuild2)
42 //modified by IFV for treating shell
43 Standard_Boolean tosplit = Standard_False;
44 Standard_Boolean IsShell = (S1oriented.ShapeType() == TopAbs_SHELL);
47 ex.Init(S1oriented, TopAbs_FACE);
48 for (; ex.More(); ex.Next()) {
49 const TopoDS_Shape& sh = ex.Current();
50 tosplit = ToSplit(sh,ToBuild1);
54 else tosplit = ToSplit(S1oriented,ToBuild1);
56 if ( ! tosplit ) return;
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;
64 // work on a FORWARD solid <S1forward>
65 TopoDS_Shape S1forward = S1oriented;
66 myBuildTool.Orientation(S1forward,TopAbs_FORWARD);
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();
75 if (!n2) RevOri1 = Standard_False;
76 if (!n1) RevOri2 = Standard_False;
78 // Create a face set <FS> connected by edges
79 // -----------------------------------------
80 TopOpeBRepBuild_ShellFaceSet SFS;
83 Standard_Boolean tSPS = TopOpeBRepBuild_GettraceSPS();
84 // Standard_Integer iSolid = myDataStructure->Shape(S1oriented);
87 GdumpSHASTA(S1oriented,ToBuild1,"___ SplitSolid ");
88 GdumpSAMDOM(LS1, (char *) "1 : ");
89 GdumpSAMDOM(LS2, (char *) "2 : ");
91 SFS.DEBNumber(GdumpSHASETindex());
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);
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);
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);
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;
128 SFS.AddElement(aFace);
133 // Create a Solid Builder SOBU
134 // -------------------------
135 TopOpeBRepBuild_SolidBuilder SOBU(SFS);
137 // Build the new solids on S1
138 // --------------------------
139 TopTools_ListOfShape& SolidList = ChangeMerged(S1oriented,ToBuild1);
141 MakeShells(SOBU,SolidList);
143 MakeSolids(SOBU,SolidList);
145 // connect list of new solids <SolidList> as solids built on LS1 solids
146 // --------------------------------------------------------------------
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;
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;
167 //#ifndef TopOpeBRepBuild_SplitSolid_INCLUDED