1 // Created on: 1995-10-23
2 // Created by: Yves FRICAUD
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 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 <BRepAlgo_Tool.hxx>
23 #include <TopoDS_Edge.hxx>
24 #include <TopoDS_Iterator.hxx>
25 #include <TopoDS_Shape.hxx>
26 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
27 #include <TopTools_ListOfShape.hxx>
29 //=======================================================================
30 //function : Deboucle3D
32 //=======================================================================
33 TopoDS_Shape BRepAlgo_Tool::Deboucle3D(const TopoDS_Shape& S,
34 const TopTools_MapOfShape& Boundary)
38 switch ( S.ShapeType()) {
45 // if the shell contains free borders that do not belong to the
46 // free borders of caps ( Boundary) it is removed.
47 TopTools_IndexedDataMapOfShapeListOfShape Map;
48 TopExp::MapShapesAndAncestors(S,TopAbs_EDGE,TopAbs_FACE,Map);
50 Standard_Boolean JeGarde = Standard_True;
51 for ( Standard_Integer i = 1; i <= Map.Extent() && JeGarde; i++) {
52 const TopTools_ListOfShape& aLF = Map(i);
53 if (aLF.Extent() < 2) {
54 const TopoDS_Edge& anEdge = TopoDS::Edge(Map.FindKey(i));
55 if (anEdge.Orientation() == TopAbs_INTERNAL) {
56 const TopoDS_Face& aFace = TopoDS::Face(aLF.First());
57 if (aFace.Orientation() != TopAbs_INTERNAL) {
61 if (!Boundary.Contains(anEdge) &&
62 !BRep_Tool::Degenerated(anEdge) )
63 JeGarde = Standard_False;
72 // iterate on sub-shapes and add non-empty.
73 TopoDS_Iterator it(S);
74 TopoDS_Shape SubShape;
75 Standard_Boolean NbSub = 0;
77 if (S.ShapeType() == TopAbs_COMPOUND) {
78 B.MakeCompound(TopoDS::Compound(SS));
81 B.MakeSolid(TopoDS::Solid(SS));
83 for ( ; it.More(); it.Next()) {
84 const TopoDS_Shape& CurS = it.Value();
85 SubShape = Deboucle3D(CurS,Boundary);
86 if ( !SubShape.IsNull()) {
94 cout << "No subhape in shape!" << endl;