1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-10 18:51:21 +03:00

0026377: Passing Handle objects as arguments to functions as non-const reference to base type is dangerous

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.
This commit is contained in:
abv 2016-02-17 17:33:18 +03:00
parent fe9b8ff2f2
commit aa00364da7
59 changed files with 395 additions and 211 deletions

View File

@ -860,9 +860,9 @@ Standard_Boolean AIS_AngleDimension::InitTwoEdgesAngle (gp_Pln& theComputedPlane
// Compute geometry for this plane and edges // Compute geometry for this plane and edges
Standard_Boolean isInfinite1,isInfinite2; Standard_Boolean isInfinite1,isInfinite2;
gp_Pnt aFirstPoint1, aLastPoint1, aFirstPoint2, aLastPoint2; gp_Pnt aFirstPoint1, aLastPoint1, aFirstPoint2, aLastPoint2;
Handle(Geom_Curve) aFirstCurve = aFirstLine, aSecondCurve = aSecondLine;
if (!AIS::ComputeGeometry (aFirstEdge, aSecondEdge, if (!AIS::ComputeGeometry (aFirstEdge, aSecondEdge,
aFirstLine, aSecondLine, aFirstCurve, aSecondCurve,
aFirstPoint1, aLastPoint1, aFirstPoint1, aLastPoint1,
aFirstPoint2, aLastPoint2, aFirstPoint2, aLastPoint2,
isInfinite1, isInfinite2)) isInfinite1, isInfinite2))

View File

@ -106,13 +106,13 @@ void AIS_Chamf2dDimension::Compute(const Handle(PrsMgr_PresentationManager3d)& ,
{ {
aPresentation->Clear(); aPresentation->Clear();
Handle(Geom_Line) glin; Handle(Geom_Curve) gcurv;
gp_Pnt pfirst,plast; gp_Pnt pfirst,plast;
const TopoDS_Edge& thechamfedge = TopoDS::Edge(myFShape); const TopoDS_Edge& thechamfedge = TopoDS::Edge(myFShape);
if (!AIS::ComputeGeometry(thechamfedge, glin,pfirst,plast) ) if (!AIS::ComputeGeometry (thechamfedge, gcurv, pfirst, plast))
return; return;
Handle(Geom_Line) glin = Handle(Geom_Line)::DownCast (gcurv);
gp_Dir dir1 (glin->Position().Direction()); gp_Dir dir1 (glin->Position().Direction());
gp_Dir norm1 = myPlane->Pln().Axis().Direction(); gp_Dir norm1 = myPlane->Pln().Axis().Direction();
myDir = norm1.Crossed(dir1); myDir = norm1.Crossed(dir1);

View File

@ -154,7 +154,7 @@ void AIS_SymmetricRelation::ComputeSelection(const Handle(SelectMgr_Selection)&
Handle(SelectMgr_EntityOwner) own = new SelectMgr_EntityOwner(this,7); Handle(SelectMgr_EntityOwner) own = new SelectMgr_EntityOwner(this,7);
Standard_Real F,L; Standard_Real F,L;
Handle(Geom_Line) geom_axis,extcurve; Handle(Geom_Curve) geom_axis, extcurve;
gp_Pnt p1,p2; gp_Pnt p1,p2;
Standard_Boolean isinfinite,isonplane; Standard_Boolean isinfinite,isonplane;
if (!AIS::ComputeGeometry(TopoDS::Edge(myTool), if (!AIS::ComputeGeometry(TopoDS::Edge(myTool),
@ -164,7 +164,8 @@ void AIS_SymmetricRelation::ComputeSelection(const Handle(SelectMgr_Selection)&
isonplane, isonplane,
myPlane)) return; 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){ if(myFShape.ShapeType() != TopAbs_VERTEX){
BRepAdaptor_Curve cu1(TopoDS::Edge(myFShape)); BRepAdaptor_Curve cu1(TopoDS::Edge(myFShape));
@ -402,7 +403,7 @@ void AIS_SymmetricRelation::ComputeTwoEdgesSymmetric(const Handle(Prs3d_Presenta
return; return;
} }
aprs->SetInfiniteState((isInfinite1 || isInfinite2) && (myExtShape !=0)); aprs->SetInfiniteState((isInfinite1 || isInfinite2) && (myExtShape !=0));
Handle(Geom_Line) geom_axis,extcurve; Handle(Geom_Curve) geom_axis,extcurve;
gp_Pnt p1,p2; gp_Pnt p1,p2;
Standard_Boolean isinfinite,isonplane; Standard_Boolean isinfinite,isonplane;
if (!AIS::ComputeGeometry(TopoDS::Edge(myTool), if (!AIS::ComputeGeometry(TopoDS::Edge(myTool),
@ -412,7 +413,8 @@ void AIS_SymmetricRelation::ComputeTwoEdgesSymmetric(const Handle(Prs3d_Presenta
isonplane, isonplane,
myPlane)) return; 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(); myAxisDirAttach = laxis.Direction();
if(cu1.GetType() == GeomAbs_Line){ if(cu1.GetType() == GeomAbs_Line){
@ -578,7 +580,7 @@ void AIS_SymmetricRelation::ComputeTwoEdgesSymmetric(const Handle(Prs3d_Presenta
void AIS_SymmetricRelation::ComputeTwoVerticesSymmetric(const Handle(Prs3d_Presentation)& aprs) void AIS_SymmetricRelation::ComputeTwoVerticesSymmetric(const Handle(Prs3d_Presentation)& aprs)
{ {
if(myFShape.ShapeType() != TopAbs_VERTEX || mySShape.ShapeType() != TopAbs_VERTEX) return; 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; gp_Pnt p1,p2;
Standard_Boolean isinfinite,isonplane; Standard_Boolean isinfinite,isonplane;
if (!AIS::ComputeGeometry(TopoDS::Edge(myTool), if (!AIS::ComputeGeometry(TopoDS::Edge(myTool),
@ -604,7 +606,9 @@ void AIS_SymmetricRelation::ComputeTwoVerticesSymmetric(const Handle(Prs3d_Prese
myExtShape = 1; myExtShape = 1;
else else
return ; 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(); myAxisDirAttach = laxis.Direction();
// recherche points attache // recherche points attache

View File

@ -62,21 +62,23 @@ void BinDrivers_DocumentRetrievalDriver::ReadShapeSection
{ {
// Read Shapes // Read Shapes
Handle(BinMNaming_NamedShapeDriver) aNamedShapeDriver; Handle(BinMDF_ADriver) aDriver;
if (myDrivers->GetDriver(STANDARD_TYPE(TNaming_NamedShape),aNamedShapeDriver)) if (myDrivers->GetDriver(STANDARD_TYPE(TNaming_NamedShape),aDriver))
{ {
try { try {
OCC_CATCH_SIGNALS OCC_CATCH_SIGNALS
aNamedShapeDriver->ReadShapeSection (theIS); Handle(BinMNaming_NamedShapeDriver) aNamedShapeDriver =
} Handle(BinMNaming_NamedShapeDriver)::DownCast (aDriver);
catch(Standard_Failure) { aNamedShapeDriver->ReadShapeSection (theIS);
Handle(Standard_Failure) aFailure = Standard_Failure::Caught();
const TCollection_ExtendedString aMethStr
("BinDrivers_DocumentRetrievalDriver: ");
WriteMessage (aMethStr + "error of Shape Section " +
aFailure->GetMessageString());
}
} }
catch(Standard_Failure) {
Handle(Standard_Failure) aFailure = Standard_Failure::Caught();
const TCollection_ExtendedString aMethStr
("BinDrivers_DocumentRetrievalDriver: ");
WriteMessage (aMethStr + "error of Shape Section " +
aFailure->GetMessageString());
}
}
} }
//======================================================================= //=======================================================================

View File

@ -57,10 +57,14 @@ void BinDrivers_DocumentStorageDriver::WriteShapeSection
{ {
const Standard_Size aShapesSectionOffset = (Standard_Size) theOS.tellp(); const Standard_Size aShapesSectionOffset = (Standard_Size) theOS.tellp();
Handle(BinMNaming_NamedShapeDriver) aNamedShapeDriver; Handle(BinMDF_ADriver) aDriver;
if (myDrivers->GetDriver(STANDARD_TYPE(TNaming_NamedShape), aNamedShapeDriver)) { if (myDrivers->GetDriver(STANDARD_TYPE(TNaming_NamedShape), aDriver))
{
try { 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) { catch(Standard_Failure) {
TCollection_ExtendedString anErrorStr ("Error: "); TCollection_ExtendedString anErrorStr ("Error: ");

View File

@ -47,8 +47,10 @@ void BinMXCAFDoc::AddDrivers(const Handle(BinMDF_ADriverTable)& theDriverTable,
theDriverTable->AddDriver( new BinMXCAFDoc_GraphNodeDriver(theMsgDrv)); theDriverTable->AddDriver( new BinMXCAFDoc_GraphNodeDriver(theMsgDrv));
//oan: changes for sharing locations map //oan: changes for sharing locations map
Handle(BinMNaming_NamedShapeDriver) aNamedShapeDriver; Handle(BinMDF_ADriver) aNSDriver;
theDriverTable->GetDriver(STANDARD_TYPE(TNaming_NamedShape), aNamedShapeDriver); theDriverTable->GetDriver(STANDARD_TYPE(TNaming_NamedShape), aNSDriver);
Handle(BinMNaming_NamedShapeDriver) aNamedShapeDriver =
Handle(BinMNaming_NamedShapeDriver)::DownCast (aNSDriver);
Handle(BinMXCAFDoc_LocationDriver) aLocationDriver = new BinMXCAFDoc_LocationDriver (theMsgDrv); Handle(BinMXCAFDoc_LocationDriver) aLocationDriver = new BinMXCAFDoc_LocationDriver (theMsgDrv);
if( !aNamedShapeDriver.IsNull() ) if( !aNamedShapeDriver.IsNull() )

View File

@ -61,6 +61,14 @@ public:
//! that case A is setted. //! 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); 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 Draw_Interpretor& ReturnLabel (Draw_Interpretor& theCommands, const TDF_Label& L);
Standard_EXPORT static void AllCommands (Draw_Interpretor& theCommands); Standard_EXPORT static void AllCommands (Draw_Interpretor& theCommands);

View File

@ -60,6 +60,14 @@ public:
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); 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 Draw_Interpretor& ReturnLabel (Draw_Interpretor& theCommands, const TDF_Label& L);
Standard_EXPORT static void AllCommands (Draw_Interpretor& theCommands); Standard_EXPORT static void AllCommands (Draw_Interpretor& theCommands);

View File

@ -72,9 +72,25 @@ public:
//! <exact> : same as for HasItem //! <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; 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 //! 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; 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 //! Binds an item to a dictionnary entry
//! If <name> is already known in the dictionary, its value //! If <name> is already known in the dictionary, its value
//! is changed. Else, the dictionary entry is created. //! is changed. Else, the dictionary entry is created.

View File

@ -1438,8 +1438,7 @@ static void csave(const Handle(Draw_Drawable3D)&d, ostream& OS)
static Handle(Draw_Drawable3D) crestore (istream& is) static Handle(Draw_Drawable3D) crestore (istream& is)
{ {
Handle(Geom_Curve) G; Handle(Geom_Curve) G = GeomTools_CurveSet::ReadCurve(is);
GeomTools_CurveSet::ReadCurve(is,G);
Handle(DrawTrSurf_Curve) N = Handle(DrawTrSurf_Curve) N =
new DrawTrSurf_Curve(G,CurvColor,Discret,Deflection,DrawMode); new DrawTrSurf_Curve(G,CurvColor,Discret,Deflection,DrawMode);
return N; return N;
@ -1470,8 +1469,8 @@ static void bzcsave(const Handle(Draw_Drawable3D)&d, ostream& OS)
static Handle(Draw_Drawable3D) bzcrestore (istream& is) static Handle(Draw_Drawable3D) bzcrestore (istream& is)
{ {
Handle(Geom_BezierCurve) G; Handle(Geom_BezierCurve) G =
GeomTools_CurveSet::ReadCurve(is,G); Handle(Geom_BezierCurve)::DownCast (GeomTools_CurveSet::ReadCurve(is));
Handle(DrawTrSurf_BezierCurve) N = Handle(DrawTrSurf_BezierCurve) N =
new DrawTrSurf_BezierCurve(G,CurvColor,PolesColor,ShowPoles, new DrawTrSurf_BezierCurve(G,CurvColor,PolesColor,ShowPoles,
Discret,Deflection,DrawMode); Discret,Deflection,DrawMode);
@ -1503,8 +1502,8 @@ static void bscsave(const Handle(Draw_Drawable3D)&d, ostream& OS)
static Handle(Draw_Drawable3D) bscrestore (istream& is) static Handle(Draw_Drawable3D) bscrestore (istream& is)
{ {
Handle(Geom_BSplineCurve) G; Handle(Geom_BSplineCurve) G =
GeomTools_CurveSet::ReadCurve(is,G); Handle(Geom_BSplineCurve)::DownCast (GeomTools_CurveSet::ReadCurve(is));
Handle(DrawTrSurf_BSplineCurve) N = Handle(DrawTrSurf_BSplineCurve) N =
new DrawTrSurf_BSplineCurve(G, CurvColor,PolesColor, new DrawTrSurf_BSplineCurve(G, CurvColor,PolesColor,
KnotsColor, KnotsColor,
@ -1536,8 +1535,7 @@ static void c2dsave(const Handle(Draw_Drawable3D)&d, ostream& OS)
static Handle(Draw_Drawable3D) c2drestore (istream& is) static Handle(Draw_Drawable3D) c2drestore (istream& is)
{ {
Handle(Geom2d_Curve) G; Handle(Geom2d_Curve) G = GeomTools_Curve2dSet::ReadCurve2d(is);
GeomTools_Curve2dSet::ReadCurve2d(is,G);
Handle(DrawTrSurf_Curve2d) N = Handle(DrawTrSurf_Curve2d) N =
new DrawTrSurf_Curve2d(G,CurvColor,Discret); new DrawTrSurf_Curve2d(G,CurvColor,Discret);
return N; return N;
@ -1568,8 +1566,8 @@ static void bzc2dsave(const Handle(Draw_Drawable3D)&d, ostream& OS)
static Handle(Draw_Drawable3D) bzc2drestore (istream& is) static Handle(Draw_Drawable3D) bzc2drestore (istream& is)
{ {
Handle(Geom2d_BezierCurve) G; Handle(Geom2d_BezierCurve) G =
GeomTools_Curve2dSet::ReadCurve2d(is,G); Handle(Geom2d_BezierCurve)::DownCast (GeomTools_Curve2dSet::ReadCurve2d(is));
Handle(DrawTrSurf_BezierCurve2d) N = Handle(DrawTrSurf_BezierCurve2d) N =
new DrawTrSurf_BezierCurve2d(G,CurvColor,PolesColor,ShowPoles, new DrawTrSurf_BezierCurve2d(G,CurvColor,PolesColor,ShowPoles,
Discret); Discret);
@ -1601,8 +1599,8 @@ static void bsc2dsave(const Handle(Draw_Drawable3D)&d, ostream& OS)
static Handle(Draw_Drawable3D) bsc2drestore (istream& is) static Handle(Draw_Drawable3D) bsc2drestore (istream& is)
{ {
Handle(Geom2d_BSplineCurve) G; Handle(Geom2d_BSplineCurve) G =
GeomTools_Curve2dSet::ReadCurve2d(is,G); Handle(Geom2d_BSplineCurve)::DownCast (GeomTools_Curve2dSet::ReadCurve2d(is));
Handle(DrawTrSurf_BSplineCurve2d) N = Handle(DrawTrSurf_BSplineCurve2d) N =
new DrawTrSurf_BSplineCurve2d(G, CurvColor,PolesColor, new DrawTrSurf_BSplineCurve2d(G, CurvColor,PolesColor,
KnotsColor, KnotsColor,
@ -1634,8 +1632,7 @@ static void ssave(const Handle(Draw_Drawable3D)&d, ostream& OS)
static Handle(Draw_Drawable3D) srestore (istream& is) static Handle(Draw_Drawable3D) srestore (istream& is)
{ {
Handle(Geom_Surface) G; Handle(Geom_Surface) G = GeomTools_SurfaceSet::ReadSurface(is);
GeomTools_SurfaceSet::ReadSurface(is,G);
Handle(DrawTrSurf_Surface) N = Handle(DrawTrSurf_Surface) N =
new DrawTrSurf_Surface(G, new DrawTrSurf_Surface(G,
NbUIsos,NbVIsos, NbUIsos,NbVIsos,
@ -1669,8 +1666,8 @@ static void bzssave(const Handle(Draw_Drawable3D)&d, ostream& OS)
static Handle(Draw_Drawable3D) bzsrestore (istream& is) static Handle(Draw_Drawable3D) bzsrestore (istream& is)
{ {
Handle(Geom_BezierSurface) G; Handle(Geom_BezierSurface) G =
GeomTools_SurfaceSet::ReadSurface(is,G); Handle(Geom_BezierSurface)::DownCast (GeomTools_SurfaceSet::ReadSurface(is));
Handle(DrawTrSurf_BezierSurface) N = Handle(DrawTrSurf_BezierSurface) N =
new DrawTrSurf_BezierSurface(G,NbUIsos,NbVIsos, new DrawTrSurf_BezierSurface(G,NbUIsos,NbVIsos,
BoundsColor,IsosColor,PolesColor, BoundsColor,IsosColor,PolesColor,
@ -1704,8 +1701,8 @@ static void bsssave(const Handle(Draw_Drawable3D)&d, ostream& OS)
static Handle(Draw_Drawable3D) bssrestore (istream& is) static Handle(Draw_Drawable3D) bssrestore (istream& is)
{ {
Handle(Geom_BSplineSurface) G; Handle(Geom_BSplineSurface) G =
GeomTools_SurfaceSet::ReadSurface(is,G); Handle(Geom_BSplineSurface)::DownCast (GeomTools_SurfaceSet::ReadSurface(is));
Handle(DrawTrSurf_BSplineSurface) N; Handle(DrawTrSurf_BSplineSurface) N;
if (!knotsIsos) if (!knotsIsos)
N = new DrawTrSurf_BSplineSurface(G, N = new DrawTrSurf_BSplineSurface(G,

View File

@ -38,7 +38,7 @@ void GeomTools::Write(const Handle(Geom_Surface)& S, Standard_OStream& OS)
void GeomTools::Read(Handle(Geom_Surface)& S, Standard_IStream& IS) 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::Dump(const Handle(Geom_Curve)& C, Standard_OStream& OS)
@ -53,7 +53,7 @@ void GeomTools::Write(const Handle(Geom_Curve)& C, Standard_OStream& OS)
void GeomTools::Read(Handle(Geom_Curve)& C, Standard_IStream& IS) 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::Dump(const Handle(Geom2d_Curve)& C, Standard_OStream& OS)
@ -68,7 +68,7 @@ void GeomTools::Write(const Handle(Geom2d_Curve)& C, Standard_OStream& OS)
void GeomTools::Read(Handle(Geom2d_Curve)& C, Standard_IStream& IS) void GeomTools::Read(Handle(Geom2d_Curve)& C, Standard_IStream& IS)
{ {
GeomTools_Curve2dSet::ReadCurve2d(IS,C); C = GeomTools_Curve2dSet::ReadCurve2d(IS);
} }
//======================================================================= //=======================================================================

View File

@ -709,8 +709,7 @@ static Standard_IStream& operator>>(Standard_IStream& IS,
Standard_Real p1=0.,p2=0.; Standard_Real p1=0.,p2=0.;
GeomTools::GetReal(IS, p1); GeomTools::GetReal(IS, p1);
GeomTools::GetReal(IS, p2); GeomTools::GetReal(IS, p2);
Handle(Geom2d_Curve) BC; Handle(Geom2d_Curve) BC = GeomTools_Curve2dSet::ReadCurve2d(IS);
GeomTools_Curve2dSet::ReadCurve2d(IS,BC);
C = new Geom2d_TrimmedCurve(BC,p1,p2); C = new Geom2d_TrimmedCurve(BC,p1,p2);
return IS; return IS;
} }
@ -725,8 +724,7 @@ static Standard_IStream& operator>>(Standard_IStream& IS,
{ {
Standard_Real p=0.; Standard_Real p=0.;
GeomTools::GetReal(IS, p); GeomTools::GetReal(IS, p);
Handle(Geom2d_Curve) BC; Handle(Geom2d_Curve) BC = GeomTools_Curve2dSet::ReadCurve2d(IS);
GeomTools_Curve2dSet::ReadCurve2d(IS,BC);
C = new Geom2d_OffsetCurve(BC,p); C = new Geom2d_OffsetCurve(BC,p);
return IS; return IS;
} }
@ -736,11 +734,11 @@ static Standard_IStream& operator>>(Standard_IStream& IS,
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_IStream& GeomTools_Curve2dSet::ReadCurve2d(Standard_IStream& IS, Handle(Geom2d_Curve) GeomTools_Curve2dSet::ReadCurve2d(Standard_IStream& IS)
Handle(Geom2d_Curve)& C)
{ {
Standard_Integer ctype; Standard_Integer ctype;
Handle(Geom2d_Curve) C;
try { try {
OCC_CATCH_SIGNALS OCC_CATCH_SIGNALS
IS >> ctype; IS >> ctype;
@ -833,9 +831,8 @@ Standard_IStream& GeomTools_Curve2dSet::ReadCurve2d(Standard_IStream& IS,
cout <<"EXCEPTION in GeomTools_Curve2dSet::ReadCurve2d(..)!!!" << endl; cout <<"EXCEPTION in GeomTools_Curve2dSet::ReadCurve2d(..)!!!" << endl;
cout << anExc << endl; cout << anExc << endl;
#endif #endif
C = NULL;
} }
return IS; return C;
} }
//======================================================================= //=======================================================================
@ -852,14 +849,13 @@ void GeomTools_Curve2dSet::Read(Standard_IStream& IS)
return; return;
} }
Handle(Geom2d_Curve) C;
Standard_Integer i, nbcurve; Standard_Integer i, nbcurve;
IS >> nbcurve; IS >> nbcurve;
//OCC19559 //OCC19559
Handle(Message_ProgressIndicator) progress = GetProgress(); Handle(Message_ProgressIndicator) progress = GetProgress();
Message_ProgressSentry PS(progress, "2D Curves", 0, nbcurve, 1); Message_ProgressSentry PS(progress, "2D Curves", 0, nbcurve, 1);
for (i = 1; i <= nbcurve && PS.More(); i++, PS.Next()) { 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); myMap.Add(C);
} }
} }

View File

@ -71,9 +71,9 @@ public:
Standard_EXPORT static void PrintCurve2d (const Handle(Geom2d_Curve)& C, Standard_OStream& OS, const Standard_Boolean compact = Standard_False); 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 //! 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). //! 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_EXPORT void SetProgress (const Handle(Message_ProgressIndicator)& PR);

View File

@ -729,8 +729,7 @@ static Standard_IStream& operator>>(Standard_IStream& IS,
Standard_Real p1=0.,p2=0.; Standard_Real p1=0.,p2=0.;
GeomTools::GetReal(IS, p1); GeomTools::GetReal(IS, p1);
GeomTools::GetReal(IS, p2); GeomTools::GetReal(IS, p2);
Handle(Geom_Curve) BC; Handle(Geom_Curve) BC = GeomTools_CurveSet::ReadCurve(IS);
GeomTools_CurveSet::ReadCurve(IS,BC);
C = new Geom_TrimmedCurve(BC,p1,p2); C = new Geom_TrimmedCurve(BC,p1,p2);
return IS; return IS;
} }
@ -747,8 +746,7 @@ static Standard_IStream& operator>>(Standard_IStream& IS,
GeomTools::GetReal(IS, p); GeomTools::GetReal(IS, p);
gp_Dir D(1.,0.,0.); gp_Dir D(1.,0.,0.);
IS >> D; IS >> D;
Handle(Geom_Curve) BC; Handle(Geom_Curve) BC = GeomTools_CurveSet::ReadCurve(IS);
GeomTools_CurveSet::ReadCurve(IS,BC);
C = new Geom_OffsetCurve(BC,p,D); C = new Geom_OffsetCurve(BC,p,D);
return IS; return IS;
} }
@ -758,11 +756,11 @@ static Standard_IStream& operator>>(Standard_IStream& IS,
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_IStream& GeomTools_CurveSet::ReadCurve(Standard_IStream& IS, Handle(Geom_Curve) GeomTools_CurveSet::ReadCurve (Standard_IStream& IS)
Handle(Geom_Curve)& C)
{ {
Standard_Integer ctype; Standard_Integer ctype;
Handle(Geom_Curve) C;
try { try {
OCC_CATCH_SIGNALS OCC_CATCH_SIGNALS
IS >> ctype; IS >> ctype;
@ -854,9 +852,8 @@ Standard_IStream& GeomTools_CurveSet::ReadCurve(Standard_IStream& IS,
cout <<"EXCEPTION in GeomTools_CurveSet::ReadCurve(..)!!!" << endl; cout <<"EXCEPTION in GeomTools_CurveSet::ReadCurve(..)!!!" << endl;
cout << anExc << endl; cout << anExc << endl;
#endif #endif
C = NULL;
} }
return IS; return C;
} }
//======================================================================= //=======================================================================
@ -873,14 +870,13 @@ void GeomTools_CurveSet::Read(Standard_IStream& IS)
return; return;
} }
Handle(Geom_Curve) C;
Standard_Integer i, nbcurve; Standard_Integer i, nbcurve;
IS >> nbcurve; IS >> nbcurve;
//OCC19559 //OCC19559
Handle(Message_ProgressIndicator) progress = GetProgress(); Handle(Message_ProgressIndicator) progress = GetProgress();
Message_ProgressSentry PS(progress, "3D Curves", 0, nbcurve, 1); Message_ProgressSentry PS(progress, "3D Curves", 0, nbcurve, 1);
for (i = 1; i <= nbcurve && PS.More(); i++, PS.Next()) { 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); myMap.Add(C);
} }
} }

View File

@ -71,9 +71,9 @@ public:
Standard_EXPORT static void PrintCurve (const Handle(Geom_Curve)& C, Standard_OStream& OS, const Standard_Boolean compact = Standard_False); 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 //! 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). //! 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); Standard_EXPORT void SetProgress (const Handle(Message_ProgressIndicator)& PR);

View File

@ -786,9 +786,8 @@ static Standard_IStream& operator>>(Standard_IStream& IS,
Handle(Geom_SurfaceOfLinearExtrusion)& S) Handle(Geom_SurfaceOfLinearExtrusion)& S)
{ {
gp_Dir D(1.,0.,0.); gp_Dir D(1.,0.,0.);
Handle(Geom_Curve) C;
IS >> D; IS >> D;
GeomTools_CurveSet::ReadCurve(IS,C); Handle(Geom_Curve) C = GeomTools_CurveSet::ReadCurve(IS);
S = new Geom_SurfaceOfLinearExtrusion(C,D); S = new Geom_SurfaceOfLinearExtrusion(C,D);
return IS; return IS;
} }
@ -803,9 +802,8 @@ static Standard_IStream& operator>>(Standard_IStream& IS,
{ {
gp_Pnt P(0.,0.,0.); gp_Pnt P(0.,0.,0.);
gp_Dir D(1.,0.,0.); gp_Dir D(1.,0.,0.);
Handle(Geom_Curve) C;
IS >> P >> D; 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)); S = new Geom_SurfaceOfRevolution(C,gp_Ax1(P,D));
return IS; return IS;
} }
@ -906,8 +904,7 @@ static Standard_IStream& operator>>(Standard_IStream& IS,
GeomTools::GetReal(IS, U2); GeomTools::GetReal(IS, U2);
GeomTools::GetReal(IS, V1); GeomTools::GetReal(IS, V1);
GeomTools::GetReal(IS, V2); GeomTools::GetReal(IS, V2);
Handle(Geom_Surface) BS; Handle(Geom_Surface) BS = GeomTools_SurfaceSet::ReadSurface(IS);
GeomTools_SurfaceSet::ReadSurface(IS,BS);
S = new Geom_RectangularTrimmedSurface(BS,U1,U2,V1,V2); S = new Geom_RectangularTrimmedSurface(BS,U1,U2,V1,V2);
return IS; return IS;
} }
@ -922,8 +919,7 @@ static Standard_IStream& operator>>(Standard_IStream& IS,
{ {
Standard_Real O=0.; Standard_Real O=0.;
GeomTools::GetReal(IS, O); GeomTools::GetReal(IS, O);
Handle(Geom_Surface) BS; Handle(Geom_Surface) BS = GeomTools_SurfaceSet::ReadSurface(IS);
GeomTools_SurfaceSet::ReadSurface(IS,BS);
S = new Geom_OffsetSurface(BS,O,Standard_True); S = new Geom_OffsetSurface(BS,O,Standard_True);
return IS; return IS;
} }
@ -934,11 +930,11 @@ static Standard_IStream& operator>>(Standard_IStream& IS,
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_IStream& GeomTools_SurfaceSet::ReadSurface(Standard_IStream& IS, Handle(Geom_Surface) GeomTools_SurfaceSet::ReadSurface(Standard_IStream& IS)
Handle(Geom_Surface)& S)
{ {
Standard_Integer stype; Standard_Integer stype;
Handle(Geom_Surface) S;
try { try {
OCC_CATCH_SIGNALS OCC_CATCH_SIGNALS
IS >> stype; IS >> stype;
@ -1047,9 +1043,8 @@ Standard_IStream& GeomTools_SurfaceSet::ReadSurface(Standard_IStream& IS,
cout <<"EXCEPTION in GeomTools_SurfaceSet::ReadSurface(..)!!!" << endl; cout <<"EXCEPTION in GeomTools_SurfaceSet::ReadSurface(..)!!!" << endl;
cout << anExc << endl; cout << anExc << endl;
#endif #endif
S = NULL;
} }
return IS; return S;
} }
//======================================================================= //=======================================================================
@ -1066,14 +1061,13 @@ void GeomTools_SurfaceSet::Read(Standard_IStream& IS)
return; return;
} }
Handle(Geom_Surface) S;
Standard_Integer i, nbsurf; Standard_Integer i, nbsurf;
IS >> nbsurf; IS >> nbsurf;
//OCC19559 //OCC19559
Handle(Message_ProgressIndicator) progress = GetProgress(); Handle(Message_ProgressIndicator) progress = GetProgress();
Message_ProgressSentry PS(progress, "Surfaces", 0, nbsurf, 1); Message_ProgressSentry PS(progress, "Surfaces", 0, nbsurf, 1);
for (i = 1; i <= nbsurf && PS.More(); i++, PS.Next()) { 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); myMap.Add(S);
} }
} }

View File

@ -71,9 +71,9 @@ public:
Standard_EXPORT static void PrintSurface (const Handle(Geom_Surface)& S, Standard_OStream& OS, const Standard_Boolean compact = Standard_False); 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 //! 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). //! 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); Standard_EXPORT void SetProgress (const Handle(Message_ProgressIndicator)& PR);

View File

@ -100,10 +100,13 @@ static Handle(MoniTool_Profile) thealiases;
{ {
TCollection_AsciiString str; TCollection_AsciiString str;
if (thealiases.IsNull()) return str; if (thealiases.IsNull()) return str;
Handle(TCollection_HAsciiString) val; Handle(Standard_Transient) aVal;
if (!thealiases->Value(command,val)) return str; if (!thealiases->Value(command,aVal)) return str;
str.AssignCat (val->ToCString()); Handle(TCollection_HAsciiString) val =
return str; Handle(TCollection_HAsciiString)::DownCast (aVal);
if (!val.IsNull())
str.AssignCat (val->ToCString());
return str;
} }

View File

@ -180,14 +180,16 @@ Standard_Boolean IGESData_BasicEditor::SetUnitName (const Standard_CString name)
// Traites actuellement (necessaires) : // Traites actuellement (necessaires) :
// 1(Annotation), aussi 4(pour maillage). 5(ParamUV) traite par AutoCorrect // 1(Annotation), aussi 4(pour maillage). 5(ParamUV) traite par AutoCorrect
Handle(IGESData_GeneralModule) gmod;
Standard_Integer CN; Standard_Integer CN;
Standard_Integer i; // svv Jan11 2000 : porting on DEC Standard_Integer i; // svv Jan11 2000 : porting on DEC
for (i = 1; i <= nb; i ++) { for (i = 1; i <= nb; i ++) {
// Subordinate (sur directs en propre seulement) // Subordinate (sur directs en propre seulement)
Handle(IGESData_IGESEntity) ent = themodel->Entity(i); Handle(IGESData_IGESEntity) ent = themodel->Entity(i);
Standard_Integer igt = ent->TypeNumber(); 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; Interface_EntityIterator sh;
gmod->OwnSharedCase (CN,ent,sh); gmod->OwnSharedCase (CN,ent,sh);
for (sh.Start(); sh.More(); sh.Next()) { for (sh.Start(); sh.More(); sh.Next()) {
@ -301,14 +303,16 @@ Standard_Boolean IGESData_BasicEditor::SetUnitName (const Standard_CString name)
} }
// Corrections specifiques // Corrections specifiques
Handle(IGESData_GeneralModule) gmod;
Handle(IGESData_SpecificModule) smod;
Standard_Integer CN; Standard_Integer CN;
Handle(Interface_GeneralModule) gmodule;
if (theglib.Select (ent,gmod,CN)) { if (theglib.Select (ent,gmodule,CN)) {
Handle(IGESData_GeneralModule) gmod =
Handle(IGESData_GeneralModule)::DownCast (gmodule);
IGESData_DirChecker DC = gmod->DirChecker(CN,ent); IGESData_DirChecker DC = gmod->DirChecker(CN,ent);
done |= DC.Correct(ent); done |= DC.Correct(ent);
} }
Handle(IGESData_SpecificModule) smod;
if (theslib.Select (ent,smod,CN)) done |= smod->OwnCorrect (CN,ent); if (theslib.Select (ent,smod,CN)) done |= smod->OwnCorrect (CN,ent);
return done; return done;

View File

@ -43,7 +43,11 @@ IGESData_FreeFormatEntity::IGESData_FreeFormatEntity () { }
Standard_Boolean IGESData_FreeFormatEntity::ParamData Standard_Boolean IGESData_FreeFormatEntity::ParamData
(const Standard_Integer num, Interface_ParamType& ptype, (const Standard_Integer num, Interface_ParamType& ptype,
Handle(IGESData_IGESEntity)& ent, Handle(TCollection_HAsciiString)& val) const 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 Interface_ParamType IGESData_FreeFormatEntity::ParamType

View File

@ -334,11 +334,16 @@ IGESData_IGESReaderTool::IGESData_IGESReaderTool
IGESData_ParamReader& PR) const IGESData_ParamReader& PR) const
{ {
Handle(Interface_Check) ach = new Interface_Check;; 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 // 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); module->ReadOwnParams(CN,ent,IR,PR);
}
else if (ent.IsNull()) { else if (ent.IsNull()) {
// Pas trouve dutout // Pas trouve dutout
// Sending of message : Null Entity // Sending of message : Null Entity

View File

@ -716,6 +716,7 @@ Standard_Boolean IGESData_ParamReader::ReadEntity (const Handle(IGESData_IGESRea
Handle(IGESData_IGESEntity)& val, Handle(IGESData_IGESEntity)& val,
const Standard_Boolean canbenul) const Standard_Boolean canbenul)
{ {
aStatus = IGESData_EntityError;
if (!PrepareRead(PC,Standard_False)) return Standard_False; if (!PrepareRead(PC,Standard_False)) return Standard_False;
Standard_Integer nval; Standard_Integer nval;
// if (!ReadingEntityNumber(theindex,amsg,nval)) return Standard_False; // if (!ReadingEntityNumber(theindex,amsg,nval)) return Standard_False;
@ -730,6 +731,8 @@ Standard_Boolean IGESData_ParamReader::ReadEntity (const Handle(IGESData_IGESRea
thelast = Standard_True; thelast = Standard_True;
} }
else
aStatus = IGESData_EntityOK;
return canbenul; return canbenul;
} }
else val = GetCasted(IGESData_IGESEntity,IR->BoundEntity(nval)); else val = GetCasted(IGESData_IGESEntity,IR->BoundEntity(nval));
@ -745,6 +748,8 @@ Standard_Boolean IGESData_ParamReader::ReadEntity (const Handle(IGESData_IGESRea
//SendFail (amsg); //SendFail (amsg);
thelast = Standard_True; thelast = Standard_True;
} }
else
aStatus = IGESData_EntityOK;
return canbenul; return canbenul;
} }
} }
@ -1344,6 +1349,7 @@ Standard_Boolean IGESData_ParamReader::ReadingReal
} else if (FP.ParamType() == Interface_ParamVoid) { } else if (FP.ParamType() == Interface_ParamVoid) {
val = 0.0; // DEFAULT val = 0.0; // DEFAULT
} else { } else {
val = 0.0; // DEFAULT
char ssem[100]; char ssem[100];
sprintf(ssem,": not given as Real, rank %d",num); sprintf(ssem,": not given as Real, rank %d",num);
AddFail (mess,ssem,": not given as Real, rank %d"); AddFail (mess,ssem,": not given as Real, rank %d");

View File

@ -224,6 +224,16 @@ public:
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); 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 //! Works as ReadEntity without Type, but in addition checks the
//! Type of the Entity, which must be "kind of" a given <type> //! Type of the Entity, which must be "kind of" a given <type>
//! Then, gives the same fail cases as ReadEntity without Type, //! Then, gives the same fail cases as ReadEntity without Type,
@ -231,6 +241,16 @@ public:
//! (in such a case, returns False and givel <val> = Null) //! (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); 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); 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 //! Reads a list of Integer values, defined by PC (with a count of

View File

@ -104,9 +104,11 @@ void IGESData_ToolLocation::ResetDependences (const Handle(IGESData_IGESEntity)
void IGESData_ToolLocation::SetOwnAsDependent (const Handle(IGESData_IGESEntity)& ent) void IGESData_ToolLocation::SetOwnAsDependent (const Handle(IGESData_IGESEntity)& ent)
{ {
Handle(IGESData_GeneralModule) module;
Standard_Integer CN; 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; Interface_EntityIterator list;
module->OwnSharedCase(CN,ent,list); module->OwnSharedCase(CN,ent,list);
// Remarque : en toute rigueur, il faudrait ignorer les entites referencees // Remarque : en toute rigueur, il faudrait ignorer les entites referencees

View File

@ -169,7 +169,7 @@ void IGESDraw_ToolViewsVisible::OwnRenew
up = another->NbDisplayedEntities(); up = another->NbDisplayedEntities();
if (up == 0) return; if (up == 0) return;
Handle(IGESData_HArray1OfIGESEntity) tempDisplayEntities; Handle(IGESData_HArray1OfIGESEntity) tempDisplayEntities;
Handle(IGESData_IGESEntity) anew; Handle(Standard_Transient) anew;
for (I = 1; I <= up; I++) { for (I = 1; I <= up; I++) {
if (TC.Search (another->DisplayedEntity(I),anew)) newdisp.GetOneItem(anew); if (TC.Search (another->DisplayedEntity(I),anew)) newdisp.GetOneItem(anew);
} }

View File

@ -272,7 +272,7 @@ void IGESDraw_ToolViewsVisibleWithAttr::OwnRenew
up = another->NbDisplayedEntities(); up = another->NbDisplayedEntities();
if (up == 0) return; if (up == 0) return;
Handle(IGESData_HArray1OfIGESEntity) tempDisplayEntities; Handle(IGESData_HArray1OfIGESEntity) tempDisplayEntities;
Handle(IGESData_IGESEntity) anew; Handle(Standard_Transient) anew;
for (I = 1; I <= up; I++) { for (I = 1; I <= up; I++) {
if (TC.Search (another->DisplayedEntity(I),anew)) newdisp.GetOneItem(anew); if (TC.Search (another->DisplayedEntity(I),anew)) newdisp.GetOneItem(anew);
} }

View File

@ -109,11 +109,11 @@ void IGESGeom_ToolBoundedSurface::ReadOwnParams(const Handle(IGESGeom_BoundedSur
if (!tempBounds.IsNull()){ if (!tempBounds.IsNull()){
for ( i = 1; i <= num; i++ ) 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(), Msg168, tempEnt); //szv#4:S4163:12Mar99 moved in if
//st = PR.ReadEntity(IR, PR.Current(), "Boundary Entities", tempEnt); //st = PR.ReadEntity(IR, PR.Current(), "Boundary Entities", tempEnt);
if (PR.ReadEntity(IR, PR.Current(), aStatus, tempEnt)) if (PR.ReadEntity(IR, PR.Current(), aStatus, tempEnt))
tempBounds->SetValue(i, tempEnt); tempBounds->SetValue(i, Handle(IGESGeom_Boundary)::DownCast (tempEnt));
else{ else{
Message_Msg Msg168("XTSEP_168"); Message_Msg Msg168("XTSEP_168");
switch(aStatus) { switch(aStatus) {

View File

@ -165,11 +165,14 @@ IGESSelect_RebuildDrawings::IGESSelect_RebuildDrawings ()
// si View() transfere, mettre a jour ... // si View() transfere, mettre a jour ...
for (setl.Start(); setl.More(); setl.Next()) { for (setl.Start(); setl.More(); setl.Next()) {
DeclareAndCast(IGESData_IGESEntity,ent,setl.Value()); DeclareAndCast(IGESData_IGESEntity,ent,setl.Value());
Handle(IGESData_ViewKindEntity) vieworig, viewnew; Handle(IGESData_ViewKindEntity) vieworig = ent->View();
vieworig = ent->View();
if (vieworig.IsNull()) continue; if (vieworig.IsNull()) continue;
if (!TC.Search(vieworig,viewnew)) continue; Handle(Standard_Transient) aView;
ent->InitView(viewnew); if (!TC.Search(vieworig,aView)) continue;
Handle(IGESData_ViewKindEntity) viewnew =
Handle(IGESData_ViewKindEntity)::DownCast (aView);
if (! viewnew.IsNull())
ent->InitView(viewnew);
} }
} }

View File

@ -56,7 +56,7 @@ void IGESSolid_ToolManifoldSolid::ReadOwnParams
Standard_Boolean abool, shellFlag; //szv#4:S4163:12Mar99 `st` moved down Standard_Boolean abool, shellFlag; //szv#4:S4163:12Mar99 `st` moved down
Standard_Integer nbshells, i; Standard_Integer nbshells, i;
Handle(TColStd_HArray1OfInteger) voidShellFlags; Handle(TColStd_HArray1OfInteger) voidShellFlags;
Handle(IGESSolid_Shell) shell; Handle(IGESData_IGESEntity) shell;
Handle(IGESSolid_Shell) ashell; Handle(IGESSolid_Shell) ashell;
Handle(IGESSolid_HArray1OfShell) voidShells; Handle(IGESSolid_HArray1OfShell) voidShells;
IGESData_Status aStatus; IGESData_Status aStatus;
@ -132,7 +132,7 @@ void IGESSolid_ToolManifoldSolid::ReadOwnParams
} }
} }
DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent); 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 void IGESSolid_ToolManifoldSolid::WriteOwnParams

View File

@ -44,7 +44,7 @@ void IGESSolid_ToolToroidalSurface::ReadOwnParams
Handle(IGESGeom_Point) tempCenter; Handle(IGESGeom_Point) tempCenter;
Standard_Real majRad, minRad; Standard_Real majRad, minRad;
Handle(IGESGeom_Direction) tempAxis; // default Unparametrised 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 //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed
PR.ReadEntity(IR, PR.Current(), "Center point", PR.ReadEntity(IR, PR.Current(), "Center point",
@ -61,7 +61,7 @@ void IGESSolid_ToolToroidalSurface::ReadOwnParams
PR.ReadEntity(IR, PR.Current(), "Reference direction", tempRefdir); //szv#4:S4163:12Mar99 `st=` not needed PR.ReadEntity(IR, PR.Current(), "Reference direction", tempRefdir); //szv#4:S4163:12Mar99 `st=` not needed
DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent); 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 void IGESSolid_ToolToroidalSurface::WriteOwnParams

View File

@ -143,7 +143,7 @@ static
const Handle(IntTools_Context)& ); const Handle(IntTools_Context)& );
static static
Standard_Boolean IsCurveValid(Handle(Geom2d_Curve)& thePCurve); Standard_Boolean IsCurveValid(const Handle(Geom2d_Curve)& thePCurve);
static static
Standard_Boolean ApproxWithPCurves(const gp_Cylinder& theCyl, Standard_Boolean ApproxWithPCurves(const gp_Cylinder& theCyl,
@ -2622,7 +2622,7 @@ Standard_Boolean ParameterOutOfBoundary(const Standard_Real theParameter,
//function : IsCurveValid //function : IsCurveValid
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_Boolean IsCurveValid(Handle(Geom2d_Curve)& thePCurve) Standard_Boolean IsCurveValid (const Handle(Geom2d_Curve)& thePCurve)
{ {
if(thePCurve.IsNull()) if(thePCurve.IsNull())
return Standard_False; return Standard_False;

View File

@ -268,9 +268,17 @@ Interface_CopyTool::Interface_CopyTool
Handle(Standard_Transient) res; Handle(Standard_Transient) res;
if (!themap->Search(ent,res)) continue; // entite pas transferee if (!themap->Search(ent,res)) continue; // entite pas transferee
// Reconduction des references "Imply". Attention, ne pas copier si non chargee // Reconduction des references "Imply". Attention, ne pas copier si non chargee
Handle(Interface_ReportEntity) rep; Handle(Standard_Transient) aRep;
if (!therep->Search(ent,rep)) Implied (ent,res); if (!therep->Search(ent,aRep))
else if (!rep->HasNewContent()) Implied (ent,res); {
Implied (ent,res);
}
else
{
Handle(Interface_ReportEntity) rep = Handle(Interface_ReportEntity)::DownCast (aRep);
if (! rep.IsNull() && ! rep->HasNewContent())
Implied (ent,res);
}
} }
} }
@ -302,7 +310,7 @@ Interface_CopyTool::Interface_CopyTool
Handle(Standard_Transient) res; Handle(Standard_Transient) res;
if (!themap->Search(ent,res)) continue; if (!themap->Search(ent,res)) continue;
if (withreports) { if (withreports) {
Handle(Interface_ReportEntity) rep; Handle(Standard_Transient) rep;
if (therep->Search(ent,rep)) res = rep; if (therep->Search(ent,rep)) res = rep;
} }
iter.GetOneItem(res); iter.GetOneItem(res);
@ -321,7 +329,7 @@ Interface_CopyTool::Interface_CopyTool
Handle(Standard_Transient) res; Handle(Standard_Transient) res;
if (!themap->Search(ent,res)) continue; if (!themap->Search(ent,res)) continue;
if (withreports) { if (withreports) {
Handle(Interface_ReportEntity) rep; Handle(Standard_Transient) rep;
if (therep->Search(ent,rep)) res = rep; if (therep->Search(ent,rep)) res = rep;
} }
iter.GetOneItem(res); iter.GetOneItem(res);

View File

@ -280,10 +280,14 @@ static Standard_Boolean IsCurrent (const Standard_CString name)
Handle(TCollection_HAsciiString) sw, val; Handle(TCollection_HAsciiString) sw, val;
if (!thecurconf->GetItem (name,sw,Standard_True)) sw.Nullify(); if (!thecurconf->GetItem (name,sw,Standard_True)) sw.Nullify();
Handle(Standard_Transient) aVal;
if (!sw.IsNull()) { 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 // On applique
if (!val.IsNull()) tv->SetHStringValue (val); if (!val.IsNull()) tv->SetHStringValue (val);

View File

@ -2401,16 +2401,6 @@ void OpenGl_Context::ReleaseResource (const TCollection_AsciiString& theKey,
} }
} }
// =======================================================================
// function : DelayedRelease
// purpose :
// =======================================================================
void OpenGl_Context::DelayedRelease (Handle(OpenGl_Resource)& theResource)
{
myUnusedResources->Prepend (theResource);
theResource.Nullify();
}
// ======================================================================= // =======================================================================
// function : ReleaseDelayed // function : ReleaseDelayed
// purpose : // purpose :

View File

@ -401,7 +401,12 @@ public:
//! Append resource to queue for delayed clean up. //! Append resource to queue for delayed clean up.
//! Resources in this queue will be released at next redraw call. //! 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. //! Clean up the delayed release queue.
Standard_EXPORT void ReleaseDelayed(); Standard_EXPORT void ReleaseDelayed();

View File

@ -1589,8 +1589,9 @@ Standard_Boolean OpenGl_View::initRaytraceResources (const Handle(OpenGl_Context
// function : nullifyResource // function : nullifyResource
// purpose : // purpose :
// ======================================================================= // =======================================================================
template <class T>
inline void nullifyResource (const Handle(OpenGl_Context)& theGlContext, inline void nullifyResource (const Handle(OpenGl_Context)& theGlContext,
Handle(OpenGl_Resource)& theResource) Handle(T)& theResource)
{ {
if (!theResource.IsNull()) if (!theResource.IsNull())
{ {

View File

@ -352,12 +352,13 @@ void PrsMgr_PresentationManager::displayImmediate (const Handle(V3d_Viewer)& the
if (aPrs.IsNull()) if (aPrs.IsNull())
continue; continue;
Handle(Prs3d_Presentation) aViewDepPrs; Handle(Graphic3d_Structure) aViewDepPrs;
Handle(Prs3d_PresentationShadow) aShadowPrs = Handle(Prs3d_PresentationShadow)::DownCast (aPrs); Handle(Prs3d_PresentationShadow) aShadowPrs = Handle(Prs3d_PresentationShadow)::DownCast (aPrs);
if (!aShadowPrs.IsNull() && aView->IsComputed (aShadowPrs->ParentId(), aViewDepPrs)) if (!aShadowPrs.IsNull() && aView->IsComputed (aShadowPrs->ParentId(), aViewDepPrs))
{ {
aShadowPrs.Nullify(); aShadowPrs.Nullify();
aShadowPrs = new Prs3d_PresentationShadow (myStructureManager, aViewDepPrs); aShadowPrs = new Prs3d_PresentationShadow (myStructureManager,
Handle(Prs3d_Presentation)::DownCast (aViewDepPrs));
aShadowPrs->SetZLayer (aViewDepPrs->CStructure()->ZLayer()); aShadowPrs->SetZLayer (aViewDepPrs->CStructure()->ZLayer());
aShadowPrs->SetClipPlanes (aViewDepPrs->GetClipPlanes()); aShadowPrs->SetClipPlanes (aViewDepPrs->GetClipPlanes());
aShadowPrs->CStructure()->IsForHighlight = 1; aShadowPrs->CStructure()->IsForHighlight = 1;

View File

@ -25,6 +25,7 @@
#include <Standard_DefineHandle.hxx> #include <Standard_DefineHandle.hxx>
#include <Standard_Transient.hxx> #include <Standard_Transient.hxx>
#include <TCollection_AsciiString.hxx> #include <TCollection_AsciiString.hxx>
#include <Geom_Circle.hxx>
#include <Geom_Line.hxx> #include <Geom_Line.hxx>
#include <Geom_BSplineCurve.hxx> #include <Geom_BSplineCurve.hxx>
#include <Geom_Surface.hxx> #include <Geom_Surface.hxx>
@ -50,8 +51,6 @@ inline void func (const Handle(gp_Pnt)&) {}
inline void func (const Handle(gp_XYZ)&) {} inline void func (const Handle(gp_XYZ)&) {}
inline void func (const Handle(gp_Trsf)&) {} inline void func (const Handle(gp_Trsf)&) {}
inline void gunc (Handle(Geom_Curve)&) {}
static Standard_Integer QAHandleOps (Draw_Interpretor& theDI, static Standard_Integer QAHandleOps (Draw_Interpretor& theDI,
Standard_Integer /*theArgNb*/, Standard_Integer /*theArgNb*/,
const char** /*theArgVec*/) const char** /*theArgVec*/)
@ -117,10 +116,7 @@ static Standard_Integer QAHandleOps (Draw_Interpretor& theDI,
func (cLine); func (cLine);
#endif #endif
// passing handle as non-const reference to base type const Handle(Geom_Curve)& aCurve2 = aLine; // cast to base const ref
// currently allowed for compatibility
gunc (aLine);
Handle(Geom_Curve)& aCurve2 = aLine; // cast to base non-const ref
Handle(Geom_Line) qLine = cpLine; // constructor from const pointer -- could be made explicit... Handle(Geom_Line) qLine = cpLine; // constructor from const pointer -- could be made explicit...

View File

@ -2754,7 +2754,9 @@ static Handle(StepDimTol_HArray1OfDatumSystemOrReference) WriteDatumSystem(const
Handle(StepDimTol_HArray1OfDatumReferenceModifier) aModifiers; Handle(StepDimTol_HArray1OfDatumReferenceModifier) aModifiers;
if (aDatumSeqPos.Length() == 1) { if (aDatumSeqPos.Length() == 1) {
// Datum entity // 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); aDatumRef.SetValue(aFirstDatum);
// Modifiers // Modifiers
XCAFDimTolObjects_DatumModifiersSequence aSimpleModifiers = aDatumSeqPos.Value(1)->GetModifiers(); XCAFDimTolObjects_DatumModifiersSequence aSimpleModifiers = aDatumSeqPos.Value(1)->GetModifiers();
@ -2776,7 +2778,9 @@ static Handle(StepDimTol_HArray1OfDatumSystemOrReference) WriteDatumSystem(const
for (Standard_Integer j = 1; j <= aDatumSeqPos.Length(); j++) { for (Standard_Integer j = 1; j <= aDatumSeqPos.Length(); j++) {
// Datum entity // Datum entity
Handle(StepDimTol_Datum) aDatum; 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; StepDimTol_DatumOrCommonDatum anElemDatumRef;
anElemDatumRef.SetValue(aDatum); anElemDatumRef.SetValue(aDatum);
if (aFirstDatum.IsNull()) if (aFirstDatum.IsNull())
@ -3497,9 +3501,10 @@ Standard_Boolean STEPCAFControl_Writer::WriteDGTsAP242 (const Handle(XSControl_W
TCollection_AsciiString aDatumTargetId = TCollection_AsciiString(anObject->GetDatumTargetNumber()); TCollection_AsciiString aDatumTargetId = TCollection_AsciiString(anObject->GetDatumTargetNumber());
if (!aNameIdMap.Add(aDatumName.Cat(aDatumTargetId))) if (!aNameIdMap.Add(aDatumName.Cat(aDatumTargetId)))
continue; continue;
Handle(StepDimTol_Datum) aWrittenDatum; Handle(Standard_Transient) aWrittenDatum;
Standard_Boolean isFirstDT = !aDatumMap.Find(aDatumName, 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 // Add created Datum into Map
aDatumMap.Bind(aDatumName, aDatum); aDatumMap.Bind(aDatumName, aDatum);
} }

View File

@ -198,7 +198,7 @@ Standard_Boolean Select3D_SensitiveGroup::Matches (SelectBasics_SelectingVolumeM
for (Select3D_EntitySequenceIter anIt (myEntities); anIt.More(); anIt.Next()) for (Select3D_EntitySequenceIter anIt (myEntities); anIt.More(); anIt.Next())
{ {
SelectBasics_PickResult aMatchResult; SelectBasics_PickResult aMatchResult;
Handle(SelectBasics_SensitiveEntity)& aChild = anIt.ChangeValue(); Handle(Select3D_SensitiveEntity)& aChild = anIt.ChangeValue();
if (!aChild->Matches (theMgr, aMatchResult)) if (!aChild->Matches (theMgr, aMatchResult))
{ {
aMatchResult = SelectBasics_PickResult (RealLast(), RealLast()); aMatchResult = SelectBasics_PickResult (RealLast(), RealLast());

View File

@ -239,6 +239,7 @@ namespace opencascade {
//! Upcast to non-const reference to base type. //! Upcast to non-const reference to base type.
//! NB: this cast can be dangerous, but required for legacy code; see #26377 //! NB: this cast can be dangerous, but required for legacy code; see #26377
template <class T2> 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>& () operator handle<T2>& ()
{ {
// error "type is not a member of enable_if" will be generated if T2 is not sub-type of T // error "type is not a member of enable_if" will be generated if T2 is not sub-type of T

View File

@ -49,7 +49,9 @@ public:
template <class Type> template <class Type>
StdObjMgt_ReadData& operator >> (Handle(Type)& theTarget) StdObjMgt_ReadData& operator >> (Handle(Type)& theTarget)
{ {
ReadReference (theTarget); Handle(StdObjMgt_Persistent) aTarget = theTarget;
ReadReference (aTarget);
theTarget = Handle(Type)::DownCast (aTarget);
return *this; return *this;
} }

View File

@ -515,7 +515,8 @@ Standard_Integer StepData_StepReaderData::ReadSub(const Standard_Integer numsub,
Handle(StepData_SelectNamed) sn = new StepData_SelectNamed; Handle(StepData_SelectNamed) sn = new StepData_SelectNamed;
val = sn; val = sn;
sn->SetName (rectyp.ToCString()); 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; else return 0;
} }
@ -686,7 +687,11 @@ Standard_Boolean StepData_StepReaderData::ReadMember(const Standard_Integer num,
{ {
Handle(Standard_Transient) v = val; Handle(Standard_Transient) v = val;
Handle(StepData_PDescr) nuldescr; 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); Standard_Boolean res = ReadAny (num,nump,mess,ach,nuldescr,v);
if (v == val) return res; if (v == val) return res;
// changement -> refus // changement -> refus
@ -886,9 +891,11 @@ Standard_Boolean StepData_StepReaderData::ReadAny(const Standard_Integer num,
Handle(TColStd_HSequenceOfReal) aSeq = new TColStd_HSequenceOfReal; Handle(TColStd_HSequenceOfReal) aSeq = new TColStd_HSequenceOfReal;
for(Standard_Integer i=1; i<=nbp2; i++) { for(Standard_Integer i=1; i<=nbp2; i++) {
if( Param(numsub2,i).ParamType() != Interface_ParamReal ) continue; if( Param(numsub2,i).ParamType() != Interface_ParamReal ) continue;
Handle(StepData_SelectReal) sm1 = new StepData_SelectReal; Handle(Standard_Transient) asr = new StepData_SelectReal;
if( !ReadAny(numsub2,i,mess,ach,descr,sm1) ) continue; if( !ReadAny(numsub2,i,mess,ach,descr,asr) ) continue;
aSeq->Append(sm1->Real()); 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()); Handle(TColStd_HArray1OfReal) anArr = new TColStd_HArray1OfReal(1,aSeq->Length());
for(Standard_Integer nr=1; nr<=aSeq->Length(); nr++) { for(Standard_Integer nr=1; nr<=aSeq->Length(); nr++) {

View File

@ -175,6 +175,14 @@ public:
//! some members as Entity, some other not) //! 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; 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, //! reads parameter <nump> of record <num> into a Field,
//! controlled by a Parameter Descriptor (PDescr), which controls //! controlled by a Parameter Descriptor (PDescr), which controls
//! its allowed type(s) and value //! its allowed type(s) and value
@ -230,6 +238,14 @@ public:
//! is an Entity but is not Kind of required type //! 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; 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 //! Same as above, but a SelectType checks Type Matching, and
//! records the read Entity (see method Value from SelectType) //! 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; 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;

View File

@ -211,9 +211,14 @@ Standard_Boolean StepData_StepReaderTool::AnalyseRecord
Handle(Interface_Check)& acheck) Handle(Interface_Check)& acheck)
{ {
DeclareAndCast(StepData_StepReaderData,stepdat,Data()); DeclareAndCast(StepData_StepReaderData,stepdat,Data());
Handle(StepData_ReadWriteModule) module; Standard_Integer CN; Handle(Interface_ReaderModule) imodule;
if (therlib.Select(anent,module,CN)) 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); module->ReadStep(CN,stepdat,num,acheck,anent);
}
else { else {
// Pas trouve : tenter UndefinedEntity de StepData // Pas trouve : tenter UndefinedEntity de StepData
DeclareAndCast(StepData_UndefinedEntity,und,anent); DeclareAndCast(StepData_UndefinedEntity,und,anent);

View File

@ -185,6 +185,14 @@ public:
//! this method. //! this method.
Standard_EXPORT Standard_Boolean FindAttribute (const Standard_GUID& anID, Handle(TDF_Attribute)& anAttribute) const; 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 //! Adds an Attribute <other> to the label of
//! <me>.Raises if there is already one of the same //! <me>.Raises if there is already one of the same
//! GUID fhan <other>. //! GUID fhan <other>.

View File

@ -150,6 +150,14 @@ public:
//! A removed attribute cannot be found. //! A removed attribute cannot be found.
Standard_EXPORT Standard_Boolean FindAttribute (const Standard_GUID& anID, Handle(TDF_Attribute)& anAttribute) const; 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 //! Finds an attribute of the current label, according
//! to <anID> and <aTransaction>. This attribute //! to <anID> and <aTransaction>. This attribute
//! has/had to be a valid one for the given //! has/had to be a valid one for the given

View File

@ -106,6 +106,14 @@ public:
//! explanation about the method behavior) //! explanation about the method behavior)
Standard_EXPORT Standard_Boolean HasRelocation (const Handle(TDF_Attribute)& aSourceAttribute, Handle(TDF_Attribute)& aTargetAttribute) const; 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 //! Sets the relocation value of <aSourceTransient> to
//! <aTargetTransient>. //! <aTargetTransient>.
Standard_EXPORT void SetTransientRelocation (const Handle(Standard_Transient)& aSourceTransient, const Handle(Standard_Transient)& aTargetTransient); Standard_EXPORT void SetTransientRelocation (const Handle(Standard_Transient)& aSourceTransient, const Handle(Standard_Transient)& aTargetTransient);

View File

@ -881,9 +881,9 @@ TNaming_Iterator::TNaming_Iterator(const TDF_Label& Lab,
const Standard_Integer Trans) const Standard_Integer Trans)
:myTrans(Trans) :myTrans(Trans)
{ {
Handle(TNaming_NamedShape) Att; Handle(TDF_Attribute) Att;
if (Lab.FindAttribute(TNaming_NamedShape::GetID(),Trans,Att)) { if (Lab.FindAttribute(TNaming_NamedShape::GetID(),Trans,Att)) {
myNode = Att->myNode; myNode = Handle(TNaming_NamedShape)::DownCast (Att)->myNode;
} }
else { else {
myNode = 0L; myNode = 0L;

View File

@ -1762,7 +1762,9 @@ void TPrsStd_ConstraintTools::ComputeOffset (const Handle(TDataXtd_Constraint)&
Standard_Boolean is_planar (aConst->IsPlanar()); Standard_Boolean is_planar (aConst->IsPlanar());
Handle(Geom_Plane) aplane; Handle(Geom_Plane) aplane;
if (is_planar) { if (is_planar) {
GetGeom (aConst,aplane); Handle(Geom_Geometry) ageom;
GetGeom (aConst,ageom);
aplane = Handle(Geom_Plane)::DownCast (ageom);
if (aplane.IsNull()) { if (aplane.IsNull()) {
#ifdef OCCT_DEBUG #ifdef OCCT_DEBUG
cout << "TPrsStd_ConstraintTools::ComputeOffset: null plane" << endl; cout << "TPrsStd_ConstraintTools::ComputeOffset: null plane" << endl;
@ -2090,8 +2092,9 @@ void TPrsStd_ConstraintTools::ComputeCoincident(const Handle(TDataXtd_Constraint
} }
TopoDS_Shape shape1,shape2 ; TopoDS_Shape shape1,shape2 ;
Handle(Geom_Plane) aplane; Handle(Geom_Geometry) ageom;
GetShapesAndGeom(aConst,shape1,shape2,aplane); GetShapesAndGeom(aConst,shape1,shape2,ageom);
Handle(Geom_Plane) aplane = Handle(Geom_Plane)::DownCast (ageom);
if (shape1.IsNull() || shape2.IsNull()) { if (shape1.IsNull() || shape2.IsNull()) {
#ifdef OCCT_DEBUG #ifdef OCCT_DEBUG
cout << "TPrsStd_ConstraintTools::ComputeCoincident: nul shape" << endl; cout << "TPrsStd_ConstraintTools::ComputeCoincident: nul shape" << endl;

View File

@ -240,6 +240,14 @@ public:
//! immediately used, well initialised //! immediately used, well initialised
Standard_EXPORT Standard_Boolean FindTypedTransient (const Handle(Transfer_Finder)& start, const Handle(Standard_Type)& atype, Handle(Standard_Transient)& val) const; 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 //! Searches for a transient result recorded in a Binder, whatever
//! this Binder is recorded or not in <me> //! this Binder is recorded or not in <me>
//! //!
@ -249,6 +257,14 @@ public:
//! Apart from this, works as FindTypedTransient //! 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; 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 //! Returns the maximum possible value for Map Index
//! (no result can be bound with a value greater than it) //! (no result can be bound with a value greater than it)
Standard_EXPORT Standard_Integer NbMapped() const; Standard_EXPORT Standard_Integer NbMapped() const;

View File

@ -290,17 +290,33 @@ VrmlData_ErrorStatus VrmlData_IndexedFaceSet::Read(VrmlData_InBuffer& theBuffer)
// These four checks should be the last one to avoid their interference // These four checks should be the last one to avoid their interference
// with the other tokens (e.g., coordIndex) // with the other tokens (e.g., coordIndex)
else if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "texCoord")) else if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "texCoord"))
aStatus = ReadNode (theBuffer, myTxCoords, {
Handle(VrmlData_Node) aNode;
aStatus = ReadNode (theBuffer, aNode,
STANDARD_TYPE(VrmlData_TextureCoordinate)); STANDARD_TYPE(VrmlData_TextureCoordinate));
myTxCoords = Handle(VrmlData_TextureCoordinate)::DownCast (aNode);
}
else if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "color")) else if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "color"))
aStatus = ReadNode (theBuffer, myColors, {
Handle(VrmlData_Node) aNode;
aStatus = ReadNode (theBuffer, aNode,
STANDARD_TYPE(VrmlData_Color)); STANDARD_TYPE(VrmlData_Color));
myColors = Handle(VrmlData_Color)::DownCast (aNode);
}
else if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "coord")) else if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "coord"))
aStatus = ReadNode (theBuffer, myCoords, {
Handle(VrmlData_Node) aNode;
aStatus = ReadNode (theBuffer, aNode,
STANDARD_TYPE(VrmlData_Coordinate)); STANDARD_TYPE(VrmlData_Coordinate));
myCoords = Handle(VrmlData_Coordinate)::DownCast (aNode);
}
else if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "normal")) else if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "normal"))
aStatus = ReadNode (theBuffer, myNormals, {
Handle(VrmlData_Node) aNode;
aStatus = ReadNode (theBuffer, aNode,
STANDARD_TYPE(VrmlData_Normal)); STANDARD_TYPE(VrmlData_Normal));
myNormals = Handle(VrmlData_Normal)::DownCast (aNode);
}
if (!OK(aStatus)) if (!OK(aStatus))
break; break;
} }

View File

@ -144,11 +144,19 @@ VrmlData_ErrorStatus VrmlData_IndexedLineSet::Read
// These two checks should be the last one to avoid their interference // These two checks should be the last one to avoid their interference
// with the other tokens (e.g., coordIndex) // with the other tokens (e.g., coordIndex)
else if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "color")) else if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "color"))
aStatus = ReadNode (theBuffer, myColors, {
Handle(VrmlData_Node) aNode;
aStatus = ReadNode (theBuffer, aNode,
STANDARD_TYPE(VrmlData_Color)); STANDARD_TYPE(VrmlData_Color));
myColors = Handle(VrmlData_Color)::DownCast (aNode);
}
else if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "coord")) else if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "coord"))
aStatus = ReadNode (theBuffer, myCoords, {
Handle(VrmlData_Node) aNode;
aStatus = ReadNode (theBuffer, aNode,
STANDARD_TYPE(VrmlData_Coordinate)); STANDARD_TYPE(VrmlData_Coordinate));
myCoords = Handle(VrmlData_Coordinate)::DownCast (aNode);
}
else else
break; break;
if (!OK(aStatus)) if (!OK(aStatus))

View File

@ -370,13 +370,21 @@ VrmlData_ErrorStatus VrmlData_ShapeNode::Read (VrmlData_InBuffer& theBuffer)
VrmlData_ErrorStatus aStatus; VrmlData_ErrorStatus aStatus;
while (OK(aStatus, VrmlData_Scene::ReadLine(theBuffer))) { while (OK(aStatus, VrmlData_Scene::ReadLine(theBuffer))) {
if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "appearance")) if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "appearance"))
aStatus = ReadNode (theBuffer, myAppearance, {
Handle(VrmlData_Node) aNode;
aStatus = ReadNode (theBuffer, aNode,
STANDARD_TYPE(VrmlData_Appearance)); STANDARD_TYPE(VrmlData_Appearance));
myAppearance = Handle(VrmlData_Appearance)::DownCast (aNode);
}
else if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "geometry")) 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 // here we do not check for the Geometry type because unknown node types can
// occur (IndexedLineSet, etc.) // occur (IndexedLineSet, etc.)
// STANDARD_TYPE(VrmlData_Geometry)); // STANDARD_TYPE(VrmlData_Geometry));
}
else else
break; break;
@ -509,14 +517,26 @@ VrmlData_ErrorStatus VrmlData_Appearance::Read (VrmlData_InBuffer& theBuffer)
VrmlData_ErrorStatus aStatus; VrmlData_ErrorStatus aStatus;
while (OK(aStatus, VrmlData_Scene::ReadLine(theBuffer))) { while (OK(aStatus, VrmlData_Scene::ReadLine(theBuffer))) {
if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "material")) if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "material"))
aStatus = ReadNode (theBuffer, myMaterial, {
Handle(VrmlData_Node) aNode;
aStatus = ReadNode (theBuffer, aNode,
STANDARD_TYPE(VrmlData_Material)); STANDARD_TYPE(VrmlData_Material));
myMaterial = Handle(VrmlData_Material)::DownCast (aNode);
}
else if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "textureTransform")) else if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "textureTransform"))
aStatus = ReadNode (theBuffer, myTTransform {
Handle(VrmlData_Node) aNode;
aStatus = ReadNode (theBuffer, aNode
/*,STANDARD_TYPE(VrmlData_TextureTransform)*/); /*,STANDARD_TYPE(VrmlData_TextureTransform)*/);
myTTransform = Handle(VrmlData_TextureTransform)::DownCast (aNode);
}
else if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "texture")) else if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "texture"))
aStatus = ReadNode (theBuffer, myTexture, {
Handle(VrmlData_Node) aNode;
aStatus = ReadNode (theBuffer, aNode,
STANDARD_TYPE(VrmlData_Texture)); STANDARD_TYPE(VrmlData_Texture));
myTexture = Handle(VrmlData_Texture)::DownCast (aNode);
}
else else
break; break;

View File

@ -66,11 +66,14 @@ Handle(XmlMDF_ADriver) XmlDrivers_DocumentRetrievalDriver::ReadShapeSection(
const Handle(CDM_MessageDriver)& theMsgDriver) const Handle(CDM_MessageDriver)& theMsgDriver)
{ {
if (myDrivers.IsNull()) myDrivers = AttributeDrivers (theMsgDriver); if (myDrivers.IsNull()) myDrivers = AttributeDrivers (theMsgDriver);
Handle(XmlMNaming_NamedShapeDriver) aNamedShapeDriver; Handle(XmlMDF_ADriver) aDriver;
if (myDrivers -> GetDriver (STANDARD_TYPE(TNaming_NamedShape), if (myDrivers->GetDriver (STANDARD_TYPE(TNaming_NamedShape), aDriver))
aNamedShapeDriver)) {
Handle(XmlMNaming_NamedShapeDriver) aNamedShapeDriver =
Handle(XmlMNaming_NamedShapeDriver)::DownCast (aDriver);
aNamedShapeDriver -> ReadShapeSection (theElement); aNamedShapeDriver -> ReadShapeSection (theElement);
return aNamedShapeDriver; }
return aDriver;
} }
//======================================================================= //=======================================================================

View File

@ -53,10 +53,12 @@ Handle(XmlMDF_ADriverTable) XmlDrivers_DocumentStorageDriver::AttributeDrivers
Standard_Boolean XmlDrivers_DocumentStorageDriver::WriteShapeSection Standard_Boolean XmlDrivers_DocumentStorageDriver::WriteShapeSection
(XmlObjMgt_Element& theElement) (XmlObjMgt_Element& theElement)
{ {
Handle(XmlMNaming_NamedShapeDriver) aNamedShapeDriver;
Standard_Boolean isShape(Standard_False); Standard_Boolean isShape(Standard_False);
if (myDrivers -> GetDriver (STANDARD_TYPE(TNaming_NamedShape), Handle(XmlMDF_ADriver) aDriver;
aNamedShapeDriver)) { if (myDrivers->GetDriver (STANDARD_TYPE(TNaming_NamedShape), aDriver))
{
Handle(XmlMNaming_NamedShapeDriver) aNamedShapeDriver =
Handle(XmlMNaming_NamedShapeDriver)::DownCast (aDriver);
aNamedShapeDriver -> WriteShapeSection (theElement); aNamedShapeDriver -> WriteShapeSection (theElement);
isShape = Standard_True; isShape = Standard_True;
} }

View File

@ -48,8 +48,10 @@ void XmlMXCAFDoc::AddDrivers (const Handle(XmlMDF_ADriverTable)& aDriverTable,
aDriverTable -> AddDriver (new XmlMXCAFDoc_GraphNodeDriver (anMsgDrv)); aDriverTable -> AddDriver (new XmlMXCAFDoc_GraphNodeDriver (anMsgDrv));
//oan: changes for sharing locations map //oan: changes for sharing locations map
Handle(XmlMNaming_NamedShapeDriver) aNamedShapeDriver; Handle(XmlMDF_ADriver) aDriver;
aDriverTable->GetDriver(STANDARD_TYPE(TNaming_NamedShape), aNamedShapeDriver); aDriverTable->GetDriver(STANDARD_TYPE(TNaming_NamedShape), aDriver);
Handle(XmlMNaming_NamedShapeDriver) aNamedShapeDriver =
Handle(XmlMNaming_NamedShapeDriver)::DownCast (aDriver);
Handle(XmlMXCAFDoc_LocationDriver) aLocationDriver = new XmlMXCAFDoc_LocationDriver (anMsgDrv); Handle(XmlMXCAFDoc_LocationDriver) aLocationDriver = new XmlMXCAFDoc_LocationDriver (anMsgDrv);
if( !aNamedShapeDriver.IsNull() ) if( !aNamedShapeDriver.IsNull() )

View File

@ -6,7 +6,7 @@ puts "TODO CR23096 ALL: LABELS : Faulty"
set filename 919-004-T03-04-CP-VL.igs set filename 919-004-T03-04-CP-VL.igs
set ref_data { 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 ) TPSTAT : Faulties = 0 ( 2 ) Warnings = 310 ( 2179 ) Summary = 310 ( 2181 )
CHECKSHAPE : Wires = 0 ( 3 ) Faces = 0 ( 3 ) Shells = 0 ( 0 ) Solids = 0 ( 0 ) 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 ) NBSHAPES : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 1457 ( 1455 ) Summary = 38832 ( 38834 )

View File

@ -23,28 +23,3 @@ set ratio [expr $time_occt / $time_std]
if { $ratio > 1.05 } { if { $ratio > 1.05 } {
puts "Error: OCCT handle is too slow: $time_occt vs. $time_std of shared_ptr" 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!"
}
}