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

0024513: Suspicious code highlighted by 0024510

Blend_Walking_1: value returned by TestArret() deleted.
IntTools_EdgeFace: deleted redundant parameter ff2 and anIsProj2 associated with ff2, since ff2 = !ff1. Refactoring.
ProjLib_ProjectedCurve: treatment of surface of revolution is symmetric for surface of revolution now. Refactoring.
This commit is contained in:
aml
2014-04-16 10:42:28 +04:00
committed by apn
parent c26b5a34bc
commit 5546828378
3 changed files with 418 additions and 382 deletions

View File

@@ -165,8 +165,7 @@ void Blend_Walking::Perform(Blend_Function& Func,
} }
Standard_Boolean Blend_Walking::PerformFirstSection Standard_Boolean Blend_Walking::PerformFirstSection(Blend_Function& Func,
(Blend_Function& Func,
const Standard_Real Pdep, const Standard_Real Pdep,
math_Vector& ParDep, math_Vector& ParDep,
const Standard_Real Tolesp, const Standard_Real Tolesp,
@@ -182,43 +181,41 @@ Standard_Boolean Blend_Walking::PerformFirstSection
Pos1 = Pos2 = TopAbs_UNKNOWN; Pos1 = Pos2 = TopAbs_UNKNOWN;
Blend_Status State;
param = Pdep; param = Pdep;
Func.Set(param); Func.Set(param);
math_Vector tolerance(1,4),infbound(1,4),supbound(1,4); math_Vector tolerance(1, 4),infbound(1, 4),supbound(1, 4);
Func.GetTolerance(tolerance,tolesp); Func.GetTolerance(tolerance, tolesp);
Func.GetBounds(infbound,supbound); Func.GetBounds(infbound, supbound);
math_FunctionSetRoot rsnld(Func,tolerance,30); math_FunctionSetRoot rsnld(Func, tolerance, 30);
rsnld.Perform(Func,ParDep,infbound,supbound); rsnld.Perform(Func, ParDep, infbound, supbound);
if (!rsnld.IsDone()) { if (!rsnld.IsDone())
{
return Standard_False; return Standard_False;
} }
rsnld.Root(sol); rsnld.Root(sol);
ParDep = sol; ParDep = sol;
Pos1 = domain1->Classify(gp_Pnt2d(sol(1),sol(2)), Pos1 = domain1->Classify(gp_Pnt2d(sol(1), sol(2)), Min(tolerance(1), tolerance(2)), 0);
Min(tolerance(1),tolerance(2)),0); Pos2 = domain2->Classify(gp_Pnt2d(sol(3), sol(4)), Min(tolerance(3), tolerance(4)), 0);
Pos2 = domain2->Classify(gp_Pnt2d(sol(3),sol(4)), if (Pos1 != TopAbs_IN || Pos2 != TopAbs_IN)
Min(tolerance(3),tolerance(4)),0); {
if (Pos1 != TopAbs_IN || Pos2 != TopAbs_IN) {
return Standard_False; return Standard_False;
} }
State = TestArret(Func, Blend_OK, Standard_False); TestArret(Func, Blend_OK, Standard_False);
#ifdef DEB #ifdef DEB
if (Blend_GettraceDRAWSECT()){ if (Blend_GettraceDRAWSECT())
Drawsect(surf1,surf2,sol,param,Func); {
Drawsect(surf1, surf2, sol, param, Func);
} }
#endif #endif
return Standard_True; return Standard_True;
} }
Standard_Boolean Blend_Walking::PerformFirstSection Standard_Boolean Blend_Walking::PerformFirstSection (Blend_Function& Func,
(Blend_Function& Func,
Blend_FuncInv& FuncInv, Blend_FuncInv& FuncInv,
const Standard_Real Pdep, const Standard_Real Pdep,
const Standard_Real Pmax, const Standard_Real Pmax,
@@ -235,63 +232,71 @@ Standard_Boolean Blend_Walking::PerformFirstSection
comptra = Standard_False; comptra = Standard_False;
line = new TheLine (); line = new TheLine ();
Standard_Real w1,w2, extrapol; Standard_Real w1, w2, extrapol;
Standard_Boolean recad1,recad2; Standard_Boolean recad1, recad2;
tolesp = Abs(Tolesp); tolesp = Abs(Tolesp);
tolgui = Abs(TolGuide); tolgui = Abs(TolGuide);
if (Pmax-Pdep >= 0.) { if (Pmax - Pdep >= 0.0)
{
sens = 1.; sens = 1.;
} }
else { else
{
sens = -1.; sens = -1.;
} }
extrapol = Abs(Pmax-Pdep)/50; // 2% extrapol = Abs(Pmax - Pdep) / 50.0; // 2%
Blend_Status State; Blend_Status State;
param = Pdep; param = Pdep;
Func.Set(param); Func.Set(param);
math_Vector tolerance(1,4),infbound(1,4),supbound(1,4); math_Vector tolerance(1, 4),infbound(1, 4),supbound(1, 4);
math_Vector solrst1(1,4),solrst2(1,4); math_Vector solrst1(1, 4),solrst2(1, 4);
TheExtremity Ext1,Ext2; TheExtremity Ext1, Ext2;
Standard_Integer Index1 = 0, Index2 = 0, nbarc; Standard_Integer Index1 = 0, Index2 = 0, nbarc;
Standard_Boolean Isvtx1 = Standard_False, Isvtx2 = Standard_False; Standard_Boolean Isvtx1 = Standard_False, Isvtx2 = Standard_False;
TheVertex Vtx1,Vtx2; TheVertex Vtx1, Vtx2;
gp_Pnt2d p2d; gp_Pnt2d p2d;
Func.GetTolerance(tolerance,tolesp); Func.GetTolerance(tolerance, tolesp);
Func.GetBounds(infbound,supbound); Func.GetBounds(infbound, supbound);
math_FunctionSetRoot rsnld(Func,tolerance,30); math_FunctionSetRoot rsnld(Func, tolerance, 30);
rsnld.Perform(Func,ParDep,infbound,supbound); rsnld.Perform(Func, ParDep, infbound, supbound);
if (!rsnld.IsDone()) { if (!rsnld.IsDone())
{
return Standard_False; return Standard_False;
} }
rsnld.Root(sol); rsnld.Root(sol);
w1 = w2 = Pmax; w1 = w2 = Pmax;
recad1 = RecOnS1 && Recadre(FuncInv,Standard_True, recad1 = RecOnS1 && Recadre(FuncInv, Standard_True, sol, solrst1,
sol,solrst1,Index1,Isvtx1,Vtx1, extrapol); Index1, Isvtx1, Vtx1, extrapol);
if (recad1) { if (recad1)
{
w1 = solrst1(2); w1 = solrst1(2);
} }
recad2 = RecOnS2 && Recadre(FuncInv,Standard_False, recad2 = RecOnS2 && Recadre(FuncInv, Standard_False, sol, solrst2,
sol,solrst2,Index2,Isvtx2,Vtx2, extrapol); Index2, Isvtx2, Vtx2, extrapol);
if (recad2) { if (recad2)
{
w2 = solrst2(2); w2 = solrst2(2);
} }
if (!recad1 && !recad2) { if (!recad1 && !recad2)
{
return Standard_False; return Standard_False;
} }
if (recad1 && recad2) { if (recad1 && recad2)
if (Abs(w1-w2) <= tolgui) { {
if (Abs(w1 - w2) <= tolgui)
{
//sol sur 1 et 2 a la fois //sol sur 1 et 2 a la fois
State = Blend_OnRst12; State = Blend_OnRst12;
param = w1; param = w1;
@@ -300,70 +305,78 @@ Standard_Boolean Blend_Walking::PerformFirstSection
ParSol(3) = solrst1(3); ParSol(3) = solrst1(3);
ParSol(4) = solrst1(4); ParSol(4) = solrst1(4);
} }
else if (sens*(w2-w1) < 0.) { // on garde le plus grand else if (sens * (w2 - w1) < 0.0)
{ // on garde le plus grand
//sol sur 1 //sol sur 1
State = Blend_OnRst1; State = Blend_OnRst1;
param = w1; param = w1;
recdomain1->Init(); recdomain1->Init();
nbarc = 1; nbarc = 1;
while (nbarc < Index1) { while (nbarc < Index1)
{
nbarc++; nbarc++;
recdomain1->Next(); recdomain1->Next();
} }
p2d = TheArcTool::Value(recdomain1->Value(),solrst1(1)); p2d = TheArcTool::Value(recdomain1->Value(), solrst1(1));
ParSol(1) = p2d.X(); ParSol(1) = p2d.X();
ParSol(2) = p2d.Y(); ParSol(2) = p2d.Y();
ParSol(3) = solrst1(3); ParSol(3) = solrst1(3);
ParSol(4) = solrst1(4); ParSol(4) = solrst1(4);
} }
else { else
{
//sol sur 2 //sol sur 2
State = Blend_OnRst2; State = Blend_OnRst2;
param = w2; param = w2;
recdomain2->Init(); recdomain2->Init();
nbarc = 1; nbarc = 1;
while (nbarc < Index2) { while (nbarc < Index2)
{
nbarc++; nbarc++;
recdomain2->Next(); recdomain2->Next();
} }
p2d = TheArcTool::Value(recdomain2->Value(),solrst2(1)); p2d = TheArcTool::Value(recdomain2->Value(), solrst2(1));
ParSol(1) = solrst2(3); ParSol(1) = solrst2(3);
ParSol(2) = solrst2(4); ParSol(2) = solrst2(4);
ParSol(3) = p2d.X(); ParSol(3) = p2d.X();
ParSol(4) = p2d.Y(); ParSol(4) = p2d.Y();
} }
} }
else if (recad1) { else if (recad1)
{
// sol sur 1 // sol sur 1
State = Blend_OnRst1; State = Blend_OnRst1;
param = w1; param = w1;
recdomain1->Init(); recdomain1->Init();
nbarc = 1; nbarc = 1;
while (nbarc < Index1) { while (nbarc < Index1)
{
nbarc++; nbarc++;
recdomain1->Next(); recdomain1->Next();
} }
p2d = TheArcTool::Value(recdomain1->Value(),solrst1(1)); p2d = TheArcTool::Value(recdomain1->Value(), solrst1(1));
ParSol(1) = p2d.X(); ParSol(1) = p2d.X();
ParSol(2) = p2d.Y(); ParSol(2) = p2d.Y();
ParSol(3) = solrst1(3); ParSol(3) = solrst1(3);
ParSol(4) = solrst1(4); ParSol(4) = solrst1(4);
} }
else { //if (recad2) { else
{ //if (recad2) {
//sol sur 2 //sol sur 2
State = Blend_OnRst2; State = Blend_OnRst2;
param = w2; param = w2;
recdomain2->Init(); recdomain2->Init();
nbarc = 1; nbarc = 1;
while (nbarc < Index2) { while (nbarc < Index2)
{
nbarc++; nbarc++;
recdomain2->Next(); recdomain2->Next();
} }
p2d = TheArcTool::Value(recdomain2->Value(),solrst2(1)); p2d = TheArcTool::Value(recdomain2->Value(), solrst2(1));
ParSol(1) = solrst2(3); ParSol(1) = solrst2(3);
ParSol(2) = solrst2(4); ParSol(2) = solrst2(4);
ParSol(3) = p2d.X(); ParSol(3) = p2d.X();
@@ -374,46 +387,44 @@ Standard_Boolean Blend_Walking::PerformFirstSection
sol = ParSol; sol = ParSol;
Func.Set(param); Func.Set(param);
State = TestArret(Func, State, Standard_False); State = TestArret(Func, State, Standard_False);
switch (State) { switch (State)
case Blend_OnRst1 :
{ {
#ifdef DEB case Blend_OnRst1:
if (Blend_GettraceDRAWSECT()){ {
Drawsect(surf1,surf2,sol,param,Func); #ifdef DEB
if (Blend_GettraceDRAWSECT())
{
Drawsect(surf1, surf2, sol, param, Func);
} }
#endif #endif
MakeExtremity(Ext1,Standard_True,Index1, MakeExtremity(Ext1, Standard_True, Index1, solrst1(1), Isvtx1, Vtx1);
solrst1(1),Isvtx1,Vtx1); Ext2.SetValue(previousP.PointOnS2(), sol(3), sol(4), tolesp);
Ext2.SetValue(previousP.PointOnS2(),
sol(3),sol(4),tolesp);
} }
break; break;
case Blend_OnRst2 : case Blend_OnRst2:
{ {
#ifdef DEB #ifdef DEB
if (Blend_GettraceDRAWSECT()){ if (Blend_GettraceDRAWSECT())
Drawsect(surf1,surf2,sol,param,Func); {
Drawsect(surf1, surf2, sol, param, Func);
} }
#endif #endif
Ext1.SetValue(previousP.PointOnS1(), Ext1.SetValue(previousP.PointOnS1(), sol(1), sol(2), tolesp);
sol(1),sol(2),tolesp); MakeExtremity(Ext2, Standard_False, Index2, solrst2(1), Isvtx2, Vtx2);
MakeExtremity(Ext2,Standard_False,Index2,
solrst2(1),Isvtx2,Vtx2);
} }
break; break;
case Blend_OnRst12 : case Blend_OnRst12 :
{ {
#ifdef DEB #ifdef DEB
if (Blend_GettraceDRAWSECT()){ if (Blend_GettraceDRAWSECT())
Drawsect(surf1,surf2,sol,param,Func); {
Drawsect(surf1, surf2, sol, param, Func);
} }
#endif #endif
MakeExtremity(Ext1,Standard_True,Index1, MakeExtremity(Ext1, Standard_True , Index1, solrst1(1), Isvtx1, Vtx1);
solrst1(1),Isvtx1,Vtx1); MakeExtremity(Ext2, Standard_False, Index2, solrst2(1), Isvtx2, Vtx2);
MakeExtremity(Ext2,Standard_False,Index2,
solrst2(1),Isvtx2,Vtx2);
} }
break; break;
default: default:
@@ -421,11 +432,13 @@ Standard_Boolean Blend_Walking::PerformFirstSection
Standard_Failure::Raise("Blend_Walking::PerformFirstSection : echec"); Standard_Failure::Raise("Blend_Walking::PerformFirstSection : echec");
} }
} }
if (sens < 0.) { if (sens < 0.0)
line->SetEndPoints(Ext1,Ext2); {
line->SetEndPoints(Ext1, Ext2);
} }
else { else
line->SetStartPoints(Ext1,Ext2); {
line->SetStartPoints(Ext1, Ext2);
} }
return Standard_True; return Standard_True;
} }
@@ -570,4 +583,3 @@ void Blend_Walking::Check(const Standard_Boolean C)
{ {
check = C; check = C;
} }

View File

@@ -400,40 +400,41 @@ void IntTools_EdgeFace::Prepare()
//function : FindProjectableRoot //function : FindProjectableRoot
//purpose : //purpose :
//======================================================================= //=======================================================================
void IntTools_EdgeFace::FindProjectableRoot void IntTools_EdgeFace::FindProjectableRoot (const Standard_Real tt1,
(const Standard_Real tt1,
const Standard_Real tt2, const Standard_Real tt2,
const Standard_Integer ff1, const Standard_Integer ff1,
const Standard_Integer ff2, const Standard_Integer /*ff2*/,
Standard_Real& tRoot) Standard_Real& tRoot)
{ {
Standard_Real tm, t1, t2, aEpsT; Standard_Real tm, t1, t2, aEpsT;
Standard_Integer anIsProj1, anIsProj2, anIsProjm; Standard_Integer anIsProj1, anIsProjm;
aEpsT=0.5*myEpsT; aEpsT = 0.5 * myEpsT;
//
// Root is inside [tt1, tt2]
t1=tt1;
t2=tt2;
anIsProj1=ff1;
anIsProj2=ff2;
for(;;) { // Root is inside [tt1, tt2]
if (fabs(t1-t2) < aEpsT) { t1 = tt1;
tRoot=(anIsProj1) ? t1 : t2; t2 = tt2;
anIsProj1 = ff1;
for(;;)
{
if (fabs(t1 - t2) < aEpsT)
{
tRoot = (anIsProj1) ? t1 : t2;
return; return;
} }
tm=.5*(t1+t2); tm = 0.5 * (t1 + t2);
anIsProjm=IsProjectable(tm); anIsProjm = IsProjectable(tm);
if (anIsProjm != anIsProj1) { if (anIsProjm != anIsProj1)
t2=tm; {
anIsProj2=anIsProjm; t2 = tm;
}
else {
t1=tm;
anIsProj1=anIsProjm;
} }
else
{
t1 = tm;
anIsProj1 = anIsProjm;
} }
} // for(;;)
} }
//======================================================================= //=======================================================================
//function : IsProjectable //function : IsProjectable

View File

@@ -332,8 +332,8 @@ void ProjLib_ProjectedCurve::Load(const Handle(Adaptor3d_HCurve)& C)
GeomAbs_SurfaceType SType = mySurface->GetType(); GeomAbs_SurfaceType SType = mySurface->GetType();
GeomAbs_CurveType CType = myCurve->GetType(); GeomAbs_CurveType CType = myCurve->GetType();
switch (SType) { switch (SType)
{
case GeomAbs_Plane: case GeomAbs_Plane:
{ {
ProjLib_Plane P(mySurface->Plane()); ProjLib_Plane P(mySurface->Plane());
@@ -362,7 +362,8 @@ void ProjLib_ProjectedCurve::Load(const Handle(Adaptor3d_HCurve)& C)
{ {
ProjLib_Sphere P(mySurface->Sphere()); ProjLib_Sphere P(mySurface->Sphere());
Project(P,myCurve); Project(P,myCurve);
if ( P.IsDone()) { if ( P.IsDone())
{
// on met dans la pseudo-periode ( car Sphere n'est pas // on met dans la pseudo-periode ( car Sphere n'est pas
// periodique en V !) // periodique en V !)
P.SetInBounds(myCurve->FirstParameter()); P.SetInBounds(myCurve->FirstParameter());
@@ -382,59 +383,63 @@ void ProjLib_ProjectedCurve::Load(const Handle(Adaptor3d_HCurve)& C)
case GeomAbs_BezierSurface: case GeomAbs_BezierSurface:
case GeomAbs_BSplineSurface: case GeomAbs_BSplineSurface:
{ {
Standard_Boolean IsTrimmed[2] = {Standard_False, Standard_False}; Standard_Boolean IsTrimmed[2] = {Standard_False, Standard_False};
Standard_Integer SingularCase[2]; Standard_Integer SingularCase[2];
Standard_Real f, l, dt; Standard_Real f, l, dt;
const Standard_Real eps = 0.01; const Standard_Real eps = 0.01;
f = myCurve->FirstParameter(); f = myCurve->FirstParameter();
l = myCurve->LastParameter(); l = myCurve->LastParameter();
dt = (l-f)*eps; dt = (l - f) * eps;
Standard_Real U1=0.,U2=0.,V1=0.,V2=0; Standard_Real U1 = 0.0, U2=0.0, V1=0.0, V2=0.0;
const Adaptor3d_Surface& S = mySurface->Surface(); const Adaptor3d_Surface& S = mySurface->Surface();
U1 = S.FirstUParameter(); U1 = S.FirstUParameter();
U2 = S.LastUParameter(); U2 = S.LastUParameter();
V1 = S.FirstVParameter(); V1 = S.FirstVParameter();
V2 = S.LastVParameter(); V2 = S.LastVParameter();
if(IsoIsDeg(S, U1, GeomAbs_IsoU, 0., myTolerance) ) { if(IsoIsDeg(S, U1, GeomAbs_IsoU, 0., myTolerance))
{
//Surface has pole at U = Umin //Surface has pole at U = Umin
gp_Pnt Pole = mySurface->Value(U1, V1); gp_Pnt Pole = mySurface->Value(U1, V1);
TrimC3d(myCurve, IsTrimmed, dt, Pole, SingularCase, 1); TrimC3d(myCurve, IsTrimmed, dt, Pole, SingularCase, 1);
} }
if(IsoIsDeg(S, U2, GeomAbs_IsoU, 0., myTolerance) ) { if(IsoIsDeg(S, U2, GeomAbs_IsoU, 0., myTolerance))
{
//Surface has pole at U = Umax //Surface has pole at U = Umax
gp_Pnt Pole = mySurface->Value(U2, V1); gp_Pnt Pole = mySurface->Value(U2, V1);
TrimC3d(myCurve, IsTrimmed, dt, Pole, SingularCase, 2); TrimC3d(myCurve, IsTrimmed, dt, Pole, SingularCase, 2);
} }
if(IsoIsDeg(S, V1, GeomAbs_IsoV, 0., myTolerance) ) { if(IsoIsDeg(S, V1, GeomAbs_IsoV, 0., myTolerance))
{
//Surface has pole at V = Vmin //Surface has pole at V = Vmin
gp_Pnt Pole = mySurface->Value(U1, V1); gp_Pnt Pole = mySurface->Value(U1, V1);
TrimC3d(myCurve, IsTrimmed, dt, Pole, SingularCase, 3); TrimC3d(myCurve, IsTrimmed, dt, Pole, SingularCase, 3);
} }
if(IsoIsDeg(S, V2, GeomAbs_IsoV, 0., myTolerance) ) { if(IsoIsDeg(S, V2, GeomAbs_IsoV, 0., myTolerance))
{
//Surface has pole at V = Vmax //Surface has pole at V = Vmax
gp_Pnt Pole = mySurface->Value(U1, V2); gp_Pnt Pole = mySurface->Value(U1, V2);
TrimC3d(myCurve, IsTrimmed, dt, Pole, SingularCase, 4); TrimC3d(myCurve, IsTrimmed, dt, Pole, SingularCase, 4);
} }
ProjLib_ComputeApproxOnPolarSurface polar(myCurve, ProjLib_ComputeApproxOnPolarSurface polar(myCurve, mySurface, myTolerance);
mySurface,
myTolerance);
Handle(Geom2d_BSplineCurve) aRes = polar.BSpline(); Handle(Geom2d_BSplineCurve) aRes = polar.BSpline();
if(IsTrimmed[0] || IsTrimmed[1]) { if(IsTrimmed[0] || IsTrimmed[1])
if(IsTrimmed[0]) { {
if(IsTrimmed[0])
{
//Add segment before start of curve //Add segment before start of curve
f = myCurve->FirstParameter(); f = myCurve->FirstParameter();
ExtendC2d(aRes, f, -dt, U1, U2, V1, V2, 0, SingularCase[0]); ExtendC2d(aRes, f, -dt, U1, U2, V1, V2, 0, SingularCase[0]);
} }
if(IsTrimmed[1]) { if(IsTrimmed[1])
{
//Add segment after end of curve //Add segment after end of curve
l = myCurve->LastParameter(); l = myCurve->LastParameter();
ExtendC2d(aRes, l, dt, U1, U2, V1, V2, 1, SingularCase[1]); ExtendC2d(aRes, l, dt, U1, U2, V1, V2, 1, SingularCase[1]);
@@ -442,8 +447,7 @@ void ProjLib_ProjectedCurve::Load(const Handle(Adaptor3d_HCurve)& C)
Handle(Geom2d_Curve) NewCurve2d; Handle(Geom2d_Curve) NewCurve2d;
GeomLib::SameRange(Precision::PConfusion(), aRes, GeomLib::SameRange(Precision::PConfusion(), aRes,
aRes->FirstParameter(), aRes->LastParameter(), aRes->FirstParameter(), aRes->LastParameter(),
FirstPar, LastPar, FirstPar, LastPar, NewCurve2d);
NewCurve2d);
aRes = Handle(Geom2d_BSplineCurve)::DownCast(NewCurve2d); aRes = Handle(Geom2d_BSplineCurve)::DownCast(NewCurve2d);
} }
myResult.SetBSpline(aRes); myResult.SetBSpline(aRes);
@@ -455,11 +459,12 @@ void ProjLib_ProjectedCurve::Load(const Handle(Adaptor3d_HCurve)& C)
default: default:
{ {
Standard_Boolean IsTrimmed[2] = {Standard_False, Standard_False}; Standard_Boolean IsTrimmed[2] = {Standard_False, Standard_False};
Standard_Real Vsingular[2] = { 0.0 , 0.0 }; //for surfaces of revolution Standard_Real Vsingular[2] = {0.0 , 0.0}; //for surfaces of revolution
Standard_Real f = 0., l = 0., dt = 0.; Standard_Real f = 0.0, l = 0.0, dt = 0.0;
const Standard_Real eps = 0.01; const Standard_Real eps = 0.01;
if(mySurface->GetType() == GeomAbs_SurfaceOfRevolution) { if(mySurface->GetType() == GeomAbs_SurfaceOfRevolution)
{
//Check possible singularity //Check possible singularity
gp_Pnt P = mySurface->AxeOfRevolution().Location(); gp_Pnt P = mySurface->AxeOfRevolution().Location();
@@ -469,42 +474,44 @@ void ProjLib_ProjectedCurve::Load(const Handle(Adaptor3d_HCurve)& C)
f = myCurve->FirstParameter(); f = myCurve->FirstParameter();
l = myCurve->LastParameter(); l = myCurve->LastParameter();
dt = (l-f)*eps; dt = (l - f) * eps;
P = myCurve->Value(f); P = myCurve->Value(f);
if(L.Distance(P) < Precision::Confusion()) { if(L.Distance(P) < Precision::Confusion())
{
IsTrimmed[0] = Standard_True; IsTrimmed[0] = Standard_True;
f = f+dt; f = f + dt;
myCurve = myCurve->Trim(f, l, Precision::Confusion()); myCurve = myCurve->Trim(f, l, Precision::Confusion());
Vsingular[0] = ElCLib::Parameter(L, P); Vsingular[0] = ElCLib::Parameter(L, P);
//SingularCase[0] = 3; //SingularCase[0] = 3;
} }
P = myCurve->Value(l); P = myCurve->Value(l);
if(L.Distance(P) < Precision::Confusion()) { if(L.Distance(P) < Precision::Confusion())
{
IsTrimmed[1] = Standard_True; IsTrimmed[1] = Standard_True;
l = l-dt; l = l - dt;
myCurve = myCurve->Trim(f, l, Precision::Confusion()); myCurve = myCurve->Trim(f, l, Precision::Confusion());
Vsingular[1] = ElCLib::Parameter(L, P); Vsingular[1] = ElCLib::Parameter(L, P);
//SingularCase[1] = 3; //SingularCase[1] = 4;
} }
} }
ProjLib_CompProjectedCurve Projector(mySurface,myCurve, ProjLib_CompProjectedCurve Projector(mySurface,myCurve, myTolerance, myTolerance);
myTolerance,myTolerance); Handle(ProjLib_HCompProjectedCurve) HProjector = new ProjLib_HCompProjectedCurve();
Handle(ProjLib_HCompProjectedCurve) HProjector =
new ProjLib_HCompProjectedCurve();
HProjector->Set(Projector); HProjector->Set(Projector);
// Normalement, dans le cadre de ProjLib, le resultat // Normalement, dans le cadre de ProjLib, le resultat
// doit etre une et une seule courbe !!! // doit etre une et une seule courbe !!!
// De plus, cette courbe ne doit pas etre Single point // De plus, cette courbe ne doit pas etre Single point
Standard_Integer NbCurves = Projector.NbCurves(); Standard_Integer NbCurves = Projector.NbCurves();
Standard_Real Udeb = 0.,Ufin = 0.; Standard_Real Udeb = 0.0,Ufin = 0.0;
if (NbCurves > 0) { if (NbCurves > 0)
Projector.Bounds(1,Udeb,Ufin); {
Projector.Bounds(1, Udeb, Ufin);
} }
else { else
{
StdFail_NotDone::Raise("ProjLib CompProjectedCurve Not Done"); StdFail_NotDone::Raise("ProjLib CompProjectedCurve Not Done");
} }
// Approximons cette courbe algorithmique. // Approximons cette courbe algorithmique.
@@ -515,13 +522,13 @@ void ProjLib_ProjectedCurve::Load(const Handle(Adaptor3d_HCurve)& C)
Standard_Integer MaxSeg = 16; Standard_Integer MaxSeg = 16;
Approx_CurveOnSurface appr(HProjector, mySurface, Udeb, Ufin, Approx_CurveOnSurface appr(HProjector, mySurface, Udeb, Ufin,
myTolerance, myTolerance, Continuity, MaxDegree, MaxSeg,
Continuity, MaxDegree, MaxSeg,
Only3d, Only2d); Only3d, Only2d);
Handle(Geom2d_BSplineCurve) aRes = appr.Curve2d(); Handle(Geom2d_BSplineCurve) aRes = appr.Curve2d();
if(IsTrimmed[0] || IsTrimmed[1]) { if(IsTrimmed[0] || IsTrimmed[1])
{
// Treatment only for surface of revolution // Treatment only for surface of revolution
Standard_Real u1, u2, v1, v2; Standard_Real u1, u2, v1, v2;
u1 = mySurface->FirstUParameter(); u1 = mySurface->FirstUParameter();
@@ -529,19 +536,20 @@ void ProjLib_ProjectedCurve::Load(const Handle(Adaptor3d_HCurve)& C)
v1 = mySurface->FirstVParameter(); v1 = mySurface->FirstVParameter();
v2 = mySurface->LastVParameter(); v2 = mySurface->LastVParameter();
if(IsTrimmed[0]) { if(IsTrimmed[0])
{
//Add segment before start of curve //Add segment before start of curve
ExtendC2d(aRes, f, -dt, u1, u2, Vsingular[0], v2, 0, 3); ExtendC2d(aRes, f, -dt, u1, u2, Vsingular[0], v2, 0, 3);
} }
if(IsTrimmed[1]) { if(IsTrimmed[1])
{
//Add segment after end of curve //Add segment after end of curve
ExtendC2d(aRes, l, dt, u1, u2, Vsingular[1], v2, 1, 3); ExtendC2d(aRes, l, dt, u1, u2, v1, Vsingular[1], 1, 4);
} }
Handle(Geom2d_Curve) NewCurve2d; Handle(Geom2d_Curve) NewCurve2d;
GeomLib::SameRange(Precision::PConfusion(), aRes, GeomLib::SameRange(Precision::PConfusion(), aRes,
aRes->FirstParameter(), aRes->LastParameter(), aRes->FirstParameter(), aRes->LastParameter(),
FirstPar, LastPar, FirstPar, LastPar, NewCurve2d);
NewCurve2d);
aRes = Handle(Geom2d_BSplineCurve)::DownCast(NewCurve2d); aRes = Handle(Geom2d_BSplineCurve)::DownCast(NewCurve2d);
} }
@@ -550,50 +558,57 @@ void ProjLib_ProjectedCurve::Load(const Handle(Adaptor3d_HCurve)& C)
myResult.SetType(GeomAbs_BSplineCurve); myResult.SetType(GeomAbs_BSplineCurve);
} }
} }
if ( !myResult.IsDone()) { if ( !myResult.IsDone())
{
ProjLib_ComputeApprox Comp( myCurve, mySurface, myTolerance); ProjLib_ComputeApprox Comp( myCurve, mySurface, myTolerance);
myResult.Done(); myResult.Done();
// set the type // set the type
if ( SType == GeomAbs_Plane && CType == GeomAbs_BezierCurve) { if ( SType == GeomAbs_Plane && CType == GeomAbs_BezierCurve)
{
myResult.SetType(GeomAbs_BezierCurve); myResult.SetType(GeomAbs_BezierCurve);
myResult.SetBezier(Comp.Bezier()) ; myResult.SetBezier(Comp.Bezier()) ;
} }
else { else
{
myResult.SetType(GeomAbs_BSplineCurve); myResult.SetType(GeomAbs_BSplineCurve);
myResult.SetBSpline(Comp.BSpline()) ; myResult.SetBSpline(Comp.BSpline()) ;
} }
// set the periodicity flag // set the periodicity flag
if ( SType == GeomAbs_Plane && if (SType == GeomAbs_Plane &&
CType == GeomAbs_BSplineCurve && CType == GeomAbs_BSplineCurve &&
myCurve->IsPeriodic() ) { myCurve->IsPeriodic() )
{
myResult.SetPeriodic(); myResult.SetPeriodic();
} }
myTolerance = Comp.Tolerance(); myTolerance = Comp.Tolerance();
} }
else { else
{
// On remet arbitrairement la tol atteinte a une valeur // On remet arbitrairement la tol atteinte a une valeur
// petite en attendant mieux. dub lbo 11/03/97 // petite en attendant mieux. dub lbo 11/03/97
myTolerance = Min(myTolerance,Precision::Confusion()); myTolerance = Min(myTolerance,Precision::Confusion());
// Translate the projected curve to keep the first point // Translate the projected curve to keep the first point
// In the canonical boundaries of periodic surfaces. // In the canonical boundaries of periodic surfaces.
if (mySurface->IsUPeriodic()) { if (mySurface->IsUPeriodic())
{
// xf // xf
Standard_Real aT1, aT2, aU1, aU2, aUPeriod, aUr, aUm, aUmid, dUm, dUr; Standard_Real aT1, aT2, aU1, aU2, aUPeriod, aUr, aUm, aUmid, dUm, dUr;
GeomAbs_CurveType aTypeR; GeomAbs_CurveType aTypeR;
ProjLib_Projector aResult; ProjLib_Projector aResult;
// //
aT1=myCurve->FirstParameter(); aT1 = myCurve->FirstParameter();
aT2=myCurve->LastParameter(); aT2 = myCurve->LastParameter();
aU1=mySurface->FirstUParameter(); aU1 = mySurface->FirstUParameter();
aU2=mySurface->LastUParameter(); aU2 = mySurface->LastUParameter();
aUPeriod=mySurface->UPeriod(); aUPeriod = mySurface->UPeriod();
// //
aTypeR=myResult.GetType(); aTypeR = myResult.GetType();
if ((aU2-aU1)<(aUPeriod-myTolerance) && aTypeR == GeomAbs_Line) { if ((aU2 - aU1) < (aUPeriod - myTolerance) && aTypeR == GeomAbs_Line)
aResult=myResult; {
aResult = myResult;
aResult.UFrame(aT1, aT2, aU1, aUPeriod); aResult.UFrame(aT1, aT2, aU1, aUPeriod);
// //
gp_Lin2d &aLr = (gp_Lin2d &) aResult.Line(); gp_Lin2d &aLr = (gp_Lin2d &) aResult.Line();
@@ -601,14 +616,16 @@ void ProjLib_ProjectedCurve::Load(const Handle(Adaptor3d_HCurve)& C)
gp_Lin2d &aLm = (gp_Lin2d &) myResult.Line(); gp_Lin2d &aLm = (gp_Lin2d &) myResult.Line();
aUm=aLm.Location().X(); aUm=aLm.Location().X();
// //
aUmid=0.5*(aU2+aU1); aUmid = 0.5 * (aU2 + aU1);
dUm=fabs(aUm-aUmid); dUm = fabs(aUm - aUmid);
dUr=fabs(aUr-aUmid); dUr = fabs(aUr - aUmid);
if (dUr<dUm) { if (dUr < dUm)
myResult=aResult; {
myResult = aResult;
} }
} }
else { else
{
myResult.UFrame(aT1, aT2, aU1, aUPeriod); myResult.UFrame(aT1, aT2, aU1, aUPeriod);
} }
// //
@@ -622,7 +639,8 @@ void ProjLib_ProjectedCurve::Load(const Handle(Adaptor3d_HCurve)& C)
// Modified by skv - Wed Aug 11 15:45:58 2004 OCC6272 Begin // Modified by skv - Wed Aug 11 15:45:58 2004 OCC6272 Begin
// Correct the U isoline in periodical surface // Correct the U isoline in periodical surface
// to be inside restriction boundaries. // to be inside restriction boundaries.
if (myResult.GetType() == GeomAbs_Line) { if (myResult.GetType() == GeomAbs_Line)
{
gp_Lin2d &aLine = (gp_Lin2d &) myResult.Line(); gp_Lin2d &aLine = (gp_Lin2d &) myResult.Line();
Standard_Real aPeriod = mySurface->UPeriod(); Standard_Real aPeriod = mySurface->UPeriod();
@@ -630,34 +648,37 @@ void ProjLib_ProjectedCurve::Load(const Handle(Adaptor3d_HCurve)& C)
Standard_Real aLUPar = mySurface->LastUParameter(); Standard_Real aLUPar = mySurface->LastUParameter();
// Check if the parametric range is lower then the period. // Check if the parametric range is lower then the period.
if (aLUPar - aFUPar < aPeriod - myTolerance) { if (aLUPar - aFUPar < aPeriod - myTolerance)
{
Standard_Real aU = aLine.Location().X(); Standard_Real aU = aLine.Location().X();
if (Abs(aU + aPeriod - aFUPar) < myTolerance || if (Abs(aU + aPeriod - aFUPar) < myTolerance ||
Abs(aU - aPeriod - aFUPar) < myTolerance) { Abs(aU - aPeriod - aFUPar) < myTolerance)
{
gp_Pnt2d aNewLoc(aFUPar, aLine.Location().Y()); gp_Pnt2d aNewLoc(aFUPar, aLine.Location().Y());
aLine.SetLocation(aNewLoc); aLine.SetLocation(aNewLoc);
} else if (Abs(aU + aPeriod - aLUPar) < myTolerance || }
Abs(aU - aPeriod - aLUPar) < myTolerance) { else if (Abs(aU + aPeriod - aLUPar) < myTolerance ||
Abs(aU - aPeriod - aLUPar) < myTolerance)
{
gp_Pnt2d aNewLoc(aLUPar, aLine.Location().Y()); gp_Pnt2d aNewLoc(aLUPar, aLine.Location().Y());
aLine.SetLocation(aNewLoc); aLine.SetLocation(aNewLoc);
} }
} }
} }
} }
// Modified by skv - Wed Aug 11 15:45:58 2004 OCC6272 End // Modified by skv - Wed Aug 11 15:45:58 2004 OCC6272 End
if (mySurface->IsVPeriodic()) { if (mySurface->IsVPeriodic())
myResult.VFrame(myCurve->FirstParameter(), {
myCurve->LastParameter(), myResult.VFrame(myCurve->FirstParameter(), myCurve->LastParameter(),
mySurface->FirstVParameter(), mySurface->FirstVParameter(), mySurface->VPeriod());
mySurface->VPeriod()); // Modified by skv - Wed Aug 11 15:45:58 2004 OCC6272 Begin
// Modified by skv - Wed Aug 11 15:45:58 2004 OCC6272 Begin // Correct the V isoline in a periodical surface
// Correct the V isoline in a periodical surface // to be inside restriction boundaries.
// to be inside restriction boundaries. if (myResult.GetType() == GeomAbs_Line)
if (myResult.GetType() == GeomAbs_Line) { {
gp_Lin2d &aLine = (gp_Lin2d &) myResult.Line(); gp_Lin2d &aLine = (gp_Lin2d &) myResult.Line();
Standard_Real aPeriod = mySurface->VPeriod(); Standard_Real aPeriod = mySurface->VPeriod();
@@ -665,24 +686,26 @@ void ProjLib_ProjectedCurve::Load(const Handle(Adaptor3d_HCurve)& C)
Standard_Real aLVPar = mySurface->LastVParameter(); Standard_Real aLVPar = mySurface->LastVParameter();
// Check if the parametric range is lower then the period. // Check if the parametric range is lower then the period.
if (aLVPar - aFVPar < aPeriod - myTolerance) { if (aLVPar - aFVPar < aPeriod - myTolerance)
{
Standard_Real aV = aLine.Location().Y(); Standard_Real aV = aLine.Location().Y();
if (Abs(aV + aPeriod - aFVPar) < myTolerance || if (Abs(aV + aPeriod - aFVPar) < myTolerance ||
Abs(aV - aPeriod - aFVPar) < myTolerance) { Abs(aV - aPeriod - aFVPar) < myTolerance)
{
gp_Pnt2d aNewLoc(aLine.Location().X(), aFVPar); gp_Pnt2d aNewLoc(aLine.Location().X(), aFVPar);
aLine.SetLocation(aNewLoc); aLine.SetLocation(aNewLoc);
} else if (Abs(aV + aPeriod - aLVPar) < myTolerance || }
Abs(aV - aPeriod - aLVPar) < myTolerance) { else if (Abs(aV + aPeriod - aLVPar) < myTolerance ||
Abs(aV - aPeriod - aLVPar) < myTolerance)
{
gp_Pnt2d aNewLoc(aLine.Location().X(), aLVPar); gp_Pnt2d aNewLoc(aLine.Location().X(), aLVPar);
aLine.SetLocation(aNewLoc); aLine.SetLocation(aNewLoc);
} }
} }
} }
} }
// Modified by skv - Wed Aug 11 15:45:58 2004 OCC6272 End // Modified by skv - Wed Aug 11 15:45:58 2004 OCC6272 End
} }
} }