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

194
src/CSLib/CSLib.cdl Executable file
View File

@@ -0,0 +1,194 @@
-- File: CSLib.cdl
-- Created: Mon Sep 9 15:44:13 1991
-- Author: Michel Chauvat
-- JCV Decembre 1991
---Copyright: Matra Datavision 1991
package CSLib
---Purpose: This package implements functions for basis geometric
-- computation on curves and surfaces.
-- The tolerance criterions used in this package are
-- Resolution from package gp and RealEpsilon from class
-- Real of package Standard.
uses gp,
TColgp,
TColStd,
math
is
enumeration DerivativeStatus is
Done, D1uIsNull, D1vIsNull, D1IsNull, D1uD1vRatioIsNull,
D1vD1uRatioIsNull, D1uIsParallelD1v;
--- Purpose :
--
-- D1uIsNull : ||D1U|| <= Resolution
--
-- D1vIsNull : ||D1V|| <= Resolution
--
-- D1IsNull : the first derivatives in the U and V parametric
-- directions have null length :
-- ||D1U|| <= Resolution and ||D1V|| <= Resolution
--
-- D1uD1vRatioIsNull : the first derivative in the U direction has
-- null length by comparison with the derivative
-- in the V direction
-- ||D1U|| / ||D1V|| <= RealEpsilon
--
-- D1vD1uRatioIsNull : the first derivative in the V direction has
-- null length by comparison with the derivative
-- in the U direction
-- ||D1V|| / ||D1U|| <= RealEpsilon
--
-- D1uIsParallelD1v : the angle between the derivatives in the U and
-- V direction is null (tolerance criterion given
-- as input data)
enumeration NormalStatus is
Singular,Defined,InfinityOfSolutions, D1NuIsNull, D1NvIsNull, D1NIsNull,
D1NuNvRatioIsNull, D1NvNuRatioIsNull, D1NuIsParallelD1Nv;
--- Purpose :
--
-- if N is the normal
--
-- InfinityOfSolutions : ||DN/du||>Resolution, ||DN/dv||>Resolution
--
-- D1NuIsNull : ||DN/du|| <= Resolution
--
-- D1NvIsNull : ||DN/dv|| <= Resolution
--
-- D1NIsNull : ||DN/du||<=Resolution, ||DN/dv||<=Resolution
--
-- D1NuNvRatioIsNull : ||D1Nu|| / ||D1Nv|| <= RealEpsilon
--
-- D1NvNuRatioIsNull : ||D1Nu|| / ||D1Nv|| <= RealEpsilon
--
-- D1NuIsParallelD1Nv : The angle between D1Nu and D1Nv is Null.
class Class2d;
---Purpose:
--
-- *** Class2d : Low level algorithm for 2d classification
-- this class was moved from package BRepTopAdaptor
--- Purpose :
-- The following functions computes the normal to a surface
private class NormalPolyDef;
--- Purpose :
-- The following functions computes the normal to a surface
-- inherits FunctionWithDerivative from math
--
Normal (D1U, D1V: Vec from gp; SinTol: Real;
Status: out DerivativeStatus;
Normal: out Dir from gp);
--- Purpose :
-- Computes the normal direction of a surface as the cross product
-- between D1U and D1V.
-- If D1U has null length or D1V has null length or D1U and D1V are
-- parallel the normal is undefined.
-- To check that D1U and D1V are colinear the sinus of the angle
-- between D1U and D1V is computed and compared with SinTol.
-- The normal is computed if Status == Done else the Status gives the
-- reason why the computation has failed.
Normal (D1U, D1V, D2U, D2V, D2UV: Vec from gp; SinTol: Real;
Done : out Boolean; Status : out NormalStatus;
Normal: out Dir from gp);
--- Purpose :
-- If there is a singularity on the surface the previous method
-- cannot compute the local normal.
-- This method computes an approched normal direction of a surface.
-- It does a limited development and needs the second derivatives
-- on the surface as input data.
-- It computes the normal as follow :
-- N(u, v) = D1U ^ D1V
-- N(u0+du,v0+dv) = N0 + DN/du(u0,v0) * du + DN/dv(u0,v0) * dv + Eps
-- with Eps->0 so we can have the equivalence N ~ dN/du + dN/dv.
-- DNu = ||DN/du|| and DNv = ||DN/dv||
--
-- . if DNu IsNull (DNu <= Resolution from gp) the answer Done = True
-- the normal direction is given by DN/dv
-- . if DNv IsNull (DNv <= Resolution from gp) the answer Done = True
-- the normal direction is given by DN/du
-- . if the two directions DN/du and DN/dv are parallel Done = True
-- the normal direction is given either by DN/du or DN/dv.
-- To check that the two directions are colinear the sinus of the
-- angle between these directions is computed and compared with
-- SinTol.
-- . if DNu/DNv or DNv/DNu is lower or equal than Real Epsilon
-- Done = False, the normal is undefined
-- . if DNu IsNull and DNv is Null Done = False, there is an
-- indetermination and we should do a limited developpement at
-- order 2 (it means that we cannot omit Eps).
-- . if DNu Is not Null and DNv Is not Null Done = False, there are
-- an infinity of normals at the considered point on the surface.
Normal (D1U, D1V: Vec from gp; MagTol: Real;
Status: out NormalStatus;
Normal: out Dir from gp);
--- Purpose :
-- Computes the normal direction of a surface as the cross product
-- between D1U and D1V.
--
Normal (MaxOrder : Integer ; DerNUV : Array2OfVec from TColgp; MagTol: Real;
U , V , Umin , Umax , Vmin , Vmax : Real; Status: out NormalStatus;
Normal : out Dir from gp; OrderU , OrderV : out Integer);
--- Purpose : find the first order k0 of deriviative of NUV
-- where: foreach order < k0 all the derivatives of NUV are
-- null all the derivatives of NUV corresponding to the order
-- k0 are collinear and have the same sens.
-- In this case, normal at U,V is unique.
DNNUV ( Nu , Nv : Integer; DerSurf : Array2OfVec from TColgp )
returns Vec from gp;
---Purpose : -- Computes the derivative of order Nu in the --
-- direction U and Nv in the direction V of the not --
-- normalized normal vector at the point P(U,V) The
-- array DerSurf contain the derivative (i,j) of the surface
-- for i=0,Nu+1 ; j=0,Nv+1
DNNUV (Nu,Nv : Integer ; DerSurf1 : Array2OfVec from TColgp;
DerSurf2 : Array2OfVec from TColgp )
returns Vec from gp;
---Purpose : Computes the derivatives of order Nu in the direction Nu
-- and Nv in the direction Nv of the not normalized vector
-- N(u,v) = dS1/du * dS2/dv (cases where we use an osculating surface)
-- DerSurf1 are the derivatives of S1
DNNormal( Nu , Nv : Integer; DerNUV : Array2OfVec from TColgp ;
Iduref : Integer = 0; Idvref : Integer = 0 )
returns Vec from gp;
---Purpose : -- Computes the derivative of order Nu in the --
-- direction U and Nv in the direction V of the
-- normalized normal vector at the point P(U,V) array
-- DerNUV contain the derivative (i+Iduref,j+Idvref)
-- of D1U ^ D1V for i=0,Nu ; j=0,Nv Iduref and Idvref
-- correspond to a derivative of D1U ^ D1V which can
-- be used to compute the normalized normal vector.
-- In the regular cases , Iduref=Idvref=0.
end CSLib;

539
src/CSLib/CSLib.cxx Executable file
View File

@@ -0,0 +1,539 @@
// File: CSLib.cxx
// Created: Mon Sep 9 11:19:10 1991
// Author: Michel Chauvat
// Modif JCV Decembre 1991 : Ajout des Status
// Modif JPI Octobre 1996 : Ajout des methodes DNNUV et DNNormal
// Modif JPI Novembre 1996 : Ajout de la methode Normal pour les cas singuliers
#include <CSLib.ixx>
#include <gp.hxx>
#include <gp_Vec.hxx>
#include <PLib.hxx>
#include <Precision.hxx>
#include <TColgp_Array2OfVec.hxx>
#include <TColStd_Array2OfReal.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <math_FunctionRoots.hxx>
#include <CSLib_NormalPolyDef.hxx>
#define D1uD1vRatioIsNull CSLib_D1uD1vRatioIsNull
#define D1vD1uRatioIsNull CSLib_D1vD1uRatioIsNull
#define D1uIsParallelD1v CSLib_D1uIsParallelD1v
#define D1IsNull CSLib_D1IsNull
#define D1uIsNull CSLib_D1uIsNull
#define D1vIsNull CSLib_D1vIsNull
#define Done CSLib_Done
#define D1NuIsNull CSLib_D1NuIsNull
#define D1NvIsNull CSLib_D1NvIsNull
#define D1NuIsParallelD1Nv CSLib_D1NuIsParallelD1Nv
#define D1NIsNull CSLib_D1NIsNull
#define D1NuNvRatioIsNull CSLib_D1NuNvRatioIsNull
#define D1NvNuRatioIsNull CSLib_D1NvNuRatioIsNull
#define InfinityOfSolutions CSLib_InfinityOfSolutions
#define Defined CSLib_Defined
#define Singular CSLib_Singular
void CSLib::Normal (
const gp_Vec& D1U,
const gp_Vec& D1V,
const Standard_Real SinTol,
CSLib_DerivativeStatus& Status,
gp_Dir& Normal
) {
// Fonction: Calcul de la normale a partir des tangentes en u et en v.
Standard_Real D1UMag = D1U.SquareMagnitude();
Standard_Real D1VMag = D1V.SquareMagnitude();
gp_Vec D1UvD1V = D1U.Crossed(D1V);
if (D1UMag <= gp::Resolution() && D1VMag <= gp::Resolution()) {
Status = D1IsNull;
}
else if (D1UMag <= gp::Resolution()) Status = D1uIsNull;
else if (D1VMag <= gp::Resolution()) Status = D1vIsNull;
// else if ((D1VMag / D1UMag) <= RealEpsilon()) Status = D1vD1uRatioIsNull;
// else if ((D1UMag / D1VMag) <= RealEpsilon()) Status = D1uD1vRatioIsNull;
else {
Standard_Real Sin2 =
D1UvD1V.SquareMagnitude() / (D1UMag * D1VMag);
if (Sin2 < (SinTol * SinTol)) { Status = D1uIsParallelD1v; }
else { Normal = gp_Dir (D1UvD1V); Status = Done; }
}
}
void CSLib::Normal (
const gp_Vec& D1U,
const gp_Vec& D1V,
const gp_Vec& D2U,
const gp_Vec& D2V,
const gp_Vec& DUV,
const Standard_Real SinTol,
Standard_Boolean& Done,
CSLib_NormalStatus& Status,
gp_Dir& Normal
) {
// Calcul d'une normale approchee dans le cas d'une normale nulle.
// On utilise le developpement limite de la normale a l'ordre 1:
// N(u0+du,v0+dv) = N0 + dN/du(u0,v0) * du + dN/dv(u0,v0) * dv + epsilon
// -> N ~ dN/du + dN/dv.
gp_Vec D1Nu = D2U.Crossed (D1V);
D1Nu.Add (D1U.Crossed (DUV));
gp_Vec D1Nv = DUV.Crossed (D1V);
D1Nv.Add (D1U.Crossed (D2V));
Standard_Real LD1Nu = D1Nu.SquareMagnitude();
Standard_Real LD1Nv = D1Nv.SquareMagnitude();
if (LD1Nu <= RealEpsilon() && LD1Nv <= RealEpsilon()) {
Status = D1NIsNull;
Done = Standard_False;
}
else if (LD1Nu < RealEpsilon()) {
Status = D1NuIsNull;
Done = Standard_True;
Normal = gp_Dir (D1Nv);
}
else if (LD1Nv < RealEpsilon()) {
Status = D1NvIsNull;
Done = Standard_True;
Normal = gp_Dir (D1Nu);
}
else if ((LD1Nv / LD1Nu) <= RealEpsilon()) {
Status = D1NvNuRatioIsNull;
Done = Standard_False;
}
else if ((LD1Nu / LD1Nv) <= RealEpsilon()) {
Status = D1NuNvRatioIsNull;
Done = Standard_False;
}
else {
gp_Vec D1NCross = D1Nu.Crossed (D1Nv);
Standard_Real Sin2 = D1NCross.SquareMagnitude() / (LD1Nu * LD1Nv);
if (Sin2 < (SinTol * SinTol)) {
Status = D1NuIsParallelD1Nv;
Done = Standard_True;
Normal = gp_Dir (D1Nu);
}
else {
Status = InfinityOfSolutions;
Done = Standard_False;
}
}
}
void CSLib::Normal (
const gp_Vec& D1U,
const gp_Vec& D1V,
const Standard_Real MagTol,
CSLib_NormalStatus& Status,
gp_Dir& Normal
) {
// Fonction: Calcul de la normale a partir des tangentes en u et en v.
Standard_Real D1UMag = D1U.Magnitude();
Standard_Real D1VMag = D1V.Magnitude();
gp_Vec D1UvD1V = D1U.Crossed(D1V);
Standard_Real NMag =D1UvD1V .Magnitude();
if (NMag <= MagTol || D1UMag <= MagTol || D1VMag <= MagTol ) {
Status = Singular;
// if (D1UMag <= MagTol || D1VMag <= MagTol && NMag > MagTol) MagTol = 2* NMag;
}
else
{ Normal = gp_Dir (D1UvD1V); Status = Defined; }
}
// Calcul du vecteur normal dans les cas singuliers
//
void CSLib::Normal(const Standard_Integer MaxOrder,
const TColgp_Array2OfVec& DerNUV,
const Standard_Real SinTol,
const Standard_Real U,
const Standard_Real V,
const Standard_Real Umin,
const Standard_Real Umax,
const Standard_Real Vmin,
const Standard_Real Vmax,
CSLib_NormalStatus& Status,
gp_Dir& Normal,
Standard_Integer& OrderU,
Standard_Integer& OrderV)
{
// Standard_Integer i,l,Order=-1;
Standard_Integer i=0,Order=-1;
Standard_Boolean Trouve=Standard_False;
// Status = Singular;
Standard_Real Norme;
gp_Vec D;
//Recherche de k0 tel que toutes des derivee de N=dS/du ^ dS/dv soient nulles
//jusqu'a l'ordre k0-1
while(!Trouve && Order < MaxOrder)
{
Order++;
i=Order;
while((i>=0) && (!Trouve))
{
Standard_Integer j=Order-i;
D=DerNUV(i,j);
Norme=D.Magnitude();
Trouve=(Trouve ||(Norme>=SinTol));
i--;
}
}
OrderU=i+1;
OrderV=Order-OrderU;
//Vko premiere derivee de N non nulle : reference
if(Trouve)
{
if(Order == 0)
{
Status = Defined;
Normal=D.Normalized();
}
else
{
gp_Vec Vk0;
Vk0=DerNUV(OrderU,OrderV);
TColStd_Array1OfReal Ratio(0,Order);
//Calcul des lambda i
i=0;
Standard_Boolean definie=Standard_False;
while(i<=Order && !definie)
{
if(DerNUV(i,Order-i).Magnitude()<=SinTol) Ratio(i)=0;
else
{
if(DerNUV(i,Order-i).IsParallel(Vk0,1e-6))
{
// Ratio(i) = DerNUV(i,Order-i).Magnitude() / Vk0.Magnitude();
// if(DerNUV(i,Order-i).IsOpposite(Vk0,1e-6)) Ratio(i)=-Ratio(i);
Standard_Real r = DerNUV(i,Order-i).Magnitude() / Vk0.Magnitude();
if(DerNUV(i,Order-i).IsOpposite(Vk0,1e-6)) r=-r;
Ratio(i)=r;
}
else
{
definie=Standard_True;
//
}
}
i++;
}//fin while
if(!definie)
{ //Tout les lambda i existent
Standard_Integer SP;
Standard_Real inf,sup;
inf=0.0-Standard_PI;
sup=0.0+Standard_PI;
Standard_Boolean FU,LU,FV,LV;
//Creation du domaine de definition en fonction de la position
//du point singulier (milieu, bord, coin).
FU=(Abs(U-Umin) < Precision::PConfusion());
LU=(Abs(U-Umax) < Precision::PConfusion() );
FV=(Abs(V-Vmin) < Precision::PConfusion() );
LV=(Abs(V-Vmax) < Precision::PConfusion() );
if(LU)
{
inf=Standard_PI/2;
sup=3*inf;
if(LV){inf=Standard_PI;}
if(FV){sup=Standard_PI;}
}
else if(FU)
{
sup=Standard_PI/2;
inf=-sup;
if(LV){sup=0;}
if(FV){inf=0;}
}
else if(LV)
{
inf=0.0-Standard_PI;
sup=0;
}
else if(FV)
{
inf=0;
sup=Standard_PI;
}
Standard_Boolean CS=0;
Standard_Real Vprec=0,Vsuiv;
//Creation du polynome
CSLib_NormalPolyDef Poly(Order,Ratio);
//Recherche des zeros de SAPS
math_FunctionRoots FindRoots(Poly,inf,sup,200,1e-5,
Precision::Confusion(),
Precision::Confusion());
//Si il y a des zeros
if(FindRoots.IsDone())
{
if(FindRoots.NbSolutions()>0)
{
//rangement par ordre crossant des racines de SAPS dans Sol0
TColStd_Array1OfReal Sol0(0,FindRoots.NbSolutions()+1);
Sol0(1)=FindRoots.Value(1);
Standard_Integer n=1;
while(n<=FindRoots.NbSolutions())
{
Standard_Real ASOL=FindRoots.Value(n);
Standard_Integer i=n-1;
while((i>=1) && (Sol0(i)> ASOL))
{
Sol0(i+1)=Sol0(i);
i--;
}
Sol0(i+1)=ASOL;
n++;
}//fin while(n
//Ajouts des bornes du domaines
Sol0(0)=inf;
Sol0(FindRoots.NbSolutions()+1)=sup;
//Recherche des changement de signe de SAPS par comparaison de ses
//valeurs a gauche et a droite de chaque racines
Standard_Integer ifirst=0;
for (i=0;i<=FindRoots.NbSolutions();i++)
{
if(Abs(Sol0(i+1)-Sol0(i)) > Precision::PConfusion())
{
Poly.Value((Sol0(i)+Sol0(i+1))/2.0,Vsuiv);
if(ifirst == 0)
{
ifirst=i;
CS=Standard_False;
Vprec=Vsuiv;
}
else
{
CS=(Vprec*Vsuiv)<0;
Vprec=Vsuiv;
}
}
}
}
else
{
//SAPS n'a pas de racine donc forcement ne change pas de signe
CS=Standard_False;
Poly.Value(inf,Vsuiv);
}
//fin if(MFR.NbSolutions()>0)
}//fin if(MFR>IsDone())
if(CS)
//Le polynome change de signe
SP=0;
else if(Vsuiv>0)
//Le polynome est toujours positif
SP=1;
else
//Le polynome est toujours negatif
SP=-1;
if(SP==0)
Status = InfinityOfSolutions;
else
{
Status = Defined;
Normal=SP*Vk0.Normalized();
}
}
else
{
Status = Defined;
Normal=D.Normalized();
}
}
}
}
//
// Calcul de la derivee du vecteur normal non norme
//
gp_Vec CSLib::DNNUV(const Standard_Integer Nu,
const Standard_Integer Nv,
const TColgp_Array2OfVec& DerSurf)
{
Standard_Integer i,j;
gp_Vec D(0,0,0),VG,VD,PV;
PLib::Binomial(Nu);
PLib::Binomial(Nv);
for(i=0;i<=Nu;i++)
for(j=0;j<=Nv;j++){
VG=DerSurf.Value(i+1,j);
VD=DerSurf.Value(Nu-i,Nv+1-j);
PV=VG^VD;
D=D+PLib::Bin(Nu,i)*PLib::Bin(Nv,j)*PV;
}
return D;
}
//=======================================================================
//function : DNNUV
//purpose :
//=======================================================================
gp_Vec CSLib::DNNUV(const Standard_Integer Nu,
const Standard_Integer Nv,
const TColgp_Array2OfVec& DerSurf1,
const TColgp_Array2OfVec& DerSurf2)
{
Standard_Integer i,j;
gp_Vec D(0,0,0),VG,VD,PV;
PLib::Binomial(Nu);
PLib::Binomial(Nv);
for(i=0;i<=Nu;i++)
for(j=0;j<=Nv;j++){
VG=DerSurf1.Value(i+1,j);
VD=DerSurf2.Value(Nu-i,Nv+1-j);
PV=VG^VD;
D=D+PLib::Bin(Nu,i)*PLib::Bin(Nv,j)*PV;
}
return D;
}
//
// CalCul des derivees du vecteur normal norme en fonction des derivees
// du vecteur normal non norme
//
gp_Vec CSLib::DNNormal(const Standard_Integer Nu,
const Standard_Integer Nv,
const TColgp_Array2OfVec& DerNUV,
const Standard_Integer Iduref,
const Standard_Integer Idvref)
{
Standard_Integer Kderiv;
Kderiv=Nu+Nv;
TColgp_Array2OfVec DerVecNor(0,Kderiv,0,Kderiv);
TColStd_Array2OfReal TabScal(0,Kderiv,0,Kderiv);
TColStd_Array2OfReal TabNorm(0,Kderiv,0,Kderiv);
Standard_Integer Ideriv,Jderiv,Mderiv,Pderiv,Qderiv;
Standard_Real Scal,Dnorm;
gp_Vec DerNor;
DerNor=(DerNUV.Value(Iduref,Idvref)).Normalized();
DerVecNor.SetValue(0,0,DerNor);
Dnorm=DerNUV.Value(Iduref,Idvref)*DerVecNor.Value(0,0);
TabNorm.SetValue(0,0,Dnorm);
TabScal.SetValue(0,0,0.);
PLib::Binomial(Kderiv + Iduref);
PLib::Binomial(Kderiv + Idvref);
for ( Mderiv = 1;Mderiv <= Kderiv; Mderiv++)
for ( Pderiv = 0 ; Pderiv <= Mderiv ; Pderiv++)
{
Qderiv = Mderiv - Pderiv;
if (Pderiv <= Nu && Qderiv <= Nv)
{
//
// Compute n . derivee(p,q) de n
Scal = 0.;
if ( Pderiv > Qderiv )
{
for (Jderiv=1 ; Jderiv <=Qderiv;Jderiv++)
Scal=Scal
-PLib::Bin(Qderiv,Jderiv)*
(DerVecNor.Value(0,Jderiv)*DerVecNor.Value(Pderiv,Qderiv-Jderiv));
for (Jderiv=0 ; Jderiv < Qderiv ; Jderiv++)
Scal=Scal
-PLib::Bin(Qderiv,Jderiv)*
(DerVecNor.Value(Pderiv,Jderiv)*DerVecNor.Value(0,Qderiv-Jderiv));
for (Ideriv=1 ; Ideriv < Pderiv;Ideriv++)
for (Jderiv =0 ; Jderiv <=Qderiv ; Jderiv++)
Scal= Scal
- PLib::Bin(Pderiv,Ideriv)
*PLib::Bin(Qderiv,Jderiv)
*(DerVecNor.Value(Ideriv,Jderiv)
*DerVecNor.Value(Pderiv-Ideriv,Qderiv-Jderiv));
}
else
{
for (Ideriv = 1 ; Ideriv <= Pderiv ; Ideriv++)
Scal = Scal - PLib::Bin(Pderiv,Ideriv)*
DerVecNor.Value(Ideriv,0)*DerVecNor.Value(Pderiv-Ideriv,Qderiv);
for (Ideriv = 0 ; Ideriv < Pderiv ; Ideriv++)
Scal = Scal - PLib::Bin(Pderiv,Ideriv)*
DerVecNor.Value(Ideriv,Qderiv)*DerVecNor.Value(Pderiv-Ideriv,0);
for (Ideriv=0 ; Ideriv <= Pderiv;Ideriv++)
for (Jderiv =1 ; Jderiv <Qderiv ; Jderiv++)
Scal= Scal
- PLib::Bin(Pderiv,Ideriv)
*PLib::Bin(Qderiv,Jderiv)
*(DerVecNor.Value(Ideriv,Jderiv)
*DerVecNor.Value(Pderiv-Ideriv,Qderiv-Jderiv));
}
TabScal.SetValue(Pderiv,Qderiv,Scal/2.);
//
// Compute the derivative (n,p) of NUV Length
//
Dnorm=(DerNUV.Value(Pderiv+Iduref,Qderiv+Idvref))*DerVecNor.Value(0,0);
for (Jderiv = 0 ; Jderiv < Qderiv ; Jderiv++)
Dnorm = Dnorm - PLib::Bin(Qderiv+Idvref,Jderiv+Idvref)
*TabNorm.Value(Pderiv,Jderiv)
*TabScal.Value(0,Qderiv-Jderiv);
for (Ideriv = 0 ; Ideriv < Pderiv ; Ideriv++)
for (Jderiv = 0 ; Jderiv <= Qderiv ; Jderiv++)
Dnorm = Dnorm - PLib::Bin(Pderiv+Iduref,Ideriv+Iduref)
*PLib::Bin(Qderiv+Idvref,Jderiv+Idvref)
*TabNorm.Value(Ideriv,Jderiv)
*TabScal.Value(Pderiv-Ideriv,Qderiv-Jderiv);
TabNorm.SetValue(Pderiv,Qderiv,Dnorm);
//
// Compute derivative (p,q) of n
//
DerNor = DerNUV.Value(Pderiv+Iduref,Qderiv+Idvref);
for (Jderiv = 1 ; Jderiv <= Qderiv ; Jderiv++)
DerNor = DerNor - PLib::Bin(Pderiv+Iduref,Iduref)
*PLib::Bin(Qderiv+Idvref,Jderiv+Idvref)
*TabNorm.Value(0,Jderiv)
*DerVecNor.Value(Pderiv,Qderiv-Jderiv);
for (Ideriv = 1 ; Ideriv <= Pderiv ; Ideriv++)
for (Jderiv = 0 ; Jderiv <= Qderiv ; Jderiv++)
DerNor = DerNor - PLib::Bin(Pderiv+Iduref,Ideriv+Iduref)
*PLib::Bin(Qderiv+Idvref,Jderiv+Idvref)
*TabNorm.Value(Ideriv,Jderiv)
*DerVecNor.Value(Pderiv-Ideriv,Qderiv-Jderiv);
DerNor = DerNor / PLib::Bin(Pderiv+Iduref,Iduref)
/ PLib::Bin(Qderiv+Idvref,Idvref)
/ TabNorm.Value(0,0);
DerVecNor.SetValue(Pderiv,Qderiv,DerNor);
}
}
return DerVecNor.Value(Nu,Nv);
}
#undef D1uD1vRatioIsNull
#undef D1vD1uRatioIsNull
#undef D1uIsParallelD1v
#undef D1uIsNull
#undef D1vIsNull
#undef D1IsNull
#undef Done
#undef D1NuIsNull
#undef D1NvIsNull
#undef D1NuIsParallelD1Nv
#undef D1NIsNull
#undef D1NuNvRatioIsNull
#undef D1NvNuRatioIsNull
#undef InfinityOfSolutions
#undef Resolution

56
src/CSLib/CSLib_Class2d.cdl Executable file
View File

@@ -0,0 +1,56 @@
-- File: CSLib_Class2d.cdl
-- Created: Wed Mar 8 14:53:28 1995
-- Author: Laurent BUCHARD
-- <lbr@mastox>
---Copyright: Matra Datavision 1995
class Class2d from CSLib
uses
Pnt2d from gp,
Array1OfPnt2d from TColgp
is
Create(TP: Array1OfPnt2d from TColgp; aTolu,aTolv:Real from Standard;
umin,vmin,umax,vmax: Real from Standard)
returns Class2d from CSLib;
SiDans(me; P: Pnt2d from gp)
returns Integer from Standard;
SiDans_OnMode(me; P: Pnt2d from gp; Tol: Real from Standard)
returns Integer from Standard;
InternalSiDans(me; X,Y: Real from Standard)
returns Integer from Standard;
InternalSiDansOuOn(me; X,Y: Real from Standard)
returns Integer from Standard;
Copy(me; Other: Class2d from CSLib)
returns Class2d from CSLib;
---C++: return const &
---C++: alias operator=
--Purpose *** Raise if called ***
Destroy(me: in out);
---C++: alias ~
fields
MyPnts2dX: Address from Standard;
MyPnts2dY: Address from Standard;
Tolu : Real from Standard;
Tolv : Real from Standard;
N : Integer from Standard;
Umin : Real from Standard;
Vmin : Real from Standard;
Umax : Real from Standard;
Vmax : Real from Standard;
end Class2d from CSLib;

312
src/CSLib/CSLib_Class2d.cxx Executable file
View File

@@ -0,0 +1,312 @@
// File: CSLib_Class2d.cxx
// Created: Wed Mar 8 15:06:24 1995
// Author: Laurent BUCHARD
// <lbr@mastox>
//#define No_Standard_OutOfRange
#include <CSLib_Class2d.ixx>
#include <Standard_ConstructionError.hxx>
static inline
Standard_Real Transform2d(const Standard_Real u,
const Standard_Real umin,
const Standard_Real umaxmumin);
//=======================================================================
//function : CSLib_Class2d
//purpose :
//=======================================================================
CSLib_Class2d::CSLib_Class2d(const TColgp_Array1OfPnt2d& TP2d,
const Standard_Real aTolu,
const Standard_Real aTolv,
const Standard_Real umin,
const Standard_Real vmin,
const Standard_Real umax,
const Standard_Real vmax)
{
Umin=umin;
Vmin=vmin;
Umax=umax;
Vmax=vmax;
//
if(umax<=umin || vmax<=vmin) {
MyPnts2dX=NULL;
MyPnts2dY=NULL;
N=0;
}
//
else {
Standard_Integer i, iLower;
Standard_Real du,dv,*Pnts2dX,*Pnts2dY, aPrc;
//
aPrc=1.e-10;
N = TP2d.Length();
Tolu = aTolu;
Tolv = aTolv;
MyPnts2dX = new Standard_Real [N+1];
MyPnts2dY = new Standard_Real [N+1];
du=umax-umin;
dv=vmax-vmin;
Pnts2dX = (Standard_Real *)MyPnts2dX;
Pnts2dY = (Standard_Real *)MyPnts2dY;
//
iLower=TP2d.Lower();
for(i = 0; i<N; ++i) {
const gp_Pnt2d& aP2D=TP2d(i+iLower);
Pnts2dX[i] = Transform2d(aP2D.X(), umin, du);
Pnts2dY[i] = Transform2d(aP2D.Y(), vmin, dv);
}
Pnts2dX[N]=Pnts2dX[0];
Pnts2dY[N]=Pnts2dY[0];
//
if(du>aPrc) {
Tolu/=du;
}
if(dv>aPrc) {
Tolv/=dv;
}
}
}
//=======================================================================
//function : Destroy
//purpose :
//=======================================================================
void CSLib_Class2d::Destroy() {
if(MyPnts2dX) {
delete [] (Standard_Real *)MyPnts2dX;
MyPnts2dX=NULL;
}
if(MyPnts2dY) {
delete [] (Standard_Real *)MyPnts2dY;
MyPnts2dY=NULL;
}
}
//-- Attention Tableau de 0 ------> N + 1
//-- P1 ..... Pn P1
//--
//-- 1 2 3
//-- 4 0 5
//-- 6 7 8
//--
//=======================================================================
//function : SiDans
//purpose :
//=======================================================================
Standard_Integer CSLib_Class2d::SiDans(const gp_Pnt2d& P) const
{
if(!N) {
return 0;
}
//
Standard_Real x,y, aTolu, aTolv;
//
x = P.X(); y = P.Y();
aTolu=Tolu*(Umax-Umin);
aTolv=Tolv*(Vmax-Vmin);
//
if(Umin<Umax && Vmin<Vmax) {
if( ( x<(Umin-aTolu) ) ||
( x>(Umax+aTolu) ) ||
( y<(Vmin-aTolv) ) ||
( y>(Vmax+aTolv) ) ) {
return -1;
}
x=Transform2d(x,Umin,Umax-Umin);
y=Transform2d(y,Vmin,Vmax-Vmin);
}
Standard_Integer res = InternalSiDansOuOn(x,y);
if(res==-1) { //-- on est peut etre ON
return 0;
}
if(Tolu || Tolv) {
if(res != InternalSiDans(x-Tolu,y-Tolv)) return 0;
if(res != InternalSiDans(x+Tolu,y-Tolv)) return 0;
if(res != InternalSiDans(x-Tolu,y+Tolv)) return 0;
if(res != InternalSiDans(x+Tolu,y+Tolv)) return 0;
}
//
return((res)? 1: -1);
}
//=======================================================================
//function : SiDans_OnMode
//purpose :
//=======================================================================
Standard_Integer CSLib_Class2d::SiDans_OnMode(const gp_Pnt2d& P,
const Standard_Real Tol) const
{
if(!N){
return 0;
}
//
Standard_Real x,y, aTolu, aTolv;
//
x = P.X(); y = P.Y();
aTolu=Tol;
aTolv=Tol;
//-- ****** A FAIRE PLUS TARD, ESTIMER EN CHAQUE POINT la Tol2d en fct de la Tol3d *****
if(Umin<Umax && Vmin<Vmax) {
if(x<(Umin-aTolu) || (x>Umax+aTolu) ||
(y<Vmin-aTolv) || (y>Vmax+aTolv)) {
return -1;
}
x=Transform2d(x,Umin,Umax-Umin);
y=Transform2d(y,Vmin,Vmax-Vmin);
}
//
Standard_Integer res = InternalSiDansOuOn(x,y);
if(aTolu || aTolv) {
if(res != InternalSiDans(x-aTolu,y-aTolv)) return 0;
if(res != InternalSiDans(x+aTolu,y-aTolv)) return 0;
if(res != InternalSiDans(x-aTolu,y+aTolv)) return 0;
if(res != InternalSiDans(x+aTolu,y+aTolv)) return 0;
}
return((res)? 1: -1);
}
//=======================================================================
//function : InternalSiDans
//purpose :
//=======================================================================
Standard_Integer CSLib_Class2d::InternalSiDans(const Standard_Real Px,
const Standard_Real Py) const
{
Standard_Integer nbc, i, ip1, SH, NH;
Standard_Real *Pnts2dX, *Pnts2dY;
Standard_Real x, y, nx, ny;
//
nbc = 0;
i = 0;
ip1 = 1;
Pnts2dX = (Standard_Real *)MyPnts2dX;
Pnts2dY = (Standard_Real *)MyPnts2dY;
x = (Pnts2dX[i]-Px);
y = (Pnts2dY[i]-Py);
SH = (y<0.)? -1 : 1;
//
for(i=0; i<N ; i++,ip1++) {
nx = Pnts2dX[ip1] - Px;
ny = Pnts2dY[ip1] - Py;
NH = (ny<0.)? -1 : 1;
if(NH!=SH) {
if(x>0. && nx>0.) {
nbc++;
}
else {
if(x>0.0 || nx>0.) {
if((x-y*(nx-x)/(ny-y))>0.) {
nbc++;
}
}
}
SH = NH;
}
x = nx; y = ny;
}
return(nbc&1);
}
//modified by NIZNHY-PKV Fri Jan 15 09:03:48 2010f
//=======================================================================
//function : InternalSiDansOuOn
//purpose : meme code que ci-dessus + test sur ON (return(-1) dans ce cas
//=======================================================================
Standard_Integer CSLib_Class2d::InternalSiDansOuOn(const Standard_Real Px,
const Standard_Real Py) const
{
Standard_Integer nbc, i, ip1, SH, NH, iRet;
Standard_Real *Pnts2dX, *Pnts2dY;
Standard_Real x, y, nx, ny, aX;
Standard_Real aYmin, aTol;
//
aTol=(Tolu>Tolv)? Tolu : Tolv;
nbc = 0;
i = 0;
ip1 = 1;
Pnts2dX = (Standard_Real *)MyPnts2dX;
Pnts2dY = (Standard_Real *)MyPnts2dY;
x = (Pnts2dX[i]-Px);
y = (Pnts2dY[i]-Py);
aYmin=y;
SH = (y<0.)? -1 : 1;
for(i=0; i<N ; i++, ip1++) {
nx = Pnts2dX[ip1] - Px;
ny = Pnts2dY[ip1] - Py;
//-- le 14 oct 97
if(nx<Tolu && nx>-Tolu && ny<Tolv && ny>-Tolv) {
iRet=-1;
return iRet;
}
//find Y coordinate of polyline for current X gka
//in order to detect possible status ON
Standard_Real aDx = (Pnts2dX[ip1] - Pnts2dX[ip1-1]);
if( (Pnts2dX[ip1-1] - Px) * nx < 0.)
{
Standard_Real aCurPY = Pnts2dY[ip1] - (Pnts2dY[ip1] - Pnts2dY[ip1-1])/aDx *nx;
Standard_Real aDeltaY = aCurPY - Py;
if(aDeltaY >= -Tolv && aDeltaY <= Tolv)
{
iRet=-1;
return iRet;
}
}
//
NH = (ny<0.)? -1 : 1;
if(NH!=SH) {
if(x>0. && nx>0.) {
nbc++;
}
else {
if(x>0. || nx>0.) {
aX=x-y*(nx-x)/(ny-y);
if(aX>0.){
nbc++;
}
}
}
SH = NH;
}
else {// y has same sign as ny
if (ny<aYmin) {
aYmin=ny;
}
}
x = nx; y = ny;
}// for(i=0; i<N ; i++,ip1++) {
iRet=nbc&1;
return iRet;
}
//modified by NIZNHY-PKV Fri Jan 15 09:03:55 2010t
//=======================================================================
//function : Copy
//purpose :
//=======================================================================
const CSLib_Class2d& CSLib_Class2d::Copy(const CSLib_Class2d& ) const
{
cerr<<"Copy not allowed in CSLib_Class2d"<<endl;
Standard_ConstructionError::Raise();
return *this;
}
//=======================================================================
//function : Transform2d
//purpose :
//=======================================================================
Standard_Real Transform2d(const Standard_Real u,
const Standard_Real umin,
const Standard_Real umaxmumin)
{
if(umaxmumin>1e-10) {
Standard_Real U = (u-umin)/umaxmumin;
return U;
}
else {
return u;
}
}

View File

@@ -0,0 +1,40 @@
-- File: SingularityAna_PolyStyle.cdl
-- Created: Fri Aug 23 10:33:30 1996
-- Author: Benoit TANNIOU
-- <bt1@sgi65>
---Copyright: Matra Datavision 1996
private class NormalPolyDef from CSLib
inherits FunctionWithDerivative from math
uses
Array1OfReal from TColStd
is
Create(k0:Integer; li:Array1OfReal) returns NormalPolyDef from CSLib;
Value(me: in out; X: Real; F: out Real)
---Purpose: computes the value <F>of the function for the variable <X>.
-- Returns True if the calculation were successfully done,
-- False otherwise.
returns Boolean;
Derivative(me: in out; X: Real; D: out Real)
---Purpose: computes the derivative <D> of the function
-- for the variable <X>.
-- Returns True if the calculation were successfully done,
-- False otherwise.
returns Boolean;
Values(me: in out; X: Real; F, D: out Real)
---Purpose: computes the value <F> and the derivative <D> of the
-- function for the variable <X>.
-- Returns True if the calculation were successfully done,
-- False otherwise.
returns Boolean;
fields
myK0: Integer from Standard;
myTABli: Array1OfReal from TColStd;
end NormalPolyDef;

View File

@@ -0,0 +1,75 @@
// File: SingularityAna_PolyStyle.cxx
// Created: Fri Aug 23 11:00:24 1996
// Author: Benoit TANNIOU
// <bt1@sgi65>
#include <CSLib_NormalPolyDef.ixx>
#include <PLib.hxx>
//=============================================================================
CSLib_NormalPolyDef::CSLib_NormalPolyDef(const Standard_Integer k0,
const TColStd_Array1OfReal& li)
//=============================================================================
:myTABli(0,k0)
{
myK0=k0;
for(Standard_Integer i=0;i<=k0;i++)
myTABli(i)=li(i);
}
//=============================================================================
Standard_Boolean CSLib_NormalPolyDef::Value(const Standard_Real X,
Standard_Real& F)
//=============================================================================
{
F=0.0;
Standard_Real co,si;
co=cos(X);
si=sin(X);
PLib::Binomial(myK0);
for(Standard_Integer i=0;i<=myK0;i++){
F=F+PLib::Bin(myK0,i)*pow(co,i)*pow(si,(myK0-i))*myTABli(i);
}
return Standard_True;
}
//=============================================================================
Standard_Boolean CSLib_NormalPolyDef::Derivative(const Standard_Real X,
Standard_Real& D)
//=============================================================================
{
D=0.0;
Standard_Real co,si;
co=cos(X);
si=sin(X);
for(Standard_Integer i=0;i<=myK0;i++){
D=D+PLib::Bin(myK0,i)*pow(co,(i-1))*pow(si,(myK0-i-1))*(myK0*co*co-i);
}
return Standard_True;
}
//=============================================================================
Standard_Boolean CSLib_NormalPolyDef::Values(const Standard_Real X,
Standard_Real& F,
Standard_Real& D)
//=============================================================================
{
F=0;
D=0;
Standard_Real co,si;
co=cos(X);
si=sin(X);
for(Standard_Integer i=0;i<=myK0;i++){
F=F+PLib::Bin(myK0,i)*pow(co,i)*pow(si,(myK0-i))*myTABli(i);
D=D+PLib::Bin(myK0,i)*pow(co,(i-1))*
pow(si,(myK0-i-1))*(myK0*co*co-i)*myTABli(i);
}
return Standard_True;
}