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

View File

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

View File

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