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

0024255: Regressions in test cases on OCCT vc9 win64 Release

Updated test-cases from branch CR24255_3

0024255: Regressions in test cases on OCCT vc9 win64 Release

Small refactoring.

Fix for CASE bugs modalg_5 bug25298_09: FAILED (error)

Test-cases correction (bugs modalg_5 bugs25804_1, bug25704_2)
This commit is contained in:
ifv
2015-02-12 14:38:39 +03:00
committed by bugmaster
parent 48e653b689
commit 873c119ff1
102 changed files with 4301 additions and 3440 deletions

View File

@@ -21,6 +21,7 @@
#include <Geom2d_Point.hxx>
#include <Geom2d_CartesianPoint.hxx>
#include <Geom2d_TrimmedCurve.hxx>
#include <Geom2d_BSplineCurve.hxx>
#include <gp.hxx>
#include <gp_Pnt2d.hxx>
#include <gp_Vec2d.hxx>
@@ -31,21 +32,27 @@
#include <Bisector_BisecAna.hxx>
#include <Bisector_BisecPC.hxx>
#include <Bisector_BisecCC.hxx>
#include <GCE2d_MakeSegment.hxx>
/*
#ifdef OCCT_DEBUG
//#define DRAW
#ifdef DRAW
#include <DrawTrSurf.hxx>
static char tname[100];
static Standard_CString name = tname ;
#pragma comment(lib, "TKDraw.lib")
static char name[100];
static Standard_Integer nbb = 0;
*/
static Standard_Boolean Affich = Standard_False;
#endif
#endif
static Standard_Boolean IsMaxRC (const Handle(Geom2d_Curve)& C,
Standard_Real U,
Standard_Real& R);
Standard_Real U,
Standard_Real& R);
static void ReplaceByLineIfIsToSmall (Handle(Geom2d_Curve)& Bis,
Standard_Real& UFirst,
Standard_Real& ULast);
Standard_Real& UFirst,
Standard_Real& ULast);
//=============================================================================
//function : Empty Constructor
//=============================================================================
@@ -66,48 +73,97 @@ Bisector_Bisec::Bisector_Bisec()
//===========================================================================
void Bisector_Bisec::Perform(const Handle(Geom2d_Curve)& afirstcurve ,
const Handle(Geom2d_Curve)& asecondcurve ,
const gp_Pnt2d& apoint ,
const gp_Vec2d& afirstvector ,
const gp_Vec2d& asecondvector ,
const Standard_Real adirection ,
const Standard_Real tolerance ,
const Standard_Boolean oncurve )
const Handle(Geom2d_Curve)& asecondcurve ,
const gp_Pnt2d& apoint ,
const gp_Vec2d& afirstvector ,
const gp_Vec2d& asecondvector ,
const Standard_Real adirection ,
const Standard_Real tolerance ,
const Standard_Boolean oncurve )
{
Handle(Standard_Type) Type1 = afirstcurve ->DynamicType();
Handle(Standard_Type) Type2 = asecondcurve->DynamicType();
Handle(Bisector_Curve) Bis;
Standard_Real UFirst,ULast;
if (Type1 == STANDARD_TYPE(Geom2d_TrimmedCurve)) {
Type1 = Handle(Geom2d_TrimmedCurve)::DownCast(afirstcurve)
->BasisCurve()->DynamicType();
->BasisCurve()->DynamicType();
}
if (Type2 == STANDARD_TYPE(Geom2d_TrimmedCurve)) {
Type2 = Handle(Geom2d_TrimmedCurve)::DownCast(asecondcurve)
->BasisCurve()->DynamicType();
->BasisCurve()->DynamicType();
}
Handle(Geom2d_Curve) afirstcurve1 = afirstcurve;
Handle(Geom2d_Curve) asecondcurve1 = asecondcurve;
if(Type1 == STANDARD_TYPE(Geom2d_BSplineCurve))
{
Handle(Geom2d_BSplineCurve) aBS;
if(afirstcurve->DynamicType() == STANDARD_TYPE(Geom2d_TrimmedCurve))
{
aBS = Handle(Geom2d_BSplineCurve)::DownCast(Handle(Geom2d_TrimmedCurve)::DownCast(afirstcurve)
->BasisCurve());
}
else
{
aBS = Handle(Geom2d_BSplineCurve)::DownCast(afirstcurve);
}
if(aBS->Degree() == 1 && aBS->NbPoles() == 2)
{
if(aBS->Pole(1).Distance(aBS->Pole(2)) < 1.e-4)
{
afirstcurve1 = GCE2d_MakeSegment(aBS->Pole(1), aBS->Pole(2));
Type1 = STANDARD_TYPE(Geom2d_Line);
}
}
}
if(Type2 == STANDARD_TYPE(Geom2d_BSplineCurve))
{
Handle(Geom2d_BSplineCurve) aBS;
if(asecondcurve->DynamicType() == STANDARD_TYPE(Geom2d_TrimmedCurve))
{
aBS = Handle(Geom2d_BSplineCurve)::DownCast(Handle(Geom2d_TrimmedCurve)::DownCast(asecondcurve)
->BasisCurve());
}
else
{
aBS = Handle(Geom2d_BSplineCurve)::DownCast(asecondcurve);
}
if(aBS->Degree() == 1 && aBS->NbPoles() == 2)
{
if(aBS->Pole(1).Distance(aBS->Pole(2)) < 1.e-4)
{
asecondcurve1 = GCE2d_MakeSegment(aBS->Pole(1), aBS->Pole(2));
Type2 = STANDARD_TYPE(Geom2d_Line);
}
}
}
if ( (Type1 == STANDARD_TYPE(Geom2d_Circle) || Type1 == STANDARD_TYPE(Geom2d_Line)) &&
(Type2 == STANDARD_TYPE(Geom2d_Circle) || Type2 == STANDARD_TYPE(Geom2d_Line)) ) {
(Type2 == STANDARD_TYPE(Geom2d_Circle) || Type2 == STANDARD_TYPE(Geom2d_Line)) )
{
//------------------------------------------------------------------
// Analytic Bissectrice.
//------------------------------------------------------------------
Handle(Bisector_BisecAna) BisAna = new Bisector_BisecAna();
BisAna->Perform(afirstcurve ,
asecondcurve ,
apoint ,
afirstvector ,
asecondvector ,
adirection ,
tolerance ,
oncurve );
UFirst = BisAna->ParameterOfStartPoint();
ULast = BisAna->ParameterOfEndPoint();
Bis = BisAna;
Handle(Bisector_BisecAna) BisAna = new Bisector_BisecAna();
BisAna->Perform(afirstcurve1 ,
asecondcurve1 ,
apoint ,
afirstvector ,
asecondvector ,
adirection ,
tolerance ,
oncurve );
UFirst = BisAna->ParameterOfStartPoint();
ULast = BisAna->ParameterOfEndPoint();
Bis = BisAna;
}
else {
Standard_Boolean IsLine = Standard_False;
Standard_Boolean IsLine = Standard_False;
if (oncurve) {
gp_Dir2d Fd(afirstvector);
@@ -115,7 +171,7 @@ void Bisector_Bisec::Perform(const Handle(Geom2d_Curve)& afirstcurve ,
//if (Fd.Dot(Sd) < Precision::Angular() - 1.) {
//if (Fd.Dot(Sd) < 10*Precision::Angular() - 1.) //patch
if (Fd.Dot(Sd) < Sqrt(2.*Precision::Angular()) - 1.)
IsLine = Standard_True;
IsLine = Standard_True;
}
if (IsLine) {
//------------------------------------------------------------------
@@ -125,7 +181,7 @@ void Bisector_Bisec::Perform(const Handle(Geom2d_Curve)& afirstcurve ,
Handle (Geom2d_CartesianPoint) PG = new Geom2d_CartesianPoint(apoint);
Handle (Geom2d_Line) L = new Geom2d_Line (apoint,N);
Handle (Geom2d_TrimmedCurve)
BisL = new Geom2d_TrimmedCurve (L,0,Precision::Infinite());
BisL = new Geom2d_TrimmedCurve (L,0,Precision::Infinite());
Handle(Bisector_BisecAna) BisAna = new Bisector_BisecAna ();
BisAna->Init(BisL);
UFirst = BisAna->ParameterOfStartPoint();
@@ -137,58 +193,78 @@ void Bisector_Bisec::Perform(const Handle(Geom2d_Curve)& afirstcurve ,
// Bissectrice algo
//-------------------------------------------------------------------
Handle(Bisector_BisecCC) BisCC = new Bisector_BisecCC();
BisCC -> Perform(asecondcurve,
afirstcurve ,
adirection ,
adirection ,
apoint);
BisCC -> Perform(asecondcurve1,
afirstcurve1 ,
adirection ,
adirection ,
apoint);
if (BisCC -> IsEmpty()) {
// bissectrice is empty. a point is projected at the end of the guide curve.
// Construction of a false bissectrice.
// modified by NIZHNY-EAP Mon Feb 21 12:00:13 2000 ___BEGIN___
gp_Dir2d dir1(afirstvector), dir2(asecondvector);
Standard_Real
Nx = - dir1.X() - dir2.X(),
Ny = - dir1.Y() - dir2.Y();
if (Abs(Nx) <= gp::Resolution() && Abs(Ny) <= gp::Resolution()) {
Nx = - afirstvector.Y();
Ny = afirstvector.X();
}
//gp_Dir2d N ( - adirection*afirstvector.Y(), adirection*afirstvector.X());
gp_Dir2d N ( adirection*Nx, adirection*Ny);
// modified by NIZHNY-EAP Mon Feb 21 12:00:19 2000 ___END___
Handle (Geom2d_CartesianPoint) PG = new Geom2d_CartesianPoint(apoint);
Handle (Geom2d_Line) L = new Geom2d_Line (apoint,N);
Handle (Geom2d_TrimmedCurve)
BisL = new Geom2d_TrimmedCurve (L,0,Precision::Infinite());
Handle(Bisector_BisecAna) BisAna = new Bisector_BisecAna ();
BisAna->Init(BisL);
UFirst = BisAna->ParameterOfStartPoint();
ULast = BisAna->ParameterOfEndPoint();
Bis = BisAna;
// bissectrice is empty. a point is projected at the end of the guide curve.
// Construction of a false bissectrice.
// modified by NIZHNY-EAP Mon Feb 21 12:00:13 2000 ___BEGIN___
gp_Pnt2d aP1 = afirstcurve1->Value(afirstcurve1->LastParameter());
gp_Pnt2d aP2 = asecondcurve1->Value(asecondcurve1->FirstParameter());
gp_Pnt2d aPm(.5*(aP1.XY()+aP2.XY()));
Standard_Real Nx, Ny;
if(aPm.Distance(apoint) > 10.*Precision::Confusion())
{
Nx = apoint.X() - aPm.X();
Ny = apoint.Y() - aPm.Y();
if(adirection < 0)
{
Nx = -Nx;
Ny = -Ny;
}
}
else
{
gp_Dir2d dir1(afirstvector), dir2(asecondvector);
Nx = - dir1.X() - dir2.X(),
Ny = - dir1.Y() - dir2.Y();
if (Abs(Nx) <= gp::Resolution() && Abs(Ny) <= gp::Resolution()) {
Nx = -afirstvector.Y();
Ny = afirstvector.X();
}
}
gp_Dir2d N ( adirection*Nx, adirection*Ny);
// modified by NIZHNY-EAP Mon Feb 21 12:00:19 2000 ___END___
Handle (Geom2d_CartesianPoint) PG = new Geom2d_CartesianPoint(apoint);
Handle (Geom2d_Line) L = new Geom2d_Line (apoint,N);
Handle (Geom2d_TrimmedCurve)
BisL = new Geom2d_TrimmedCurve (L,0,Precision::Infinite());
Handle(Bisector_BisecAna) BisAna = new Bisector_BisecAna ();
BisAna->Init(BisL);
UFirst = BisAna->ParameterOfStartPoint();
ULast = BisAna->ParameterOfEndPoint();
Bis = BisAna;
}
else {
UFirst = BisCC->FirstParameter();
ULast = BisCC->LastParameter ();
Bis = BisCC;
ReplaceByLineIfIsToSmall(Bis,UFirst,ULast);
UFirst = BisCC->FirstParameter();
ULast = BisCC->LastParameter ();
Bis = BisCC;
ReplaceByLineIfIsToSmall(Bis,UFirst,ULast);
}
}
}
UFirst = Max(UFirst, Bis->FirstParameter());
ULast = Min(ULast, Bis->LastParameter());
thebisector = new Geom2d_TrimmedCurve(Bis,UFirst,ULast);
/*
sprintf( name, "c1_%d", ++nbb );
DrawTrSurf::Set( name, afirstcurve );
sprintf( name, "c2_%d", nbb );
DrawTrSurf::Set( name, asecondcurve );
sprintf( name, "p%d", nbb );
DrawTrSurf::Set( name, apoint );
sprintf( name, "b%d", nbb );
DrawTrSurf::Set( name, thebisector );
*/
#ifdef DRAW
if(Affich)
{
sprintf( name, "c1_%d", ++nbb );
DrawTrSurf::Set( name, afirstcurve );
sprintf( name, "c2_%d", nbb );
DrawTrSurf::Set( name, asecondcurve );
sprintf( name, "p%d", nbb );
DrawTrSurf::Set( name, apoint );
sprintf( name, "b%d", nbb );
DrawTrSurf::Set( name, thebisector );
}
#endif
}
//===========================================================================
@@ -204,13 +280,13 @@ void Bisector_Bisec::Perform(const Handle(Geom2d_Curve)& afirstcurve ,
//===========================================================================
void Bisector_Bisec::Perform(const Handle(Geom2d_Curve)& afirstcurve ,
const Handle(Geom2d_Point)& asecondpoint ,
const gp_Pnt2d& apoint ,
const gp_Vec2d& afirstvector ,
const gp_Vec2d& asecondvector,
const Standard_Real adirection ,
const Standard_Real tolerance ,
const Standard_Boolean oncurve )
const Handle(Geom2d_Point)& asecondpoint ,
const gp_Pnt2d& apoint ,
const gp_Vec2d& afirstvector ,
const gp_Vec2d& asecondvector,
const Standard_Real adirection ,
const Standard_Real tolerance ,
const Standard_Boolean oncurve )
{
//gp_Pnt2d SecondPnt = asecondpoint->Pnt2d();
@@ -220,7 +296,7 @@ void Bisector_Bisec::Perform(const Handle(Geom2d_Curve)& afirstcurve ,
if (Type1 == STANDARD_TYPE(Geom2d_TrimmedCurve)) {
Type1 = Handle(Geom2d_TrimmedCurve)::DownCast(afirstcurve)
->BasisCurve()->DynamicType();
->BasisCurve()->DynamicType();
}
if ( Type1 == STANDARD_TYPE(Geom2d_Circle) || Type1 == STANDARD_TYPE(Geom2d_Line)) {
@@ -229,13 +305,13 @@ void Bisector_Bisec::Perform(const Handle(Geom2d_Curve)& afirstcurve ,
//------------------------------------------------------------------
Handle(Bisector_BisecAna) BisAna = new Bisector_BisecAna();
BisAna -> Perform (afirstcurve ,
asecondpoint ,
apoint ,
afirstvector ,
asecondvector ,
adirection ,
tolerance ,
oncurve );
asecondpoint ,
apoint ,
afirstvector ,
asecondvector ,
adirection ,
tolerance ,
oncurve );
UFirst = BisAna->ParameterOfStartPoint();
ULast = BisAna->ParameterOfEndPoint();
Bis = BisAna;
@@ -243,11 +319,11 @@ void Bisector_Bisec::Perform(const Handle(Geom2d_Curve)& afirstcurve ,
else {
Standard_Boolean IsLine = Standard_False;
Standard_Real RC = Precision::Infinite();
if (oncurve) {
if (Bisector::IsConvex(afirstcurve,adirection) ||
IsMaxRC(afirstcurve,afirstcurve->LastParameter(),RC)) {
IsLine = Standard_True;
IsMaxRC(afirstcurve,afirstcurve->LastParameter(),RC)) {
IsLine = Standard_True;
}
}
if (IsLine) {
@@ -269,66 +345,73 @@ void Bisector_Bisec::Perform(const Handle(Geom2d_Curve)& afirstcurve ,
//-------------------------------------------------------------------
Handle(Bisector_BisecPC) BisPC = new Bisector_BisecPC();
Handle(Geom2d_Curve) afirstcurvereverse = afirstcurve->Reversed();
BisPC -> Perform(afirstcurvereverse ,
asecondpoint->Pnt2d(),
- adirection );
// Modified by Sergey KHROMOV - Thu Feb 21 16:49:54 2002 Begin
asecondpoint->Pnt2d(),
- adirection );
// Modified by Sergey KHROMOV - Thu Feb 21 16:49:54 2002 Begin
if (BisPC -> IsEmpty()) {
gp_Dir2d dir1(afirstvector), dir2(asecondvector);
Standard_Real
Nx = - dir1.X() - dir2.X(),
Ny = - dir1.Y() - dir2.Y();
if (Abs(Nx) <= gp::Resolution() && Abs(Ny) <= gp::Resolution()) {
Nx = - afirstvector.Y();
Ny = afirstvector.X();
}
// gp_Dir2d N ( -adirection*afirstvector.Y(), adirection*afirstvector.X());
gp_Dir2d N ( adirection*Nx, adirection*Ny);
Handle (Geom2d_Line) L = new Geom2d_Line (apoint,N);
Handle (Geom2d_TrimmedCurve) BisL = new Geom2d_TrimmedCurve(L,0,RC);
Handle(Bisector_BisecAna) BisAna = new Bisector_BisecAna ();
BisAna->Init(BisL);
UFirst = BisAna->ParameterOfStartPoint();
ULast = BisAna->ParameterOfEndPoint();
Bis = BisAna;
gp_Dir2d dir1(afirstvector), dir2(asecondvector);
Standard_Real
Nx = - dir1.X() - dir2.X(),
Ny = - dir1.Y() - dir2.Y();
if (Abs(Nx) <= gp::Resolution() && Abs(Ny) <= gp::Resolution()) {
Nx = - afirstvector.Y();
Ny = afirstvector.X();
}
// gp_Dir2d N ( -adirection*afirstvector.Y(), adirection*afirstvector.X());
gp_Dir2d N ( adirection*Nx, adirection*Ny);
Handle (Geom2d_Line) L = new Geom2d_Line (apoint,N);
Handle (Geom2d_TrimmedCurve) BisL = new Geom2d_TrimmedCurve(L,0,RC);
Handle(Bisector_BisecAna) BisAna = new Bisector_BisecAna ();
BisAna->Init(BisL);
UFirst = BisAna->ParameterOfStartPoint();
ULast = BisAna->ParameterOfEndPoint();
Bis = BisAna;
} else {
// Modified by Sergey KHROMOV - Wed Mar 6 17:01:08 2002 End
UFirst = BisPC->Parameter(apoint);
ULast = BisPC->LastParameter();
if(UFirst >= ULast)
{
//Standard_Real t = .9;
//UFirst = (1. - t) * BisPC->FirstParameter() + t * ULast;
//Extrapolate by line
//gp_Dir2d N ( -adirection*afirstvector.Y(), adirection*afirstvector.X());
gp_Vec2d V( BisPC->Value(BisPC->FirstParameter()), BisPC->Value(ULast) );
gp_Dir2d N( V );
Handle (Geom2d_Line) L = new Geom2d_Line (apoint,N);
Handle (Geom2d_TrimmedCurve) BisL = new Geom2d_TrimmedCurve (L,0,RC);
Handle(Bisector_BisecAna) BisAna = new Bisector_BisecAna ();
BisAna->Init(BisL);
UFirst = BisAna->ParameterOfStartPoint();
ULast = BisAna->ParameterOfEndPoint();
Bis = BisAna;
}
else
Bis = BisPC;
// Modified by Sergey KHROMOV - Wed Mar 6 17:01:08 2002 End
UFirst = BisPC->Parameter(apoint);
ULast = BisPC->LastParameter();
if(UFirst >= ULast)
{
//Standard_Real t = .9;
//UFirst = (1. - t) * BisPC->FirstParameter() + t * ULast;
//Extrapolate by line
//gp_Dir2d N ( -adirection*afirstvector.Y(), adirection*afirstvector.X());
gp_Vec2d V( BisPC->Value(BisPC->FirstParameter()), BisPC->Value(ULast) );
gp_Dir2d N( V );
Handle (Geom2d_Line) L = new Geom2d_Line (apoint,N);
Handle (Geom2d_TrimmedCurve) BisL = new Geom2d_TrimmedCurve (L,0,RC);
Handle(Bisector_BisecAna) BisAna = new Bisector_BisecAna ();
BisAna->Init(BisL);
UFirst = BisAna->ParameterOfStartPoint();
ULast = BisAna->ParameterOfEndPoint();
Bis = BisAna;
}
else
Bis = BisPC;
}
}
}
if(UFirst < Bis->FirstParameter())
UFirst = Bis->FirstParameter();
if(ULast > Bis->LastParameter())
ULast = Bis->LastParameter();
thebisector = new Geom2d_TrimmedCurve(Bis,UFirst,ULast);
/*
#ifdef DRAW
if(Affich)
{
sprintf( name, "c1_%d", ++nbb );
DrawTrSurf::Set( name, afirstcurve );
sprintf( name, "c2_%d", nbb );
DrawTrSurf::Set( name, SecondPnt );
DrawTrSurf::Set( name, asecondpoint->Pnt2d() );
sprintf( name, "p%d", nbb );
DrawTrSurf::Set( name, apoint );
sprintf( name, "b%d", nbb );
DrawTrSurf::Set( name, thebisector );
*/
}
#endif
}
//===========================================================================
@@ -344,13 +427,13 @@ void Bisector_Bisec::Perform(const Handle(Geom2d_Curve)& afirstcurve ,
//===========================================================================
void Bisector_Bisec::Perform(const Handle(Geom2d_Point)& afirstpoint ,
const Handle(Geom2d_Curve)& asecondcurve ,
const gp_Pnt2d& apoint ,
const gp_Vec2d& afirstvector ,
const gp_Vec2d& asecondvector,
const Standard_Real adirection ,
const Standard_Real tolerance ,
const Standard_Boolean oncurve )
const Handle(Geom2d_Curve)& asecondcurve ,
const gp_Pnt2d& apoint ,
const gp_Vec2d& afirstvector ,
const gp_Vec2d& asecondvector,
const Standard_Real adirection ,
const Standard_Real tolerance ,
const Standard_Boolean oncurve )
{
//gp_Pnt2d FirstPnt = afirstpoint->Pnt2d();
@@ -358,38 +441,38 @@ void Bisector_Bisec::Perform(const Handle(Geom2d_Point)& afirstpoint ,
Handle(Bisector_Curve) Bis;
Handle(Standard_Type) Type1 = asecondcurve ->DynamicType();
Standard_Real UFirst,ULast;
if (Type1 == STANDARD_TYPE(Geom2d_TrimmedCurve)) {
Type1 = Handle(Geom2d_TrimmedCurve)::DownCast(asecondcurve)
->BasisCurve()->DynamicType();
->BasisCurve()->DynamicType();
}
if ( Type1 == STANDARD_TYPE(Geom2d_Circle) || Type1 == STANDARD_TYPE(Geom2d_Line)) {
//------------------------------------------------------------------
// Analytic Bissectrice.
//------------------------------------------------------------------
Handle(Bisector_BisecAna) BisAna = new Bisector_BisecAna();
BisAna -> Perform (afirstpoint ,
asecondcurve ,
apoint ,
afirstvector ,
asecondvector ,
adirection ,
tolerance ,
oncurve );
asecondcurve ,
apoint ,
afirstvector ,
asecondvector ,
adirection ,
tolerance ,
oncurve );
UFirst = BisAna->ParameterOfStartPoint();
ULast = BisAna->ParameterOfEndPoint();
Bis = BisAna;
}
else {
// Standard_Real UPoint = 0.;
// Standard_Real UPoint = 0.;
Standard_Boolean IsLine = Standard_False;
Standard_Real RC = Precision::Infinite();
if (oncurve) {
if (Bisector::IsConvex(asecondcurve, adirection) ||
IsMaxRC(asecondcurve,asecondcurve->FirstParameter(),RC)) {
IsLine = Standard_True;
IsMaxRC(asecondcurve,asecondcurve->FirstParameter(),RC)) {
IsLine = Standard_True;
}
}
if (IsLine) {
@@ -411,62 +494,69 @@ void Bisector_Bisec::Perform(const Handle(Geom2d_Point)& afirstpoint ,
//-------------------------------------------------------------------
Handle(Bisector_BisecPC) BisPC = new Bisector_BisecPC();
BisPC -> Perform(asecondcurve ,
afirstpoint->Pnt2d(),
adirection );
// Modified by Sergey KHROMOV - Thu Feb 21 16:49:54 2002 Begin
afirstpoint->Pnt2d(),
adirection );
// Modified by Sergey KHROMOV - Thu Feb 21 16:49:54 2002 Begin
if (BisPC -> IsEmpty()) {
gp_Dir2d dir1(afirstvector), dir2(asecondvector);
Standard_Real
Nx = - dir1.X() - dir2.X(),
Ny = - dir1.Y() - dir2.Y();
if (Abs(Nx) <= gp::Resolution() && Abs(Ny) <= gp::Resolution()) {
Nx = - afirstvector.Y();
Ny = afirstvector.X();
}
// gp_Dir2d N ( -adirection*afirstvector.Y(), adirection*afirstvector.X());
gp_Dir2d N ( adirection*Nx, adirection*Ny);
Handle (Geom2d_Line) L = new Geom2d_Line (apoint,N);
Handle (Geom2d_TrimmedCurve) BisL = new Geom2d_TrimmedCurve(L,0,RC);
Handle(Bisector_BisecAna) BisAna = new Bisector_BisecAna ();
BisAna->Init(BisL);
UFirst = BisAna->ParameterOfStartPoint();
ULast = BisAna->ParameterOfEndPoint();
Bis = BisAna;
gp_Dir2d dir1(afirstvector), dir2(asecondvector);
Standard_Real
Nx = - dir1.X() - dir2.X(),
Ny = - dir1.Y() - dir2.Y();
if (Abs(Nx) <= gp::Resolution() && Abs(Ny) <= gp::Resolution()) {
Nx = - afirstvector.Y();
Ny = afirstvector.X();
}
// gp_Dir2d N ( -adirection*afirstvector.Y(), adirection*afirstvector.X());
gp_Dir2d N ( adirection*Nx, adirection*Ny);
Handle (Geom2d_Line) L = new Geom2d_Line (apoint,N);
Handle (Geom2d_TrimmedCurve) BisL = new Geom2d_TrimmedCurve(L,0,RC);
Handle(Bisector_BisecAna) BisAna = new Bisector_BisecAna ();
BisAna->Init(BisL);
UFirst = BisAna->ParameterOfStartPoint();
ULast = BisAna->ParameterOfEndPoint();
Bis = BisAna;
} else {
// Modified by Sergey KHROMOV - Thu Feb 21 16:49:58 2002 End
UFirst = BisPC->Parameter(apoint);
ULast = BisPC->LastParameter();
if(UFirst >= ULast)
{
//Extrapolate by line
//gp_Dir2d N ( -adirection*afirstvector.Y(), adirection*afirstvector.X());
gp_Vec2d V( BisPC->Value(BisPC->FirstParameter()), BisPC->Value(ULast) );
gp_Dir2d N( V );
Handle (Geom2d_Line) L = new Geom2d_Line (apoint,N);
Handle (Geom2d_TrimmedCurve) BisL = new Geom2d_TrimmedCurve (L,0,RC);
Handle(Bisector_BisecAna) BisAna = new Bisector_BisecAna ();
BisAna->Init(BisL);
UFirst = BisAna->ParameterOfStartPoint();
ULast = BisAna->ParameterOfEndPoint();
Bis = BisAna;
}
else
Bis = BisPC;
// Modified by Sergey KHROMOV - Thu Feb 21 16:49:58 2002 End
UFirst = BisPC->Parameter(apoint);
ULast = BisPC->LastParameter();
if(UFirst >= ULast)
{
//Extrapolate by line
//gp_Dir2d N ( -adirection*afirstvector.Y(), adirection*afirstvector.X());
gp_Vec2d V( BisPC->Value(BisPC->FirstParameter()), BisPC->Value(ULast) );
gp_Dir2d N( V );
Handle (Geom2d_Line) L = new Geom2d_Line (apoint,N);
Handle (Geom2d_TrimmedCurve) BisL = new Geom2d_TrimmedCurve (L,0,RC);
Handle(Bisector_BisecAna) BisAna = new Bisector_BisecAna ();
BisAna->Init(BisL);
UFirst = BisAna->ParameterOfStartPoint();
ULast = BisAna->ParameterOfEndPoint();
Bis = BisAna;
}
else
Bis = BisPC;
}
}
}
UFirst = Max(UFirst, Bis->FirstParameter());
ULast = Min(ULast, Bis->LastParameter());
thebisector = new Geom2d_TrimmedCurve(Bis,UFirst,ULast);
/*
#ifdef DRAW
if(Affich)
{
sprintf( name, "c1_%d", ++nbb );
DrawTrSurf::Set( name, FirstPnt );
DrawTrSurf::Set( name, afirstpoint->Pnt2d() );
sprintf( name, "c2_%d", nbb );
DrawTrSurf::Set( name, asecondcurve );
sprintf( name, "p%d", nbb );
DrawTrSurf::Set( name, apoint );
sprintf( name, "b%d", nbb );
DrawTrSurf::Set( name, thebisector );
*/
}
#endif
}
//===========================================================================
@@ -481,29 +571,31 @@ void Bisector_Bisec::Perform(const Handle(Geom2d_Point)& afirstpoint ,
//===========================================================================
void Bisector_Bisec::Perform(const Handle(Geom2d_Point)& afirstpoint ,
const Handle(Geom2d_Point)& asecondpoint ,
const gp_Pnt2d& apoint ,
const gp_Vec2d& afirstvector ,
const gp_Vec2d& asecondvector,
const Standard_Real adirection ,
const Standard_Real tolerance ,
const Standard_Boolean oncurve )
const Handle(Geom2d_Point)& asecondpoint ,
const gp_Pnt2d& apoint ,
const gp_Vec2d& afirstvector ,
const gp_Vec2d& asecondvector,
const Standard_Real adirection ,
const Standard_Real tolerance ,
const Standard_Boolean oncurve )
{
Handle(Bisector_BisecAna) Bis = new Bisector_BisecAna();
Bis -> Perform (afirstpoint ,
asecondpoint ,
apoint ,
afirstvector ,
asecondvector ,
adirection ,
tolerance ,
oncurve );
asecondpoint ,
apoint ,
afirstvector ,
asecondvector ,
adirection ,
tolerance ,
oncurve );
thebisector = new Geom2d_TrimmedCurve(Bis,
Bis->ParameterOfStartPoint(),
Bis->ParameterOfEndPoint());
Bis->ParameterOfStartPoint(),
Bis->ParameterOfEndPoint());
/*
#ifdef DRAW
if(Affich)
{
sprintf( name, "c1_%d", ++nbb );
DrawTrSurf::Set( name, afirstpoint->Pnt2d() );
sprintf( name, "c2_%d", nbb );
@@ -512,7 +604,8 @@ void Bisector_Bisec::Perform(const Handle(Geom2d_Point)& afirstpoint ,
DrawTrSurf::Set( name, apoint );
sprintf( name, "b%d", nbb );
DrawTrSurf::Set( name, thebisector );
*/
}
#endif
}
//=============================================================================
@@ -539,8 +632,8 @@ const Handle(Geom2d_TrimmedCurve)& Bisector_Bisec::ChangeValue()
// replaced by a half-straight.
//=============================================================================
static void ReplaceByLineIfIsToSmall (Handle(Geom2d_Curve)& Bis,
Standard_Real& UFirst,
Standard_Real& ULast )
Standard_Real& UFirst,
Standard_Real& ULast )
{
if (Abs(ULast - UFirst) > 2.*Precision::PConfusion()*10.) return; //patch
@@ -568,8 +661,8 @@ static void ReplaceByLineIfIsToSmall (Handle(Geom2d_Curve)& Bis,
//purpose :
//=============================================================================
static Standard_Boolean IsMaxRC (const Handle(Geom2d_Curve)& C,
Standard_Real U,
Standard_Real& R)
Standard_Real U,
Standard_Real& R)
{
Standard_Real KF,KL;
Standard_Real US = C->FirstParameter();
@@ -583,7 +676,7 @@ static Standard_Boolean IsMaxRC (const Handle(Geom2d_Curve)& C,
Norm2 = D1.SquareMagnitude();;
if (Norm2 < gp::Resolution()) { KF = 0.0;}
else { KF = Abs(D1^D2)/(Norm2*sqrt(Norm2));}
C->D2(UL,P,D1,D2);
Norm2 = D1.SquareMagnitude();;
if (Norm2 < gp::Resolution()) { KL = 0.0;}

View File

@@ -46,24 +46,24 @@
static Standard_Boolean ProjOnCurve (const gp_Pnt2d& P,
const Handle(Geom2d_Curve)& C,
Standard_Real& theParam);
const Handle(Geom2d_Curve)& C,
Standard_Real& theParam);
static Standard_Real Curvature (const Handle(Geom2d_Curve)& C,
Standard_Real U,
Standard_Real Tol) ;
Standard_Real U,
Standard_Real Tol) ;
static Standard_Boolean TestExtension (const Handle(Geom2d_Curve)& C1,
const Handle(Geom2d_Curve)& C2,
const Standard_Integer Start_End);
const Handle(Geom2d_Curve)& C2,
const Standard_Integer Start_End);
static Standard_Boolean DiscretPar(const Standard_Real DU,
const Standard_Real EpsMin,
const Standard_Real EpsMax,
const Standard_Integer NbMin,
const Standard_Integer NbMax,
Standard_Real& Eps,
Standard_Integer& Nb);
const Standard_Real EpsMin,
const Standard_Real EpsMax,
const Standard_Integer NbMin,
const Standard_Integer NbMax,
Standard_Real& Eps,
Standard_Integer& Nb);
//=============================================================================
//function :
@@ -80,11 +80,11 @@ Bisector_BisecCC::Bisector_BisecCC()
//purpose :
//=============================================================================
Bisector_BisecCC::Bisector_BisecCC(const Handle(Geom2d_Curve)& Cu1,
const Handle(Geom2d_Curve)& Cu2,
const Standard_Real Side1,
const Standard_Real Side2,
const gp_Pnt2d& Origin,
const Standard_Real DistMax)
const Handle(Geom2d_Curve)& Cu2,
const Standard_Real Side1,
const Standard_Real Side2,
const gp_Pnt2d& Origin,
const Standard_Real DistMax)
{
Perform (Cu1,Cu2,Side1,Side2,Origin,DistMax);
}
@@ -94,11 +94,11 @@ Bisector_BisecCC::Bisector_BisecCC(const Handle(Geom2d_Curve)& Cu1,
//purpose :
//=============================================================================
void Bisector_BisecCC::Perform(const Handle(Geom2d_Curve)& Cu1,
const Handle(Geom2d_Curve)& Cu2,
const Standard_Real Side1,
const Standard_Real Side2,
const gp_Pnt2d& Origin,
const Standard_Real DistMax)
const Handle(Geom2d_Curve)& Cu2,
const Standard_Real Side1,
const Standard_Real Side2,
const gp_Pnt2d& Origin,
const Standard_Real DistMax)
{
isEmpty = Standard_False;
distMax = DistMax;
@@ -122,7 +122,6 @@ void Bisector_BisecCC::Perform(const Handle(Geom2d_Curve)& Cu1,
// Calculate first point of the polygon.
//---------------------------------------------
Standard_Boolean isProjDone = ProjOnCurve (Origin,curve1, U);
P = ValueByInt (U,UC1,UC2,Dist);
if(!isProjDone)
{
@@ -130,6 +129,20 @@ void Bisector_BisecCC::Perform(const Handle(Geom2d_Curve)& Cu1,
return;
}
P = ValueByInt (U,UC1,UC2,Dist);
if(Dist < Precision::Confusion())
{
gp_Pnt2d aP1 = curve1->Value(UC1);
gp_Pnt2d aP2 = curve2->Value(UC2);
Standard_Real dp = (aP1.Distance(P)+aP2.Distance(P));
Standard_Real dorig = (aP1.Distance(Origin)+aP2.Distance(Origin));
if(dp < dorig)
{
isEmpty = Standard_True;
return;
}
}
if (Dist < Precision::Infinite()) {
//----------------------------------------------------
// the parameter of the origin point gives a point
@@ -363,11 +376,11 @@ Handle(Geom2d_Geometry) Bisector_BisecCC::Copy() const
Handle(Bisector_BisecCC) Bisector_BisecCC::ChangeGuide() const
{
Handle(Bisector_BisecCC) C = new Bisector_BisecCC();
C -> Curve (1, curve2) ; C -> Curve (2, curve1);
C -> Sign (1, sign2 ) ; C -> Sign (2, sign1 );
C -> IsConvex (1, isConvex2); C -> IsConvex (2, isConvex1);
//-------------------------------------------------------------------------
// Construction of the new polygon from the initial one.
// inversion of PointOnBis and Calculation of new parameters on the bissectrice.
@@ -380,8 +393,8 @@ Handle(Bisector_BisecCC) Bisector_BisecCC::ChangeGuide() const
for (Standard_Integer i = myPolygon.Length(); i >=1; i--) {
Bisector_PointOnBis P = myPolygon.Value(i);
Bisector_PointOnBis NewP (P.ParamOnC2(), P.ParamOnC1(),
P.ParamOnC2(), P.Distance (),
P.Point());
P.ParamOnC2(), P.Distance (),
P.Point());
Poly.Append (NewP);
}
}
@@ -389,15 +402,15 @@ Handle(Bisector_BisecCC) Bisector_BisecCC::ChangeGuide() const
for (Standard_Integer i = 1; i <= myPolygon.Length(); i ++) {
Bisector_PointOnBis P = myPolygon.Value(i);
Bisector_PointOnBis NewP (P.ParamOnC2(), P.ParamOnC1(),
P.ParamOnC2(), P.Distance (),
P.Point());
P.ParamOnC2(), P.Distance (),
P.Point());
Poly.Append (NewP);
}
}
C -> Polygon (Poly);
C -> FirstParameter (Poly.First().ParamOnBis());
C -> LastParameter (Poly.Last() .ParamOnBis());
return C;
}
@@ -429,7 +442,7 @@ Standard_Boolean Bisector_BisecCC::IsCN (const Standard_Integer N) const
//=============================================================================
Standard_Real Bisector_BisecCC::FirstParameter() const
{
return startIntervals.First();
return startIntervals.First();
}
//=============================================================================
@@ -438,7 +451,7 @@ Standard_Real Bisector_BisecCC::FirstParameter() const
//=============================================================================
Standard_Real Bisector_BisecCC::LastParameter() const
{
return endIntervals.Last();
return endIntervals.Last();
}
//=============================================================================
@@ -475,7 +488,7 @@ Standard_Real Bisector_BisecCC::IntervalFirst(const Standard_Integer Index) cons
{
return startIntervals.Value(Index);
}
//=============================================================================
//function : IntervalLast
//purpose :
@@ -510,7 +523,7 @@ Standard_Boolean Bisector_BisecCC::IsClosed() const
{
if (curve1->IsClosed()) {
if (startIntervals.First() == curve1->FirstParameter() &&
endIntervals .Last () == curve1->LastParameter () )
endIntervals .Last () == curve1->LastParameter () )
return Standard_True;
}
return Standard_False;
@@ -531,8 +544,8 @@ Standard_Boolean Bisector_BisecCC::IsPeriodic() const
//purpose :
//=============================================================================
static Standard_Real Curvature (const Handle(Geom2d_Curve)& C,
Standard_Real U,
Standard_Real Tol)
Standard_Real U,
Standard_Real Tol)
{
Standard_Real K1;
gp_Vec2d D1,D2;
@@ -569,9 +582,9 @@ static Standard_Real Curvature (const Handle(Geom2d_Curve)& C,
//
//=============================================================================
gp_Pnt2d Bisector_BisecCC::ValueAndDist (const Standard_Real U,
Standard_Real& U1,
Standard_Real& U2,
Standard_Real& Dist) const
Standard_Real& U1,
Standard_Real& U2,
Standard_Real& Dist) const
{
gp_Vec2d T;
@@ -619,11 +632,11 @@ gp_Pnt2d Bisector_BisecCC::ValueAndDist (const Standard_Real U,
//---------------------------------------------------------------
gp_Pnt2d P1;
gp_Vec2d T1;
Standard_Real EpsH = 1.E-8;
Standard_Real EpsH100 = 1.E-6;
Standard_Real EpsH = 1.E-9;
Standard_Real EpsH100 = 1.E-7;
curve1->D1 (U1,P1,T1);
gp_Vec2d N1(T1.Y(), - T1.X());
if ((VMax - VMin) < Precision::PConfusion()) {
U2 = VInit;
}
@@ -637,14 +650,14 @@ gp_Pnt2d Bisector_BisecCC::ValueAndDist (const Standard_Real U,
else {
math_BissecNewton SolNew (H,VMin - EpsH100,VMax + EpsH100,EpsH,10);
if (SolNew.IsDone()) {
U2 = SolNew.Root();
U2 = SolNew.Root();
}
else {
math_FunctionRoot SolRoot (H,VInit,EpsH,VMin - EpsH100,VMax + EpsH100);
if (SolRoot.IsDone()) {
U2 = SolRoot.Root();
}
else { Valid = Standard_False;}
math_FunctionRoot SolRoot (H,VInit,EpsH,VMin - EpsH100,VMax + EpsH100);
if (SolRoot.IsDone()) {
U2 = SolRoot.Root();
}
else { Valid = Standard_False;}
}
}
}
@@ -667,8 +680,8 @@ gp_Pnt2d Bisector_BisecCC::ValueAndDist (const Standard_Real U,
Valid = Standard_False;
}
else {
PBis = P1.Translated(- (0.5*SquareP2P1/N1P2P1)*N1);
Dist = P1.SquareDistance(PBis);
PBis = P1.Translated(- (0.5*SquareP2P1/N1P2P1)*N1);
Dist = P1.SquareDistance(PBis);
}
}
@@ -691,20 +704,20 @@ gp_Pnt2d Bisector_BisecCC::ValueAndDist (const Standard_Real U,
Geom2dAdaptor_Curve ANorLi(NorLi);
//-------------------------------------------------------------------------
Geom2dInt_GInter Intersect(ABisPC,ANorLi,
Precision::Confusion(),Precision::Confusion());
Precision::Confusion(),Precision::Confusion());
//-------------------------------------------------------------------------
if (Intersect.IsDone() && !Intersect.IsEmpty()) {
for (Standard_Integer i = 1; i <= Intersect.NbPoints(); i++) {
if (Intersect.Point(i).ParamOnSecond()*sign1 < Precision::PConfusion()) {
P = Intersect.Point(i).Value();
if (P.SquareDistance(P1) < DMin) {
DMin = P.SquareDistance(P1);
PBis = P;
U2 = BisPC->LinkBisCurve(Intersect.Point(i).ParamOnFirst());
Dist = DMin;
}
}
if (Intersect.Point(i).ParamOnSecond()*sign1 < Precision::PConfusion()) {
P = Intersect.Point(i).Value();
if (P.SquareDistance(P1) < DMin) {
DMin = P.SquareDistance(P1);
PBis = P;
U2 = BisPC->LinkBisCurve(Intersect.Point(i).ParamOnFirst());
Dist = DMin;
}
}
}
}
}
@@ -725,9 +738,9 @@ gp_Pnt2d Bisector_BisecCC::ValueAndDist (const Standard_Real U,
// normal at this point.
//=============================================================================
gp_Pnt2d Bisector_BisecCC::ValueByInt (const Standard_Real U,
Standard_Real& U1,
Standard_Real& U2,
Standard_Real& Dist) const
Standard_Real& U1,
Standard_Real& U2,
Standard_Real& Dist) const
{
//------------------------------------------------------------------
// Return point, tangent, normal on C1 at parameter U.
@@ -738,7 +751,7 @@ gp_Pnt2d Bisector_BisecCC::ValueByInt (const Standard_Real U,
gp_Vec2d Tan1,Tan2;
curve1->D1(U1,P1,Tan1);
gp_Vec2d N1( Tan1.Y(), - Tan1.X());
//--------------------------------------------------------------------------
// test confusion of P1 with extremity of curve2.
//--------------------------------------------------------------------------
@@ -777,7 +790,7 @@ gp_Pnt2d Bisector_BisecCC::ValueByInt (const Standard_Real U,
Standard_Integer NbSamples =20;
Standard_Real UFirstOnC2 = curve2->FirstParameter();
Standard_Real ULastOnC2 = curve2->LastParameter();
if (!myPolygon.IsEmpty()){
if (sign1 == sign2) { ULastOnC2 = myPolygon.Last().ParamOnC2();}
else { UFirstOnC2 = myPolygon.Last().ParamOnC2();}
@@ -792,10 +805,10 @@ gp_Pnt2d Bisector_BisecCC::ValueByInt (const Standard_Real U,
Bisector_FunctionH H (curve2,P1,sign1*sign2*Tan1);
math_FunctionRoots SolRoot (H,
UFirstOnC2,
ULastOnC2 ,
NbSamples,
EpsX,EpsH,EpsH);
UFirstOnC2,
ULastOnC2 ,
NbSamples,
EpsX,EpsH,EpsH);
if (SolRoot.IsDone()) {
for (Standard_Integer j = 1; j <= SolRoot.NbSolutions(); j++) {
USol = SolRoot.Value(j);
@@ -806,60 +819,60 @@ gp_Pnt2d Bisector_BisecCC::ValueByInt (const Standard_Real U,
// Test if the solution is at the proper side of the curves.
if (N1P2P1*sign1 > 0 ) {
P = P1.Translated(- (0.5*SquareP2P1/N1P2P1)*N1);
DistPP1 = P1.SquareDistance(P);
if (DistPP1 < DMin) {
DMin = DistPP1;
PSol = P;
U2 = USol;
YaSol = Standard_True;
}
P = P1.Translated(- (0.5*SquareP2P1/N1P2P1)*N1);
DistPP1 = P1.SquareDistance(P);
if (DistPP1 < DMin) {
DMin = DistPP1;
PSol = P;
U2 = USol;
YaSol = Standard_True;
}
}
}
}
/*
/*
if (!YaSol) {
//--------------------------------------------------------------------
// Construction de la bisectrice point courbe et de la droite passant
// par P1 et portee par la normale.
//--------------------------------------------------------------------
Handle(Bisector_BisecPC) BisPC
= new Bisector_BisecPC(curve2,P1,sign2,2*distMax);
//-------------------------------
// Test si la bissectrice existe.
//-------------------------------
if (BisPC->IsEmpty()) {
Dist = Precision::Infinite();
PSol = P1;
return PSol;
}
Handle(Geom2d_Line) NorLi = new Geom2d_Line (P1,N1);
Geom2dAdaptor_Curve NorLiAd;
if (sign1 < 0.) {NorLiAd.Load(NorLi,0. ,distMax);}
else {NorLiAd.Load(NorLi,- distMax,0. );}
//-------------------------------------------------------------------------
Geom2dInt_GInter Intersect(BisPC,NorLiAd,
Precision::Confusion(),Precision::Confusion());
//-------------------------------------------------------------------------
if (Intersect.IsDone() && !Intersect.IsEmpty()) {
for (Standard_Integer i = 1; i <= Intersect.NbPoints(); i++) {
if (Intersect.Point(i).ParamOnSecond()*sign1< Precision::PConfusion()) {
P = Intersect.Point(i).Value();
DistPP1 = P.SquareDistance(P1);
if (DistPP1 < DMin) {
DMin = DistPP1;
PSol = P;
U2 = Intersect.Point(i).ParamOnFirst();
YaSol = Standard_True;
}
}
}
}
//--------------------------------------------------------------------
// Construction de la bisectrice point courbe et de la droite passant
// par P1 et portee par la normale.
//--------------------------------------------------------------------
Handle(Bisector_BisecPC) BisPC
= new Bisector_BisecPC(curve2,P1,sign2,2*distMax);
//-------------------------------
// Test si la bissectrice existe.
//-------------------------------
if (BisPC->IsEmpty()) {
Dist = Precision::Infinite();
PSol = P1;
return PSol;
}
*/
Handle(Geom2d_Line) NorLi = new Geom2d_Line (P1,N1);
Geom2dAdaptor_Curve NorLiAd;
if (sign1 < 0.) {NorLiAd.Load(NorLi,0. ,distMax);}
else {NorLiAd.Load(NorLi,- distMax,0. );}
//-------------------------------------------------------------------------
Geom2dInt_GInter Intersect(BisPC,NorLiAd,
Precision::Confusion(),Precision::Confusion());
//-------------------------------------------------------------------------
if (Intersect.IsDone() && !Intersect.IsEmpty()) {
for (Standard_Integer i = 1; i <= Intersect.NbPoints(); i++) {
if (Intersect.Point(i).ParamOnSecond()*sign1< Precision::PConfusion()) {
P = Intersect.Point(i).Value();
DistPP1 = P.SquareDistance(P1);
if (DistPP1 < DMin) {
DMin = DistPP1;
PSol = P;
U2 = Intersect.Point(i).ParamOnFirst();
YaSol = Standard_True;
}
}
}
}
}
*/
if (YaSol) {
Dist = DMin;
@@ -869,7 +882,7 @@ gp_Pnt2d Bisector_BisecCC::ValueByInt (const Standard_Real U,
P2 = curve2->Value(U2);
gp_Vec2d PP1(P1.X() - PSol.X(),P1.Y() - PSol.Y());
gp_Vec2d PP2(P2.X() - PSol.X(),P2.Y() - PSol.Y());
//-----------------------------------------------
// Dist = product of norms = distance at the square.
//-----------------------------------------------
@@ -878,18 +891,18 @@ gp_Pnt2d Bisector_BisecCC::ValueByInt (const Standard_Real U,
}
else {
if ( !isConvex1 ) {
Standard_Real K1 = Curvature(curve1,U1,Precision::Confusion());
if (K1 != 0.) {
if (Dist > 1/(K1*K1)) YaSol = Standard_False;
}
Standard_Real K1 = Curvature(curve1,U1,Precision::Confusion());
if (K1 != 0.) {
if (Dist > 1/(K1*K1)) YaSol = Standard_False;
}
}
if (YaSol) {
if ( !isConvex2 ) {
Standard_Real K2 = Curvature(curve2,U2,Precision::Confusion());
if (K2 != 0.) {
if (Dist > 1/(K2*K2)) YaSol = Standard_False;
}
}
if ( !isConvex2 ) {
Standard_Real K2 = Curvature(curve2,U2,Precision::Confusion());
if (K2 != 0.) {
if (Dist > 1/(K2*K2)) YaSol = Standard_False;
}
}
}
}
}
@@ -905,7 +918,7 @@ gp_Pnt2d Bisector_BisecCC::ValueByInt (const Standard_Real U,
//purpose :
//=============================================================================
void Bisector_BisecCC::D0(const Standard_Real U,
gp_Pnt2d& P) const
gp_Pnt2d& P) const
{
Standard_Real U1,U2,Dist;
@@ -917,8 +930,8 @@ void Bisector_BisecCC::D0(const Standard_Real U,
//purpose :
//=============================================================================
void Bisector_BisecCC::D1(const Standard_Real U,
gp_Pnt2d& P,
gp_Vec2d& V ) const
gp_Pnt2d& P,
gp_Vec2d& V ) const
{
V.SetCoord(0.,0.);
gp_Vec2d V2,V3;
@@ -930,9 +943,9 @@ void Bisector_BisecCC::D1(const Standard_Real U,
//purpose :
//=============================================================================
void Bisector_BisecCC::D2(const Standard_Real U,
gp_Pnt2d& P,
gp_Vec2d& V1,
gp_Vec2d& V2) const
gp_Pnt2d& P,
gp_Vec2d& V1,
gp_Vec2d& V2) const
{
V1.SetCoord(0.,0.);
V2.SetCoord(0.,0.);
@@ -945,10 +958,10 @@ void Bisector_BisecCC::D2(const Standard_Real U,
//purpose :
//=============================================================================
void Bisector_BisecCC::D3(const Standard_Real U,
gp_Pnt2d& P,
gp_Vec2d& V1,
gp_Vec2d& V2,
gp_Vec2d& V3) const
gp_Pnt2d& P,
gp_Vec2d& V1,
gp_Vec2d& V2,
gp_Vec2d& V3) const
{
V1.SetCoord(0.,0.);
V2.SetCoord(0.,0.);
@@ -961,7 +974,7 @@ void Bisector_BisecCC::D3(const Standard_Real U,
//purpose :
//=============================================================================
gp_Vec2d Bisector_BisecCC::DN(const Standard_Real U,
const Standard_Integer N) const
const Standard_Integer N) const
{
gp_Pnt2d P;
gp_Vec2d V1(0.,0.);
@@ -969,12 +982,12 @@ gp_Vec2d Bisector_BisecCC::DN(const Standard_Real U,
gp_Vec2d V3(0.,0.);
Values (U,N,P,V1,V2,V3);
switch (N) {
case 1 : return V1;
case 2 : return V2;
case 3 : return V3;
default: {
Standard_NotImplemented::Raise();
}
case 1 : return V1;
case 2 : return V2;
case 3 : return V3;
default: {
Standard_NotImplemented::Raise();
}
}
return V1;
}
@@ -1000,11 +1013,11 @@ gp_Vec2d Bisector_BisecCC::DN(const Standard_Real U,
//
//=============================================================================
void Bisector_BisecCC::Values (const Standard_Real U,
const Standard_Integer N,
gp_Pnt2d& P,
gp_Vec2d& V1,
gp_Vec2d& V2,
gp_Vec2d& V3) const
const Standard_Integer N,
gp_Pnt2d& P,
gp_Vec2d& V1,
gp_Vec2d& V2,
gp_Vec2d& V3) const
{
V1 = gp_Vec2d(0.,0.);
V2 = gp_Vec2d(0.,0.);
@@ -1014,7 +1027,7 @@ void Bisector_BisecCC::Values (const Standard_Real U,
// curve.
//-------------------------------------------------------------------------
Standard_Real U0,V0,Dist;
//-----------------------------------------------
// is the polygon reduced to a point or empty?
//-----------------------------------------------
@@ -1066,16 +1079,16 @@ void Bisector_BisecCC::Values (const Standard_Real U,
TvvPuPv = Tvv.Dot(PuPv) ; TvTvv = Tv.Dot(Tvv) ;
Standard_Real dHdu = 2*(TuPuPv*(TuuPuPv - TuTu)*TvTv +
TvPuPv*TuTv*TuTu -TuTuu*TvPuPv*TvPuPv);
TvPuPv*TuTv*TuTu -TuTuu*TvPuPv*TvPuPv);
Standard_Real dHdv = 2*(TuPuPv*TuTv*TvTv + TvTvv*TuPuPv*TuPuPv -
TvPuPv*(TvvPuPv + TvTv)*TuTu);
TvPuPv*(TvvPuPv + TvTv)*TuTu);
//-----------------------------
// Calculate dF/du and dF/dv.
//-----------------------------
Standard_Real NorPuPv,NuPuPv,NorTv;
Standard_Real A,B,dAdu,dAdv,dBdu,dBdv,BB;
NorPuPv = Nor.Dot(PuPv);
NuPuPv = Nu .Dot(PuPv);
NorTv = Nor.Dot(Tv) ;
@@ -1087,7 +1100,7 @@ void Bisector_BisecCC::Values (const Standard_Real U,
dBdu = - NuPuPv ;
dAdv = TvPuPv;
dBdv = - NorTv;
//---------------------------------------
// F(u,v) = Pu - (A(u,v)/B(u,v))*Nor(u)
//----------------------------------------
@@ -1098,7 +1111,7 @@ void Bisector_BisecCC::Values (const Standard_Real U,
else {
gp_Vec2d dFdu = Tu - (dAdu/B - dBdu*A/BB)*Nor - (A/B)*Nu;
gp_Vec2d dFdv = ( - dAdv/B + dBdv*A/BB)*Nor ;
if (Abs(dHdv) > gp::Resolution()) {
V1 = dFdu + dFdv*( - dHdu / dHdv );
}
@@ -1115,10 +1128,10 @@ void Bisector_BisecCC::Values (const Standard_Real U,
// by tangence of the curve.
//============================================================================
gp_Pnt2d Bisector_BisecCC::Extension (const Standard_Real U,
Standard_Real& U1,
Standard_Real& U2,
Standard_Real& Dist,
gp_Vec2d& T ) const
Standard_Real& U1,
Standard_Real& U2,
Standard_Real& Dist,
gp_Vec2d& T ) const
{
Bisector_PointOnBis PRef;
gp_Pnt2d P,P1,P2,PBis;
@@ -1189,7 +1202,7 @@ gp_Pnt2d Bisector_BisecCC::Extension (const Standard_Real U,
}
if (T1.Dot(Tang) < 0.) Tang = - Tang;
}
T = Tang.Normalized();
PBis.SetCoord(P.X() + dU*T.X(),P.Y() + dU*T.Y());
Dist = P1.Distance(PBis);
@@ -1201,12 +1214,12 @@ gp_Pnt2d Bisector_BisecCC::Extension (const Standard_Real U,
// purpose :
//=============================================================================
static Standard_Boolean PointByInt(const Handle(Geom2d_Curve)& CA,
const Handle(Geom2d_Curve)& CB,
const Standard_Real SignA,
const Standard_Real SignB,
const Standard_Real UOnA,
Standard_Real& UOnB,
Standard_Real& Dist)
const Handle(Geom2d_Curve)& CB,
const Standard_Real SignA,
const Standard_Real SignB,
const Standard_Real UOnA,
Standard_Real& UOnB,
Standard_Real& Dist)
{
//------------------------------------------------------------------
// Return point,tangent, normal on CA with parameter UOnA.
@@ -1218,7 +1231,7 @@ static Standard_Boolean PointByInt(const Handle(Geom2d_Curve)& CA,
CA->D1(UOnA,P1,Tan1);
gp_Vec2d N1(Tan1.Y(), - Tan1.X());
//--------------------------------------------------------------------------
// test of confusion of P1 with extremity of curve2.
//--------------------------------------------------------------------------
@@ -1250,7 +1263,7 @@ static Standard_Boolean PointByInt(const Handle(Geom2d_Curve)& CA,
Standard_Real DMin = Precision::Infinite();
Standard_Real UPC;
Standard_Boolean YaSol = Standard_False;
//--------------------------------------------------------------------
//--------------------------------------------------------------------
// Construction of the bisectrice point curve and of the straight line passing
// through P1 and carried by the normal.
//--------------------------------------------------------------------
@@ -1271,21 +1284,21 @@ static Standard_Boolean PointByInt(const Handle(Geom2d_Curve)& CA,
Geom2dAdaptor_Curve ANorLi(NorLi);
//-------------------------------------------------------------------------
Geom2dInt_GInter Intersect(ABisPC,ANorLi,
Precision::Confusion(),Precision::Confusion());
Precision::Confusion(),Precision::Confusion());
//-------------------------------------------------------------------------
if (Intersect.IsDone() && !Intersect.IsEmpty()) {
for (Standard_Integer i = 1; i <= Intersect.NbPoints(); i++) {
if (Intersect.Point(i).ParamOnSecond()*SignA < Precision::PConfusion()) {
P = Intersect.Point(i).Value();
if (P.SquareDistance(P1) < DMin) {
DMin = P.SquareDistance(P1);
PSol = P;
UPC = Intersect.Point(i).ParamOnFirst();
UOnB = BisPC->LinkBisCurve(UPC);
Dist = DMin;
YaSol = Standard_True;
}
P = Intersect.Point(i).Value();
if (P.SquareDistance(P1) < DMin) {
DMin = P.SquareDistance(P1);
PSol = P;
UPC = Intersect.Point(i).ParamOnFirst();
UOnB = BisPC->LinkBisCurve(UPC);
Dist = DMin;
YaSol = Standard_True;
}
}
}
}
@@ -1294,27 +1307,38 @@ static Standard_Boolean PointByInt(const Handle(Geom2d_Curve)& CA,
// Point found => Test distance curvature + Angular test
//---------------------------------------------------------------
P2 = CB->Value(UOnB);
if(P1.SquareDistance(PSol) < 1.e-32)
{
YaSol = Standard_False;
return YaSol;
}
if(P2.SquareDistance(PSol) < 1.e-32)
{
YaSol = Standard_False;
return YaSol;
}
gp_Dir2d PP1Unit(P1.X() - PSol.X(),P1.Y() - PSol.Y());
gp_Dir2d PP2Unit(P2.X() - PSol.X(),P2.Y() - PSol.Y());
if (PP1Unit*PP2Unit > 1. - Precision::Angular()) {
YaSol = Standard_False;
}
else {
Dist = sqrt(Dist);
if ( !IsConvexA ) {
Standard_Real K1 = Curvature(CA,UOnA,Precision::Confusion());
if (K1 != 0.) {
if (Dist > Abs(1/K1)) YaSol = Standard_False;
}
Standard_Real K1 = Curvature(CA,UOnA,Precision::Confusion());
if (K1 != 0.) {
if (Dist > Abs(1/K1)) YaSol = Standard_False;
}
}
if (YaSol) {
if ( !IsConvexB ) {
Standard_Real K2 = Curvature(CB,UOnB,Precision::Confusion());
if (K2 != 0.) {
if (Dist > Abs(1/K2)) YaSol = Standard_False;
}
}
if ( !IsConvexB ) {
Standard_Real K2 = Curvature(CB,UOnB,Precision::Confusion());
if (K2 != 0.) {
if (Dist > Abs(1/K2)) YaSol = Standard_False;
}
}
}
}
}
@@ -1426,20 +1450,20 @@ Standard_Real Bisector_BisecCC::Parameter(const gp_Pnt2d& P) const
//=============================================================================
//void Bisector_BisecCC::Dump(const Standard_Integer Deep,
void Bisector_BisecCC::Dump(const Standard_Integer ,
const Standard_Integer Offset) const
const Standard_Integer Offset) const
{
Indent (Offset);
cout <<"Bisector_BisecCC :"<<endl;
Indent (Offset);
// cout <<"Curve1 :"<<curve1<<endl;
// cout <<"Curve2 :"<<curve2<<endl;
// cout <<"Curve1 :"<<curve1<<endl;
// cout <<"Curve2 :"<<curve2<<endl;
cout <<"Sign1 :"<<sign1<<endl;
cout <<"Sign2 :"<<sign2<<endl;
cout <<"Number Of Intervals :"<<startIntervals.Length()<<endl;
for (Standard_Integer i = 1; i <= startIntervals.Length(); i++) {
cout <<"Interval number :"<<i<<"Start :"<<startIntervals.Value(i)
<<" end :"<< endIntervals.Value(i)<<endl ;
<<" end :"<< endIntervals.Value(i)<<endl ;
}
cout <<"Index Current Interval :"<<currentInterval<<endl;
}
@@ -1449,7 +1473,7 @@ void Bisector_BisecCC::Dump(const Standard_Integer ,
// purpose :
//=============================================================================
void Bisector_BisecCC::Curve(const Standard_Integer I,
const Handle(Geom2d_Curve)& C)
const Handle(Geom2d_Curve)& C)
{
if (I == 1) curve1 = C;
else if (I == 2) curve2 = C;
@@ -1461,7 +1485,7 @@ void Bisector_BisecCC::Curve(const Standard_Integer I,
// purpose :
//=============================================================================
void Bisector_BisecCC::Sign(const Standard_Integer I,
const Standard_Real S)
const Standard_Real S)
{
if (I == 1) sign1 = S;
else if (I == 2) sign2 = S;
@@ -1491,7 +1515,7 @@ void Bisector_BisecCC::DistMax(const Standard_Real D)
// purpose :
//=============================================================================
void Bisector_BisecCC::IsConvex(const Standard_Integer I,
const Standard_Boolean IsConvex)
const Standard_Boolean IsConvex)
{
if (I == 1) isConvex1 = IsConvex;
else if (I == 2) isConvex2 = IsConvex;
@@ -1586,7 +1610,7 @@ void Bisector_BisecCC::LastParameter (const Standard_Real U)
// purpose :
//=============================================================================
Standard_Real Bisector_BisecCC::SearchBound (const Standard_Real U1,
const Standard_Real U2) const
const Standard_Real U2) const
{
Standard_Real UMid,Dist1,Dist2,DistMid,U11,U22;
Standard_Real UC1,UC2;
@@ -1596,22 +1620,22 @@ Standard_Real Bisector_BisecCC::SearchBound (const Standard_Real U1,
U11 = U1; U22 = U2;
PBisPrec = ValueByInt(U11,UC1,UC2,Dist1);
PBis = ValueByInt(U22,UC1,UC2,Dist2);
while ((U22 - U11) > TolPar ||
((Dist1 < Precision::Infinite() &&
Dist2 < Precision::Infinite() &&
!PBis.IsEqual(PBisPrec,TolPnt)))) {
PBisPrec = PBis;
UMid = 0.5*( U22 + U11);
PBis = ValueByInt(UMid,UC1,UC2,DistMid);
if ((Dist1 < Precision::Infinite()) == (DistMid < Precision::Infinite())) {
U11 = UMid;
Dist1 = DistMid;
}
else {
U22 = UMid;
Dist2 = DistMid;
}
((Dist1 < Precision::Infinite() &&
Dist2 < Precision::Infinite() &&
!PBis.IsEqual(PBisPrec,TolPnt)))) {
PBisPrec = PBis;
UMid = 0.5*( U22 + U11);
PBis = ValueByInt(UMid,UC1,UC2,DistMid);
if ((Dist1 < Precision::Infinite()) == (DistMid < Precision::Infinite())) {
U11 = UMid;
Dist1 = DistMid;
}
else {
U22 = UMid;
Dist2 = DistMid;
}
}
PBis = ValueByInt(U11,UC1,UC2,Dist1);
if (Dist1 < Precision::Infinite()) {
@@ -1628,8 +1652,8 @@ Standard_Real Bisector_BisecCC::SearchBound (const Standard_Real U1,
// purpose :
//=============================================================================
static Standard_Boolean ProjOnCurve (const gp_Pnt2d& P,
const Handle(Geom2d_Curve)& C,
Standard_Real& theParam)
const Handle(Geom2d_Curve)& C,
Standard_Real& theParam)
{
//Standard_Real UOnCurve =0.;
theParam = 0.0;
@@ -1644,16 +1668,16 @@ static Standard_Boolean ProjOnCurve (const gp_Pnt2d& P,
theParam = C->FirstParameter();
return Standard_True;
}
if (P.IsEqual(PL ,Precision::Confusion()))
{
theParam = C->LastParameter();
return Standard_True;
}
gp_Vec2d PPF(PF.X() - P.X(), PF.Y() - P.Y());
TF.Normalize();
if ( Abs (PPF.Dot(TF)) < Precision::Confusion())
{
theParam = C->FirstParameter();
@@ -1667,8 +1691,8 @@ static Standard_Boolean ProjOnCurve (const gp_Pnt2d& P,
return Standard_True;
}
Geom2dAPI_ProjectPointOnCurve Proj(P,C,
C->FirstParameter(),
C->LastParameter());
C->FirstParameter(),
C->LastParameter());
if (Proj.NbPoints() > 0) {
theParam = Proj.LowerDistanceParameter();
}
@@ -1684,8 +1708,8 @@ static Standard_Boolean ProjOnCurve (const gp_Pnt2d& P,
// purpose :
//=============================================================================
static Standard_Boolean TestExtension (const Handle(Geom2d_Curve)& C1,
const Handle(Geom2d_Curve)& C2,
const Standard_Integer Start_End)
const Handle(Geom2d_Curve)& C2,
const Standard_Integer Start_End)
{
gp_Pnt2d P1,P2;
gp_Vec2d T1,T2;
@@ -1708,7 +1732,7 @@ static Standard_Boolean TestExtension (const Handle(Geom2d_Curve)& C1,
if (P1.IsEqual(P2,Precision::Confusion())) {
T2.Normalize();
if (T1.Dot(T2) > 1.0 - Precision::Confusion()) {
Test = Standard_True;
Test = Standard_True;
}
}
}
@@ -1753,12 +1777,12 @@ void Bisector_BisecCC::ComputePointEnd ()
// purpose :
//=============================================================================
static Standard_Boolean DiscretPar(const Standard_Real DU,
const Standard_Real EpsMin,
const Standard_Real EpsMax,
const Standard_Integer NbMin,
const Standard_Integer NbMax,
Standard_Real& Eps,
Standard_Integer& Nb)
const Standard_Real EpsMin,
const Standard_Real EpsMax,
const Standard_Integer NbMin,
const Standard_Integer NbMax,
Standard_Real& Eps,
Standard_Integer& Nb)
{
if (DU <= NbMin*EpsMin) {
Eps = DU/(NbMin + 1) ;

View File

@@ -33,12 +33,14 @@
#include <Precision.hxx>
#include <math_BissecNewton.hxx>
#include <ElCLib.hxx>
#ifdef OCCT_DEBUG
//#define DRAW
#ifdef DRAW
#include <Draw_Appli.hxx>
#include <DrawTrSurf_Curve2d.hxx>
#include <Draw_Marker2D.hxx>
#include <DrawTrSurf.hxx>
static char name[100];
static Standard_Boolean Affich = Standard_False;
static Standard_Integer nbint = 0;
#endif
#endif
//===================================================================================
@@ -172,14 +174,14 @@ void Bisector_Inter::Perform(const Bisector_Bisec& C1,
PMax,UMax,D2.LastTolerance());
if ((IB2 == 1 && Bis2->IsExtendAtStart()) ||
(IB2 == Bis1->NbIntervals() && Bis2->IsExtendAtEnd()) ){
//--------------------------------------------------------
// Part corresponding to an extension is a segment.
//--------------------------------------------------------
SBis2 [IB2] = ConstructSegment (PMin,PMax,UMin,UMax);
(IB2 == Bis1->NbIntervals() && Bis2->IsExtendAtEnd()) ){
//--------------------------------------------------------
// Part corresponding to an extension is a segment.
//--------------------------------------------------------
SBis2 [IB2] = ConstructSegment (PMin,PMax,UMin,UMax);
}
else {
SBis2 [IB2] = Bis2;
SBis2 [IB2] = Bis2;
}
NB2++;
}
@@ -269,11 +271,11 @@ void Bisector_Inter::SinglePerform(const Handle(Geom2d_Curve)& CBis1,
if (Type1 == STANDARD_TYPE(Geom2d_Line) && Type2 != STANDARD_TYPE(Geom2d_Line)) {
TestBound(Handle(Geom2d_Line)::DownCast(Bis1),
D1,Bis2,D2,TolConf,Standard_False);
D1,Bis2,D2,TolConf,Standard_False);
}
else if (Type2 == STANDARD_TYPE(Geom2d_Line)&& Type1 != STANDARD_TYPE(Geom2d_Line)) {
TestBound(Handle(Geom2d_Line)::DownCast(Bis2),
D2,Bis1,D1,TolConf,Standard_True);
D2,Bis1,D1,TolConf,Standard_True);
}
Geom2dInt_GInter Intersect;
Geom2dAdaptor_Curve ABis1(Bis1);
@@ -285,21 +287,17 @@ void Bisector_Inter::SinglePerform(const Handle(Geom2d_Curve)& CBis1,
#ifdef DRAW
if (Affich) {
Handle(DrawTrSurf_Curve2d) dr;
Draw_Color Couleur = Draw_bleu;
dr = new DrawTrSurf_Curve2d(Bis1,Couleur,100);
dout << dr;
dr = new DrawTrSurf_Curve2d(Bis2,Couleur,100);
dout << dr;
if (IsDone() && !IsEmpty()) {
sprintf( name, "i1_%d", ++nbint);
DrawTrSurf::Set(name, Bis1);
sprintf( name, "i2_%d", nbint);
DrawTrSurf::Set(name, Bis2);
if (IsDone() && !IsEmpty()) {
for (Standard_Integer k = 1; k <= NbPoints(); k++) {
gp_Pnt2d P = Point(k).Value();
Handle(Draw_Marker2D) drp = new Draw_Marker2D(P,Draw_Plus,Draw_vert);
dout << drp;
gp_Pnt2d P = Point(k).Value();
sprintf( name, "ip_%d_%d", nbint, k);
DrawTrSurf::Set(name, P);
}
}
dout.Flush();
}
#endif
}