mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +03:00
Integration of OCCT 6.5.0 from SVN
This commit is contained in:
62
src/Bisector/Bisector.cdl
Executable file
62
src/Bisector/Bisector.cdl
Executable file
@@ -0,0 +1,62 @@
|
||||
-- File: Bisector.cdl
|
||||
-- Created: Thu May 19 10:55:33 1994
|
||||
-- Author: Yves FRICAUD
|
||||
-- <yfr@phobox>
|
||||
---Copyright: Matra Datavision 1992
|
||||
|
||||
package Bisector
|
||||
|
||||
--- Purpose : This package provides the bisecting line between two
|
||||
-- geometric elements.
|
||||
|
||||
uses
|
||||
MMgt,
|
||||
Standard,
|
||||
TCollection,
|
||||
TColStd,
|
||||
TColgp,
|
||||
TopAbs,
|
||||
Geom2d,
|
||||
GeomAbs,
|
||||
gp,
|
||||
math,
|
||||
IntCurve,
|
||||
GccInt,
|
||||
StdFail,
|
||||
IntRes2d
|
||||
is
|
||||
|
||||
deferred class Curve;
|
||||
|
||||
class BisecAna;
|
||||
--- Purpose: This class provides the bisecting line between two
|
||||
-- geometric elements.The elements are Circles,Lines or
|
||||
-- Points.
|
||||
|
||||
class BisecPC;
|
||||
---Purpose: This class provides the bisecting line between a point
|
||||
-- a Curve.
|
||||
|
||||
class BisecCC;
|
||||
---Purpose: This class provides the bisecting line between two
|
||||
-- Curves.
|
||||
|
||||
class Bisec;
|
||||
---Purpose: This class provides the bisecting line between two
|
||||
-- geometris elelements. The bisecting line is
|
||||
-- trimmed by a point,
|
||||
|
||||
class Inter;
|
||||
|
||||
class PointOnBis;
|
||||
|
||||
class PolyBis;
|
||||
|
||||
private class FunctionH;
|
||||
|
||||
private class FunctionInter;
|
||||
|
||||
IsConvex (Cu : Curve from Geom2d; Sign : Real)
|
||||
returns Boolean from Standard;
|
||||
|
||||
end Bisector;
|
27
src/Bisector/Bisector.cxx
Executable file
27
src/Bisector/Bisector.cxx
Executable file
@@ -0,0 +1,27 @@
|
||||
// File: Bisector.cxx
|
||||
// Created: Tue mar 3 17:54:52 1994
|
||||
// Author: Yves FRICAUD
|
||||
// <yfr@phylox>
|
||||
|
||||
|
||||
#include <Bisector.ixx>
|
||||
#include <gp_Pnt2d.hxx>
|
||||
#include <gp_Vec2d.hxx>
|
||||
|
||||
//======================================================================
|
||||
// function : IsConvex
|
||||
// Purpose :
|
||||
//======================================================================
|
||||
Standard_Boolean Bisector::IsConvex(const Handle(Geom2d_Curve)& Cu,
|
||||
const Standard_Real Sign)
|
||||
{
|
||||
|
||||
Standard_Real U1 = (Cu->LastParameter() + Cu->FirstParameter())/2.;
|
||||
gp_Pnt2d P1;
|
||||
gp_Vec2d V1,V2;
|
||||
Cu->D2(U1,P1,V1,V2);
|
||||
Standard_Real Tol = 1.e-5;
|
||||
if (Sign*(V1^V2) < Tol) return Standard_True; // <= 0.
|
||||
else return Standard_False;
|
||||
}
|
||||
|
117
src/Bisector/Bisector_Bisec.cdl
Executable file
117
src/Bisector/Bisector_Bisec.cdl
Executable file
@@ -0,0 +1,117 @@
|
||||
-- File: Bisector_Bisec.cdl
|
||||
-- Created: Mon Oct 19 10:06:35 1992
|
||||
-- Author: Remi GILET
|
||||
-- <reg@phobox>
|
||||
---Copyright: Matra Datavision 1992
|
||||
|
||||
class Bisec from Bisector
|
||||
|
||||
--- Purpose : Bisec provides the bisecting line between two elements
|
||||
-- This line is trimed by a point <P> and it's contained in the domain
|
||||
-- defined by the two vectors <V1>, <V2> and <Sense>.
|
||||
--
|
||||
-- Definition of the domain:
|
||||
-- if <Sense> is true the bisecting line is contained in the sector
|
||||
-- defined by <-V1> and <-V2> in the sense indirect.
|
||||
-- if <Sense> is false the bisecting line is contained in the sector
|
||||
-- defined by <-V1> and <-V2> in the sense direct.
|
||||
--
|
||||
-- <Tolerance> is used to define degenerate bisector.
|
||||
-- if the bisector is an hyperbola and one of this radius is smaller
|
||||
-- than <Tolerance>, the bisector is replaced by a line or semi_line
|
||||
-- corresponding to one of hyperbola's axes.
|
||||
-- if the bisector is a parabola on the focal length is smaller than
|
||||
-- <Tolerance>, the bisector is replaced by a semi_line corresponding
|
||||
-- to the axe of symetrie of the parabola.
|
||||
-- if the bisector is an ellipse and the minor radius is smaller than
|
||||
-- <Tolerance>, the bisector is replaced by a segment corresponding
|
||||
-- to the great axe of the ellipse.
|
||||
|
||||
uses
|
||||
|
||||
TrimmedCurve from Geom2d ,
|
||||
Curve from Geom2d ,
|
||||
Curve from Bisector,
|
||||
Point from Geom2d ,
|
||||
Pnt2d from gp ,
|
||||
Vec2d from gp ,
|
||||
Integer from Standard
|
||||
|
||||
is
|
||||
Create returns Bisec from Bisector;
|
||||
|
||||
Perform(me : in out ;
|
||||
Cu1 : Curve from Geom2d ;
|
||||
Cu2 : Curve from Geom2d ;
|
||||
P : Pnt2d from gp ;
|
||||
V1 : Vec2d from gp ;
|
||||
V2 : Vec2d from gp ;
|
||||
Sense : Real from Standard ;
|
||||
Tolerance : Real from Standard ;
|
||||
oncurve : Boolean from Standard = Standard_True );
|
||||
|
||||
--- Purpose : Performs the bisecting line between the curves
|
||||
-- <Cu1> and <Cu2>.
|
||||
-- <oncurve> is True if the point <P> is common to <Cu1>
|
||||
-- and <Cu2>.
|
||||
|
||||
Perform(me : in out ;
|
||||
Cu : Curve from Geom2d ;
|
||||
Pnt : Point from Geom2d ;
|
||||
P : Pnt2d from gp ;
|
||||
V1 : Vec2d from gp ;
|
||||
V2 : Vec2d from gp ;
|
||||
Sense : Real from Standard ;
|
||||
Tolerance : Real from Standard ;
|
||||
oncurve : Boolean from Standard = Standard_True);
|
||||
|
||||
--- Purpose : Performs the bisecting line between the curve
|
||||
-- <Cu1> and the point <Pnt>.
|
||||
-- <oncurve> is True if the point <P> is the point <Pnt>.
|
||||
|
||||
Perform(me : in out ;
|
||||
Pnt : Point from Geom2d ;
|
||||
Cu : Curve from Geom2d ;
|
||||
P : Pnt2d from gp ;
|
||||
V1 : Vec2d from gp ;
|
||||
V2 : Vec2d from gp ;
|
||||
Sense : Real from Standard ;
|
||||
Tolerance : Real from Standard ;
|
||||
oncurve : Boolean from Standard = Standard_True );
|
||||
|
||||
--- Purpose : Performs the bisecting line between the curve
|
||||
-- <Cu> and the point <Pnt>.
|
||||
-- <oncurve> is True if the point <P> is the point <Pnt>.
|
||||
|
||||
Perform(me : in out ;
|
||||
Pnt1 : Point from Geom2d ;
|
||||
Pnt2 : Point from Geom2d ;
|
||||
P : Pnt2d from gp ;
|
||||
V1 : Vec2d from gp ;
|
||||
V2 : Vec2d from gp ;
|
||||
Sense : Real from Standard ;
|
||||
Tolerance : Real from Standard = 0.0 ;
|
||||
oncurve : Boolean from Standard = Standard_True ) ;
|
||||
|
||||
--- Purpose : Performs the bisecting line between the two points
|
||||
-- <Pnt1> and <Pnt2>.
|
||||
|
||||
|
||||
Value(me) returns TrimmedCurve from Geom2d
|
||||
--- Purpose : Returns the Curve of <me>.
|
||||
---C++: return const &
|
||||
is static;
|
||||
|
||||
ChangeValue (me : in out) returns mutable TrimmedCurve from Geom2d
|
||||
--- Purpose : Returns the Curve of <me>.
|
||||
--
|
||||
---C++: return const &
|
||||
is static;
|
||||
|
||||
fields
|
||||
|
||||
thebisector : TrimmedCurve from Geom2d;
|
||||
|
||||
end Bisec;
|
||||
|
||||
|
621
src/Bisector/Bisector_Bisec.cxx
Executable file
621
src/Bisector/Bisector_Bisec.cxx
Executable file
@@ -0,0 +1,621 @@
|
||||
// File: Bisector_Bisec.cxx
|
||||
// Created: Mon Jul 4 10:05:48 1994
|
||||
// Author: Yves FRICAUD
|
||||
// <yfr@phobox>
|
||||
|
||||
#include <Bisector_Bisec.ixx>
|
||||
#include <Bisector.hxx>
|
||||
#include <Geom2d_Circle.hxx>
|
||||
#include <Geom2d_Line.hxx>
|
||||
#include <Geom2d_Point.hxx>
|
||||
#include <Geom2d_CartesianPoint.hxx>
|
||||
#include <Geom2d_TrimmedCurve.hxx>
|
||||
#include <gp.hxx>
|
||||
#include <gp_Pnt2d.hxx>
|
||||
#include <gp_Vec2d.hxx>
|
||||
#include <StdFail_NotDone.hxx>
|
||||
#include <Standard_NotImplemented.hxx>
|
||||
#include <Precision.hxx>
|
||||
#include <Bisector_Curve.hxx>
|
||||
#include <Bisector_BisecAna.hxx>
|
||||
#include <Bisector_BisecPC.hxx>
|
||||
#include <Bisector_BisecCC.hxx>
|
||||
|
||||
/*
|
||||
#include <DrawTrSurf.hxx>
|
||||
static char tname[100];
|
||||
static Standard_CString name = tname ;
|
||||
static Standard_Integer nbb = 0;
|
||||
*/
|
||||
|
||||
#ifdef DEB
|
||||
static Standard_Boolean PointIsOnCurve(const Handle(Geom2d_Curve)& C,
|
||||
const gp_Pnt2d& P,
|
||||
Standard_Real& U);
|
||||
#endif
|
||||
static Standard_Boolean IsMaxRC (const Handle(Geom2d_Curve)& C,
|
||||
Standard_Real U,
|
||||
Standard_Real& R);
|
||||
|
||||
static void ReplaceByLineIfIsToSmall (Handle(Geom2d_Curve)& Bis,
|
||||
Standard_Real& UFirst,
|
||||
Standard_Real& ULast);
|
||||
//=============================================================================
|
||||
//function : Constructeur vide
|
||||
//=============================================================================
|
||||
Bisector_Bisec::Bisector_Bisec()
|
||||
{
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// calcul de la bissectrice entre deux courbes issue d un point.
|
||||
//
|
||||
// afirstcurve : \ courbes entre lesquelles on veut calculer la
|
||||
// asecondcurve : / bissectrice.
|
||||
// apoint : point par lequel doit passer la bissectrice.
|
||||
// afirstvector : \ vecteurs pour determiner le secteur dans lequel
|
||||
// asecondvector : / la bissectrice doit se trouver.
|
||||
// adirection : indique le cote de la bissectrice a conserver.
|
||||
// tolerance : seuil a partir duquel les bisectrices sont degenerees
|
||||
//===========================================================================
|
||||
|
||||
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 )
|
||||
{
|
||||
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();
|
||||
}
|
||||
if (Type2 == STANDARD_TYPE(Geom2d_TrimmedCurve)) {
|
||||
Type2 = Handle(Geom2d_TrimmedCurve)::DownCast(asecondcurve)
|
||||
->BasisCurve()->DynamicType();
|
||||
}
|
||||
|
||||
if ( (Type1 == STANDARD_TYPE(Geom2d_Circle) || Type1 == STANDARD_TYPE(Geom2d_Line)) &&
|
||||
(Type2 == STANDARD_TYPE(Geom2d_Circle) || Type2 == STANDARD_TYPE(Geom2d_Line)) ) {
|
||||
//------------------------------------------------------------------
|
||||
// Bissectrice analytique.
|
||||
//------------------------------------------------------------------
|
||||
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;
|
||||
}
|
||||
else {
|
||||
Standard_Boolean IsLine = Standard_False;
|
||||
|
||||
if (oncurve) {
|
||||
gp_Dir2d Fd(afirstvector);
|
||||
gp_Dir2d Sd(asecondvector);
|
||||
//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;
|
||||
}
|
||||
if (IsLine) {
|
||||
//------------------------------------------------------------------
|
||||
// Demi-Droite.
|
||||
//------------------------------------------------------------------
|
||||
gp_Dir2d N ( - adirection*afirstvector.Y(), adirection*afirstvector.X());
|
||||
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 {
|
||||
//-------------------------------------------------------------------
|
||||
// Bissectrice algo
|
||||
//-------------------------------------------------------------------
|
||||
Handle(Bisector_BisecCC) BisCC = new Bisector_BisecCC();
|
||||
BisCC -> Perform(asecondcurve,
|
||||
afirstcurve ,
|
||||
adirection ,
|
||||
adirection ,
|
||||
apoint);
|
||||
|
||||
if (BisCC -> IsEmpty()) {
|
||||
// la bissectrice est vide apoint se projette a la fin de la courbe
|
||||
// guide . Construction d une fausse 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;
|
||||
}
|
||||
else {
|
||||
UFirst = BisCC->FirstParameter();
|
||||
ULast = BisCC->LastParameter ();
|
||||
Bis = BisCC;
|
||||
ReplaceByLineIfIsToSmall(Bis,UFirst,ULast);
|
||||
}
|
||||
}
|
||||
}
|
||||
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 );
|
||||
*/
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// calcul de la bissectrice entre une courbe et un point issue d un point.
|
||||
//
|
||||
// afirstcurve : \ courbe et point entre lesquelles on veut calculer la
|
||||
// asecondpoint : / bissectrice.
|
||||
// apoint : point par lequel doit passer la bissectrice.
|
||||
// afirstvector : \ vecteurs pour determiner le secteur dans lequel
|
||||
// asecondvector : / la bissectrice doit se trouver.
|
||||
// adirection : indique le cote de la bissectrice a conserver.
|
||||
// tolerance : seuil a partir duquel les bisectrices sont degenerees
|
||||
//===========================================================================
|
||||
|
||||
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 )
|
||||
{
|
||||
//gp_Pnt2d SecondPnt = asecondpoint->Pnt2d();
|
||||
|
||||
Handle(Bisector_Curve) Bis;
|
||||
Handle(Standard_Type) Type1 = afirstcurve ->DynamicType();
|
||||
Standard_Real UFirst,ULast;
|
||||
|
||||
if (Type1 == STANDARD_TYPE(Geom2d_TrimmedCurve)) {
|
||||
Type1 = Handle(Geom2d_TrimmedCurve)::DownCast(afirstcurve)
|
||||
->BasisCurve()->DynamicType();
|
||||
}
|
||||
|
||||
if ( Type1 == STANDARD_TYPE(Geom2d_Circle) || Type1 == STANDARD_TYPE(Geom2d_Line)) {
|
||||
//------------------------------------------------------------------
|
||||
// Bissectrice analytique.
|
||||
//------------------------------------------------------------------
|
||||
Handle(Bisector_BisecAna) BisAna = new Bisector_BisecAna();
|
||||
BisAna -> Perform (afirstcurve ,
|
||||
asecondpoint ,
|
||||
apoint ,
|
||||
afirstvector ,
|
||||
asecondvector ,
|
||||
adirection ,
|
||||
tolerance ,
|
||||
oncurve );
|
||||
UFirst = BisAna->ParameterOfStartPoint();
|
||||
ULast = BisAna->ParameterOfEndPoint();
|
||||
Bis = BisAna;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
if (IsLine) {
|
||||
//------------------------------------------------------------------
|
||||
// Demi-Droite.
|
||||
//------------------------------------------------------------------
|
||||
gp_Dir2d N ( -adirection*afirstvector.Y(), adirection*afirstvector.X());
|
||||
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 {
|
||||
//-------------------------------------------------------------------
|
||||
// Bissectrice algo
|
||||
//-------------------------------------------------------------------
|
||||
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
|
||||
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;
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
thebisector = new Geom2d_TrimmedCurve(Bis,UFirst,ULast);
|
||||
|
||||
/*
|
||||
sprintf( name, "c1_%d", ++nbb );
|
||||
DrawTrSurf::Set( name, afirstcurve );
|
||||
sprintf( name, "c2_%d", nbb );
|
||||
DrawTrSurf::Set( name, SecondPnt );
|
||||
sprintf( name, "p%d", nbb );
|
||||
DrawTrSurf::Set( name, apoint );
|
||||
sprintf( name, "b%d", nbb );
|
||||
DrawTrSurf::Set( name, thebisector );
|
||||
*/
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// calcul de la bissectrice entre une courbe et un point issue d un point.
|
||||
//
|
||||
// afirstpoint : \ point et courbe entre lesquelles on veut calculer la
|
||||
// asecondcurve : / bissectrice.
|
||||
// apoint : point par lequel doit passer la bissectrice.
|
||||
// afirstvector : \ vecteurs pour determiner le secteur dans lequel
|
||||
// asecondvector : / la bissectrice doit se trouver.
|
||||
// adirection : indique le cote de la bissectrice a conserver.
|
||||
// tolerance : seuil a partir duquel les bisectrices sont degenerees
|
||||
//===========================================================================
|
||||
|
||||
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 )
|
||||
|
||||
{
|
||||
//gp_Pnt2d FirstPnt = afirstpoint->Pnt2d();
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
if ( Type1 == STANDARD_TYPE(Geom2d_Circle) || Type1 == STANDARD_TYPE(Geom2d_Line)) {
|
||||
//------------------------------------------------------------------
|
||||
// Bissectrice analytique.
|
||||
//------------------------------------------------------------------
|
||||
Handle(Bisector_BisecAna) BisAna = new Bisector_BisecAna();
|
||||
BisAna -> Perform (afirstpoint ,
|
||||
asecondcurve ,
|
||||
apoint ,
|
||||
afirstvector ,
|
||||
asecondvector ,
|
||||
adirection ,
|
||||
tolerance ,
|
||||
oncurve );
|
||||
UFirst = BisAna->ParameterOfStartPoint();
|
||||
ULast = BisAna->ParameterOfEndPoint();
|
||||
Bis = BisAna;
|
||||
}
|
||||
else {
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
if (IsLine) {
|
||||
//------------------------------------------------------------------
|
||||
// Demi-Droite.
|
||||
//------------------------------------------------------------------
|
||||
gp_Dir2d N ( -adirection*afirstvector.Y(), adirection*afirstvector.X());
|
||||
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 {
|
||||
//-------------------------------------------------------------------
|
||||
// Bissectrice algo
|
||||
//-------------------------------------------------------------------
|
||||
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
|
||||
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;
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
thebisector = new Geom2d_TrimmedCurve(Bis,UFirst,ULast);
|
||||
|
||||
/*
|
||||
sprintf( name, "c1_%d", ++nbb );
|
||||
DrawTrSurf::Set( name, FirstPnt );
|
||||
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 );
|
||||
*/
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// calcul de la bissectrice entre deux points issue d un point.
|
||||
//
|
||||
// afirstpoint : \ courbes entre lesquelles on veut calculer la
|
||||
// asecondpoint : / bissectrice.
|
||||
// apoint : point par lequel doit passer la bissectrice.
|
||||
// afirstvector : \ vecteurs pour determiner le secteur dans lequel
|
||||
// asecondvector : / la bissectrice doit se trouver.
|
||||
// adirection : indique le cote de la bissectrice a conserver.
|
||||
//===========================================================================
|
||||
|
||||
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 )
|
||||
{
|
||||
Handle(Bisector_BisecAna) Bis = new Bisector_BisecAna();
|
||||
|
||||
Bis -> Perform (afirstpoint ,
|
||||
asecondpoint ,
|
||||
apoint ,
|
||||
afirstvector ,
|
||||
asecondvector ,
|
||||
adirection ,
|
||||
tolerance ,
|
||||
oncurve );
|
||||
thebisector = new Geom2d_TrimmedCurve(Bis,
|
||||
Bis->ParameterOfStartPoint(),
|
||||
Bis->ParameterOfEndPoint());
|
||||
|
||||
/*
|
||||
sprintf( name, "c1_%d", ++nbb );
|
||||
DrawTrSurf::Set( name, afirstpoint->Pnt2d() );
|
||||
sprintf( name, "c2_%d", nbb );
|
||||
DrawTrSurf::Set( name, asecondpoint->Pnt2d() );
|
||||
sprintf( name, "p%d", nbb );
|
||||
DrawTrSurf::Set( name, apoint );
|
||||
sprintf( name, "b%d", nbb );
|
||||
DrawTrSurf::Set( name, thebisector );
|
||||
*/
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : Value
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
const Handle(Geom2d_TrimmedCurve)& Bisector_Bisec::Value() const
|
||||
{
|
||||
return thebisector;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : ChangeValue
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
const Handle(Geom2d_TrimmedCurve)& Bisector_Bisec::ChangeValue()
|
||||
{
|
||||
return thebisector;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : PointIsOnCurve
|
||||
// purpose :
|
||||
//=============================================================================
|
||||
#ifdef DEB
|
||||
static Standard_Boolean PointIsOnCurve(const Handle(Geom2d_Curve)& C,
|
||||
const gp_Pnt2d& P,
|
||||
Standard_Real& U)
|
||||
{
|
||||
if (C->Value(C->FirstParameter()).IsEqual(P,Precision::Confusion())) {
|
||||
U = C->FirstParameter();
|
||||
return Standard_True;
|
||||
}
|
||||
if (C->Value(C->LastParameter()).IsEqual(P,Precision::Confusion())) {
|
||||
U = C->LastParameter();
|
||||
return Standard_True;
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
#endif
|
||||
//=============================================================================
|
||||
//function : ReplaceByLineIfIsToSmall
|
||||
//purpose : Si une bissectrice algorithmique est de taille negligeable elle est
|
||||
// remplace par une demi-droite.
|
||||
//=============================================================================
|
||||
static void ReplaceByLineIfIsToSmall (Handle(Geom2d_Curve)& Bis,
|
||||
Standard_Real& UFirst,
|
||||
Standard_Real& ULast )
|
||||
|
||||
{
|
||||
if (Abs(ULast - UFirst) > 2.*Precision::PConfusion()*10.) return; //patch
|
||||
|
||||
gp_Pnt2d PF = Bis->Value(UFirst);
|
||||
gp_Pnt2d PL = Bis->Value(ULast);
|
||||
|
||||
if (PF.Distance(PL) > Precision::Confusion()*10.) return;
|
||||
|
||||
gp_Vec2d T1 = Bis->DN(UFirst,1);
|
||||
|
||||
Handle (Geom2d_CartesianPoint) PG = new Geom2d_CartesianPoint(PF);
|
||||
Handle (Geom2d_Line) L = new Geom2d_Line (PF,T1);
|
||||
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;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : IsMaxRC
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
static Standard_Boolean IsMaxRC (const Handle(Geom2d_Curve)& C,
|
||||
Standard_Real U,
|
||||
Standard_Real& R)
|
||||
{
|
||||
Standard_Real KF,KL;
|
||||
Standard_Real US = C->FirstParameter();
|
||||
Standard_Real UL = C->LastParameter();
|
||||
|
||||
gp_Vec2d D1,D2;
|
||||
gp_Pnt2d P;
|
||||
Standard_Real Norm2;
|
||||
|
||||
C->D2(US,P,D1,D2);
|
||||
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;}
|
||||
else { KL = Abs(D1^D2)/(Norm2*sqrt(Norm2));}
|
||||
|
||||
Standard_Boolean IsMax = Standard_False;
|
||||
|
||||
if (U == UL) {
|
||||
if (KL < KF) {
|
||||
if (KL == 0.0) R = Precision::Infinite(); else R = 1/KL;
|
||||
IsMax = Standard_True;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (KF < KL) {
|
||||
if (KF == 0.0) R = Precision::Infinite(); else R = 1/KF;
|
||||
IsMax = Standard_True;
|
||||
}
|
||||
}
|
||||
return IsMax;
|
||||
}
|
206
src/Bisector/Bisector_BisecAna.cdl
Executable file
206
src/Bisector/Bisector_BisecAna.cdl
Executable file
@@ -0,0 +1,206 @@
|
||||
-- File: Bisector_BisecAna.cdl
|
||||
-- Created: Thu May 19 10:55:33 1994
|
||||
-- Author: Yves FRICAUD
|
||||
-- <yfr@phobox>
|
||||
---Copyright: Matra Datavision 1992
|
||||
|
||||
class BisecAna from Bisector
|
||||
|
||||
--- Purpose :
|
||||
|
||||
inherits
|
||||
|
||||
Curve from Bisector
|
||||
|
||||
uses
|
||||
Shape from GeomAbs,
|
||||
CurveType from GeomAbs,
|
||||
Curve from Geom2d,
|
||||
Geometry from Geom2d,
|
||||
TrimmedCurve from Geom2d,
|
||||
Point from Geom2d,
|
||||
Bisec from GccInt,
|
||||
Pnt2d from gp,
|
||||
Vec2d from gp,
|
||||
Trsf2d from gp
|
||||
|
||||
raises DomainError from Standard,
|
||||
RangeError from Standard
|
||||
|
||||
is
|
||||
Create returns mutable BisecAna;
|
||||
|
||||
Perform(me : mutable ;
|
||||
Cu1 : Curve from Geom2d ;
|
||||
Cu2 : Curve from Geom2d ;
|
||||
P : Pnt2d from gp ;
|
||||
V1 : Vec2d from gp ;
|
||||
V2 : Vec2d from gp ;
|
||||
Sense : Real from Standard ;
|
||||
Tolerance : Real from Standard ;
|
||||
oncurve : Boolean from Standard = Standard_True );
|
||||
|
||||
--- Purpose : Performs the bisecting line between the curves
|
||||
-- <Cu1> and <Cu2>.
|
||||
-- <oncurve> is True if the point <P> is common to <Cu1>
|
||||
-- and <Cu2>.
|
||||
|
||||
Perform(me : mutable ;
|
||||
Cu : Curve from Geom2d ;
|
||||
Pnt : Point from Geom2d ;
|
||||
P : Pnt2d from gp ;
|
||||
V1 : Vec2d from gp ;
|
||||
V2 : Vec2d from gp ;
|
||||
Sense : Real from Standard ;
|
||||
Tolerance : Real from Standard ;
|
||||
oncurve : Boolean from Standard = Standard_True);
|
||||
|
||||
--- Purpose : Performs the bisecting line between the curve
|
||||
-- <Cu1> and the point <Pnt>.
|
||||
-- <oncurve> is True if the point <P> is the point <Pnt>.
|
||||
|
||||
Perform(me : mutable ;
|
||||
Pnt : Point from Geom2d ;
|
||||
Cu : Curve from Geom2d ;
|
||||
P : Pnt2d from gp ;
|
||||
V1 : Vec2d from gp ;
|
||||
V2 : Vec2d from gp ;
|
||||
Sense : Real from Standard ;
|
||||
Tolerance : Real from Standard ;
|
||||
oncurve : Boolean from Standard = Standard_True );
|
||||
|
||||
--- Purpose : Performs the bisecting line between the curve
|
||||
-- <Cu> and the point <Pnt>.
|
||||
-- <oncurve> is True if the point <P> is the point <Pnt>.
|
||||
|
||||
|
||||
Perform(me : mutable ;
|
||||
Pnt1 : Point from Geom2d ;
|
||||
Pnt2 : Point from Geom2d ;
|
||||
P : Pnt2d from gp ;
|
||||
V1 : Vec2d from gp ;
|
||||
V2 : Vec2d from gp ;
|
||||
Sense : Real from Standard ;
|
||||
Tolerance : Real from Standard = 0.0 ;
|
||||
oncurve : Boolean from Standard = Standard_True ) ;
|
||||
|
||||
--- Purpose : Performs the bisecting line between the two points
|
||||
-- <Pnt1> and <Pnt2>.
|
||||
|
||||
Init ( me : mutable;
|
||||
bisector : TrimmedCurve from Geom2d)
|
||||
is static;
|
||||
|
||||
IsExtendAtStart (me) returns Boolean from Standard
|
||||
is static;
|
||||
|
||||
IsExtendAtEnd (me) returns Boolean from Standard
|
||||
is static;
|
||||
|
||||
SetTrim(me : mutable ; Cu : Curve from Geom2d);
|
||||
--- Purpose : Trim <me> by a domain defined by the curve <Cu>.
|
||||
-- This domain is the set of the points which are
|
||||
-- nearest from <Cu> than the extremitis of <Cu>.
|
||||
|
||||
SetTrim(me : mutable ; uf, ul : Real from Standard);
|
||||
--- Purpose : Trim <me> by a domain defined by uf and ul
|
||||
|
||||
Distance(me : mutable ;
|
||||
P : Pnt2d from gp ;
|
||||
Bis : Bisec from GccInt ;
|
||||
V1 : Vec2d from gp ;
|
||||
V2 : Vec2d from gp ;
|
||||
Sense : Real from Standard ;
|
||||
U : out Real from Standard ;
|
||||
sense : out Boolean from Standard ;
|
||||
ok : out Boolean from Standard )
|
||||
|
||||
--- Purpose : Returns the distance between the point <P> and
|
||||
-- the bisecting <Bis>.
|
||||
returns Real
|
||||
is private;
|
||||
|
||||
|
||||
Reverse (me : mutable)
|
||||
is static;
|
||||
|
||||
ReversedParameter(me; U : Real) returns Real
|
||||
is static;
|
||||
|
||||
IsCN (me; N : Integer) returns Boolean
|
||||
--- Purpose : Returns the order of continuity of the curve.
|
||||
raises RangeError
|
||||
--- Purpose : Raised if N < 0.
|
||||
is static;
|
||||
|
||||
Copy (me) returns mutable like me
|
||||
is static;
|
||||
|
||||
Transform (me : mutable; T : Trsf2d)
|
||||
is static;
|
||||
|
||||
FirstParameter(me) returns Real
|
||||
is static;
|
||||
|
||||
LastParameter(me) returns Real
|
||||
is static;
|
||||
|
||||
IsClosed (me) returns Boolean
|
||||
is static;
|
||||
|
||||
IsPeriodic (me) returns Boolean
|
||||
is static;
|
||||
|
||||
Continuity (me) returns Shape from GeomAbs
|
||||
is static;
|
||||
|
||||
D0(me; U : Real; P : out Pnt2d)
|
||||
is static;
|
||||
|
||||
D1 (me; U : Real; P : out Pnt2d; V1 : out Vec2d)
|
||||
is static;
|
||||
|
||||
D2 (me; U : Real; P : out Pnt2d; V1, V2 : out Vec2d)
|
||||
is static;
|
||||
|
||||
D3 (me; U : Real; P : out Pnt2d; V1, V2, V3 : out Vec2d)
|
||||
is static;
|
||||
|
||||
DN (me; U : Real; N : Integer) returns Vec2d
|
||||
is static;
|
||||
|
||||
Geom2dCurve (me) returns Curve from Geom2d
|
||||
is static;
|
||||
|
||||
Parameter (me ; P : Pnt2d from gp) returns Real
|
||||
is static;
|
||||
|
||||
ParameterOfStartPoint (me) returns Real
|
||||
is static;
|
||||
|
||||
ParameterOfEndPoint (me) returns Real
|
||||
is static;
|
||||
|
||||
NbIntervals (me) returns Integer
|
||||
---Purpose: If necessary, breaks the curve in intervals of
|
||||
-- continuity <C1>. And returns the number of
|
||||
-- intervals.
|
||||
is static;
|
||||
|
||||
IntervalFirst(me ; Index : Integer from Standard) returns Real
|
||||
---Purpose: Returns the first parameter of the current
|
||||
-- interval.
|
||||
is static;
|
||||
|
||||
IntervalLast(me ; Index : Integer from Standard) returns Real
|
||||
---Purpose: Returns the last parameter of the current
|
||||
-- interval.
|
||||
is static;
|
||||
|
||||
Dump (me; Deep : Integer = 0; Offset : Integer = 0) is static;
|
||||
|
||||
fields
|
||||
|
||||
thebisector : TrimmedCurve from Geom2d;
|
||||
|
||||
end BisecAna;
|
1594
src/Bisector/Bisector_BisecAna.cxx
Executable file
1594
src/Bisector/Bisector_BisecAna.cxx
Executable file
File diff suppressed because it is too large
Load Diff
299
src/Bisector/Bisector_BisecCC.cdl
Executable file
299
src/Bisector/Bisector_BisecCC.cdl
Executable file
@@ -0,0 +1,299 @@
|
||||
-- File: Bisector_BisecCC.cdl
|
||||
-- Created: Mon Jan 10 11:49:47 1994
|
||||
-- Author: Yves FRICAUD
|
||||
-- <yfr@phylox>
|
||||
---Copyright: Matra Datavision 1994
|
||||
|
||||
|
||||
class BisecCC from Bisector
|
||||
|
||||
inherits
|
||||
|
||||
Curve from Bisector
|
||||
|
||||
---Purpose: Construct the bisector between two curves.
|
||||
-- The curves can intersect only in their extremities.
|
||||
|
||||
uses
|
||||
PolyBis from Bisector,
|
||||
Shape from GeomAbs,
|
||||
CurveType from GeomAbs,
|
||||
Curve from Geom2d,
|
||||
Geometry from Geom2d,
|
||||
Pnt2d from gp,
|
||||
Vec2d from gp,
|
||||
SequenceOfReal from TColStd,
|
||||
Trsf2d from gp
|
||||
|
||||
raises DomainError from Standard,
|
||||
RangeError from Standard
|
||||
is
|
||||
|
||||
Create returns mutable BisecCC;
|
||||
|
||||
Create (Cu1 : Curve from Geom2d;
|
||||
Cu2 : Curve from Geom2d;
|
||||
Side1 : Real ;
|
||||
Side2 : Real ;
|
||||
Origin : Pnt2d from gp ;
|
||||
DistMax : Real = 500 )
|
||||
---Purpose: Constructs the bisector between the curves <Cu1>
|
||||
-- and <Cu2>.
|
||||
--
|
||||
-- <Side1> (resp <Side2>) = 1 if the
|
||||
-- bisector curve is on the left of <Cu1> (resp <Cu2>)
|
||||
-- else <Side1> (resp <Side2>) = -1.
|
||||
--
|
||||
-- the Bisector is trimmed by the Point <Origin>.
|
||||
-- <DistMax> is used to trim the bisector.The distance
|
||||
-- between the points of the bisector and <Cu> is smaller
|
||||
-- than <DistMax>.
|
||||
--
|
||||
returns mutable BisecCC from Bisector;
|
||||
|
||||
Perform (me : mutable ;
|
||||
Cu1 : Curve from Geom2d;
|
||||
Cu2 : Curve from Geom2d;
|
||||
Side1 : Real ;
|
||||
Side2 : Real ;
|
||||
Origin : Pnt2d from gp ;
|
||||
DistMax : Real = 500 )
|
||||
---Purpose: Computes the bisector between the curves <Cu1>
|
||||
-- and <Cu2>.
|
||||
--
|
||||
-- <Side1> (resp <Side2>) = 1 if the
|
||||
-- bisector curve is on the left of <Cu1> (resp <Cu2>)
|
||||
-- else <Side1> (resp <Side2>) = -1.
|
||||
--
|
||||
-- the Bisector is trimmed by the Point <Origin>.
|
||||
--
|
||||
-- <DistMax> is used to trim the bisector.The distance
|
||||
-- between the points of the bisector and <Cu> is smaller
|
||||
-- than <DistMax>.
|
||||
--
|
||||
|
||||
is static;
|
||||
|
||||
IsExtendAtStart (me) returns Boolean from Standard
|
||||
is static;
|
||||
|
||||
IsExtendAtEnd (me) returns Boolean from Standard
|
||||
is static;
|
||||
--
|
||||
Reverse (me : mutable)
|
||||
is static;
|
||||
|
||||
ReversedParameter(me; U : Real) returns Real
|
||||
is static;
|
||||
|
||||
IsCN (me; N : Integer) returns Boolean
|
||||
--- Purpose : Returns the order of continuity of the curve.
|
||||
raises RangeError
|
||||
--- Purpose : Raised if N < 0.
|
||||
is static;
|
||||
|
||||
ChangeGuide (me) returns mutable like me
|
||||
---Purpose: The parameter on <me> is linked to the parameter
|
||||
-- on the first curve. This method creates the same bisector
|
||||
-- where the curves are inversed.
|
||||
is static;
|
||||
|
||||
Copy (me) returns mutable like me
|
||||
is static;
|
||||
|
||||
Transform (me : mutable; T : Trsf2d)
|
||||
--- Purpose :
|
||||
-- Transformation of a geometric object. This tansformation
|
||||
-- can be a translation, a rotation, a symmetry, a scaling
|
||||
-- or a complex transformation obtained by combination of
|
||||
-- the previous elementaries transformations.
|
||||
is static;
|
||||
|
||||
|
||||
--
|
||||
FirstParameter(me) returns Real
|
||||
is static;
|
||||
|
||||
LastParameter(me) returns Real
|
||||
is static;
|
||||
|
||||
Continuity(me) returns Shape from GeomAbs
|
||||
is static;
|
||||
|
||||
NbIntervals (me) returns Integer
|
||||
---Purpose: If necessary, breaks the curve in intervals of
|
||||
-- continuity <C1>. And returns the number of
|
||||
-- intervals.
|
||||
is static;
|
||||
|
||||
IntervalFirst(me ; Index : Integer from Standard) returns Real
|
||||
---Purpose: Returns the first parameter of the current
|
||||
-- interval.
|
||||
is static;
|
||||
|
||||
IntervalLast(me ; Index : Integer from Standard) returns Real
|
||||
---Purpose: Returns the last parameter of the current
|
||||
-- interval.
|
||||
is static;
|
||||
|
||||
IntervalContinuity(me) returns Shape from GeomAbs
|
||||
is static;
|
||||
|
||||
IsClosed(me) returns Boolean
|
||||
is static;
|
||||
|
||||
IsPeriodic(me) returns Boolean
|
||||
is static;
|
||||
|
||||
ValueAndDist (me; U : Real; U1, U2, Distance : in out Real)
|
||||
---Purpose: Returns the point of parameter U.
|
||||
-- Computes the distance between the current point and
|
||||
-- the two curves I separate.
|
||||
-- Computes the parameters on each curve corresponding
|
||||
-- of the projection of the current point.
|
||||
returns Pnt2d from gp
|
||||
is static;
|
||||
|
||||
|
||||
ValueByInt (me; U : Real; U1, U2, Distance : in out Real)
|
||||
returns Pnt2d from gp
|
||||
---Purpose: Returns the point of parameter U.
|
||||
-- Computes the distance between the current point and
|
||||
-- the two curves I separate.
|
||||
-- Computes the parameters on each curve corresponding
|
||||
-- of the projection of the current point.
|
||||
is static;
|
||||
|
||||
|
||||
D0 (me; U : Real; P : out Pnt2d)
|
||||
is static;
|
||||
|
||||
D1 (me; U : Real; P : out Pnt2d from gp ; V : out Vec2d from gp)
|
||||
is static ;
|
||||
|
||||
D2 (me; U : Real; P : out Pnt2d from gp; V1, V2 : out Vec2d from gp)
|
||||
is static;
|
||||
|
||||
D3 (me; U : Real; P : out Pnt2d from gp; V1, V2, V3 : out Vec2d from gp)
|
||||
is static;
|
||||
|
||||
DN (me; U : Real; N : Integer)
|
||||
returns Vec2d from gp
|
||||
is static;
|
||||
|
||||
Values (me ;
|
||||
U : Real ;
|
||||
N : Integer ;
|
||||
P : in out Pnt2d ;
|
||||
V1 : in out Vec2d ;
|
||||
V2 : in out Vec2d ;
|
||||
V3 : in out Vec2d )
|
||||
is static private;
|
||||
|
||||
|
||||
IsEmpty (me) returns Boolean from Standard
|
||||
is static;
|
||||
|
||||
LinkBisCurve (me ; U : Real) returns Real from Standard
|
||||
---Purpose: Returns the parameter on the curve1 of the projection
|
||||
-- of the point of parameter U on <me>.
|
||||
is static;
|
||||
|
||||
LinkCurveBis (me ; U : Real) returns Real from Standard
|
||||
---Purpose: Returns the reciproque of LinkBisCurve.
|
||||
is static;
|
||||
|
||||
Parameter ( me ; P : Pnt2d from gp) returns Real
|
||||
is static;
|
||||
|
||||
Curve (me ; IndCurve : Integer) returns Curve from Geom2d
|
||||
is static;
|
||||
|
||||
Polygon (me) returns PolyBis from Bisector
|
||||
---C++: return const&
|
||||
is static;
|
||||
|
||||
Dump (me; Deep : Integer = 0; Offset : Integer = 0) is static;
|
||||
|
||||
SupLastParameter (me : mutable)
|
||||
is static private;
|
||||
|
||||
Extension(me ;
|
||||
U : Real ;
|
||||
U1, U2, Dist : in out Real ;
|
||||
T1 : in out Vec2d from gp )
|
||||
returns Pnt2d from gp
|
||||
is static private;
|
||||
|
||||
SearchBound (me ; U1,U2 : Real from Standard)
|
||||
returns Real from Standard
|
||||
is static private;
|
||||
|
||||
ComputePointEnd (me : mutable)
|
||||
is static private;
|
||||
|
||||
Curve (me : mutable; Index : Integer; C : Curve from Geom2d)
|
||||
is static private;
|
||||
|
||||
Sign (me : mutable; Index : Integer; Sign : Real from Standard)
|
||||
is static private;
|
||||
|
||||
Polygon (me : mutable; Poly : PolyBis from Bisector)
|
||||
is static private;
|
||||
|
||||
DistMax (me : mutable; DistMax : Real from Standard)
|
||||
is static private;
|
||||
|
||||
IsConvex (me : mutable; Index : Integer; IsConvex : Boolean from Standard)
|
||||
is static private;
|
||||
|
||||
IsEmpty (me : mutable; IsEmpty : Boolean from Standard)
|
||||
is static private;
|
||||
|
||||
ExtensionStart (me : mutable; ExtensionStart : Boolean from Standard)
|
||||
is static private;
|
||||
|
||||
ExtensionEnd (me : mutable; ExtensionEnd : Boolean from Standard)
|
||||
is static private;
|
||||
|
||||
PointStart (me : mutable; Point : Pnt2d from gp)
|
||||
is static private;
|
||||
|
||||
PointEnd (me : mutable; Point : Pnt2d from gp)
|
||||
is static private;
|
||||
|
||||
StartIntervals (me : mutable; StartIntervals : SequenceOfReal from TColStd)
|
||||
is static private;
|
||||
|
||||
EndIntervals (me : mutable; EndIntervals : SequenceOfReal from TColStd)
|
||||
is static private;
|
||||
|
||||
FirstParameter (me : mutable; U1 : Real from Standard)
|
||||
is static private;
|
||||
|
||||
LastParameter (me : mutable; U1 : Real from Standard)
|
||||
is static private;
|
||||
|
||||
|
||||
|
||||
fields
|
||||
|
||||
curve1 : Curve from Geom2d;
|
||||
curve2 : Curve from Geom2d;
|
||||
sign1 : Real from Standard;
|
||||
sign2 : Real from Standard;
|
||||
startIntervals : SequenceOfReal from TColStd;
|
||||
endIntervals : SequenceOfReal from TColStd;
|
||||
currentInterval: Integer from Standard;
|
||||
myPolygon : PolyBis from Bisector;
|
||||
shiftParameter : Real from Standard;
|
||||
distMax : Real from Standard;
|
||||
isEmpty : Boolean from Standard;
|
||||
isConvex1 : Boolean from Standard;
|
||||
isConvex2 : Boolean from Standard;
|
||||
extensionStart : Boolean from Standard;
|
||||
extensionEnd : Boolean from Standard;
|
||||
pointStart : Pnt2d from gp;
|
||||
pointEnd : Pnt2d from gp;
|
||||
|
||||
end BisecCC;
|
1760
src/Bisector/Bisector_BisecCC.cxx
Executable file
1760
src/Bisector/Bisector_BisecCC.cxx
Executable file
File diff suppressed because it is too large
Load Diff
261
src/Bisector/Bisector_BisecPC.cdl
Executable file
261
src/Bisector/Bisector_BisecPC.cdl
Executable file
@@ -0,0 +1,261 @@
|
||||
-- File: Bisector_BisecPC.cdl
|
||||
-- Created: Mon Jan 10 11:49:47 1994
|
||||
-- Author: Yves FRICAUD
|
||||
-- <yfr@phylox>
|
||||
---Copyright: Matra Datavision 1994
|
||||
|
||||
|
||||
class BisecPC from Bisector
|
||||
|
||||
inherits
|
||||
|
||||
Curve from Bisector
|
||||
---Purpose: Provides the bisector between a point and a curve.
|
||||
-- the curvature on the curve has to be monoton.
|
||||
-- the point can't be on the curve exept at the extremitys.
|
||||
--
|
||||
|
||||
uses
|
||||
Shape from GeomAbs,
|
||||
CurveType from GeomAbs,
|
||||
Curve from Geom2d,
|
||||
Geometry from Geom2d,
|
||||
Pnt2d from gp,
|
||||
Vec2d from gp,
|
||||
SequenceOfReal from TColStd,
|
||||
Trsf2d from gp
|
||||
|
||||
|
||||
raises DomainError from Standard,
|
||||
RangeError from Standard
|
||||
is
|
||||
|
||||
Create returns mutable BisecPC;
|
||||
|
||||
Create (Cu : Curve from Geom2d;
|
||||
P : Pnt2d from gp ;
|
||||
Side : Real ;
|
||||
DistMax : Real = 500 )
|
||||
|
||||
---Purpose: Constructs the bisector between the point <P> and
|
||||
-- the curve <Cu>.
|
||||
-- <Side> = 1. if the bisector curve is on the Left of <Cu>
|
||||
-- else <Side> = -1.
|
||||
-- <DistMax> is used to trim the bisector.The distance
|
||||
-- between the points of the bisector and <Cu> is smaller
|
||||
-- than <DistMax>.
|
||||
--
|
||||
returns mutable BisecPC from Bisector;
|
||||
|
||||
Create (Cu : Curve from Geom2d;
|
||||
P : Pnt2d from gp ;
|
||||
Side : Real ;
|
||||
UMin : Real ;
|
||||
UMax : Real )
|
||||
|
||||
---Purpose: Constructs the bisector between the point <P> and
|
||||
-- the curve <Cu> Trimmed by <UMin> and <UMax>
|
||||
-- <Side> = 1. if the bisector curve is on the Left of <Cu>
|
||||
-- else <Side> = -1.
|
||||
-- Warning: the bisector is supposed all over defined between
|
||||
-- <UMin> and <UMax>.
|
||||
|
||||
returns mutable BisecPC from Bisector;
|
||||
|
||||
Perform (me : mutable ;
|
||||
Cu : Curve from Geom2d;
|
||||
P : Pnt2d from gp ;
|
||||
Side : Real ;
|
||||
DistMax : Real = 500 )
|
||||
|
||||
---Purpose: Construct the bisector between the point <P> and
|
||||
-- the curve <Cu>.
|
||||
-- <Side> = 1. if the bisector curve is on the Left of <Cu>
|
||||
-- else <Side> = -1.
|
||||
-- <DistMax> is used to trim the bisector.The distance
|
||||
-- between the points of the bisector and <Cu> is smaller
|
||||
-- than <DistMax>.
|
||||
|
||||
is static;
|
||||
|
||||
|
||||
|
||||
IsExtendAtStart (me) returns Boolean from Standard
|
||||
---Purpose: Returns True if the bisector is extended at start.
|
||||
is static;
|
||||
|
||||
IsExtendAtEnd (me) returns Boolean from Standard
|
||||
---Purpose: Returns True if the bisector is extended at end.
|
||||
is static;
|
||||
|
||||
Reverse (me : mutable)
|
||||
--- Purpose :
|
||||
-- Changes the direction of parametrization of <me>.
|
||||
-- The orientation of the curve is modified. If the curve
|
||||
-- is bounded the StartPoint of the initial curve becomes the
|
||||
-- EndPoint of the reversed curve and the EndPoint of the initial
|
||||
-- curve becomes the StartPoint of the reversed curve.
|
||||
is static;
|
||||
|
||||
ReversedParameter(me; U : Real) returns Real
|
||||
---Purpose: Returns the parameter on the reversed curve for
|
||||
-- the point of parameter U on <me>.
|
||||
is static;
|
||||
|
||||
Copy (me) returns mutable like me
|
||||
is static;
|
||||
|
||||
Transform (me : mutable; T : Trsf2d)
|
||||
--- Purpose :
|
||||
-- Transformation of a geometric object. This tansformation
|
||||
-- can be a translation, a rotation, a symmetry, a scaling
|
||||
-- or a complex transformation obtained by combination of
|
||||
-- the previous elementaries transformations.
|
||||
is static;
|
||||
|
||||
IsCN (me; N : Integer) returns Boolean
|
||||
--- Purpose : Returns the order of continuity of the curve.
|
||||
raises RangeError
|
||||
--- Purpose : Raised if N < 0.
|
||||
is static;
|
||||
|
||||
FirstParameter(me) returns Real
|
||||
--- Purpose : Value of the first parameter.
|
||||
is static;
|
||||
|
||||
LastParameter(me) returns Real
|
||||
--- Purpose : Value of the last parameter.
|
||||
is static;
|
||||
|
||||
Continuity(me) returns Shape from GeomAbs
|
||||
is static;
|
||||
|
||||
NbIntervals(me ) returns Integer
|
||||
---Purpose: If necessary, breaks the curve in intervals of
|
||||
-- continuity <C1>. And returns the number of
|
||||
-- intervals.
|
||||
is static;
|
||||
|
||||
IntervalFirst(me ; Index : Integer from Standard ) returns Real
|
||||
---Purpose: Returns the first parameter of the current
|
||||
-- interval.
|
||||
is static;
|
||||
|
||||
IntervalLast (me ; Index : Integer from Standard ) returns Real
|
||||
---Purpose: Returns the last parameter of the current
|
||||
-- interval.
|
||||
is static;
|
||||
|
||||
IntervalContinuity(me) returns Shape from GeomAbs
|
||||
is static;
|
||||
|
||||
IsClosed(me) returns Boolean
|
||||
is static;
|
||||
|
||||
IsPeriodic(me) returns Boolean
|
||||
is static;
|
||||
|
||||
Values (me ;
|
||||
U : Real ;
|
||||
N : Integer ;
|
||||
P : in out Pnt2d ;
|
||||
V1 : in out Vec2d ;
|
||||
V2 : in out Vec2d ;
|
||||
V3 : in out Vec2d )
|
||||
is static private;
|
||||
|
||||
Distance (me; U : Real) returns Real
|
||||
---Purpose: Returns the distance between the point of
|
||||
-- parameter U on <me> and my point or my curve.
|
||||
is static;
|
||||
|
||||
D0 (me; U : Real; P : out Pnt2d)
|
||||
is static;
|
||||
|
||||
D1 (me; U : Real; P : out Pnt2d from gp ; V : out Vec2d from gp)
|
||||
is static ;
|
||||
|
||||
D2 (me; U : Real; P : out Pnt2d from gp; V1, V2 : out Vec2d from gp)
|
||||
is static;
|
||||
|
||||
D3 (me; U : Real; P : out Pnt2d from gp; V1, V2, V3 : out Vec2d from gp)
|
||||
is static;
|
||||
|
||||
DN (me; U : Real; N : Integer)
|
||||
returns Vec2d from gp
|
||||
is static;
|
||||
|
||||
Dump (me; Deep : Integer = 0; Offset : Integer = 0) is static;
|
||||
|
||||
LinkBisCurve (me ; U : Real) returns Real from Standard
|
||||
---Purpose: Returns the parameter on the curve1 of the projection
|
||||
-- of the point of parameter U on <me>.
|
||||
is static;
|
||||
|
||||
LinkCurveBis (me ; U : Real) returns Real from Standard
|
||||
---Purpose: Returns the reciproque of LinkBisCurve.
|
||||
is static;
|
||||
|
||||
Extension (me ;
|
||||
U : Real ;
|
||||
P : in out Pnt2d ;
|
||||
V1 : in out Vec2d ;
|
||||
V2 : in out Vec2d ;
|
||||
V3 : in out Vec2d )
|
||||
is static private;
|
||||
|
||||
Parameter ( me ; P : Pnt2d from gp) returns Real
|
||||
---Purpose: Returns the parameter on <me> corresponding to <P>.
|
||||
is static;
|
||||
|
||||
IsEmpty (me) returns Boolean from Standard
|
||||
---Purpose: Returns <True> if the bisector is empty.
|
||||
is static;
|
||||
|
||||
ComputeIntervals (me : mutable)
|
||||
---Purpose: Computes the interval where the bisector is defined.
|
||||
is static private;
|
||||
|
||||
CuspFilter (me : mutable)
|
||||
is static private;
|
||||
|
||||
SearchBound( me ; U1,U2 : Real) returns Real
|
||||
is static private;
|
||||
|
||||
Init (me : mutable;
|
||||
Curve : Curve from Geom2d;
|
||||
Point : Pnt2d from gp;
|
||||
Sign : Real from Standard;
|
||||
StartIntervals : SequenceOfReal from TColStd;
|
||||
EndIntervals : SequenceOfReal from TColStd;
|
||||
BisInterval : Integer from Standard;
|
||||
CurrentInterval: Integer from Standard;
|
||||
ShiftParameter : Real from Standard;
|
||||
DistMax : Real from Standard;
|
||||
IsEmpty : Boolean from Standard;
|
||||
IsConvex : Boolean from Standard;
|
||||
ExtensionStart : Boolean from Standard;
|
||||
ExtensionEnd : Boolean from Standard;
|
||||
PointStartBis : Pnt2d from gp;
|
||||
PointEndBis : Pnt2d from gp)
|
||||
is static private;
|
||||
|
||||
fields
|
||||
|
||||
curve : Curve from Geom2d;
|
||||
point : Pnt2d from gp;
|
||||
sign : Real from Standard;
|
||||
startIntervals : SequenceOfReal from TColStd;
|
||||
endIntervals : SequenceOfReal from TColStd;
|
||||
bisInterval : Integer from Standard;
|
||||
currentInterval: Integer from Standard;
|
||||
shiftParameter : Real from Standard;
|
||||
distMax : Real from Standard;
|
||||
isEmpty : Boolean from Standard;
|
||||
isConvex : Boolean from Standard;
|
||||
extensionStart : Boolean from Standard;
|
||||
extensionEnd : Boolean from Standard;
|
||||
pointStartBis : Pnt2d from gp;
|
||||
pointEndBis : Pnt2d from gp;
|
||||
|
||||
end BisecPC;
|
863
src/Bisector/Bisector_BisecPC.cxx
Executable file
863
src/Bisector/Bisector_BisecPC.cxx
Executable file
@@ -0,0 +1,863 @@
|
||||
// File: Bisector_BisecPC.cxx
|
||||
// Created: Thu Mar 10 17:54:52 1994
|
||||
// Author: Yves FRICAUD
|
||||
// <yfr@phylox>
|
||||
|
||||
#include <Bisector_BisecPC.ixx>
|
||||
#include <Bisector.hxx>
|
||||
#include <Geom2dAdaptor_Curve.hxx>
|
||||
#include <Geom2d_Curve.hxx>
|
||||
#include <Geom2d_Line.hxx>
|
||||
#include <Geom2d_CartesianPoint.hxx>
|
||||
#include <Geom2dInt_GInter.hxx>
|
||||
#include <Geom2dGcc.hxx>
|
||||
#include <GccEnt_Position.hxx>
|
||||
#include <Geom2dGcc_Circ2d2TanRad.hxx>
|
||||
#include <Geom2dGcc_QualifiedCurve.hxx>
|
||||
#include <Geom2d_TrimmedCurve.hxx>
|
||||
#include <Geom2dAPI_ProjectPointOnCurve.hxx>
|
||||
#include <Geom2dLProp_CLProps2d.hxx>
|
||||
#include <gp_Pnt2d.hxx>
|
||||
#include <gp_Vec2d.hxx>
|
||||
#include <gp_Ax2d.hxx>
|
||||
#include <gp.hxx>
|
||||
#include <Precision.hxx>
|
||||
#include <ElCLib.hxx>
|
||||
#include <IntRes2d_IntersectionPoint.hxx>
|
||||
|
||||
#include <Standard_DivideByZero.hxx>
|
||||
#include <Standard_NotImplemented.hxx>
|
||||
|
||||
//=============================================================================
|
||||
//function :
|
||||
// purpose :
|
||||
//=============================================================================
|
||||
Bisector_BisecPC::Bisector_BisecPC()
|
||||
{
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function :
|
||||
// purpose :
|
||||
//=============================================================================
|
||||
Bisector_BisecPC::Bisector_BisecPC(const Handle(Geom2d_Curve)& Cu,
|
||||
const gp_Pnt2d& P,
|
||||
const Standard_Real Side,
|
||||
const Standard_Real DistMax)
|
||||
{
|
||||
Perform (Cu,P,Side,DistMax);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function :
|
||||
// purpose :
|
||||
//=============================================================================
|
||||
Bisector_BisecPC::Bisector_BisecPC(const Handle(Geom2d_Curve)& Cu,
|
||||
const gp_Pnt2d& P,
|
||||
const Standard_Real Side,
|
||||
const Standard_Real UMin,
|
||||
const Standard_Real UMax)
|
||||
|
||||
{
|
||||
curve = Handle (Geom2d_Curve)::DownCast(Cu->Copy());
|
||||
point = P;
|
||||
sign = Side;
|
||||
startIntervals.Append(UMin);
|
||||
endIntervals .Append(UMax);
|
||||
bisInterval = 1;
|
||||
extensionStart = Standard_False;
|
||||
extensionEnd = Standard_False;
|
||||
pointStartBis = Value(UMin);
|
||||
pointEndBis = Value(UMax);
|
||||
isConvex = Bisector::IsConvex(curve,sign);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : Perform
|
||||
// purpose :
|
||||
//=============================================================================
|
||||
void Bisector_BisecPC::Perform(const Handle(Geom2d_Curve)& Cu,
|
||||
const gp_Pnt2d& P,
|
||||
const Standard_Real Side,
|
||||
const Standard_Real DistMax)
|
||||
{
|
||||
curve = Handle (Geom2d_Curve)::DownCast(Cu->Copy());
|
||||
point = P;
|
||||
distMax = DistMax;
|
||||
sign = Side;
|
||||
isConvex = Bisector::IsConvex(curve,sign);
|
||||
//--------------------------------------------
|
||||
// Calcul intervalle de definition.
|
||||
//--------------------------------------------
|
||||
ComputeIntervals();
|
||||
if (isEmpty) return;
|
||||
|
||||
//-------------------------
|
||||
// Construction extensions.
|
||||
//-------------------------
|
||||
bisInterval = 1;
|
||||
extensionStart = Standard_False;
|
||||
extensionEnd = Standard_False;
|
||||
pointStartBis = Value(startIntervals.First());
|
||||
pointEndBis = Value(endIntervals .Last());
|
||||
|
||||
if (!isConvex) {
|
||||
if (point.IsEqual(curve->Value(curve->FirstParameter()),
|
||||
Precision::Confusion()) ) {
|
||||
extensionStart = Standard_True;
|
||||
Standard_Real UFirst = startIntervals.First() - P.Distance(pointStartBis);
|
||||
startIntervals.InsertBefore(1,UFirst);
|
||||
endIntervals .InsertBefore(1,startIntervals.Value(2));
|
||||
bisInterval = 2;
|
||||
}
|
||||
else if (point.IsEqual(curve->Value(curve->LastParameter()),
|
||||
Precision::Confusion()) ) {
|
||||
extensionEnd = Standard_True;
|
||||
Standard_Real ULast = endIntervals.Last() + P.Distance(pointEndBis);
|
||||
startIntervals.Append(endIntervals.Last());
|
||||
endIntervals .Append(ULast);
|
||||
bisInterval = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : IsExtendAtStart
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
Standard_Boolean Bisector_BisecPC::IsExtendAtStart() const
|
||||
{
|
||||
return extensionStart;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : IsExtendAtEnd
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
Standard_Boolean Bisector_BisecPC::IsExtendAtEnd() const
|
||||
{
|
||||
return extensionEnd;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : Reverse
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
void Bisector_BisecPC::Reverse()
|
||||
{
|
||||
Standard_NotImplemented::Raise();
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : ReversedParameter
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
Standard_Real Bisector_BisecPC::ReversedParameter(const Standard_Real U) const
|
||||
{
|
||||
return LastParameter() + FirstParameter() - U;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : Copy
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
Handle(Geom2d_Geometry) Bisector_BisecPC::Copy() const
|
||||
{
|
||||
Handle(Geom2d_Curve) CopyC = Handle(Geom2d_Curve)::DownCast(curve->Copy());
|
||||
Handle(Bisector_BisecPC) C = new Bisector_BisecPC();
|
||||
|
||||
C->Init (CopyC,point,sign,
|
||||
startIntervals,endIntervals,bisInterval,currentInterval,
|
||||
shiftParameter,distMax,isEmpty,isConvex,extensionStart,extensionEnd,
|
||||
pointStartBis,pointEndBis);
|
||||
return C;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : Transform
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
void Bisector_BisecPC::Transform(const gp_Trsf2d& T)
|
||||
{
|
||||
curve ->Transform(T);
|
||||
point . Transform(T);
|
||||
pointStartBis. Transform(T);
|
||||
pointEndBis . Transform(T);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : IsCN
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
Standard_Boolean Bisector_BisecPC::IsCN(const Standard_Integer N) const
|
||||
{
|
||||
return curve->IsCN(N+1);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : FirstParameter
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
Standard_Real Bisector_BisecPC::FirstParameter() const
|
||||
{
|
||||
return startIntervals.First();
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : LastParameter
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
Standard_Real Bisector_BisecPC::LastParameter() const
|
||||
{
|
||||
return endIntervals.Last();
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : Continuity
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
GeomAbs_Shape Bisector_BisecPC::Continuity() const
|
||||
{
|
||||
GeomAbs_Shape Cont = curve->Continuity();
|
||||
switch (Cont) {
|
||||
case GeomAbs_C1 : return GeomAbs_C0;
|
||||
case GeomAbs_C2 : return GeomAbs_C1;
|
||||
case GeomAbs_C3 : return GeomAbs_C2;
|
||||
case GeomAbs_CN : return GeomAbs_CN;
|
||||
#ifndef DEB
|
||||
default: break;
|
||||
#endif
|
||||
}
|
||||
return GeomAbs_C0;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : NbIntervals
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
Standard_Integer Bisector_BisecPC::NbIntervals() const
|
||||
{
|
||||
return startIntervals.Length();
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : IntervalFirst
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
Standard_Real Bisector_BisecPC::IntervalFirst(const Standard_Integer I) const
|
||||
{
|
||||
return startIntervals.Value(I);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : IntervalLast
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
Standard_Real Bisector_BisecPC::IntervalLast(const Standard_Integer I) const
|
||||
{
|
||||
return endIntervals.Value(I);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : IntervalContinuity
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
GeomAbs_Shape Bisector_BisecPC::IntervalContinuity() const
|
||||
{
|
||||
GeomAbs_Shape Cont = curve->Continuity();
|
||||
switch (Cont) {
|
||||
case GeomAbs_C1 : return GeomAbs_C0;
|
||||
case GeomAbs_C2 : return GeomAbs_C1;
|
||||
case GeomAbs_C3 : return GeomAbs_C2;
|
||||
case GeomAbs_CN : return GeomAbs_CN;
|
||||
#ifndef DEB
|
||||
default: break;
|
||||
#endif
|
||||
}
|
||||
return GeomAbs_C0;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : IsClosed
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
Standard_Boolean Bisector_BisecPC::IsClosed() const
|
||||
{
|
||||
if (curve->IsClosed()) {
|
||||
//-----------------------------------------------------------------------
|
||||
// La bisectrice est fermee si la curve est fermee et que la bissectrice
|
||||
// a un seul domaine de continuite egale a celui de la courbe.
|
||||
// -----------------------------------------------------------------------
|
||||
if (startIntervals.First() == curve->FirstParameter() &&
|
||||
endIntervals .First() == curve->LastParameter () )
|
||||
return Standard_True;
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : IsPeriodic
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
Standard_Boolean Bisector_BisecPC::IsPeriodic() const
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : Extension
|
||||
// purpose :
|
||||
//=============================================================================
|
||||
void Bisector_BisecPC::Extension(const Standard_Real U,
|
||||
gp_Pnt2d& P,
|
||||
gp_Vec2d& V1,
|
||||
gp_Vec2d& V2,
|
||||
gp_Vec2d& V3 ) const
|
||||
{
|
||||
gp_Dir2d DirExt;
|
||||
Standard_Real dU;
|
||||
|
||||
if ( U < startIntervals.Value(bisInterval)) {
|
||||
dU = U - startIntervals.Value(bisInterval);
|
||||
DirExt.SetCoord(pointStartBis.X() - point.X(),
|
||||
pointStartBis.Y() - point.Y());
|
||||
P.SetCoord(pointStartBis.X() + dU*DirExt.X(),
|
||||
pointStartBis.Y() + dU*DirExt.Y());
|
||||
}
|
||||
else if ( U > endIntervals.Value(bisInterval)) {
|
||||
dU = U - endIntervals.Value(bisInterval);
|
||||
DirExt.SetCoord(point.X() - pointEndBis.X(),
|
||||
point.Y() - pointEndBis.Y());
|
||||
P.SetCoord(pointEndBis.X() + dU*DirExt.X(),
|
||||
pointEndBis.Y() + dU*DirExt.Y());
|
||||
}
|
||||
V1.SetCoord(DirExt.X(),DirExt.Y());
|
||||
V2.SetCoord(0. ,0. );
|
||||
V3.SetCoord(0. ,0. );
|
||||
}
|
||||
|
||||
|
||||
//=============================================================================
|
||||
//function : Values
|
||||
// purpose : A chaque point de la courbe est associe un point sur la
|
||||
// bissectrice. l equation de la bissectrice est:
|
||||
// || PP(u)||**2
|
||||
// F(u) = P(u) - 1/2* -------------- * N(u)
|
||||
// (N(u)|PP(u))
|
||||
//
|
||||
// N(u) normale a la courbe en u.
|
||||
// ( | ) designe le produit scalaire.
|
||||
//=============================================================================
|
||||
void Bisector_BisecPC::Values(const Standard_Real U,
|
||||
const Standard_Integer N,
|
||||
gp_Pnt2d& P,
|
||||
gp_Vec2d& V1,
|
||||
gp_Vec2d& V2,
|
||||
gp_Vec2d& V3 ) const
|
||||
{
|
||||
if ( U < startIntervals.Value(bisInterval)) {
|
||||
Extension(U,P,V1,V2,V3);
|
||||
return;
|
||||
}
|
||||
else if ( U > endIntervals.Value(bisInterval)) {
|
||||
Extension(U,P,V1,V2,V3);
|
||||
return;
|
||||
}
|
||||
Standard_Real UOnCurve = LinkBisCurve(U);
|
||||
|
||||
gp_Vec2d Tu,Tuu,T3u;
|
||||
gp_Pnt2d PC;
|
||||
|
||||
switch (N) {
|
||||
case 0 : {curve->D1(UOnCurve,PC,Tu) ;break;}
|
||||
case 1 : {curve->D2(UOnCurve,PC,Tu,Tuu) ;break;}
|
||||
case 2 : {curve->D3(UOnCurve,PC,Tu,Tuu,T3u);break;}
|
||||
}
|
||||
|
||||
gp_Vec2d PPC(PC.X() - point.X(), PC.Y() - point.Y());
|
||||
gp_Vec2d Nor( - Tu.Y(), Tu.X());
|
||||
|
||||
Standard_Real SquarePPC = PPC.SquareMagnitude();
|
||||
Standard_Real NorPPC = Nor.Dot(PPC);
|
||||
Standard_Real A1;
|
||||
|
||||
if (Abs(NorPPC) > gp::Resolution() && (NorPPC*sign) < 0.) {
|
||||
A1 = 0.5*SquarePPC/NorPPC;
|
||||
P.SetCoord(PC.X() - Nor.X()*A1, PC.Y() - Nor.Y()*A1);
|
||||
}
|
||||
else {return; }
|
||||
|
||||
if (N == 0) return; // Fin Calcul Point;
|
||||
|
||||
gp_Vec2d Nu ( - Tuu.Y() , Tuu.X()); // derivee de la normale en U.
|
||||
Standard_Real NuPPC = Nu .Dot(PPC);
|
||||
Standard_Real TuPPC = Tu .Dot(PPC);
|
||||
Standard_Real NorPPCE2 = NorPPC*NorPPC;
|
||||
Standard_Real A2 = TuPPC/NorPPC - 0.5*NuPPC*SquarePPC/NorPPCE2;
|
||||
|
||||
//--------------------------
|
||||
V1 = Tu - A1*Nu - A2*Nor;
|
||||
//--------------------------
|
||||
if (N == 1) return; //Fin calcul D1.
|
||||
|
||||
gp_Vec2d Nuu ( - T3u.Y() , T3u.X());
|
||||
|
||||
Standard_Real NorPPCE4 = NorPPCE2*NorPPCE2;
|
||||
Standard_Real NuuPPC = Nuu.Dot(PPC);
|
||||
Standard_Real TuuPPC = Tuu.Dot(PPC);
|
||||
|
||||
Standard_Real A21 = TuuPPC/NorPPC - TuPPC*NuPPC/NorPPCE2;
|
||||
Standard_Real A22 = (0.5*NuuPPC*SquarePPC + NuPPC*TuPPC)/NorPPCE2 -
|
||||
NuPPC*SquarePPC*NorPPC*NuPPC/NorPPCE4;
|
||||
Standard_Real A2u = A21 - A22;
|
||||
//----------------------------------------
|
||||
V2 = Tuu - 2*A2*Nu - A1*Nuu - A2u*Nor;
|
||||
//----------------------------------------
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : Curvature
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
// Unused :
|
||||
#ifdef DEB
|
||||
static Standard_Real Curvature (const Handle(Geom2d_Curve)& C,
|
||||
Standard_Real U,
|
||||
Standard_Real Tol)
|
||||
{
|
||||
Standard_Real K1;
|
||||
gp_Vec2d D1,D2;
|
||||
gp_Pnt2d P;
|
||||
C->D2(U,P,D1,D2);
|
||||
Standard_Real Norm2 = D1.SquareMagnitude();;
|
||||
if (Norm2 < Tol) {
|
||||
K1 = 0.0;
|
||||
}
|
||||
else {
|
||||
K1 = (D1^D2)/(Norm2*sqrt(Norm2));
|
||||
}
|
||||
return K1;
|
||||
}
|
||||
#endif
|
||||
|
||||
//=============================================================================
|
||||
//function : Distance
|
||||
//purpose : distance au carre du point de parametre U a la courbe et au point:
|
||||
//
|
||||
// 2 ||PP(u)||**4 2
|
||||
// d = 1/4* ------------------- ||Nor||
|
||||
// (Nor(u)/PP(u))**2
|
||||
//
|
||||
// ou Nor est la normale a la courbe en U.
|
||||
//=============================================================================
|
||||
Standard_Real Bisector_BisecPC::Distance (const Standard_Real U) const
|
||||
{
|
||||
gp_Vec2d Tan;
|
||||
gp_Pnt2d PC;
|
||||
|
||||
Standard_Real UOnCurve = LinkBisCurve(U);
|
||||
|
||||
curve->D1(UOnCurve,PC,Tan);
|
||||
gp_Vec2d PPC(PC.X() - point.X(), PC.Y() - point.Y());
|
||||
gp_Vec2d Nor( - Tan.Y(), Tan.X());
|
||||
|
||||
Standard_Real NorNor = Nor.SquareMagnitude();
|
||||
Standard_Real SquareMagPPC = PPC.SquareMagnitude();
|
||||
Standard_Real Prosca = Nor.Dot(PPC);
|
||||
|
||||
if (point.IsEqual(PC,Precision::Confusion())) {
|
||||
if (isConvex) { return 0.;}
|
||||
//----------------------------------------------------
|
||||
// le point est sur une courbe concave.
|
||||
// Le point voulu n est pas le point commun.
|
||||
// ceci pour evite la discontinuite de la bisectrice.
|
||||
//----------------------------------------------------
|
||||
else { return Precision::Infinite();}
|
||||
}
|
||||
|
||||
if (Abs(Prosca) < Precision::Confusion() || (Prosca*sign) > 0. ) {
|
||||
return Precision::Infinite();
|
||||
}
|
||||
else {
|
||||
Standard_Real A = 0.5*SquareMagPPC/Prosca;
|
||||
Standard_Real Dist = A*A*NorNor;
|
||||
//----------------------------------------
|
||||
// Test Courbure si la courbe est concave.
|
||||
//----------------------------------------
|
||||
// if (!isConvex){
|
||||
// Standard_Real K = Curvature(curve,UOnCurve,Precision::Confusion());
|
||||
// if (K != 0.) {
|
||||
// if (Dist > 1/(K*K)) { Dist = Precision::Infinite();}
|
||||
// }
|
||||
// }
|
||||
return Dist;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=============================================================================
|
||||
//function : D0
|
||||
// purpose :
|
||||
//=============================================================================
|
||||
void Bisector_BisecPC::D0(const Standard_Real U,
|
||||
gp_Pnt2d& P) const
|
||||
{
|
||||
P = point;
|
||||
gp_Vec2d V1,V2,V3;
|
||||
Values(U,0,P,V1,V2,V3);
|
||||
}
|
||||
|
||||
|
||||
//=============================================================================
|
||||
//function : D1
|
||||
// purpose :
|
||||
//=============================================================================
|
||||
void Bisector_BisecPC::D1(const Standard_Real U,
|
||||
gp_Pnt2d& P,
|
||||
gp_Vec2d& V ) const
|
||||
{
|
||||
P = point;
|
||||
V.SetCoord(0.,0.);
|
||||
gp_Vec2d V2,V3;
|
||||
Values(U,1,P,V,V2,V3);
|
||||
}
|
||||
|
||||
|
||||
//=============================================================================
|
||||
//function : D2
|
||||
// purpose :
|
||||
//=============================================================================
|
||||
void Bisector_BisecPC::D2(const Standard_Real U,
|
||||
gp_Pnt2d& P,
|
||||
gp_Vec2d& V1,
|
||||
gp_Vec2d& V2) const
|
||||
{
|
||||
P = point;
|
||||
V1.SetCoord(0.,0.);
|
||||
V2.SetCoord(0.,0.);
|
||||
gp_Vec2d V3;
|
||||
Values(U,2,P,V1,V2,V3);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : D3
|
||||
// purpose :
|
||||
//=============================================================================
|
||||
void Bisector_BisecPC::D3(const Standard_Real U,
|
||||
gp_Pnt2d& P,
|
||||
gp_Vec2d& V1,
|
||||
gp_Vec2d& V2,
|
||||
gp_Vec2d& V3) const
|
||||
{
|
||||
P = point;
|
||||
V1.SetCoord(0.,0.);
|
||||
V2.SetCoord(0.,0.);
|
||||
V3.SetCoord(0.,0.);
|
||||
Values(U,3,P,V1,V2,V3);
|
||||
}
|
||||
|
||||
|
||||
//=============================================================================
|
||||
//function : DN
|
||||
// purpose :
|
||||
//=============================================================================
|
||||
gp_Vec2d Bisector_BisecPC::DN (const Standard_Real U,
|
||||
const Standard_Integer N) const
|
||||
{
|
||||
gp_Pnt2d P = point;
|
||||
gp_Vec2d V1(0.,0.);
|
||||
gp_Vec2d V2(0.,0.);
|
||||
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();
|
||||
}
|
||||
}
|
||||
return V1;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : SearchBound
|
||||
// purpose :
|
||||
//=============================================================================
|
||||
Standard_Real Bisector_BisecPC::SearchBound (const Standard_Real U1,
|
||||
const Standard_Real U2) const
|
||||
{
|
||||
Standard_Real Dist1,Dist2,DistMid,U11,U22;
|
||||
#ifndef DEB
|
||||
Standard_Real UMid = 0.;
|
||||
#else
|
||||
Standard_Real UMid;
|
||||
#endif
|
||||
Standard_Real Tol = Precision::PConfusion();
|
||||
Standard_Real DistMax2 = distMax*distMax;
|
||||
U11 = U1; U22 = U2;
|
||||
Dist1 = Distance(U11);
|
||||
Dist2 = Distance(U22);
|
||||
|
||||
while ((U22 - U11) > Tol) {
|
||||
UMid = 0.5*( U22 + U11);
|
||||
DistMid = Distance(UMid);
|
||||
if ((Dist1 > DistMax2) == (DistMid > DistMax2)) {
|
||||
U11 = UMid;
|
||||
Dist1 = DistMid;
|
||||
}
|
||||
else {
|
||||
U22 = UMid;
|
||||
Dist2 = DistMid;
|
||||
}
|
||||
}
|
||||
return UMid;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : CuspFilter
|
||||
// purpose :
|
||||
//=============================================================================
|
||||
void Bisector_BisecPC::CuspFilter()
|
||||
{
|
||||
Standard_NotImplemented::Raise();
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : ComputeIntervals
|
||||
// purpose :
|
||||
//=============================================================================
|
||||
void Bisector_BisecPC::ComputeIntervals ()
|
||||
{
|
||||
#ifndef DEB
|
||||
Standard_Real U1 =0.,U2 =0.,UProj =0.;
|
||||
#else
|
||||
Standard_Real U1,U2,UProj;
|
||||
#endif
|
||||
Standard_Real UStart,UEnd;
|
||||
Standard_Real Dist1,Dist2,DistProj;
|
||||
isEmpty = Standard_False;
|
||||
shiftParameter = 0.;
|
||||
Standard_Boolean YaProj = Standard_False;
|
||||
Standard_Real DistMax2 = distMax*distMax;
|
||||
|
||||
U1 = curve->FirstParameter();
|
||||
U2 = curve->LastParameter();
|
||||
Dist1 = Distance(U1);
|
||||
Dist2 = Distance(U2);
|
||||
DistProj = Precision::Infinite();
|
||||
|
||||
Geom2dAPI_ProjectPointOnCurve Proj(point,curve,U1,U2);
|
||||
if (Proj.NbPoints() > 0) {
|
||||
UProj = Proj.LowerDistanceParameter();
|
||||
DistProj = Distance(UProj);
|
||||
YaProj = Standard_True;
|
||||
}
|
||||
|
||||
if (Dist1 < DistMax2 && Dist2 < DistMax2) {
|
||||
if (DistProj > DistMax2 && YaProj) {
|
||||
isEmpty = Standard_True;
|
||||
}
|
||||
else {
|
||||
startIntervals.Append(U1);
|
||||
endIntervals .Append(U2);
|
||||
}
|
||||
return;
|
||||
}
|
||||
else if (Dist1 > DistMax2 && Dist2 > DistMax2) {
|
||||
if (DistProj < DistMax2) {
|
||||
UStart = SearchBound(U1,UProj);
|
||||
UEnd = SearchBound(UProj,U2);
|
||||
}
|
||||
else {
|
||||
isEmpty = Standard_True;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (Dist1 < DistMax2) {
|
||||
UStart = U1;
|
||||
UEnd = SearchBound(U1,U2);
|
||||
}
|
||||
else if (Dist2 < DistMax2) {
|
||||
UEnd = U2;
|
||||
UStart = SearchBound(U1,U2);
|
||||
}
|
||||
startIntervals.Append(UStart);
|
||||
endIntervals .Append(UEnd);
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Decalage eventuel du parametre sur la courbe par rapport a celui sur
|
||||
// la curve. Le decalage est effectue si la curve est periodique. et
|
||||
// que le point de parametre initial est interieure a un interval de cont
|
||||
// inuite.
|
||||
//------------------------------------------------------------------------
|
||||
if (curve->IsPeriodic()) {
|
||||
if (startIntervals.Length() > 1) { // Plusieurs intervals.
|
||||
if (endIntervals .Last() == curve->LastParameter() &&
|
||||
startIntervals.First() == curve->FirstParameter() ) {
|
||||
//---------------------------------------------------------------
|
||||
// la bissectrice est definie a l origine.
|
||||
// => Fusion du premier et du dernier interval.
|
||||
// => le 0 sur la bisectrice devient le debut du premier interval
|
||||
// => decalage de parametre sur toutes les bornes des intervals.
|
||||
//---------------------------------------------------------------
|
||||
startIntervals.Remove(1);
|
||||
endIntervals .Remove(endIntervals.Length());
|
||||
|
||||
shiftParameter = Period() - startIntervals.First() ;
|
||||
for (Standard_Integer k = 1; k <= startIntervals.Length(); k++) {
|
||||
endIntervals .ChangeValue(k) += shiftParameter;
|
||||
startIntervals.ChangeValue(k) += shiftParameter;
|
||||
}
|
||||
startIntervals.ChangeValue(1) = 0.;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : LinkBisCurve
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
Standard_Real Bisector_BisecPC::LinkBisCurve(const Standard_Real U) const
|
||||
{
|
||||
return (U - shiftParameter);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : LinkCurveBis
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
Standard_Real Bisector_BisecPC::LinkCurveBis(const Standard_Real U) const
|
||||
{
|
||||
return (U + shiftParameter);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : IsEmpty
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
Standard_Boolean Bisector_BisecPC::IsEmpty() const
|
||||
{
|
||||
return isEmpty;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//function : Parameter
|
||||
//purpose :
|
||||
//==========================================================================
|
||||
Standard_Real Bisector_BisecPC::Parameter(const gp_Pnt2d& P) const
|
||||
{
|
||||
Standard_Real Tol = Precision::Confusion();
|
||||
|
||||
if (P.IsEqual(pointStartBis,Tol)) {return startIntervals.Value(bisInterval);}
|
||||
if (P.IsEqual(pointEndBis ,Tol)) {return endIntervals .Value(bisInterval);}
|
||||
|
||||
if (extensionStart) {
|
||||
gp_Ax2d Axe(pointStartBis,gp_Dir2d(pointStartBis.X() - P.X(),
|
||||
pointStartBis.Y() - P.Y()));
|
||||
Standard_Real U = ElCLib::LineParameter(Axe,P);
|
||||
gp_Pnt2d Proj = ElCLib::LineValue(U,Axe);
|
||||
if (Proj.IsEqual(P,Tol) && U < 0.) {
|
||||
return U + startIntervals.Value(bisInterval);
|
||||
}
|
||||
}
|
||||
if (extensionEnd) {
|
||||
gp_Ax2d Axe(pointEndBis,gp_Dir2d(P.X() - pointEndBis.X(),
|
||||
P.Y() - pointEndBis.Y()));
|
||||
Standard_Real U = ElCLib::LineParameter(Axe,P);
|
||||
gp_Pnt2d Proj = ElCLib::LineValue(U,Axe);
|
||||
if (Proj.IsEqual(P,Tol) && U > 0.) {
|
||||
return U + endIntervals.Value(bisInterval);
|
||||
}
|
||||
}
|
||||
#ifndef DEB
|
||||
Standard_Real UOnCurve = 0.;
|
||||
#else
|
||||
Standard_Real UOnCurve;
|
||||
#endif
|
||||
Geom2dAPI_ProjectPointOnCurve Proj(P,curve,
|
||||
curve->FirstParameter(),curve->LastParameter());
|
||||
if (Proj.NbPoints() > 0) {
|
||||
UOnCurve = Proj.LowerDistanceParameter();
|
||||
}
|
||||
return LinkCurveBis(UOnCurve);
|
||||
}
|
||||
|
||||
|
||||
//=============================================================================
|
||||
//function : Indent
|
||||
// purpose :
|
||||
//=============================================================================
|
||||
static void Indent(const Standard_Integer Offset) {
|
||||
if (Offset > 0) {
|
||||
for (Standard_Integer i = 0; i < Offset; i++) {cout << " ";}
|
||||
}
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : Init
|
||||
// purpose :
|
||||
//=============================================================================
|
||||
void Bisector_BisecPC::Init (const Handle_Geom2d_Curve& Curve,
|
||||
const gp_Pnt2d& Point,
|
||||
const Standard_Real Sign,
|
||||
const TColStd_SequenceOfReal& StartIntervals,
|
||||
const TColStd_SequenceOfReal& EndIntervals,
|
||||
const Standard_Integer BisInterval,
|
||||
const Standard_Integer CurrentInterval,
|
||||
const Standard_Real ShiftParameter,
|
||||
const Standard_Real DistMax,
|
||||
const Standard_Boolean IsEmpty,
|
||||
const Standard_Boolean IsConvex,
|
||||
const Standard_Boolean ExtensionStart,
|
||||
const Standard_Boolean ExtensionEnd,
|
||||
const gp_Pnt2d& PointStartBis,
|
||||
const gp_Pnt2d& PointEndBis)
|
||||
{
|
||||
curve = Curve;
|
||||
point = Point;
|
||||
sign = Sign ;
|
||||
startIntervals = StartIntervals;
|
||||
endIntervals = EndIntervals;
|
||||
bisInterval = BisInterval;
|
||||
currentInterval = CurrentInterval;
|
||||
shiftParameter = ShiftParameter;
|
||||
distMax = DistMax;
|
||||
isEmpty = IsEmpty;
|
||||
isConvex = IsConvex;
|
||||
extensionStart = ExtensionStart;
|
||||
extensionEnd = ExtensionEnd;
|
||||
pointStartBis = PointStartBis;
|
||||
pointEndBis = PointEndBis;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : Dump
|
||||
// purpose :
|
||||
//=============================================================================
|
||||
//void Bisector_BisecPC::Dump(const Standard_Integer Deep,
|
||||
void Bisector_BisecPC::Dump(const Standard_Integer ,
|
||||
const Standard_Integer Offset) const
|
||||
{
|
||||
Indent (Offset);
|
||||
cout <<"Bisector_BisecPC :"<<endl;
|
||||
Indent (Offset);
|
||||
cout <<"Point :"<<endl;
|
||||
cout <<" X = "<<point.X()<<endl;
|
||||
cout <<" Y = "<<point.Y()<<endl;
|
||||
cout <<"Sign :"<<sign<<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 ;
|
||||
}
|
||||
cout <<"Index Current Interval :"<<currentInterval<<endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
48
src/Bisector/Bisector_Curve.cdl
Executable file
48
src/Bisector/Bisector_Curve.cdl
Executable file
@@ -0,0 +1,48 @@
|
||||
-- File: Bisector_Curve.cdl
|
||||
-- Created: Fri Mar 18 10:18:20 1994
|
||||
-- Author: Yves FRICAUD
|
||||
-- <yfr@viandox>
|
||||
---Copyright: Matra Datavision 1994
|
||||
|
||||
|
||||
deferred class Curve from Bisector
|
||||
|
||||
---Purpose:
|
||||
|
||||
inherits
|
||||
Curve from Geom2d
|
||||
|
||||
uses
|
||||
Pnt2d from gp
|
||||
|
||||
is
|
||||
|
||||
Parameter ( me ; P : Pnt2d from gp) returns Real
|
||||
is deferred;
|
||||
|
||||
IsExtendAtStart (me) returns Boolean from Standard
|
||||
is deferred;
|
||||
|
||||
IsExtendAtEnd (me) returns Boolean from Standard
|
||||
is deferred;
|
||||
|
||||
NbIntervals (me) returns Integer
|
||||
---Purpose: If necessary, breaks the curve in intervals of
|
||||
-- continuity <C1>. And returns the number of
|
||||
-- intervals.
|
||||
is deferred;
|
||||
|
||||
IntervalFirst(me; Index : Integer from Standard) returns Real
|
||||
---Purpose: Returns the first parameter of the current
|
||||
-- interval.
|
||||
is deferred;
|
||||
|
||||
IntervalLast(me; Index : Integer from Standard) returns Real
|
||||
---Purpose: Returns the last parameter of the current
|
||||
-- interval.
|
||||
is deferred;
|
||||
|
||||
end Curve;
|
||||
|
||||
|
||||
|
7
src/Bisector/Bisector_Curve.cxx
Executable file
7
src/Bisector/Bisector_Curve.cxx
Executable file
@@ -0,0 +1,7 @@
|
||||
// File: Bisector_Curve.cxx
|
||||
// Created: Fri Mar 18 15:26:00 1994
|
||||
// Author: Yves FRICAUD
|
||||
// <yfr@phylox>
|
||||
|
||||
|
||||
#include <Bisector_Curve.ixx>
|
47
src/Bisector/Bisector_FunctionH.cdl
Executable file
47
src/Bisector/Bisector_FunctionH.cdl
Executable file
@@ -0,0 +1,47 @@
|
||||
-- File: Bisector_FunctionH.cdl
|
||||
-- Created: Tue Apr 5 14:05:05 1994
|
||||
-- Author: Yves FRICAUD
|
||||
-- <yfr@phylox>
|
||||
---Copyright: Matra Datavision 1994
|
||||
|
||||
|
||||
private class FunctionH from Bisector
|
||||
|
||||
inherits FunctionWithDerivative from math
|
||||
|
||||
-- 2 2
|
||||
---Purpose: H(v) = (T1 .P2(v) - P1) * ||T(v)|| -
|
||||
-- 2 2
|
||||
-- (T(v).P2(v) - P1) * ||T1||
|
||||
|
||||
uses
|
||||
Curve from Geom2d,
|
||||
Pnt2d from gp,
|
||||
Vec2d from gp
|
||||
|
||||
is
|
||||
|
||||
Create (C2 : Curve from Geom2d ;
|
||||
P1 : Pnt2d from gp ;
|
||||
T1 : Vec2d from gp )
|
||||
returns FunctionH from Bisector;
|
||||
|
||||
Value(me : in out; X : Real; F : out Real)
|
||||
---Purpose: Computes the values of the Functions for the variable <X>.
|
||||
returns Boolean;
|
||||
|
||||
Derivative(me : in out; X : Real; D : out Real)
|
||||
returns Boolean;
|
||||
|
||||
Values(me : in out ; X : Real; F : out Real; D : out Real)
|
||||
---Purpose: Returns the values of the functions and the derivatives
|
||||
-- for the variable <X>.
|
||||
returns Boolean;
|
||||
|
||||
fields
|
||||
|
||||
curve2 : Curve from Geom2d;
|
||||
p1 : Pnt2d from gp;
|
||||
t1 : Vec2d from gp;
|
||||
|
||||
end FunctionH;
|
85
src/Bisector/Bisector_FunctionH.cxx
Executable file
85
src/Bisector/Bisector_FunctionH.cxx
Executable file
@@ -0,0 +1,85 @@
|
||||
// File: Bisector_FunctionH.cxx
|
||||
// Created: Tue Apr 5 14:33:16 1994
|
||||
// Author: Yves FRICAUD
|
||||
// <yfr@phylox>
|
||||
|
||||
|
||||
#include <Bisector_FunctionH.ixx>
|
||||
#include <Geom2d_Curve.hxx>
|
||||
|
||||
//=============================================================================
|
||||
//function :
|
||||
// purpose :
|
||||
//=============================================================================
|
||||
Bisector_FunctionH::Bisector_FunctionH (const Handle(Geom2d_Curve)& C2,
|
||||
const gp_Pnt2d& P1,
|
||||
const gp_Vec2d& T1)
|
||||
:p1(P1),t1(T1)
|
||||
{
|
||||
t1.Normalize();
|
||||
curve2 = C2;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : Value
|
||||
// purpose :
|
||||
// F = P1P2.(||T2||T1 + T2)
|
||||
//=============================================================================
|
||||
Standard_Boolean Bisector_FunctionH::Value (const Standard_Real X,
|
||||
Standard_Real& F)
|
||||
{
|
||||
gp_Pnt2d P2 ; // point sur C2.
|
||||
gp_Vec2d T2 ; // tangente a C2 en V.
|
||||
curve2->D1(X,P2,T2);
|
||||
|
||||
Standard_Real NormT2 = T2.Magnitude();
|
||||
Standard_Real Ax = NormT2*t1.X() - T2.X();
|
||||
Standard_Real Ay = NormT2*t1.Y() - T2.Y();
|
||||
|
||||
F = (p1.X() - P2.X())*Ax + (p1.Y() - P2.Y())*Ay;
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : Derivative
|
||||
// purpose :
|
||||
//=============================================================================
|
||||
Standard_Boolean Bisector_FunctionH::Derivative(const Standard_Real X,
|
||||
Standard_Real& D)
|
||||
{
|
||||
Standard_Real F;
|
||||
return Values (X,F,D);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : Values
|
||||
// purpose :
|
||||
//=============================================================================
|
||||
Standard_Boolean Bisector_FunctionH::Values (const Standard_Real X,
|
||||
Standard_Real& F,
|
||||
Standard_Real& D)
|
||||
{
|
||||
gp_Pnt2d P2 ; // point sur C2.
|
||||
gp_Vec2d T2 ; // tangente a C2 en V.
|
||||
gp_Vec2d T2v ; // derivee seconde a C2 en V.
|
||||
|
||||
curve2->D2(X,P2,T2,T2v);
|
||||
|
||||
Standard_Real NormT2 = T2.Magnitude();
|
||||
Standard_Real Ax = NormT2*t1.X() - T2.X();
|
||||
Standard_Real Ay = NormT2*t1.Y() - T2.Y();
|
||||
|
||||
F = (p1.X() - P2.X())*Ax + (p1.Y() - P2.Y())*Ay;
|
||||
|
||||
Standard_Real Scal = T2.Dot(T2v)/NormT2;
|
||||
Standard_Real dAx = Scal*t1.X() - T2v.X();
|
||||
Standard_Real dAy = Scal*t1.Y() - T2v.Y();
|
||||
|
||||
D = - T2.X()*Ax - T2.Y()*Ay + (p1.X() - P2.X())*dAx + (p1.Y() - P2.Y())*dAy;
|
||||
|
||||
|
||||
return Standard_True;
|
||||
|
||||
}
|
||||
|
54
src/Bisector/Bisector_FunctionInter.cdl
Executable file
54
src/Bisector/Bisector_FunctionInter.cdl
Executable file
@@ -0,0 +1,54 @@
|
||||
-- File: Bisector_FunctionInter.cdl
|
||||
-- Created: Tue Apr 5 14:05:05 1994
|
||||
-- Author: Yves FRICAUD
|
||||
-- <yfr@phylox>
|
||||
---Copyright: Matra Datavision 1994
|
||||
|
||||
|
||||
private class FunctionInter from Bisector
|
||||
inherits FunctionWithDerivative from math
|
||||
|
||||
---Purpose: 2 2
|
||||
-- F(u) = (PC(u) - PBis1(u)) + (PC(u) - PBis2(u))
|
||||
|
||||
uses
|
||||
Curve from Geom2d,
|
||||
Curve from Bisector
|
||||
--
|
||||
|
||||
is
|
||||
|
||||
Create returns FunctionInter from Bisector;
|
||||
|
||||
Create (C : Curve from Geom2d ;
|
||||
Bis1 : Curve from Bisector;
|
||||
Bis2 : Curve from Bisector)
|
||||
returns FunctionInter from Bisector;
|
||||
|
||||
Perform (me : in out;
|
||||
C : Curve from Geom2d ;
|
||||
Bis1 : Curve from Bisector;
|
||||
Bis2 : Curve from Bisector)
|
||||
is static;
|
||||
|
||||
Value(me : in out; X : Real; F : out Real)
|
||||
---Purpose: Computes the values of the Functions for the variable <X>.
|
||||
returns Boolean
|
||||
is static;
|
||||
|
||||
Derivative(me : in out; X : Real; D : out Real)
|
||||
returns Boolean;
|
||||
|
||||
Values(me : in out ; X : Real; F : out Real; D : out Real)
|
||||
---Purpose: Returns the values of the functions and the derivatives
|
||||
-- for the variable <X>.
|
||||
returns Boolean
|
||||
is static;
|
||||
|
||||
fields
|
||||
|
||||
curve : Curve from Geom2d;
|
||||
bisector1 : Curve from Bisector;
|
||||
bisector2 : Curve from Bisector;
|
||||
|
||||
end FunctionInter;
|
113
src/Bisector/Bisector_FunctionInter.cxx
Executable file
113
src/Bisector/Bisector_FunctionInter.cxx
Executable file
@@ -0,0 +1,113 @@
|
||||
// File: Bisector_FunctionInter.cxx
|
||||
// Created: Tue Apr 5 14:33:16 1994
|
||||
// Author: Yves FRICAUD
|
||||
// <yfr@phylox>
|
||||
|
||||
|
||||
#include <Bisector_FunctionInter.ixx>
|
||||
#include <Geom2d_Curve.hxx>
|
||||
#include <Bisector_BisecCC.hxx>
|
||||
#include <Bisector_BisecPC.hxx>
|
||||
#include <gp_Pnt2d.hxx>
|
||||
#include <gp_Vec2d.hxx>
|
||||
#include <gp.hxx>
|
||||
#include <Precision.hxx>
|
||||
|
||||
//=============================================================================
|
||||
//function :
|
||||
// purpose :
|
||||
//=============================================================================
|
||||
Bisector_FunctionInter::Bisector_FunctionInter ()
|
||||
{
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function :
|
||||
// purpose :
|
||||
//=============================================================================
|
||||
Bisector_FunctionInter::Bisector_FunctionInter (const Handle(Geom2d_Curve)& C ,
|
||||
const Handle(Bisector_Curve)& B1 ,
|
||||
const Handle(Bisector_Curve)& B2 )
|
||||
{
|
||||
curve = C;
|
||||
bisector1 = B1;
|
||||
bisector2 = B2;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function :
|
||||
// purpose :
|
||||
//=============================================================================
|
||||
void Bisector_FunctionInter::Perform (const Handle(Geom2d_Curve)& C ,
|
||||
const Handle(Bisector_Curve)& B1 ,
|
||||
const Handle(Bisector_Curve)& B2 )
|
||||
{
|
||||
curve = C;
|
||||
bisector1 = B1;
|
||||
bisector2 = B2;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
// function : Value
|
||||
// purpose :
|
||||
///=============================================================================
|
||||
Standard_Boolean Bisector_FunctionInter::Value (const Standard_Real X,
|
||||
Standard_Real& F)
|
||||
{
|
||||
gp_Pnt2d PC = curve ->Value(X);
|
||||
gp_Pnt2d PB1 = bisector1 ->Value(X);
|
||||
gp_Pnt2d PB2 = bisector2 ->Value(X);
|
||||
|
||||
F = PC.Distance(PB1) - PC.Distance(PB2);
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : Derivative
|
||||
// purpose :
|
||||
//=============================================================================
|
||||
Standard_Boolean Bisector_FunctionInter::Derivative(const Standard_Real X,
|
||||
Standard_Real& D)
|
||||
{
|
||||
Standard_Real F;
|
||||
return Values (X,F,D);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : Values
|
||||
// purpose :
|
||||
//=============================================================================
|
||||
Standard_Boolean Bisector_FunctionInter::Values (const Standard_Real X,
|
||||
Standard_Real& F,
|
||||
Standard_Real& D)
|
||||
{
|
||||
gp_Pnt2d PC, PB1, PB2;
|
||||
gp_Vec2d TC, TB1, TB2;
|
||||
Standard_Real F1, F2, DF1, DF2;
|
||||
|
||||
curve ->D1(X,PC ,TC);
|
||||
bisector1 ->D1(X,PB1,TB1);
|
||||
bisector2 ->D1(X,PB2,TB2);
|
||||
F1 = PC.Distance(PB1);
|
||||
F2 = PC.Distance(PB2);
|
||||
F = F1 - F2;
|
||||
if (Abs(F1) < gp::Resolution()) {
|
||||
DF1 = Precision::Infinite();
|
||||
}
|
||||
else {
|
||||
DF1 = ((PC.X() - PB1.X())*(TC.X() - TB1.X()) +
|
||||
(PC.Y() - PB1.Y())*(TC.Y() - TB1.Y()) )/F1;
|
||||
}
|
||||
if (Abs(F2) < gp::Resolution()) {
|
||||
DF2 = Precision::Infinite();
|
||||
}
|
||||
else {
|
||||
DF2 = ((PC.X() - PB2.X())*(TC.X() - TB2.X()) +
|
||||
(PC.Y() - PB2.Y())*(TC.Y() - TB2.Y()) )/F2;
|
||||
}
|
||||
D = DF1 - DF2;
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
80
src/Bisector/Bisector_Inter.cdl
Executable file
80
src/Bisector/Bisector_Inter.cdl
Executable file
@@ -0,0 +1,80 @@
|
||||
-- File: Bisector_Inter.cdl
|
||||
-- Created: Fri Jun 24 10:57:59 1994
|
||||
-- Author: Yves FRICAUD
|
||||
-- <yfr@phobox>
|
||||
---Copyright: Matra Datavision 1994
|
||||
|
||||
|
||||
class Inter from Bisector
|
||||
|
||||
---Purpose: Intersection between two <Bisec> from Bisector.
|
||||
|
||||
inherits
|
||||
Intersection from IntRes2d
|
||||
|
||||
uses
|
||||
Domain from IntRes2d,
|
||||
Bisec from Bisector,
|
||||
Curve from Bisector,
|
||||
BisecCC from Bisector,
|
||||
Curve from Geom2d,
|
||||
Line from Geom2d
|
||||
|
||||
raises ConstructionError from Standard
|
||||
|
||||
is
|
||||
Create returns Inter from Bisector;
|
||||
|
||||
Create (C1: Bisec from Bisector; D1: Domain from IntRes2d;
|
||||
C2: Bisec from Bisector; D2: Domain from IntRes2d;
|
||||
TolConf,Tol : Real from Standard;
|
||||
ComunElement : Boolean from Standard)
|
||||
---Purpose: Intersection between 2 curves.
|
||||
-- C1 separates the element A and B.
|
||||
-- C2 separates the elements C et D.
|
||||
-- If B an C have the same geometry. <ComunElement>
|
||||
-- Has to be True.
|
||||
-- It Permits an optimiztion of the computation.
|
||||
|
||||
returns Inter from Bisector
|
||||
raises ConstructionError from Standard;
|
||||
|
||||
|
||||
Perform (me: in out;
|
||||
C1: Bisec from Bisector; D1: Domain from IntRes2d;
|
||||
C2: Bisec from Bisector; D2: Domain from IntRes2d;
|
||||
TolConf,Tol : Real from Standard;
|
||||
ComunElement : Boolean from Standard)
|
||||
---Purpose: Intersection between 2 curves.
|
||||
-- C1 separates the element A and B.
|
||||
-- C2 separates the elements C et D.
|
||||
-- If B an C have the same geometry. <ComunElement>
|
||||
-- Has to be True.
|
||||
-- It Permits an optimiztion of the computation.
|
||||
|
||||
raises ConstructionError from Standard
|
||||
is static;
|
||||
|
||||
SinglePerform (me: in out;
|
||||
C1: Curve from Geom2d ; D1: Domain from IntRes2d;
|
||||
C2: Curve from Geom2d ; D2: Domain from IntRes2d;
|
||||
TolConf,Tol : Real from Standard;
|
||||
ComunElement : Boolean from Standard)
|
||||
---Purpose: Intersection between 2 curves.
|
||||
|
||||
raises ConstructionError from Standard
|
||||
is static private;
|
||||
|
||||
NeighbourPerform (me : in out;
|
||||
C1 : BisecCC from Bisector; D1: Domain from IntRes2d;
|
||||
C2 : BisecCC from Bisector; D2: Domain from IntRes2d;
|
||||
Tol: Real from Standard)
|
||||
is static private;
|
||||
|
||||
TestBound (me : in out;
|
||||
C1 : Line from Geom2d ; D1 : Domain from IntRes2d;
|
||||
C2 : Curve from Geom2d ; D2 : Domain from IntRes2d;
|
||||
Tol: Real from Standard; Reverse : Boolean from Standard)
|
||||
is static private;
|
||||
|
||||
end Inter;
|
429
src/Bisector/Bisector_Inter.cxx
Executable file
429
src/Bisector/Bisector_Inter.cxx
Executable file
@@ -0,0 +1,429 @@
|
||||
// File: Bisector_Inter.cxx
|
||||
// Created: Fri Jun 24 11:38:47 1994
|
||||
// Author: Yves FRICAUD
|
||||
// <yfr@phobox>
|
||||
|
||||
// Modified by skv - Mon May 5 15:06:39 2003 OCC616
|
||||
|
||||
#include <Bisector_Inter.ixx>
|
||||
#include <IntRes2d_Intersection.hxx>
|
||||
#include <Bisector_Curve.hxx>
|
||||
#include <Bisector_BisecAna.hxx>
|
||||
#include <Bisector_BisecCC.hxx>
|
||||
#include <Bisector_BisecPC.hxx>
|
||||
#include <Bisector_FunctionInter.hxx>
|
||||
#include <Geom2dInt_GInter.hxx>
|
||||
#include <Geom2d_TrimmedCurve.hxx>
|
||||
#include <Geom2dAdaptor_Curve.hxx>
|
||||
#include <Geom2d_Curve.hxx>
|
||||
#include <Geom2d_Line.hxx>
|
||||
#include <IntRes2d_Transition.hxx>
|
||||
#include <IntRes2d_IntersectionPoint.hxx>
|
||||
#include <Precision.hxx>
|
||||
#include <math_BissecNewton.hxx>
|
||||
#include <ElCLib.hxx>
|
||||
|
||||
#ifdef DRAW
|
||||
#include <Draw_Appli.hxx>
|
||||
#include <DrawTrSurf_Curve2d.hxx>
|
||||
#include <Draw_Marker2D.hxx>
|
||||
#endif
|
||||
#ifdef DEB
|
||||
static Standard_Boolean Affich = Standard_False;
|
||||
#endif
|
||||
|
||||
//===================================================================================
|
||||
// function :
|
||||
// putpose :
|
||||
//===================================================================================
|
||||
Bisector_Inter::Bisector_Inter()
|
||||
{
|
||||
}
|
||||
|
||||
//===================================================================================
|
||||
// function :
|
||||
// putpose :
|
||||
//===================================================================================
|
||||
Bisector_Inter::Bisector_Inter(const Bisector_Bisec& C1,
|
||||
const IntRes2d_Domain& D1,
|
||||
const Bisector_Bisec& C2,
|
||||
const IntRes2d_Domain& D2,
|
||||
const Standard_Real TolConf,
|
||||
const Standard_Real Tol,
|
||||
const Standard_Boolean ComunElement)
|
||||
{
|
||||
Perform (C1,D1,C2,D2,TolConf,Tol,ComunElement);
|
||||
}
|
||||
|
||||
//===================================================================================
|
||||
// function : ConstructSegment
|
||||
// putpose :
|
||||
//===================================================================================
|
||||
static Handle(Geom2d_Line) ConstructSegment(const gp_Pnt2d& PMin,
|
||||
const gp_Pnt2d& PMax,
|
||||
const Standard_Real UMin,
|
||||
// const Standard_Real UMax)
|
||||
const Standard_Real )
|
||||
{
|
||||
gp_Dir2d Dir(PMax.X() - PMin.X(),PMax.Y() - PMin.Y());
|
||||
Handle(Geom2d_Line) L = new Geom2d_Line (gp_Pnt2d(PMin.X() - UMin*Dir.X(),
|
||||
PMin.Y() - UMin*Dir.Y()),Dir);
|
||||
return L;
|
||||
}
|
||||
|
||||
//===================================================================================
|
||||
// function : Perform
|
||||
// putpose :
|
||||
//===================================================================================
|
||||
void Bisector_Inter::Perform(const Bisector_Bisec& C1,
|
||||
const IntRes2d_Domain& D1,
|
||||
const Bisector_Bisec& C2,
|
||||
const IntRes2d_Domain& D2,
|
||||
const Standard_Real TolConf,
|
||||
const Standard_Real Tol,
|
||||
const Standard_Boolean ComunElement)
|
||||
{
|
||||
Handle(Bisector_Curve) Bis1 = Handle(Bisector_Curve)::DownCast( C1.Value()->BasisCurve());
|
||||
Handle(Bisector_Curve) Bis2 = Handle(Bisector_Curve)::DownCast( C2.Value()->BasisCurve());
|
||||
|
||||
Handle(Geom2d_Curve)* SBis1 = new Handle(Geom2d_Curve) [Bis1->NbIntervals()+1];
|
||||
Handle(Geom2d_Curve)* SBis2 = new Handle(Geom2d_Curve) [Bis2->NbIntervals()+1];
|
||||
IntRes2d_Domain* SD1 = new IntRes2d_Domain [Bis1->NbIntervals()+1];
|
||||
IntRes2d_Domain* SD2 = new IntRes2d_Domain [Bis2->NbIntervals()+1];
|
||||
|
||||
Standard_Integer NB1 = 0; Standard_Integer NB2 = 0;
|
||||
Standard_Real MinDomain,MaxDomain;
|
||||
Standard_Real UMin,UMax;
|
||||
gp_Pnt2d PMin,PMax;
|
||||
|
||||
//------------------------------------------------------
|
||||
// Recuperation Min Max domain1.
|
||||
//------------------------------------------------------
|
||||
if (D1.HasFirstPoint()) {MinDomain = D1.FirstParameter();}
|
||||
else {MinDomain = RealFirst(); }
|
||||
|
||||
if (D1.HasLastPoint()) {MaxDomain = D1.LastParameter();}
|
||||
else {MaxDomain = RealLast(); }
|
||||
|
||||
//----------------------------------------------------------
|
||||
// Decoupage de la premiere courbe selon les intervalles de
|
||||
// continuite en tenant compte de D1
|
||||
//----------------------------------------------------------
|
||||
//for (Standard_Integer IB1 = 1; IB1 <= Bis1->NbIntervals(); IB1++) {
|
||||
Standard_Integer IB1;
|
||||
for ( IB1 = 1; IB1 <= Bis1->NbIntervals(); IB1++) {
|
||||
UMin = Bis1->IntervalFirst(IB1);
|
||||
UMax = Bis1->IntervalLast (IB1);
|
||||
if (UMax > MinDomain && UMin < MaxDomain) {
|
||||
UMin = Max (UMin,MinDomain);
|
||||
UMax = Min (UMax,MaxDomain);
|
||||
PMin = Bis1->Value(UMin);
|
||||
PMax = Bis1->Value(UMax);
|
||||
SD1 [IB1].SetValues(PMin,UMin,D1.FirstTolerance(),
|
||||
PMax,UMax,D1.LastTolerance());
|
||||
|
||||
if ((IB1 == 1 && Bis1->IsExtendAtStart()) ||
|
||||
(IB1 == Bis1->NbIntervals() && Bis1->IsExtendAtEnd()) ){
|
||||
//--------------------------------------------------------
|
||||
// Portion correspondante a une extension est un segment.
|
||||
//--------------------------------------------------------
|
||||
SBis1 [IB1] = ConstructSegment (PMin,PMax,UMin,UMax);
|
||||
}
|
||||
else {
|
||||
SBis1 [IB1] = Bis1;
|
||||
}
|
||||
NB1++;
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------
|
||||
// Recuperation Min Max domain2.
|
||||
//------------------------------------------------------
|
||||
if (D2.HasFirstPoint()) {MinDomain = D2.FirstParameter();}
|
||||
else {MinDomain = RealFirst(); }
|
||||
|
||||
if (D2.HasLastPoint()) {MaxDomain = D2.LastParameter();}
|
||||
else {MaxDomain = RealLast(); }
|
||||
|
||||
//----------------------------------------------------------
|
||||
// Decoupage de la deuxieme courbe selon les intervalles de
|
||||
// continuite en tenant compte de D2
|
||||
//----------------------------------------------------------
|
||||
//for (Standard_Integer IB2 = 1; IB2 <= Bis2->NbIntervals(); IB2++) {
|
||||
Standard_Integer IB2;
|
||||
for ( IB2 = 1; IB2 <= Bis2->NbIntervals(); IB2++) {
|
||||
UMin = Bis2->IntervalFirst(IB2);
|
||||
UMax = Bis2->IntervalLast (IB2);
|
||||
if (UMax > MinDomain && UMin < MaxDomain) {
|
||||
UMin = Max (UMin,MinDomain);
|
||||
UMax = Min (UMax,MaxDomain);
|
||||
PMin = Bis2->Value(UMin);
|
||||
PMax = Bis2->Value(UMax);
|
||||
SD2 [IB2].SetValues(PMin,UMin,D2.FirstTolerance(),
|
||||
PMax,UMax,D2.LastTolerance());
|
||||
|
||||
if ((IB2 == 1 && Bis2->IsExtendAtStart()) ||
|
||||
(IB2 == Bis1->NbIntervals() && Bis2->IsExtendAtEnd()) ){
|
||||
//--------------------------------------------------------
|
||||
// Portion correspondante a une extension est un segment.
|
||||
//--------------------------------------------------------
|
||||
SBis2 [IB2] = ConstructSegment (PMin,PMax,UMin,UMax);
|
||||
}
|
||||
else {
|
||||
SBis2 [IB2] = Bis2;
|
||||
}
|
||||
NB2++;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
// Boucle sur les intersections des portions de chaque courbe.
|
||||
//--------------------------------------------------------------
|
||||
for ( IB1 = 1; IB1 <= NB1; IB1++) {
|
||||
for ( IB2 = 1; IB2 <= NB2; IB2++) {
|
||||
SinglePerform(SBis1[IB1],SD1[IB1],
|
||||
SBis2[IB2],SD2[IB2],TolConf,Tol,ComunElement);
|
||||
}
|
||||
}
|
||||
delete [] SBis1;
|
||||
delete [] SBis2;
|
||||
delete [] SD1;
|
||||
delete [] SD2;
|
||||
}
|
||||
|
||||
//===================================================================================
|
||||
// function : SinglePerform
|
||||
// putpose :
|
||||
//===================================================================================
|
||||
void Bisector_Inter::SinglePerform(const Handle(Geom2d_Curve)& CBis1,
|
||||
const IntRes2d_Domain& D1,
|
||||
const Handle(Geom2d_Curve)& CBis2,
|
||||
const IntRes2d_Domain& D2,
|
||||
const Standard_Real TolConf,
|
||||
const Standard_Real Tol,
|
||||
const Standard_Boolean ComunElement)
|
||||
{
|
||||
Handle(Geom2d_Curve) Bis1 = CBis1;
|
||||
Handle(Geom2d_Curve) Bis2 = CBis2;
|
||||
|
||||
Handle(Standard_Type) Type1 = Bis1->DynamicType();
|
||||
Handle(Standard_Type) Type2 = Bis2->DynamicType();
|
||||
|
||||
if (Type1 == STANDARD_TYPE(Bisector_BisecAna) || Type2 == STANDARD_TYPE(Bisector_BisecAna)) {
|
||||
Handle(Geom2d_Curve) C2Bis1,C2Bis2;
|
||||
if (Type1 == STANDARD_TYPE(Bisector_BisecAna)) {
|
||||
C2Bis1 = Handle(Bisector_BisecAna)::DownCast(Bis1)->Geom2dCurve();
|
||||
}
|
||||
else {
|
||||
C2Bis1 = Bis1;
|
||||
}
|
||||
if (Type2 == STANDARD_TYPE(Bisector_BisecAna)) {
|
||||
C2Bis2 = Handle(Bisector_BisecAna)::DownCast(Bis2)->Geom2dCurve();
|
||||
}
|
||||
else {
|
||||
C2Bis2 = Bis2;
|
||||
}
|
||||
Type1 = C2Bis1->DynamicType();
|
||||
Type2 = C2Bis2->DynamicType();
|
||||
if (Type1 == STANDARD_TYPE(Geom2d_Line) && Type2 != STANDARD_TYPE(Geom2d_Line)) {
|
||||
TestBound(Handle(Geom2d_Line)::DownCast(C2Bis1),
|
||||
D1,C2Bis2,D2,TolConf,Standard_False);
|
||||
}
|
||||
else if (Type2 == STANDARD_TYPE(Geom2d_Line)&& Type1 != STANDARD_TYPE(Geom2d_Line)) {
|
||||
TestBound(Handle(Geom2d_Line)::DownCast(C2Bis2),
|
||||
D2,C2Bis1,D1,TolConf,Standard_True);
|
||||
}
|
||||
Geom2dInt_GInter Intersect;
|
||||
Geom2dAdaptor_Curve AC2Bis1(C2Bis1);
|
||||
Geom2dAdaptor_Curve AC2Bis2(C2Bis2);
|
||||
Intersect.Perform(AC2Bis1,D1,AC2Bis2,D2,TolConf,Tol);
|
||||
Append (Intersect,D1.FirstParameter(),D1.LastParameter(),
|
||||
D2.FirstParameter(),D2.LastParameter());
|
||||
}
|
||||
else if (Type1 == STANDARD_TYPE(Bisector_BisecPC) || Type2 == STANDARD_TYPE(Bisector_BisecPC)) {
|
||||
Geom2dInt_GInter Intersect;
|
||||
Geom2dAdaptor_Curve ABis1(Bis1);
|
||||
Geom2dAdaptor_Curve ABis2(Bis2);
|
||||
Intersect.Perform(ABis1,D1,ABis2,D2,TolConf,Tol);
|
||||
Append (Intersect,D1.FirstParameter(),D1.LastParameter(),
|
||||
D2.FirstParameter(),D2.LastParameter());
|
||||
}
|
||||
else if (ComunElement &&
|
||||
Type1 == STANDARD_TYPE(Bisector_BisecCC) && Type2 == STANDARD_TYPE(Bisector_BisecCC)) {
|
||||
NeighbourPerform(Handle(Bisector_BisecCC)::DownCast(Bis1),D1,
|
||||
Handle(Bisector_BisecCC)::DownCast(Bis2),D2,Tol);
|
||||
}
|
||||
else {
|
||||
// Si on arrive la une des deux bissectrices est un segment.
|
||||
// Si une des bissectrice n est pas un segment on teste si
|
||||
// ses extremites sont sur la droite
|
||||
|
||||
if (Type1 == STANDARD_TYPE(Geom2d_Line) && Type2 != STANDARD_TYPE(Geom2d_Line)) {
|
||||
TestBound(Handle(Geom2d_Line)::DownCast(Bis1),
|
||||
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);
|
||||
}
|
||||
Geom2dInt_GInter Intersect;
|
||||
Geom2dAdaptor_Curve ABis1(Bis1);
|
||||
Geom2dAdaptor_Curve ABis2(Bis2);
|
||||
Intersect.Perform(ABis1,D1,ABis2,D2,TolConf,Tol);
|
||||
Append (Intersect,D1.FirstParameter(),D1.LastParameter(),
|
||||
D2.FirstParameter(),D2.LastParameter());
|
||||
}
|
||||
|
||||
#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()) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
dout.Flush();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
//===================================================================================
|
||||
// function : NeighbourPerform
|
||||
// putpose : Recherche de l intersection de 2 bissectrices courbe/courbe
|
||||
// Voisines (ie Bis1 separe A et B et Bis2 separe B et C).
|
||||
// Bis1 est parametree par B et Bis2 par C.
|
||||
//
|
||||
// Methode : On parametre Bis2 par B
|
||||
// les 2 bissectrices sont alors parametree par la meme
|
||||
// courbe.
|
||||
// Soientt D1(u) = d(Bis1(u),B(u)) et D2(U) = d(Bis2(u),B(U))
|
||||
// On cherche le parametre U0 pour lequel D1(U0)-D2(U0) = 0.
|
||||
//===================================================================================
|
||||
void Bisector_Inter::NeighbourPerform(const Handle(Bisector_BisecCC)& Bis1,
|
||||
const IntRes2d_Domain& D1,
|
||||
const Handle(Bisector_BisecCC)& Bis2,
|
||||
const IntRes2d_Domain& D2,
|
||||
const Standard_Real Tol)
|
||||
{
|
||||
Standard_Real USol,U1,U2,Dist;
|
||||
#ifndef DEB
|
||||
Standard_Real UMin =0.,UMax =0.;
|
||||
#else
|
||||
Standard_Real UMin,UMax;
|
||||
#endif
|
||||
Standard_Real Eps = Precision::PConfusion();
|
||||
gp_Pnt2d PSol;
|
||||
|
||||
Handle(Geom2d_Curve) Guide;
|
||||
Handle(Bisector_BisecCC) BisTemp;
|
||||
|
||||
// Changement ligne guide sur Bis2.
|
||||
BisTemp = Bis2->ChangeGuide();
|
||||
Guide = Bis2->Curve(2);
|
||||
#ifdef DEB
|
||||
gp_Pnt2d P2S = Bis2->ValueAndDist(D2.FirstParameter(),U1,UMax,Dist);
|
||||
gp_Pnt2d P2E = Bis2->ValueAndDist(D2.LastParameter() ,U1,UMin,Dist);
|
||||
#else
|
||||
Bis2->ValueAndDist(D2.FirstParameter(),U1,UMax,Dist);
|
||||
Bis2->ValueAndDist(D2.LastParameter() ,U1,UMin,Dist);
|
||||
#endif
|
||||
// Calcul du domaine d intersection sur la ligne guide.
|
||||
UMin = Max (D1.FirstParameter(),UMin);
|
||||
UMax = Min (D1.LastParameter() ,UMax);
|
||||
|
||||
done = Standard_True;
|
||||
|
||||
if (UMin - Eps > UMax + Eps) {return;}
|
||||
|
||||
// Resolution F = 0 pour trouver le point commun.
|
||||
Bisector_FunctionInter Fint (Guide,Bis1,BisTemp);
|
||||
math_BissecNewton Sol (Fint,UMin,UMax,Tol,20);
|
||||
if (Sol.IsDone()) {
|
||||
USol = Sol.Root();
|
||||
}
|
||||
else { return; }
|
||||
|
||||
PSol = BisTemp ->ValueAndDist(USol,U1,U2,Dist);
|
||||
|
||||
IntRes2d_Transition Trans1,Trans2;
|
||||
IntRes2d_IntersectionPoint PointInterSol(PSol,USol,U2,
|
||||
Trans1,Trans2,Standard_False);
|
||||
Append (PointInterSol);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//===================================================================================
|
||||
// function : TestBound
|
||||
// putpose : Test si les extremites de Bis2 sont sur le segment coorespondant
|
||||
// a Bis1.
|
||||
//===================================================================================
|
||||
void Bisector_Inter::TestBound (const Handle(Geom2d_Line)& Bis1,
|
||||
const IntRes2d_Domain& D1,
|
||||
const Handle(Geom2d_Curve)& Bis2,
|
||||
const IntRes2d_Domain& D2,
|
||||
const Standard_Real TolConf,
|
||||
const Standard_Boolean Reverse)
|
||||
{
|
||||
IntRes2d_Transition Trans1,Trans2;
|
||||
IntRes2d_IntersectionPoint PointInterSol;
|
||||
|
||||
gp_Lin2d L1 = Bis1->Lin2d();
|
||||
gp_Pnt2d PF = Bis2->Value(D2.FirstParameter());
|
||||
gp_Pnt2d PL = Bis2->Value(D2.LastParameter());
|
||||
// Modified by skv - Mon May 5 14:43:28 2003 OCC616 Begin
|
||||
// Standard_Real Tol = Min(TolConf,Precision::Confusion());
|
||||
// Tol = 10*Tol;
|
||||
Standard_Real Tol = TolConf;
|
||||
// Modified by skv - Mon May 5 14:43:30 2003 OCC616 End
|
||||
|
||||
Standard_Boolean BisecAlgo = Standard_False;
|
||||
if (Bis2->DynamicType() == STANDARD_TYPE(Bisector_BisecCC))
|
||||
{
|
||||
BisecAlgo = Standard_True;
|
||||
// Modified by skv - Mon May 5 14:43:45 2003 OCC616 Begin
|
||||
// Tol = 1.e-5;
|
||||
// Modified by skv - Mon May 5 14:43:46 2003 OCC616 End
|
||||
}
|
||||
|
||||
if (L1.Distance(PF) < Tol) {
|
||||
Standard_Real U1 = ElCLib::Parameter(L1,PF);
|
||||
// Modified by skv - Mon May 5 14:48:12 2003 OCC616 Begin
|
||||
// if ( D1.FirstParameter() - Tol <= U1 &&
|
||||
// D1.LastParameter () + Tol >= U1 ) {
|
||||
if ( D1.FirstParameter() - D1.FirstTolerance() < U1 &&
|
||||
D1.LastParameter () + D1.LastTolerance() > U1 ) {
|
||||
// Modified by skv - Mon May 5 14:48:14 2003 OCC616 End
|
||||
// PF est sur L1
|
||||
if (BisecAlgo)
|
||||
PF = ElCLib::Value( U1 , L1 );
|
||||
PointInterSol.SetValues (PF, U1, D2.FirstParameter(),
|
||||
Trans1, Trans2, Reverse);
|
||||
Append (PointInterSol);
|
||||
}
|
||||
}
|
||||
|
||||
if (L1.Distance(PL) < Tol) {
|
||||
Standard_Real U1 = ElCLib::Parameter(L1,PL);
|
||||
// Modified by skv - Mon May 5 15:05:48 2003 OCC616 Begin
|
||||
// if ( D1.FirstParameter() - Tol <= U1 &&
|
||||
// D1.LastParameter () + Tol >= U1 ) {
|
||||
if ( D1.FirstParameter() - D1.FirstTolerance() < U1 &&
|
||||
D1.LastParameter () + D1.LastTolerance() > U1 ) {
|
||||
// Modified by skv - Mon May 5 15:05:49 2003 OCC616 End
|
||||
if (BisecAlgo)
|
||||
PL = ElCLib::Value( U1 , L1 );
|
||||
PointInterSol.SetValues (PL, U1, D2.LastParameter(),
|
||||
Trans1, Trans2, Reverse);
|
||||
Append (PointInterSol);
|
||||
}
|
||||
}
|
||||
}
|
68
src/Bisector/Bisector_PointOnBis.cdl
Executable file
68
src/Bisector/Bisector_PointOnBis.cdl
Executable file
@@ -0,0 +1,68 @@
|
||||
-- File: Bisector_PointOnBis.cdl
|
||||
-- Created: Mon Jan 10 16:23:20 1994
|
||||
-- Author: Yves FRICAUD
|
||||
-- <yfr@phylox>
|
||||
---Copyright: Matra Datavision 1994
|
||||
|
||||
|
||||
class PointOnBis from Bisector
|
||||
|
||||
---Purpose:
|
||||
|
||||
uses
|
||||
Pnt2d from gp
|
||||
|
||||
is
|
||||
Create returns PointOnBis from Bisector;
|
||||
|
||||
Create ( Param1, Param2, ParamBis, Distance : Real; Point : Pnt2d)
|
||||
returns PointOnBis from Bisector;
|
||||
|
||||
ParamOnC1 (me : in out; Param : Real)
|
||||
is static;
|
||||
|
||||
ParamOnC2 (me : in out; Param : Real)
|
||||
is static;
|
||||
|
||||
ParamOnBis (me : in out; Param : Real)
|
||||
is static;
|
||||
|
||||
Distance (me : in out; Distance : Real)
|
||||
is static;
|
||||
|
||||
IsInfinite (me : in out; Infinite : Boolean)
|
||||
is static;
|
||||
|
||||
Point (me : in out ; P :Pnt2d)
|
||||
is static;
|
||||
|
||||
ParamOnC1 (me) returns Real
|
||||
is static;
|
||||
|
||||
ParamOnC2 (me) returns Real
|
||||
is static;
|
||||
|
||||
ParamOnBis (me) returns Real
|
||||
is static;
|
||||
|
||||
Distance (me) returns Real
|
||||
is static;
|
||||
|
||||
Point (me) returns Pnt2d
|
||||
is static;
|
||||
|
||||
IsInfinite (me) returns Boolean
|
||||
is static;
|
||||
|
||||
Dump (me) is static;
|
||||
|
||||
fields
|
||||
|
||||
param1 : Real;
|
||||
param2 : Real;
|
||||
paramBis : Real;
|
||||
distance : Real;
|
||||
infinite : Boolean;
|
||||
point : Pnt2d from gp;
|
||||
|
||||
end PointOnBis;
|
153
src/Bisector/Bisector_PointOnBis.cxx
Executable file
153
src/Bisector/Bisector_PointOnBis.cxx
Executable file
@@ -0,0 +1,153 @@
|
||||
// File: Bisector_PointOnBis.cxx
|
||||
// Created: Mon Jan 10 17:06:47 1994
|
||||
// Author: Yves FRICAUD
|
||||
// <yfr@phylox>
|
||||
|
||||
#include <Bisector_PointOnBis.ixx>
|
||||
|
||||
|
||||
//=============================================================================
|
||||
//function :
|
||||
// purpose :
|
||||
//=============================================================================
|
||||
Bisector_PointOnBis::Bisector_PointOnBis()
|
||||
{
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function :
|
||||
// purpose :
|
||||
//=============================================================================
|
||||
Bisector_PointOnBis::Bisector_PointOnBis(const Standard_Real Param1,
|
||||
const Standard_Real Param2,
|
||||
const Standard_Real ParamBis,
|
||||
const Standard_Real Distance,
|
||||
const gp_Pnt2d& P)
|
||||
: param1 (Param1),
|
||||
param2 (Param2),
|
||||
paramBis (ParamBis),
|
||||
distance (Distance),
|
||||
point (P)
|
||||
{
|
||||
infinite = Standard_False;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : ParamOnC1
|
||||
// purpose :
|
||||
//=============================================================================
|
||||
void Bisector_PointOnBis::ParamOnC1(const Standard_Real Param)
|
||||
{
|
||||
param1 = Param;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : ParamOnC2
|
||||
// purpose :
|
||||
//=============================================================================
|
||||
void Bisector_PointOnBis::ParamOnC2(const Standard_Real Param)
|
||||
{
|
||||
param2 = Param;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : ParamOnBis
|
||||
// purpose :
|
||||
//=============================================================================
|
||||
void Bisector_PointOnBis::ParamOnBis(const Standard_Real Param)
|
||||
{
|
||||
paramBis = Param;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : Distance
|
||||
// purpose :
|
||||
//=============================================================================
|
||||
void Bisector_PointOnBis::Distance(const Standard_Real Distance)
|
||||
{
|
||||
distance = Distance;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : Point
|
||||
// purpose :
|
||||
//=============================================================================
|
||||
void Bisector_PointOnBis::Point (const gp_Pnt2d& P)
|
||||
{
|
||||
point = P;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : IsInfinite
|
||||
// purpose :
|
||||
//=============================================================================
|
||||
void Bisector_PointOnBis::IsInfinite(const Standard_Boolean Infinite)
|
||||
{
|
||||
infinite = Infinite;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : ParamOnC1
|
||||
// purpose :
|
||||
//=============================================================================
|
||||
Standard_Real Bisector_PointOnBis::ParamOnC1()const
|
||||
{
|
||||
return param1;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : ParamOnC2
|
||||
// purpose :
|
||||
//=============================================================================
|
||||
Standard_Real Bisector_PointOnBis::ParamOnC2()const
|
||||
{
|
||||
return param2;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : ParamOnBis
|
||||
// purpose :
|
||||
//=============================================================================
|
||||
Standard_Real Bisector_PointOnBis::ParamOnBis()const
|
||||
{
|
||||
return paramBis;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : Distance
|
||||
// purpose :
|
||||
//=============================================================================
|
||||
Standard_Real Bisector_PointOnBis::Distance()const
|
||||
{
|
||||
return distance;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : Point
|
||||
// purpose :
|
||||
//=============================================================================
|
||||
gp_Pnt2d Bisector_PointOnBis::Point ()const
|
||||
{
|
||||
return point;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : IsInfinite
|
||||
// purpose :
|
||||
//=============================================================================
|
||||
Standard_Boolean Bisector_PointOnBis::IsInfinite() const
|
||||
{
|
||||
return infinite;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : Dump
|
||||
// purpose :
|
||||
//=============================================================================
|
||||
void Bisector_PointOnBis::Dump() const
|
||||
{
|
||||
cout <<"Param1 :"<<param1<<endl;
|
||||
cout <<"Param2 :"<<param2<<endl;
|
||||
cout <<"Param Bis :"<<paramBis<<endl;
|
||||
cout <<"Distance :"<<distance<<endl;
|
||||
}
|
51
src/Bisector/Bisector_PolyBis.cdl
Executable file
51
src/Bisector/Bisector_PolyBis.cdl
Executable file
@@ -0,0 +1,51 @@
|
||||
-- File: Bisector_PolyBis.cdl
|
||||
-- Created: Fri Apr 1 16:10:52 1994
|
||||
-- Author: Yves FRICAUD
|
||||
-- <yfr@phylox>
|
||||
---Copyright: Matra Datavision 1994
|
||||
|
||||
class PolyBis from Bisector
|
||||
|
||||
---Purpose: Polygon of PointOnBis
|
||||
|
||||
uses
|
||||
PointOnBis from Bisector,
|
||||
Trsf2d from gp
|
||||
|
||||
is
|
||||
Create returns PolyBis from Bisector;
|
||||
|
||||
Append ( me : in out; Point : PointOnBis from Bisector)
|
||||
is static ;
|
||||
|
||||
Length (me) returns Integer
|
||||
is static ;
|
||||
|
||||
IsEmpty (me) returns Boolean
|
||||
is static;
|
||||
|
||||
Value (me ; Index : Integer) returns PointOnBis from Bisector
|
||||
---C++: return const&
|
||||
is static;
|
||||
|
||||
First (me) returns PointOnBis from Bisector
|
||||
---C++: return const&
|
||||
is static;
|
||||
|
||||
Last (me) returns PointOnBis from Bisector
|
||||
---C++: return const&
|
||||
is static;
|
||||
|
||||
Interval (me ; U :Real) returns Integer from Standard
|
||||
is static;
|
||||
|
||||
Transform (me : in out ; T :Trsf2d)
|
||||
is static;
|
||||
|
||||
fields
|
||||
|
||||
thePoints : PointOnBis from Bisector [30];
|
||||
nbPoints : Integer from Standard;
|
||||
|
||||
end PolyBis;
|
||||
|
136
src/Bisector/Bisector_PolyBis.cxx
Executable file
136
src/Bisector/Bisector_PolyBis.cxx
Executable file
@@ -0,0 +1,136 @@
|
||||
// File: Bisector_PolyBis.cxx
|
||||
// Created: Mon Jan 10 17:06:47 1994
|
||||
// Author: Yves FRICAUD
|
||||
// <yfr@phylox>
|
||||
|
||||
#include <Bisector_PolyBis.ixx>
|
||||
#include <Bisector_PointOnBis.hxx>
|
||||
#include <Geom2d_Curve.hxx>
|
||||
#include <ElCLib.hxx>
|
||||
#include <gp.hxx>
|
||||
|
||||
#include <Standard_ConstructionError.hxx>
|
||||
|
||||
//=============================================================================
|
||||
//function : Bisector_PolyBis
|
||||
// purpose :
|
||||
//=============================================================================
|
||||
Bisector_PolyBis::Bisector_PolyBis()
|
||||
{
|
||||
nbPoints = 0;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : Append
|
||||
// purpose :
|
||||
//=============================================================================
|
||||
void Bisector_PolyBis::Append (const Bisector_PointOnBis& P)
|
||||
{
|
||||
nbPoints++;
|
||||
thePoints [nbPoints] = P;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : Length
|
||||
// purpose :
|
||||
//=============================================================================
|
||||
Standard_Integer Bisector_PolyBis::Length() const
|
||||
{
|
||||
return nbPoints;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : IsEmpty
|
||||
// purpose :
|
||||
//=============================================================================
|
||||
Standard_Boolean Bisector_PolyBis::IsEmpty() const
|
||||
{
|
||||
return (nbPoints == 0);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : Value
|
||||
// purpose :
|
||||
//=============================================================================
|
||||
const Bisector_PointOnBis& Bisector_PolyBis::Value
|
||||
(const Standard_Integer Index)
|
||||
const
|
||||
{
|
||||
return thePoints [Index];
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : First
|
||||
// purpose :
|
||||
//=============================================================================
|
||||
const Bisector_PointOnBis& Bisector_PolyBis::First() const
|
||||
{
|
||||
return thePoints[1];
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : Last
|
||||
// purpose :
|
||||
//=============================================================================
|
||||
const Bisector_PointOnBis& Bisector_PolyBis::Last() const
|
||||
{
|
||||
return thePoints[nbPoints];
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : Points
|
||||
// purpose :
|
||||
//=============================================================================
|
||||
//const PointOnBis& Bisector_PolyBis::Points()
|
||||
//{
|
||||
// return thePoints;
|
||||
//}
|
||||
|
||||
//=============================================================================
|
||||
//function : Interval
|
||||
// purpose :
|
||||
//=============================================================================
|
||||
Standard_Integer Bisector_PolyBis::Interval (const Standard_Real U) const
|
||||
{
|
||||
if ( Last().ParamOnBis() - U < gp::Resolution()) {
|
||||
return nbPoints - 1;
|
||||
}
|
||||
Standard_Real dU = (Last().ParamOnBis() - First().ParamOnBis())/(nbPoints - 1);
|
||||
if (dU <= gp::Resolution()) return 1;
|
||||
|
||||
Standard_Integer IntU = Standard_Integer(Abs(U - First().ParamOnBis())/dU) ;
|
||||
IntU++;
|
||||
|
||||
if (thePoints[IntU].ParamOnBis() >= U) {
|
||||
for (Standard_Integer i = IntU; i >= 1; i--) {
|
||||
if (thePoints[i].ParamOnBis() <= U) {
|
||||
IntU = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (Standard_Integer i = IntU; i <= nbPoints - 1; i++) {
|
||||
if (thePoints[i].ParamOnBis() >= U) {
|
||||
IntU = i - 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return IntU;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Transform
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Bisector_PolyBis::Transform(const gp_Trsf2d& T)
|
||||
{
|
||||
for (Standard_Integer i = 1; i <= nbPoints; i ++) {
|
||||
gp_Pnt2d P = thePoints[i].Point();
|
||||
P.Transform(T) ;
|
||||
thePoints[i].Point(P);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user