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 <BRep_Builder.hxx>
23 #include <BRepClass3d.hxx>
24 #include <BRepClass3d_SolidClassifier.hxx>
25 #include <TopAbs_Orientation.hxx>
26 #include <TopAbs_State.hxx>
27 #include <TopoDS_Iterator.hxx>
28 #include <TopoDS_Shell.hxx>
29 #include <TopoDS_Solid.hxx>
32 Standard_Boolean IsInternal(const TopoDS_Shell& aSx);
34 //=======================================================================
35 //function : OuterShell
37 //=======================================================================
38 TopoDS_Shell BRepClass3d::OuterShell(const TopoDS_Solid& aSolid)
40 Standard_Boolean bFound;
43 TopoDS_Shell aShell, aDummy;
46 BRepClass3d_SolidClassifier aSC;
48 if (aSolid.IsNull()) {
53 bFound=Standard_False;
55 // if solid has one shell, it will return, without checking orientation
56 Standard_Integer aShellCounter = 0;
57 for (aIt.Initialize(aSolid); aIt.More(); aIt.Next()) {
58 const TopoDS_Shape& aSx=aIt.Value();
59 if (aSx.ShapeType()==TopAbs_SHELL) {
60 aShell=*((TopoDS_Shell*)&aSx);
62 if (aShellCounter >= 2)
66 if (aShellCounter == 0) {
69 else if (aShellCounter == 1) {
73 for (aIt.Initialize(aSolid); aIt.More(); aIt.Next()) {
74 const TopoDS_Shape& aSx=aIt.Value();
75 if (aSx.ShapeType()==TopAbs_SHELL) {
76 aShell=*((TopoDS_Shell*)&aSx);
77 if (!IsInternal(aShell)) {
80 aBB.Add(aSDx, aShell);
83 aSC.PerformInfinitePoint(aTol);
84 if(aSC.State()==TopAbs_OUT) {
99 //=======================================================================
100 //function : IsInternal
102 //=======================================================================
103 Standard_Boolean IsInternal(const TopoDS_Shell& aSx)
105 Standard_Boolean bInternal;
106 TopAbs_Orientation aOr;
109 bInternal=Standard_False;
113 const TopoDS_Shape& aSy=aIt.Value();
114 aOr=aSy.Orientation();
115 bInternal=(aOr==TopAbs_INTERNAL);