1
0
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:
bugmaster
2011-03-16 07:30:28 +00:00
committed by bugmaster
parent 4903637061
commit 7fd59977df
16375 changed files with 3882564 additions and 0 deletions

3
src/IntImpParGen/FILES Executable file
View File

@@ -0,0 +1,3 @@
IntImpParGen_Tool.cxx
IntImpParGen_Tool.cxx
IntImpParGen_Tool.hxx

View File

@@ -0,0 +1,69 @@
-- File: IntImpParGen.cdl
-- Created: Mon Mar 2 10:07:38 1992
-- Author: Laurent BUCHARD
-- <lbr@phobox>
---Copyright: Matra Datavision 1992
package IntImpParGen
---Purpose: Gives a generic algorithm to intersect Implicit Curves
-- and Bounded Parametric Curves.
--
-- Level: Internal
--
-- All the methods of all the classes are Internal.
uses Standard, TColStd, gp, math, IntRes2d, StdFail
is
deferred class ImpTool;
---Purpose: Template class for an implicit curve.
deferred generic class ParTool;
---Purpose: Template class for a tool on a parameterised curve.
generic class ImpParTool;
---Purpose: Math function, instantiated inside the Intersector.
generic class Intersector,MyImpParTool;
---Purpose: Tool used by the package IntCurve and IntImpParGen
DetermineTransition(Pos1 : Position from IntRes2d;
Tan1 : in out Vec2d from gp;
Norm1 : Vec2d from gp;
Trans1: in out Transition from IntRes2d;
Pos2 : Position from IntRes2d;
Tan2 : in out Vec2d from gp;
Norm2 : Vec2d from gp;
Trans2: in out Transition from IntRes2d;
Tol : Real from Standard);
DetermineTransition(Pos1 : Position from IntRes2d;
Tan1 : in out Vec2d from gp;
Trans1: in out Transition from IntRes2d;
Pos2 : Position from IntRes2d;
Tan2 : in out Vec2d from gp;
Trans2: in out Transition from IntRes2d;
Tol : Real from Standard)
returns Boolean from Standard;
DeterminePosition( Pos1 : in out Position from IntRes2d;
Dom1 : Domain from IntRes2d;
P1 : Pnt2d from gp;
Tol : Real from Standard);
NormalizeOnDomain( Par1 : in out Real from Standard;
Dom1 : Domain from IntRes2d)
returns Real from Standard;
end IntImpParGen;

220
src/IntImpParGen/IntImpParGen.cxx Executable file
View File

@@ -0,0 +1,220 @@
// File: IntImpParGen_Tool.hxx
// Created: Wed Jun 10 15:04:00 1992
// Author: Laurent BUCHARD
// <lbr@sdsun2>
#include <IntImpParGen.ixx>
#include <IntRes2d_Domain.hxx>
#include <IntRes2d_Position.hxx>
#include <IntRes2d_Transition.hxx>
#include <gp_Vec2d.hxx>
#include <gp_Pnt2d.hxx>
#include <IntImpParGen_Tool.hxx>
#include <gp.hxx>
#define TOLERANCE_ANGULAIRE 0.00000001
#define DERIVEE_PREMIERE_NULLE 0.000000000001
//----------------------------------------------------------------------
Standard_Real IntImpParGen::NormalizeOnDomain(Standard_Real& Param,
const IntRes2d_Domain& TheDomain) {
Standard_Real modParam = Param;
if(TheDomain.IsClosed()) {
Standard_Real Periode,t;
TheDomain.EquivalentParameters(t,Periode);
Periode-=t;
while( modParam<TheDomain.FirstParameter()
&& modParam+Periode < TheDomain.LastParameter()) {
modParam+=Periode;
}
while( modParam>TheDomain.LastParameter()
&& modParam-Periode > TheDomain.FirstParameter()) {
modParam-=Periode;
}
}
return(modParam);
}
//----------------------------------------------------------------------
void IntImpParGen::DeterminePosition(IntRes2d_Position& Pos1,
const IntRes2d_Domain& TheDomain,
const gp_Pnt2d& Pnt1,
const Standard_Real Param1) {
Pos1=IntRes2d_Middle;
if(TheDomain.HasFirstPoint()) {
if(Pnt1.Distance(TheDomain.FirstPoint())
<= TheDomain.FirstTolerance()) {
Pos1=IntRes2d_Head;
}
}
if(TheDomain.HasLastPoint()) {
if(Pnt1.Distance(TheDomain.LastPoint())
<= TheDomain.LastTolerance()) {
if(Pos1==IntRes2d_Head) {
if(Abs(Param1-TheDomain.LastParameter())
< Abs(Param1-TheDomain.FirstParameter()))
Pos1=IntRes2d_End;
}
else {
Pos1=IntRes2d_End;
}
}
}
}
//----------------------------------------------------------------------
void IntImpParGen::DetermineTransition(const IntRes2d_Position Pos1,
gp_Vec2d& Tan1,
const gp_Vec2d& Norm1,
IntRes2d_Transition& T1,
const IntRes2d_Position Pos2,
gp_Vec2d& Tan2,
const gp_Vec2d& Norm2,
IntRes2d_Transition& T2,
const Standard_Real ) {
Standard_Boolean courbure1=Standard_True;
Standard_Boolean courbure2=Standard_True;
Standard_Boolean decide=Standard_True;
T1.SetPosition(Pos1);
T2.SetPosition(Pos2);
if (Tan1.SquareMagnitude()<=DERIVEE_PREMIERE_NULLE) {
Tan1=Norm1;
courbure1=Standard_False;
if (Tan1.SquareMagnitude()<=DERIVEE_PREMIERE_NULLE) { // transition undecided
decide=Standard_False;
}
}
if (Tan2.SquareMagnitude()<=DERIVEE_PREMIERE_NULLE) {
Tan2=Norm2;
courbure2=Standard_False;
if (Tan2.SquareMagnitude()<=DERIVEE_PREMIERE_NULLE) { // transition undecided
decide=Standard_False;
}
}
if (!decide) {
T1.SetValue(Pos1);
T2.SetValue(Pos2);
}
else {
Standard_Real sgn=Tan1.Crossed(Tan2);
Standard_Real norm=Tan1.Magnitude()*Tan2.Magnitude();
if (Abs(sgn)<=TOLERANCE_ANGULAIRE*norm) { // Transition TOUCH #########
Standard_Boolean opos=(Tan1.Dot(Tan2))<0;
if (!(courbure1||courbure2)) {
T1.SetValue(Standard_True,Pos1,IntRes2d_Unknown,opos);
T2.SetValue(Standard_True,Pos2,IntRes2d_Unknown,opos);
}
else {
gp_Vec2d Norm;
Tan1.Normalized();
Norm.SetCoord(-Tan1.Y(),Tan1.X());
Standard_Real Val1,Val2;
if (!courbure1) {
Val1=0.0;
}
else {
Val1=Norm.Dot(Norm1);
}
if (!courbure2) {
Val2=0.0;
}
else {
Val2=Norm.Dot(Norm2);
}
if (Abs(Val1-Val2) <= TOLERANCE_ANGULAIRE) {
T1.SetValue(Standard_True,Pos1,IntRes2d_Unknown,opos);
T2.SetValue(Standard_True,Pos2,IntRes2d_Unknown,opos);
}
else if (Val2 > Val1) {
T2.SetValue(Standard_True,Pos2,IntRes2d_Inside,opos);
if (opos) {
T1.SetValue(Standard_True,Pos1,IntRes2d_Inside,opos);
}
else {
T1.SetValue(Standard_True,Pos1,IntRes2d_Outside,opos);
}
}
else { // Val1 > Val2
T2.SetValue(Standard_True,Pos2,IntRes2d_Outside,opos);
if (opos) {
T1.SetValue(Standard_True,Pos1,IntRes2d_Outside,opos);
}
else {
T1.SetValue(Standard_True,Pos1,IntRes2d_Inside,opos);
}
}
}
}
else if (sgn<0) {
T1.SetValue(Standard_False,Pos1,IntRes2d_In);
T2.SetValue(Standard_False,Pos2,IntRes2d_Out);
}
else { // sgn>0
T1.SetValue(Standard_False,Pos1,IntRes2d_Out);
T2.SetValue(Standard_False,Pos2,IntRes2d_In);
}
}
}
//----------------------------------------------------------------------
Standard_Boolean IntImpParGen::DetermineTransition(const IntRes2d_Position Pos1,
gp_Vec2d& Tan1,
IntRes2d_Transition& T1,
const IntRes2d_Position Pos2,
gp_Vec2d& Tan2,
IntRes2d_Transition& T2,
const Standard_Real ) {
T1.SetPosition(Pos1);
T2.SetPosition(Pos2);
Standard_Real Tan1Magnitude = Tan1.Magnitude();
if (Tan1Magnitude<=DERIVEE_PREMIERE_NULLE) {
return(Standard_False);
}
Standard_Real Tan2Magnitude = Tan2.Magnitude();
if (Tan2Magnitude<=DERIVEE_PREMIERE_NULLE) {
return(Standard_False);
}
Standard_Real sgn=Tan1.Crossed(Tan2);
Standard_Real norm=Tan1Magnitude*Tan2Magnitude;
if (Abs(sgn)<=TOLERANCE_ANGULAIRE*norm) { // Transition TOUCH #########
return(Standard_False);
}
else if (sgn<0) {
T1.SetValue(Standard_False,Pos1,IntRes2d_In);
T2.SetValue(Standard_False,Pos2,IntRes2d_Out);
}
else { // sgn>0
T1.SetValue(Standard_False,Pos1,IntRes2d_Out);
T2.SetValue(Standard_False,Pos2,IntRes2d_In);
}
return(Standard_True);
}

View File

@@ -0,0 +1,66 @@
-- File: ImpParTool.cdl
-- Created: Mon Mar 30 18:19:14 1992
-- Author: Laurent BUCHARD
-- <lbr@topsn3>
---Copyright: Matra Datavision 1992
generic class ImpParTool from IntImpParGen (
ImpTool as any; -- as ImpTool from IntImpParGen
ParCurve as any;
ParTool as any) -- as ParTool from IntImpParGen(ParCurve)
inherits FunctionWithDerivative from math
---Purpose: Implements the function used by FunctionAllRoots
-- to find the areas where the distance between the
-- implicit and the parametric curves is less than a
-- tolerance.
uses Pnt2d from gp,
Vec2d from gp
is
Create(IT: ImpTool; PC: ParCurve)
---Purpose: Constructor of the class.
returns ImpParTool from IntImpParGen;
Value(me: in out; Param: Real from Standard; F: out Real from Standard)
---Purpose: Computes the value of the signed distance between
-- the implicit curve and the point at parameter Param
-- on the parametrised curve.
returns Boolean from Standard
is redefined static;
Derivative(me: in out; Param: Real from Standard;
D: out Real from Standard)
---Purpose: Computes the derivative of the previous function at
-- parameter Param.
returns Boolean from Standard
is redefined static;
Values(me: in out; Param: Real from Standard; F,D: out Real from Standard)
---Purpose: Computes the value and the derivative of the function.
returns Boolean from Standard
is redefined static;
fields
TheParCurve : Address from Standard;
TheImpTool : ImpTool;
end ImpParTool;

View File

@@ -0,0 +1,43 @@
#include <gp_Vec2d.hxx>
IntImpParGen_ImpParTool::IntImpParGen_ImpParTool(const ImpTool& ITool,
const ParCurve& PC):
TheImpTool(ITool)
{
TheParCurve = (Standard_Address)(&PC);
}
Standard_Boolean IntImpParGen_ImpParTool::Value(const Standard_Real Param,
Standard_Real& ApproxDistance) {
ApproxDistance = TheImpTool.Distance(ParTool::Value((*((ParCurve *)(TheParCurve))),Param));
return(Standard_True);
}
Standard_Boolean IntImpParGen_ImpParTool::Derivative(const Standard_Real Param,
Standard_Real& D_ApproxDistance_DV) {
gp_Pnt2d Pt;
gp_Vec2d TanParCurve;
gp_Vec2d Grad=TheImpTool.GradDistance(ParTool::Value((*((ParCurve *)(TheParCurve))),Param));
ParTool::D1((*((ParCurve *)(TheParCurve))),Param,Pt,TanParCurve);
D_ApproxDistance_DV = Grad.Dot(TanParCurve);
return(Standard_True);
}
Standard_Boolean IntImpParGen_ImpParTool::Values(const Standard_Real Param,
Standard_Real& ApproxDistance,
Standard_Real& Deriv) {
this->Value(Param,ApproxDistance);
this->Derivative(Param,Deriv);
return(Standard_True);
}

View File

@@ -0,0 +1,86 @@
-- File: ImpTool.cdl
-- Created: Thu Mar 26 14:24:05 1992
-- Author: Laurent BUCHARD
-- <lbr@topsn3>
---Copyright: Matra Datavision 1992
deferred class ImpTool from IntImpParGen
---Purpose: Template class for an implicit curve.
uses Pnt2d from gp,
Vec2d from gp
is
Value (me; U: Real from Standard)
--Purpose: Computes the point at parameter U on the
-- Implicit Curve.
returns Pnt2d from gp
is static;
D1 (me; U: Real from Standard ; P: out Pnt2d; T: out Vec2d)
--Purpose: Computes the first derivative and the point on the
-- implicit curve at parameter U.
is static;
D2 (me; U: Real from Standard ; P: out Pnt2d; T,N: out Vec2d)
--Purpose: Computes the first, the second derivatives
-- and the point on the implicit curve at parameter U.
is static;
Distance(me; P: Pnt2d from gp)
---Purpose: Computes the value of the signed distance between
-- the point P and the implicit curve.
--
returns Real from Standard
is static;
GradDistance(me; P: Pnt2d from gp)
---Purpose: Computes the Gradient of the Signed Distance
-- between a point and the implicit curve, at the
-- point P.
--
returns Vec2d from gp
is static;
FindParameter(me; P: Pnt2d from gp)
---Purpose: Returns the parameter U of the point on the
-- implicit curve corresponding to the point P.
-- The correspondance between P and the point P(U) on
-- the implicit curve must be coherent with the way
-- of determination of the signed distance.
returns Real from Standard
is static;
end ImpTool;

View File

@@ -0,0 +1 @@
#include <IntImpParGen_ImpTool.ixx>

View File

@@ -0,0 +1,130 @@
-- File: Intersector.cdl
-- Created: Mon Mar 2 10:41:48 1992
-- Author: Laurent BUCHARD
-- <lbr@phobox>
---Copyright: Matra Datavision 1992
generic class Intersector from IntImpParGen (
ImpTool as any; -- as ImpTool from IntImpParGen
ParCurve as any;
ParTool as any; -- as ParTool from IntImpParGen(ParCurve)
ProjectOnPCurveTool as any) -- as ProjectOnPCurveToolGen from IntCurve
inherits Intersection from IntRes2d
---Purpose: Calculates all the IntersectionPoints
-- and IntersectionSegments between an implicit curve
-- (see class ImpTool) and a parametrised curve (see class
-- ParTool) on their domains.
-- The results of the intersection are stored in the
-- Intersection class from IntRes2d.
-- The parametrised curve has to be bounded (the domain
-- of this curve must verify HasFirstPoint returns True
-- and HasLastPoint returns True).
uses IntersectionPoint from IntRes2d,
IntersectionSegment from IntRes2d,
SequenceOfIntersectionPoint from IntRes2d,
SequenceOfIntersectionSegment from IntRes2d,
Domain from IntRes2d,
Pnt2d from gp,
Array1OfReal from TColStd
raises ConstructionError from Standard
class MyImpParTool instantiates ImpParTool from IntImpParGen(
ImpTool,
ParCurve,
ParTool);
is
Create
---Purpose: Empty constructor.
returns Intersector from IntImpParGen;
Create ( ITool : ImpTool;
Dom1 : Domain from IntRes2d;
PCurve : ParCurve;
Dom2 : Domain from IntRes2d;
TolConf,Tol: Real from Standard)
---Purpose: Intersection between an implicit curve and
-- a parametrised curve.
-- The exception ConstructionError is raised if the domain
-- of the parametrised curve does not verify HasFirstPoint
-- and HasLastPoint return True.
returns Intersector from IntImpParGen
raises ConstructionError from Standard;
Perform (me: in out;
ITool : ImpTool;
Dom1 : Domain from IntRes2d;
PCurve : ParCurve;
Dom2 : Domain from IntRes2d;
TolConf,Tol: Real from Standard)
---Purpose: Intersection between an implicit curve and
-- a parametrised curve.
-- The exception ConstructionError is raised if the domain
-- of the parametrised curve does not verify HasFirstPoint
-- and HasLastPoint return True.
raises ConstructionError from Standard
is static;
FindU ( me ;
parameter : Real from Standard ;
point : in out Pnt2d from gp;
TheParCurev : ParCurve;
TheImpTool : ImpTool)
returns Real from Standard
is static ;
FindV ( me ;
parameter : Real from Standard ;
point : in out Pnt2d from gp ;
TheImpTool : ImpTool ;
ParCurve : ParCurve ;
TheParCurveDomain : Domain from IntRes2d ;
V0 : Real from Standard ;
V1 : Real from Standard ;
Tolerance : Real from Standard )
returns Real from Standard
is static;
And_Domaine_Objet1_Intersections ( me ;
TheImpTool : ImpTool ;
TheParCurve : ParCurve ;
TheImpCurveDomain : Domain from IntRes2d ;
TheParCurveDomain : Domain from IntRes2d ;
NbResultats : in out Integer from Standard ;
Inter2_And_Domain2 : in out Array1OfReal from TColStd ;
Inter1 : in out Array1OfReal from TColStd ;
Resultat1 : in out Array1OfReal from TColStd ;
Resultat2 : in out Array1OfReal from TColStd ;
EpsNul : Real from Standard )
is static;
end Intersector;

View File

@@ -0,0 +1,701 @@
// File : IntImpParGen_Intersector.gxx
// Created : Mon Mar 2 14:00:00 1992
// Author : Laurent BUCHARD
// <lbr@phobox>
// Copyright: Matra Datavision 1992
#include <Standard_ConstructionError.hxx>
#include <IntRes2d_Domain.hxx>
#include <IntRes2d_IntersectionPoint.hxx>
#include <IntRes2d_IntersectionSegment.hxx>
#include <IntRes2d_SequenceOfIntersectionPoint.hxx>
#include <IntRes2d_SequenceOfIntersectionSegment.hxx>
#include <IntRes2d_Transition.hxx>
#include <IntRes2d_Position.hxx>
#include <IntImpParGen.hxx>
#include <math_FunctionSample.hxx>
#include <math_FunctionAllRoots.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <gp.hxx>
#include <gp_Vec2d.hxx>
//======================================================================
#define EPSDIST Tol
#define EPSNUL TolConf
#define EPSX ParTool::EpsX(TheParCurve)
#define NB_ECHANTILLONS
static Standard_Real PIpPI = Standard_PI+Standard_PI;
//======================================================================
void IntImpParGen_Intersector::And_Domaine_Objet1_Intersections(const ImpTool& TheImpTool,
const ParCurve& TheParCurve,
const IntRes2d_Domain& TheImpCurveDomain,
const IntRes2d_Domain& TheParCurveDomain,
Standard_Integer& NbResultats,
TColStd_Array1OfReal& Inter2_And_Domain2,
TColStd_Array1OfReal& Inter1,
TColStd_Array1OfReal& Resultat1,
TColStd_Array1OfReal& Resultat2,
const Standard_Real EpsNul) const {
Standard_Integer Nb_Bornes_Intersection=NbResultats;
NbResultats=0;
for(Standard_Integer i=1; i<=Nb_Bornes_Intersection; i+=2) {
Standard_Boolean reverse=Standard_False;
Standard_Real param1=Inter1.Value(i);
Standard_Real param2=Inter1.Value(i+1);
Standard_Integer indice_1=i;
Standard_Integer indice_2=i+1;
if(param1>param2) {
Standard_Real t=param1; param1=param2; param2=t;
indice_1=i+1;
indice_2=i;
reverse=Standard_True;
}
gp_Pnt2d Pt1=TheImpTool.Value(param1);
gp_Pnt2d Pt2=TheImpTool.Value(param2);
gp_Pnt2d Pt;
Standard_Boolean IsOnTheImpCurveDomain1=Standard_True;
Standard_Boolean IsOnABoundary1=Standard_False;
Standard_Boolean IsOnTheImpCurveDomain2=Standard_True;
Standard_Boolean IsOnABoundary2=Standard_False;
//--------------------------------------------------------------------
if(TheImpCurveDomain.HasFirstPoint()) {
if(param1<TheImpCurveDomain.FirstParameter()) {
if(Pt1.Distance(TheImpCurveDomain.FirstPoint())
> TheImpCurveDomain.FirstTolerance()) {
IsOnTheImpCurveDomain1=Standard_False;
}
else { IsOnABoundary1=Standard_True; }
}
}
if(IsOnTheImpCurveDomain1 && TheImpCurveDomain.HasLastPoint()) {
if(param1>TheImpCurveDomain.LastParameter()) {
if(Pt1.Distance(TheImpCurveDomain.LastPoint())
> TheImpCurveDomain.FirstTolerance()) {
IsOnTheImpCurveDomain1=Standard_False;
}
else { IsOnABoundary1=Standard_True; }
}
}
//--------------------------------------------------------------------
if(TheImpCurveDomain.HasFirstPoint()) {
if(param2<TheImpCurveDomain.FirstParameter()) {
if(Pt2.Distance(TheImpCurveDomain.FirstPoint())
> TheImpCurveDomain.FirstTolerance()) {
IsOnTheImpCurveDomain2=Standard_False;
}
else { IsOnABoundary2=Standard_True; }
}
}
if(IsOnTheImpCurveDomain2 && TheImpCurveDomain.HasLastPoint()) {
if(param2>TheImpCurveDomain.LastParameter()) {
if(Pt2.Distance(TheImpCurveDomain.LastPoint())
> TheImpCurveDomain.FirstTolerance()) {
IsOnTheImpCurveDomain2=Standard_False;
}
else { IsOnABoundary2=Standard_True; }
}
}
if(IsOnTheImpCurveDomain1) {
//------------------------------------------------------------------
//--- la borne 1 est sur le domaine --
NbResultats++;
Resultat1.SetValue(NbResultats,Inter1.Value(indice_1));
Resultat2.SetValue(NbResultats,Inter2_And_Domain2.Value(indice_1));
//--- la borne2 est aussi sur le domaine ---
if(IsOnTheImpCurveDomain2) {
NbResultats++;
Resultat1.SetValue(NbResultats,Inter1.Value(indice_2));
Resultat2.SetValue(NbResultats,Inter2_And_Domain2.Value(indice_2));
}
else {
//--- Borne1 sur domaine et Borne 2 Hors Domaine ---
Standard_Real t;
NbResultats++;
t=TheImpCurveDomain.LastParameter();
Resultat1.SetValue(NbResultats,t);
// Standard_Real popResult = FindV(t,Pt,TheImpTool,TheParCurve,
// TheParCurveDomain,
// Inter2_And_Domain2.Value(indice_1),
// Inter2_And_Domain2.Value(indice_2),
// EpsNul);
//
// Resultat2.SetValue(NbResultats,popResult);
Resultat2.SetValue(NbResultats,
IntImpParGen_Intersector::FindV(t,Pt,TheImpTool,TheParCurve,
TheParCurveDomain,
Inter2_And_Domain2.Value(indice_1),
Inter2_And_Domain2.Value(indice_2),
EpsNul));
}
}
else { //======= la borne1 n est pas sur le domaine ========
if(IsOnTheImpCurveDomain2) {
Standard_Real t;
NbResultats++;
t=TheImpCurveDomain.FirstParameter();
Resultat1.SetValue(NbResultats,t);
Resultat2.SetValue(NbResultats,
IntImpParGen_Intersector::FindV(t,Pt,TheImpTool,TheParCurve,
TheParCurveDomain,
Inter2_And_Domain2.Value(indice_1),
Inter2_And_Domain2.Value(indice_2),
EpsNul));
NbResultats++;
Resultat1.SetValue(NbResultats,Inter1.Value(indice_2));
Resultat2.SetValue(NbResultats,Inter2_And_Domain2.Value(indice_2));
}
else { //====== la borne2 et la borne1 sont hors domaine =====
if(param1<TheImpCurveDomain.FirstParameter()
&& param2>TheImpCurveDomain.LastParameter()) {
Standard_Real t;
NbResultats++;
t=TheImpCurveDomain.FirstParameter();
Resultat1.SetValue(NbResultats,t);
Resultat2.SetValue(NbResultats,
IntImpParGen_Intersector::FindV(t,Pt,TheImpTool,TheParCurve,
TheParCurveDomain,
Inter2_And_Domain2.Value(indice_1),
Inter2_And_Domain2.Value(indice_2),
EpsNul));
NbResultats++;
t=TheImpCurveDomain.LastParameter();
Resultat1.SetValue(NbResultats,t);
Resultat2.SetValue(NbResultats,
IntImpParGen_Intersector::FindV(t,Pt,TheImpTool,TheParCurve,
TheParCurveDomain,
Inter2_And_Domain2.Value(indice_1),
Inter2_And_Domain2.Value(indice_2),
EpsNul));
}
}
}
}
}
//======================================================================
//-- C o n s t r u c t e u r s e t P e r f o r m
IntImpParGen_Intersector::IntImpParGen_Intersector() {
done=Standard_False;
}
//----------------------------------------------------------------------
//--
IntImpParGen_Intersector::IntImpParGen_Intersector(const ImpTool& TheImpTool,
const IntRes2d_Domain& TheImpCurveDomain,
const ParCurve& TheParCurve,
const IntRes2d_Domain& TheParCurveDomain,
const Standard_Real TolConf,
const Standard_Real Tol) {
Perform(TheImpTool,TheImpCurveDomain,TheParCurve,TheParCurveDomain,TolConf,Tol);
}
//----------------------------------------------------------------------
//--
void IntImpParGen_Intersector::Perform(const ImpTool& TheImpTool,
const IntRes2d_Domain& TheImpCurveDomain,
const ParCurve& TheParCurve,
const IntRes2d_Domain& TheParCurveDomain,
const Standard_Real TolConf,
const Standard_Real Tol) {
Standard_Integer i,nb_segments_solution, nb_points_solution;
Standard_Real param1,param2,EpsX, EpsNul, EpsDist;
IntRes2d_Transition Trans1,Trans2;
gp_Pnt2d pt1,pt2;
gp_Vec2d Tan1,Tan2,Norm1,Norm2;
IntRes2d_Position Pos1,Pos2;
//----------------------------------------------
//-- On teste apres appel aux maths si les bornes
//-- des domaines sont des solutions
//--
Standard_Boolean HeadOnImp =Standard_False;
Standard_Boolean HeadOnPar =Standard_False;
Standard_Boolean EndOnImp =Standard_False;
Standard_Boolean EndOnPar =Standard_False;
this->ResetFields();
IntImpParGen_MyImpParTool TheImpParTool(TheImpTool,TheParCurve);
if (! (TheParCurveDomain.HasFirstPoint() &&
TheParCurveDomain.HasLastPoint())) {
Standard_ConstructionError::Raise("Domaine sur courbe incorrect");
}
Standard_Integer nb_echantillons = ParTool::NbSamples(TheParCurve,
TheParCurveDomain.FirstParameter(),
TheParCurveDomain.LastParameter());
EpsX = EPSX;
if(EpsX>1.0e-10) EpsX = 1.0e-10;
EpsNul=(TolConf<=1.0e-10)? 1.0e-10: TolConf;
EpsDist=(Tol<=1.0e-10)? 1.0e-10: Tol;
Standard_Real Tolerance_Angulaire=EpsDist;
if((TheParCurveDomain.LastParameter() - TheParCurveDomain.FirstParameter()) < 100.0*EpsX) {
EpsX = (TheParCurveDomain.LastParameter() - TheParCurveDomain.FirstParameter())*0.01;
}
math_FunctionSample Sample2(TheParCurveDomain.FirstParameter(),
TheParCurveDomain.LastParameter(),
nb_echantillons);
math_FunctionAllRoots Sol(TheImpParTool,
Sample2,
EpsX,
EpsDist,
EpsNul);
if(!Sol.IsDone()) {done = Standard_False; return; }
nb_segments_solution=Sol.NbIntervals();
nb_points_solution=Sol.NbPoints();
//--------------------------------------------------------------------
//-- T r a i t e m e n t d e s P o i n t s S o l u t i o n s
for(i=1; i<=nb_points_solution; i++) {
gp_Pnt2d Pt;
param2=Sol.GetPoint(i);
param1=FindU(param2,Pt,TheParCurve,TheImpTool);
if(TheImpCurveDomain.IsClosed()) {
param1 = IntImpParGen::NormalizeOnDomain( param1
,TheImpCurveDomain);
}
Standard_Boolean IsOnTheImpCurveDomain=Standard_True;
if(TheImpCurveDomain.HasFirstPoint()) {
if(param1<TheImpCurveDomain.FirstParameter()) {
if(Pt.Distance(TheImpCurveDomain.FirstPoint())
> TheImpCurveDomain.FirstTolerance()) {
IsOnTheImpCurveDomain=Standard_False;
}
}
}
if(IsOnTheImpCurveDomain && TheImpCurveDomain.HasLastPoint()) {
if(param1>TheImpCurveDomain.LastParameter()) {
if(Pt.Distance(TheImpCurveDomain.LastPoint())
> TheImpCurveDomain.FirstTolerance()) {
IsOnTheImpCurveDomain=Standard_False;
}
}
}
if(IsOnTheImpCurveDomain) {
TheImpTool.D2(param1,pt1,Tan1,Norm1);
ParTool::D2(TheParCurve,param2,pt2,Tan2,Norm2);
IntImpParGen::DeterminePosition(Pos1,TheImpCurveDomain,pt1,param1);
IntImpParGen::DeterminePosition(Pos2,TheParCurveDomain,pt2,param2);
if(Pos1==IntRes2d_End) EndOnImp = Standard_True;
else if(Pos1==IntRes2d_Head) HeadOnImp = Standard_True;
if(Pos2==IntRes2d_End) EndOnPar = Standard_True;
else if(Pos2==IntRes2d_Head) HeadOnPar = Standard_True;
IntImpParGen::DetermineTransition(Pos1,Tan1,Norm1,Trans1,
Pos2,Tan2,Norm2,Trans2,
Tolerance_Angulaire);
IntRes2d_IntersectionPoint IP(pt1,param1,param2
,Trans1,Trans2
,ReversedParameters());
Insert(IP);
}
}
//-- F i n d u T r a i t e m e n t d e s P t s S o l.
//--------------------------------------------------------------------
//-- T r a i t e m e n t D e s S e g m e n t s ---
//--------------------------------------------------------------------
//-- On a N segments solution sur le domaine de V soit au pire :
//-- --> N segments solution sur le domaine de U
//-- -->2N segments si la courbe en U est fermee
//--
TColStd_Array1OfReal Inter2_and_Domaine2(1,2+8*nb_segments_solution);
TColStd_Array1OfReal Inter1(1,2+8*nb_segments_solution);
Standard_Integer nb_segments_crees=0;
for (Standard_Integer j2=1,j=1;j<=nb_segments_solution;j++,j2+=2) {
Standard_Real param2_inf,param2_sup;
Standard_Real param1_inf,param1_sup;
gp_Pnt2d Ptemp;
Sol.GetInterval(j,param2_inf,param2_sup);
param1_inf=FindU(param2_inf,Ptemp,TheParCurve,TheImpTool);
param1_sup=FindU(param2_sup,Ptemp,TheParCurve,TheImpTool);
//----------------------------------------------------------------------
//-- C o u r b e I m p l i c i t e F e r m e e
if(TheImpCurveDomain.IsClosed()) {
gp_Pnt2d Ptemp;
gp_Vec2d T1,T2,N1,N2;
Standard_Real param1_origine,param1_fin;
TheImpCurveDomain.EquivalentParameters(param1_origine,param1_fin);
Standard_Real Periode=param1_fin-param1_origine;
while(param1_inf<param1_origine) { param1_inf+=Periode; }
while(param1_sup<param1_origine) { param1_sup+=Periode; }
ParTool::D2(TheParCurve,param2_inf,Ptemp,T2,N2);
TheImpTool.D2(param1_inf,Ptemp,T1,N1);
if(T1.Magnitude()<=gp::Resolution()) T1=N1;
if(T2.Magnitude()<=gp::Resolution()) T2=N2;
if(T1.Dot(T2) >=0.0) {
//--- param1_inf designe un point entrant (et T1 est vers la matiere)
if(param1_inf>=param1_sup) { param1_sup+=Periode; }
}
else { //--- param1_inf : point sortant (et T1 est Hors matiere)
if(param1_inf<=param1_sup) { param1_inf+=Periode; }
}
//--- On cree un nouveau segment decale de Periode
//-- Exemple de Pb : Domaine PI/4 PI/2 et intervalle 0,PI
//-- Domaine 1.5PI 2.5PI et intervalle 0,PI
//-- -2pi 0 2pi
//-- ------|--------------------|-----------------|-----------
//-- [----------------------------] Domaine
//-- [~~~~~~~~~~~~~~~~~] Inters.
//--
//-- On cree un nouvel intervalle
//-- interv decale
//-- [a~~~~~~~~~~~~b] [a~~~~~~~~~~~~~~~b] et [a~~~]
//--
//
if(TheImpCurveDomain.LastParameter()
> ((param1_inf>param1_sup)? (param1_sup+Periode):
(param1_inf+Periode))) {
Inter2_and_Domaine2.SetValue(j2,param2_inf);
Inter1.SetValue(j2,param1_inf+Periode);
Inter2_and_Domaine2.SetValue(j2+1,param2_sup);
Inter1.SetValue(j2+1,param1_sup+Periode);
j2+=2;
nb_segments_crees++;
}
if(TheImpCurveDomain.FirstParameter()
<((param1_inf<param1_sup)? (param1_sup-Periode): (param1_inf-Periode))) {
Inter2_and_Domaine2.SetValue(j2,param2_inf);
Inter1.SetValue(j2,param1_inf-Periode);
Inter2_and_Domaine2.SetValue(j2+1,param2_sup);
Inter1.SetValue(j2+1,param1_sup-Periode);
j2+=2;
nb_segments_crees++;
}
}
//-- F i n C o u r b e I m p l i c i t e F e r m e e
//----------------------------------------------------------------------
Inter2_and_Domaine2.SetValue(j2,param2_inf);
Inter1.SetValue(j2,param1_inf);
Inter2_and_Domaine2.SetValue(j2+1,param2_sup);
Inter1.SetValue(j2+1,param1_sup);
}
//------------------------------------------------------------------
//-- INTER2_DOMAINE2 : Intersection AND CurveDomain : Function of PARAM2
//-- INTER1 : Intersection AND CurveDomain : Function of PARAM1
//------------------------------------------------------------------
//--
TColStd_Array1OfReal Resultat1(1,2+(1+nb_segments_solution)*2);
TColStd_Array1OfReal Resultat2(1,2+(1+nb_segments_solution)*2);
nb_segments_solution+=nb_segments_crees;
Standard_Integer NbResultats=nb_segments_solution*2;
And_Domaine_Objet1_Intersections(TheImpTool,
TheParCurve,
TheImpCurveDomain,
TheParCurveDomain,
NbResultats,
Inter2_and_Domaine2,Inter1,
Resultat1,Resultat2,EpsNul);
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//Calcule_Toutes_Transitions(NbResultats,
// Resultat1,Resultat2,
// TheImpTool,
// TheImpCurveDomain,
// TheParCurve,
// TheParCurveDomain);
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~ Fonction Calcule_Toutes_Transitions Repportee ici pour cause ~~~~~
//~~~~~ D acces aux methodes Protected APPEND
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
{
IntRes2d_Position Pos1,Pos2;
IntRes2d_Transition Trans1,Trans2;
gp_Vec2d Tan1,Tan2,Norm1,Norm2;
gp_Pnt2d Pt1_on1,Pt2_on1,Pt1_on2,Pt2_on2;
Standard_Real Param1_on1,Param2_on1,Param1_on2,Param2_on2;
Standard_Real Dist_Mini_ImpCurve=EPSNUL;
Standard_Real Tolerance_Angulaire=Dist_Mini_ImpCurve;
for(Standard_Integer i=1; i<=NbResultats ; i+=2) {
Standard_Integer ip1=i+1;
Standard_Boolean OnlyOnePoint=Standard_False;
Param1_on1=Resultat1.Value(i);
Param1_on2=Resultat2.Value(i);
Param2_on1=Resultat1.Value(ip1);
Param2_on2=Resultat2.Value(ip1);
Pt1_on1=TheImpTool.Value(Param1_on1);
Pt2_on1=TheImpTool.Value(Param2_on1);
Pt1_on2=ParTool::Value(TheParCurve,Param1_on2);
Pt2_on2=ParTool::Value(TheParCurve,Param2_on2);
if(!TheImpCurveDomain.IsClosed()) {
if( Pt1_on1.Distance(Pt2_on1) <= Dist_Mini_ImpCurve ) {
if( Pt1_on2.Distance(Pt2_on2) <= Dist_Mini_ImpCurve ) {
OnlyOnePoint=Standard_True;
}
}
}
Param1_on1=IntImpParGen::NormalizeOnDomain(Param1_on1,TheImpCurveDomain);
Param1_on2=IntImpParGen::NormalizeOnDomain(Param1_on2,TheParCurveDomain);
TheImpTool.D2(Param1_on1,Pt1_on1,Tan1,Norm1);
ParTool::D2(TheParCurve,Param1_on2,Pt1_on2,Tan2,Norm2);
IntImpParGen::DeterminePosition(Pos1,TheImpCurveDomain,Pt1_on1,Param1_on1);
IntImpParGen::DeterminePosition(Pos2,TheParCurveDomain,Pt1_on2,Param1_on2);
if(Pos1==IntRes2d_End) EndOnImp = Standard_True;
else if(Pos1==IntRes2d_Head) HeadOnImp = Standard_True;
if(Pos2==IntRes2d_End) EndOnPar = Standard_True;
else if(Pos2==IntRes2d_Head) HeadOnPar = Standard_True;
IntImpParGen::DetermineTransition(Pos1,Tan1,Norm1,Trans1,
Pos2,Tan2,Norm2,Trans2,
Tolerance_Angulaire);
//============== Detection du cas : L intersection est en bout
//============== sur les 2 domaines
if(Pos1!=IntRes2d_Middle && Pos2!=IntRes2d_Middle) {
Standard_Real m=0.5*(Pt1_on1.X() + Pt1_on2.X());
Pt1_on1.SetX(m);
m=0.5*(Pt1_on1.Y() + Pt1_on2.Y());
Pt1_on1.SetY(m);
}
IntRes2d_IntersectionPoint new_p1(Pt1_on1
,Param1_on1,Param1_on2
,Trans1,Trans2
,ReversedParameters());
if(!OnlyOnePoint) {
IntRes2d_IntersectionPoint new_p2;
Param2_on1=IntImpParGen::NormalizeOnDomain(Param2_on1,TheImpCurveDomain);
Param2_on2=IntImpParGen::NormalizeOnDomain(Param2_on2,TheParCurveDomain);
TheImpTool.D2(Param2_on1,Pt2_on1,Tan1,Norm1);
ParTool::D2(TheParCurve,Param2_on2,Pt2_on2,Tan2,Norm2);
IntImpParGen::DeterminePosition(Pos1,TheImpCurveDomain,Pt2_on1,Param2_on1);
IntImpParGen::DeterminePosition(Pos2,TheParCurveDomain,Pt2_on2,Param2_on2);
if(Pos1==IntRes2d_End) EndOnImp = Standard_True;
else if(Pos1==IntRes2d_Head) HeadOnImp = Standard_True;
if(Pos2==IntRes2d_End) EndOnPar = Standard_True;
else if(Pos2==IntRes2d_Head) HeadOnPar = Standard_True;
IntImpParGen::DetermineTransition(Pos1,Tan1,Norm1,Trans1,
Pos2,Tan2,Norm2,Trans2,
Tolerance_Angulaire);
//============== Detection du cas : L intersection est en bout
//============== sur les 2 domaines
if(Pos1!=IntRes2d_Middle && Pos2!=IntRes2d_Middle) {
Standard_Real m=0.5*(Pt2_on1.X() + Pt2_on2.X() );
Pt2_on1.SetX(m);
m=0.5*(Pt2_on1.Y() + Pt2_on2.Y());
Pt2_on1.SetY(m);
}
new_p2.SetValues(Pt2_on1,Param2_on1,Param2_on2
,Trans1,Trans2
,ReversedParameters());
Standard_Boolean segopposite=((Tan1.Dot(Tan2) < 0.0)?
Standard_True : Standard_False);
IntRes2d_IntersectionSegment new_seg(new_p1,new_p2
,segopposite
,ReversedParameters());
Append(new_seg);
}
else {
Insert(new_p1);
}
}
} //~~~~~~~~~~~~ Fin du corps de la fonction Calc...Transitions~~~~~~~~~~
//-------------------------------------------
//-- On teste les points en bouts solutions
//--
if(!HeadOnImp && TheImpCurveDomain.HasFirstPoint()) {
if(!HeadOnPar) {
if(TheImpCurveDomain.FirstPoint().Distance(TheParCurveDomain.FirstPoint())
<= Max(TheImpCurveDomain.FirstTolerance(),TheParCurveDomain.FirstTolerance())) {
param1 = TheImpCurveDomain.FirstParameter();
param2 = TheParCurveDomain.FirstParameter();
TheImpTool.D2(param1,pt1,Tan1,Norm1);
ParTool::D2(TheParCurve,param2,pt2,Tan2,Norm2);
IntImpParGen::DetermineTransition(IntRes2d_Head,Tan1,Norm1,Trans1,
IntRes2d_Head,Tan2,Norm2,Trans2,
Tolerance_Angulaire);
IntRes2d_IntersectionPoint IP(TheImpCurveDomain.FirstPoint(),
param1,param2,
Trans1,Trans2,
ReversedParameters());
Insert(IP);
}
}
if(!EndOnPar) {
if(TheImpCurveDomain.FirstPoint().Distance(TheParCurveDomain.LastPoint())
<= Max(TheImpCurveDomain.FirstTolerance(),TheParCurveDomain.LastTolerance())) {
param1 = TheImpCurveDomain.FirstParameter();
param2 = TheParCurveDomain.LastParameter();
TheImpTool.D2(param1,pt1,Tan1,Norm1);
ParTool::D2(TheParCurve,param2,pt2,Tan2,Norm2);
IntImpParGen::DetermineTransition(IntRes2d_Head,Tan1,Norm1,Trans1,
IntRes2d_End ,Tan2,Norm2,Trans2,
Tolerance_Angulaire);
IntRes2d_IntersectionPoint IP(TheImpCurveDomain.FirstPoint(),
param1,param2,
Trans1,Trans2,
ReversedParameters());
Insert(IP);
}
}
}
if(!EndOnImp && TheImpCurveDomain.HasLastPoint()) {
if(!HeadOnPar) {
if(TheImpCurveDomain.LastPoint().Distance(TheParCurveDomain.FirstPoint())
<= Max(TheImpCurveDomain.LastTolerance(),TheParCurveDomain.FirstTolerance())) {
param1 = TheImpCurveDomain.LastParameter();
param2 = TheParCurveDomain.FirstParameter();
TheImpTool.D2(param1,pt1,Tan1,Norm1);
ParTool::D2(TheParCurve,param2,pt2,Tan2,Norm2);
IntImpParGen::DetermineTransition(IntRes2d_End,Tan1,Norm1,Trans1,
IntRes2d_Head,Tan2,Norm2,Trans2,
Tolerance_Angulaire);
IntRes2d_IntersectionPoint IP(TheImpCurveDomain.LastPoint(),
param1,param2,
Trans1,Trans2,
ReversedParameters());
Insert(IP);
}
}
if(!EndOnPar) {
if(TheImpCurveDomain.LastPoint().Distance(TheParCurveDomain.LastPoint())
<= Max(TheImpCurveDomain.LastTolerance(),TheParCurveDomain.LastTolerance())) {
param1 = TheImpCurveDomain.LastParameter();
param2 = TheParCurveDomain.LastParameter();
TheImpTool.D2(param1,pt1,Tan1,Norm1);
ParTool::D2(TheParCurve,param2,pt2,Tan2,Norm2);
IntImpParGen::DetermineTransition(IntRes2d_End,Tan1,Norm1,Trans1,
IntRes2d_End,Tan2,Norm2,Trans2,
Tolerance_Angulaire);
IntRes2d_IntersectionPoint IP(TheImpCurveDomain.LastPoint(),
param1,param2,
Trans1,Trans2,
ReversedParameters());
Insert(IP);
}
}
}
done=Standard_True;
}
Standard_Real IntImpParGen_Intersector::FindU(const Standard_Real parameter
,gp_Pnt2d& point
,const ParCurve& TheParCurve
,const ImpTool& TheImpTool) const
{
point=ParTool::Value(TheParCurve,parameter);
return(TheImpTool.FindParameter(point));
}
Standard_Real IntImpParGen_Intersector::FindV(const Standard_Real parameter
,gp_Pnt2d& point
,const ImpTool& TheImpTool
,const ParCurve& TheParCurve
,const IntRes2d_Domain& TheParCurveDomain
,const Standard_Real V0
,const Standard_Real V1
,const Standard_Real Tolerance) const
{
point=TheImpTool.Value(parameter);
if(TheParCurveDomain.IsClosed()) {
Standard_Real V = ProjectOnPCurveTool::FindParameter(TheParCurve,
point,
Tolerance);
return(IntImpParGen::NormalizeOnDomain(V,TheParCurveDomain));
}
else {
Standard_Real VV0 = V0;
Standard_Real VV1 = V1;
if(V1<V0) { VV0 = V1; VV1 = V0; }
//-- ??????????????????????????????????????????????????????????????????????
//-- Modif le 15 Septembre 1992 : On Teste le parametre retourne
//--??????????????????????????????????????????????????????????????????????
Standard_Real X = ProjectOnPCurveTool::FindParameter(TheParCurve,
point,
VV0,VV1,Tolerance);
if(X>VV1) X=VV1; else if(X<VV0) X=VV0;
return(X);
}
}

View File

@@ -0,0 +1,68 @@
-- File: ParTool.cdl
-- Created: Fri Mar 27 13:16:36 1992
-- Author: Laurent BUCHARD
-- <lbr@topsn3>
---Copyright: Matra Datavision 1992
deferred generic class ParTool from IntImpParGen
(ParCurve as any)
---Purpose: Template class for a tool on a parametrised curve.
uses Pnt2d from gp,
Vec2d from gp,
Lin2d from gp
is
Value (myclass; C: ParCurve; U: Real from Standard)
---Purpose: Returns the point at parameter U on the Curve C.
returns Pnt2d from gp;
D1 (myclass; C:ParCurve; U:Real from Standard ;
P: out Pnt2d; T: out Vec2d);
---Purpose: Computes the Point and the First derivative of
-- the parametric curve C at parameter U.
D2 (myclass; C:ParCurve; U:Real from Standard ;
P: out Pnt2d; T,N: out Vec2d);
---Purpose: Computes the Point, the First and the Second derivative of
-- the parametric curve C at parameter U.
EpsX (myclass; C: ParCurve)
---Purpose: Returns the valuec of the parametric tolerance
-- on the curve C.
returns Real from Standard;
NbSamples(myclass; C: ParCurve)
---Purpose: NbSamples is the number of sample point used to
-- polygonise the parametric curve on its domain.
returns Integer from Standard;
end ParTool;

View File

View File

@@ -0,0 +1,158 @@
// File: IntImpParGen_Tool.cxx
// Created: Wed Jun 10 15:06:44 1992
// Author: Laurent BUCHARD
// <lbr@sdsun2>
#include <IntImpParGen_Tool.hxx>
#include <gp.hxx>
#define TOLERANCE_ANGULAIRE 0.00000001
//----------------------------------------------------------------------
Standard_Real NormalizeOnDomain(Standard_Real& Param,const IntRes2d_Domain& TheDomain) {
Standard_Real modParam = Param;
if(TheDomain.IsClosed()) {
Standard_Real Periode,t;
TheDomain.EquivalentParameters(t,Periode);
Periode-=t;
if(TheDomain.HasFirstPoint()) {
while(modParam<TheDomain.FirstParameter()) {
modParam+=Periode;
}
}
if(TheDomain.HasLastPoint()) {
if(modParam>TheDomain.LastParameter()) {
modParam-=Periode;
}
}
}
return(modParam);
}
//----------------------------------------------------------------------
void Determine_Position(IntRes2d_Position& Pos1,
const IntRes2d_Domain& TheDomain,
const gp_Pnt2d& Pnt1,
const Standard_Real Param1) {
Pos1=IntRes2d_Middle;
if(TheDomain.HasFirstPoint()) {
if(Pnt1.Distance(TheDomain.FirstPoint())
<= TheDomain.FirstTolerance()) {
Pos1=IntRes2d_Head;
}
}
if(TheDomain.HasLastPoint()) {
if(Pnt1.Distance(TheDomain.LastPoint())
<= TheDomain.LastTolerance()) {
if(Pos1==IntRes2d_Head) {
if(Abs(Param1-TheDomain.LastParameter())
< Abs(Param1-TheDomain.FirstParameter()))
Pos1=IntRes2d_End;
}
else {
Pos1=IntRes2d_End;
}
}
}
}
//----------------------------------------------------------------------
void Determine_Transition(const IntRes2d_Position Pos1,
gp_Vec2d& Tan1,
const gp_Vec2d& Norm1,
IntRes2d_Transition& T1,
const IntRes2d_Position Pos2,
gp_Vec2d& Tan2,
const gp_Vec2d& Norm2,
IntRes2d_Transition& T2,
// const Standard_Real Tolerance_Angulaire) {
const Standard_Real ) {
Standard_Boolean courbure1=Standard_True;
Standard_Boolean courbure2=Standard_True;
Standard_Boolean decide=Standard_True;
if (Tan1.Magnitude()<=gp::Resolution()) {
Tan1=Norm1;
courbure1=Standard_False;
if (Tan1.Magnitude()<=gp::Resolution()) { // transition undecided
decide=Standard_False;
}
}
if (Tan2.Magnitude()<=gp::Resolution()) {
Tan2=Norm2;
courbure2=Standard_False;
if (Tan2.Magnitude()<=gp::Resolution()) { // transition undecided
decide=Standard_False;
}
}
if (!decide) {
T1.SetValue(Pos1);
T2.SetValue(Pos2);
}
else {
Standard_Real sgn=Tan1.Crossed(Tan2);
Standard_Real norm=Tan1.Magnitude()*Tan2.Magnitude();
if (Abs(sgn)<=TOLERANCE_ANGULAIRE*norm) { // Transition TOUCH #########
Standard_Boolean opos=(Tan1.Dot(Tan2))<0;
if (!(courbure1||courbure2)) {
T1.SetValue(Standard_True,Pos1,IntRes2d_Unknown,opos);
T2.SetValue(Standard_True,Pos2,IntRes2d_Unknown,opos);
}
else {
gp_Vec2d Norm;
Tan1.Normalized();
Norm.SetCoord(-Tan1.Y(),Tan1.X());
Standard_Real Val1,Val2;
if (!courbure1) {
Val1=0.0;
}
else {
Val1=Norm.Dot(Norm1);
}
if (!courbure2) {
Val2=0.0;
}
else {
Val2=Norm.Dot(Norm2);
}
if (Abs(Val1-Val2) <= gp::Resolution()) {
T1.SetValue(Standard_True,Pos1,IntRes2d_Unknown,opos);
T2.SetValue(Standard_True,Pos2,IntRes2d_Unknown,opos);
}
else if (Val2 > Val1) {
T2.SetValue(Standard_True,Pos2,IntRes2d_Inside,opos);
if (opos) {
T1.SetValue(Standard_True,Pos1,IntRes2d_Inside,opos);
}
else {
T1.SetValue(Standard_True,Pos1,IntRes2d_Outside,opos);
}
}
else { // Val1 > Val2
T2.SetValue(Standard_True,Pos2,IntRes2d_Outside,opos);
if (opos) {
T1.SetValue(Standard_True,Pos1,IntRes2d_Outside,opos);
}
else {
T1.SetValue(Standard_True,Pos1,IntRes2d_Inside,opos);
}
}
}
}
else if (sgn<0) {
T1.SetValue(Standard_False,Pos1,IntRes2d_In);
T2.SetValue(Standard_False,Pos2,IntRes2d_Out);
}
else { // sgn>0
T1.SetValue(Standard_False,Pos1,IntRes2d_Out);
T2.SetValue(Standard_False,Pos2,IntRes2d_In);
}
}
}

View File

@@ -0,0 +1,47 @@
// File: IntImpParGen_Tool.hxx
// Created: Wed Jun 10 15:04:00 1992
// Author: Laurent BUCHARD
// <lbr@sdsun2>
#ifndef IntImpParGen_Tool_HeaderFile
#define IntImpParGen_Tool_HeaderFile
#ifndef IntRes2d_Domain_HeaderFile
#include <IntRes2d_Domain.hxx>
#endif
#ifndef IntRes2d_Position_HeaderFile
#include <IntRes2d_Position.hxx>
#endif
#ifndef IntRes2d_Transition_HeaderFile
#include <IntRes2d_Transition.hxx>
#endif
#ifndef gp_Vec2d_HeaderFile
#include <gp_Vec2d.hxx>
#endif
#ifndef gp_Pnt2d_HeaderFile
#include <gp_Pnt2d.hxx>
#endif
Standard_Real NormalizeOnDomain(Standard_Real&,const IntRes2d_Domain&);
void Determine_Position(IntRes2d_Position&,
const IntRes2d_Domain&,
const gp_Pnt2d&,const Standard_Real);
void Determine_Transition(const IntRes2d_Position Pos1,
gp_Vec2d& Tan1,
const gp_Vec2d& Norm1,
IntRes2d_Transition& Trans1,
const IntRes2d_Position Pos2,
gp_Vec2d& Tan2,
const gp_Vec2d& Norm2,
IntRes2d_Transition& Trans2,
const Standard_Real ToleranceAng);
#endif