mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-10 18:51:21 +03:00
0023129: BRepTools::OuterShell() works wrong - it always returns the first shell
This commit is contained in:
parent
73a97e76da
commit
4b66ae7692
@ -46,22 +46,19 @@ is
|
|||||||
DataMap from TCollection(Shape from TopoDS,
|
DataMap from TCollection(Shape from TopoDS,
|
||||||
Address from Standard,
|
Address from Standard,
|
||||||
ShapeMapHasher from TopTools);
|
ShapeMapHasher from TopTools);
|
||||||
|
|
||||||
|
|
||||||
class SolidExplorer;
|
class SolidExplorer;
|
||||||
|
|
||||||
class SolidPassiveClassifier instantiates Classifier3d from TopClass
|
class SolidPassiveClassifier instantiates
|
||||||
(Intersector3d from BRepClass3d);
|
Classifier3d from TopClass (Intersector3d from BRepClass3d);
|
||||||
|
|
||||||
---class SClassifier instantiates SolidClassifier from TopClass
|
|
||||||
--- (SolidExplorer from BRepClass3d,
|
|
||||||
--- Intersector3d from BRepClass3d);
|
|
||||||
|
|
||||||
|
|
||||||
class SClassifier;
|
class SClassifier;
|
||||||
|
|
||||||
class SolidClassifier;
|
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;
|
end BRepClass3d;
|
||||||
|
112
src/BRepClass3d/BRepClass3d.cxx
Normal file
112
src/BRepClass3d/BRepClass3d.cxx
Normal 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;
|
||||||
|
}
|
@ -37,49 +37,81 @@
|
|||||||
#include <TopAbs.hxx>
|
#include <TopAbs.hxx>
|
||||||
#include <TopoDS_Face.hxx>
|
#include <TopoDS_Face.hxx>
|
||||||
#include <TopoDS.hxx>
|
#include <TopoDS.hxx>
|
||||||
|
#include <TopoDS_Shell.hxx>
|
||||||
|
#include <TopoDS_Solid.hxx>
|
||||||
|
#include <BRepClass3d.hxx>
|
||||||
|
|
||||||
|
//
|
||||||
|
static
|
||||||
|
Standard_Boolean issame(TopoDS_Face& face,
|
||||||
|
TopoDS_Face& newface);
|
||||||
|
static
|
||||||
|
TopoDS_Face findface(TopoDS_Shape& shape,
|
||||||
|
TopoDS_Face& face);
|
||||||
|
//
|
||||||
|
static Standard_Integer shell(Draw_Interpretor&, Standard_Integer, const char** );
|
||||||
|
static Standard_Integer outershell(Draw_Interpretor&, Standard_Integer, const char** );
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : ShellCommands
|
||||||
static Standard_Boolean issame(TopoDS_Face& face, TopoDS_Face& newface)
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void BRepTest::ShellCommands(Draw_Interpretor& theCommands)
|
||||||
{
|
{
|
||||||
TopExp_Explorer exp(face,TopAbs_VERTEX),newexp(newface,TopAbs_VERTEX);
|
static Standard_Boolean loaded = Standard_False;
|
||||||
Standard_Integer newcounter=0,counter=0;
|
if (loaded) return;
|
||||||
for (;exp.More();exp.Next())
|
loaded = Standard_True;
|
||||||
{
|
|
||||||
counter++;
|
const char* g = "Projection of wire commands";
|
||||||
gp_Pnt p(BRep_Tool::Pnt(TopoDS::Vertex(exp.Current())));
|
|
||||||
for (;newexp.More();newexp.Next())
|
theCommands.Add("shell","Make shell on bugged object", __FILE__, shell,g);
|
||||||
{
|
theCommands.Add("outershell","use outershell r s", __FILE__, outershell,g);
|
||||||
gp_Pnt newp(BRep_Tool::Pnt(TopoDS::Vertex(newexp.Current())));
|
|
||||||
if (p.IsEqual(newp,1e-7))
|
}
|
||||||
{
|
//modified by NIZNHY-PKV Thu Sep 20 10:44:11 2012f
|
||||||
newcounter++;
|
//=======================================================================
|
||||||
break;
|
//function : outershell
|
||||||
};
|
//purpose :
|
||||||
};
|
//=======================================================================
|
||||||
};
|
Standard_Integer outershell(Draw_Interpretor& di, Standard_Integer n, const char** a)
|
||||||
if (counter==newcounter)
|
{
|
||||||
return Standard_True;
|
TopoDS_Shape aS;
|
||||||
return Standard_False;
|
TopoDS_Solid aSd;
|
||||||
|
TopoDS_Shell aSh;
|
||||||
|
//
|
||||||
|
if (n!=3) {
|
||||||
|
di << " use outershell r s\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aS=DBRep::Get(a[2]);
|
||||||
|
if (aS.IsNull()) {
|
||||||
|
di << " Null shape is not allowed\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (aS.ShapeType()!=TopAbs_SOLID) {
|
||||||
|
di << " The shape must be a solid\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aSd=*((TopoDS_Solid*)&aS);
|
||||||
|
//
|
||||||
|
aSh=BRepClass3d::OuterShell(aSd);
|
||||||
|
if (aSh.IsNull()) {
|
||||||
|
di << " not found\n";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
DBRep::Set(a[1],aSh);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static TopoDS_Face findface(TopoDS_Shape& shape, TopoDS_Face& face)
|
//modified by NIZNHY-PKV Thu Sep 20 10:44:17 2012t
|
||||||
{
|
//=======================================================================
|
||||||
TopoDS_Face newface;
|
//function : shell
|
||||||
TopExp_Explorer exp(shape,TopAbs_FACE);
|
//purpose :
|
||||||
for (;exp.More();exp.Next())
|
//=======================================================================
|
||||||
{
|
Standard_Integer shell(Draw_Interpretor& di, Standard_Integer n, const char** a)
|
||||||
newface = TopoDS::Face(exp.Current());
|
|
||||||
if (issame(face,newface))
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
return newface;
|
|
||||||
}
|
|
||||||
|
|
||||||
static Standard_Integer shell(Draw_Interpretor& di, Standard_Integer n, const char** a)
|
|
||||||
{
|
{
|
||||||
TopoDS_Shape Shape = DBRep::Get(a[1]);
|
TopoDS_Shape Shape = DBRep::Get(a[1]);
|
||||||
TopTools_ListOfShape ListOfCorks;
|
TopTools_ListOfShape ListOfCorks;
|
||||||
@ -117,18 +149,52 @@ static Standard_Integer shell(Draw_Interpretor& di, Standard_Integer n, const ch
|
|||||||
DBRep::Set("S",MKTS.Shape());
|
DBRep::Set("S",MKTS.Shape());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/*********************************************************************************/
|
|
||||||
|
|
||||||
void BRepTest::ShellCommands(Draw_Interpretor& theCommands)
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : issame
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
Standard_Boolean issame(TopoDS_Face& face, TopoDS_Face& newface)
|
||||||
{
|
{
|
||||||
static Standard_Boolean loaded = Standard_False;
|
TopExp_Explorer exp(face,TopAbs_VERTEX),newexp(newface,TopAbs_VERTEX);
|
||||||
if (loaded) return;
|
Standard_Integer newcounter=0,counter=0;
|
||||||
loaded = Standard_True;
|
for (;exp.More();exp.Next())
|
||||||
|
{
|
||||||
const char* g = "Projection of wire commands";
|
counter++;
|
||||||
|
gp_Pnt p(BRep_Tool::Pnt(TopoDS::Vertex(exp.Current())));
|
||||||
theCommands.Add("shell","Make shell on bugged object",
|
for (;newexp.More();newexp.Next())
|
||||||
__FILE__,
|
{
|
||||||
shell,g);
|
gp_Pnt newp(BRep_Tool::Pnt(TopoDS::Vertex(newexp.Current())));
|
||||||
|
if (p.IsEqual(newp,1e-7))
|
||||||
|
{
|
||||||
|
newcounter++;
|
||||||
|
break;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
if (counter==newcounter)
|
||||||
|
return Standard_True;
|
||||||
|
return Standard_False;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : findface
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
TopoDS_Face findface(TopoDS_Shape& shape, TopoDS_Face& face)
|
||||||
|
{
|
||||||
|
TopoDS_Face newface;
|
||||||
|
TopExp_Explorer exp(shape,TopAbs_FACE);
|
||||||
|
for (;exp.More();exp.Next())
|
||||||
|
{
|
||||||
|
newface = TopoDS::Face(exp.Current());
|
||||||
|
if (issame(face,newface))
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
return newface;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user