1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-04 13:13:25 +03:00

0023129: BRepTools::OuterShell() works wrong - it always returns the first shell

This commit is contained in:
pkv
2012-09-27 12:03:12 +04:00
parent 73a97e76da
commit 4b66ae7692
3 changed files with 234 additions and 59 deletions

View File

@@ -46,22 +46,19 @@ is
DataMap from TCollection(Shape from TopoDS,
Address from Standard,
ShapeMapHasher from TopTools);
class SolidExplorer;
class SolidPassiveClassifier instantiates Classifier3d from TopClass
(Intersector3d from BRepClass3d);
class SolidPassiveClassifier instantiates
Classifier3d from TopClass (Intersector3d from BRepClass3d);
---class SClassifier instantiates SolidClassifier from TopClass
--- (SolidExplorer from BRepClass3d,
--- Intersector3d from BRepClass3d);
class SClassifier;
class SolidClassifier;
OuterShell(S : Solid from TopoDS)
returns Shell from TopoDS;
---Purpose: Returns the outer most shell of <S>. Returns a Null
-- shell if <S> has no outer shell.
end BRepClass3d;

View File

@@ -0,0 +1,112 @@
// Created on: 1993-01-21
// Created by: Peter KURNEV
// Copyright (c) 1993-1999 Matra Datavision
// Copyright (c) 1999-2012 OPEN CASCADE SAS
//
// The content of this file is subject to the Open CASCADE Technology Public
// License Version 6.5 (the "License"). You may not use the content of this file
// except in compliance with the License. Please obtain a copy of the License
// at http://www.opencascade.org and read it completely before using this file.
//
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
//
// The Original Code and all software distributed under the License is
// distributed on an "AS IS" basis, without warranty of any kind, and the
// Initial Developer hereby disclaims all such warranties, including without
// limitation, any warranties of merchantability, fitness for a particular
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
// File: BRepClass3d.cxx
// Created: Thu Sep 20 10:05:46 2012
// Author:
// <pkv@PETREX>
#include <BRepClass3d.ixx>
#include <TopAbs_State.hxx>
#include <TopAbs_Orientation.hxx>
#include <TopoDS_Solid.hxx>
#include <TopoDS_Shell.hxx>
#include <TopoDS_Iterator.hxx>
#include <BRep_Builder.hxx>
#include <BRepClass3d_SolidClassifier.hxx>
static
Standard_Boolean IsInternal(const TopoDS_Shell& aSx);
//=======================================================================
//function : OuterShell
//purpose :
//=======================================================================
TopoDS_Shell BRepClass3d::OuterShell(const TopoDS_Solid& aSolid)
{
Standard_Boolean bFound;
Standard_Real aTol;
TopoDS_Solid aSDx;
TopoDS_Shell aShell, aDummy;
TopoDS_Iterator aIt;
BRep_Builder aBB;
BRepClass3d_SolidClassifier aSC;
//
if (aSolid.IsNull()) {
return aDummy;
}
//
aTol=1.e-7;
bFound=Standard_False;
//
aIt.Initialize(aSolid);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aSx=aIt.Value();
if (aSx.ShapeType()==TopAbs_SHELL) {
aShell=*((TopoDS_Shell*)&aSx);
if (!IsInternal(aShell)) {
aSDx=aSolid;
aSDx.EmptyCopy();
aBB.Add(aSDx, aShell);
//
aSC.Load(aSDx);
aSC.PerformInfinitePoint(aTol);
if(aSC.State()==TopAbs_OUT) {
bFound=Standard_True;
break;
}
}
}
}
//
if (!bFound) {
return aDummy;
}
//
return aShell;
}
//=======================================================================
//function : IsInternal
//purpose :
//=======================================================================
Standard_Boolean IsInternal(const TopoDS_Shell& aSx)
{
Standard_Boolean bInternal;
TopAbs_Orientation aOr;
TopoDS_Iterator aIt;
//
bInternal=Standard_False;
//
aIt.Initialize(aSx);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aSy=aIt.Value();
aOr=aSy.Orientation();
bInternal=(aOr==TopAbs_INTERNAL);
break;
}
//
return bInternal;
}