Operator of cast to non-const reference is declared deprecated to produce compiler warning if used (usually implicitly).
OCCT code is updated to avoid that cast, occurring when function accepting non-const reference to handle is called with handle to derived type.
For that, local variable of argument type is passed instead, and down-cast is used to get it to desired type after the call.
A few occurrences of use of uninitialized variable are corrected.
// Compute geometry for this plane and edges
Standard_Boolean isInfinite1,isInfinite2;
gp_Pnt aFirstPoint1, aLastPoint1, aFirstPoint2, aLastPoint2;
-
+ Handle(Geom_Curve) aFirstCurve = aFirstLine, aSecondCurve = aSecondLine;
if (!AIS::ComputeGeometry (aFirstEdge, aSecondEdge,
- aFirstLine, aSecondLine,
+ aFirstCurve, aSecondCurve,
aFirstPoint1, aLastPoint1,
aFirstPoint2, aLastPoint2,
isInfinite1, isInfinite2))
{
aPresentation->Clear();
- Handle(Geom_Line) glin;
+ Handle(Geom_Curve) gcurv;
gp_Pnt pfirst,plast;
const TopoDS_Edge& thechamfedge = TopoDS::Edge(myFShape);
- if (!AIS::ComputeGeometry(thechamfedge, glin,pfirst,plast) )
+ if (!AIS::ComputeGeometry (thechamfedge, gcurv, pfirst, plast))
return;
-
+ Handle(Geom_Line) glin = Handle(Geom_Line)::DownCast (gcurv);
gp_Dir dir1 (glin->Position().Direction());
gp_Dir norm1 = myPlane->Pln().Axis().Direction();
myDir = norm1.Crossed(dir1);
Handle(SelectMgr_EntityOwner) own = new SelectMgr_EntityOwner(this,7);
Standard_Real F,L;
- Handle(Geom_Line) geom_axis,extcurve;
+ Handle(Geom_Curve) geom_axis, extcurve;
gp_Pnt p1,p2;
Standard_Boolean isinfinite,isonplane;
if (!AIS::ComputeGeometry(TopoDS::Edge(myTool),
isonplane,
myPlane)) return;
- gp_Lin laxis (geom_axis->Lin());
+ Handle(Geom_Line) geom_line = Handle(Geom_Line)::DownCast (geom_axis);
+ gp_Lin laxis (geom_line->Lin());
if(myFShape.ShapeType() != TopAbs_VERTEX){
BRepAdaptor_Curve cu1(TopoDS::Edge(myFShape));
return;
}
aprs->SetInfiniteState((isInfinite1 || isInfinite2) && (myExtShape !=0));
- Handle(Geom_Line) geom_axis,extcurve;
+ Handle(Geom_Curve) geom_axis,extcurve;
gp_Pnt p1,p2;
Standard_Boolean isinfinite,isonplane;
if (!AIS::ComputeGeometry(TopoDS::Edge(myTool),
isonplane,
myPlane)) return;
- gp_Lin laxis (geom_axis->Lin());
+ Handle(Geom_Line) geom_line = Handle(Geom_Line)::DownCast (geom_axis);
+ gp_Lin laxis (geom_line->Lin());
myAxisDirAttach = laxis.Direction();
if(cu1.GetType() == GeomAbs_Line){
void AIS_SymmetricRelation::ComputeTwoVerticesSymmetric(const Handle(Prs3d_Presentation)& aprs)
{
if(myFShape.ShapeType() != TopAbs_VERTEX || mySShape.ShapeType() != TopAbs_VERTEX) return;
- Handle(Geom_Line) geom_axis,extcurve;
+ Handle(Geom_Curve) geom_axis,extcurve;
gp_Pnt p1,p2;
Standard_Boolean isinfinite,isonplane;
if (!AIS::ComputeGeometry(TopoDS::Edge(myTool),
myExtShape = 1;
else
return ;
- gp_Lin laxis (geom_axis->Lin());
+
+ Handle(Geom_Line) geom_line = Handle(Geom_Line)::DownCast (geom_axis);
+ gp_Lin laxis (geom_line->Lin());
myAxisDirAttach = laxis.Direction();
// recherche points attache
{
// Read Shapes
- Handle(BinMNaming_NamedShapeDriver) aNamedShapeDriver;
- if (myDrivers->GetDriver(STANDARD_TYPE(TNaming_NamedShape),aNamedShapeDriver))
- {
- try {
- OCC_CATCH_SIGNALS
- aNamedShapeDriver->ReadShapeSection (theIS);
- }
- catch(Standard_Failure) {
- Handle(Standard_Failure) aFailure = Standard_Failure::Caught();
- const TCollection_ExtendedString aMethStr
- ("BinDrivers_DocumentRetrievalDriver: ");
- WriteMessage (aMethStr + "error of Shape Section " +
- aFailure->GetMessageString());
- }
+ Handle(BinMDF_ADriver) aDriver;
+ if (myDrivers->GetDriver(STANDARD_TYPE(TNaming_NamedShape),aDriver))
+ {
+ try {
+ OCC_CATCH_SIGNALS
+ Handle(BinMNaming_NamedShapeDriver) aNamedShapeDriver =
+ Handle(BinMNaming_NamedShapeDriver)::DownCast (aDriver);
+ aNamedShapeDriver->ReadShapeSection (theIS);
}
+ catch(Standard_Failure) {
+ Handle(Standard_Failure) aFailure = Standard_Failure::Caught();
+ const TCollection_ExtendedString aMethStr
+ ("BinDrivers_DocumentRetrievalDriver: ");
+ WriteMessage (aMethStr + "error of Shape Section " +
+ aFailure->GetMessageString());
+ }
+ }
}
//=======================================================================
{
const Standard_Size aShapesSectionOffset = (Standard_Size) theOS.tellp();
- Handle(BinMNaming_NamedShapeDriver) aNamedShapeDriver;
- if (myDrivers->GetDriver(STANDARD_TYPE(TNaming_NamedShape), aNamedShapeDriver)) {
+ Handle(BinMDF_ADriver) aDriver;
+ if (myDrivers->GetDriver(STANDARD_TYPE(TNaming_NamedShape), aDriver))
+ {
try {
- OCC_CATCH_SIGNALS aNamedShapeDriver->WriteShapeSection (theOS);
+ OCC_CATCH_SIGNALS
+ Handle(BinMNaming_NamedShapeDriver) aNamedShapeDriver =
+ Handle(BinMNaming_NamedShapeDriver)::DownCast (aDriver);
+ aNamedShapeDriver->WriteShapeSection (theOS);
}
catch(Standard_Failure) {
TCollection_ExtendedString anErrorStr ("Error: ");
theDriverTable->AddDriver( new BinMXCAFDoc_GraphNodeDriver(theMsgDrv));
//oan: changes for sharing locations map
- Handle(BinMNaming_NamedShapeDriver) aNamedShapeDriver;
- theDriverTable->GetDriver(STANDARD_TYPE(TNaming_NamedShape), aNamedShapeDriver);
+ Handle(BinMDF_ADriver) aNSDriver;
+ theDriverTable->GetDriver(STANDARD_TYPE(TNaming_NamedShape), aNSDriver);
+ Handle(BinMNaming_NamedShapeDriver) aNamedShapeDriver =
+ Handle(BinMNaming_NamedShapeDriver)::DownCast (aNSDriver);
Handle(BinMXCAFDoc_LocationDriver) aLocationDriver = new BinMXCAFDoc_LocationDriver (theMsgDrv);
if( !aNamedShapeDriver.IsNull() )
//! that case A is setted.
Standard_EXPORT static Standard_Boolean Find (const Handle(TDF_Data)& DF, const Standard_CString Entry, const Standard_GUID& ID, Handle(TDF_Attribute)& A, const Standard_Boolean Complain = Standard_True);
+ //! Safe variant for arbitrary type of argument
+ template <class T>
+ static Standard_Boolean Find (const Handle(TDF_Data)& DF, const Standard_CString Entry, const Standard_GUID& ID, Handle(T)& A, const Standard_Boolean Complain = Standard_True)
+ {
+ Handle(TDF_Attribute) anAttr = A;
+ return Find (DF, Entry, ID, anAttr, Complain) && ! (A = Handle(T)::DownCast(anAttr)).IsNull();
+ }
+
Standard_EXPORT static Draw_Interpretor& ReturnLabel (Draw_Interpretor& theCommands, const TDF_Label& L);
Standard_EXPORT static void AllCommands (Draw_Interpretor& theCommands);
Standard_EXPORT static Standard_Boolean Find (const Handle(TDocStd_Document)& Document, const Standard_CString Entry, const Standard_GUID& ID, Handle(TDF_Attribute)& A, const Standard_Boolean Complain = Standard_True);
+ //! Safe variant for arbitrary type of argument
+ template <class T>
+ static Standard_Boolean Find (const Handle(TDocStd_Document)& Document, const Standard_CString Entry, const Standard_GUID& ID, Handle(T)& A, const Standard_Boolean Complain = Standard_True)
+ {
+ Handle(TDF_Attribute) anAttr = A;
+ return Find (Document, Entry, ID, anAttr, Complain) && ! (A = Handle(T)::DownCast(anAttr)).IsNull();
+ }
+
Standard_EXPORT static Draw_Interpretor& ReturnLabel (Draw_Interpretor& theCommands, const TDF_Label& L);
Standard_EXPORT static void AllCommands (Draw_Interpretor& theCommands);
//! <exact> : same as for HasItem
Standard_EXPORT Standard_Boolean GetItem (const Standard_CString name, Handle(Standard_Transient)& anitem, const Standard_Boolean exact = Standard_True) const;
+ //! Safe variant of GetItem() for arbitrary type of argument
+ template <class T>
+ Standard_Boolean GetItem (const Standard_CString theName, Handle(T)& theItem, const Standard_Boolean theExact = Standard_True) const
+ {
+ Handle(Standard_Transient) anItem = theItem;
+ return GetItem (theName, anItem, theExact) && ! (theItem = Handle(T)::DownCast(anItem)).IsNull();
+ }
+
//! Works as above method but accepts a String from TCollection
Standard_EXPORT Standard_Boolean GetItem (const TCollection_AsciiString& name, Handle(Standard_Transient)& anitem, const Standard_Boolean exact = Standard_True) const;
+ //! Safe variant of GetItem() for arbitrary type of argument
+ template <class T>
+ Standard_Boolean GetItem (const TCollection_AsciiString& theName, Handle(T)& theItem, const Standard_Boolean theExact = Standard_True) const
+ {
+ Handle(Standard_Transient) anItem = theItem;
+ return GetItem (theName, anItem, theExact) && ! (theItem = Handle(T)::DownCast(anItem)).IsNull();
+ }
+
//! Binds an item to a dictionnary entry
//! If <name> is already known in the dictionary, its value
//! is changed. Else, the dictionary entry is created.
static Handle(Draw_Drawable3D) crestore (istream& is)
{
- Handle(Geom_Curve) G;
- GeomTools_CurveSet::ReadCurve(is,G);
+ Handle(Geom_Curve) G = GeomTools_CurveSet::ReadCurve(is);
Handle(DrawTrSurf_Curve) N =
new DrawTrSurf_Curve(G,CurvColor,Discret,Deflection,DrawMode);
return N;
static Handle(Draw_Drawable3D) bzcrestore (istream& is)
{
- Handle(Geom_BezierCurve) G;
- GeomTools_CurveSet::ReadCurve(is,G);
+ Handle(Geom_BezierCurve) G =
+ Handle(Geom_BezierCurve)::DownCast (GeomTools_CurveSet::ReadCurve(is));
Handle(DrawTrSurf_BezierCurve) N =
new DrawTrSurf_BezierCurve(G,CurvColor,PolesColor,ShowPoles,
Discret,Deflection,DrawMode);
static Handle(Draw_Drawable3D) bscrestore (istream& is)
{
- Handle(Geom_BSplineCurve) G;
- GeomTools_CurveSet::ReadCurve(is,G);
+ Handle(Geom_BSplineCurve) G =
+ Handle(Geom_BSplineCurve)::DownCast (GeomTools_CurveSet::ReadCurve(is));
Handle(DrawTrSurf_BSplineCurve) N =
new DrawTrSurf_BSplineCurve(G, CurvColor,PolesColor,
KnotsColor,
static Handle(Draw_Drawable3D) c2drestore (istream& is)
{
- Handle(Geom2d_Curve) G;
- GeomTools_Curve2dSet::ReadCurve2d(is,G);
+ Handle(Geom2d_Curve) G = GeomTools_Curve2dSet::ReadCurve2d(is);
Handle(DrawTrSurf_Curve2d) N =
new DrawTrSurf_Curve2d(G,CurvColor,Discret);
return N;
static Handle(Draw_Drawable3D) bzc2drestore (istream& is)
{
- Handle(Geom2d_BezierCurve) G;
- GeomTools_Curve2dSet::ReadCurve2d(is,G);
+ Handle(Geom2d_BezierCurve) G =
+ Handle(Geom2d_BezierCurve)::DownCast (GeomTools_Curve2dSet::ReadCurve2d(is));
Handle(DrawTrSurf_BezierCurve2d) N =
new DrawTrSurf_BezierCurve2d(G,CurvColor,PolesColor,ShowPoles,
Discret);
static Handle(Draw_Drawable3D) bsc2drestore (istream& is)
{
- Handle(Geom2d_BSplineCurve) G;
- GeomTools_Curve2dSet::ReadCurve2d(is,G);
+ Handle(Geom2d_BSplineCurve) G =
+ Handle(Geom2d_BSplineCurve)::DownCast (GeomTools_Curve2dSet::ReadCurve2d(is));
Handle(DrawTrSurf_BSplineCurve2d) N =
new DrawTrSurf_BSplineCurve2d(G, CurvColor,PolesColor,
KnotsColor,
static Handle(Draw_Drawable3D) srestore (istream& is)
{
- Handle(Geom_Surface) G;
- GeomTools_SurfaceSet::ReadSurface(is,G);
+ Handle(Geom_Surface) G = GeomTools_SurfaceSet::ReadSurface(is);
Handle(DrawTrSurf_Surface) N =
new DrawTrSurf_Surface(G,
NbUIsos,NbVIsos,
static Handle(Draw_Drawable3D) bzsrestore (istream& is)
{
- Handle(Geom_BezierSurface) G;
- GeomTools_SurfaceSet::ReadSurface(is,G);
+ Handle(Geom_BezierSurface) G =
+ Handle(Geom_BezierSurface)::DownCast (GeomTools_SurfaceSet::ReadSurface(is));
Handle(DrawTrSurf_BezierSurface) N =
new DrawTrSurf_BezierSurface(G,NbUIsos,NbVIsos,
BoundsColor,IsosColor,PolesColor,
static Handle(Draw_Drawable3D) bssrestore (istream& is)
{
- Handle(Geom_BSplineSurface) G;
- GeomTools_SurfaceSet::ReadSurface(is,G);
+ Handle(Geom_BSplineSurface) G =
+ Handle(Geom_BSplineSurface)::DownCast (GeomTools_SurfaceSet::ReadSurface(is));
Handle(DrawTrSurf_BSplineSurface) N;
if (!knotsIsos)
N = new DrawTrSurf_BSplineSurface(G,
void GeomTools::Read(Handle(Geom_Surface)& S, Standard_IStream& IS)
{
- GeomTools_SurfaceSet::ReadSurface(IS,S);
+ S = GeomTools_SurfaceSet::ReadSurface(IS);
}
void GeomTools::Dump(const Handle(Geom_Curve)& C, Standard_OStream& OS)
void GeomTools::Read(Handle(Geom_Curve)& C, Standard_IStream& IS)
{
- GeomTools_CurveSet::ReadCurve(IS,C);
+ C = GeomTools_CurveSet::ReadCurve(IS);
}
void GeomTools::Dump(const Handle(Geom2d_Curve)& C, Standard_OStream& OS)
void GeomTools::Read(Handle(Geom2d_Curve)& C, Standard_IStream& IS)
{
- GeomTools_Curve2dSet::ReadCurve2d(IS,C);
+ C = GeomTools_Curve2dSet::ReadCurve2d(IS);
}
//=======================================================================
Standard_Real p1=0.,p2=0.;
GeomTools::GetReal(IS, p1);
GeomTools::GetReal(IS, p2);
- Handle(Geom2d_Curve) BC;
- GeomTools_Curve2dSet::ReadCurve2d(IS,BC);
+ Handle(Geom2d_Curve) BC = GeomTools_Curve2dSet::ReadCurve2d(IS);
C = new Geom2d_TrimmedCurve(BC,p1,p2);
return IS;
}
{
Standard_Real p=0.;
GeomTools::GetReal(IS, p);
- Handle(Geom2d_Curve) BC;
- GeomTools_Curve2dSet::ReadCurve2d(IS,BC);
+ Handle(Geom2d_Curve) BC = GeomTools_Curve2dSet::ReadCurve2d(IS);
C = new Geom2d_OffsetCurve(BC,p);
return IS;
}
//purpose :
//=======================================================================
-Standard_IStream& GeomTools_Curve2dSet::ReadCurve2d(Standard_IStream& IS,
- Handle(Geom2d_Curve)& C)
+Handle(Geom2d_Curve) GeomTools_Curve2dSet::ReadCurve2d(Standard_IStream& IS)
{
Standard_Integer ctype;
+ Handle(Geom2d_Curve) C;
try {
OCC_CATCH_SIGNALS
IS >> ctype;
cout <<"EXCEPTION in GeomTools_Curve2dSet::ReadCurve2d(..)!!!" << endl;
cout << anExc << endl;
#endif
- C = NULL;
}
- return IS;
+ return C;
}
//=======================================================================
return;
}
- Handle(Geom2d_Curve) C;
Standard_Integer i, nbcurve;
IS >> nbcurve;
//OCC19559
Handle(Message_ProgressIndicator) progress = GetProgress();
Message_ProgressSentry PS(progress, "2D Curves", 0, nbcurve, 1);
for (i = 1; i <= nbcurve && PS.More(); i++, PS.Next()) {
- GeomTools_Curve2dSet::ReadCurve2d(IS,C);
+ Handle(Geom2d_Curve) C = GeomTools_Curve2dSet::ReadCurve2d (IS);
myMap.Add(C);
}
}
Standard_EXPORT static void PrintCurve2d (const Handle(Geom2d_Curve)& C, Standard_OStream& OS, const Standard_Boolean compact = Standard_False);
//! Reads the curve from the stream. The curve is
- //! assumed to have been writtent with the Print
+ //! assumed to have been written with the Print
//! method (compact = True).
- Standard_EXPORT static Standard_IStream& ReadCurve2d (Standard_IStream& IS, Handle(Geom2d_Curve)& C);
+ Standard_EXPORT static Handle(Geom2d_Curve) ReadCurve2d (Standard_IStream& IS);
Standard_EXPORT void SetProgress (const Handle(Message_ProgressIndicator)& PR);
Standard_Real p1=0.,p2=0.;
GeomTools::GetReal(IS, p1);
GeomTools::GetReal(IS, p2);
- Handle(Geom_Curve) BC;
- GeomTools_CurveSet::ReadCurve(IS,BC);
+ Handle(Geom_Curve) BC = GeomTools_CurveSet::ReadCurve(IS);
C = new Geom_TrimmedCurve(BC,p1,p2);
return IS;
}
GeomTools::GetReal(IS, p);
gp_Dir D(1.,0.,0.);
IS >> D;
- Handle(Geom_Curve) BC;
- GeomTools_CurveSet::ReadCurve(IS,BC);
+ Handle(Geom_Curve) BC = GeomTools_CurveSet::ReadCurve(IS);
C = new Geom_OffsetCurve(BC,p,D);
return IS;
}
//purpose :
//=======================================================================
-Standard_IStream& GeomTools_CurveSet::ReadCurve(Standard_IStream& IS,
- Handle(Geom_Curve)& C)
+Handle(Geom_Curve) GeomTools_CurveSet::ReadCurve (Standard_IStream& IS)
{
Standard_Integer ctype;
+ Handle(Geom_Curve) C;
try {
OCC_CATCH_SIGNALS
IS >> ctype;
cout <<"EXCEPTION in GeomTools_CurveSet::ReadCurve(..)!!!" << endl;
cout << anExc << endl;
#endif
- C = NULL;
}
- return IS;
+ return C;
}
//=======================================================================
return;
}
- Handle(Geom_Curve) C;
Standard_Integer i, nbcurve;
IS >> nbcurve;
//OCC19559
Handle(Message_ProgressIndicator) progress = GetProgress();
Message_ProgressSentry PS(progress, "3D Curves", 0, nbcurve, 1);
for (i = 1; i <= nbcurve && PS.More(); i++, PS.Next()) {
- GeomTools_CurveSet::ReadCurve(IS,C);
+ Handle(Geom_Curve) C = GeomTools_CurveSet::ReadCurve (IS);
myMap.Add(C);
}
}
Standard_EXPORT static void PrintCurve (const Handle(Geom_Curve)& C, Standard_OStream& OS, const Standard_Boolean compact = Standard_False);
//! Reads the curve from the stream. The curve is
- //! assumed to have been writtent with the Print
+ //! assumed to have been written with the Print
//! method (compact = True).
- Standard_EXPORT static Standard_IStream& ReadCurve (Standard_IStream& IS, Handle(Geom_Curve)& C);
+ Standard_EXPORT static Handle(Geom_Curve) ReadCurve (Standard_IStream& IS);
Standard_EXPORT void SetProgress (const Handle(Message_ProgressIndicator)& PR);
Handle(Geom_SurfaceOfLinearExtrusion)& S)
{
gp_Dir D(1.,0.,0.);
- Handle(Geom_Curve) C;
IS >> D;
- GeomTools_CurveSet::ReadCurve(IS,C);
+ Handle(Geom_Curve) C = GeomTools_CurveSet::ReadCurve(IS);
S = new Geom_SurfaceOfLinearExtrusion(C,D);
return IS;
}
{
gp_Pnt P(0.,0.,0.);
gp_Dir D(1.,0.,0.);
- Handle(Geom_Curve) C;
IS >> P >> D;
- GeomTools_CurveSet::ReadCurve(IS,C);
+ Handle(Geom_Curve) C = GeomTools_CurveSet::ReadCurve(IS);
S = new Geom_SurfaceOfRevolution(C,gp_Ax1(P,D));
return IS;
}
GeomTools::GetReal(IS, U2);
GeomTools::GetReal(IS, V1);
GeomTools::GetReal(IS, V2);
- Handle(Geom_Surface) BS;
- GeomTools_SurfaceSet::ReadSurface(IS,BS);
+ Handle(Geom_Surface) BS = GeomTools_SurfaceSet::ReadSurface(IS);
S = new Geom_RectangularTrimmedSurface(BS,U1,U2,V1,V2);
return IS;
}
{
Standard_Real O=0.;
GeomTools::GetReal(IS, O);
- Handle(Geom_Surface) BS;
- GeomTools_SurfaceSet::ReadSurface(IS,BS);
+ Handle(Geom_Surface) BS = GeomTools_SurfaceSet::ReadSurface(IS);
S = new Geom_OffsetSurface(BS,O,Standard_True);
return IS;
}
//purpose :
//=======================================================================
-Standard_IStream& GeomTools_SurfaceSet::ReadSurface(Standard_IStream& IS,
- Handle(Geom_Surface)& S)
+Handle(Geom_Surface) GeomTools_SurfaceSet::ReadSurface(Standard_IStream& IS)
{
Standard_Integer stype;
+ Handle(Geom_Surface) S;
try {
OCC_CATCH_SIGNALS
IS >> stype;
cout <<"EXCEPTION in GeomTools_SurfaceSet::ReadSurface(..)!!!" << endl;
cout << anExc << endl;
#endif
- S = NULL;
}
- return IS;
+ return S;
}
//=======================================================================
return;
}
- Handle(Geom_Surface) S;
Standard_Integer i, nbsurf;
IS >> nbsurf;
//OCC19559
Handle(Message_ProgressIndicator) progress = GetProgress();
Message_ProgressSentry PS(progress, "Surfaces", 0, nbsurf, 1);
for (i = 1; i <= nbsurf && PS.More(); i++, PS.Next()) {
- GeomTools_SurfaceSet::ReadSurface(IS,S);
+ Handle(Geom_Surface) S = GeomTools_SurfaceSet::ReadSurface (IS);
myMap.Add(S);
}
}
Standard_EXPORT static void PrintSurface (const Handle(Geom_Surface)& S, Standard_OStream& OS, const Standard_Boolean compact = Standard_False);
//! Reads the surface from the stream. The surface is
- //! assumed to have been writtent with the Print
+ //! assumed to have been written with the Print
//! method (compact = True).
- Standard_EXPORT static Standard_IStream& ReadSurface (Standard_IStream& IS, Handle(Geom_Surface)& S);
+ Standard_EXPORT static Handle(Geom_Surface) ReadSurface (Standard_IStream& IS);
Standard_EXPORT void SetProgress (const Handle(Message_ProgressIndicator)& PR);
{
TCollection_AsciiString str;
if (thealiases.IsNull()) return str;
- Handle(TCollection_HAsciiString) val;
- if (!thealiases->Value(command,val)) return str;
- str.AssignCat (val->ToCString());
- return str;
+ Handle(Standard_Transient) aVal;
+ if (!thealiases->Value(command,aVal)) return str;
+ Handle(TCollection_HAsciiString) val =
+ Handle(TCollection_HAsciiString)::DownCast (aVal);
+ if (!val.IsNull())
+ str.AssignCat (val->ToCString());
+ return str;
}
// Traites actuellement (necessaires) :
// 1(Annotation), aussi 4(pour maillage). 5(ParamUV) traite par AutoCorrect
- Handle(IGESData_GeneralModule) gmod;
Standard_Integer CN;
Standard_Integer i; // svv Jan11 2000 : porting on DEC
for (i = 1; i <= nb; i ++) {
// Subordinate (sur directs en propre seulement)
Handle(IGESData_IGESEntity) ent = themodel->Entity(i);
Standard_Integer igt = ent->TypeNumber();
- if (theglib.Select (ent,gmod,CN)) {
+ Handle(Interface_GeneralModule) gmodule;
+ if (theglib.Select (ent,gmodule,CN)) {
+ Handle(IGESData_GeneralModule) gmod =
+ Handle(IGESData_GeneralModule)::DownCast (gmodule);
Interface_EntityIterator sh;
gmod->OwnSharedCase (CN,ent,sh);
for (sh.Start(); sh.More(); sh.Next()) {
}
// Corrections specifiques
- Handle(IGESData_GeneralModule) gmod;
- Handle(IGESData_SpecificModule) smod;
Standard_Integer CN;
-
- if (theglib.Select (ent,gmod,CN)) {
+ Handle(Interface_GeneralModule) gmodule;
+ if (theglib.Select (ent,gmodule,CN)) {
+ Handle(IGESData_GeneralModule) gmod =
+ Handle(IGESData_GeneralModule)::DownCast (gmodule);
IGESData_DirChecker DC = gmod->DirChecker(CN,ent);
done |= DC.Correct(ent);
}
+
+ Handle(IGESData_SpecificModule) smod;
if (theslib.Select (ent,smod,CN)) done |= smod->OwnCorrect (CN,ent);
return done;
Standard_Boolean IGESData_FreeFormatEntity::ParamData
(const Standard_Integer num, Interface_ParamType& ptype,
Handle(IGESData_IGESEntity)& ent, Handle(TCollection_HAsciiString)& val) const
-{ return UndefinedContent()->ParamData (num,ptype,ent,val); }
+{
+ Handle(Standard_Transient) anEnt = ent;
+ return UndefinedContent()->ParamData (num, ptype, anEnt, val) &&
+ ! (ent = Handle(IGESData_IGESEntity)::DownCast (anEnt)).IsNull();
+}
Interface_ParamType IGESData_FreeFormatEntity::ParamType
IGESData_ParamReader& PR) const
{
Handle(Interface_Check) ach = new Interface_Check;;
- Handle(IGESData_ReadWriteModule) module; Standard_Integer CN;
+ Handle(Interface_ReaderModule) imodule;
+ Standard_Integer CN;
// Les Modules font tout
- if (therlib.Select(ent,module,CN))
+ if (therlib.Select(ent,imodule,CN))
+ {
+ Handle(IGESData_ReadWriteModule) module =
+ Handle(IGESData_ReadWriteModule)::DownCast (imodule);
module->ReadOwnParams(CN,ent,IR,PR);
+ }
else if (ent.IsNull()) {
// Pas trouve dutout
// Sending of message : Null Entity
Handle(IGESData_IGESEntity)& val,
const Standard_Boolean canbenul)
{
+ aStatus = IGESData_EntityError;
if (!PrepareRead(PC,Standard_False)) return Standard_False;
Standard_Integer nval;
// if (!ReadingEntityNumber(theindex,amsg,nval)) return Standard_False;
thelast = Standard_True;
}
+ else
+ aStatus = IGESData_EntityOK;
return canbenul;
}
else val = GetCasted(IGESData_IGESEntity,IR->BoundEntity(nval));
//SendFail (amsg);
thelast = Standard_True;
}
+ else
+ aStatus = IGESData_EntityOK;
return canbenul;
}
}
} else if (FP.ParamType() == Interface_ParamVoid) {
val = 0.0; // DEFAULT
} else {
+ val = 0.0; // DEFAULT
char ssem[100];
sprintf(ssem,": not given as Real, rank %d",num);
AddFail (mess,ssem,": not given as Real, rank %d");
Standard_EXPORT Standard_Boolean ReadEntity (const Handle(IGESData_IGESReaderData)& IR, const IGESData_ParamCursor& PC, IGESData_Status& aStatus, const Handle(Standard_Type)& type, Handle(IGESData_IGESEntity)& val, const Standard_Boolean canbenul = Standard_False);
+ //! Safe variant for arbitrary type of argument
+ template <class T>
+ Standard_Boolean ReadEntity (const Handle(IGESData_IGESReaderData)& IR, const IGESData_ParamCursor& PC, IGESData_Status& aStatus, const Handle(Standard_Type)& type, Handle(T)& val, const Standard_Boolean canbenul = Standard_False)
+ {
+ Handle(IGESData_IGESEntity) aVal = val;
+ Standard_Boolean aRes = ReadEntity (IR, PC, aStatus, type, aVal, canbenul);
+ val = Handle(T)::DownCast(aVal);
+ return aRes && (canbenul || ! val.IsNull());
+ }
+
//! Works as ReadEntity without Type, but in addition checks the
//! Type of the Entity, which must be "kind of" a given <type>
//! Then, gives the same fail cases as ReadEntity without Type,
//! (in such a case, returns False and givel <val> = Null)
Standard_EXPORT Standard_Boolean ReadEntity (const Handle(IGESData_IGESReaderData)& IR, const IGESData_ParamCursor& PC, const Standard_CString mess, const Handle(Standard_Type)& type, Handle(IGESData_IGESEntity)& val, const Standard_Boolean canbenul = Standard_False);
+ //! Safe variant for arbitrary type of argument
+ template <class T>
+ Standard_Boolean ReadEntity (const Handle(IGESData_IGESReaderData)& IR, const IGESData_ParamCursor& PC, const Standard_CString mess, const Handle(Standard_Type)& type, Handle(T)& val, const Standard_Boolean canbenul = Standard_False)
+ {
+ Handle(IGESData_IGESEntity) aVal = val;
+ Standard_Boolean aRes = ReadEntity (IR, PC, mess, type, aVal, canbenul);
+ val = Handle(T)::DownCast(aVal);
+ return aRes && (canbenul || ! val.IsNull());
+ }
+
Standard_EXPORT Standard_Boolean ReadInts (const IGESData_ParamCursor& PC, const Message_Msg& amsg, Handle(TColStd_HArray1OfInteger)& val, const Standard_Integer index = 1);
//! Reads a list of Integer values, defined by PC (with a count of
void IGESData_ToolLocation::SetOwnAsDependent (const Handle(IGESData_IGESEntity)& ent)
{
- Handle(IGESData_GeneralModule) module;
Standard_Integer CN;
- if (!thelib.Select(ent,module,CN)) return;
+ Handle(Interface_GeneralModule) gmodule;
+ if (!thelib.Select(ent,gmodule,CN)) return;
+ Handle(IGESData_GeneralModule) module =
+ Handle(IGESData_GeneralModule)::DownCast (gmodule);
Interface_EntityIterator list;
module->OwnSharedCase(CN,ent,list);
// Remarque : en toute rigueur, il faudrait ignorer les entites referencees
up = another->NbDisplayedEntities();
if (up == 0) return;
Handle(IGESData_HArray1OfIGESEntity) tempDisplayEntities;
- Handle(IGESData_IGESEntity) anew;
+ Handle(Standard_Transient) anew;
for (I = 1; I <= up; I++) {
if (TC.Search (another->DisplayedEntity(I),anew)) newdisp.GetOneItem(anew);
}
up = another->NbDisplayedEntities();
if (up == 0) return;
Handle(IGESData_HArray1OfIGESEntity) tempDisplayEntities;
- Handle(IGESData_IGESEntity) anew;
+ Handle(Standard_Transient) anew;
for (I = 1; I <= up; I++) {
if (TC.Search (another->DisplayedEntity(I),anew)) newdisp.GetOneItem(anew);
}
if (!tempBounds.IsNull()){
for ( i = 1; i <= num; i++ )
{
- Handle(IGESGeom_Boundary) tempEnt;
+ Handle(IGESData_IGESEntity) tempEnt;
//st = PR.ReadEntity(IR, PR.Current(), Msg168, tempEnt); //szv#4:S4163:12Mar99 moved in if
//st = PR.ReadEntity(IR, PR.Current(), "Boundary Entities", tempEnt);
if (PR.ReadEntity(IR, PR.Current(), aStatus, tempEnt))
- tempBounds->SetValue(i, tempEnt);
+ tempBounds->SetValue(i, Handle(IGESGeom_Boundary)::DownCast (tempEnt));
else{
Message_Msg Msg168("XTSEP_168");
switch(aStatus) {
// si View() transfere, mettre a jour ...
for (setl.Start(); setl.More(); setl.Next()) {
DeclareAndCast(IGESData_IGESEntity,ent,setl.Value());
- Handle(IGESData_ViewKindEntity) vieworig, viewnew;
- vieworig = ent->View();
+ Handle(IGESData_ViewKindEntity) vieworig = ent->View();
if (vieworig.IsNull()) continue;
- if (!TC.Search(vieworig,viewnew)) continue;
- ent->InitView(viewnew);
+ Handle(Standard_Transient) aView;
+ if (!TC.Search(vieworig,aView)) continue;
+ Handle(IGESData_ViewKindEntity) viewnew =
+ Handle(IGESData_ViewKindEntity)::DownCast (aView);
+ if (! viewnew.IsNull())
+ ent->InitView(viewnew);
}
}
Standard_Boolean abool, shellFlag; //szv#4:S4163:12Mar99 `st` moved down
Standard_Integer nbshells, i;
Handle(TColStd_HArray1OfInteger) voidShellFlags;
- Handle(IGESSolid_Shell) shell;
+ Handle(IGESData_IGESEntity) shell;
Handle(IGESSolid_Shell) ashell;
Handle(IGESSolid_HArray1OfShell) voidShells;
IGESData_Status aStatus;
}
}
DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
- ent->Init (shell, shellFlag, voidShells, voidShellFlags);
+ ent->Init (Handle(IGESSolid_Shell)::DownCast (shell), shellFlag, voidShells, voidShellFlags);
}
void IGESSolid_ToolManifoldSolid::WriteOwnParams
Handle(IGESGeom_Point) tempCenter;
Standard_Real majRad, minRad;
Handle(IGESGeom_Direction) tempAxis; // default Unparametrised
- Handle(IGESGeom_Direction) tempRefdir; // default Unparametrised
+ Handle(IGESData_IGESEntity) tempRefdir; // default Unparametrised
//Standard_Boolean st; //szv#4:S4163:12Mar99 not needed
PR.ReadEntity(IR, PR.Current(), "Center point",
PR.ReadEntity(IR, PR.Current(), "Reference direction", tempRefdir); //szv#4:S4163:12Mar99 `st=` not needed
DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
- ent->Init (tempCenter, tempAxis, majRad, minRad, tempRefdir);
+ ent->Init (tempCenter, tempAxis, majRad, minRad, Handle(IGESGeom_Direction)::DownCast (tempRefdir));
}
void IGESSolid_ToolToroidalSurface::WriteOwnParams
const Handle(IntTools_Context)& );
static
- Standard_Boolean IsCurveValid(Handle(Geom2d_Curve)& thePCurve);
+ Standard_Boolean IsCurveValid(const Handle(Geom2d_Curve)& thePCurve);
static
Standard_Boolean ApproxWithPCurves(const gp_Cylinder& theCyl,
//function : IsCurveValid
//purpose :
//=======================================================================
-Standard_Boolean IsCurveValid(Handle(Geom2d_Curve)& thePCurve)
+Standard_Boolean IsCurveValid (const Handle(Geom2d_Curve)& thePCurve)
{
if(thePCurve.IsNull())
return Standard_False;
Handle(Standard_Transient) res;
if (!themap->Search(ent,res)) continue; // entite pas transferee
// Reconduction des references "Imply". Attention, ne pas copier si non chargee
- Handle(Interface_ReportEntity) rep;
- if (!therep->Search(ent,rep)) Implied (ent,res);
- else if (!rep->HasNewContent()) Implied (ent,res);
+ Handle(Standard_Transient) aRep;
+ if (!therep->Search(ent,aRep))
+ {
+ Implied (ent,res);
+ }
+ else
+ {
+ Handle(Interface_ReportEntity) rep = Handle(Interface_ReportEntity)::DownCast (aRep);
+ if (! rep.IsNull() && ! rep->HasNewContent())
+ Implied (ent,res);
+ }
}
}
Handle(Standard_Transient) res;
if (!themap->Search(ent,res)) continue;
if (withreports) {
- Handle(Interface_ReportEntity) rep;
+ Handle(Standard_Transient) rep;
if (therep->Search(ent,rep)) res = rep;
}
iter.GetOneItem(res);
Handle(Standard_Transient) res;
if (!themap->Search(ent,res)) continue;
if (withreports) {
- Handle(Interface_ReportEntity) rep;
+ Handle(Standard_Transient) rep;
if (therep->Search(ent,rep)) res = rep;
}
iter.GetOneItem(res);
Handle(TCollection_HAsciiString) sw, val;
if (!thecurconf->GetItem (name,sw,Standard_True)) sw.Nullify();
+ Handle(Standard_Transient) aVal;
if (!sw.IsNull()) {
- if (!opt->Item (sw->ToCString(),val)) val.Nullify();
+ if (!opt->Item (sw->ToCString(),aVal))
+ aVal.Nullify();
}
- if (val.IsNull() && !proper) opt->Value(val);
+ if (aVal.IsNull() && !proper)
+ opt->Value(aVal);
+ val = Handle(TCollection_HAsciiString)::DownCast (aVal);
// On applique
if (!val.IsNull()) tv->SetHStringValue (val);
}
}
-// =======================================================================
-// function : DelayedRelease
-// purpose :
-// =======================================================================
-void OpenGl_Context::DelayedRelease (Handle(OpenGl_Resource)& theResource)
-{
- myUnusedResources->Prepend (theResource);
- theResource.Nullify();
-}
-
// =======================================================================
// function : ReleaseDelayed
// purpose :
//! Append resource to queue for delayed clean up.
//! Resources in this queue will be released at next redraw call.
- Standard_EXPORT void DelayedRelease (Handle(OpenGl_Resource)& theResource);
+ template <class T>
+ void DelayedRelease (Handle(T)& theResource)
+ {
+ myUnusedResources->Prepend (theResource);
+ theResource.Nullify();
+ }
//! Clean up the delayed release queue.
Standard_EXPORT void ReleaseDelayed();
// function : nullifyResource
// purpose :
// =======================================================================
+template <class T>
inline void nullifyResource (const Handle(OpenGl_Context)& theGlContext,
- Handle(OpenGl_Resource)& theResource)
+ Handle(T)& theResource)
{
if (!theResource.IsNull())
{
if (aPrs.IsNull())
continue;
- Handle(Prs3d_Presentation) aViewDepPrs;
+ Handle(Graphic3d_Structure) aViewDepPrs;
Handle(Prs3d_PresentationShadow) aShadowPrs = Handle(Prs3d_PresentationShadow)::DownCast (aPrs);
if (!aShadowPrs.IsNull() && aView->IsComputed (aShadowPrs->ParentId(), aViewDepPrs))
{
aShadowPrs.Nullify();
- aShadowPrs = new Prs3d_PresentationShadow (myStructureManager, aViewDepPrs);
+ aShadowPrs = new Prs3d_PresentationShadow (myStructureManager,
+ Handle(Prs3d_Presentation)::DownCast (aViewDepPrs));
aShadowPrs->SetZLayer (aViewDepPrs->CStructure()->ZLayer());
aShadowPrs->SetClipPlanes (aViewDepPrs->GetClipPlanes());
aShadowPrs->CStructure()->IsForHighlight = 1;
#include <Standard_DefineHandle.hxx>
#include <Standard_Transient.hxx>
#include <TCollection_AsciiString.hxx>
+#include <Geom_Circle.hxx>
#include <Geom_Line.hxx>
#include <Geom_BSplineCurve.hxx>
#include <Geom_Surface.hxx>
inline void func (const Handle(gp_XYZ)&) {}
inline void func (const Handle(gp_Trsf)&) {}
-inline void gunc (Handle(Geom_Curve)&) {}
-
static Standard_Integer QAHandleOps (Draw_Interpretor& theDI,
Standard_Integer /*theArgNb*/,
const char** /*theArgVec*/)
func (cLine);
#endif
- // passing handle as non-const reference to base type
- // currently allowed for compatibility
- gunc (aLine);
- Handle(Geom_Curve)& aCurve2 = aLine; // cast to base non-const ref
+ const Handle(Geom_Curve)& aCurve2 = aLine; // cast to base const ref
Handle(Geom_Line) qLine = cpLine; // constructor from const pointer -- could be made explicit...
Handle(StepDimTol_HArray1OfDatumReferenceModifier) aModifiers;
if (aDatumSeqPos.Length() == 1) {
// Datum entity
- theDatumMap.Find(aDatumSeqPos.Value(1)->GetName()->String(), aFirstDatum);
+ Handle(Standard_Transient) aFDValue;
+ if (theDatumMap.Find(aDatumSeqPos.Value(1)->GetName()->String(), aFDValue))
+ aFirstDatum = Handle(StepDimTol_Datum)::DownCast (aFDValue);
aDatumRef.SetValue(aFirstDatum);
// Modifiers
XCAFDimTolObjects_DatumModifiersSequence aSimpleModifiers = aDatumSeqPos.Value(1)->GetModifiers();
for (Standard_Integer j = 1; j <= aDatumSeqPos.Length(); j++) {
// Datum entity
Handle(StepDimTol_Datum) aDatum;
- theDatumMap.Find(aDatumSeqPos.Value(j)->GetName()->String(), aDatum);
+ Handle(Standard_Transient) aDValue;
+ if (theDatumMap.Find(aDatumSeqPos.Value(j)->GetName()->String(), aDValue))
+ aDatum = Handle(StepDimTol_Datum)::DownCast (aDValue);
StepDimTol_DatumOrCommonDatum anElemDatumRef;
anElemDatumRef.SetValue(aDatum);
if (aFirstDatum.IsNull())
TCollection_AsciiString aDatumTargetId = TCollection_AsciiString(anObject->GetDatumTargetNumber());
if (!aNameIdMap.Add(aDatumName.Cat(aDatumTargetId)))
continue;
- Handle(StepDimTol_Datum) aWrittenDatum;
+ Handle(Standard_Transient) aWrittenDatum;
Standard_Boolean isFirstDT = !aDatumMap.Find(aDatumName, aWrittenDatum);
- Handle(StepDimTol_Datum) aDatum = WriteDatumAP242(WS, aShapeL.First(), aDatumL, isFirstDT, aWrittenDatum);
+ Handle(StepDimTol_Datum) aDatum = WriteDatumAP242(WS, aShapeL.First(), aDatumL, isFirstDT,
+ Handle(StepDimTol_Datum)::DownCast (aWrittenDatum));
// Add created Datum into Map
aDatumMap.Bind(aDatumName, aDatum);
}
for (Select3D_EntitySequenceIter anIt (myEntities); anIt.More(); anIt.Next())
{
SelectBasics_PickResult aMatchResult;
- Handle(SelectBasics_SensitiveEntity)& aChild = anIt.ChangeValue();
+ Handle(Select3D_SensitiveEntity)& aChild = anIt.ChangeValue();
if (!aChild->Matches (theMgr, aMatchResult))
{
aMatchResult = SelectBasics_PickResult (RealLast(), RealLast());
//! Upcast to non-const reference to base type.
//! NB: this cast can be dangerous, but required for legacy code; see #26377
template <class T2>
+ Standard_DEPRECATED("Passing non-const reference to handle of base type in function is unsafe; use variable of exact type")
operator handle<T2>& ()
{
// error "type is not a member of enable_if" will be generated if T2 is not sub-type of T
template <class Type>
StdObjMgt_ReadData& operator >> (Handle(Type)& theTarget)
{
- ReadReference (theTarget);
+ Handle(StdObjMgt_Persistent) aTarget = theTarget;
+ ReadReference (aTarget);
+ theTarget = Handle(Type)::DownCast (aTarget);
return *this;
}
Handle(StepData_SelectNamed) sn = new StepData_SelectNamed;
val = sn;
sn->SetName (rectyp.ToCString());
- if (ReadAny (numsub,1,mess,ach,descr,sn)) return sn->Kind();
+ Handle(Standard_Transient) aSN = sn;
+ if (ReadAny (numsub,1,mess,ach,descr,aSN)) return sn->Kind();
else return 0;
}
{
Handle(Standard_Transient) v = val;
Handle(StepData_PDescr) nuldescr;
- if (v.IsNull()) return ReadAny (num,nump,mess,ach,nuldescr,val);
+ if (v.IsNull())
+ {
+ return ReadAny (num,nump,mess,ach,nuldescr,v) &&
+ ! (val = Handle(StepData_SelectMember)::DownCast(v)).IsNull();
+ }
Standard_Boolean res = ReadAny (num,nump,mess,ach,nuldescr,v);
if (v == val) return res;
// changement -> refus
Handle(TColStd_HSequenceOfReal) aSeq = new TColStd_HSequenceOfReal;
for(Standard_Integer i=1; i<=nbp2; i++) {
if( Param(numsub2,i).ParamType() != Interface_ParamReal ) continue;
- Handle(StepData_SelectReal) sm1 = new StepData_SelectReal;
- if( !ReadAny(numsub2,i,mess,ach,descr,sm1) ) continue;
- aSeq->Append(sm1->Real());
+ Handle(Standard_Transient) asr = new StepData_SelectReal;
+ if( !ReadAny(numsub2,i,mess,ach,descr,asr) ) continue;
+ Handle(StepData_SelectReal) sm1 = Handle(StepData_SelectReal)::DownCast (asr);
+ if (! sm1.IsNull())
+ aSeq->Append(sm1->Real());
}
Handle(TColStd_HArray1OfReal) anArr = new TColStd_HArray1OfReal(1,aSeq->Length());
for(Standard_Integer nr=1; nr<=aSeq->Length(); nr++) {
//! some members as Entity, some other not)
Standard_EXPORT Standard_Boolean ReadMember (const Standard_Integer num, const Standard_Integer nump, const Standard_CString mess, Handle(Interface_Check)& ach, Handle(StepData_SelectMember)& val) const;
+ //! Safe variant for arbitrary type of argument
+ template <class T>
+ Standard_Boolean ReadMember (const Standard_Integer num, const Standard_Integer nump, const Standard_CString mess, Handle(Interface_Check)& ach, Handle(T)& val) const
+ {
+ Handle(StepData_SelectMember) aVal = val;
+ return ReadMember (num, nump, mess, ach, aVal) && ! (val = Handle(T)::DownCast(aVal)).IsNull();
+ }
+
//! reads parameter <nump> of record <num> into a Field,
//! controlled by a Parameter Descriptor (PDescr), which controls
//! its allowed type(s) and value
//! is an Entity but is not Kind of required type
Standard_EXPORT Standard_Boolean ReadEntity (const Standard_Integer num, const Standard_Integer nump, const Standard_CString mess, Handle(Interface_Check)& ach, const Handle(Standard_Type)& atype, Handle(Standard_Transient)& ent) const;
+ //! Safe variant for arbitrary type of argument
+ template <class T>
+ Standard_Boolean ReadEntity (const Standard_Integer num, const Standard_Integer nump, const Standard_CString mess, Handle(Interface_Check)& ach, const Handle(Standard_Type)& atype, Handle(T)& ent) const
+ {
+ Handle(Standard_Transient) anEnt = ent;
+ return ReadEntity (num, nump, mess, ach, atype, anEnt) && ! (ent = Handle(T)::DownCast(anEnt)).IsNull();
+ }
+
//! Same as above, but a SelectType checks Type Matching, and
//! records the read Entity (see method Value from SelectType)
Standard_EXPORT Standard_Boolean ReadEntity (const Standard_Integer num, const Standard_Integer nump, const Standard_CString mess, Handle(Interface_Check)& ach, StepData_SelectType& sel) const;
Handle(Interface_Check)& acheck)
{
DeclareAndCast(StepData_StepReaderData,stepdat,Data());
- Handle(StepData_ReadWriteModule) module; Standard_Integer CN;
- if (therlib.Select(anent,module,CN))
+ Handle(Interface_ReaderModule) imodule;
+ Standard_Integer CN;
+ if (therlib.Select(anent,imodule,CN))
+ {
+ Handle(StepData_ReadWriteModule) module =
+ Handle(StepData_ReadWriteModule)::DownCast (imodule);
module->ReadStep(CN,stepdat,num,acheck,anent);
+ }
else {
// Pas trouve : tenter UndefinedEntity de StepData
DeclareAndCast(StepData_UndefinedEntity,und,anent);
//! this method.
Standard_EXPORT Standard_Boolean FindAttribute (const Standard_GUID& anID, Handle(TDF_Attribute)& anAttribute) const;
+ //! Safe variant for arbitrary type of argument
+ template <class T>
+ Standard_Boolean FindAttribute (const Standard_GUID& theID, Handle(T)& theAttr) const
+ {
+ Handle(TDF_Attribute) anAttr = theAttr;
+ return FindAttribute (theID, anAttr) && ! (theAttr = Handle(T)::DownCast(anAttr)).IsNull();
+ }
+
//! Adds an Attribute <other> to the label of
//! <me>.Raises if there is already one of the same
//! GUID fhan <other>.
//! A removed attribute cannot be found.
Standard_EXPORT Standard_Boolean FindAttribute (const Standard_GUID& anID, Handle(TDF_Attribute)& anAttribute) const;
+ //! Safe variant of FindAttribute() for arbitrary type of argument
+ template <class T>
+ Standard_Boolean FindAttribute (const Standard_GUID& theID, Handle(T)& theAttr) const
+ {
+ Handle(TDF_Attribute) anAttr = theAttr;
+ return FindAttribute (theID, anAttr) && ! (theAttr = Handle(T)::DownCast(anAttr)).IsNull();
+ }
+
//! Finds an attribute of the current label, according
//! to <anID> and <aTransaction>. This attribute
//! has/had to be a valid one for the given
//! explanation about the method behavior)
Standard_EXPORT Standard_Boolean HasRelocation (const Handle(TDF_Attribute)& aSourceAttribute, Handle(TDF_Attribute)& aTargetAttribute) const;
+ //! Safe variant for arbitrary type of argument
+ template <class T>
+ Standard_Boolean HasRelocation (const Handle(TDF_Attribute)& theSource, Handle(T)& theTarget) const
+ {
+ Handle(TDF_Attribute) anAttr = theTarget;
+ return HasRelocation (theSource, anAttr) && ! (theTarget = Handle(T)::DownCast(anAttr)).IsNull();
+ }
+
//! Sets the relocation value of <aSourceTransient> to
//! <aTargetTransient>.
Standard_EXPORT void SetTransientRelocation (const Handle(Standard_Transient)& aSourceTransient, const Handle(Standard_Transient)& aTargetTransient);
const Standard_Integer Trans)
:myTrans(Trans)
{
- Handle(TNaming_NamedShape) Att;
+ Handle(TDF_Attribute) Att;
if (Lab.FindAttribute(TNaming_NamedShape::GetID(),Trans,Att)) {
- myNode = Att->myNode;
+ myNode = Handle(TNaming_NamedShape)::DownCast (Att)->myNode;
}
else {
myNode = 0L;
Standard_Boolean is_planar (aConst->IsPlanar());
Handle(Geom_Plane) aplane;
if (is_planar) {
- GetGeom (aConst,aplane);
+ Handle(Geom_Geometry) ageom;
+ GetGeom (aConst,ageom);
+ aplane = Handle(Geom_Plane)::DownCast (ageom);
if (aplane.IsNull()) {
#ifdef OCCT_DEBUG
cout << "TPrsStd_ConstraintTools::ComputeOffset: null plane" << endl;
}
TopoDS_Shape shape1,shape2 ;
- Handle(Geom_Plane) aplane;
- GetShapesAndGeom(aConst,shape1,shape2,aplane);
+ Handle(Geom_Geometry) ageom;
+ GetShapesAndGeom(aConst,shape1,shape2,ageom);
+ Handle(Geom_Plane) aplane = Handle(Geom_Plane)::DownCast (ageom);
if (shape1.IsNull() || shape2.IsNull()) {
#ifdef OCCT_DEBUG
cout << "TPrsStd_ConstraintTools::ComputeCoincident: nul shape" << endl;
//! immediately used, well initialised
Standard_EXPORT Standard_Boolean FindTypedTransient (const Handle(Transfer_Finder)& start, const Handle(Standard_Type)& atype, Handle(Standard_Transient)& val) const;
+ //! Safe variant for arbitrary type of argument
+ template <class T>
+ Standard_Boolean FindTypedTransient (const Handle(Transfer_Finder)& start, const Handle(Standard_Type)& atype, Handle(T)& val) const
+ {
+ Handle(Standard_Transient) aVal = val;
+ return FindTypedTransient (start, atype, aVal) && ! (val = Handle(T)::DownCast(aVal)).IsNull();
+ }
+
//! Searches for a transient result recorded in a Binder, whatever
//! this Binder is recorded or not in <me>
//!
//! Apart from this, works as FindTypedTransient
Standard_EXPORT Standard_Boolean GetTypedTransient (const Handle(Transfer_Binder)& binder, const Handle(Standard_Type)& atype, Handle(Standard_Transient)& val) const;
+ //! Safe variant for arbitrary type of argument
+ template <class T>
+ Standard_Boolean GetTypedTransient (const Handle(Transfer_Binder)& start, const Handle(Standard_Type)& atype, Handle(T)& val) const
+ {
+ Handle(Standard_Transient) aVal = val;
+ return GetTypedTransient (start, atype, aVal) && ! (val = Handle(T)::DownCast(aVal)).IsNull();
+ }
+
//! Returns the maximum possible value for Map Index
//! (no result can be bound with a value greater than it)
Standard_EXPORT Standard_Integer NbMapped() const;
// These four checks should be the last one to avoid their interference
// with the other tokens (e.g., coordIndex)
else if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "texCoord"))
- aStatus = ReadNode (theBuffer, myTxCoords,
+ {
+ Handle(VrmlData_Node) aNode;
+ aStatus = ReadNode (theBuffer, aNode,
STANDARD_TYPE(VrmlData_TextureCoordinate));
+ myTxCoords = Handle(VrmlData_TextureCoordinate)::DownCast (aNode);
+ }
else if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "color"))
- aStatus = ReadNode (theBuffer, myColors,
+ {
+ Handle(VrmlData_Node) aNode;
+ aStatus = ReadNode (theBuffer, aNode,
STANDARD_TYPE(VrmlData_Color));
+ myColors = Handle(VrmlData_Color)::DownCast (aNode);
+ }
else if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "coord"))
- aStatus = ReadNode (theBuffer, myCoords,
+ {
+ Handle(VrmlData_Node) aNode;
+ aStatus = ReadNode (theBuffer, aNode,
STANDARD_TYPE(VrmlData_Coordinate));
+ myCoords = Handle(VrmlData_Coordinate)::DownCast (aNode);
+ }
else if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "normal"))
- aStatus = ReadNode (theBuffer, myNormals,
+ {
+ Handle(VrmlData_Node) aNode;
+ aStatus = ReadNode (theBuffer, aNode,
STANDARD_TYPE(VrmlData_Normal));
+ myNormals = Handle(VrmlData_Normal)::DownCast (aNode);
+ }
if (!OK(aStatus))
break;
}
// These two checks should be the last one to avoid their interference
// with the other tokens (e.g., coordIndex)
else if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "color"))
- aStatus = ReadNode (theBuffer, myColors,
+ {
+ Handle(VrmlData_Node) aNode;
+ aStatus = ReadNode (theBuffer, aNode,
STANDARD_TYPE(VrmlData_Color));
+ myColors = Handle(VrmlData_Color)::DownCast (aNode);
+ }
else if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "coord"))
- aStatus = ReadNode (theBuffer, myCoords,
+ {
+ Handle(VrmlData_Node) aNode;
+ aStatus = ReadNode (theBuffer, aNode,
STANDARD_TYPE(VrmlData_Coordinate));
+ myCoords = Handle(VrmlData_Coordinate)::DownCast (aNode);
+ }
else
break;
if (!OK(aStatus))
VrmlData_ErrorStatus aStatus;
while (OK(aStatus, VrmlData_Scene::ReadLine(theBuffer))) {
if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "appearance"))
- aStatus = ReadNode (theBuffer, myAppearance,
+ {
+ Handle(VrmlData_Node) aNode;
+ aStatus = ReadNode (theBuffer, aNode,
STANDARD_TYPE(VrmlData_Appearance));
+ myAppearance = Handle(VrmlData_Appearance)::DownCast (aNode);
+ }
else if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "geometry"))
- aStatus = ReadNode (theBuffer, myGeometry);
+ {
+ Handle(VrmlData_Node) aNode;
+ aStatus = ReadNode (theBuffer, aNode);
+ myGeometry = Handle(VrmlData_Geometry)::DownCast (aNode);
// here we do not check for the Geometry type because unknown node types can
// occur (IndexedLineSet, etc.)
// STANDARD_TYPE(VrmlData_Geometry));
+ }
else
break;
VrmlData_ErrorStatus aStatus;
while (OK(aStatus, VrmlData_Scene::ReadLine(theBuffer))) {
if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "material"))
- aStatus = ReadNode (theBuffer, myMaterial,
+ {
+ Handle(VrmlData_Node) aNode;
+ aStatus = ReadNode (theBuffer, aNode,
STANDARD_TYPE(VrmlData_Material));
+ myMaterial = Handle(VrmlData_Material)::DownCast (aNode);
+ }
else if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "textureTransform"))
- aStatus = ReadNode (theBuffer, myTTransform
+ {
+ Handle(VrmlData_Node) aNode;
+ aStatus = ReadNode (theBuffer, aNode
/*,STANDARD_TYPE(VrmlData_TextureTransform)*/);
+ myTTransform = Handle(VrmlData_TextureTransform)::DownCast (aNode);
+ }
else if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "texture"))
- aStatus = ReadNode (theBuffer, myTexture,
+ {
+ Handle(VrmlData_Node) aNode;
+ aStatus = ReadNode (theBuffer, aNode,
STANDARD_TYPE(VrmlData_Texture));
+ myTexture = Handle(VrmlData_Texture)::DownCast (aNode);
+ }
else
break;
const Handle(CDM_MessageDriver)& theMsgDriver)
{
if (myDrivers.IsNull()) myDrivers = AttributeDrivers (theMsgDriver);
- Handle(XmlMNaming_NamedShapeDriver) aNamedShapeDriver;
- if (myDrivers -> GetDriver (STANDARD_TYPE(TNaming_NamedShape),
- aNamedShapeDriver))
+ Handle(XmlMDF_ADriver) aDriver;
+ if (myDrivers->GetDriver (STANDARD_TYPE(TNaming_NamedShape), aDriver))
+ {
+ Handle(XmlMNaming_NamedShapeDriver) aNamedShapeDriver =
+ Handle(XmlMNaming_NamedShapeDriver)::DownCast (aDriver);
aNamedShapeDriver -> ReadShapeSection (theElement);
- return aNamedShapeDriver;
+ }
+ return aDriver;
}
//=======================================================================
Standard_Boolean XmlDrivers_DocumentStorageDriver::WriteShapeSection
(XmlObjMgt_Element& theElement)
{
- Handle(XmlMNaming_NamedShapeDriver) aNamedShapeDriver;
Standard_Boolean isShape(Standard_False);
- if (myDrivers -> GetDriver (STANDARD_TYPE(TNaming_NamedShape),
- aNamedShapeDriver)) {
+ Handle(XmlMDF_ADriver) aDriver;
+ if (myDrivers->GetDriver (STANDARD_TYPE(TNaming_NamedShape), aDriver))
+ {
+ Handle(XmlMNaming_NamedShapeDriver) aNamedShapeDriver =
+ Handle(XmlMNaming_NamedShapeDriver)::DownCast (aDriver);
aNamedShapeDriver -> WriteShapeSection (theElement);
isShape = Standard_True;
}
aDriverTable -> AddDriver (new XmlMXCAFDoc_GraphNodeDriver (anMsgDrv));
//oan: changes for sharing locations map
- Handle(XmlMNaming_NamedShapeDriver) aNamedShapeDriver;
- aDriverTable->GetDriver(STANDARD_TYPE(TNaming_NamedShape), aNamedShapeDriver);
+ Handle(XmlMDF_ADriver) aDriver;
+ aDriverTable->GetDriver(STANDARD_TYPE(TNaming_NamedShape), aDriver);
+ Handle(XmlMNaming_NamedShapeDriver) aNamedShapeDriver =
+ Handle(XmlMNaming_NamedShapeDriver)::DownCast (aDriver);
Handle(XmlMXCAFDoc_LocationDriver) aLocationDriver = new XmlMXCAFDoc_LocationDriver (anMsgDrv);
if( !aNamedShapeDriver.IsNull() )
set filename 919-004-T03-04-CP-VL.igs
set ref_data {
-DATA : Faulties = 0 ( 0 ) Warnings = 0 ( 0 ) Summary = 0 ( 0 )
+DATA : Faulties = 0 ( 2 ) Warnings = 0 ( 0 ) Summary = 0 ( 2 )
TPSTAT : Faulties = 0 ( 2 ) Warnings = 310 ( 2179 ) Summary = 310 ( 2181 )
CHECKSHAPE : Wires = 0 ( 3 ) Faces = 0 ( 3 ) Shells = 0 ( 0 ) Solids = 0 ( 0 )
NBSHAPES : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 1457 ( 1455 ) Summary = 38832 ( 38834 )
if { $ratio > 1.05 } {
puts "Error: OCCT handle is too slow: $time_occt vs. $time_std of shared_ptr"
}
-
-# Check performance of down casting at different nesting depths.
-# OCCT is expected to be the same as C++
-set depths {3 5 10 50}
-set threshold_std 4.0
-set threshold_ptr 2.5
-for {set i 0} {$i < [llength $depths]} {incr i} {
- set depth [lindex $depths $i]
- puts "\nTesting DownCast at nesting depth $depth"
-
- set res [QAHandleCast $depth 0 100000]
- set res_lines [split $res \n]
- set time_occt [lindex [lindex [split [lindex $res_lines end-2] :] end] end]
- set time_std [lindex [lindex [split [lindex $res_lines end-1] :] end] end]
- set time_ptr [lindex [lindex [split [lindex $res_lines end ] :] end] end]
- set ratio_std [expr $time_occt / $time_std]
- set ratio_ptr [expr $time_occt / $time_ptr]
-
- puts "Ratio of time of OCCT DownCast() to dynamic_cast<>: $ratio_std"
- puts "Ratio of time of OCCT DownCast() to dynamic_pointer_cast<>: $ratio_ptr"
-
- if { $ratio_std > $threshold_std || $ratio_ptr > $threshold_ptr } {
- puts "Error: OCCT DownCast is expected to be faster!"
- }
-}
\ No newline at end of file