1 // Created on: 1993-01-21
2 // Created by: Peter KURNEV
3 // Copyright (c) 1993-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.
17 // File: BRepClass3d.cxx
18 // Created: Thu Sep 20 10:05:46 2012
22 #include <BRepClass3d.ixx>
25 #include <TopAbs_State.hxx>
26 #include <TopAbs_Orientation.hxx>
28 #include <TopoDS_Solid.hxx>
29 #include <TopoDS_Shell.hxx>
30 #include <TopoDS_Iterator.hxx>
32 #include <BRep_Builder.hxx>
33 #include <BRepClass3d_SolidClassifier.hxx>
37 Standard_Boolean IsInternal(const TopoDS_Shell& aSx);
39 //=======================================================================
40 //function : OuterShell
42 //=======================================================================
43 TopoDS_Shell BRepClass3d::OuterShell(const TopoDS_Solid& aSolid)
45 Standard_Boolean bFound;
48 TopoDS_Shell aShell, aDummy;
51 BRepClass3d_SolidClassifier aSC;
53 if (aSolid.IsNull()) {
58 bFound=Standard_False;
60 // if solid has one shell, it will return, without checking orientation
61 Standard_Integer aShellCounter = 0;
62 for (aIt.Initialize(aSolid); aIt.More(); aIt.Next()) {
63 const TopoDS_Shape& aSx=aIt.Value();
64 if (aSx.ShapeType()==TopAbs_SHELL) {
65 aShell=*((TopoDS_Shell*)&aSx);
67 if (aShellCounter >= 2)
71 if (aShellCounter == 0) {
74 else if (aShellCounter == 1) {
78 for (aIt.Initialize(aSolid); aIt.More(); aIt.Next()) {
79 const TopoDS_Shape& aSx=aIt.Value();
80 if (aSx.ShapeType()==TopAbs_SHELL) {
81 aShell=*((TopoDS_Shell*)&aSx);
82 if (!IsInternal(aShell)) {
85 aBB.Add(aSDx, aShell);
88 aSC.PerformInfinitePoint(aTol);
89 if(aSC.State()==TopAbs_OUT) {
104 //=======================================================================
105 //function : IsInternal
107 //=======================================================================
108 Standard_Boolean IsInternal(const TopoDS_Shell& aSx)
110 Standard_Boolean bInternal;
111 TopAbs_Orientation aOr;
114 bInternal=Standard_False;
118 const TopoDS_Shape& aSy=aIt.Value();
119 aOr=aSy.Orientation();
120 bInternal=(aOr==TopAbs_INTERNAL);