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

0024023: Revamp the OCCT Handle - non-cost reference cast

Code corrected to avoid passing object to function as non-const reference to handle of the base type where it is not necessary.
This commit is contained in:
abv
2015-06-25 00:45:56 +03:00
parent 5b111128de
commit 7f22979e82
23 changed files with 90 additions and 164 deletions

View File

@@ -4185,8 +4185,9 @@ Standard_EXPORT
Bout = PDeb.Translated(-20*rabdist * VrefDeb);
Standard_Boolean goodext = 0;
for(Standard_Integer icont = 3; icont>=1 && !goodext; icont--) {
newc = BSpline;
GeomLib::ExtendCurveToPoint( newc, Bout, icont, Standard_False);
Handle(Geom_BoundedCurve) anExtCurve = BSpline;
GeomLib::ExtendCurveToPoint (anExtCurve, Bout, icont, Standard_False);
newc = Handle(Geom_BSplineCurve)::DownCast (anExtCurve);
gacurve.Load(newc);
GCPnts_AbscissaPoint GCP(gacurve,-rabdist,Wrefdeb,WF);
if(GCP.IsDone()) {
@@ -4210,8 +4211,9 @@ Standard_EXPORT
Bout = PFin.Translated(20*rabdist * VrefFin);
Standard_Boolean goodext = 0;
for(Standard_Integer icont = 3; icont>=1 && !goodext; icont--) {
newc = BSpline;
GeomLib::ExtendCurveToPoint( newc, Bout, icont, Standard_True);
Handle(Geom_BoundedCurve) anExtCurve = BSpline;
GeomLib::ExtendCurveToPoint (anExtCurve, Bout, icont, Standard_True);
newc = Handle(Geom_BSplineCurve)::DownCast (anExtCurve);
gacurve.Load(newc);
GCPnts_AbscissaPoint GCP(gacurve,rabdist,Wreffin,WL);
if(GCP.IsDone()) {
@@ -4338,7 +4340,9 @@ Standard_EXPORT
adjust = Standard_True;
}
if(adjust) {
GeomLib::AdjustExtremity(BSpline, PDeb, PFin, VrefDeb, VrefFin);
Handle(Geom_BoundedCurve) anExtCurve = BSpline;
GeomLib::AdjustExtremity(anExtCurve, PDeb, PFin, VrefDeb, VrefFin);
BSpline = Handle(Geom_BSplineCurve)::DownCast (anExtCurve);
}
}

View File

@@ -692,10 +692,13 @@ Standard_Boolean ChFi3d_Builder::StoreData(Handle(ChFiDS_SurfData)& Data,
Standard_Real length1,length2;
length1=Data->FirstExtensionValue();
length2=Data->LastExtensionValue();
Handle(Geom_BoundedSurface) aBndSurf = Surf;
if (length1 > Precision::Confusion())
GeomLib::ExtendSurfByLength(Surf,length1,1,Standard_False,Standard_False);
GeomLib::ExtendSurfByLength(aBndSurf,length1,1,Standard_False,Standard_False);
if (length2 > Precision::Confusion())
GeomLib::ExtendSurfByLength(Surf,length2,1,Standard_False,Standard_True);
GeomLib::ExtendSurfByLength(aBndSurf,length2,1,Standard_False,Standard_True);
Surf = Handle(Geom_BSplineSurface)::DownCast (aBndSurf);
//Correction of surface on extremities
if (length1 <= Precision::Confusion())

View File

@@ -187,9 +187,9 @@ static Standard_Real recadre(const Standard_Real p,
// parameter in FaceInterference.
//=======================================================================
static Standard_Boolean Update(Handle(Adaptor3d_HSurface)& fb,
Handle(Adaptor2d_HCurve2d)& pcfb,
Handle(Adaptor3d_HSurface)& surf,
static Standard_Boolean Update(const Handle(Adaptor3d_HSurface)& fb,
const Handle(Adaptor2d_HCurve2d)& pcfb,
const Handle(Adaptor3d_HSurface)& surf,
ChFiDS_FaceInterference& fi,
ChFiDS_CommonPoint& cp,
gp_Pnt2d& p2dbout,
@@ -229,8 +229,8 @@ static Standard_Boolean Update(Handle(Adaptor3d_HSurface)& fb,
// and <p2dbout>
//=======================================================================
static Standard_Boolean Update(Handle(Adaptor3d_HSurface)& fb,
Handle(Adaptor3d_HCurve)& ct,
static Standard_Boolean Update(const Handle(Adaptor3d_HSurface)& fb,
const Handle(Adaptor3d_HCurve)& ct,
ChFiDS_FaceInterference& fi,
ChFiDS_CommonPoint& cp,
gp_Pnt2d& p2dbout,
@@ -356,9 +356,9 @@ static Standard_Boolean IntersUpdateOnSame(Handle(GeomAdaptor_HSurface)& HGs,
// face at end.
//=======================================================================
static Standard_Boolean Update(Handle(Adaptor3d_HSurface)& face,
Handle(Adaptor2d_HCurve2d)& edonface,
Handle(Adaptor3d_HSurface)& surf,
static Standard_Boolean Update(const Handle(Adaptor3d_HSurface)& face,
const Handle(Adaptor2d_HCurve2d)& edonface,
const Handle(Adaptor3d_HSurface)& surf,
ChFiDS_FaceInterference& fi,
ChFiDS_CommonPoint& cp,
const Standard_Boolean isfirst)
@@ -424,42 +424,25 @@ static void ChFi3d_ExtendSurface (Handle(Geom_Surface) & S ,
Standard_Integer & prol )
{
if (prol) return;
Handle(Geom_BSplineSurface) S1;
Handle(Geom_BezierSurface) S2;
prol = (S->IsKind (STANDARD_TYPE(Geom_BSplineSurface)) ? 1 :
S->IsKind (STANDARD_TYPE(Geom_BezierSurface)) ? 2 : 0);
if ( ! prol )
return;
Standard_Real length,umin,umax,vmin,vmax;
gp_Pnt P1,P2;
S->Bounds(umin,umax,vmin,vmax);
S->D0(umin,vmin,P1);
S->D0(umax,vmax,P2);
length=P1.Distance(P2);
prol=0;
S1=Handle(Geom_BSplineSurface)::DownCast(S);
S2=Handle(Geom_BezierSurface)::DownCast(S);
if (!S1.IsNull()) {
GeomLib::ExtendSurfByLength(S1,length,1,Standard_False,
Standard_True);
GeomLib::ExtendSurfByLength(S1,length,1,Standard_True,
Standard_True);
GeomLib::ExtendSurfByLength(S1,length,1,Standard_False,
Standard_False);
GeomLib::ExtendSurfByLength(S1,length,1,Standard_True,
Standard_False);
S=S1;
prol=1;
}
if (!S2.IsNull()) {
GeomLib::ExtendSurfByLength(S2,length,1,Standard_False,
Standard_True);
GeomLib::ExtendSurfByLength(S2,length,1,Standard_True,
Standard_True);
GeomLib::ExtendSurfByLength(S2,length,1,Standard_False,
Standard_False);
GeomLib::ExtendSurfByLength(S2,length,1,Standard_True,
Standard_False);
S=S2;
prol=2;
}
Handle(Geom_BoundedSurface) aBS = Handle(Geom_BoundedSurface)::DownCast(S);
GeomLib::ExtendSurfByLength (aBS, length, 1, Standard_False, Standard_True);
GeomLib::ExtendSurfByLength (aBS, length, 1, Standard_True, Standard_True);
GeomLib::ExtendSurfByLength (aBS, length, 1, Standard_False, Standard_False);
GeomLib::ExtendSurfByLength (aBS, length, 1, Standard_True, Standard_False);
S = aBS;
}
//=======================================================================
@@ -467,7 +450,7 @@ static void ChFi3d_ExtendSurface (Handle(Geom_Surface) & S ,
//purpose : calculate the 2d of the curve Ct on face Face
//=======================================================================
static void ComputeCurve2d (Handle(Geom_Curve )& Ct,
static void ComputeCurve2d (const Handle(Geom_Curve )& Ct,
TopoDS_Face & Face,
Handle(Geom2d_Curve) & C2d)
{
@@ -2267,8 +2250,8 @@ void ChFi3d_Builder::PerformIntersectionAtEnd(const Standard_Integer Index)
inters.Perform(HC, HGs);
if ( !prolface[nn] && ( !inters.IsDone() || (inters.NbPoints()==0) )) {
// extend surface of conge
Handle(Geom_BSplineSurface) S1=
Handle(Geom_BSplineSurface)::DownCast(DStr.Surface(Fd->Surf()).Surface());
Handle(Geom_BoundedSurface) S1=
Handle(Geom_BoundedSurface)::DownCast(DStr.Surface(Fd->Surf()).Surface());
if (!S1.IsNull()) {
Standard_Real length = 0.5 * Max(Fi1Length,Fi2Length);
GeomLib::ExtendSurfByLength(S1,length,1,Standard_False,!isfirst);