1 // Created on: 1993-01-21
2 // Created by: Peter KURNEV
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
21 // File: BRepClass3d.cxx
22 // Created: Thu Sep 20 10:05:46 2012
26 #include <BRepClass3d.ixx>
29 #include <TopAbs_State.hxx>
30 #include <TopAbs_Orientation.hxx>
32 #include <TopoDS_Solid.hxx>
33 #include <TopoDS_Shell.hxx>
34 #include <TopoDS_Iterator.hxx>
36 #include <BRep_Builder.hxx>
37 #include <BRepClass3d_SolidClassifier.hxx>
41 Standard_Boolean IsInternal(const TopoDS_Shell& aSx);
43 //=======================================================================
44 //function : OuterShell
46 //=======================================================================
47 TopoDS_Shell BRepClass3d::OuterShell(const TopoDS_Solid& aSolid)
49 Standard_Boolean bFound;
52 TopoDS_Shell aShell, aDummy;
55 BRepClass3d_SolidClassifier aSC;
57 if (aSolid.IsNull()) {
62 bFound=Standard_False;
64 // if solid has one shell, it will return, without checking orientation
65 Standard_Integer aShellCounter = 0;
66 for (aIt.Initialize(aSolid); aIt.More(); aIt.Next()) {
67 const TopoDS_Shape& aSx=aIt.Value();
68 if (aSx.ShapeType()==TopAbs_SHELL) {
69 aShell=*((TopoDS_Shell*)&aSx);
71 if (aShellCounter >= 2)
75 if (aShellCounter == 0) {
78 else if (aShellCounter == 1) {
82 for (aIt.Initialize(aSolid); aIt.More(); aIt.Next()) {
83 const TopoDS_Shape& aSx=aIt.Value();
84 if (aSx.ShapeType()==TopAbs_SHELL) {
85 aShell=*((TopoDS_Shell*)&aSx);
86 if (!IsInternal(aShell)) {
89 aBB.Add(aSDx, aShell);
92 aSC.PerformInfinitePoint(aTol);
93 if(aSC.State()==TopAbs_OUT) {
108 //=======================================================================
109 //function : IsInternal
111 //=======================================================================
112 Standard_Boolean IsInternal(const TopoDS_Shell& aSx)
114 Standard_Boolean bInternal;
115 TopAbs_Orientation aOr;
118 bInternal=Standard_False;
121 for (; aIt.More(); aIt.Next()) {
122 const TopoDS_Shape& aSy=aIt.Value();
123 aOr=aSy.Orientation();
124 bInternal=(aOr==TopAbs_INTERNAL);