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.
18 #include <BRep_Builder.hxx>
19 #include <BRep_Tool.hxx>
20 #include <Geom2d_Curve.hxx>
22 #include <Standard_NoSuchObject.hxx>
23 #include <Standard_ProgramError.hxx>
24 #include <TCollection_AsciiString.hxx>
27 #include <TopoDS_Compound.hxx>
28 #include <TopoDS_Edge.hxx>
29 #include <TopoDS_Face.hxx>
30 #include <TopoDS_Shape.hxx>
31 #include <TopoDS_Vertex.hxx>
32 #include <TopoDS_Wire.hxx>
33 #include <TopOpeBRepBuild_Builder.hxx>
34 #include <TopOpeBRepBuild_define.hxx>
35 #include <TopOpeBRepBuild_EdgeBuilder.hxx>
36 #include <TopOpeBRepBuild_FaceBuilder.hxx>
37 #include <TopOpeBRepBuild_GTopo.hxx>
38 #include <TopOpeBRepBuild_HBuilder.hxx>
39 #include <TopOpeBRepBuild_PaveSet.hxx>
40 #include <TopOpeBRepBuild_ShapeSet.hxx>
41 #include <TopOpeBRepBuild_ShellFaceSet.hxx>
42 #include <TopOpeBRepBuild_SolidBuilder.hxx>
43 #include <TopOpeBRepBuild_WireEdgeSet.hxx>
44 #include <TopOpeBRepDS_BuildTool.hxx>
45 #include <TopOpeBRepDS_CurveIterator.hxx>
46 #include <TopOpeBRepDS_HDataStructure.hxx>
47 #include <TopOpeBRepDS_PointIterator.hxx>
48 #include <TopOpeBRepDS_SurfaceIterator.hxx>
49 #include <TopOpeBRepTool.hxx>
50 #include <TopOpeBRepTool_ShapeExplorer.hxx>
51 #include <TopTools_IndexedDataMapOfShapeShape.hxx>
52 #include <TopTools_IndexedMapOfOrientedShape.hxx>
55 Standard_EXPORT void debgsobu(const Standard_Integer /*iSO*/) {}
58 //=======================================================================
59 //function : GSFSMakeSolids
61 //=======================================================================
62 void TopOpeBRepBuild_Builder::GSFSMakeSolids
63 (const TopoDS_Shape& SOF,TopOpeBRepBuild_ShellFaceSet& SFS,TopTools_ListOfShape& LOSO)
66 Standard_Integer iSO; Standard_Boolean tSPS = GtraceSPS(SOF,iSO);
67 if(tSPS){GdumpSHA(SOF, (char *) "#--- GSFSMakeSolids ");std::cout<<std::endl;}
70 Standard_Boolean ForceClass = Standard_True;
71 TopOpeBRepBuild_SolidBuilder SOBU;
72 SOBU.InitSolidBuilder(SFS,ForceClass);
73 GSOBUMakeSolids(SOF,SOBU,LOSO);
77 //=======================================================================
78 //function : GSOBUMakeSolids
80 //=======================================================================
81 void TopOpeBRepBuild_Builder::GSOBUMakeSolids
82 (const TopoDS_Shape& SOF,TopOpeBRepBuild_SolidBuilder& SOBU,TopTools_ListOfShape& LOSO)
85 Standard_Integer iSO; Standard_Boolean tSPS = GtraceSPS(SOF,iSO);
86 if(tSPS){GdumpSHA(SOF, (char *) "#--- GSOBUMakeSolids ");std::cout<<std::endl;}
87 if(tSPS){GdumpSOBU(SOBU);debgsobu(iSO);}
90 TopoDS_Shape newSolid;
91 TopoDS_Shape newShell;
92 Standard_Integer nfa = 0;
93 Standard_Integer nsh = 0;
95 for (; SOBU.MoreSolid(); SOBU.NextSolid()) {
97 myBuildTool.MakeSolid(newSolid);
98 nsh = SOBU.InitShell();
99 for (; SOBU.MoreShell(); SOBU.NextShell()) {
100 Standard_Boolean isold = SOBU.IsOldShell();
101 if (isold) newShell = SOBU.OldShell();
103 myBuildTool.MakeShell(newShell);
104 nfa = SOBU.InitFace();
105 for (; SOBU.MoreFace(); SOBU.NextFace()) {
106 TopoDS_Shape F = SOBU.Face();
107 myBuildTool.AddShellFace(newShell,F);
111 // caractere closed du nouveau shell newShell
113 Standard_Boolean closed = Standard_True;
114 TopTools_IndexedDataMapOfShapeListOfShape edgemap;
115 TopExp::MapShapesAndAncestors
116 (newShell,TopAbs_EDGE,TopAbs_FACE,edgemap);
117 Standard_Integer iedge,nedge = edgemap.Extent();
118 for (iedge = 1; iedge <= nedge; iedge++) {
119 const TopoDS_Shape& E = edgemap.FindKey(iedge);
120 TopAbs_Orientation oE = E.Orientation();
121 if (oE == TopAbs_INTERNAL ||
122 oE == TopAbs_EXTERNAL) continue;
123 const TopoDS_Edge& EE = TopoDS::Edge(E);
124 Standard_Boolean degen = BRep_Tool::Degenerated(EE);
126 Standard_Integer nbf = edgemap(iedge).Extent();
128 closed = Standard_False;
132 myBuildTool.Closed(newShell,closed);
135 myBuildTool.AddSolidShell(newSolid,newShell);
139 TopExp_Explorer ex(newSolid,TopAbs_VERTEX);
140 Standard_Boolean isempty = ex.More();
145 Standard_Boolean newSolidOK = Standard_True;
146 if (nsh == 1 && nfa == 1) {
147 TopExp_Explorer exp(newSolid,TopAbs_EDGE);
148 Standard_Boolean hasnondegenerated = Standard_False;
149 for(;exp.More(); exp.Next()) {
150 const TopoDS_Edge& e = TopoDS::Edge(exp.Current());
151 if ( !BRep_Tool::Degenerated(e) ) {
152 hasnondegenerated = Standard_True;
156 newSolidOK = hasnondegenerated;
157 if ( !newSolidOK ) continue;
160 TopTools_ListOfShape newSolidLOS;
161 RegularizeSolid(SOF,newSolid,newSolidLOS);
162 LOSO.Append(newSolidLOS);
163 // LOSO.Append(newSolid);