1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-05 18:16:23 +03:00

0023089: Wrong result done by solid classifier algorithm

This commit is contained in:
pkv 2012-04-10 09:08:37 +04:00
parent 3946774d9e
commit 7d9b843ce9

View File

@ -20,7 +20,7 @@
// Modified by skv - Wed Sep 3 16:14:10 2003 OCC578
#define OPTIMISATION 1
@ -61,16 +61,26 @@
GeomAbs_SurfaceType IntCurvesFace_Intersector::SurfaceType() const {
//=======================================================================
//function : SurfaceType
//purpose :
//=======================================================================
GeomAbs_SurfaceType IntCurvesFace_Intersector::SurfaceType() const
{
return(Adaptor3d_HSurfaceTool::GetType(Hsurface));
}
//============================================================================
//=======================================================================
//function : IntCurvesFace_Intersector
//purpose :
//=======================================================================
IntCurvesFace_Intersector::IntCurvesFace_Intersector(const TopoDS_Face& Face,
const Standard_Real aTol)
:
Tol(aTol),done(Standard_False),nbpnt(0),PtrOnPolyhedron(NULL),PtrOnBndBounding(NULL)
Tol(aTol),
done(Standard_False),
nbpnt(0),
PtrOnPolyhedron(NULL),
PtrOnBndBounding(NULL)
{
BRepAdaptor_Surface surface;
face = Face;
@ -90,20 +100,63 @@ IntCurvesFace_Intersector::IntCurvesFace_Intersector(const TopoDS_Face& Face,
U1 = Hsurface->LastUParameter();
V0 = Hsurface->FirstVParameter();
V1 = Hsurface->LastVParameter();
//-- nbsu = Adaptor3d_HSurfaceTool::NbSamplesU(Hsurface,U0,U1);
//-- nbsv = Adaptor3d_HSurfaceTool::NbSamplesV(Hsurface,V0,V1);
//modified by NIZNHY-PKV Fri Apr 06 07:30:47 2012f
Standard_Boolean bFlag;
//
{
Standard_Real dU, dV, dA, dB, aR, aTresh;
bFlag=Standard_True;
//
aTresh=100.;
dU=U1-U0;
dV=V1-V0;
dA=dU;
dB=dV;
if (dV>dU) {
dA=dV;
dB=dU;
}
//
aR=dA/dB;
if (dB<Precision::PConfusion()) {
bFlag=!bFlag;
}
else {
if (aR>aTresh) {
bFlag=!bFlag;
}
}
}
//
if (bFlag) {
nbsu = myTopolTool->NbSamplesU();
nbsv = myTopolTool->NbSamplesV();
if(nbsu>40) nbsu = 40;
if(nbsv>40) nbsv = 40;
//-- printf("\n IntCurvesFace_Intersector : nbsu=(%3d)->%3d nbsv=(%3d)->%3d",myTopolTool->NbSamplesU(),nbsu,myTopolTool->NbSamplesV(),nbsv);
PtrOnPolyhedron = (IntCurveSurface_ThePolyhedronOfHInter *) new IntCurveSurface_ThePolyhedronOfHInter(Hsurface,nbsu,nbsv,U0,V0,U1,V1);
PtrOnPolyhedron = (IntCurveSurface_ThePolyhedronOfHInter *)
new IntCurveSurface_ThePolyhedronOfHInter(Hsurface,nbsu,nbsv,U0,V0,U1,V1);
}
//
/*
nbsu = myTopolTool->NbSamplesU();
nbsv = myTopolTool->NbSamplesV();
if(nbsu>40) nbsu = 40;
if(nbsv>40) nbsv = 40;
PtrOnPolyhedron = (IntCurveSurface_ThePolyhedronOfHInter *)
new IntCurveSurface_ThePolyhedronOfHInter(Hsurface,nbsu,nbsv,U0,V0,U1,V1);
*/
//modified by NIZNHY-PKV Fri Apr 06 07:30:49 2012t
}
}
//============================================================================
//=======================================================================
//function : InternalCall
//purpose :
//=======================================================================
void IntCurvesFace_Intersector::InternalCall(const IntCurveSurface_HInter &HICS,
const Standard_Real parinf,const Standard_Real parsup) {
const Standard_Real parinf,
const Standard_Real parsup)
{
if(HICS.IsDone()) {
for(Standard_Integer index=HICS.NbPoints(); index>=1; index--) {
const IntCurveSurface_IntersectionPoint& HICSPointindex = HICS.Point(index);
@ -167,37 +220,36 @@ void IntCurvesFace_Intersector::InternalCall(const IntCurveSurface_HInter &HICS,
} //-- Loop on Intersection points.
} //-- HICS.IsDone()
}
//--------------------------------------------------------------------------------
void IntCurvesFace_Intersector::Perform(const gp_Lin& L,const Standard_Real ParMin,const Standard_Real ParMax) {
//=======================================================================
//function : Perform
//purpose :
//=======================================================================
void IntCurvesFace_Intersector::Perform(const gp_Lin& L,
const Standard_Real ParMin,
const Standard_Real ParMax)
{
done = Standard_True;
SeqPnt.Clear();
// Modified by skv - Wed Sep 3 16:14:10 2003 OCC578 Begin
mySeqState.Clear();
// Modified by skv - Wed Sep 3 16:14:11 2003 OCC578 End
nbpnt = 0;
IntCurveSurface_HInter HICS;
IntCurveSurface_HInter HICS;
Handle(Geom_Line) geomline = new Geom_Line(L);
GeomAdaptor_Curve LL(geomline);
//--
Handle(GeomAdaptor_HCurve) HLL = new GeomAdaptor_HCurve(LL);
//--
Standard_Real parinf=ParMin;
Standard_Real parsup=ParMax;
//
if(PtrOnPolyhedron == NULL) {
HICS.Perform(HLL,Hsurface);
}
else {
Intf_Tool bndTool;
Bnd_Box boxLine;
bndTool.LinBox(L,((IntCurveSurface_ThePolyhedronOfHInter *)PtrOnPolyhedron)->Bounding(),boxLine);
bndTool.LinBox
(L,
((IntCurveSurface_ThePolyhedronOfHInter *)PtrOnPolyhedron)->Bounding(),
boxLine);
if(bndTool.NbSegments() == 0)
return;
for(Standard_Integer nbseg=1; nbseg<= bndTool.NbSegments(); nbseg++) {
@ -225,8 +277,10 @@ void IntCurvesFace_Intersector::Perform(const gp_Lin& L,const Standard_Real ParM
#if OPTIMISATION
if(PtrOnBndBounding==NULL) {
PtrOnBndBounding = (Bnd_BoundSortBox *) new Bnd_BoundSortBox();
IntCurveSurface_ThePolyhedronOfHInter *thePolyh=(IntCurveSurface_ThePolyhedronOfHInter *)PtrOnPolyhedron;
((Bnd_BoundSortBox *)(PtrOnBndBounding))->Initialize(IntCurveSurface_ThePolyhedronToolOfHInter::Bounding(*thePolyh),
IntCurveSurface_ThePolyhedronOfHInter *thePolyh=
(IntCurveSurface_ThePolyhedronOfHInter *)PtrOnPolyhedron;
((Bnd_BoundSortBox *)(PtrOnBndBounding))->
Initialize(IntCurveSurface_ThePolyhedronToolOfHInter::Bounding(*thePolyh),
IntCurveSurface_ThePolyhedronToolOfHInter::ComponentsBounding(*thePolyh));
}
HICS.Perform(HLL,
@ -243,77 +297,15 @@ void IntCurvesFace_Intersector::Perform(const gp_Lin& L,const Standard_Real ParM
}
InternalCall(HICS,parinf,parsup);
#if 0
if(HICS.IsDone()) {
for(Standard_Integer index=HICS.NbPoints(); index>=1; index--) {
const IntCurveSurface_IntersectionPoint& HICSPointindex = HICS.Point(index);
gp_Pnt2d Puv(HICSPointindex.U(),HICSPointindex.V());
TopAbs_State currentstate = myTopolTool->Classify(Puv,Tol);
if(currentstate==TopAbs_IN || currentstate==TopAbs_ON) {
Standard_Real HICSW = HICSPointindex.W();
if(HICSW >= parinf && HICSW <= parsup ) {
Standard_Real U = HICSPointindex.U();
Standard_Real V = HICSPointindex.V();
Standard_Real W = HICSW;
IntCurveSurface_TransitionOnCurve transition = HICSPointindex.Transition();
gp_Pnt pnt = HICSPointindex.Pnt();
// state = currentstate;
// Modified by skv - Wed Sep 3 16:14:10 2003 OCC578 Begin
Standard_Integer anIntState = (currentstate == TopAbs_IN) ? 0 : 1;
// Modified by skv - Wed Sep 3 16:14:11 2003 OCC578 End
if(face.Orientation()==TopAbs_REVERSED) {
if(transition == IntCurveSurface_In)
transition = IntCurveSurface_Out;
else
transition = IntCurveSurface_In;
}
//----- Insertion du point
if(nbpnt==0) {
IntCurveSurface_IntersectionPoint PPP(pnt,U,V,W,transition);
SeqPnt.Append(PPP);
// Modified by skv - Wed Sep 3 16:14:10 2003 OCC578 Begin
mySeqState.Append(anIntState);
// Modified by skv - Wed Sep 3 16:14:11 2003 OCC578 End
}
else {
Standard_Integer i = 1;
Standard_Integer b = nbpnt+1;
while(i<=nbpnt) {
const IntCurveSurface_IntersectionPoint& Pnti=SeqPnt.Value(i);
Standard_Real wi = Pnti.W();
if(wi >= W) { b=i; i=nbpnt; }
i++;
}
IntCurveSurface_IntersectionPoint PPP(pnt,U,V,W,transition);
// Modified by skv - Wed Sep 3 16:14:10 2003 OCC578 Begin
// if(b>nbpnt) { SeqPnt.Append(PPP); }
// else if(b>0) { SeqPnt.InsertBefore(b,PPP); }
if(b>nbpnt) {
SeqPnt.Append(PPP);
mySeqState.Append(anIntState);
} else if(b>0) {
SeqPnt.InsertBefore(b,PPP);
mySeqState.InsertBefore(b, anIntState);
}
// Modified by skv - Wed Sep 3 16:14:11 2003 OCC578 End
}
nbpnt++;
}
} //-- classifier state is IN or ON
} //-- Loop on Intersection points.
} //-- HICS.IsDone()
#endif
}
//============================================================================
void IntCurvesFace_Intersector::Perform(const Handle(Adaptor3d_HCurve)& HCu,const Standard_Real ParMin,const Standard_Real ParMax) {
//=======================================================================
//function : Perform
//purpose :
//=======================================================================
void IntCurvesFace_Intersector::Perform(const Handle(Adaptor3d_HCurve)& HCu,
const Standard_Real ParMin,
const Standard_Real ParMax)
{
done = Standard_True;
SeqPnt.Clear();
// Modified by skv - Wed Sep 3 16:14:10 2003 OCC578 Begin