mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
Integration of OCCT 6.5.0 from SVN
This commit is contained in:
10
src/IntAna2d/FILES
Executable file
10
src/IntAna2d/FILES
Executable file
@@ -0,0 +1,10 @@
|
||||
IntAna2d_AnaIntersection_1.cxx
|
||||
IntAna2d_AnaIntersection_2.cxx
|
||||
IntAna2d_AnaIntersection_3.cxx
|
||||
IntAna2d_AnaIntersection_4.cxx
|
||||
IntAna2d_AnaIntersection_5.cxx
|
||||
IntAna2d_AnaIntersection_6.cxx
|
||||
IntAna2d_AnaIntersection_7.cxx
|
||||
IntAna2d_AnaIntersection_8.cxx
|
||||
IntAna2d_Outils.cxx
|
||||
IntAna2d_Outils.hxx
|
31
src/IntAna2d/IntAna2d.cdl
Executable file
31
src/IntAna2d/IntAna2d.cdl
Executable file
@@ -0,0 +1,31 @@
|
||||
-- File: IntAna2d.cdl
|
||||
-- Created: Wed Feb 20 14:31:39 1991
|
||||
-- Author: Jacques GOUSSARD
|
||||
-- <jag@topsn3>
|
||||
---Copyright: Matra Datavision 1991
|
||||
|
||||
|
||||
package IntAna2d
|
||||
|
||||
|
||||
---Purpose: This package defines the intersection between two elements of
|
||||
-- the geometric processor : Line, Circle, Ellipse, Parabola and
|
||||
-- Hyperbola; One of these elements is known with his real type,
|
||||
-- the other one is known by an implicit quadratic equation (see
|
||||
-- class Conic).
|
||||
-- A particular case has been made for the intersection between
|
||||
-- two Lin2d, two Circ2d, a Lin2d and a Circ2d.
|
||||
|
||||
uses
|
||||
|
||||
Standard, TCollection, gp, StdFail
|
||||
|
||||
is
|
||||
|
||||
class Conic;
|
||||
|
||||
class AnaIntersection;
|
||||
|
||||
class IntPoint;
|
||||
|
||||
end IntAna2d;
|
271
src/IntAna2d/IntAna2d_AnaIntersection.cdl
Executable file
271
src/IntAna2d/IntAna2d_AnaIntersection.cdl
Executable file
@@ -0,0 +1,271 @@
|
||||
-- File: AnaIntersection.cdl
|
||||
-- Created: Wed Feb 20 17:20:26 1991
|
||||
-- Author: Jacques GOUSSARD
|
||||
-- <jag@topsn3>
|
||||
---Copyright: Matra Datavision 1991
|
||||
|
||||
|
||||
class AnaIntersection from IntAna2d
|
||||
|
||||
---Purpose: Implementation of the analytical intersection between:
|
||||
-- - two Lin2d,
|
||||
-- - two Circ2d,
|
||||
-- - a Lin2d and a Circ2d,
|
||||
-- - an element of gp (Lin2d, Circ2d, Elips2d, Parab2d, Hypr2d)
|
||||
-- and another conic.
|
||||
-- No tolerance is given for all the intersections: the tolerance
|
||||
-- will be the "precision machine".
|
||||
|
||||
|
||||
uses Vec2d from gp,
|
||||
Lin2d from gp,
|
||||
Circ2d from gp,
|
||||
Elips2d from gp,
|
||||
Parab2d from gp,
|
||||
Hypr2d from gp,
|
||||
Conic from IntAna2d,
|
||||
IntPoint from IntAna2d
|
||||
|
||||
raises NotDone from StdFail,
|
||||
OutOfRange from Standard
|
||||
|
||||
is
|
||||
|
||||
Create
|
||||
|
||||
---Purpose: Empty constructor. IsDone returns False.
|
||||
|
||||
returns AnaIntersection;
|
||||
|
||||
|
||||
Create( L1,L2: Lin2d from gp)
|
||||
|
||||
---Purpose: Intersection between two lines.
|
||||
|
||||
returns AnaIntersection
|
||||
|
||||
raises NotDone from StdFail;
|
||||
|
||||
|
||||
Create( C1,C2: Circ2d from gp)
|
||||
|
||||
---Purpose: Intersection between two circles.
|
||||
|
||||
returns AnaIntersection
|
||||
|
||||
raises NotDone from StdFail;
|
||||
|
||||
|
||||
Create( L: Lin2d from gp; C: Circ2d from gp)
|
||||
|
||||
---Purpose: Intersection between a line and a circle.
|
||||
|
||||
returns AnaIntersection
|
||||
|
||||
raises NotDone from StdFail;
|
||||
|
||||
|
||||
Create(L: Lin2d from gp; C: Conic from IntAna2d)
|
||||
|
||||
---Purpose: Intersection between a line and a conic.
|
||||
|
||||
returns AnaIntersection
|
||||
|
||||
raises NotDone from StdFail;
|
||||
|
||||
|
||||
Create(C: Circ2d from gp; Co: Conic from IntAna2d)
|
||||
|
||||
---Purpose: Intersection between a circle and another conic.
|
||||
|
||||
returns AnaIntersection
|
||||
|
||||
raises NotDone from StdFail;
|
||||
|
||||
|
||||
Create(E: Elips2d from gp; C: Conic from IntAna2d)
|
||||
|
||||
---Purpose: Intersection between an ellipse and another conic.
|
||||
|
||||
returns AnaIntersection
|
||||
|
||||
raises NotDone from StdFail;
|
||||
|
||||
|
||||
Create(P: Parab2d from gp; C: Conic from IntAna2d)
|
||||
|
||||
---Purpose: Intersection between a parabola and another conic.
|
||||
|
||||
returns AnaIntersection
|
||||
|
||||
raises NotDone from StdFail;
|
||||
|
||||
|
||||
Create(H: Hypr2d from gp; C: Conic from IntAna2d)
|
||||
|
||||
---Purpose: Intersection between an hyperbola and another conic.
|
||||
|
||||
returns AnaIntersection
|
||||
|
||||
raises NotDone from StdFail;
|
||||
|
||||
|
||||
Perform(me: in out; L1,L2: Lin2d from gp)
|
||||
|
||||
---Purpose: Intersection between two lines.
|
||||
|
||||
raises NotDone from StdFail
|
||||
|
||||
is static;
|
||||
|
||||
|
||||
Perform(me: in out; C1,C2: Circ2d from gp)
|
||||
|
||||
---Purpose: Intersection between two circles.
|
||||
|
||||
raises NotDone from StdFail
|
||||
|
||||
is static;
|
||||
|
||||
|
||||
Perform(me: in out; L: Lin2d from gp; C: Circ2d from gp)
|
||||
|
||||
---Purpose: Intersection between a line and a circle.
|
||||
|
||||
raises NotDone from StdFail
|
||||
|
||||
is static;
|
||||
|
||||
|
||||
Perform(me: in out; L: Lin2d from gp; C: Conic from IntAna2d)
|
||||
|
||||
---Purpose: Intersection between a line and a conic.
|
||||
|
||||
raises NotDone from StdFail
|
||||
|
||||
is static;
|
||||
|
||||
|
||||
Perform(me: in out; C: Circ2d from gp; Co: Conic from IntAna2d)
|
||||
|
||||
---Purpose: Intersection between a circle and another conic.
|
||||
|
||||
raises NotDone from StdFail
|
||||
|
||||
is static;
|
||||
|
||||
|
||||
Perform(me: in out; E: Elips2d from gp; C: Conic from IntAna2d)
|
||||
|
||||
---Purpose: Intersection between an ellipse and another conic.
|
||||
|
||||
raises NotDone from StdFail
|
||||
|
||||
is static;
|
||||
|
||||
|
||||
Perform(me: in out; P: Parab2d from gp; C: Conic from IntAna2d)
|
||||
|
||||
---Purpose: Intersection between a parabola and another conic.
|
||||
|
||||
raises NotDone from StdFail
|
||||
|
||||
is static;
|
||||
|
||||
|
||||
Perform(me: in out; H: Hypr2d from gp; C: Conic from IntAna2d)
|
||||
|
||||
---Purpose: Intersection between an hyperbola and another conic.
|
||||
|
||||
raises NotDone from StdFail
|
||||
|
||||
is static;
|
||||
|
||||
|
||||
IsDone(me)
|
||||
|
||||
---Purpose: Returns TRUE if the computation was succesfull.
|
||||
|
||||
returns Boolean
|
||||
---C++: inline
|
||||
is static;
|
||||
|
||||
|
||||
IsEmpty(me)
|
||||
|
||||
---Purpose: Returns TRUE when there is no intersection, i-e
|
||||
-- - no intersection point
|
||||
-- - the elements are not identical.
|
||||
-- The element may be parallel in this case.
|
||||
|
||||
returns Boolean
|
||||
|
||||
raises NotDone from StdFail
|
||||
---C++:inline
|
||||
is static;
|
||||
|
||||
|
||||
IdenticalElements(me)
|
||||
|
||||
---Purpose: For the intersection between an element of gp and a conic
|
||||
-- known by an implicit equation, the result will be TRUE
|
||||
-- if the element of gp verifies the implicit equation.
|
||||
-- For the intersection between two Lin2d or two Circ2d, the
|
||||
-- result will be TRUE if the elements are identical.
|
||||
-- The function returns FALSE in all the other cases.
|
||||
|
||||
returns Boolean
|
||||
|
||||
raises NotDone from StdFail
|
||||
---C++:inline
|
||||
is static;
|
||||
|
||||
|
||||
ParallelElements(me)
|
||||
|
||||
---Purpose: For the intersection between two Lin2d or two Circ2d,
|
||||
-- the function returns TRUE if the elements are parallel.
|
||||
-- The function returns FALSE in all the other cases.
|
||||
|
||||
returns Boolean
|
||||
|
||||
raises NotDone from StdFail
|
||||
---C++:inline
|
||||
is static;
|
||||
|
||||
|
||||
NbPoints(me)
|
||||
|
||||
---Purpose: returns the number of IntPoint between the 2 curves.
|
||||
|
||||
returns Integer
|
||||
|
||||
raises NotDone from StdFail
|
||||
---C++:inline
|
||||
is static;
|
||||
|
||||
|
||||
Point(me; N: Integer)
|
||||
|
||||
---Purpose: returns the intersection point of range N;
|
||||
-- If (N<=0) or (N>NbPoints), an exception is raised.
|
||||
|
||||
returns IntPoint from IntAna2d
|
||||
|
||||
raises NotDone from StdFail,
|
||||
OutOfRange from Standard
|
||||
---C++:return const &
|
||||
---C++:inline
|
||||
is static;
|
||||
|
||||
|
||||
fields
|
||||
|
||||
done : Boolean from Standard;
|
||||
para : Boolean from Standard;
|
||||
iden : Boolean from Standard;
|
||||
empt : Boolean from Standard;
|
||||
nbp : Integer from Standard;
|
||||
lpnt : IntPoint from IntAna2d [4];
|
||||
|
||||
end AnaIntersection;
|
58
src/IntAna2d/IntAna2d_AnaIntersection.cxx
Executable file
58
src/IntAna2d/IntAna2d_AnaIntersection.cxx
Executable file
@@ -0,0 +1,58 @@
|
||||
// File IntAna2d_AnaIntersection.cxx, JAG le 6 Juin 1991
|
||||
|
||||
#include <IntAna2d_AnaIntersection.ixx>
|
||||
|
||||
#include <Standard_OutOfRange.hxx>
|
||||
#include <StdFail_NotDone.hxx>
|
||||
|
||||
IntAna2d_AnaIntersection::IntAna2d_AnaIntersection () {
|
||||
|
||||
done = Standard_False;
|
||||
}
|
||||
|
||||
IntAna2d_AnaIntersection::IntAna2d_AnaIntersection (const gp_Lin2d& L1,
|
||||
const gp_Lin2d& L2) {
|
||||
Perform(L1,L2);
|
||||
}
|
||||
|
||||
IntAna2d_AnaIntersection::IntAna2d_AnaIntersection (const gp_Circ2d& C1,
|
||||
const gp_Circ2d& C2) {
|
||||
Perform(C1,C2);
|
||||
}
|
||||
|
||||
|
||||
IntAna2d_AnaIntersection::IntAna2d_AnaIntersection (const gp_Lin2d& L,
|
||||
const gp_Circ2d& C) {
|
||||
Perform(L,C);
|
||||
}
|
||||
|
||||
|
||||
IntAna2d_AnaIntersection::IntAna2d_AnaIntersection (const gp_Lin2d& L,
|
||||
const IntAna2d_Conic& Conic) {
|
||||
Perform(L,Conic);
|
||||
}
|
||||
|
||||
IntAna2d_AnaIntersection::IntAna2d_AnaIntersection (const gp_Parab2d& P,
|
||||
const IntAna2d_Conic& Conic) {
|
||||
Perform(P,Conic);
|
||||
}
|
||||
|
||||
IntAna2d_AnaIntersection::IntAna2d_AnaIntersection (const gp_Circ2d& C,
|
||||
const IntAna2d_Conic& Conic) {
|
||||
Perform(C,Conic);
|
||||
}
|
||||
|
||||
IntAna2d_AnaIntersection::IntAna2d_AnaIntersection (const gp_Elips2d& E,
|
||||
const IntAna2d_Conic& Conic) {
|
||||
Perform(E,Conic);
|
||||
}
|
||||
|
||||
|
||||
IntAna2d_AnaIntersection::IntAna2d_AnaIntersection (const gp_Hypr2d& E,
|
||||
const IntAna2d_Conic& Conic)
|
||||
{
|
||||
Perform(E,Conic);
|
||||
}
|
||||
|
||||
|
||||
|
58
src/IntAna2d/IntAna2d_AnaIntersection.lxx
Executable file
58
src/IntAna2d/IntAna2d_AnaIntersection.lxx
Executable file
@@ -0,0 +1,58 @@
|
||||
// File IntAna2d_AnaIntersection.lxx, JAG le 6 Juin 1991
|
||||
|
||||
#include <StdFail_NotDone.hxx>
|
||||
#include <Standard_OutOfRange.hxx>
|
||||
|
||||
inline Standard_Boolean IntAna2d_AnaIntersection::IsDone () const {
|
||||
return done;
|
||||
}
|
||||
|
||||
inline Standard_Boolean IntAna2d_AnaIntersection::IsEmpty () const {
|
||||
|
||||
if (!done) {
|
||||
StdFail_NotDone::Raise();
|
||||
}
|
||||
return ((nbp==0)&&(!iden));
|
||||
}
|
||||
|
||||
inline Standard_Boolean IntAna2d_AnaIntersection::IdenticalElements () const {
|
||||
|
||||
if (!done) {
|
||||
StdFail_NotDone::Raise();
|
||||
}
|
||||
return iden ;
|
||||
}
|
||||
|
||||
inline Standard_Boolean IntAna2d_AnaIntersection::ParallelElements () const {
|
||||
|
||||
if (!done) {
|
||||
StdFail_NotDone::Raise();
|
||||
}
|
||||
return para ;
|
||||
}
|
||||
|
||||
inline Standard_Integer IntAna2d_AnaIntersection::NbPoints () const {
|
||||
|
||||
if (!done) {
|
||||
StdFail_NotDone::Raise();
|
||||
}
|
||||
return nbp ;
|
||||
}
|
||||
|
||||
inline const IntAna2d_IntPoint& IntAna2d_AnaIntersection::Point (const Standard_Integer N) const {
|
||||
|
||||
if (!done) {
|
||||
StdFail_NotDone::Raise();
|
||||
return lpnt[0];
|
||||
}
|
||||
else {
|
||||
if ((N<=0)||(N>nbp)) {
|
||||
Standard_OutOfRange::Raise();
|
||||
return lpnt[0];
|
||||
}
|
||||
else {
|
||||
return lpnt[N-1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
101
src/IntAna2d/IntAna2d_AnaIntersection_1.cxx
Executable file
101
src/IntAna2d/IntAna2d_AnaIntersection_1.cxx
Executable file
@@ -0,0 +1,101 @@
|
||||
#include <IntAna2d_AnaIntersection.jxx>
|
||||
|
||||
|
||||
void IntAna2d_AnaIntersection::Perform (const gp_Lin2d& L1,
|
||||
const gp_Lin2d& L2) {
|
||||
|
||||
|
||||
done = Standard_False;
|
||||
|
||||
Standard_Real A1,B1,C1;
|
||||
Standard_Real A2,B2,C2;
|
||||
L1.Coefficients(A1,B1,C1);
|
||||
L2.Coefficients(A2,B2,C2);
|
||||
|
||||
Standard_Real al1,be1,ga1;
|
||||
Standard_Real al2,be2,ga2;
|
||||
|
||||
Standard_Real Det =Max (Abs(A1),Max(Abs(A2),Max(Abs(B1),Abs(B2))));
|
||||
|
||||
if (Abs(A1)==Det) {
|
||||
al1=A1;
|
||||
be1=B1;
|
||||
ga1=C1;
|
||||
al2=A2;
|
||||
be2=B2;
|
||||
ga2=C2;
|
||||
}
|
||||
else if (Abs(B1)==Det) {
|
||||
al1=B1;
|
||||
be1=A1;
|
||||
ga1=C1;
|
||||
al2=B2;
|
||||
be2=A2;
|
||||
ga2=C2;
|
||||
}
|
||||
else if (Abs(A2)==Det) {
|
||||
al1=A2;
|
||||
be1=B2;
|
||||
ga1=C2;
|
||||
al2=A1;
|
||||
be2=B1;
|
||||
ga2=C1;
|
||||
}
|
||||
else {
|
||||
al1=B2;
|
||||
be1=A2;
|
||||
ga1=C2;
|
||||
al2=B1;
|
||||
be2=A1;
|
||||
ga2=C1;
|
||||
}
|
||||
|
||||
Standard_Real rap=al2/al1;
|
||||
Standard_Real denom=be2-rap*be1;
|
||||
|
||||
if (Abs(denom)<=RealEpsilon()) { // Directions confondues
|
||||
para=Standard_True;
|
||||
nbp=0;
|
||||
if (Abs(ga2-rap*ga1)<=RealEpsilon()) { // Droites confondues
|
||||
iden=Standard_True;
|
||||
empt=Standard_False;
|
||||
}
|
||||
else { // Droites paralleles
|
||||
iden=Standard_False;
|
||||
empt=Standard_True;
|
||||
}
|
||||
}
|
||||
else {
|
||||
para=Standard_False;
|
||||
iden=Standard_False;
|
||||
empt=Standard_False;
|
||||
nbp=1;
|
||||
Standard_Real XS = (be1*ga2/al1-be2*ga1/al1)/denom;
|
||||
Standard_Real YS = (rap*ga1-ga2)/denom;
|
||||
|
||||
if (((Abs(A1)!=Det)&&(Abs(B1)==Det))||
|
||||
((Abs(A1)!=Det)&&(Abs(B1)!=Det)&&(Abs(A2)!=Det))) {
|
||||
Standard_Real temp=XS;
|
||||
XS=YS;
|
||||
YS=temp;
|
||||
}
|
||||
|
||||
Standard_Real La,Mu;
|
||||
if (Abs(A1)>=Abs(B1)) {
|
||||
La=(YS-L1.Location().Y())/A1;
|
||||
}
|
||||
else {
|
||||
La=(L1.Location().X()-XS)/B1;
|
||||
}
|
||||
if (Abs(A2)>=Abs(B2)) {
|
||||
Mu=(YS-L2.Location().Y())/A2;
|
||||
}
|
||||
else {
|
||||
Mu=(L2.Location().X()-XS)/B2;
|
||||
}
|
||||
lpnt[0].SetValue(XS,YS,La,Mu);
|
||||
}
|
||||
done=Standard_True;
|
||||
}
|
||||
|
||||
|
154
src/IntAna2d/IntAna2d_AnaIntersection_2.cxx
Executable file
154
src/IntAna2d/IntAna2d_AnaIntersection_2.cxx
Executable file
@@ -0,0 +1,154 @@
|
||||
#include <IntAna2d_AnaIntersection.jxx>
|
||||
|
||||
#include <gp_Vec2d.hxx>
|
||||
|
||||
void IntAna2d_AnaIntersection::Perform (const gp_Circ2d& C1,
|
||||
const gp_Circ2d& C2) {
|
||||
|
||||
done=Standard_False;
|
||||
Standard_Real d=C1.Location().Distance(C2.Location());
|
||||
Standard_Real R1=C1.Radius();
|
||||
Standard_Real R2=C2.Radius();
|
||||
Standard_Real sum=R1+R2;
|
||||
Standard_Real dif=Abs(R1-R2);
|
||||
|
||||
|
||||
if (d<=RealEpsilon()) { // Cercle concentriques
|
||||
para=Standard_True;
|
||||
nbp=0;
|
||||
if (dif<=RealEpsilon()) { // Cercles confondus
|
||||
empt=Standard_False;
|
||||
iden=Standard_True;
|
||||
}
|
||||
else { // Cercles paralleles
|
||||
empt=Standard_True;
|
||||
iden=Standard_False;
|
||||
}
|
||||
}
|
||||
else if ((d-sum)>Epsilon(sum)) { // Cercles exterieurs l un a l autre
|
||||
// et No solution
|
||||
empt=Standard_True;
|
||||
para=Standard_False;
|
||||
iden=Standard_False;
|
||||
nbp=0;
|
||||
}
|
||||
else if (Abs(d-sum)<=Epsilon(sum)) { // Cercles exterieurs et tangents
|
||||
empt=Standard_False;
|
||||
para=Standard_False;
|
||||
iden=Standard_False;
|
||||
nbp=1;
|
||||
gp_Vec2d ax(C1.Location(),C2.Location());
|
||||
gp_Vec2d Ox1(C1.XAxis().Direction());
|
||||
gp_Vec2d Ox2(C2.XAxis().Direction());
|
||||
|
||||
Standard_Real XS = ( C1.Location().X()*R2 + C2.Location().X()*R1 ) / sum;
|
||||
Standard_Real YS = ( C1.Location().Y()*R2 + C2.Location().Y()*R1 ) / sum;
|
||||
Standard_Real ang1=Ox1.Angle(ax); // Resultat entre -PI et +PI
|
||||
Standard_Real ang2=Ox2.Angle(ax) + PI;
|
||||
if (ang1<0) {ang1=2*PI+ang1;} // On revient entre 0 et 2PI
|
||||
lpnt[0].SetValue(XS,YS,ang1,ang2);
|
||||
}
|
||||
else if (((sum-d)>Epsilon(d)) && ((d-dif)>Epsilon(d))) {
|
||||
empt=Standard_False;
|
||||
para=Standard_False;
|
||||
iden=Standard_False;
|
||||
nbp=2;
|
||||
gp_Vec2d ax(C1.Location(),C2.Location());
|
||||
gp_Vec2d Ox1(C1.XAxis().Direction());
|
||||
gp_Vec2d Ox2(C2.XAxis().Direction());
|
||||
Standard_Real ref1=Ox1.Angle(ax); // Resultat entre -PI et +PI
|
||||
Standard_Real ref2=Ox2.Angle(ax); // Resultat entre -PI et +PI
|
||||
|
||||
Standard_Real l1=(d*d + R1*R1 -R2*R2)/(2.0*d);
|
||||
Standard_Real h= Sqrt(R1*R1-l1*l1);
|
||||
|
||||
Standard_Real XS1= C1.Location().X() + l1*ax.X()/d - h*ax.Y()/d;
|
||||
Standard_Real YS1= C1.Location().Y() + l1*ax.Y()/d + h*ax.X()/d;
|
||||
|
||||
Standard_Real XS2= C1.Location().X() + l1*ax.X()/d + h*ax.Y()/d;
|
||||
Standard_Real YS2= C1.Location().Y() + l1*ax.Y()/d - h*ax.X()/d;
|
||||
|
||||
Standard_Real sint1=h /R1;
|
||||
Standard_Real cost1=l1/R1;
|
||||
|
||||
Standard_Real sint2=h /R2;
|
||||
Standard_Real cost2=(l1-d)/R2;
|
||||
|
||||
Standard_Real ang1,ang2;
|
||||
|
||||
// ang1 et ang2 correspondent aux solutions avec sinus positif
|
||||
// si l'axe de reference est l'axe des centres C1C2
|
||||
// On prend l'arccos entre pi/2 et 3pi/2, l'arcsin sinon.
|
||||
|
||||
if (Abs(cost1)<=0.707) {
|
||||
ang1=ACos(cost1);
|
||||
}
|
||||
else {
|
||||
ang1=ASin(sint1);
|
||||
if (cost1<0.0) {ang1=PI-ang1;}
|
||||
}
|
||||
if (Abs(cost2)<=0.707) {
|
||||
ang2=ACos(cost2);
|
||||
}
|
||||
else {
|
||||
ang2=ASin(sint2);
|
||||
if (cost2<0.0) {ang2=PI-ang2;}
|
||||
}
|
||||
Standard_Real ang11=ref1+ang1;
|
||||
Standard_Real ang21=ref2+ang2;
|
||||
Standard_Real ang12=ref1-ang1;
|
||||
Standard_Real ang22=ref2-ang2;
|
||||
if (ang11<0.) {
|
||||
ang11=2*PI+ang11;
|
||||
}
|
||||
else if (ang11>=2*PI) {
|
||||
ang11=ang11-2*PI;
|
||||
}
|
||||
if (ang21<0.) {
|
||||
ang21=2*PI+ang21;
|
||||
}
|
||||
else if (ang21>=2*PI) {
|
||||
ang21=ang21-2*PI;
|
||||
}
|
||||
if (ang12<0.) {
|
||||
ang12=2*PI+ang12;
|
||||
}
|
||||
else if (ang12>=2*PI) {
|
||||
ang12=ang12-2*PI;
|
||||
}
|
||||
if (ang22<0.) {
|
||||
ang22=2*PI+ang22;
|
||||
}
|
||||
else if (ang22>=2*PI) {
|
||||
ang22=ang22-2*PI;
|
||||
}
|
||||
lpnt[0].SetValue(XS1,YS1,ang11,ang21);
|
||||
lpnt[1].SetValue(XS2,YS2,ang12,ang22);
|
||||
}
|
||||
else if (Abs(d-dif)<=Epsilon(d)) { // Cercles tangents interieurs
|
||||
empt=Standard_False;
|
||||
para=Standard_False;
|
||||
iden=Standard_False;
|
||||
nbp=1;
|
||||
gp_Vec2d ax(C1.Location(),C2.Location());
|
||||
gp_Vec2d Ox1(C1.XAxis().Direction());
|
||||
gp_Vec2d Ox2(C2.XAxis().Direction());
|
||||
Standard_Real ang1=Ox1.Angle(ax); // Resultat entre -PI et +PI
|
||||
Standard_Real ang2=Ox2.Angle(ax);
|
||||
if (ang1<0) {ang1=2*PI+ang1;} // On revient entre 0 et 2PI
|
||||
if (ang2<0) {ang2=2*PI+ang2;} // On revient entre 0 et 2PI
|
||||
Standard_Real XS = ( C1.Location().X()*R2 - C2.Location().X()*R1 ) / (R2 - R1);
|
||||
Standard_Real YS = ( C1.Location().Y()*R2 - C2.Location().Y()*R1 ) / (R2 - R1);
|
||||
lpnt[0].SetValue(XS,YS,ang1,ang2);
|
||||
}
|
||||
else { // On doit avoir d<dif-Resol et d<>0 donc
|
||||
// 1 cercle dans l autre et no solution
|
||||
empt=Standard_True;
|
||||
para=Standard_False;
|
||||
iden=Standard_False;
|
||||
nbp=0;
|
||||
}
|
||||
done=Standard_True;
|
||||
}
|
||||
|
||||
|
117
src/IntAna2d/IntAna2d_AnaIntersection_3.cxx
Executable file
117
src/IntAna2d/IntAna2d_AnaIntersection_3.cxx
Executable file
@@ -0,0 +1,117 @@
|
||||
#include <IntAna2d_AnaIntersection.jxx>
|
||||
#include <ElCLib.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : Perform
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void IntAna2d_AnaIntersection::Perform(const gp_Lin2d& L,
|
||||
const gp_Circ2d& C)
|
||||
{
|
||||
|
||||
done=Standard_False;
|
||||
|
||||
iden=Standard_False;
|
||||
para=Standard_False;
|
||||
//
|
||||
Standard_Real A,B,C0, d;
|
||||
gp_Pnt2d aP2D, aP2D1, aP2D2;
|
||||
//
|
||||
L.Coefficients(A,B,C0);
|
||||
d=A*C.Location().X() + B*C.Location().Y() + C0;
|
||||
|
||||
if (Abs(d)-C.Radius()>Epsilon(C.Radius())) {
|
||||
empt=Standard_True;
|
||||
nbp=0;
|
||||
}
|
||||
else { // Au moins 1 solution
|
||||
empt=Standard_False;
|
||||
//
|
||||
//modified by NIZNHY-PKV Fri Jun 15 09:55:00 2007f
|
||||
//Standard_Real ang;
|
||||
//ang = C.XAxis().Direction().Angle(L.Direction());
|
||||
//ang = ang + PI / 2.0;
|
||||
//modified by NIZNHY-PKV Fri Jun 15 09:55:29 2007t
|
||||
if (Abs(Abs(d)-C.Radius())<=Epsilon(C.Radius())) { // Cas de tangence
|
||||
|
||||
Standard_Real u, XS, YS, ang;
|
||||
//
|
||||
nbp=1;
|
||||
XS=C.Location().X() - d*A;
|
||||
YS=C.Location().Y() - d*B;
|
||||
//
|
||||
//modified by NIZNHY-PKV Fri Jun 15 09:55:35 2007f
|
||||
aP2D.SetCoord(XS, YS);
|
||||
u=ElCLib::Parameter(L, aP2D);
|
||||
ang=ElCLib::Parameter(C, aP2D);
|
||||
/*
|
||||
u=B*(L.Location().X()-C.Location().X()) -
|
||||
A*(L.Location().Y()-C.Location().Y());
|
||||
if (d<0.0) {ang=ang+PI;}
|
||||
if (ang>=2.0*PI) {
|
||||
ang=ang-2.0*PI;
|
||||
}
|
||||
else if (ang<0.0) {
|
||||
ang=ang+2.0*PI;
|
||||
}
|
||||
*/
|
||||
//modified by NIZNHY-PKV Fri Jun 15 09:55:41 2007t
|
||||
lpnt[0].SetValue(XS,YS,u,ang);
|
||||
}
|
||||
else { // 2 points d intersection
|
||||
Standard_Real h, XS1,YS1, XS2,YS2, ang1,ang2, u1,u2;//,cost,sint angt;
|
||||
nbp=2;
|
||||
h=Sqrt(C.Radius()*C.Radius()-d*d);
|
||||
//modified by NIZNHY-PKV Fri Jun 15 09:55:47 2007f
|
||||
//cost=d/C.Radius();
|
||||
//sint=h/C.Radius();
|
||||
//modified by NIZNHY-PKV Fri Jun 15 09:55:52 2007t
|
||||
XS1=C.Location().X() - d*A - h*B;
|
||||
YS1=C.Location().Y() - d*B + h*A;
|
||||
XS2=C.Location().X() - d*A + h*B;
|
||||
YS2=C.Location().Y() - d*B - h*A;
|
||||
//
|
||||
//modified by NIZNHY-PKV Fri Jun 15 09:55:57 2007f
|
||||
aP2D1.SetCoord(XS1, YS1);
|
||||
aP2D2.SetCoord(XS2, YS2);
|
||||
u1=ElCLib::Parameter(L, aP2D1);
|
||||
u2=ElCLib::Parameter(L, aP2D2);
|
||||
ang1=ElCLib::Parameter(C, aP2D1);
|
||||
ang2=ElCLib::Parameter(C, aP2D2);
|
||||
//
|
||||
/*
|
||||
if (Abs(cost)<=0.707) {
|
||||
angt=ACos(cost);
|
||||
}
|
||||
else {
|
||||
angt=ASin(sint);
|
||||
if (cost<0) {angt=PI-angt;}
|
||||
}
|
||||
|
||||
ang1=ang-angt;
|
||||
ang2=ang+angt;
|
||||
if (ang1<0.0) {
|
||||
ang1=ang1+2.0*PI;
|
||||
}
|
||||
else if (ang1>=2.0*PI) {
|
||||
ang1=ang1-2.0*PI;
|
||||
}
|
||||
if (ang2<0.0) {
|
||||
ang2=ang2+2.0*PI;
|
||||
}
|
||||
else if (ang2>=2.0*PI) {
|
||||
ang2=ang2-2.0*PI;
|
||||
}
|
||||
|
||||
u1=B*(L.Location().X()-C.Location().X()) -
|
||||
A*(L.Location().Y()-C.Location().Y()) +h;
|
||||
u2=u1-2.0*h;
|
||||
*/
|
||||
//modified by NIZNHY-PKV Fri Jun 15 09:56:19 2007t
|
||||
lpnt[0].SetValue(XS1,YS1,u1,ang1);
|
||||
lpnt[1].SetValue(XS2,YS2,u2,ang2);
|
||||
}
|
||||
}
|
||||
done=Standard_True;
|
||||
}
|
||||
|
54
src/IntAna2d/IntAna2d_AnaIntersection_4.cxx
Executable file
54
src/IntAna2d/IntAna2d_AnaIntersection_4.cxx
Executable file
@@ -0,0 +1,54 @@
|
||||
//============================================ IntAna2d_AnaIntersection_4.cxx
|
||||
//============================================================================
|
||||
#include <IntAna2d_AnaIntersection.jxx>
|
||||
#include <IntAna2d_Outils.hxx>
|
||||
|
||||
void IntAna2d_AnaIntersection::Perform (const gp_Lin2d& L,
|
||||
const IntAna2d_Conic& Conic)
|
||||
{
|
||||
Standard_Real A,B,C,D,E,F;
|
||||
Standard_Real px0,px1,px2;
|
||||
Standard_Real DR_A,DR_B,DR_C,X0,Y0;
|
||||
Standard_Integer i;
|
||||
Standard_Real tx,ty,S;
|
||||
|
||||
done = Standard_False;
|
||||
nbp = 0;
|
||||
para = Standard_False;
|
||||
iden = Standard_False;
|
||||
|
||||
Conic.Coefficients(A,B,C,D,E,F);
|
||||
L.Coefficients(DR_A,DR_B,DR_C);
|
||||
X0=L.Location().X();
|
||||
Y0=L.Location().Y();
|
||||
|
||||
// Parametre: L
|
||||
// X = Xo - L DR_B et Y = Yo + L DR_A
|
||||
|
||||
px0=F + X0*(D+D + A*X0 + 2.0*C*Y0) + Y0*(E+E + B*Y0);
|
||||
px1=2.0*(E*DR_A - D*DR_B + X0*(C*DR_A - A*DR_B) + Y0*(B*DR_A - C*DR_B));
|
||||
px2=DR_A*(B*DR_A - 2.0*C*DR_B) + A*(DR_B*DR_B);
|
||||
|
||||
MyDirectPolynomialRoots Sol(px2,px1,px0);
|
||||
|
||||
if(!Sol.IsDone()) {
|
||||
done=Standard_False;
|
||||
return;
|
||||
}
|
||||
else {
|
||||
if(Sol.InfiniteRoots()) {
|
||||
iden=Standard_True;
|
||||
done=Standard_True;
|
||||
return;
|
||||
}
|
||||
nbp=Sol.NbSolutions();
|
||||
for(i=1;i<=nbp;i++) {
|
||||
S=Sol.Value(i);
|
||||
tx=X0 - S*DR_B;
|
||||
ty=Y0 + S*DR_A;
|
||||
lpnt[i-1].SetValue(tx,ty,S);
|
||||
}
|
||||
Traitement_Points_Confondus(nbp,lpnt);
|
||||
}
|
||||
done=Standard_True;
|
||||
}
|
66
src/IntAna2d/IntAna2d_AnaIntersection_5.cxx
Executable file
66
src/IntAna2d/IntAna2d_AnaIntersection_5.cxx
Executable file
@@ -0,0 +1,66 @@
|
||||
//============================================ IntAna2d_AnaIntersection_5.cxx
|
||||
//============================================================================
|
||||
#include <IntAna2d_AnaIntersection.jxx>
|
||||
|
||||
#include <IntAna2d_Outils.hxx>
|
||||
|
||||
void IntAna2d_AnaIntersection::Perform(const gp_Circ2d& Circle,
|
||||
const IntAna2d_Conic& Conic)
|
||||
{
|
||||
Standard_Boolean CIsDirect = Circle.IsDirect();
|
||||
Standard_Real A,B,C,D,E,F;
|
||||
Standard_Real pcc,pss,p2sc,pc,ps,pcte;
|
||||
Standard_Real radius=Circle.Radius();
|
||||
Standard_Real radius_P2=radius*radius;
|
||||
Standard_Integer i;
|
||||
Standard_Real tx,ty,S;
|
||||
|
||||
done = Standard_False;
|
||||
nbp = 0;
|
||||
para = Standard_False;
|
||||
empt = Standard_False;
|
||||
iden = Standard_False;
|
||||
|
||||
gp_Ax2d Axe_rep(Circle.XAxis());
|
||||
|
||||
Conic.Coefficients(A,B,C,D,E,F);
|
||||
Conic.NewCoefficients(A,B,C,D,E,F,Axe_rep);
|
||||
|
||||
// Parametre a avec x=Radius Cos(a) et y=Radius Sin(a)
|
||||
|
||||
pss = B*radius_P2;
|
||||
pcc = A*radius_P2 - pss; // COS ^2
|
||||
p2sc =C*radius_P2; // 2 SIN COS
|
||||
pc = 2.0*D*radius; // COS
|
||||
ps = 2.0*E*radius; // SIN
|
||||
pcte= F + pss; // 1
|
||||
|
||||
math_TrigonometricFunctionRoots Sol(pcc,p2sc,pc,ps,pcte,0.0,2.0*PI);
|
||||
|
||||
if(!Sol.IsDone()) {
|
||||
cout << "\n\nmath_TrigonometricFunctionRoots -> NotDone\n\n"<<endl;
|
||||
done=Standard_False;
|
||||
return;
|
||||
}
|
||||
else {
|
||||
if(Sol.InfiniteRoots()) {
|
||||
iden=Standard_True;
|
||||
done=Standard_True;
|
||||
return;
|
||||
}
|
||||
nbp=Sol.NbSolutions();
|
||||
for(i=1;i<=nbp;i++) {
|
||||
S = Sol.Value(i);
|
||||
tx= radius*Cos(S);
|
||||
ty= radius*Sin(S);
|
||||
Coord_Ancien_Repere(tx,ty,Axe_rep);
|
||||
if(!CIsDirect)
|
||||
S = PI+PI-S;
|
||||
lpnt[i-1].SetValue(tx,ty,S);
|
||||
}
|
||||
Traitement_Points_Confondus(nbp,lpnt);
|
||||
}
|
||||
done=Standard_True;
|
||||
}
|
||||
|
||||
|
65
src/IntAna2d/IntAna2d_AnaIntersection_6.cxx
Executable file
65
src/IntAna2d/IntAna2d_AnaIntersection_6.cxx
Executable file
@@ -0,0 +1,65 @@
|
||||
//============================================ IntAna2d_AnaIntersection_6.cxx
|
||||
//============================================================================
|
||||
#include <IntAna2d_AnaIntersection.jxx>
|
||||
|
||||
#include <IntAna2d_Outils.hxx>
|
||||
|
||||
void IntAna2d_AnaIntersection::Perform(const gp_Elips2d& Elips,
|
||||
const IntAna2d_Conic& Conic)
|
||||
{
|
||||
Standard_Boolean EIsDirect = Elips.IsDirect();
|
||||
Standard_Real A,B,C,D,E,F;
|
||||
Standard_Real pcte,ps,pc,p2sc,pcc,pss;
|
||||
Standard_Real minor_radius=Elips.MinorRadius();
|
||||
Standard_Real major_radius=Elips.MajorRadius();
|
||||
Standard_Integer i;
|
||||
Standard_Real tx,ty,S;
|
||||
|
||||
done = Standard_False;
|
||||
nbp = 0;
|
||||
para = Standard_False;
|
||||
iden = Standard_False;
|
||||
empt = Standard_False;
|
||||
|
||||
|
||||
gp_Ax2d Axe_rep(Elips.XAxis());
|
||||
|
||||
Conic.Coefficients(A,B,C,D,E,F);
|
||||
Conic.NewCoefficients(A,B,C,D,E,F,Axe_rep);
|
||||
|
||||
// Parametre : a avec x=MajorRadius Cos(a) et y=MinorRadius Sin(a)
|
||||
|
||||
pss= B*minor_radius*minor_radius; // SIN ^2
|
||||
pcc= A*major_radius*major_radius-pss; // COS ^2
|
||||
p2sc=C*major_radius*minor_radius; // 2 SIN COS
|
||||
pc= 2.0*D*major_radius; // COS
|
||||
ps= 2.0*E*minor_radius; // SIN
|
||||
pcte=F+pss; // 1
|
||||
|
||||
math_TrigonometricFunctionRoots Sol(pcc,p2sc,pc,ps,pcte,0.0,2.0*PI);
|
||||
|
||||
if (!Sol.IsDone()) {
|
||||
done=Standard_False;
|
||||
return;
|
||||
}
|
||||
else {
|
||||
if(Sol.InfiniteRoots()) {
|
||||
iden=Standard_True;
|
||||
done=Standard_True;
|
||||
return;
|
||||
}
|
||||
nbp=Sol.NbSolutions();
|
||||
for(i=1;i<=nbp;i++) {
|
||||
S = Sol.Value(i);
|
||||
tx=major_radius*Cos(S);
|
||||
ty=minor_radius*Sin(S);
|
||||
Coord_Ancien_Repere(tx,ty,Axe_rep);
|
||||
if(!EIsDirect)
|
||||
S = PI+PI-S;
|
||||
lpnt[i-1].SetValue(tx,ty,S);
|
||||
}
|
||||
Traitement_Points_Confondus(nbp,lpnt);
|
||||
}
|
||||
done = Standard_True;
|
||||
}
|
||||
|
66
src/IntAna2d/IntAna2d_AnaIntersection_7.cxx
Executable file
66
src/IntAna2d/IntAna2d_AnaIntersection_7.cxx
Executable file
@@ -0,0 +1,66 @@
|
||||
//============================================ IntAna2d_AnaIntersection_7.cxx
|
||||
//============================================================================
|
||||
#include <IntAna2d_AnaIntersection.jxx>
|
||||
|
||||
#include <IntAna2d_Outils.hxx>
|
||||
|
||||
void IntAna2d_AnaIntersection::Perform(const gp_Parab2d& P,
|
||||
const IntAna2d_Conic& Conic)
|
||||
{
|
||||
Standard_Boolean PIsDirect = P.IsDirect();
|
||||
Standard_Real A,B,C,D,E,F;
|
||||
Standard_Real px4,px3,px2,px1,px0;
|
||||
Standard_Integer i;
|
||||
Standard_Real tx,ty,S;
|
||||
Standard_Real un_sur_2p=0.5/(P.Parameter());
|
||||
gp_Ax2d Axe_rep(P.MirrorAxis());
|
||||
|
||||
done = Standard_False;
|
||||
nbp = 0;
|
||||
para = Standard_False;
|
||||
empt = Standard_False;
|
||||
iden = Standard_False;
|
||||
|
||||
Conic.Coefficients(A,B,C,D,E,F);
|
||||
Conic.NewCoefficients(A,B,C,D,E,F,Axe_rep);
|
||||
|
||||
//-------- 'Parametre' y avec y=y x=y^2/(2 p)
|
||||
|
||||
px0=F;
|
||||
px1=E+E;
|
||||
px2=B + un_sur_2p*(D+D);
|
||||
px3=(C+C)*un_sur_2p;
|
||||
px4=A*(un_sur_2p*un_sur_2p);
|
||||
|
||||
MyDirectPolynomialRoots Sol(px4,px3,px2,px1,px0);
|
||||
|
||||
if(!Sol.IsDone()) {
|
||||
done=Standard_False;
|
||||
}
|
||||
else {
|
||||
if(Sol.InfiniteRoots()) {
|
||||
iden=Standard_True;
|
||||
done=Standard_True;
|
||||
}
|
||||
nbp=Sol.NbSolutions();
|
||||
for(i=1;i<=nbp;i++) {
|
||||
S = Sol.Value(i);
|
||||
tx=un_sur_2p*S*S;
|
||||
ty=S;
|
||||
Coord_Ancien_Repere(tx,ty,Axe_rep);
|
||||
if(!PIsDirect)
|
||||
S =-S;
|
||||
lpnt[i-1].SetValue(tx,ty,S);
|
||||
}
|
||||
Traitement_Points_Confondus(nbp,lpnt);
|
||||
}
|
||||
done=Standard_True;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
115
src/IntAna2d/IntAna2d_AnaIntersection_8.cxx
Executable file
115
src/IntAna2d/IntAna2d_AnaIntersection_8.cxx
Executable file
@@ -0,0 +1,115 @@
|
||||
//============================================ IntAna2d_AnaIntersection_8.cxx
|
||||
//============================================================================
|
||||
#include <IntAna2d_AnaIntersection.jxx>
|
||||
|
||||
#include <IntAna2d_Outils.hxx>
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
// ------ Verification de la validite des points obtenus ----------
|
||||
// --- Methode a implementer dans les autres routines si on constate
|
||||
// --- des problemes d'instabilite numerique sur
|
||||
// --- * la construction des polynomes en t (t:parametre)
|
||||
// --- * la resolution du polynome
|
||||
// --- * le retour : parametre t -> point d'intersection
|
||||
// --- Probleme : A partir de quelle Tolerance un point n'est
|
||||
// --- plus un point de la courbe. (f(x,y)=1e-10 ??)
|
||||
// --- ne donne pas d'info. sur la dist. du pt a la courbe
|
||||
// -----------------------------------------------------------------
|
||||
// ------ Methode non implementee pour les autres Intersections
|
||||
// --- Si un probleme est constate : Dupliquer le code entre les
|
||||
// --- commentaires VERIF-VALID
|
||||
// -----------------------------------------------------------------
|
||||
|
||||
void IntAna2d_AnaIntersection::Perform(const gp_Hypr2d& H,
|
||||
const IntAna2d_Conic& Conic)
|
||||
{
|
||||
Standard_Boolean HIsDirect = H.IsDirect();
|
||||
Standard_Real A,B,C,D,E,F;
|
||||
Standard_Real px0,px1,px2,px3,px4;
|
||||
Standard_Real minor_radius=H.MinorRadius();
|
||||
Standard_Real major_radius=H.MajorRadius();
|
||||
Standard_Integer i;
|
||||
Standard_Real tx,ty,S;
|
||||
|
||||
done = Standard_False;
|
||||
nbp = 0;
|
||||
para = Standard_False;
|
||||
iden = Standard_False;
|
||||
empt = Standard_False;
|
||||
|
||||
gp_Ax2d Axe_rep(H.XAxis());
|
||||
Conic.Coefficients(A,B,C,D,E,F);
|
||||
Conic.NewCoefficients(A,B,C,D,E,F,Axe_rep);
|
||||
|
||||
Standard_Real A_major_radiusP2=A*major_radius*major_radius;
|
||||
Standard_Real B_minor_radiusP2=B*minor_radius*minor_radius;
|
||||
Standard_Real C_2_major_minor_radius=C*2.0*major_radius*minor_radius;
|
||||
|
||||
// Parametre : t avec x=MajorRadius*Ch(t) y=:minorRadius*Sh(t)
|
||||
// Le polynome est reecrit en Exp(t)
|
||||
// Suivent les Coeffs du polynome P multiplie par 4*Exp(t)^2
|
||||
|
||||
px0=A_major_radiusP2 - C_2_major_minor_radius + B_minor_radiusP2;
|
||||
px1=4.0*(D*major_radius-E*minor_radius);
|
||||
px2=2.0*(A_major_radiusP2 + 2.0*F - B_minor_radiusP2);
|
||||
px3=4.0*(D*major_radius+E*minor_radius);
|
||||
px4=A_major_radiusP2 + C_2_major_minor_radius + B_minor_radiusP2;
|
||||
|
||||
MyDirectPolynomialRoots Sol(px4,px3,px2,px1,px0);
|
||||
|
||||
if(!Sol.IsDone()) {
|
||||
//-- cout<<" Done = False ds IntAna2d_AnaIntersection_8.cxx "<<endl;
|
||||
done=Standard_False;
|
||||
return;
|
||||
}
|
||||
else {
|
||||
if(Sol.InfiniteRoots()) {
|
||||
iden=Standard_True;
|
||||
done=Standard_True;
|
||||
return;
|
||||
}
|
||||
// On a X=(CosH(t)*major_radius)/2 , Y=(SinH(t)*minor_radius)/2
|
||||
// la Resolution est en S=Exp(t)
|
||||
nbp=Sol.NbSolutions();
|
||||
Standard_Integer nb_sol_valides=0;
|
||||
for(i=1;i<=nbp;i++) {
|
||||
S=Sol.Value(i);
|
||||
if(S>RealEpsilon()) {
|
||||
tx=0.5*major_radius*(S+1/S);
|
||||
ty=0.5*minor_radius*(S-1/S);
|
||||
|
||||
//--- Est-on sur la bonne branche de l'Hyperbole
|
||||
//--------------- VERIF-VALIDITE-INTERSECTION ----------
|
||||
//--- On Suppose que l'ecart sur la courbe1 est nul
|
||||
//--- (le point a ete obtenu par parametrage)
|
||||
//--- ??? la tolerance a ete fixee a 1e-10 ?????????????
|
||||
|
||||
#if 0
|
||||
Standard_Real ecart_sur_courbe2;
|
||||
ecart_sur_courbe2=Conic.Value(tx,ty);
|
||||
if(ecart_sur_courbe2<=1e-10 && ecart_sur_courbe2>=-1e-10) {
|
||||
nb_sol_valides++;
|
||||
Coord_Ancien_Repere(tx,ty,Axe_rep);
|
||||
lpnt[nb_sol_valides-1].SetValue(tx,ty,Log(S));
|
||||
}
|
||||
#else
|
||||
|
||||
nb_sol_valides++;
|
||||
Coord_Ancien_Repere(tx,ty,Axe_rep);
|
||||
S = Log(S);
|
||||
if(!HIsDirect)
|
||||
S = -S;
|
||||
lpnt[nb_sol_valides-1].SetValue(tx,ty,S);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
nbp=nb_sol_valides;
|
||||
Traitement_Points_Confondus(nbp,lpnt);
|
||||
}
|
||||
done=Standard_True;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
103
src/IntAna2d/IntAna2d_Conic.cdl
Executable file
103
src/IntAna2d/IntAna2d_Conic.cdl
Executable file
@@ -0,0 +1,103 @@
|
||||
-- File: Conic.cdl
|
||||
-- Created: Tue Feb 11 16:07:09 1992
|
||||
-- Author: Laurent BUCHARD
|
||||
-- <lbr@phobox>
|
||||
---Copyright: Matra Datavision 1992
|
||||
|
||||
|
||||
class Conic from IntAna2d
|
||||
|
||||
---Purpose: Definition of a conic by its implicit quadaratic equation:
|
||||
-- A.X**2 + B.Y**2 + 2.C.X*Y + 2.D.X + 2.E.Y + F = 0.
|
||||
|
||||
uses XY from gp,
|
||||
Ax2d from gp,
|
||||
Circ2d from gp,
|
||||
Elips2d from gp,
|
||||
Parab2d from gp,
|
||||
Hypr2d from gp,
|
||||
Lin2d from gp
|
||||
|
||||
is
|
||||
|
||||
|
||||
Create(C: Circ2d from gp)
|
||||
|
||||
returns Conic from IntAna2d;
|
||||
|
||||
|
||||
Create(C: Lin2d from gp)
|
||||
|
||||
returns Conic from IntAna2d;
|
||||
|
||||
|
||||
Create(C: Parab2d from gp)
|
||||
|
||||
returns Conic from IntAna2d;
|
||||
|
||||
|
||||
Create(C: Hypr2d from gp)
|
||||
|
||||
returns Conic from IntAna2d;
|
||||
|
||||
|
||||
Create(C: Elips2d from gp)
|
||||
|
||||
returns Conic from IntAna2d;
|
||||
|
||||
|
||||
Value(me; X,Y: Real)
|
||||
|
||||
---Purpose: value of the function F at the point X,Y.
|
||||
|
||||
returns Real
|
||||
|
||||
is static;
|
||||
|
||||
|
||||
Grad(me; X,Y: Real)
|
||||
|
||||
---Purpose: returns the value of the gradient of F at the point X,Y.
|
||||
|
||||
returns XY from gp
|
||||
|
||||
is static;
|
||||
|
||||
|
||||
ValAndGrad(me; X,Y: Real; Val: out Real; Grd: out XY from gp)
|
||||
|
||||
---Purpose: Returns the value of the function and its gradient at
|
||||
-- the point X,Y.
|
||||
|
||||
is static;
|
||||
|
||||
|
||||
Coefficients(me; A,B,C,D,E,F: out Real)
|
||||
|
||||
---Purpose: returns the coefficients of the polynomial equation
|
||||
-- wich defines the conic:
|
||||
-- A.X**2 + B.Y**2 + 2.C.X*Y + 2.D.X + 2.E.Y + F = 0.
|
||||
|
||||
is static;
|
||||
|
||||
|
||||
NewCoefficients(me; A,B,C,D,E,F: in out Real ; Axis: Ax2d from gp)
|
||||
---Purpose: Returns the coefficients of the polynomial equation
|
||||
-- ( written in the natural coordinates system )
|
||||
-- A x x + B y y + 2 C x y + 2 D x + 2 E y + F
|
||||
-- in the local coordinates system defined by Axis
|
||||
|
||||
is static;
|
||||
|
||||
fields
|
||||
|
||||
a: Real;
|
||||
b: Real;
|
||||
c: Real;
|
||||
d: Real;
|
||||
e: Real;
|
||||
f: Real;
|
||||
|
||||
end Conic;
|
||||
|
||||
|
92
src/IntAna2d/IntAna2d_Conic.cxx
Executable file
92
src/IntAna2d/IntAna2d_Conic.cxx
Executable file
@@ -0,0 +1,92 @@
|
||||
#include <IntAna2d_Conic.ixx>
|
||||
|
||||
|
||||
IntAna2d_Conic::IntAna2d_Conic (const gp_Lin2d& L) {
|
||||
|
||||
a = 0.0;
|
||||
b = 0.0;
|
||||
c = 0.0;
|
||||
L.Coefficients(d,e,f);
|
||||
f = 2*f;
|
||||
}
|
||||
|
||||
IntAna2d_Conic::IntAna2d_Conic (const gp_Circ2d& C) {
|
||||
|
||||
C.Coefficients(a,b,c,d,e,f);
|
||||
}
|
||||
|
||||
|
||||
IntAna2d_Conic::IntAna2d_Conic (const gp_Elips2d& E) {
|
||||
|
||||
E.Coefficients(a,b,c,d,e,f);
|
||||
}
|
||||
|
||||
|
||||
IntAna2d_Conic::IntAna2d_Conic (const gp_Parab2d& P) {
|
||||
P.Coefficients(a,b,c,d,e,f);
|
||||
}
|
||||
|
||||
|
||||
IntAna2d_Conic::IntAna2d_Conic (const gp_Hypr2d& H) {
|
||||
H.Coefficients(a,b,c,d,e,f);
|
||||
}
|
||||
|
||||
|
||||
void IntAna2d_Conic::NewCoefficients(Standard_Real& A,Standard_Real& B,Standard_Real& C
|
||||
,Standard_Real& D,Standard_Real& E,Standard_Real& F
|
||||
,const gp_Ax2d& Dir1) const {
|
||||
Standard_Real t11,t12,t13; // x = t11 X + t12 Y + t13
|
||||
Standard_Real t21,t22,t23; // y = t21 X + t22 Y + t23
|
||||
Standard_Real A1,B1,C1,D1,E1,F1;
|
||||
|
||||
// P0(x,y)=A x x + B y y + ... + F =0 (x,y "absolute" coordinates)
|
||||
// and P1(X(x,y),Y(x,y))=P0(x,y)
|
||||
// with P1(X,Y)= A1 X X + B1 Y Y + 2 C1 X Y + 2 D1 X + 2 E1 Y + F1
|
||||
// = A x x + B y y + 2 C x y + 2 D x + 2 E y + f
|
||||
|
||||
Dir1.Direction().Coord(t11,t21);
|
||||
Dir1.Location().Coord(t13,t23);
|
||||
|
||||
t22=t11;
|
||||
t12=-t21;
|
||||
|
||||
A1=(t11*(A*t11 + 2*C*t21) + B*t21*t21);
|
||||
B1=(t12*(A*t12 + 2*C*t22) + B*t22*t22);
|
||||
C1=(t12*(A*t11 + C*t21) + t22*(C*t11 + B*t21));
|
||||
D1=(t11*(D + A*t13) + t21*(E + C*t13) + t23*(C*t11 + B*t21));
|
||||
E1=(t12*(D + A*t13) + t22*(E + C*t13) + t23*(C*t12 + B*t22));
|
||||
F1=F + t13*(2.0*D + A*t13) + t23*(2.0*E + 2.0*C*t13 + B*t23);
|
||||
|
||||
A=A1; B=B1; C=C1; D=D1; E=E1; F=F1;
|
||||
}
|
||||
|
||||
|
||||
Standard_Real IntAna2d_Conic::Value (const Standard_Real X, const Standard_Real Y) const {
|
||||
Standard_Real _a,_b,_c,_d,_e,_f;
|
||||
this->Coefficients(_a,_b,_c,_d,_e,_f);
|
||||
return (_a*X*X + _b*Y*Y + 2.*_c*X*Y + 2.*_d*X + 2.*_e*Y +_f);
|
||||
}
|
||||
|
||||
gp_XY IntAna2d_Conic::Grad (const Standard_Real X, const Standard_Real Y) const {
|
||||
Standard_Real _a,_b,_c,_d,_e,_f;
|
||||
this->Coefficients(_a,_b,_c,_d,_e,_f);
|
||||
return gp_XY(2.*_a*X + 2.*_c*Y + 2.*_d, 2.*_b*Y + 2.*_c*X + 2.*_e);
|
||||
}
|
||||
|
||||
void IntAna2d_Conic::ValAndGrad (const Standard_Real X, const Standard_Real Y,
|
||||
Standard_Real& Val, gp_XY& Grd) const {
|
||||
Standard_Real la,lb,lc,ld,le,lf;
|
||||
this->Coefficients(la,lb,lc,ld,le,lf);
|
||||
Grd.SetCoord(2.*la*X + 2.*lc*Y + 2.*ld, 2.*lb*Y + 2.*lc*X + 2.*le);
|
||||
Val = la*X*X + lb*Y*Y + 2.*lc*X*Y + 2.*ld*X + 2.*le*Y +lf;
|
||||
}
|
||||
|
||||
|
||||
void IntAna2d_Conic::Coefficients(Standard_Real& A,Standard_Real& B,Standard_Real& C,
|
||||
Standard_Real& D,Standard_Real& E,Standard_Real& F) const
|
||||
{
|
||||
A=a; B=b; C=c; D=d; E=e; F=f;
|
||||
}
|
||||
|
||||
|
||||
|
106
src/IntAna2d/IntAna2d_IntPoint.cdl
Executable file
106
src/IntAna2d/IntAna2d_IntPoint.cdl
Executable file
@@ -0,0 +1,106 @@
|
||||
-- File: IntPoint.cdl
|
||||
-- Created: Wed Feb 20 16:51:04 1991
|
||||
-- Author: Jacques GOUSSARD
|
||||
-- <jag@topsn3>
|
||||
---Copyright: Matra Datavision 1991
|
||||
|
||||
|
||||
class IntPoint from IntAna2d inherits Storable from Standard
|
||||
|
||||
---Purpose: Geometrical intersection between two 2d elements.
|
||||
|
||||
|
||||
uses Pnt2d from gp
|
||||
|
||||
raises DomainError from Standard
|
||||
|
||||
is
|
||||
|
||||
Create(X,Y: Real; U1,U2: Real)
|
||||
|
||||
---Purpose: Create an intersection point between 2 parametric 2d lines.
|
||||
-- X,Y are the coordinate of the point. U1 is the parameter
|
||||
-- on the first element, U2 the parameter on the second one.
|
||||
|
||||
returns IntPoint;
|
||||
|
||||
|
||||
Create(X,Y: Real; U1: Real)
|
||||
|
||||
---Purpose: Create an intersection point between a parametric 2d line,
|
||||
-- and a line given by an implicit equation (ImplicitCurve).
|
||||
-- X,Y are the coordinate of the point. U1 is the parameter
|
||||
-- on the parametric element.
|
||||
|
||||
returns IntPoint;
|
||||
|
||||
|
||||
Create
|
||||
|
||||
---Purpose: Empty constructor. It's necessary to use one of
|
||||
-- the SetValue method after this one.
|
||||
|
||||
returns IntPoint;
|
||||
|
||||
|
||||
SetValue(me : in out; X,Y: Real; U1,U2: Real)
|
||||
|
||||
---Purpose: Set the values for a "non-implicit" point.
|
||||
is virtual;
|
||||
|
||||
|
||||
SetValue(me : in out; X,Y:Real; U1: Real)
|
||||
|
||||
---Purpose: Set the values for an "implicit" point.
|
||||
is virtual;
|
||||
|
||||
Value(me)
|
||||
|
||||
---Purpose: Returns the geometric point.
|
||||
---C++: inline
|
||||
---C++: return const&
|
||||
returns Pnt2d from gp
|
||||
|
||||
is static;
|
||||
|
||||
|
||||
SecondIsImplicit(me)
|
||||
|
||||
---Purpose: Returns True if the second curve is implicit.
|
||||
---C++: inline
|
||||
returns Boolean from Standard
|
||||
|
||||
is static;
|
||||
|
||||
|
||||
ParamOnFirst(me)
|
||||
|
||||
---Purpose: Returns the parameter on the first element.
|
||||
---C++: inline
|
||||
returns Real
|
||||
|
||||
is static;
|
||||
|
||||
|
||||
ParamOnSecond(me)
|
||||
|
||||
---Purpose: Returns the parameter on the second element.
|
||||
-- If the second element is an implicit curve, an exception
|
||||
-- is raised.
|
||||
---C++: inline
|
||||
returns Real
|
||||
|
||||
raises DomainError from Standard
|
||||
|
||||
is static;
|
||||
|
||||
|
||||
|
||||
fields
|
||||
|
||||
myu1 : Real from Standard;
|
||||
myu2 : Real from Standard;
|
||||
myp : Pnt2d from gp;
|
||||
myimplicit : Boolean from Standard;
|
||||
|
||||
end IntPoint;
|
48
src/IntAna2d/IntAna2d_IntPoint.cxx
Executable file
48
src/IntAna2d/IntAna2d_IntPoint.cxx
Executable file
@@ -0,0 +1,48 @@
|
||||
// File: IntPoint.cxx
|
||||
// Created: Wed Oct 7 9:43:20 1992
|
||||
// Author: Laurent BUCHARD
|
||||
// <lbr@topsn2>
|
||||
//-Copyright: Matra Datavision 1992
|
||||
|
||||
#include <IntAna2d_IntPoint.ixx>
|
||||
#include <Standard_DomainError.hxx>
|
||||
|
||||
IntAna2d_IntPoint::IntAna2d_IntPoint (const Standard_Real X, const Standard_Real Y,
|
||||
const Standard_Real U1,const Standard_Real U2):
|
||||
myu1(U1),myu2(U2),myp(X,Y),myimplicit(Standard_False)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
IntAna2d_IntPoint::IntAna2d_IntPoint (const Standard_Real X, const Standard_Real Y,
|
||||
const Standard_Real U1):
|
||||
myu1(U1),myp(X,Y),myimplicit(Standard_True)
|
||||
{
|
||||
}
|
||||
|
||||
IntAna2d_IntPoint::IntAna2d_IntPoint ():
|
||||
|
||||
myu1(RealLast()),myu2(RealLast()),myp(RealLast(),RealLast()),myimplicit(Standard_False)
|
||||
{
|
||||
}
|
||||
|
||||
void IntAna2d_IntPoint::SetValue (const Standard_Real X, const Standard_Real Y,
|
||||
const Standard_Real U1, const Standard_Real U2) {
|
||||
|
||||
myimplicit = Standard_False;
|
||||
myp.SetCoord(X,Y);
|
||||
myu1 = U1;
|
||||
myu2 = U2;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void IntAna2d_IntPoint::SetValue (const Standard_Real X, const Standard_Real Y, const Standard_Real U1) {
|
||||
|
||||
myimplicit = Standard_True;
|
||||
myp.SetCoord(X,Y);
|
||||
myu1 = U1;
|
||||
|
||||
}
|
||||
|
||||
|
28
src/IntAna2d/IntAna2d_IntPoint.lxx
Executable file
28
src/IntAna2d/IntAna2d_IntPoint.lxx
Executable file
@@ -0,0 +1,28 @@
|
||||
// File: IntPoint.lxx
|
||||
// Created: Wed Oct 7 9:43:20 1992
|
||||
// Author: Laurent BUCHARD
|
||||
// <lbr@topsn2>
|
||||
//-Copyright: Matra Datavision 1992
|
||||
|
||||
#include <Standard_DomainError.hxx>
|
||||
|
||||
|
||||
inline const gp_Pnt2d& IntAna2d_IntPoint::Value () const {
|
||||
return myp;
|
||||
}
|
||||
|
||||
inline Standard_Real IntAna2d_IntPoint::ParamOnFirst () const {
|
||||
return myu1;
|
||||
}
|
||||
|
||||
inline Standard_Real IntAna2d_IntPoint::ParamOnSecond () const {
|
||||
|
||||
if (myimplicit) {
|
||||
Standard_DomainError::Raise();
|
||||
}
|
||||
return myu2;
|
||||
}
|
||||
|
||||
inline Standard_Boolean IntAna2d_IntPoint::SecondIsImplicit() const {
|
||||
return(myimplicit);
|
||||
}
|
313
src/IntAna2d/IntAna2d_Outils.cxx
Executable file
313
src/IntAna2d/IntAna2d_Outils.cxx
Executable file
@@ -0,0 +1,313 @@
|
||||
//============================================================================
|
||||
//======================================================= IntAna2d_Outils.cxx
|
||||
//============================================================================
|
||||
#include <IntAna2d_Outils.hxx>
|
||||
#include <math_DirectPolynomialRoots.hxx>
|
||||
|
||||
MyDirectPolynomialRoots::MyDirectPolynomialRoots(const Standard_Real A4,
|
||||
const Standard_Real A3,
|
||||
const Standard_Real A2,
|
||||
const Standard_Real A1,
|
||||
const Standard_Real A0) {
|
||||
//-- cout<<" IntAna2d : A4..A0 "<<A4<<" "<<A3<<" "<<A2<<" "<<A1<<" "<<A0<<" "<<endl;
|
||||
nbsol = 0;
|
||||
same = Standard_False;
|
||||
// Modified by Sergey KHROMOV - Thu Oct 24 13:10:14 2002 Begin
|
||||
Standard_Real anAA[5];
|
||||
|
||||
anAA[0] = Abs(A0);
|
||||
anAA[1] = Abs(A1);
|
||||
anAA[2] = Abs(A2);
|
||||
anAA[3] = Abs(A3);
|
||||
anAA[4] = Abs(A4);
|
||||
|
||||
// if((Abs(A4)+Abs(A3)+Abs(A2)+Abs(A1)+Abs(A0))<Epsilon(10000.0)) {
|
||||
if((anAA[0]+anAA[1]+anAA[2]+anAA[3]+anAA[4])<Epsilon(10000.0)) {
|
||||
// Modified by Sergey KHROMOV - Thu Oct 24 13:10:15 2002 End
|
||||
same = Standard_True;
|
||||
return;
|
||||
}
|
||||
Standard_Integer i,j,nbp;
|
||||
for(i=0;i<16;i++) val[i]=RealLast();
|
||||
|
||||
Standard_Real tol = Epsilon(100.0);
|
||||
math_DirectPolynomialRoots MATH_A43210(A4,A3,A2,A1,A0);
|
||||
Standard_Boolean PbPossible = Standard_False;
|
||||
Standard_Integer NbsolPolyComplet = 0;
|
||||
if(MATH_A43210.IsDone()) {
|
||||
nbp = MATH_A43210.NbSolutions();
|
||||
NbsolPolyComplet = nbp;
|
||||
for(i=1;i<=nbp;i++) {
|
||||
Standard_Real x = MATH_A43210.Value(i);
|
||||
//-- cout<<" IntAna2d : x Pol Complet :"<<x<<endl;
|
||||
val[nbsol] = A0 + x*(A1+x*(A2+x*(A3+x*A4)));
|
||||
sol[nbsol] = x;
|
||||
if(val[nbsol]> tol || val[nbsol]<-tol) {
|
||||
PbPossible = Standard_True;
|
||||
}
|
||||
nbsol++;
|
||||
}
|
||||
if(nbp & 1)
|
||||
PbPossible = Standard_True;
|
||||
}
|
||||
else {
|
||||
PbPossible = Standard_True;
|
||||
}
|
||||
//-- On recherche le plus petit coeff entre A4 et A0
|
||||
if(PbPossible) {
|
||||
// Modified by Sergey KHROMOV - Thu Oct 24 12:45:35 2002 Begin
|
||||
Standard_Real anAMin = RealLast();
|
||||
Standard_Real anAMax = -1;
|
||||
Standard_Real anEps = RealEpsilon();
|
||||
|
||||
for (i = 0; i < 5; i++) {
|
||||
anAMin = Min(anAMin, Max(anAA[i], anEps));
|
||||
anAMax = Max(anAMax, Max(anAA[i], anEps));
|
||||
}
|
||||
|
||||
anEps = Min(1.e-4, Epsilon(1000.*anAMax/anAMin));
|
||||
// Modified by Sergey KHROMOV - Thu Oct 24 15:46:24 2002 End
|
||||
math_DirectPolynomialRoots MATH_A4321(A4,A3,A2,A1);
|
||||
if(MATH_A4321.IsDone()) {
|
||||
nbp = MATH_A4321.NbSolutions();
|
||||
//-- On Ajoute les valeurs au tableau
|
||||
for(i=1;i<=nbp;i++) {
|
||||
Standard_Real x = MATH_A4321.Value(i);
|
||||
Standard_Boolean Add = Standard_True;
|
||||
for(j=0;j<nbsol;j++) {
|
||||
Standard_Real t = sol[j]-x;
|
||||
// Modified by Sergey KHROMOV - Thu Oct 24 12:04:26 2002 Begin
|
||||
// if(Abs(t)<tol) {
|
||||
if(Abs(t) < anEps) {
|
||||
// Modified by Sergey KHROMOV - Thu Oct 24 12:04:47 2002 End
|
||||
Add = Standard_False;
|
||||
}
|
||||
}
|
||||
if(Add) {
|
||||
val[nbsol] = A0 + x*(A1+x*(A2+x*(A3+x*A4)));
|
||||
sol[nbsol] = x;
|
||||
nbsol++;
|
||||
}
|
||||
}
|
||||
}
|
||||
math_DirectPolynomialRoots MATH_A3210(A3,A2,A1,A0);
|
||||
if(MATH_A3210.IsDone()) {
|
||||
nbp = MATH_A3210.NbSolutions();
|
||||
//-- On Ajoute les valeurs au tableau
|
||||
for(i=1;i<=nbp;i++) {
|
||||
Standard_Real x = MATH_A3210.Value(i);
|
||||
Standard_Boolean Add = Standard_True;
|
||||
for(j=0;j<nbsol;j++) {
|
||||
Standard_Real t = sol[j]-x;
|
||||
// Modified by Sergey KHROMOV - Thu Oct 24 12:06:01 2002 Begin
|
||||
// if(Abs(t)<tol) {
|
||||
if(Abs(t) < anEps) {
|
||||
// Modified by Sergey KHROMOV - Thu Oct 24 12:06:04 2002 End
|
||||
Add = Standard_False;
|
||||
}
|
||||
}
|
||||
if(Add) {
|
||||
val[nbsol] = A0 + x*(A1+x*(A2+x*(A3+x*A4)));
|
||||
sol[nbsol] = x;
|
||||
nbsol++;
|
||||
}
|
||||
}
|
||||
}
|
||||
math_DirectPolynomialRoots MATH_A210(A3,A2,A1);
|
||||
if(MATH_A210.IsDone()) {
|
||||
nbp = MATH_A210.NbSolutions();
|
||||
//-- On Ajoute les valeurs au tableau
|
||||
for(i=1;i<=nbp;i++) {
|
||||
Standard_Real x = MATH_A210.Value(i);
|
||||
Standard_Boolean Add = Standard_True;
|
||||
for(j=0;j<nbsol;j++) {
|
||||
Standard_Real t = sol[j]-x;
|
||||
// Modified by Sergey KHROMOV - Thu Oct 24 12:07:04 2002 Begin
|
||||
// if(Abs(t)<tol) {
|
||||
if(Abs(t) < anEps) {
|
||||
// Modified by Sergey KHROMOV - Thu Oct 24 12:07:06 2002 End
|
||||
Add = Standard_False;
|
||||
}
|
||||
}
|
||||
if(Add) {
|
||||
val[nbsol] = A0 + x*(A1+x*(A2+x*(A3+x*A4)));
|
||||
sol[nbsol] = x;
|
||||
nbsol++;
|
||||
}
|
||||
}
|
||||
}
|
||||
//------------------------------------------------------------
|
||||
//-- On trie les valeurs par ordre decroissant de val
|
||||
//-- for(i=0;i<nbsol;i++) {
|
||||
//-- cout<<" IntAna2d Sol,Val"<<sol[i]<<" "<<val[i]<<endl;
|
||||
//-- }
|
||||
Standard_Boolean TriOK = Standard_False;
|
||||
do {
|
||||
TriOK = Standard_True;
|
||||
for(i=1; i<nbsol;i++) {
|
||||
if(Abs(val[i])<Abs(val[i-1])) {
|
||||
Standard_Real t;
|
||||
t = val[i];
|
||||
val[i] = val[i-1];
|
||||
val[i-1] = t;
|
||||
t = sol[i];
|
||||
sol[i] = sol[i-1];
|
||||
sol[i-1] = t;
|
||||
TriOK = Standard_False;
|
||||
}
|
||||
}
|
||||
}
|
||||
while(!TriOK);
|
||||
//-----------------------------------------------------------
|
||||
//-- On garde les premieres valeurs
|
||||
//-- Au moins autant que le polynome Complet
|
||||
//--
|
||||
for(nbsol=0; nbsol<NbsolPolyComplet || Abs(val[nbsol])<Epsilon(10000.0); nbsol++) ;
|
||||
//-- cout<<" IntAna2d : nbsol:"<<nbsol<<endl;
|
||||
}
|
||||
if(nbsol==0) {
|
||||
nbsol=-1;
|
||||
}
|
||||
if(nbsol>4) {
|
||||
same=1;
|
||||
nbsol=0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
MyDirectPolynomialRoots::MyDirectPolynomialRoots(const Standard_Real A2,
|
||||
const Standard_Real A1,
|
||||
const Standard_Real A0) {
|
||||
//-- cout<<" IntAna2d : A2..A0 "<<A2<<" "<<A1<<" "<<A0<<" "<<endl;
|
||||
nbsol=0;
|
||||
if((Abs(A2)+Abs(A1)+Abs(A0))<Epsilon(10000.0)) {
|
||||
same = Standard_True;
|
||||
return;
|
||||
}
|
||||
math_DirectPolynomialRoots MATH_A210(A2,A1,A0);
|
||||
same = Standard_False;
|
||||
if(MATH_A210.IsDone()) {
|
||||
for(Standard_Integer i=1;i<=MATH_A210.NbSolutions(); i++) {
|
||||
Standard_Real x = MATH_A210.Value(i);
|
||||
val[nbsol] = A0 + x*(A1+x*A2);
|
||||
sol[nbsol] = x;
|
||||
//-- cout<<" IntAna2d : x Pol Complet :"<<x<<" Val:"<<val[nbsol]<<endl;
|
||||
nbsol++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
nbsol = -1;
|
||||
}
|
||||
}
|
||||
|
||||
Standard_Boolean Points_Confondus(const Standard_Real x1,const Standard_Real y1
|
||||
,const Standard_Real x2,const Standard_Real y2) {
|
||||
if(Abs(x1-x2)<Epsilon(x1)) {
|
||||
if(Abs(y1-y2)<Epsilon(y1)) {
|
||||
return(Standard_True);
|
||||
}
|
||||
}
|
||||
return(Standard_False);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//--- Les points confondus sont supprimes
|
||||
//--- Le nombre de points est mis a jour
|
||||
|
||||
void Traitement_Points_Confondus(Standard_Integer& nb_pts,
|
||||
IntAna2d_IntPoint* pts) {
|
||||
Standard_Integer i,j;
|
||||
for(i=nb_pts;i>1;i--) {
|
||||
Standard_Boolean Non_Egalite=Standard_True;
|
||||
for(j=i-1;(j>0) && Non_Egalite;j--) {
|
||||
// <--- Deja Teste --->
|
||||
// | 1 |2 | | J | |I-1| I |I+1| |NPTS|
|
||||
// | 1 |2 | | J | |I-1|XXX|I+1| |NPTS|
|
||||
// | 1 |2 | | J | |I-1|I+1|I+2| |NPTS|
|
||||
if(Points_Confondus(pts[i-1].Value().X(),
|
||||
pts[i-1].Value().Y(),
|
||||
pts[j-1].Value().X(),
|
||||
pts[j-1].Value().Y())) {
|
||||
Standard_Integer k;
|
||||
Non_Egalite=Standard_False;
|
||||
for(k=i;k<nb_pts;k++) {
|
||||
Standard_Real Xk,Yk,Uk;
|
||||
Xk=pts[k].Value().X();
|
||||
Yk=pts[k].Value().Y();
|
||||
Uk=pts[k].ParamOnFirst();
|
||||
pts[k-1].SetValue(Xk,Yk,Uk);
|
||||
}
|
||||
nb_pts--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void Coord_Ancien_Repere(Standard_Real& x1,Standard_Real& y1,const gp_Ax2d Dir1) {
|
||||
Standard_Real t11,t12,t21,t22,t13,t23;
|
||||
Standard_Real x0,y0;
|
||||
|
||||
// x1 et y1 Sont les Coordonnees dans le repere lie a Dir1
|
||||
// On Renvoie ces Coordonnees dans le repere "absolu"
|
||||
|
||||
Dir1.Direction().Coord(t11,t21);
|
||||
Dir1.Location().Coord(t13,t23);
|
||||
|
||||
t22=t11;
|
||||
t12=-t21;
|
||||
|
||||
x0= t11*x1 + t12*y1 + t13;
|
||||
y0= t21*x1 + t22*y1 + t23;
|
||||
|
||||
x1=x0;
|
||||
y1=y0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if 0
|
||||
|
||||
//-- A Placer dans les ressources de la classe Conic ??
|
||||
//-----------------------------------------------------------------------------
|
||||
//--- Calcul des Coefficients A,..F dans le repere lie a Dir1
|
||||
//--- A Partir des Coefficients dans le repere "Absolu"
|
||||
|
||||
void Coeff_Nouveau_Repere(Standard_Real& A,Standard_Real& B,Standard_Real& C
|
||||
,Standard_Real& D,Standard_Real& E,Standard_Real& F
|
||||
,const gp_Ax2d Dir1) {
|
||||
Standard_Real t11,t12,t13; // x = t11 X + t12 Y + t13
|
||||
Standard_Real t21,t22,t23; // y = t21 X + t22 Y + t23
|
||||
Standard_Real A1,B1,C1,D1,E1,F1;
|
||||
|
||||
// On a P0(x,y)=A x x + B y y + ... + F =0 (x et y ds le repere "Absolu")
|
||||
// et on cherche P1(X(x,y),Y(x,y))=P0(x,y)
|
||||
// Avec P1(X,Y)= A1 X X + B1 Y Y + 2 C1 X Y + 2 D1 X + 2 E1 Y + F1
|
||||
// = A x x + B y y + 2 C x y + 2 D x + 2 E y + f
|
||||
|
||||
Dir1.Direction().Coord(t11,t21);
|
||||
Dir1.Location().Coord(t13,t23);
|
||||
|
||||
t22=t11;
|
||||
t12=-t21;
|
||||
|
||||
A1=(t11*(A*t11 + 2*C*t21) + B*t21*t21);
|
||||
B1=(t12*(A*t12 + 2*C*t22) + B*t22*t22);
|
||||
C1=(t12*(A*t11 + C*t21) + t22*(C*t11 + B*t21));
|
||||
D1=(t11*(D + A*t13) + t21*(E + C*t13) + t23*(C*t11 + B*t21));
|
||||
E1=(t12*(D + A*t13) + t22*(E + C*t13) + t23*(C*t12 + B*t22));
|
||||
F1=F + t13*(2.0*D + A*t13) + t23*(2.0*E + 2.0*C*t13 + B*t23);
|
||||
|
||||
A=A1; B=B1; C=C1; D=D1; E=E1; F=F1;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
63
src/IntAna2d/IntAna2d_Outils.hxx
Executable file
63
src/IntAna2d/IntAna2d_Outils.hxx
Executable file
@@ -0,0 +1,63 @@
|
||||
//============================================================================
|
||||
//======================================================= IntAna2d_Outils.hxx
|
||||
//============================================================================
|
||||
#ifndef IntAna2d_Outil_HeaderFile
|
||||
#define IntAna2d_Outil_HeaderFile
|
||||
|
||||
#ifndef math_DirectPolynomialRoots_HeaderFile
|
||||
#include <math_DirectPolynomialRoots.hxx>
|
||||
#endif
|
||||
|
||||
#ifndef math_TrigonometricFunctionRoots_HeaderFile
|
||||
#include <math_TrigonometricFunctionRoots.hxx>
|
||||
#endif
|
||||
|
||||
#ifndef IntAna2d_IntPoint_HeaderFile
|
||||
#include <IntAna2d_IntPoint.hxx>
|
||||
#endif
|
||||
|
||||
#ifndef gp_Ax2d_HeaderFile
|
||||
#include <gp_Ax2d.hxx>
|
||||
#endif
|
||||
|
||||
class MyDirectPolynomialRoots {
|
||||
public:
|
||||
MyDirectPolynomialRoots(const Standard_Real A4,
|
||||
const Standard_Real A3,
|
||||
const Standard_Real A2,
|
||||
const Standard_Real A1,
|
||||
const Standard_Real A0);
|
||||
|
||||
MyDirectPolynomialRoots(const Standard_Real A2,
|
||||
const Standard_Real A1,
|
||||
const Standard_Real A0);
|
||||
|
||||
Standard_Integer NbSolutions() const { return(nbsol); }
|
||||
Standard_Real Value(const Standard_Integer i) const { return(sol[i-1]); }
|
||||
Standard_Real IsDone() const { return(nbsol>-1); }
|
||||
Standard_Boolean InfiniteRoots() const { return(same); }
|
||||
private:
|
||||
Standard_Real sol[16];
|
||||
Standard_Real val[16];
|
||||
Standard_Integer nbsol;
|
||||
Standard_Boolean same;
|
||||
};
|
||||
|
||||
|
||||
Standard_Boolean Points_Confondus(const Standard_Real xa,const Standard_Real ya,
|
||||
const Standard_Real xb,const Standard_Real yb);
|
||||
|
||||
|
||||
|
||||
void Traitement_Points_Confondus(Standard_Integer& nb_pts
|
||||
,IntAna2d_IntPoint *pts);
|
||||
|
||||
void Coord_Ancien_Repere(Standard_Real& Ancien_X,Standard_Real& Ancien_Y
|
||||
,const gp_Ax2d Axe_Nouveau_Repere);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user