1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-09-03 14:10:33 +03:00

0030354: BOP Cut doesn't modify the attached face

The reason of this problem is in wrong work of classifier algorithm (see the message ~0080992 to the issue #30354). Therefore, the algorithm of IntTools_FClass2d class has been improved. Namely, now orientation of the polygon is computed from area-criterion instead of angle. As result, some simplification of the method IntTools_FClass2d::Init(...) has been made.

<!break>

1. New constructor has been added to the class CSLib_Class2d. It allows applying TColgp_SequenceOfPnt2d.

2. DRAW-commands "addpolygonnode" and "polygonprops" have been created. They are covered by the test case "tests/geometry/2dpolygon/A1".

3. New method Poly::PolygonProperties(...) has been created. See help for detailed information.

4. New testgrid "lowalgos classifier" has been created.
This commit is contained in:
nbv
2018-11-09 10:22:55 +03:00
committed by apn
parent dc57476a0e
commit 5fe14d0fac
27 changed files with 478 additions and 234 deletions

View File

@@ -26,82 +26,97 @@ static inline
const Standard_Real umaxmumin);
//=======================================================================
//function : CSLib_Class2d
//purpose :
//function : Init
//purpose :
//=======================================================================
CSLib_Class2d::CSLib_Class2d(const TColgp_Array1OfPnt2d& TP2d,
const Standard_Real aTolu,
const Standard_Real aTolv,
const Standard_Real umin,
const Standard_Real vmin,
const Standard_Real umax,
const Standard_Real vmax)
template <class TCol_Containers2d>
void CSLib_Class2d::Init(const TCol_Containers2d& TP2d,
const Standard_Real aTolu,
const Standard_Real aTolv,
const Standard_Real umin,
const Standard_Real vmin,
const Standard_Real umax,
const Standard_Real vmax)
{
Umin=umin;
Vmin=vmin;
Umax=umax;
Vmax=vmax;
Umin = umin;
Vmin = vmin;
Umax = umax;
Vmax = vmax;
//
if(umax<=umin || vmax<=vmin) {
MyPnts2dX=NULL;
MyPnts2dY=NULL;
N=0;
if ((umax <= umin) || (vmax <= vmin) || (TP2d.Length() < 3))
{
MyPnts2dX.Nullify();
MyPnts2dY.Nullify();
N = 0;
}
//
else {
else
{
Standard_Integer i, iLower;
Standard_Real du,dv,*Pnts2dX,*Pnts2dY, aPrc;
Standard_Real du, dv, aPrc;
//
aPrc=1.e-10;
aPrc = 1.e-10;
N = TP2d.Length();
Tolu = aTolu;
Tolv = aTolv;
MyPnts2dX = new Standard_Real [N+1];
MyPnts2dY = new Standard_Real [N+1];
du=umax-umin;
dv=vmax-vmin;
Pnts2dX = (Standard_Real *)MyPnts2dX;
Pnts2dY = (Standard_Real *)MyPnts2dY;
MyPnts2dX = new TColStd_Array1OfReal(0, N);
MyPnts2dY = new TColStd_Array1OfReal(0, N);
du = umax - umin;
dv = vmax - vmin;
//
iLower=TP2d.Lower();
for(i = 0; i<N; ++i) {
const gp_Pnt2d& aP2D=TP2d(i+iLower);
Pnts2dX[i] = Transform2d(aP2D.X(), umin, du);
Pnts2dY[i] = Transform2d(aP2D.Y(), vmin, dv);
iLower = TP2d.Lower();
for (i = 0; i<N; ++i)
{
const gp_Pnt2d& aP2D = TP2d(i + iLower);
MyPnts2dX->ChangeValue(i) = Transform2d(aP2D.X(), umin, du);
MyPnts2dY->ChangeValue(i) = Transform2d(aP2D.Y(), vmin, dv);
}
Pnts2dX[N]=Pnts2dX[0];
Pnts2dY[N]=Pnts2dY[0];
MyPnts2dX->ChangeLast() = MyPnts2dX->First();
MyPnts2dY->ChangeLast() = MyPnts2dY->First();
//
if(du>aPrc) {
Tolu/=du;
if (du>aPrc)
{
Tolu /= du;
}
if(dv>aPrc) {
Tolv/=dv;
if (dv>aPrc)
{
Tolv /= dv;
}
}
}
//=======================================================================
//function : Destroy
//purpose :
//=======================================================================
void CSLib_Class2d::Destroy() {
if(MyPnts2dX) {
delete [] (Standard_Real *)MyPnts2dX;
MyPnts2dX=NULL;
}
if(MyPnts2dY) {
delete [] (Standard_Real *)MyPnts2dY;
MyPnts2dY=NULL;
}
}
//-- Attention Table of 0 ------> N + 1
//-- P1 ..... Pn P1
//--
//-- 1 2 3
//-- 4 0 5
//-- 6 7 8
//--
//=======================================================================
//function : CSLib_Class2d
//purpose :
//=======================================================================
CSLib_Class2d::CSLib_Class2d(const TColgp_Array1OfPnt2d& thePnts2d,
const Standard_Real theTolU,
const Standard_Real theTolV,
const Standard_Real theUMin,
const Standard_Real theVMin,
const Standard_Real theUMax,
const Standard_Real theVMax)
{
Init(thePnts2d, theTolU, theTolV, theUMin,
theVMin, theUMax, theVMax);
}
//=======================================================================
//function : CSLib_Class2d
//purpose :
//=======================================================================
CSLib_Class2d::CSLib_Class2d(const TColgp_SequenceOfPnt2d& thePnts2d,
const Standard_Real theTolU,
const Standard_Real theTolV,
const Standard_Real theUMin,
const Standard_Real theVMin,
const Standard_Real theUMax,
const Standard_Real theVMax)
{
Init(thePnts2d, theTolU, theTolV, theUMin,
theVMin, theUMax, theVMax);
}
//=======================================================================
//function : SiDans
//purpose :
@@ -187,21 +202,18 @@ Standard_Integer CSLib_Class2d::InternalSiDans(const Standard_Real Px,
const Standard_Real Py) const
{
Standard_Integer nbc, i, ip1, SH, NH;
Standard_Real *Pnts2dX, *Pnts2dY;
Standard_Real x, y, nx, ny;
//
nbc = 0;
i = 0;
ip1 = 1;
Pnts2dX = (Standard_Real *)MyPnts2dX;
Pnts2dY = (Standard_Real *)MyPnts2dY;
x = (Pnts2dX[i]-Px);
y = (Pnts2dY[i]-Py);
x = (MyPnts2dX->Value(i)-Px);
y = (MyPnts2dY->Value(i)-Py);
SH = (y<0.)? -1 : 1;
//
for(i=0; i<N ; i++,ip1++) {
nx = Pnts2dX[ip1] - Px;
ny = Pnts2dY[ip1] - Py;
nx = MyPnts2dX->Value(ip1) - Px;
ny = MyPnts2dY->Value(ip1) - Py;
NH = (ny<0.)? -1 : 1;
if(NH!=SH) {
@@ -230,23 +242,20 @@ Standard_Integer CSLib_Class2d::InternalSiDansOuOn(const Standard_Real Px,
const Standard_Real Py) const
{
Standard_Integer nbc, i, ip1, SH, NH, iRet;
Standard_Real *Pnts2dX, *Pnts2dY;
Standard_Real x, y, nx, ny, aX;
Standard_Real aYmin;
//
nbc = 0;
i = 0;
ip1 = 1;
Pnts2dX = (Standard_Real *)MyPnts2dX;
Pnts2dY = (Standard_Real *)MyPnts2dY;
x = (Pnts2dX[i]-Px);
y = (Pnts2dY[i]-Py);
x = (MyPnts2dX->Value(i)-Px);
y = (MyPnts2dY->Value(i)-Py);
aYmin=y;
SH = (y<0.)? -1 : 1;
for(i=0; i<N ; i++, ip1++) {
nx = Pnts2dX[ip1] - Px;
ny = Pnts2dY[ip1] - Py;
nx = MyPnts2dX->Value(ip1) - Px;
ny = MyPnts2dY->Value(ip1) - Py;
//-- le 14 oct 97
if(nx<Tolu && nx>-Tolu && ny<Tolv && ny>-Tolv) {
iRet=-1;
@@ -254,11 +263,11 @@ Standard_Integer CSLib_Class2d::InternalSiDansOuOn(const Standard_Real Px,
}
//find Y coordinate of polyline for current X gka
//in order to detect possible status ON
Standard_Real aDx = (Pnts2dX[ip1] - Pnts2dX[ip1-1]);
if( (Pnts2dX[ip1-1] - Px) * nx < 0.)
Standard_Real aDx = (MyPnts2dX->Value(ip1) - MyPnts2dX->Value(ip1-1));
if( (MyPnts2dX->Value(ip1-1) - Px) * nx < 0.)
{
Standard_Real aCurPY = Pnts2dY[ip1] - (Pnts2dY[ip1] - Pnts2dY[ip1-1])/aDx *nx;
Standard_Real aCurPY = MyPnts2dY->Value(ip1) - (MyPnts2dY->Value(ip1) - MyPnts2dY->Value(ip1-1))/aDx *nx;
Standard_Real aDeltaY = aCurPY - Py;
if(aDeltaY >= -Tolv && aDeltaY <= Tolv)
{
@@ -296,17 +305,6 @@ Standard_Integer CSLib_Class2d::InternalSiDansOuOn(const Standard_Real Px,
}
//modified by NIZNHY-PKV Fri Jan 15 09:03:55 2010t
//=======================================================================
//function : Copy
//purpose :
//=======================================================================
const CSLib_Class2d& CSLib_Class2d::Copy(const CSLib_Class2d& ) const
{
#ifdef OCCT_DEBUG
cerr<<"Copy not allowed in CSLib_Class2d"<<endl;
#endif
throw Standard_ConstructionError();
}
//=======================================================================
//function : Transform2d
//purpose :
//=======================================================================

View File

@@ -25,6 +25,10 @@
#include <Standard_Real.hxx>
#include <Standard_Integer.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
#include <NCollection_Handle.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <TColgp_SequenceOfPnt2d.hxx>
class gp_Pnt2d;
@@ -38,8 +42,38 @@ public:
DEFINE_STANDARD_ALLOC
Standard_EXPORT CSLib_Class2d(const TColgp_Array1OfPnt2d& TP, const Standard_Real aTolu, const Standard_Real aTolv, const Standard_Real umin, const Standard_Real vmin, const Standard_Real umax, const Standard_Real vmax);
//! Constructs the 2D-polygon.
//! thePnts2d is the set of the vertices (closed polygon
//! will always be created inside of this constructor;
//! consequently, there is no point in repeating first and
//! last point in thePnts2d).
//! theTolu and theTolv are tolerances.
//! theUmin, theVmin, theUmax, theVmax are
//! UV-bounds of the polygon.
Standard_EXPORT CSLib_Class2d(const TColgp_Array1OfPnt2d& thePnts2d,
const Standard_Real theTolU,
const Standard_Real theTolV,
const Standard_Real theUMin,
const Standard_Real theVMin,
const Standard_Real theUMax,
const Standard_Real theVMax);
//! Constructs the 2D-polygon.
//! thePnts2d is the set of the vertices (closed polygon
//! will always be created inside of this constructor;
//! consequently, there is no point in repeating first and
//! last point in thePnts2d).
//! theTolu and theTolv are tolerances.
//! theUmin, theVmin, theUmax, theVmax are
//! UV-bounds of the polygon.
Standard_EXPORT CSLib_Class2d(const TColgp_SequenceOfPnt2d& thePnts2d,
const Standard_Real theTolU,
const Standard_Real theTolV,
const Standard_Real theUMin,
const Standard_Real theVMin,
const Standard_Real theUMax,
const Standard_Real theVMax);
Standard_EXPORT Standard_Integer SiDans (const gp_Pnt2d& P) const;
Standard_EXPORT Standard_Integer SiDans_OnMode (const gp_Pnt2d& P, const Standard_Real Tol) const;
@@ -48,33 +82,25 @@ public:
Standard_EXPORT Standard_Integer InternalSiDansOuOn (const Standard_Real X, const Standard_Real Y) const;
Standard_EXPORT const CSLib_Class2d& Copy (const CSLib_Class2d& Other) const;
const CSLib_Class2d& operator= (const CSLib_Class2d& Other) const
{
return Copy(Other);
}
Standard_EXPORT void Destroy();
~CSLib_Class2d()
{
Destroy();
}
protected:
private:
//! Initializes theObj
template <class TCol_Containers2d>
void Init(const TCol_Containers2d& TP2d,
const Standard_Real aTolu,
const Standard_Real aTolv,
const Standard_Real umin,
const Standard_Real vmin,
const Standard_Real umax,
const Standard_Real vmax);
//! Assign operator is forbidden
const CSLib_Class2d& operator= (const CSLib_Class2d& Other) const;
Standard_Address MyPnts2dX;
Standard_Address MyPnts2dY;
NCollection_Handle <TColStd_Array1OfReal> MyPnts2dX, MyPnts2dY;
Standard_Real Tolu;
Standard_Real Tolv;
Standard_Integer N;