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

Compare commits

..

4 Commits

Author SHA1 Message Date
ichesnok
1b836c1140 0033487: Data Exchange, Step Import - Unresolved reference crashes
IsNull() check added for Handle(StepVisual_FillAreaStyleColour).
2024-04-17 08:30:58 +01:00
ika
b78ccf1f9b 0033661: Data Exchange, Step Import - Tessellated GDTs are not imported
Add processing of tessellated_annotation_occurrence.
Add test cases.
2024-04-07 10:46:17 +01:00
oan
2956d432e2 0033560: PARASOLID Import - XT importer raises exception SIGFPE Arithmetic Exception
Prevent division by zero in exceptional cases when vector of parameters contains only a single value.
2024-03-28 13:58:36 +00:00
anv
d3e00bfaa6 0033616: Application Framework - Using filter while reading XBF may result in unresolved links
- Added tracking of unresolved links for TreeNodes;
- Test case added.
2024-03-28 13:55:46 +00:00
74 changed files with 595 additions and 282 deletions

View File

@@ -808,8 +808,11 @@ void Approx_BSplComputeLine::Parameters(const MultiLine& Line,
const Standard_Integer aNbp = lastP - firstP + 1;
// The first parameter should always be zero according to all the logic below,
// so division by any value will give zero anyway, so it should never be scaled
// to avoid case when there is only one parameter in the array thus division by zero happens.
TheParameters(firstP) = 0.0;
if (aNbp == 2) {
TheParameters(firstP) = 0.0;
TheParameters(lastP) = 1.0;
}
else if (Par == Approx_ChordLength || Par == Approx_Centripetal)
@@ -820,7 +823,6 @@ void Approx_BSplComputeLine::Parameters(const MultiLine& Line,
if (nbP3d == 0) mynbP3d = 1;
if (nbP2d == 0) mynbP2d = 1;
TheParameters(firstP) = 0.0;
dist = 0.0;
TColgp_Array1OfPnt tabP(1, mynbP3d);
TColgp_Array1OfPnt tabPP(1, mynbP3d);
@@ -861,10 +863,10 @@ void Approx_BSplComputeLine::Parameters(const MultiLine& Line,
TheParameters(i) = TheParameters(i - 1) + Sqrt(dist);
}
}
for (i = firstP; i <= lastP; i++) TheParameters(i) /= TheParameters(lastP);
for (i = firstP + 1; i <= lastP; i++) TheParameters(i) /= TheParameters(lastP);
}
else {
for (i = firstP; i <= lastP; i++) {
for (i = firstP + 1; i <= lastP; i++) {
TheParameters(i) = (Standard_Real(i) - firstP) /
(Standard_Real(lastP - Standard_Real(firstP)));
}

View File

@@ -92,7 +92,7 @@ void BOPTest::ReportAlerts(const Handle(Message_Report)& theReport)
for (int iGravity = 0; iGravity < 2; iGravity++)
{
// report shapes for the same type of alert together
NCollection_Map<Handle(Standard_Type)> aPassedTypes;
NCollection_Map<Handle(Standard_Transient)> aPassedTypes;
const Message_ListOfAlert& aList = theReport->GetAlerts (anAlertTypes[iGravity]);
for (Message_ListOfAlert::Iterator aIt (aList); aIt.More(); aIt.Next())
{

View File

@@ -515,8 +515,13 @@ BSplCLib::EvalBsplineBasis
//
// this should be always invertible if ii is correctly computed
//
Factor = (Parameter - FlatKnots(ii - qq + pp + 1))
/ (FlatKnots(ii + pp) - FlatKnots(ii - qq + pp + 1)) ;
const Standard_Real aScale = (FlatKnots(ii + pp) - FlatKnots(ii - qq + pp + 1));
if (Abs (aScale) < gp::Resolution())
{
return 2;
}
Factor = (Parameter - FlatKnots(ii - qq + pp + 1)) / aScale;
Saved = Factor * BsplineBasis(1,pp) ;
BsplineBasis(1,pp) *= (1.0e0 - Factor) ;
BsplineBasis(1,pp) += BsplineBasis(1,qq) ;
@@ -536,7 +541,13 @@ BSplCLib::EvalBsplineBasis
}
for (pp = 1 ; pp <= qq - 1 ; pp++) {
Inverse = 1.0e0 / (FlatKnots(ii + pp) - FlatKnots(ii - qq + pp + 1)) ;
const Standard_Real aScale = (FlatKnots(ii + pp) - FlatKnots(ii - qq + pp + 1));
if (Abs (aScale) < gp::Resolution())
{
return 2;
}
Inverse = 1.0e0 / aScale;
Factor = (Parameter - FlatKnots(ii - qq + pp + 1)) * Inverse ;
Saved = Factor * BsplineBasis(1,pp) ;
BsplineBasis(1,pp) *= (1.0e0 - Factor) ;

View File

@@ -33,6 +33,7 @@
#include <Storage_Schema.hxx>
#include <TCollection_AsciiString.hxx>
#include <TCollection_ExtendedString.hxx>
#include <TDataStd_TreeNode.hxx>
#include <TDF_Attribute.hxx>
#include <TDF_Data.hxx>
#include <TDF_Label.hxx>
@@ -324,7 +325,16 @@ void BinLDrivers_DocumentRetrievalDriver::Read (Standard_IStream&
// read sub-tree of the root label
if (!theFilter.IsNull())
theFilter->StartIteration();
Standard_Integer nbRead = ReadSubTree (theIStream, aData->Root(), theFilter, aQuickPart, aPS.Next());
const auto aStreamStartPosition = theIStream.tellg();
Standard_Integer nbRead = ReadSubTree (theIStream, aData->Root(), theFilter, aQuickPart, Standard_False, aPS.Next());
if (!myUnresolvedLinks.IsEmpty())
{
// In case we have skipped some linked TreeNodes before getting to
// their children.
theFilter->StartIteration();
theIStream.seekg(aStreamStartPosition, std::ios_base::beg);
nbRead += ReadSubTree(theIStream, aData->Root(), theFilter, aQuickPart, Standard_True, aPS.Next());
}
if (!aPS.More())
{
myReaderStatus = PCDM_RS_UserBreak;
@@ -373,6 +383,7 @@ Standard_Integer BinLDrivers_DocumentRetrievalDriver::ReadSubTree
const TDF_Label& theLabel,
const Handle(PCDM_ReaderFilter)& theFilter,
const Standard_Boolean& theQuickPart,
const Standard_Boolean theReadMissing,
const Message_ProgressRange& theRange)
{
Standard_Integer nbRead = 0;
@@ -393,7 +404,7 @@ Standard_Integer BinLDrivers_DocumentRetrievalDriver::ReadSubTree
aLabelSize = InverseUint64(aLabelSize);
#endif
// no one sub-label is needed, so, skip everything
if (aSkipAttrs && !theFilter->IsSubPassed())
if (aSkipAttrs && !theFilter->IsSubPassed() && myUnresolvedLinks.IsEmpty())
{
aLabelSize -= sizeof (uint64_t);
theIS.seekg (aLabelSize, std::ios_base::cur);
@@ -403,6 +414,11 @@ Standard_Integer BinLDrivers_DocumentRetrievalDriver::ReadSubTree
}
}
if (theReadMissing)
{
aSkipAttrs = Standard_True;
}
const auto anAttStartPosition = theIS.tellg();
// Read attributes:
for (theIS >> myPAtt;
theIS && myPAtt.TypeId() > 0 && // not an end marker ?
@@ -415,6 +431,12 @@ Standard_Integer BinLDrivers_DocumentRetrievalDriver::ReadSubTree
myReaderStatus = PCDM_RS_UserBreak;
return -1;
}
if (myUnresolvedLinks.Remove(myPAtt.Id()) && aSkipAttrs)
{
aSkipAttrs = Standard_False;
theIS.seekg(anAttStartPosition, std::ios_base::beg);
continue;
}
if (aSkipAttrs)
{
if (myPAtt.IsDirect()) // skip direct written stream
@@ -487,7 +509,17 @@ Standard_Integer BinLDrivers_DocumentRetrievalDriver::ReadSubTree
aDriver->TypeName(), Message_Warning);
}
else if (!isBound)
{
myRelocTable.Bind(anID, tAtt);
Handle(TDataStd_TreeNode) aNode = Handle(TDataStd_TreeNode)::DownCast(tAtt);
if (!theFilter.IsNull() && !aNode.IsNull() && !aNode->Father().IsNull() && aNode->Father()->IsNew())
{
Standard_Integer anUnresolvedLink;
myPAtt.SetPosition(BP_HEADSIZE);
myPAtt >> anUnresolvedLink;
myUnresolvedLinks.Add(anUnresolvedLink);
}
}
}
else if (!myMapUnsupported.Contains(myPAtt.TypeId()))
myMsgDriver->Send(aMethStr + "warning: type ID not registered in header: "
@@ -522,7 +554,7 @@ Standard_Integer BinLDrivers_DocumentRetrievalDriver::ReadSubTree
// read sub-tree
if (!theFilter.IsNull())
theFilter->Down (aTag);
Standard_Integer nbSubRead = ReadSubTree (theIS, aLab, theFilter, theQuickPart, aPS.Next());
Standard_Integer nbSubRead = ReadSubTree (theIS, aLab, theFilter, theQuickPart, theReadMissing, aPS.Next());
// check for error
if (nbSubRead == -1)
return -1;

View File

@@ -80,6 +80,7 @@ protected:
const TDF_Label& theData,
const Handle(PCDM_ReaderFilter)& theFilter,
const Standard_Boolean& theQuickPart,
const Standard_Boolean theReadMissing,
const Message_ProgressRange& theRanges = Message_ProgressRange());
@@ -125,6 +126,7 @@ private:
BinObjMgt_Persistent myPAtt;
TColStd_MapOfInteger myMapUnsupported;
BinLDrivers_VectorOfDocumentSection mySections;
NCollection_Map<Standard_Integer> myUnresolvedLinks;
};

View File

@@ -120,8 +120,8 @@ private:
BinObjMgt_Persistent myPAtt;
TDF_LabelList myEmptyLabels;
NCollection_Map<Handle(Standard_Type)> myMapUnsupported;
NCollection_IndexedMap<Handle(Standard_Type)> myTypesMap;
TColStd_MapOfTransient myMapUnsupported;
TColStd_IndexedMapOfTransient myTypesMap;
BinLDrivers_VectorOfDocumentSection mySections;
TCollection_ExtendedString myFileName;
//! Sizes of labels and some attributes that will be stored in the second pass

View File

@@ -90,12 +90,12 @@ const Handle(Standard_Type)& BinMDF_ADriverTable::AddDerivedDriver (Standard_CSt
//=======================================================================
void BinMDF_ADriverTable::AssignIds
(const NCollection_IndexedMap<Handle(Standard_Type)>& theTypes)
(const TColStd_IndexedMapOfTransient& theTypes)
{
myMapId.Clear();
Standard_Integer i;
for (i=1; i <= theTypes.Extent(); i++) {
const Handle(Standard_Type)& aType = theTypes(i);
Handle(Standard_Type) aType (Handle(Standard_Type)::DownCast (theTypes(i)));
if (myMap.IsBound (aType)) {
myMapId.Bind (aType, i);
}
@@ -141,8 +141,7 @@ void BinMDF_ADriverTable::AssignIds
{
if (!myMapId.IsBound2 (aStrId.Value()))
{
Handle(Standard_Type) anAdded = AddDerivedDriver(aStrId.Key().ToCString());
if (!anAdded.IsNull())
if (Handle(Standard_Type) anAdded = AddDerivedDriver (aStrId.Key().ToCString()))
{
myMapId.Bind (anAdded, aStrId.Value());
}

View File

@@ -59,7 +59,7 @@ public:
//! Assigns the IDs to the drivers of the given Types.
//! It uses indices in the map as IDs.
//! Useful in storage procedure.
Standard_EXPORT void AssignIds (const NCollection_IndexedMap<Handle(Standard_Type)>& theTypes);
Standard_EXPORT void AssignIds (const TColStd_IndexedMapOfTransient& theTypes);
//! Assigns the IDs to the drivers of the given Type Names;
//! It uses indices in the sequence as IDs.

View File

@@ -47,7 +47,7 @@ Handle(TDF_Attribute) BinMDataStd_GenericEmptyDriver::NewEmpty() const
//=======================================================================
const Handle(Standard_Type)& BinMDataStd_GenericEmptyDriver::SourceType() const
{
return STANDARD_TYPE(TDataStd_GenericEmpty);
return Standard_Type::Instance<TDataStd_GenericEmpty>();
}
//=======================================================================

View File

@@ -47,7 +47,7 @@ Handle(TDF_Attribute) BinMDataStd_GenericExtStringDriver::NewEmpty() const
//=======================================================================
Handle(Standard_Type)& BinMDataStd_GenericExtStringDriver::SourceType() const
{
static Handle(Standard_Type) aSourceType = STANDARD_TYPE(TDataStd_GenericExtString);
static Handle(Standard_Type) aSourceType = Standard_Type::Instance<TDataStd_GenericExtString>();
return aSourceType;
}

View File

@@ -15,7 +15,6 @@
#define _BinObjMgt_Position_HeaderFile
#include <Standard_Type.hxx>
#include <Standard_Transient.hxx>
class BinObjMgt_Position;
DEFINE_STANDARD_HANDLE (BinObjMgt_Position, Standard_Transient)

View File

@@ -841,9 +841,12 @@ Standard_Boolean BndLib_Box2dCurve::IsTypeBase
(const Handle(Geom2d_Curve)& aC2D,
GeomAbs_CurveType& aTypeB)
{
Standard_Boolean bRet=Standard_True;
Standard_Boolean bRet;
Handle(Standard_Type) aType;
//
const Handle(Standard_Type)& aType = aC2D->DynamicType();
bRet=Standard_True;
//
aType=aC2D->DynamicType();
if (aType==STANDARD_TYPE(Geom2d_Line)) {
aTypeB=GeomAbs_Line;
}

View File

@@ -18,7 +18,6 @@
#define _CDF_MetaDataDriver_HeaderFile
#include <Standard_Type.hxx>
#include <Standard_Transient.hxx>
class CDM_MetaData;
class TCollection_ExtendedString;

View File

@@ -36,7 +36,8 @@ class gp_Trsf;
//! list of edges and a list of faces.
class DBRep_DrawableShape : public Draw_Drawable3D
{
Draw_Drawable3D_FACTORY_RTTIEXT(DBRep_DrawableShape, Draw_Drawable3D)
DEFINE_STANDARD_RTTIEXT(DBRep_DrawableShape, Draw_Drawable3D)
Draw_Drawable3D_FACTORY
public:
Standard_EXPORT DBRep_DrawableShape(const TopoDS_Shape& C, const Draw_Color& FreeCol, const Draw_Color& ConnCol, const Draw_Color& EdgeCol, const Draw_Color& IsosCol, const Standard_Real size, const Standard_Integer nbisos, const Standard_Integer discret);

View File

@@ -51,9 +51,8 @@ public:
//! @def Draw_Drawable3D_FACTORY
//! Auxiliary macros defining Draw_Drawable3D restoration API to sub-class.
#define Draw_Drawable3D_FACTORY_RTTIEXT(Class,Base) \
DEFINE_STANDARD_RTTIEXT(Class, Base) \
static void RegisterFactory() { Draw_Drawable3D::RegisterFactory (#Class, &Restore); } \
#define Draw_Drawable3D_FACTORY \
static void RegisterFactory() { Draw_Drawable3D::RegisterFactory (get_type_name(), &Restore); } \
Standard_EXPORT static Handle(Draw_Drawable3D) Restore (Standard_IStream& theStream);
public:

View File

@@ -24,7 +24,8 @@ DEFINE_STANDARD_HANDLE(Draw_Number, Draw_Drawable3D)
//! To store numbers in variables.
class Draw_Number : public Draw_Drawable3D
{
Draw_Drawable3D_FACTORY_RTTIEXT(Draw_Number, Draw_Drawable3D)
DEFINE_STANDARD_RTTIEXT(Draw_Number, Draw_Drawable3D)
Draw_Drawable3D_FACTORY
public:
Standard_EXPORT Draw_Number (const Standard_Real theV);

View File

@@ -27,7 +27,8 @@ DEFINE_STANDARD_HANDLE(DrawTrSurf_BSplineCurve, DrawTrSurf_Curve)
class DrawTrSurf_BSplineCurve : public DrawTrSurf_Curve
{
Draw_Drawable3D_FACTORY_RTTIEXT(DrawTrSurf_BSplineCurve, DrawTrSurf_Curve)
DEFINE_STANDARD_RTTIEXT(DrawTrSurf_BSplineCurve, DrawTrSurf_Curve)
Draw_Drawable3D_FACTORY
public:
//! creates a drawable BSpline curve from a BSpline curve of package Geom.

View File

@@ -27,7 +27,8 @@ DEFINE_STANDARD_HANDLE(DrawTrSurf_BSplineCurve2d, DrawTrSurf_Curve2d)
class DrawTrSurf_BSplineCurve2d : public DrawTrSurf_Curve2d
{
Draw_Drawable3D_FACTORY_RTTIEXT(DrawTrSurf_BSplineCurve2d, DrawTrSurf_Curve2d)
DEFINE_STANDARD_RTTIEXT(DrawTrSurf_BSplineCurve2d, DrawTrSurf_Curve2d)
Draw_Drawable3D_FACTORY
public:
//! creates a drawable BSpline curve from a BSpline curve of package Geom2d.

View File

@@ -32,7 +32,8 @@ DEFINE_STANDARD_HANDLE(DrawTrSurf_BSplineSurface, DrawTrSurf_Surface)
//! if you just want to sea boundaries and isoparametric curves.
class DrawTrSurf_BSplineSurface : public DrawTrSurf_Surface
{
Draw_Drawable3D_FACTORY_RTTIEXT(DrawTrSurf_BSplineSurface, DrawTrSurf_Surface)
DEFINE_STANDARD_RTTIEXT(DrawTrSurf_BSplineSurface, DrawTrSurf_Surface)
Draw_Drawable3D_FACTORY
public:
//! default drawing mode.

View File

@@ -26,7 +26,8 @@ DEFINE_STANDARD_HANDLE(DrawTrSurf_BezierCurve, DrawTrSurf_Curve)
class DrawTrSurf_BezierCurve : public DrawTrSurf_Curve
{
Draw_Drawable3D_FACTORY_RTTIEXT(DrawTrSurf_BezierCurve, DrawTrSurf_Curve)
DEFINE_STANDARD_RTTIEXT(DrawTrSurf_BezierCurve, DrawTrSurf_Curve)
Draw_Drawable3D_FACTORY
public:
//! creates a drawable Bezier curve from a Bezier curve of package Geom.

View File

@@ -26,7 +26,8 @@ DEFINE_STANDARD_HANDLE(DrawTrSurf_BezierCurve2d, DrawTrSurf_Curve2d)
class DrawTrSurf_BezierCurve2d : public DrawTrSurf_Curve2d
{
Draw_Drawable3D_FACTORY_RTTIEXT(DrawTrSurf_BezierCurve2d, DrawTrSurf_Curve2d)
DEFINE_STANDARD_RTTIEXT(DrawTrSurf_BezierCurve2d, DrawTrSurf_Curve2d)
Draw_Drawable3D_FACTORY
public:
//! creates a drawable Bezier curve from a Bezier curve of package Geom2d.

View File

@@ -26,7 +26,8 @@ DEFINE_STANDARD_HANDLE(DrawTrSurf_BezierSurface, DrawTrSurf_Surface)
class DrawTrSurf_BezierSurface : public DrawTrSurf_Surface
{
Draw_Drawable3D_FACTORY_RTTIEXT(DrawTrSurf_BezierSurface, DrawTrSurf_Surface)
DEFINE_STANDARD_RTTIEXT(DrawTrSurf_BezierSurface, DrawTrSurf_Surface)
Draw_Drawable3D_FACTORY
public:
//! creates a drawable Bezier curve from a Bezier curve of package Geom.

View File

@@ -29,7 +29,8 @@ DEFINE_STANDARD_HANDLE(DrawTrSurf_Curve, DrawTrSurf_Drawable)
//! This class defines a drawable curve in 3d space.
class DrawTrSurf_Curve : public DrawTrSurf_Drawable
{
Draw_Drawable3D_FACTORY_RTTIEXT(DrawTrSurf_Curve, DrawTrSurf_Drawable)
DEFINE_STANDARD_RTTIEXT(DrawTrSurf_Curve, DrawTrSurf_Drawable)
Draw_Drawable3D_FACTORY
public:
//! creates a drawable curve from a curve of package Geom.

View File

@@ -29,7 +29,8 @@ DEFINE_STANDARD_HANDLE(DrawTrSurf_Curve2d, DrawTrSurf_Drawable)
//! The curve is drawn in the plane XOY.
class DrawTrSurf_Curve2d : public DrawTrSurf_Drawable
{
Draw_Drawable3D_FACTORY_RTTIEXT(DrawTrSurf_Curve2d, DrawTrSurf_Drawable)
DEFINE_STANDARD_RTTIEXT(DrawTrSurf_Curve2d, DrawTrSurf_Drawable)
Draw_Drawable3D_FACTORY
public:
//! creates a drawable curve from a curve of package Geom2d.

View File

@@ -29,7 +29,8 @@ DEFINE_STANDARD_HANDLE(DrawTrSurf_Point, Draw_Drawable3D)
//! A drawable point.
class DrawTrSurf_Point : public Draw_Drawable3D
{
Draw_Drawable3D_FACTORY_RTTIEXT(DrawTrSurf_Point, Draw_Drawable3D)
DEFINE_STANDARD_RTTIEXT(DrawTrSurf_Point, Draw_Drawable3D)
Draw_Drawable3D_FACTORY
public:
Standard_EXPORT DrawTrSurf_Point (const gp_Pnt& P, const Draw_MarkerShape Shape, const Draw_Color& Col);

View File

@@ -28,7 +28,8 @@ DEFINE_STANDARD_HANDLE(DrawTrSurf_Polygon2D, Draw_Drawable2D)
//! Optional display of nodes.
class DrawTrSurf_Polygon2D : public Draw_Drawable2D
{
Draw_Drawable3D_FACTORY_RTTIEXT(DrawTrSurf_Polygon2D, Draw_Drawable2D)
DEFINE_STANDARD_RTTIEXT(DrawTrSurf_Polygon2D, Draw_Drawable2D)
Draw_Drawable3D_FACTORY
public:
Standard_EXPORT DrawTrSurf_Polygon2D (const Handle(Poly_Polygon2D)& P);

View File

@@ -28,7 +28,8 @@ DEFINE_STANDARD_HANDLE(DrawTrSurf_Polygon3D, Draw_Drawable3D)
//! Optional display of nodes.
class DrawTrSurf_Polygon3D : public Draw_Drawable3D
{
Draw_Drawable3D_FACTORY_RTTIEXT(DrawTrSurf_Polygon3D, Draw_Drawable3D)
DEFINE_STANDARD_RTTIEXT(DrawTrSurf_Polygon3D, Draw_Drawable3D)
Draw_Drawable3D_FACTORY
public:
Standard_EXPORT DrawTrSurf_Polygon3D (const Handle(Poly_Polygon3D)& P);

View File

@@ -29,7 +29,8 @@ DEFINE_STANDARD_HANDLE(DrawTrSurf_Surface, DrawTrSurf_Drawable)
//! With this class you can draw a general surface from package Geom.
class DrawTrSurf_Surface : public DrawTrSurf_Drawable
{
Draw_Drawable3D_FACTORY_RTTIEXT(DrawTrSurf_Surface, DrawTrSurf_Drawable)
DEFINE_STANDARD_RTTIEXT(DrawTrSurf_Surface, DrawTrSurf_Drawable)
Draw_Drawable3D_FACTORY
public:
//! default drawing mode

View File

@@ -32,7 +32,8 @@ DEFINE_STANDARD_HANDLE(DrawTrSurf_Triangulation, Draw_Drawable3D)
//! Optional display of triangles and nodes indices.
class DrawTrSurf_Triangulation : public Draw_Drawable3D
{
Draw_Drawable3D_FACTORY_RTTIEXT(DrawTrSurf_Triangulation, Draw_Drawable3D)
DEFINE_STANDARD_RTTIEXT(DrawTrSurf_Triangulation, Draw_Drawable3D)
Draw_Drawable3D_FACTORY
public:
Standard_EXPORT DrawTrSurf_Triangulation (const Handle(Poly_Triangulation)& T);

View File

@@ -17,7 +17,6 @@
#include <Standard_Boolean.hxx>
#include <Standard_Type.hxx>
#include <Standard_OStream.hxx>
#include <Standard_Handle.hxx>
class Express_Schema;
class TCollection_AsciiString;

View File

@@ -15,7 +15,6 @@
#define _Express_Field_HeaderFile
#include <Standard_Type.hxx>
#include <Standard_Transient.hxx>
class Express_Type;
class TCollection_HAsciiString;

View File

@@ -15,7 +15,6 @@
#define _Express_Type_HeaderFile
#include <Standard_Type.hxx>
#include <Standard_Transient.hxx>
class TCollection_AsciiString;

View File

@@ -215,7 +215,7 @@ void Geom2dAdaptor_Curve::load(const Handle(Geom2d_Curve)& C,
myNestedEvaluator.Nullify();
myBSplineCurve.Nullify();
const Handle(Standard_Type)& TheType = C->DynamicType();
Handle(Standard_Type) TheType = C->DynamicType();
if ( TheType == STANDARD_TYPE(Geom2d_TrimmedCurve)) {
Load(Handle(Geom2d_TrimmedCurve)::DownCast (C)->BasisCurve(),
UFirst,ULast);

View File

@@ -26,7 +26,8 @@ DEFINE_STANDARD_HANDLE(HLRTest_Projector, Draw_Drawable3D)
//! Draw Variable Projector to test.
class HLRTest_Projector : public Draw_Drawable3D
{
Draw_Drawable3D_FACTORY_RTTIEXT(HLRTest_Projector, Draw_Drawable3D)
DEFINE_STANDARD_RTTIEXT(HLRTest_Projector, Draw_Drawable3D)
Draw_Drawable3D_FACTORY
public:
Standard_EXPORT HLRTest_Projector(const HLRAlgo_Projector& P);

View File

@@ -32,10 +32,9 @@ Standard_Boolean IFSelect_SignAncestor::Matches(const Handle(Standard_Transient)
const TCollection_AsciiString& text,
const Standard_Boolean /*exact*/) const
{
return false;
// if (ent.IsNull()) return Standard_False;
// DeclareAndCast(Standard_Type,atype,ent);
// if (atype.IsNull()) atype = ent->DynamicType();
// return atype->SubType(text.ToCString());
if (ent.IsNull()) return Standard_False;
DeclareAndCast(Standard_Type,atype,ent);
if (atype.IsNull()) atype = ent->DynamicType();
return atype->SubType(text.ToCString());
}

View File

@@ -33,7 +33,8 @@ static Standard_CString nulsign = "";
const Handle(Interface_InterfaceModel)& /*model*/) const
{
if (ent.IsNull()) return nulsign;
Handle(Standard_Type) atype = ent->DynamicType();
DeclareAndCast(Standard_Type,atype,ent);
if (atype.IsNull()) atype = ent->DynamicType();
Standard_CString tn = atype->Name();
if (!thenopk) return tn;
for (int i = 0; tn[i] != '\0'; i ++) {

View File

@@ -250,7 +250,7 @@ Standard_Boolean Interface_FileReaderTool::RecognizeByLib(const Standard_Integer
}
if (CN <= 0 || proto.IsNull()) return Standard_False;
// Se recaler dans GeneralLib : Creation de l entite vide
const Handle(Standard_Type)& typrot = proto->DynamicType();
Handle(Standard_Type) typrot = proto->DynamicType();
for (glib.Start(); glib.More(); glib.Next()) {
proto = glib.Protocol();
if (proto.IsNull()) continue;

View File

@@ -110,8 +110,8 @@ private:
Handle(Interface_Protocol) theproto;
Handle(Interface_SignType) thesign;
Interface_GeneralLib thelib;
NCollection_DataMap<Handle(Standard_Type),Standard_Integer> thentnum;
NCollection_IndexedDataMap<Handle(Standard_Type),Handle(Standard_Transient)> thentmod;
Interface_DataMapOfTransientInteger thentnum;
TColStd_IndexedDataMapOfTransientTransient thentmod;
};

View File

@@ -17,7 +17,6 @@
#define _Message_Alert_HeaderFile
#include <Standard_Type.hxx>
#include <Standard_Transient.hxx>
DEFINE_STANDARD_HANDLE(Message_Alert, Standard_Transient)

View File

@@ -223,9 +223,13 @@ void Message_Algorithm::SendStatusMessages (const Message_ExecStatus& theStatus,
// find message, prefixed by class type name, iterating by base classes if necessary
TCollection_AsciiString aMsgName;
Handle(Standard_Type) aType = DynamicType();
for (Handle(Standard_Type) aType = DynamicType(); ! aType.IsNull(); aType = aType->Parent())
{
aMsgName = aType->Name();
aMsgName += aSuffix;
if (Message_MsgFile::HasMsg(aMsgName))
break;
}
// create a message
Message_Msg aMsg ( aMsgName );

View File

@@ -76,7 +76,7 @@ void OSD_ThreadPool::EnumeratedThread::WaitIdle()
myIdleEvent.Reset();
}
}
#include <thread>
// =======================================================================
// function : DefaultPool
// purpose :

View File

@@ -17,7 +17,6 @@
#define OpenGl_Element_HeaderFile
#include <Standard_Type.hxx>
#include <Standard_Handle.hxx>
class Graphic3d_FrameStatsDataTmp;
class OpenGl_Workspace;

View File

@@ -17,7 +17,6 @@
#define OpenGl_Resource_HeaderFile
#include <Standard_Type.hxx>
#include <Standard_Transient.hxx>
class OpenGl_Context;

View File

@@ -2134,11 +2134,12 @@ Standard_Boolean readPMIPresentation(const Handle(Standard_Transient)& thePresen
return Standard_False;
}
Handle(Transfer_TransientProcess) aTP = theTR->TransientProcess();
Handle(StepVisual_AnnotationOccurrence) anAO;
Handle(StepVisual_StyledItem) anAO;
NCollection_Vector<Handle(StepVisual_StyledItem)> anAnnotations;
if (thePresentEntity->IsKind(STANDARD_TYPE(StepVisual_AnnotationOccurrence)))
if (thePresentEntity->IsKind(STANDARD_TYPE(StepVisual_AnnotationOccurrence)) ||
thePresentEntity->IsKind(STANDARD_TYPE(StepVisual_TessellatedAnnotationOccurrence)))
{
anAO = Handle(StepVisual_AnnotationOccurrence)::DownCast(thePresentEntity);
anAO = Handle(StepVisual_StyledItem)::DownCast(thePresentEntity);
if (!anAO.IsNull())
{
thePresentName = anAO->Name();
@@ -4368,7 +4369,8 @@ Standard_Boolean STEPCAFControl_Reader::ReadGDTs(const Handle(XSControl_WorkSess
}
}
else if (anEnt->IsKind(STANDARD_TYPE(StepVisual_DraughtingCallout)) ||
anEnt->IsKind(STANDARD_TYPE(StepVisual_AnnotationOccurrence)))
anEnt->IsKind(STANDARD_TYPE(StepVisual_AnnotationOccurrence)) ||
anEnt->IsKind(STANDARD_TYPE(StepVisual_TessellatedAnnotationOccurrence)))
{
// Protection against import presentation twice
Handle(StepVisual_DraughtingCallout) aDC;

View File

@@ -634,7 +634,7 @@ Standard_Boolean STEPConstruct_Styles::GetColors (const Handle(StepVisual_Styled
for ( Standard_Integer m=1; m <= FAS->NbFillStyles(); m++ ) {
StepVisual_FillStyleSelect FSS = FAS->FillStylesValue ( m );
Handle(StepVisual_FillAreaStyleColour) FASC = FSS.FillAreaStyleColour();
if ( SurfCol.IsNull() || SSU->Side() != StepVisual_ssNegative ) //abv 30 Mar 00: trj3_s1-pe.stp
if ( !FASC.IsNull() && (SurfCol.IsNull() || SSU->Side() != StepVisual_ssNegative) ) //abv 30 Mar 00: trj3_s1-pe.stp
SurfCol = FASC->FillColour();
}
continue;

View File

@@ -60,7 +60,8 @@ Standard_Boolean STEPSelections_SelectDerived::Matches(const Handle(Standard_Tra
Standard_Boolean plex = module->IsComplex(CN);
if (!plex) {
Handle(Standard_Type) atype = ent->DynamicType();
DeclareAndCast(Standard_Type,atype,ent);
if (atype.IsNull()) atype = ent->DynamicType();
return atype->SubType(checker);
} else {
TColStd_SequenceOfAsciiString list;

View File

@@ -15,7 +15,6 @@
#define _SelectMgr_HeaderFile
#include <Standard_Type.hxx>
#include <Standard_Handle.hxx>
class Graphic3d_Structure;
class Graphic3d_TransformPers;

View File

@@ -870,7 +870,7 @@ Standard_Boolean ShapeConstruct_ProjectCurveOnSurface::PerformByProjLib(Handle(G
Handle(Geom_Curve) cIso;
Standard_Real t1, t2;
const Handle(Standard_Type)& sType = mySurf->Surface()->DynamicType();
Handle(Standard_Type) sType = mySurf->Surface()->DynamicType();
Standard_Boolean isAnalytic = Standard_True;
if (sType == STANDARD_TYPE(Geom_BezierSurface) || sType == STANDARD_TYPE(Geom_BSplineSurface)) isAnalytic = Standard_False;
Standard_Real uf, ul, vf, vl;

View File

@@ -13,8 +13,6 @@
#include <Standard_ArrayStreamBuffer.hxx>
#include <cstring>
// =======================================================================
// function : Standard_ArrayStreamBuffer
// purpose :

View File

@@ -21,10 +21,10 @@
//! Since OCCT 7.0, relevant macros are provided by Standard_Type.hxx and Standard_Handle.hxx.
#include <Standard_Type.hxx>
#include <Standard_Handle.hxx>
class Standard_Transient;
class Standard_Persistent;
class Standard_Type;
// Obsolete macros kept for compatibility
#define IMPLEMENT_DOWNCAST(C1,BC)

View File

@@ -16,7 +16,6 @@
#define _Standard_Persistent_HeaderFile
#include <Standard_Type.hxx>
#include <Standard_Transient.hxx>
//! Root of "persistent" classes, a legacy support of
//! object oriented databases, now outdated.

View File

@@ -18,11 +18,9 @@
#include <Standard_CString.hxx>
#include <Standard_ProgramError.hxx>
const Handle(Standard_Type)& Standard_Transient::get_type_descriptor()
const Handle(Standard_Type)& Standard_Transient::get_type_descriptor ()
{
static const opencascade::handle<Standard_Type> THE_TYPE_INSTANCE(new Standard_Type(typeid(Standard_Transient), get_type_name(),
sizeof(Standard_Transient), nullptr));
return THE_TYPE_INSTANCE;
return opencascade::type_instance<Standard_Transient>::get();
}
//

View File

@@ -122,6 +122,4 @@ private:
//! Definition of Handle_Standard_Transient as typedef for compatibility
typedef opencascade::handle<Standard_Transient> Handle_Standard_Transient;
#include <Standard_Handle.hxx>
#endif

View File

@@ -1,5 +1,5 @@
// Copyright (c) 1998-1999 Matra Datavision
// Copyright (c) 1999-2024 OPEN CASCADE SAS
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
@@ -12,37 +12,40 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <Standard_Type.hxx>
#include <Standard_Mutex.hxx>
#include <Standard_Assert.hxx>
#include <unordered_map>
IMPLEMENT_STANDARD_RTTIEXT(Standard_Type,Standard_Transient)
//============================================================================
Standard_Type::Standard_Type (const std::type_info& theInfo,
const char* theName,
Standard_Size theSize,
const Handle(Standard_Type)& theParent) :
myInfo(theInfo),
myName(theName),
mySize(theSize),
myParent(theParent)
{
}
//============================================================================
Standard_Boolean Standard_Type::SubType (const Handle(Standard_Type)& theOther) const
{
const Standard_Type* aTypeIter = this;
while (aTypeIter != nullptr)
{
if (*theOther == *aTypeIter)
{
return true;
}
aTypeIter = aTypeIter->Parent();
}
return false;
return ! theOther.IsNull() && (theOther == this || (! myParent.IsNull() && myParent->SubType (theOther)));
}
//============================================================================
Standard_Boolean Standard_Type::SubType (const Standard_CString theName) const
{
const Standard_Type* aTypeIter = this;
while (aTypeIter != nullptr)
{
if (IsEqual(theName, aTypeIter->Name()))
{
return true;
}
aTypeIter = aTypeIter->Parent();
}
return false;
return theName != 0 && (IsEqual (myName, theName) || (! myParent.IsNull() && myParent->SubType (theName)));
}
// ------------------------------------------------------------------
@@ -52,3 +55,53 @@ void Standard_Type::Print (Standard_OStream& AStream) const
{
AStream << std::hex << (Standard_Address)this << " : " << std::dec << myName ;
}
//============================================================================
// Registry of types
//============================================================================
namespace {
// Map of string to type
typedef std::unordered_map<std::type_index, Standard_Type*> registry_type;
// Registry is made static in the function to ensure that it gets
// initialized by the time of first access
registry_type& GetRegistry()
{
static registry_type theRegistry;
return theRegistry;
}
// To initialize theRegistry map as soon as possible to be destroyed the latest
Handle(Standard_Type) theType = STANDARD_TYPE(Standard_Transient);
}
Standard_Type* Standard_Type::Register (const std::type_info& theInfo, const char* theName,
Standard_Size theSize, const Handle(Standard_Type)& theParent)
{
// Access to registry is protected by mutex; it should not happen often because
// instances are cached by Standard_Type::Instance() (one per binary module)
static Standard_Mutex theMutex;
Standard_Mutex::Sentry aSentry (theMutex);
// return existing descriptor if already in the registry
registry_type& aRegistry = GetRegistry();
Standard_Type* aType = 0;
auto anIter = aRegistry.find(theInfo);
if (anIter != aRegistry.end())
return anIter->second;
// else create a new descriptor
aType = new Standard_Type (theInfo, theName, theSize, theParent);
// then add it to registry and return (the reference to the handle stored in the registry)
aRegistry.emplace(theInfo, aType);
return aType;
}
Standard_Type::~Standard_Type ()
{
// remove descriptor from the registry
registry_type& aRegistry = GetRegistry();
Standard_ASSERT(aRegistry.erase(myInfo) > 0, "Standard_Type::~Standard_Type() cannot find itself in registry",);
}

View File

@@ -1,5 +1,5 @@
// Copyright (c) 1991-1999 Matra Datavision
// Copyright (c) 1999-2024 OPEN CASCADE SAS
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
@@ -16,159 +16,71 @@
#define _Standard_Type_HeaderFile
#include <Standard.hxx>
#include <Standard_OStream.hxx>
#include <Standard_Handle.hxx>
#include <Standard_Transient.hxx>
#include <Standard_OStream.hxx>
#include <functional>
#include <typeinfo>
#include <typeindex>
namespace opencascade
{
template <class T> class handle;
}
// Auxiliary tools to check at compile time that class declared as base in
// DEFINE_STANDARD_RTTI* macro is actually a base class.
#if ! defined(OCCT_CHECK_BASE_CLASS)
class Standard_Transient;
#if (defined(__GNUC__) && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 7) || (__GNUC__ > 4)))
class Standard_Type
{
public:
// For GCC 4.7+, more strict check is possible -- ensuring that base class
// is direct base -- using non-standard C++ reflection functionality.
Standard_Type(const std::type_info& theInfo,
const Standard_CString theName,
const Standard_Size theSize,
const Standard_Type* theParent) :
myInfo(theInfo),
myName(theName),
mySize(theSize),
myParent(theParent) {}
Standard_Type(const Standard_Type& theType) :
myInfo(theType.myInfo),
myName(theType.myName),
mySize(theType.mySize),
myParent(theType.myParent) {}
Standard_Type(Standard_Type&& theType) noexcept :
myInfo(theType.myInfo),
myName(theType.myName),
mySize(theType.mySize),
myParent(theType.myParent) {}
Standard_Type& operator=(const Standard_Type& theOther)
{
myInfo = theOther.myInfo;
myName = theOther.myName;
mySize = theOther.mySize;
myParent = theOther.myParent;
return *this;
}
//! Returns the system type name of the class (typeinfo.name)
Standard_CString SystemName() const { return myInfo.get().name(); }
//! Returns the hash code of the class (typeinfo.hash_code)
Standard_Size HashCode() const { return myInfo.get().hash_code(); }
//! Returns the given name of the class type (get_type_name)
Standard_CString Name() const { return myName; }
//! Returns the size of the class instance in bytes
Standard_Size Size() const { return mySize; }
//! Returns descriptor of the base class in the hierarchy. Can be null
const Standard_Type* Parent() const { return myParent; }
bool operator==(const Standard_Type& theType) const { return myInfo.get() == theType.myInfo.get(); }
bool operator==(const std::type_info& theInfo) const { return myInfo.get() == theInfo; }
//! Returns True if this type is the same as theOther, or inherits from theOther.
//! Note that multiple inheritance is not supported.
Standard_EXPORT Standard_Boolean SubType (const Handle(Standard_Type)& theOther) const;
//! Returns True if this type is the same as theOther, or inherits from theOther.
//! Note that multiple inheritance is not supported.
Standard_EXPORT Standard_Boolean SubType (const Standard_CString theOther) const;
//! Prints type (address of descriptor + name) to a stream
Standard_EXPORT void Print (Standard_OStream& theStream) const;
private:
std::reference_wrapper<const std::type_info> myInfo; //!< STL Type descriptor of current class
Standard_CString myName; //!< Given name of the class
Standard_Size mySize; //!< Size of the class instance, in bytes
const Standard_Type* myParent; //!< Type descriptor of parent class
};
#include <tr2/type_traits>
#include <tuple>
namespace opencascade
{
template <>
class handle<Standard_Type>
template<typename T>
struct direct_base_class_as_tuple {};
template<typename ... Ts>
struct direct_base_class_as_tuple<std::tr2::__reflection_typelist<Ts...> >
{
public:
//! STL-compliant typedef of contained type
typedef Standard_Type element_type;
public:
//! Empty constructor
handle() : myObject(nullptr) {}
//! Constructor from pointer to new object
handle (const Standard_Type* theType) : myObject(theType) {}
//! Copy constructor
handle (const handle& theHandle) : myObject(theHandle.myObject) {}
//! Assignment operator
handle& operator= (const handle& theHandle)
{
myObject = theHandle.myObject;
return *this;
}
bool IsNull() const { return myObject == nullptr; }
bool operator== (const handle& theHandle) const
{
return myObject == theHandle.myObject;
}
bool operator!= (const handle& theHandle) const
{
return !(myObject == theHandle.myObject);
}
//! STL-like cast to pointer to referred object (note non-const).
//! @sa std::shared_ptr::get()
const Standard_Type* get() const { return myObject; }
//! Member access operator (note non-const)
const Standard_Type* operator-> () const { return myObject; }
//! Dereferencing operator (note non-const)
const Standard_Type& operator* () const { return *myObject; }
private:
const Standard_Type* myObject;
typedef std::tuple<Ts...> type;
};
template <typename T, typename Tuple>
struct has_type;
template <typename T>
struct has_type<T, std::tuple<> > : std::false_type {};
template <typename T, typename U, typename... Ts>
struct has_type<T, std::tuple<U, Ts...> > : has_type<T, std::tuple<Ts...> > {};
template <typename T, typename... Ts>
struct has_type<T, std::tuple<T, Ts...> > : std::true_type {};
}
//! Operator printing type descriptor to stream
inline Standard_OStream& operator << (Standard_OStream& theStream, const opencascade::handle<Standard_Type>& theType)
{
theStream << theType->Name();
return theStream;
}
#define OCCT_CHECK_BASE_CLASS(Class,Base) \
using direct_base_classes = opencascade::direct_base_class_as_tuple<std::tr2::direct_bases<Class>::type>::type; \
static_assert(opencascade::has_type<Base, direct_base_classes>::type::value, "OCCT RTTI definition is incorrect: " #Base " is not direct base class of " #Class); \
static_assert(&get_type_name == &Class::get_type_name, "OCCT RTTI definition is misplaced: current class is not " #Class);
#elif (defined(_MSC_VER) && (_MSC_VER >= 1900))
// VC14+ allow using address of member functions in static checks,
// that allows checking for the current type being correctly named in the macro
#define OCCT_CHECK_BASE_CLASS(Class,Base) \
static_assert(opencascade::is_base_but_not_same<Base, Class>::value, "OCCT RTTI definition is incorrect: " #Base " is not base class of " #Class); \
static_assert(&get_type_name == &Class::get_type_name, "OCCT RTTI definition is misplaced: current class is not " #Class);
#else
// by default, check only the base class
#define OCCT_CHECK_BASE_CLASS(Class,Base) \
static_assert(opencascade::is_base_but_not_same<Base, Class>::value, "OCCT RTTI definition is incorrect: " #Base " is not base class of " #Class);
namespace std
{
template <>
struct hash<Standard_Type>
{
size_t operator()(const Standard_Type& theType) const noexcept
{
return theType.HashCode();
}
};
}
#endif
#endif /* ! defined(OCCT_CHECK_BASE_CLASS) */
//! Helper macro to get instance of a type descriptor for a class in a legacy way.
#define STANDARD_TYPE(theType) theType::get_type_descriptor()
@@ -181,13 +93,8 @@ namespace std
#define DEFINE_STANDARD_RTTI_INLINE(Class,Base) \
public: \
typedef Base base_type; \
static const char* get_type_name() { return #Class; } \
static const Handle(Standard_Type)& get_type_descriptor() \
{ \
static const Handle(Standard_Type) THE_TYPE_INSTANCE(new Standard_Type(typeid(Class), get_type_name(), \
sizeof(Class), Base::get_type_descriptor().get())); \
return THE_TYPE_INSTANCE; \
} \
static const char* get_type_name () { return #Class; OCCT_CHECK_BASE_CLASS(Class,Base) } \
static const Handle(Standard_Type)& get_type_descriptor () { return Standard_Type::Instance<Class>(); } \
virtual const Handle(Standard_Type)& DynamicType() const Standard_OVERRIDE { return get_type_descriptor (); }
//! Helper macro to be included in definition of the classes inheriting
@@ -197,18 +104,186 @@ public: \
#define DEFINE_STANDARD_RTTIEXT(Class,Base) \
public: \
typedef Base base_type; \
static const char* get_type_name() { return #Class; } \
Standard_EXPORT static const Handle(Standard_Type)& get_type_descriptor(); \
static const char* get_type_name () { return #Class; OCCT_CHECK_BASE_CLASS(Class,Base) } \
Standard_EXPORT static const Handle(Standard_Type)& get_type_descriptor (); \
Standard_EXPORT virtual const Handle(Standard_Type)& DynamicType() const Standard_OVERRIDE;
//! Defines implementation of type descriptor and DynamicType() function
#define IMPLEMENT_STANDARD_RTTIEXT(Class,Base) \
const Handle(Standard_Type)& Class::get_type_descriptor() \
{ \
static const Handle(Standard_Type) THE_TYPE_INSTANCE(new Standard_Type(typeid(Class), get_type_name(), \
sizeof(Class), Base::get_type_descriptor().get())); \
return THE_TYPE_INSTANCE; \
} \
const Handle(Standard_Type)& Class::DynamicType() const { return get_type_descriptor(); }
const Handle(Standard_Type)& Class::get_type_descriptor () { return Standard_Type::Instance<Class>(); } \
const Handle(Standard_Type)& Class::DynamicType() const { return STANDARD_TYPE(Class); }
// forward declaration of type_instance class
namespace opencascade {
template <typename T>
class type_instance;
}
//! This class provides legacy interface (type descriptor) to run-time type
//! information (RTTI) for OCCT classes inheriting from Standard_Transient.
//!
//! In addition to features provided by standard C++ RTTI (type_info),
//! Standard_Type allows passing descriptor as an object and using it for
//! analysis of the type:
//! - get descriptor of a parent class
//! - get user-defined name of the class
//! - get size of the object
//!
//! Use static template method Instance() to get descriptor for a given type.
//! Objects supporting OCCT RTTI return their type descriptor by method DynamicType().
//!
//! To be usable with OCCT type system, the class should provide:
//! - typedef base_type to its base class in the hierarchy
//! - method get_type_name() returning programmer-defined name of the class
//! (as a statically allocated constant C string or string literal)
//!
//! Note that user-defined name is used since typeid.name() is usually mangled in
//! compiler-dependent way.
//!
//! Only single chain of inheritance is supported, with a root base class Standard_Transient.
class Standard_Type : public Standard_Transient
{
public:
//! Returns the system type name of the class (typeinfo.name)
Standard_CString SystemName() const { return myInfo.name(); }
//! Returns the given name of the class type (get_type_name)
Standard_CString Name() const { return myName; }
//! Returns the size of the class instance in bytes
Standard_Size Size() const { return mySize; }
//! Returns descriptor of the base class in the hierarchy
const Handle(Standard_Type)& Parent () const { return myParent; }
//! Returns True if this type is the same as theOther, or inherits from theOther.
//! Note that multiple inheritance is not supported.
Standard_EXPORT Standard_Boolean SubType (const Handle(Standard_Type)& theOther) const;
//! Returns True if this type is the same as theOther, or inherits from theOther.
//! Note that multiple inheritance is not supported.
Standard_EXPORT Standard_Boolean SubType (const Standard_CString theOther) const;
//! Prints type (address of descriptor + name) to a stream
Standard_EXPORT void Print (Standard_OStream& theStream) const;
//! Template function returning instance of the type descriptor for an argument class.
//!
//! For optimization, each type is registered only once (due to use of the static variable).
//!
//! See helper macro DEFINE_STANDARD_RTTI for defining these items in the class.
template <class T>
static const Handle(Standard_Type)& Instance()
{
return opencascade::type_instance<T>::get();
}
//! Register a type; returns either new or existing descriptor.
//!
//! @param theInfo object stores system name of the class
//! @param theName name of the class to be stored in Name field
//! @param theSize size of the class instance
//! @param theParent base class in the Transient hierarchy
//!
//! Note that this function is intended for use by opencascade::type_instance only.
Standard_EXPORT static
Standard_Type* Register (const std::type_info& theInfo, const char* theName,
Standard_Size theSize, const Handle(Standard_Type)& theParent);
//! Destructor removes the type from the registry
Standard_EXPORT ~Standard_Type ();
// Define own RTTI
DEFINE_STANDARD_RTTIEXT(Standard_Type,Standard_Transient)
private:
//! Constructor is private
Standard_Type (const std::type_info& theInfo, const char* theName,
Standard_Size theSize, const Handle(Standard_Type)& theParent);
private:
std::type_index myInfo; //!< Object to store system name of the class
Standard_CString myName; //!< Given name of the class
Standard_Size mySize; //!< Size of the class instance, in bytes
Handle(Standard_Type) myParent; //!< Type descriptor of parent class
};
namespace opencascade {
//! Template class providing instantiation of type descriptors as singletons.
//! The descriptors are defined as static variables in function get(), which
//! is essential to ensure that they are initialized in correct sequence.
//!
//! For compilers that do not provide thread-safe initialization of static
//! variables (C++11 feature, N2660), additional global variable is
//! defined for each type to hold its type descriptor. These globals ensure
//! that all types get initialized during the library loading and thus no
//! concurrency occurs when type system is accessed from multiple threads.
template <typename T>
class type_instance
{
static Handle(Standard_Type) myInstance;
public:
static const Handle(Standard_Type)& get ();
};
//! Specialization of type descriptor instance for void; returns null handle
template <>
class type_instance<void>
{
public:
static Handle(Standard_Type) get () { return 0; }
};
// Implementation of static function returning instance of the
// type descriptor
template <typename T>
const Handle(Standard_Type)& type_instance<T>::get ()
{
#if (defined(_MSC_VER) && _MSC_VER < 1900) || \
(defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 3)) && \
! defined(__clang__) && ! defined(__INTEL_COMPILER))
// ensure that myInstance is instantiated
(void)myInstance;
#endif
// static variable inside function ensures that descriptors
// are initialized in correct sequence
static Handle(Standard_Type) anInstance =
Standard_Type::Register (typeid(T), T::get_type_name(), sizeof(T),
type_instance<typename T::base_type>::get());
return anInstance;
}
// Static class field is defined to ensure initialization of all type
// descriptors at load time of the library on compilers not supporting N2660:
// - VC++ below 14 (VS 2015)
// - GCC below 4.3
// Intel compiler reports itself as GCC on Linux and VC++ on Windows,
// and is claimed to support N2660 on Linux and on Windows "in VS2015 mode".
// CLang should support N2660 since version 2.9, but it is not clear how to
// check its version reliably (on Linux it says it is GCC 4.2).
#if (defined(_MSC_VER) && _MSC_VER < 1900) || \
(defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 3)) && \
! defined(__clang__) && ! defined(__INTEL_COMPILER))
template <typename T>
Handle(Standard_Type) type_instance<T>::myInstance (get());
#endif
}
//! Operator printing type descriptor to stream
inline Standard_OStream& operator << (Standard_OStream& theStream, const Handle(Standard_Type)& theType)
{
theType->Print (theStream);
return theStream;
}
//! Definition of Handle_Standard_Type as typedef for compatibility
DEFINE_STANDARD_HANDLE(Standard_Type,Standard_Transient)
#endif // _Standard_Type_HeaderFile

View File

@@ -756,7 +756,7 @@ static Standard_CString schemaAP242DIS = "AP242_MANAGED_MODEL_BASED_3D_ENGINEERI
#include <StepVisual_TriangulatedSurfaceSet.hxx>
static int THE_StepAP214_Protocol_init = 0;
static NCollection_DataMap<Handle(Standard_Type), Standard_Integer> types(819);
static Interface_DataMapOfTransientInteger types(819);
//=======================================================================
//function : StepAP214_Protocol

View File

@@ -31,7 +31,7 @@ static Standard_CString thename = "";
void StepData_FileProtocol::Add (const Handle(StepData_Protocol)& protocol)
{
if (protocol.IsNull()) return;
const Handle(Standard_Type)& ptype = protocol->DynamicType();
Handle(Standard_Type) ptype = protocol->DynamicType();
Standard_Integer nb = thecomps.Length();
for (Standard_Integer i = 1; i <= nb; i ++) {
if (thecomps.Value(i)->IsInstance(ptype)) return;

View File

@@ -84,7 +84,7 @@ StepData_PDescr::StepData_PDescr ()
{ thekind = KindEntity; thetype = atype; thednam.Clear(); }
void StepData_PDescr::SetDescr (const Standard_CString dscnam)
{ thekind = KindEntity; thetype = Handle(Standard_Type)();
{ thekind = KindEntity; thetype.Nullify();
thednam.Clear(); thednam.AssignCat(dscnam); }
void StepData_PDescr::AddArity (const Standard_Integer arity)

View File

@@ -18,7 +18,6 @@
#define StepFile_Read_HeaderFile
#include <Standard_CString.hxx>
#include <Standard_Handle.hxx>
#include <Standard_Type.hxx>
#include <iostream>

View File

@@ -14,7 +14,7 @@
#include <StepVisual_CoordinatesList.hxx>
#include <StepVisual_TessellatedItem.hxx>
IMPLEMENT_STANDARD_RTTIEXT(StepVisual_CoordinatesList, StepVisual_TessellatedItem)
IMPLEMENT_STANDARD_RTTIEXT(StepVisual_CoordinatesList,StepGeom_TessellatedItem)
StepVisual_CoordinatesList::StepVisual_CoordinatesList () {}

View File

@@ -15,7 +15,7 @@
#include <StepVisual_TessellatedGeometricSet.hxx>
IMPLEMENT_STANDARD_RTTIEXT(StepVisual_TessellatedGeometricSet, StepVisual_TessellatedItem)
IMPLEMENT_STANDARD_RTTIEXT(StepVisual_TessellatedGeometricSet,StepGeom_TessellatedItem)
StepVisual_TessellatedGeometricSet::StepVisual_TessellatedGeometricSet () {}

View File

@@ -39,9 +39,9 @@ TColStd_SequenceOfTransient& TObj_Assistant::getModels()
//purpose :
//=======================================================================
NCollection_IndexedMap<Handle(Standard_Type)>& TObj_Assistant::getTypes()
TColStd_IndexedMapOfTransient& TObj_Assistant::getTypes()
{
static NCollection_IndexedMap<Handle(Standard_Type)> sTypes;
static TColStd_IndexedMapOfTransient sTypes;
return sTypes;
}
@@ -119,7 +119,7 @@ Handle(Standard_Type) TObj_Assistant::FindType
(const Standard_Integer theTypeIndex)
{
if(theTypeIndex > 0 && theTypeIndex <= getTypes().Extent())
return getTypes().FindKey(theTypeIndex);
return Handle(Standard_Type)::DownCast(getTypes().FindKey(theTypeIndex));
return 0;
}
@@ -166,12 +166,12 @@ DEFINE_STANDARD_HANDLE(TObj_Assistant_UnknownType,Standard_Transient)
Standard_Integer TObj_Assistant::BindType
(const Handle(Standard_Type)& theType)
{
// if(!theType)
// {
// Handle(Standard_Transient) anUnknownType;
// anUnknownType = new TObj_Assistant_UnknownType;
// return getTypes().Add(anUnknownType);
// }
if(theType.IsNull())
{
Handle(Standard_Transient) anUnknownType;
anUnknownType = new TObj_Assistant_UnknownType;
return getTypes().Add(anUnknownType);
}
return getTypes().Add(theType);
}

View File

@@ -103,7 +103,7 @@ private:
static Standard_EXPORT TColStd_SequenceOfTransient& getModels();
//! Method for taking fields for map types
static Standard_EXPORT NCollection_IndexedMap<Handle(Standard_Type)>& getTypes();
static Standard_EXPORT TColStd_IndexedMapOfTransient& getTypes();
//! Method for taking fields for the Current model
static Standard_EXPORT Handle(TObj_Model)& getCurrentModel();

View File

@@ -1220,7 +1220,7 @@ Standard_Boolean TObj_Object::copyData
(const Handle(TObj_Object)& theTargetObject)
{
Standard_Boolean IsDone = Standard_False;
if ( !theTargetObject->IsKind( DynamicType() ) )
if ( !theTargetObject->DynamicType()->SubType( DynamicType() ) )
return IsDone;
// init the copier by labels.
TDF_Label aDataLabel = GetDataLabel();

View File

@@ -51,13 +51,17 @@ static Handle(Standard_Transient) nultrans; // pour retour const&(Null)
void Transfer_TransferIterator::SelectResult
(const Handle(Standard_Type)& atype, const Standard_Boolean keep)
{
Standard_Integer casetype = 0;
if (atype->SubType(STANDARD_TYPE(Standard_Transient))) casetype = 2;
for (Standard_Integer i = theitems->Length(); i > 0; i --) {
Handle(Transfer_Binder) atr = theitems->Value(i);
Handle(Standard_Type) btype = ResultType();
Standard_Boolean matchtype;
if (!atr->HasResult()) matchtype = Standard_False;
else if (atr->IsMultiple()) matchtype = Standard_False;
else matchtype = (btype->SubType(atype));
else if (casetype == 0) matchtype = (atype == btype); // Type fixe
else matchtype = (btype->SubType(atype)); // Dynamique
if (matchtype != keep) {
theselect->SetValue(i,0);
if (themaxi == i) themaxi = i-1;
@@ -150,7 +154,8 @@ static Handle(Standard_Transient) nultrans; // pour retour const&(Null)
Standard_Boolean Transfer_TransferIterator::HasTransientResult () const
{
Handle(Standard_Type) btype = ResultType();
return !btype.IsNull();
if (btype.IsNull()) return Standard_False;
return btype->SubType(STANDARD_TYPE(Standard_Transient));
}
const Handle(Standard_Transient)&

View File

@@ -36,7 +36,7 @@ namespace {
}
IMPLEMENT_DERIVED_ATTRIBUTE(XCAFDoc_NotesTool, TDataStd_GenericEmpty)
IMPLEMENT_DERIVED_ATTRIBUTE(XCAFDoc_NotesTool, XCAFDoc_NoteComment)
enum NotesTool_RootLabels
{

View File

@@ -112,7 +112,8 @@ static const Standard_ExtString voidext = { 0 };
(const Handle(Standard_Transient)& item, const Standard_Boolean nopk) const
{
if (item.IsNull()) return "";
Handle(Standard_Type) atype = item->DynamicType();
DeclareAndCast(Standard_Type,atype,item);
if (atype.IsNull()) atype = item->DynamicType();
Standard_CString tn = atype->Name();
if (!nopk) return tn;
for (int i = 0; tn[i] != '\0'; i ++) {

View File

@@ -46,7 +46,7 @@ Handle(TDF_Attribute) XmlMDataStd_GenericEmptyDriver::NewEmpty() const
//=======================================================================
Handle(Standard_Type) XmlMDataStd_GenericEmptyDriver::SourceType() const
{
return STANDARD_TYPE(TDataStd_GenericEmpty);
return Standard_Type::Instance<TDataStd_GenericEmpty>();
}
//=======================================================================

View File

@@ -48,7 +48,7 @@ Handle(TDF_Attribute) XmlMDataStd_GenericExtStringDriver::NewEmpty () const
//=======================================================================
Handle(Standard_Type) XmlMDataStd_GenericExtStringDriver::SourceType() const
{
return STANDARD_TYPE(TDataStd_GenericExtString);
return Standard_Type::Instance<TDataStd_GenericExtString>();
}
//=======================================================================

11
tests/bugs/xde/bug33616 Normal file
View File

@@ -0,0 +1,11 @@
puts "========"
puts "0033616: Data Exchange - Using filter while reading XBF may result in unresolved links"
puts "========"
pload ALL
XOpen [locate_data_file bug28905_as1-oc-214.xbf] D -read0:1:1:2:1
XGetShape sh D 0:1:1:2:1
checknbshapes sh -solid 1
Close D

View File

@@ -3,12 +3,12 @@ set filename bug29362_MMT200.stp
set ref_data {
NbOfDimensions : 2
NbOfDimensions : 4
NbOfDimensionalSize : 1
NbOfDimensionalLocation: 1
NbOfAngular : 0
NbOfWithPath : 0
NbOfCommonLabels : 0
NbOfCommonLabels : 1
NbOfTolerances : 0
NbOfGTWithModifiers : 0
NbOfGTWithMaxTolerance : 0

92
tests/gdt/import/A6 Normal file
View File

@@ -0,0 +1,92 @@
# !!!! This file is generated automatically, do not edit manually! See end script
set filename bug33661_nist_ftc_08_asme1_ap242-e1-tg.stp
set ref_data {
NbOfDimensions : 60
NbOfTolerances : 0
NbOfDatumFeature : 0
NbOfAttachedDatum : 0
NbOfDatumTarget : 0
0:1:1:2:1 Shape.4
0:1:4:32 Dimension.4.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:1:2:2 Shape.5
0:1:4:4 Dimension.5.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:4:5 Dimension.5.2 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:1:2:4 Shape.7
0:1:4:14 Dimension.7.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:4:18 Dimension.7.2 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:4:20 Dimension.7.3 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:1:2:14 Shape.17
0:1:4:27 Dimension.17.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:1:2:62 Shape.65
0:1:4:35 Dimension.65.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:1:2:65 Shape.68
0:1:4:36 Dimension.68.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:1:2:72 Shape.75
0:1:4:53 Dimension.75.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:1:2:84 Shape.87
0:1:4:54 Dimension.87.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:1:2:90 Shape.93
0:1:4:31 Dimension.93.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:4:33 Dimension.93.2 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:4:34 Dimension.93.3 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:1:2:94 Shape.97
0:1:4:39 Dimension.97.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:4:40 Dimension.97.2 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:4:51 Dimension.97.3 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:4:52 Dimension.97.4 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:4:55 Dimension.97.5 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:1:2:96 Shape.99
0:1:4:43 Dimension.99.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:4:44 Dimension.99.2 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:4:45 Dimension.99.3 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:4:46 Dimension.99.4 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:4:57 Dimension.99.5 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:1:2:98 Shape.101
0:1:4:47 Dimension.101.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:4:48 Dimension.101.2 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:4:49 Dimension.101.3 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:4:50 Dimension.101.4 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:4:56 Dimension.101.5 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:1:2:100 Shape.103
0:1:4:37 Dimension.103.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:4:38 Dimension.103.2 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:4:41 Dimension.103.3 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:4:42 Dimension.103.4 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:4:58 Dimension.103.5 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:1:2:102 Shape.105
0:1:4:25 Dimension.105.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:4:26 Dimension.105.2 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:1:2:116 Shape.119
0:1:4:24 Dimension.119.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:1:2:120 Shape.123
0:1:4:23 Dimension.123.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:1:2:161 Shape.164
0:1:4:15 Dimension.164.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:1:2:179 Shape.182
0:1:4:1 Dimension.182.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:4:2 Dimension.182.2 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:4:3 Dimension.182.3 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:1:2:237 Shape.240
0:1:4:17 Dimension.240.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:4:19 Dimension.240.2 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:1:2:246 Shape.249
0:1:4:6 Dimension.249.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:4:8 Dimension.249.2 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:4:9 Dimension.249.3 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:1:2:248 Shape.251
0:1:4:7 Dimension.251.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:4:10 Dimension.251.2 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:4:11 Dimension.251.3 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:1:2:250 Shape.253
0:1:4:12 Dimension.253.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:4:13 Dimension.253.2 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:1:2:256 Shape.259
0:1:4:28 Dimension.259.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:4:29 Dimension.259.2 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:4:30 Dimension.259.3 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:1:3:1 Shape.276
0:1:4:16 Dimension.276.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
}

View File

@@ -2,7 +2,13 @@
set filename bug29362_MMT200.stp
set ref_data {
Centre of mass: 0 0 0
Mass: 0
Centre of mass: 13.412719368151439 6.1818909424750705 -13.415402720911091
Mass: 252.25931515680639
}
set ref_data_write {
Centre of mass: 13.412719368151233 6.1818909424748316 -13.415402720907935
Mass: 252.25931515678892
}

16
tests/gdt/presentation/C3 Normal file
View File

@@ -0,0 +1,16 @@
# !!!! This file is generated automatically, do not edit manually! See end script
puts "TODO CR11111 ALL: Error on writing file"
set filename bug33661_nist_ftc_08_asme1_ap242-e1-tg.stp
set ref_data {
Centre of mass: -62.99891835601813 78.203476181663817 20.269103705327481
Mass: 47784.542040997127
}
set ref_data_write {
Centre of mass: -261.12759307366923 196.9986700086933 -13.86055926862322
Mass: 17568.06377585962
}