0025418: Debug output to be limited to OCC development environment
[occt.git] / src / BRepAlgo / BRepAlgo_Tool.cxx
CommitLineData
b311480e 1// Created on: 1995-10-23
2// Created by: Yves FRICAUD
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#include <BRepAlgo_Tool.ixx>
18
19#include <TopTools_ListOfShape.hxx>
20#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
21#include <TopExp.hxx>
22#include <BRep_Builder.hxx>
23#include <BRep_Tool.hxx>
24#include <TopoDS.hxx>
25#include <TopoDS_Iterator.hxx>
26#include <TopoDS_Edge.hxx>
27
28
b311480e 29
7fd59977 30
31//=======================================================================
32//function : Deboucle3D
33//purpose :
34//=======================================================================
35
36TopoDS_Shape BRepAlgo_Tool::Deboucle3D(const TopoDS_Shape& S,
37 const TopTools_MapOfShape& Boundary)
38{
39 TopoDS_Shape SS;
40
41 switch ( S.ShapeType()) {
42 case TopAbs_FACE:
43 {
44 }
45 break;
46 case TopAbs_SHELL:
47 {
0d969553
Y
48 // if the shell contains free borders that do not belong to the
49 // free borders of caps ( Boundary) it is removed.
7fd59977 50 TopTools_IndexedDataMapOfShapeListOfShape Map;
51 TopExp::MapShapesAndAncestors(S,TopAbs_EDGE,TopAbs_FACE,Map);
52
53 Standard_Boolean JeGarde = Standard_True;
54 for ( Standard_Integer i = 1; i <= Map.Extent() && JeGarde; i++) {
55 if (Map(i).Extent() < 2) {
56 const TopoDS_Edge& anEdge = TopoDS::Edge(Map.FindKey(i));
57 if (!Boundary.Contains(anEdge) &&
58 !BRep_Tool::Degenerated(anEdge) )
59 JeGarde = Standard_False;
60 }
61 }
62 if ( JeGarde) SS = S;
63 }
64 break;
65 case TopAbs_COMPOUND:
66 case TopAbs_SOLID:
67 {
0d969553 68 // iterate on sub-shapes and add non-empty.
7fd59977 69 TopoDS_Iterator it(S);
70 TopoDS_Shape SubShape;
71 Standard_Boolean NbSub = 0;
72 BRep_Builder B;
73 if (S.ShapeType() == TopAbs_COMPOUND) {
74 B.MakeCompound(TopoDS::Compound(SS));
75 }
76 else {
77 B.MakeSolid(TopoDS::Solid(SS));
78 }
79 for ( ; it.More(); it.Next()) {
80 const TopoDS_Shape& CurS = it.Value();
81 SubShape = Deboucle3D(CurS,Boundary);
82 if ( !SubShape.IsNull()) {
83 B.Add(SS, SubShape);
84 NbSub++;
85 }
86 }
ab87e6fc 87 if (NbSub == 0)
88 {
0797d9d3 89#ifdef OCCT_DEBUG
ab87e6fc 90 cout << "No subhape in shape!" << endl;
91#endif
92 SS = TopoDS_Shape();
93 }
7fd59977 94 }
95 break;
96 default:
97 break;
98 }
99 return SS;
100}