0022177: [CEA 799] RemoveExtraEdges produces non valid faces

This commit is contained in:
skv 2013-07-23 12:27:25 +00:00
parent bf782252cf
commit 5c1fd84469
3 changed files with 27 additions and 89 deletions

View File

@ -40,7 +40,7 @@
#include <gp_Pnt.hxx> #include <gp_Pnt.hxx>
#include <gp_Dir.hxx> #include <gp_Dir.hxx>
#include <gp_Pln.hxx> #include <gp_Pln.hxx>
#include <gp_Ax1.hxx> #include <gp_Ax3.hxx>
#include <Geom_Plane.hxx> #include <Geom_Plane.hxx>
IMPLEMENT_STANDARD_HANDLE(GEOMAlgo_ClsfBox, GEOMAlgo_Clsf) IMPLEMENT_STANDARD_HANDLE(GEOMAlgo_ClsfBox, GEOMAlgo_Clsf)
@ -128,17 +128,22 @@ IMPLEMENT_STANDARD_RTTIEXT(GEOMAlgo_ClsfBox, GEOMAlgo_Clsf)
} }
// //
if(aOr==TopAbs_REVERSED) { if(aOr==TopAbs_REVERSED) {
gp_Ax1 aAx1; gp_Ax3 aPos;
gp_Pln aPln; gp_Pln aPln;
gp_Pnt aP; gp_Pnt aP;
gp_Dir aD; gp_Dir aD;
Handle(Geom_Plane) aSR; Handle(Geom_Plane) aSR;
// //
aPln=myGAS[i-1].Plane(); aPln=myGAS[i-1].Plane();
aAx1=aPln.Axis(); aPos=aPln.Position();
aP=aAx1.Location(); aP=aPos.Location();
aD=aAx1.Direction(); aD=aPos.Direction();
aD.Reverse();
// Is aPos is not direct, aD is already a reversed direction.
if (aPos.Direct()) {
aD.Reverse();
}
aSR=new Geom_Plane(aP, aD); aSR=new Geom_Plane(aP, aD);
myGAS[i-1].Load(aSR); myGAS[i-1].Load(aSR);
} }

View File

@ -41,6 +41,7 @@
#include <GeomAbs_SurfaceType.hxx> #include <GeomAbs_SurfaceType.hxx>
#include <GeomAdaptor_Surface.hxx> #include <GeomAdaptor_Surface.hxx>
#include <IntSurf_Quadric.hxx>
//======================================================================= //=======================================================================
@ -52,34 +53,23 @@
const Standard_Real aTol, const Standard_Real aTol,
TopAbs_State& aState) TopAbs_State& aState)
{ {
Standard_Integer iErr; Standard_Integer iErr = 0;
Standard_Real aDp, aR; GeomAbs_SurfaceType aType = aGAS.GetType();
GeomAbs_SurfaceType aType; IntSurf_Quadric aQuad;
gp_Sphere aSph;
gp_Cylinder aCyl;
gp_Pln aPln;
// //
iErr=0; aState = TopAbs_UNKNOWN;
aState=TopAbs_UNKNOWN;
// //
aType=aGAS.GetType();
switch (aType) { switch (aType) {
case GeomAbs_Plane: case GeomAbs_Plane:
aPln=aGAS.Plane(); aQuad.SetValue(aGAS.Plane());
aR=0.;
aDp=GEOMAlgo_SurfaceTools::Distance(aP, aPln);
break; break;
case GeomAbs_Cylinder: case GeomAbs_Cylinder:
aCyl=aGAS.Cylinder(); aQuad.SetValue(aGAS.Cylinder());
aR=aCyl.Radius();
aDp=GEOMAlgo_SurfaceTools::Distance(aP, aCyl);
break; break;
case GeomAbs_Sphere: case GeomAbs_Sphere:
aSph=aGAS.Sphere(); aQuad.SetValue(aGAS.Sphere());
aR=aSph.Radius();
aDp=GEOMAlgo_SurfaceTools::Distance(aP, aSph);
break; break;
default: default:
@ -88,12 +78,14 @@
} }
// //
if (!iErr) { if (!iErr) {
aState=TopAbs_ON; const Standard_Real aDp = aQuad.Distance(aP);
if (aDp>aR+aTol) { //
aState=TopAbs_OUT; aState = TopAbs_ON;
} //
else if (aDp<aR-aTol) { if (aDp > aTol) {
aState=TopAbs_IN; aState = TopAbs_OUT;
} else if (aDp < -aTol) {
aState = TopAbs_IN;
} }
} }
// //
@ -140,53 +132,6 @@
return aRSt; return aRSt;
} }
//======================================================================= //=======================================================================
//function : Distance
//purpose :
//=======================================================================
Standard_Real GEOMAlgo_SurfaceTools::Distance(const gp_Pnt& aP,
const gp_Sphere& aSph)
{
Standard_Real aD;
//
const gp_Pnt& aLoc=aSph.Location();
aD=aLoc.Distance(aP);
//
return aD;
}
//=======================================================================
//function : Distance
//purpose :
//=======================================================================
Standard_Real GEOMAlgo_SurfaceTools::Distance(const gp_Pnt& aP,
const gp_Cylinder& aCyl)
{
Standard_Real aD;
//
const gp_Ax1& aAxis=aCyl.Axis();
gp_Lin aLin(aAxis);
aD=aLin.Distance(aP);
//
return aD;
}
//=======================================================================
//function : Distance
//purpose :
//=======================================================================
Standard_Real GEOMAlgo_SurfaceTools::Distance(const gp_Pnt& aP,
const gp_Pln& aPL)
{
Standard_Real aD;
//
const gp_Ax3& aPos=aPL.Position();
const gp_Pnt& aLoc=aPos.Location ();
const gp_Dir& aDir=aPos.Direction();
//
aD= (aDir.X() * (aP.X() - aLoc.X()) +
aDir.Y() * (aP.Y() - aLoc.Y()) +
aDir.Z() * (aP.Z() - aLoc.Z()));
return aD;
}
//=======================================================================
//function : IsCoaxial //function : IsCoaxial
//purpose : //purpose :
//======================================================================= //=======================================================================

View File

@ -75,18 +75,6 @@ class GEOMAlgo_SurfaceTools
const Standard_Real aTol, const Standard_Real aTol,
TopAbs_State& aSt) ; TopAbs_State& aSt) ;
Standard_EXPORT
static Standard_Real Distance(const gp_Pnt& aP,
const gp_Pln& aPln) ;
Standard_EXPORT
static Standard_Real Distance(const gp_Pnt& aP,
const gp_Cylinder& aCyl) ;
Standard_EXPORT
static Standard_Real Distance(const gp_Pnt& aP,
const gp_Sphere& aSph) ;
Standard_EXPORT Standard_EXPORT
static TopAbs_State ReverseState(const TopAbs_State aSt) ; static TopAbs_State ReverseState(const TopAbs_State aSt) ;