1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-01 17:36:21 +03:00

0026961: Recover possibility to read files in old persistence format

Possibility to read shapes and OCAF documents from old persistence format (Std and StdL schema) is restored.

Test cases used old persistent files on input are restored with suffix "_std"

Removing toolkit from OS package
This commit is contained in:
myn 2016-03-02 23:04:30 +03:00 committed by abv
parent 1d8656890c
commit ff205346c9
115 changed files with 6856 additions and 442 deletions

View File

@ -2,6 +2,6 @@ FoundationClasses TKernel TKMath
ModelingData TKG2d TKG3d TKGeomBase TKBRep
ModelingAlgorithms TKGeomAlgo TKTopAlgo TKPrim TKBO TKBool TKHLR TKFillet TKOffset TKFeat TKMesh TKXMesh TKShHealing
Visualization TKService TKV3d TKOpenGl TKMeshVS TKIVtk TKD3DHost
ApplicationFramework TKCDF TKLCAF TKCAF TKBinL TKXmlL TKBin TKXml TKStdL TKStd TKShape FWOSPlugin TKTObj TKBinTObj TKXmlTObj TKVCAF
ApplicationFramework TKCDF TKLCAF TKCAF TKBinL TKXmlL TKBin TKXml TKStdL TKStd FWOSPlugin TKTObj TKBinTObj TKXmlTObj TKVCAF
DataExchange TKXSBase TKSTEPBase TKSTEPAttr TKSTEP209 TKSTEP TKIGES TKXCAF TKXDEIGES TKXDESTEP TKSTL TKVRML TKXmlXCAF TKBinXCAF
Draw TKDraw TKTopTest TKViewerTest TKXSDRAW TKDCAF TKXDEDRAW TKTObjDRAW TKQADraw TKIVtkDraw DRAWEXE

View File

@ -244,9 +244,11 @@ n CDM
n FWOSDriver
n PCDM
n StdLDrivers
n StdLObject
n StdLPersistent
n StdObjMgt
n StdDrivers
n StdObject
n StdPersistent
n ShapePersistent
n TDF
@ -279,7 +281,6 @@ t TKLCAF
t TKStdL
t TKStd
t TKShape
t TKTObj
t TKXml
t TKXmlL

View File

@ -27,7 +27,6 @@ proc ApplicationFramework:toolkits { } {
FWOSPlugin \
TKStdL \
TKStd \
TKShape \
TKTObj \
TKBinTObj \
TKXmlTObj \

View File

@ -1,3 +1,23 @@
FILES
ShapePersistent.cxx
ShapePersistent.hxx
ShapePersistent_BRep.cxx
ShapePersistent_BRep.hxx
ShapePersistent_Geom.cxx
ShapePersistent_Geom.hxx
ShapePersistent_Geom_Curve.cxx
ShapePersistent_Geom_Curve.hxx
ShapePersistent_Geom_Surface.cxx
ShapePersistent_Geom_Surface.hxx
ShapePersistent_Geom2d.hxx
ShapePersistent_Geom2d_Curve.cxx
ShapePersistent_Geom2d_Curve.hxx
ShapePersistent_HArray1.cxx
ShapePersistent_HArray1.hxx
ShapePersistent_HArray2.cxx
ShapePersistent_HArray2.hxx
ShapePersistent_HSequence.cxx
ShapePersistent_HSequence.hxx
ShapePersistent_Poly.cxx
ShapePersistent_Poly.hxx
ShapePersistent_TopoDS.cxx
ShapePersistent_TopoDS.hxx

View File

@ -14,10 +14,334 @@
#include <ShapePersistent.hxx>
#include <StdObjMgt_MapOfInstantiators.hxx>
#include <StdLPersistent_HArray1.hxx>
#include <StdPersistent_TopoDS.hxx>
#include <ShapePersistent_TopoDS.hxx>
#include <ShapePersistent_HArray1.hxx>
#include <ShapePersistent_HArray2.hxx>
#include <ShapePersistent_HSequence.hxx>
#include <ShapePersistent_Geom2d.hxx>
#include <ShapePersistent_Geom2d_Curve.hxx>
#include <ShapePersistent_Geom.hxx>
#include <ShapePersistent_Geom_Curve.hxx>
#include <ShapePersistent_Geom_Surface.hxx>
#include <ShapePersistent_Poly.hxx>
#include <ShapePersistent_BRep.hxx>
//=======================================================================
//function : BindTypes
//purpose : Register types
//=======================================================================
void ShapePersistent::BindTypes (StdObjMgt_MapOfInstantiators& /*theMap*/)
void ShapePersistent::BindTypes (StdObjMgt_MapOfInstantiators& theMap)
{
theMap.Bind <StdLPersistent_HArray1::Persistent> ("PTopoDS_HArray1OfHShape");
theMap.Bind <ShapePersistent_TopoDS::Shape> ("PTopoDS_HShape");
theMap.Bind <ShapePersistent_TopoDS::Shape> ("PTopoDS_Vertex");
theMap.Bind <ShapePersistent_TopoDS::Shape> ("PTopoDS_Edge");
theMap.Bind <ShapePersistent_TopoDS::Shape> ("PTopoDS_Wire");
theMap.Bind <ShapePersistent_TopoDS::Shape> ("PTopoDS_Face");
theMap.Bind <ShapePersistent_TopoDS::Shape> ("PTopoDS_Shell");
theMap.Bind <ShapePersistent_TopoDS::Shape> ("PTopoDS_Solid");
theMap.Bind <ShapePersistent_TopoDS::Shape> ("PTopoDS_CompSolid");
theMap.Bind <ShapePersistent_TopoDS::Shape> ("PTopoDS_Compound");
theMap.Bind <StdPersistent_TopoDS::TShape> ("PTopoDS_TShape");
theMap.Bind <StdPersistent_TopoDS::TShape> ("PTopoDS_TVertex");
theMap.Bind <StdPersistent_TopoDS::TShape> ("PTopoDS_TVertex1");
theMap.Bind <StdPersistent_TopoDS::TShape> ("PTopoDS_TEdge");
theMap.Bind <StdPersistent_TopoDS::TShape> ("PTopoDS_TEdge1");
theMap.Bind <StdPersistent_TopoDS::TShape> ("PTopoDS_TFace");
theMap.Bind <StdPersistent_TopoDS::TShape> ("PTopoDS_TFace1");
theMap.Bind <ShapePersistent_TopoDS::TWire> ("PTopoDS_TWire");
theMap.Bind <ShapePersistent_TopoDS::TWire1> ("PTopoDS_TWire1");
theMap.Bind <ShapePersistent_TopoDS::TShell> ("PTopoDS_TShell");
theMap.Bind <ShapePersistent_TopoDS::TShell1> ("PTopoDS_TShell1");
theMap.Bind <ShapePersistent_TopoDS::TSolid> ("PTopoDS_TSolid");
theMap.Bind <ShapePersistent_TopoDS::TSolid1> ("PTopoDS_TSolid1");
theMap.Bind <ShapePersistent_TopoDS::TCompSolid> ("PTopoDS_TCompSolid");
theMap.Bind <ShapePersistent_TopoDS::TCompSolid1> ("PTopoDS_TCompSolid1");
theMap.Bind <ShapePersistent_TopoDS::TCompound> ("PTopoDS_TCompound");
theMap.Bind <ShapePersistent_TopoDS::TCompound1> ("PTopoDS_TCompound1");
theMap.Bind <ShapePersistent_HArray1::XYZ> ("PColgp_HArray1OfXYZ");
theMap.Bind <ShapePersistent_HArray1::Pnt> ("PColgp_HArray1OfPnt");
theMap.Bind <ShapePersistent_HArray1::Dir> ("PColgp_HArray1OfDir");
theMap.Bind <ShapePersistent_HArray1::Vec> ("PColgp_HArray1OfVec");
theMap.Bind <ShapePersistent_HArray1::XY> ("PColgp_HArray1OfXY");
theMap.Bind <ShapePersistent_HArray1::Pnt2d> ("PColgp_HArray1OfPnt2d");
theMap.Bind <ShapePersistent_HArray1::Dir2d> ("PColgp_HArray1OfDir2d");
theMap.Bind <ShapePersistent_HArray1::Vec2d> ("PColgp_HArray1OfVec2d");
theMap.Bind <ShapePersistent_HArray1::Lin2d> ("PColgp_HArray1OfLin2d");
theMap.Bind <ShapePersistent_HArray1::Circ2d> ("PColgp_HArray1OfCirc2d");
theMap.Bind <ShapePersistent_HArray1::Triangle> ("PPoly_HArray1OfTriangle");
theMap.Bind <ShapePersistent_HArray2::XYZ> ("PColgp_HArray2OfXYZ");
theMap.Bind <ShapePersistent_HArray2::Pnt> ("PColgp_HArray2OfPnt");
theMap.Bind <ShapePersistent_HArray2::Dir> ("PColgp_HArray2OfDir");
theMap.Bind <ShapePersistent_HArray2::Vec> ("PColgp_HArray2OfVec");
theMap.Bind <ShapePersistent_HArray2::XY> ("PColgp_HArray2OfXY");
theMap.Bind <ShapePersistent_HArray2::Pnt2d> ("PColgp_HArray2OfPnt2d");
theMap.Bind <ShapePersistent_HArray2::Dir2d> ("PColgp_HArray2OfDir2d");
theMap.Bind <ShapePersistent_HArray2::Vec2d> ("PColgp_HArray2OfVec2d");
theMap.Bind <ShapePersistent_HArray2::Lin2d> ("PColgp_HArray2OfLin2d");
theMap.Bind <ShapePersistent_HArray2::Circ2d> ("PColgp_HArray2OfCirc2d");
theMap.Bind <ShapePersistent_HSequence::XYZ> ("PColgp_HSequenceOfXYZ");
theMap.Bind <ShapePersistent_HSequence::Pnt> ("PColgp_HSequenceOfPnt");
theMap.Bind <ShapePersistent_HSequence::Dir> ("PColgp_HSequenceOfDir");
theMap.Bind <ShapePersistent_HSequence::Vec> ("PColgp_HSequenceOfVec");
theMap.Bind <ShapePersistent_HSequence::XYZ::Node>
("PColgp_SeqNodeOfHSequenceOfXYZ");
theMap.Bind <ShapePersistent_HSequence::Pnt::Node>
("PColgp_SeqNodeOfHSequenceOfPnt");
theMap.Bind <ShapePersistent_HSequence::Dir::Node>
("PColgp_SeqNodeOfHSequenceOfDir");
theMap.Bind <ShapePersistent_HSequence::Vec::Node>
("PColgp_SeqNodeOfHSequenceOfVec");
theMap.Bind <ShapePersistent_Geom2d::Transformation>
("PGeom2d_Transformation");
theMap.Bind <ShapePersistent_Geom2d::Geometry>
("PGeom2d_Geometry");
theMap.Bind <ShapePersistent_Geom2d::Point>
("PGeom2d_Point");
theMap.Bind <ShapePersistent_Geom2d::CartesianPoint>
("PGeom2d_CartesianPoint");
theMap.Bind <ShapePersistent_Geom2d::Vector>
("PGeom2d_Vector");
theMap.Bind <ShapePersistent_Geom2d::Direction>
("PGeom2d_Direction");
theMap.Bind <ShapePersistent_Geom2d::VectorWithMagnitude>
("PGeom2d_VectorWithMagnitude");
theMap.Bind <ShapePersistent_Geom2d::AxisPlacement>
("PGeom2d_AxisPlacement");
theMap.Bind <ShapePersistent_Geom2d::Curve>
("PGeom2d_Curve");
theMap.Bind <ShapePersistent_Geom2d_Curve::Line>
("PGeom2d_Line");
theMap.Bind <ShapePersistent_Geom2d_Curve::Conic>
("PGeom2d_Conic");
theMap.Bind <ShapePersistent_Geom2d_Curve::Circle>
("PGeom2d_Circle");
theMap.Bind <ShapePersistent_Geom2d_Curve::Ellipse>
("PGeom2d_Ellipse");
theMap.Bind <ShapePersistent_Geom2d_Curve::Hyperbola>
("PGeom2d_Hyperbola");
theMap.Bind <ShapePersistent_Geom2d_Curve::Parabola>
("PGeom2d_Parabola");
theMap.Bind <ShapePersistent_Geom2d_Curve::Bounded>
("PGeom2d_BoundedCurve");
theMap.Bind <ShapePersistent_Geom2d_Curve::Bezier>
("PGeom2d_BezierCurve");
theMap.Bind <ShapePersistent_Geom2d_Curve::BSpline>
("PGeom2d_BSplineCurve");
theMap.Bind <ShapePersistent_Geom2d_Curve::Trimmed>
("PGeom2d_TrimmedCurve");
theMap.Bind <ShapePersistent_Geom2d_Curve::Offset>
("PGeom2d_OffsetCurve");
theMap.Bind <ShapePersistent_Geom::Transformation>
("PGeom_Transformation");
theMap.Bind <ShapePersistent_Geom::Geometry>
("PGeom_Geometry");
theMap.Bind <ShapePersistent_Geom::Point>
("PGeom_Point");
theMap.Bind <ShapePersistent_Geom::CartesianPoint>
("PGeom_CartesianPoint");
theMap.Bind <ShapePersistent_Geom::Vector>
("PGeom_Vector");
theMap.Bind <ShapePersistent_Geom::Direction>
("PGeom_Direction");
theMap.Bind <ShapePersistent_Geom::VectorWithMagnitude>
("PGeom_VectorWithMagnitude");
theMap.Bind <ShapePersistent_Geom::AxisPlacement>
("PGeom_AxisPlacement");
theMap.Bind <ShapePersistent_Geom::Axis1Placement>
("PGeom_Axis1Placement");
theMap.Bind <ShapePersistent_Geom::Axis2Placement>
("PGeom_Axis2Placement");
theMap.Bind <ShapePersistent_Geom::Curve>
("PGeom_Curve");
theMap.Bind <ShapePersistent_Geom_Curve::Line>
("PGeom_Line");
theMap.Bind <ShapePersistent_Geom_Curve::Conic>
("PGeom_Conic");
theMap.Bind <ShapePersistent_Geom_Curve::Circle>
("PGeom_Circle");
theMap.Bind <ShapePersistent_Geom_Curve::Ellipse>
("PGeom_Ellipse");
theMap.Bind <ShapePersistent_Geom_Curve::Hyperbola>
("PGeom_Hyperbola");
theMap.Bind <ShapePersistent_Geom_Curve::Parabola>
("PGeom_Parabola");
theMap.Bind <ShapePersistent_Geom_Curve::Bounded>
("PGeom_BoundedCurve");
theMap.Bind <ShapePersistent_Geom_Curve::Bezier>
("PGeom_BezierCurve");
theMap.Bind <ShapePersistent_Geom_Curve::BSpline>
("PGeom_BSplineCurve");
theMap.Bind <ShapePersistent_Geom_Curve::Trimmed>
("PGeom_TrimmedCurve");
theMap.Bind <ShapePersistent_Geom_Curve::Offset>
("PGeom_OffsetCurve");
theMap.Bind <ShapePersistent_Geom::Surface>
("PGeom_Surface");
theMap.Bind <ShapePersistent_Geom_Surface::Elementary>
("PGeom_ElementarySurface");
theMap.Bind <ShapePersistent_Geom_Surface::Plane>
("PGeom_Plane");
theMap.Bind <ShapePersistent_Geom_Surface::Conical>
("PGeom_ConicalSurface");
theMap.Bind <ShapePersistent_Geom_Surface::Cylindrical>
("PGeom_CylindricalSurface");
theMap.Bind <ShapePersistent_Geom_Surface::Spherical>
("PGeom_SphericalSurface");
theMap.Bind <ShapePersistent_Geom_Surface::Toroidal>
("PGeom_ToroidalSurface");
theMap.Bind <ShapePersistent_Geom_Surface::Swept>
("PGeom_SweptSurface");
theMap.Bind <ShapePersistent_Geom_Surface::LinearExtrusion>
("PGeom_SurfaceOfLinearExtrusion");
theMap.Bind <ShapePersistent_Geom_Surface::Revolution>
("PGeom_SurfaceOfRevolution");
theMap.Bind <ShapePersistent_Geom_Surface::Bounded>
("PGeom_BoundedSurface");
theMap.Bind <ShapePersistent_Geom_Surface::Bezier>
("PGeom_BezierSurface");
theMap.Bind <ShapePersistent_Geom_Surface::BSpline>
("PGeom_BSplineSurface");
theMap.Bind <ShapePersistent_Geom_Surface::RectangularTrimmed>
("PGeom_RectangularTrimmedSurface");
theMap.Bind <ShapePersistent_Geom_Surface::Offset>
("PGeom_OffsetSurface");
theMap.Bind <ShapePersistent_Poly::Polygon2D>
("PPoly_Polygon2D");
theMap.Bind <ShapePersistent_Poly::Polygon3D>
("PPoly_Polygon3D");
theMap.Bind <ShapePersistent_Poly::PolygonOnTriangulation>
("PPoly_PolygonOnTriangulation");
theMap.Bind <ShapePersistent_Poly::Triangulation>
("PPoly_Triangulation");
theMap.Bind <ShapePersistent_BRep::PointRepresentation>
("PBRep_PointRepresentation");
theMap.Bind <ShapePersistent_BRep::PointOnCurve>
("PBRep_PointOnCurve");
theMap.Bind <ShapePersistent_BRep::PointsOnSurface>
("PBRep_PointsOnSurface");
theMap.Bind <ShapePersistent_BRep::PointOnCurveOnSurface>
("PBRep_PointOnCurveOnSurface");
theMap.Bind <ShapePersistent_BRep::PointOnSurface>
("PBRep_PointOnSurface");
theMap.Bind <ShapePersistent_BRep::CurveRepresentation>
("PBRep_CurveRepresentation");
theMap.Bind <ShapePersistent_BRep::GCurve>
("PBRep_GCurve");
theMap.Bind <ShapePersistent_BRep::Curve3D>
("PBRep_Curve3D");
theMap.Bind <ShapePersistent_BRep::CurveOnSurface>
("PBRep_CurveOnSurface");
theMap.Bind <ShapePersistent_BRep::CurveOnClosedSurface>
("PBRep_CurveOnClosedSurface");
theMap.Bind <ShapePersistent_BRep::Polygon3D>
("PBRep_Polygon3D");
theMap.Bind <ShapePersistent_BRep::PolygonOnTriangulation>
("PBRep_PolygonOnTriangulation");
theMap.Bind <ShapePersistent_BRep::PolygonOnClosedTriangulation>
("PBRep_PolygonOnClosedTriangulation");
theMap.Bind <ShapePersistent_BRep::PolygonOnSurface>
("PBRep_PolygonOnSurface");
theMap.Bind <ShapePersistent_BRep::PolygonOnClosedSurface>
("PBRep_PolygonOnClosedSurface");
theMap.Bind <ShapePersistent_BRep::CurveOn2Surfaces>
("PBRep_CurveOn2Surfaces");
theMap.Bind <ShapePersistent_BRep::TVertex> ("PBRep_TVertex");
theMap.Bind <ShapePersistent_BRep::TVertex1> ("PBRep_TVertex1");
theMap.Bind <ShapePersistent_BRep::TEdge> ("PBRep_TEdge");
theMap.Bind <ShapePersistent_BRep::TEdge1> ("PBRep_TEdge1");
theMap.Bind <ShapePersistent_BRep::TFace> ("PBRep_TFace");
theMap.Bind <ShapePersistent_BRep::TFace1> ("PBRep_TFace1");
}

View File

@ -0,0 +1,392 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <ShapePersistent_BRep.hxx>
#include <BRep_PointOnCurve.hxx>
#include <BRep_PointOnCurveOnSurface.hxx>
#include <BRep_PointOnSurface.hxx>
#include <BRep_Curve3D.hxx>
#include <BRep_CurveOnSurface.hxx>
#include <BRep_CurveOnClosedSurface.hxx>
#include <BRep_Polygon3D.hxx>
#include <BRep_PolygonOnTriangulation.hxx>
#include <BRep_PolygonOnClosedTriangulation.hxx>
#include <BRep_PolygonOnSurface.hxx>
#include <BRep_PolygonOnClosedSurface.hxx>
#include <BRep_CurveOn2Surfaces.hxx>
#include <BRep_TVertex.hxx>
#include <BRep_TEdge.hxx>
#include <BRep_TFace.hxx>
enum
{
ParameterMask = 1,
RangeMask = 2,
DegeneratedMask = 4
};
//=======================================================================
//function : Read
//purpose : Read persistent data from a file
//=======================================================================
void ShapePersistent_BRep::PointRepresentation::Read
(StdObjMgt_ReadData& theReadData)
{ theReadData >> myLocation >> myParameter >> myNext; }
//=======================================================================
//function : Import
//purpose : Import transient object from the persistent data
//=======================================================================
void ShapePersistent_BRep::PointRepresentation::Import
(BRep_ListOfPointRepresentation& thePoints) const
{
thePoints.Clear();
Handle(PointRepresentation) aPoint = this;
for (; aPoint; aPoint = aPoint->myNext)
thePoints.Prepend (aPoint->import());
}
Handle(BRep_PointRepresentation)
ShapePersistent_BRep::PointRepresentation::import() const
{ return NULL; }
void ShapePersistent_BRep::PointOnCurve::Read
(StdObjMgt_ReadData& theReadData)
{
PointRepresentation::Read (theReadData);
theReadData >> myCurve;
}
Handle(BRep_PointRepresentation)
ShapePersistent_BRep::PointOnCurve::import() const
{
if (myCurve.IsNull())
return NULL;
return new BRep_PointOnCurve
(myParameter, myCurve->Import(), myLocation.Import());
}
void ShapePersistent_BRep::PointsOnSurface::Read
(StdObjMgt_ReadData& theReadData)
{
PointRepresentation::Read (theReadData);
theReadData >> mySurface;
}
void ShapePersistent_BRep::PointOnCurveOnSurface::Read
(StdObjMgt_ReadData& theReadData)
{
PointsOnSurface::Read (theReadData);
theReadData >> myPCurve;
}
Handle(BRep_PointRepresentation)
ShapePersistent_BRep::PointOnCurveOnSurface::import() const
{
if (mySurface.IsNull() || myPCurve.IsNull())
return NULL;
return new BRep_PointOnCurveOnSurface
(myParameter, myPCurve->Import(), mySurface->Import(), myLocation.Import());
}
void ShapePersistent_BRep::PointOnSurface::Read
(StdObjMgt_ReadData& theReadData)
{
PointsOnSurface::Read (theReadData);
theReadData >> myParameter2;
}
Handle(BRep_PointRepresentation)
ShapePersistent_BRep::PointOnSurface::import() const
{
if (mySurface.IsNull())
return NULL;
return new BRep_PointOnSurface
(myParameter, myParameter2, mySurface->Import(), myLocation.Import());
}
//=======================================================================
//function : Read
//purpose : Read persistent data from a file
//=======================================================================
void ShapePersistent_BRep::CurveRepresentation::Read
(StdObjMgt_ReadData& theReadData)
{ theReadData >> myLocation >> myNext; }
//=======================================================================
//function : Import
//purpose : Import transient object from the persistent data
//=======================================================================
void ShapePersistent_BRep::CurveRepresentation::Import
(BRep_ListOfCurveRepresentation& theCurves) const
{
theCurves.Clear();
Handle(CurveRepresentation) aCurve = this;
for (; aCurve; aCurve = aCurve->myNext)
theCurves.Prepend (aCurve->import());
}
Handle(BRep_CurveRepresentation)
ShapePersistent_BRep::CurveRepresentation::import() const
{ return NULL; }
void ShapePersistent_BRep::GCurve::Read
(StdObjMgt_ReadData& theReadData)
{
CurveRepresentation::Read (theReadData);
theReadData >> myFirst >> myLast;
}
void ShapePersistent_BRep::Curve3D::Read
(StdObjMgt_ReadData& theReadData)
{
GCurve::Read (theReadData);
theReadData >> myCurve3D;
}
Handle(BRep_CurveRepresentation)
ShapePersistent_BRep::Curve3D::import() const
{
Handle(Geom_Curve) aCurve;
if (myCurve3D)
aCurve = myCurve3D->Import();
Handle(BRep_Curve3D) aRepresentation =
new BRep_Curve3D (aCurve, myLocation.Import());
aRepresentation->SetRange (myFirst, myLast);
return aRepresentation;
}
void ShapePersistent_BRep::CurveOnSurface::Read
(StdObjMgt_ReadData& theReadData)
{
GCurve::Read (theReadData);
theReadData >> myPCurve >> mySurface >> myUV1 >> myUV2;
}
Handle(BRep_CurveRepresentation)
ShapePersistent_BRep::CurveOnSurface::import() const
{
if (myPCurve.IsNull() || mySurface.IsNull())
return NULL;
Handle(BRep_CurveOnSurface) aCurve =
new BRep_CurveOnSurface (myPCurve->Import(),
mySurface->Import(),
myLocation.Import());
aCurve->SetUVPoints (myUV1, myUV2);
aCurve->SetRange (myFirst, myLast);
return aCurve;
}
void ShapePersistent_BRep::CurveOnClosedSurface::Read
(StdObjMgt_ReadData& theReadData)
{
CurveOnSurface::Read (theReadData);
theReadData >> myPCurve2 >> myContinuity >> myUV21 >> myUV22;
}
Handle(BRep_CurveRepresentation)
ShapePersistent_BRep::CurveOnClosedSurface::import() const
{
if (myPCurve.IsNull() || mySurface.IsNull() || myPCurve2.IsNull())
return NULL;
Handle(BRep_CurveOnClosedSurface) aCurve =
new BRep_CurveOnClosedSurface (myPCurve->Import(),
myPCurve2->Import(),
mySurface->Import(),
myLocation.Import(),
myContinuity);
aCurve->SetUVPoints (myUV1 , myUV2 );
aCurve->SetUVPoints2 (myUV21 , myUV22);
aCurve->SetRange (myFirst, myLast);
return aCurve;
}
void ShapePersistent_BRep::Polygon3D::Read
(StdObjMgt_ReadData& theReadData)
{
CurveRepresentation::Read (theReadData);
theReadData >> myPolygon3D;
}
Handle(BRep_CurveRepresentation)
ShapePersistent_BRep::Polygon3D::import() const
{
if (myPolygon3D.IsNull())
return NULL;
return new BRep_Polygon3D (myPolygon3D->Import(), myLocation.Import());
}
void ShapePersistent_BRep::PolygonOnTriangulation::Read
(StdObjMgt_ReadData& theReadData)
{
CurveRepresentation::Read (theReadData);
theReadData >> myPolygon >> myTriangulation;
}
Handle(BRep_CurveRepresentation)
ShapePersistent_BRep::PolygonOnTriangulation::import() const
{
if (myPolygon.IsNull() || myTriangulation.IsNull())
return NULL;
return new BRep_PolygonOnTriangulation (myPolygon->Import(),
myTriangulation->Import(),
myLocation.Import());
}
void ShapePersistent_BRep::PolygonOnClosedTriangulation::Read
(StdObjMgt_ReadData& theReadData)
{
PolygonOnTriangulation::Read (theReadData);
theReadData >> myPolygon2;
}
Handle(BRep_CurveRepresentation)
ShapePersistent_BRep::PolygonOnClosedTriangulation::import() const
{
if (myPolygon.IsNull() || myTriangulation.IsNull() || myPolygon2.IsNull())
return NULL;
return new BRep_PolygonOnClosedTriangulation (myPolygon->Import(),
myPolygon2->Import(),
myTriangulation->Import(),
myLocation.Import());
}
void ShapePersistent_BRep::PolygonOnSurface::Read
(StdObjMgt_ReadData& theReadData)
{
CurveRepresentation::Read (theReadData);
theReadData >> myPolygon2D >> mySurface;
}
Handle(BRep_CurveRepresentation)
ShapePersistent_BRep::PolygonOnSurface::import() const
{
if (myPolygon2D.IsNull() || mySurface.IsNull())
return NULL;
return new BRep_PolygonOnSurface (myPolygon2D->Import(),
mySurface->Import(),
myLocation.Import());
}
void ShapePersistent_BRep::PolygonOnClosedSurface::Read
(StdObjMgt_ReadData& theReadData)
{
PolygonOnSurface::Read (theReadData);
theReadData >> myPolygon2;
}
Handle(BRep_CurveRepresentation)
ShapePersistent_BRep::PolygonOnClosedSurface::import() const
{
if (myPolygon2D.IsNull() || mySurface.IsNull() || myPolygon2.IsNull())
return NULL;
return new BRep_PolygonOnClosedSurface (myPolygon2D->Import(),
myPolygon2->Import(),
mySurface->Import(),
myLocation.Import());
}
void ShapePersistent_BRep::CurveOn2Surfaces::Read
(StdObjMgt_ReadData& theReadData)
{
CurveRepresentation::Read (theReadData);
theReadData >> mySurface >> mySurface2 >> myLocation2 >> myContinuity;
}
Handle(BRep_CurveRepresentation)
ShapePersistent_BRep::CurveOn2Surfaces::import() const
{
if (mySurface.IsNull() || mySurface2.IsNull())
return NULL;
return new BRep_CurveOn2Surfaces (mySurface->Import(),
mySurface2->Import(),
myLocation.Import(),
myLocation2.Import(),
myContinuity);
}
//=======================================================================
//function : createTShape
//purpose : Create transient TShape object
//=======================================================================
Handle(TopoDS_TShape) ShapePersistent_BRep::pTVertex::createTShape() const
{
Handle(BRep_TVertex) aTVertex = new BRep_TVertex;
aTVertex->Tolerance (myTolerance);
aTVertex->Pnt (myPnt);
myPoints->Import (aTVertex->ChangePoints());
return aTVertex;
}
//=======================================================================
//function : createTShape
//purpose : Create transient TShape object
//=======================================================================
Handle(TopoDS_TShape) ShapePersistent_BRep::pTEdge::createTShape() const
{
Handle(BRep_TEdge) aTEdge = new BRep_TEdge;
aTEdge->Tolerance (myTolerance);
aTEdge->SameParameter (myFlags & ParameterMask);
aTEdge->SameRange (myFlags & RangeMask);
aTEdge->Degenerated (myFlags & DegeneratedMask);
myCurves->Import (aTEdge->ChangeCurves());
return aTEdge;
}
//=======================================================================
//function : createTShape
//purpose : Create transient TShape object
//=======================================================================
Handle(TopoDS_TShape) ShapePersistent_BRep::pTFace::createTShape() const
{
Handle(BRep_TFace) aTFace = new BRep_TFace;
aTFace->NaturalRestriction (myNaturalRestriction);
aTFace->Tolerance (myTolerance);
aTFace->Location (myLocation.Import());
if (mySurface)
aTFace->Surface (mySurface->Import());
if (myTriangulation)
aTFace->Triangulation (myTriangulation->Import());
return aTFace;
}

View File

@ -0,0 +1,298 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _ShapePersistent_BRep_HeaderFile
#define _ShapePersistent_BRep_HeaderFile
#include <ShapePersistent_TopoDS.hxx>
#include <ShapePersistent_Geom.hxx>
#include <ShapePersistent_Geom2d.hxx>
#include <ShapePersistent_Poly.hxx>
#include <StdObject_Location.hxx>
#include <StdObject_gp.hxx>
#include <BRep_ListOfPointRepresentation.hxx>
#include <BRep_ListOfCurveRepresentation.hxx>
#include <gp_Pnt.hxx>
#include <gp_Pnt2d.hxx>
#include <GeomAbs_Shape.hxx>
class BRep_PointRepresentation;
class BRep_CurveRepresentation;
class ShapePersistent_BRep : public ShapePersistent_TopoDS
{
public:
class PointRepresentation : public StdObjMgt_Persistent
{
public:
//! Read persistent data from a file.
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
//! Import transient object from the persistent data.
Standard_EXPORT void Import (BRep_ListOfPointRepresentation& thePoints)
const;
protected:
virtual Handle(BRep_PointRepresentation) import() const;
protected:
Object <StdObject_Location> myLocation;
Value <Standard_Real> myParameter;
private:
Reference<PointRepresentation> myNext;
};
class PointOnCurve : public PointRepresentation
{
public:
virtual void Read (StdObjMgt_ReadData& theReadData);
virtual Handle(BRep_PointRepresentation) import() const;
private:
Reference<ShapePersistent_Geom::Curve> myCurve;
};
class PointsOnSurface : public PointRepresentation
{
public:
virtual void Read (StdObjMgt_ReadData& theReadData);
protected:
Reference<ShapePersistent_Geom::Surface> mySurface;
};
class PointOnCurveOnSurface : public PointsOnSurface
{
public:
virtual void Read (StdObjMgt_ReadData& theReadData);
virtual Handle(BRep_PointRepresentation) import() const;
private:
Reference<ShapePersistent_Geom2d::Curve> myPCurve;
};
class PointOnSurface : public PointsOnSurface
{
public:
virtual void Read (StdObjMgt_ReadData& theReadData);
virtual Handle(BRep_PointRepresentation) import() const;
private:
Value<Standard_Real> myParameter2;
};
class CurveRepresentation : public StdObjMgt_Persistent
{
public:
//! Read persistent data from a file.
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
//! Import transient object from the persistent data.
Standard_EXPORT void Import (BRep_ListOfCurveRepresentation& theCurves)
const;
protected:
virtual Handle(BRep_CurveRepresentation) import() const;
protected:
Object<StdObject_Location> myLocation;
private:
Reference<CurveRepresentation> myNext;
};
class GCurve : public CurveRepresentation
{
public:
virtual void Read (StdObjMgt_ReadData& theReadData);
protected:
Value<Standard_Real> myFirst;
Value<Standard_Real> myLast;
};
class Curve3D : public GCurve
{
public:
virtual void Read (StdObjMgt_ReadData& theReadData);
virtual Handle(BRep_CurveRepresentation) import() const;
private:
Reference<ShapePersistent_Geom::Curve> myCurve3D;
};
class CurveOnSurface : public GCurve
{
public:
virtual void Read (StdObjMgt_ReadData& theReadData);
virtual Handle(BRep_CurveRepresentation) import() const;
protected:
Reference<ShapePersistent_Geom2d::Curve> myPCurve;
Reference<ShapePersistent_Geom::Surface> mySurface;
StdObject_gp::Object<gp_Pnt2d> myUV1;
StdObject_gp::Object<gp_Pnt2d> myUV2;
};
class CurveOnClosedSurface : public CurveOnSurface
{
public:
virtual void Read (StdObjMgt_ReadData& theReadData);
virtual Handle(BRep_CurveRepresentation) import() const;
private:
Reference<ShapePersistent_Geom2d::Curve> myPCurve2;
Enum<GeomAbs_Shape> myContinuity;
StdObject_gp::Object<gp_Pnt2d> myUV21;
StdObject_gp::Object<gp_Pnt2d> myUV22;
};
class Polygon3D : public CurveRepresentation
{
public:
virtual void Read (StdObjMgt_ReadData& theReadData);
virtual Handle(BRep_CurveRepresentation) import() const;
private:
Reference<ShapePersistent_Poly::Polygon3D> myPolygon3D;
};
class PolygonOnTriangulation : public CurveRepresentation
{
public:
virtual void Read (StdObjMgt_ReadData& theReadData);
virtual Handle(BRep_CurveRepresentation) import() const;
protected:
Reference<ShapePersistent_Poly::PolygonOnTriangulation> myPolygon;
Reference<ShapePersistent_Poly::Triangulation> myTriangulation;
};
class PolygonOnClosedTriangulation : public PolygonOnTriangulation
{
public:
virtual void Read (StdObjMgt_ReadData& theReadData);
virtual Handle(BRep_CurveRepresentation) import() const;
private:
Reference<ShapePersistent_Poly::PolygonOnTriangulation> myPolygon2;
};
class PolygonOnSurface : public CurveRepresentation
{
public:
virtual void Read (StdObjMgt_ReadData& theReadData);
virtual Handle(BRep_CurveRepresentation) import() const;
protected:
Reference<ShapePersistent_Poly::Polygon2D> myPolygon2D;
Reference<ShapePersistent_Geom::Surface> mySurface;
};
class PolygonOnClosedSurface : public PolygonOnSurface
{
public:
virtual void Read (StdObjMgt_ReadData& theReadData);
virtual Handle(BRep_CurveRepresentation) import() const;
private:
Reference<ShapePersistent_Poly::Polygon2D> myPolygon2;
};
class CurveOn2Surfaces : public CurveRepresentation
{
public:
virtual void Read (StdObjMgt_ReadData& theReadData);
virtual Handle(BRep_CurveRepresentation) import() const;
private:
Reference <ShapePersistent_Geom::Surface> mySurface;
Reference <ShapePersistent_Geom::Surface> mySurface2;
Object <StdObject_Location> myLocation2;
Enum <GeomAbs_Shape> myContinuity;
};
private:
class pTVertex : public pTBase
{
public:
inline void Read (StdObjMgt_ReadData& theReadData)
{
pTBase::Read (theReadData);
theReadData >> myTolerance >> myPnt >> myPoints;
}
private:
virtual Handle(TopoDS_TShape) createTShape() const;
private:
Value<Standard_Real> myTolerance;
StdObject_gp::Object<gp_Pnt> myPnt;
Reference<PointRepresentation> myPoints;
};
class pTEdge : public pTBase
{
public:
inline void Read (StdObjMgt_ReadData& theReadData)
{
pTBase::Read (theReadData);
theReadData >> myTolerance >> myFlags >> myCurves;
}
private:
virtual Handle(TopoDS_TShape) createTShape() const;
private:
Value <Standard_Real> myTolerance;
Value <Standard_Integer> myFlags;
Reference <CurveRepresentation> myCurves;
};
class pTFace : public pTBase
{
public:
inline void Read (StdObjMgt_ReadData& theReadData)
{
pTBase::Read (theReadData);
theReadData >> mySurface >> myTriangulation >> myLocation;
theReadData >> myTolerance >> myNaturalRestriction;
}
private:
virtual Handle(TopoDS_TShape) createTShape() const;
private:
Reference <ShapePersistent_Geom::Surface> mySurface;
Reference <ShapePersistent_Poly::Triangulation> myTriangulation;
Object <StdObject_Location> myLocation;
Value <Standard_Real> myTolerance;
Value <Standard_Boolean> myNaturalRestriction;
};
public:
typedef tObject <pTVertex> TVertex;
typedef tObject <pTEdge> TEdge;
typedef tObject <pTFace> TFace;
typedef tObject1 <pTVertex> TVertex1;
typedef tObject1 <pTEdge> TEdge1;
typedef tObject1 <pTFace> TFace1;
};
#endif

View File

@ -11,33 +11,30 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <StdLPersistent_PDataStd_Name.hxx>
#include <StdLPersistent_PCollection_HExtendedString.hxx>
#include <ShapePersistent_Geom.hxx>
#include <StdObjMgt_ReadData.hxx>
#include <TCollection_HExtendedString.hxx>
#include <TDataStd_Name.hxx>
//=======================================================================
//function : Read
//purpose : Read persistent data from a file
//=======================================================================
void StdLPersistent_PDataStd_Name::Read (StdObjMgt_ReadData& theReadData)
{
theReadData >> myString;
}
void ShapePersistent_Geom::Geometry::Read (StdObjMgt_ReadData&) {}
//=======================================================================
//function : ImportAttribute
//purpose : Import transient attribuite from the persistent data
//function : Read
//purpose : Read persistent data from a file
//=======================================================================
Handle(TDF_Attribute) StdLPersistent_PDataStd_Name::ImportAttribute() const
template<>
void ShapePersistent_Geom::instance<ShapePersistent_Geom::AxisPlacement,
Geom_Axis2Placement>
::Read (StdObjMgt_ReadData& theReadData)
{
if (myString.IsNull() || myString->Value().IsNull())
return NULL;
StdObject_gp::Object<gp_Ax1> anAxis;
StdObject_gp::Object<gp_Dir> anXDirection;
Handle(TDataStd_Name) aName = new TDataStd_Name;
aName->Set (myString->Value()->String());
return aName;
theReadData >> anAxis >> anXDirection;
myTransient = new Geom_Axis2Placement (anAxis.Location(),
anAxis.Direction(),
anXDirection);
}

View File

@ -0,0 +1,101 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _ShapePersistent_Geom_HeaderFile
#define _ShapePersistent_Geom_HeaderFile
#include <StdObjMgt_SharedObject.hxx>
#include <StdObject_gp.hxx>
#include <Geom_CartesianPoint.hxx>
#include <Geom_Direction.hxx>
#include <Geom_VectorWithMagnitude.hxx>
#include <Geom_Axis1Placement.hxx>
#include <Geom_Axis2Placement.hxx>
#include <Geom_Transformation.hxx>
#include <Geom_Curve.hxx>
#include <Geom_Surface.hxx>
class ShapePersistent_Geom : protected StdObjMgt_SharedObject
{
public:
class Geometry : public StdObjMgt_Persistent
{
public:
//! Read persistent data from a file.
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
};
protected:
template <class Transient>
struct geometryBase : DelayedBase<Geometry, Transient> {};
template <class Base, class PData>
class subBase : public Base
{
public:
//! Read persistent data from a file.
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData)
{ PData().Read (theReadData); }
};
template <class Base, class GpData>
struct subBase_gp : subBase <Base, StdObject_gp::Object<GpData> > {};
template <class Base>
struct subBase_empty : Base {};
template <class Base, class Target, class Data = void>
class instance : public Base
{
public:
//! Read persistent data from a file.
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData)
{
StdObject_gp::Object<Data> aData;
theReadData >> aData;
this->myTransient = new Target (aData);
}
};
private:
typedef geometryBase<Geom_Geometry> basic;
public:
typedef subBase_empty<basic> Point;
typedef instance<Point, Geom_CartesianPoint, gp_Pnt> CartesianPoint;
typedef subBase_gp<basic, gp_Vec> Vector;
typedef instance<Vector, Geom_Direction , gp_Dir> Direction;
typedef instance<Vector, Geom_VectorWithMagnitude, gp_Vec> VectorWithMagnitude;
typedef subBase_gp<basic, gp_Ax1> AxisPlacement;
typedef instance<AxisPlacement, Geom_Axis1Placement, gp_Ax1> Axis1Placement;
typedef instance<AxisPlacement, Geom_Axis2Placement> Axis2Placement;
typedef instance <SharedBase<Geom_Transformation>,
Geom_Transformation,
gp_Trsf> Transformation;
typedef geometryBase<Geom_Curve> Curve;
typedef geometryBase<Geom_Surface> Surface;
};
template<>
void ShapePersistent_Geom::instance<ShapePersistent_Geom::AxisPlacement,
Geom_Axis2Placement>
::Read (StdObjMgt_ReadData& theReadData);
#endif

View File

@ -0,0 +1,51 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _ShapePersistent_Geom2d_HeaderFile
#define _ShapePersistent_Geom2d_HeaderFile
#include <ShapePersistent_Geom.hxx>
#include <Geom2d_CartesianPoint.hxx>
#include <Geom2d_Direction.hxx>
#include <Geom2d_VectorWithMagnitude.hxx>
#include <Geom2d_AxisPlacement.hxx>
#include <Geom2d_Transformation.hxx>
#include <Geom2d_Curve.hxx>
class ShapePersistent_Geom2d : protected ShapePersistent_Geom
{
typedef geometryBase<Geom2d_Geometry> basic;
public:
typedef ShapePersistent_Geom::Geometry Geometry;
typedef subBase_empty<basic> Point;
typedef instance<Point, Geom2d_CartesianPoint, gp_Pnt2d> CartesianPoint;
typedef subBase_gp<basic, gp_Vec2d> Vector;
typedef instance<Vector, Geom2d_Direction , gp_Dir2d> Direction;
typedef instance<Vector, Geom2d_VectorWithMagnitude, gp_Vec2d> VectorWithMagnitude;
typedef instance<basic, Geom2d_AxisPlacement, gp_Ax2d> AxisPlacement;
typedef instance <SharedBase<Geom2d_Transformation>,
Geom2d_Transformation,
gp_Trsf2d> Transformation;
typedef geometryBase<Geom2d_Curve> Curve;
};
#endif

View File

@ -0,0 +1,76 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <ShapePersistent_Geom2d_Curve.hxx>
#include <Geom2d_BezierCurve.hxx>
#include <Geom2d_BSplineCurve.hxx>
#include <Geom2d_TrimmedCurve.hxx>
#include <Geom2d_OffsetCurve.hxx>
Handle(Geom2d_Curve) ShapePersistent_Geom2d_Curve::pBezier::Import() const
{
if (myPoles.IsNull())
return NULL;
if (myRational)
{
if (myWeights.IsNull())
return NULL;
return new Geom2d_BezierCurve (*myPoles->Array(), *myWeights->Array());
}
else
return new Geom2d_BezierCurve (*myPoles->Array());
}
Handle(Geom2d_Curve) ShapePersistent_Geom2d_Curve::pBSpline::Import() const
{
if (myPoles.IsNull() || myKnots.IsNull() || myMultiplicities.IsNull())
return NULL;
if (myRational)
{
if (myWeights.IsNull())
return NULL;
return new Geom2d_BSplineCurve (*myPoles->Array(),
*myWeights->Array(),
*myKnots->Array(),
*myMultiplicities->Array(),
mySpineDegree,
myPeriodic);
}
else
return new Geom2d_BSplineCurve (*myPoles->Array(),
*myKnots->Array(),
*myMultiplicities->Array(),
mySpineDegree,
myPeriodic);
}
Handle(Geom2d_Curve) ShapePersistent_Geom2d_Curve::pTrimmed::Import() const
{
if (myBasisCurve.IsNull())
return NULL;
return new Geom2d_TrimmedCurve (myBasisCurve->Import(), myFirstU, myLastU);
}
Handle(Geom2d_Curve) ShapePersistent_Geom2d_Curve::pOffset::Import() const
{
if (myBasisCurve.IsNull())
return NULL;
return new Geom2d_OffsetCurve (myBasisCurve->Import(), myOffsetValue);
}

View File

@ -0,0 +1,119 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _ShapePersistent_Geom2d_Curve_HeaderFile
#define _ShapePersistent_Geom2d_Curve_HeaderFile
#include <ShapePersistent_Geom2d.hxx>
#include <ShapePersistent_HArray1.hxx>
#include <StdLPersistent_HArray1.hxx>
#include <Geom2d_Line.hxx>
#include <Geom2d_Circle.hxx>
#include <Geom2d_Ellipse.hxx>
#include <Geom2d_Hyperbola.hxx>
#include <Geom2d_Parabola.hxx>
#include <gp_Circ2d.hxx>
#include <gp_Elips2d.hxx>
#include <gp_Hypr2d.hxx>
#include <gp_Parab2d.hxx>
class ShapePersistent_Geom2d_Curve : protected ShapePersistent_Geom2d
{
typedef Curve::PersistentBase pBase;
typedef pBase pBounded;
class pBezier : public pBounded
{
public:
inline void Read (StdObjMgt_ReadData& theReadData)
{ theReadData >> myRational >> myPoles >> myWeights; }
virtual Handle(Geom2d_Curve) Import() const;
private:
Value <Standard_Boolean> myRational;
Reference <ShapePersistent_HArray1::Pnt2d> myPoles;
Reference <StdLPersistent_HArray1::Real> myWeights;
};
class pBSpline : public pBounded
{
public:
inline void Read (StdObjMgt_ReadData& theReadData)
{
theReadData >> myRational >> myPeriodic >> mySpineDegree;
theReadData >> myPoles >> myWeights >> myKnots >> myMultiplicities;
}
virtual Handle(Geom2d_Curve) Import() const;
private:
Value <Standard_Boolean> myRational;
Value <Standard_Boolean> myPeriodic;
Value <Standard_Integer> mySpineDegree;
Reference <ShapePersistent_HArray1::Pnt2d> myPoles;
Reference <StdLPersistent_HArray1::Real> myWeights;
Reference <StdLPersistent_HArray1::Real> myKnots;
Reference <StdLPersistent_HArray1::Integer> myMultiplicities;
};
class pTrimmed : public pBounded
{
public:
inline void Read (StdObjMgt_ReadData& theReadData)
{ theReadData >> myBasisCurve >> myFirstU >> myLastU; }
virtual Handle(Geom2d_Curve) Import() const;
private:
Reference<Curve> myBasisCurve;
Value<Standard_Real> myFirstU;
Value<Standard_Real> myLastU;
};
class pOffset : public pBase
{
public:
inline void Read (StdObjMgt_ReadData& theReadData)
{ theReadData >> myBasisCurve >> myOffsetValue; }
virtual Handle(Geom2d_Curve) Import() const;
private:
Reference<Curve> myBasisCurve;
Value<Standard_Real> myOffsetValue;
};
public:
typedef instance<Curve, Geom2d_Line, gp_Ax2d> Line;
typedef subBase_gp<Curve, gp_Ax22d> Conic;
typedef instance<Conic, Geom2d_Circle , gp_Circ2d > Circle;
typedef instance<Conic, Geom2d_Ellipse , gp_Elips2d> Ellipse;
typedef instance<Conic, Geom2d_Hyperbola, gp_Hypr2d > Hyperbola;
typedef instance<Conic, Geom2d_Parabola , gp_Parab2d> Parabola;
typedef subBase_empty<Curve> Bounded;
typedef Delayed<Bounded, pBezier> Bezier;
typedef Delayed<Bounded, pBSpline> BSpline;
typedef Delayed<Bounded, pTrimmed> Trimmed;
typedef Delayed<Curve, pOffset> Offset;
};
#endif

View File

@ -0,0 +1,77 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <ShapePersistent_Geom_Curve.hxx>
#include <Geom_BezierCurve.hxx>
#include <Geom_BSplineCurve.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <Geom_OffsetCurve.hxx>
Handle(Geom_Curve) ShapePersistent_Geom_Curve::pBezier::Import() const
{
if (myPoles.IsNull())
return NULL;
if (myRational)
{
if (myWeights.IsNull())
return NULL;
return new Geom_BezierCurve (*myPoles->Array(), *myWeights->Array());
}
else
return new Geom_BezierCurve (*myPoles->Array());
}
Handle(Geom_Curve) ShapePersistent_Geom_Curve::pBSpline::Import() const
{
if (myPoles.IsNull() || myKnots.IsNull() || myMultiplicities.IsNull())
return NULL;
if (myRational)
{
if (myWeights.IsNull())
return NULL;
return new Geom_BSplineCurve (*myPoles->Array(),
*myWeights->Array(),
*myKnots->Array(),
*myMultiplicities->Array(),
mySpineDegree,
myPeriodic);
}
else
return new Geom_BSplineCurve (*myPoles->Array(),
*myKnots->Array(),
*myMultiplicities->Array(),
mySpineDegree,
myPeriodic);
}
Handle(Geom_Curve) ShapePersistent_Geom_Curve::pTrimmed::Import() const
{
if (myBasisCurve.IsNull())
return NULL;
return new Geom_TrimmedCurve (myBasisCurve->Import(), myFirstU, myLastU);
}
Handle(Geom_Curve) ShapePersistent_Geom_Curve::pOffset::Import() const
{
if (myBasisCurve.IsNull())
return NULL;
return new Geom_OffsetCurve
(myBasisCurve->Import(), myOffsetValue, myOffsetDirection);
}

View File

@ -0,0 +1,122 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _ShapePersistent_Geom_Curve_HeaderFile
#define _ShapePersistent_Geom_Curve_HeaderFile
#include <ShapePersistent_Geom.hxx>
#include <ShapePersistent_HArray1.hxx>
#include <StdLPersistent_HArray1.hxx>
#include <Geom_Line.hxx>
#include <Geom_Circle.hxx>
#include <Geom_Ellipse.hxx>
#include <Geom_Hyperbola.hxx>
#include <Geom_Parabola.hxx>
#include <gp_Circ.hxx>
#include <gp_Elips.hxx>
#include <gp_Hypr.hxx>
#include <gp_Parab.hxx>
class gp_Dir;
class ShapePersistent_Geom_Curve : private ShapePersistent_Geom
{
typedef Curve::PersistentBase pBase;
typedef pBase pBounded;
class pBezier : public pBounded
{
public:
inline void Read (StdObjMgt_ReadData& theReadData)
{ theReadData >> myRational >> myPoles >> myWeights; }
virtual Handle(Geom_Curve) Import() const;
private:
Value <Standard_Boolean> myRational;
Reference <ShapePersistent_HArray1::Pnt> myPoles;
Reference <StdLPersistent_HArray1::Real> myWeights;
};
class pBSpline : public pBounded
{
public:
inline void Read (StdObjMgt_ReadData& theReadData)
{
theReadData >> myRational >> myPeriodic >> mySpineDegree;
theReadData >> myPoles >> myWeights >> myKnots >> myMultiplicities;
}
virtual Handle(Geom_Curve) Import() const;
private:
Value <Standard_Boolean> myRational;
Value <Standard_Boolean> myPeriodic;
Value <Standard_Integer> mySpineDegree;
Reference <ShapePersistent_HArray1::Pnt> myPoles;
Reference <StdLPersistent_HArray1::Real> myWeights;
Reference <StdLPersistent_HArray1::Real> myKnots;
Reference <StdLPersistent_HArray1::Integer> myMultiplicities;
};
class pTrimmed : public pBounded
{
public:
inline void Read (StdObjMgt_ReadData& theReadData)
{ theReadData >> myBasisCurve >> myFirstU >> myLastU; }
virtual Handle(Geom_Curve) Import() const;
private:
Reference<Curve> myBasisCurve;
Value<Standard_Real> myFirstU;
Value<Standard_Real> myLastU;
};
class pOffset : public pBase
{
public:
inline void Read (StdObjMgt_ReadData& theReadData)
{ theReadData >> myBasisCurve >> myOffsetDirection >> myOffsetValue; }
virtual Handle(Geom_Curve) Import() const;
private:
Reference<Curve> myBasisCurve;
StdObject_gp::Object<gp_Dir> myOffsetDirection;
Value<Standard_Real> myOffsetValue;
};
public:
typedef instance<Curve, Geom_Line, gp_Ax1> Line;
typedef subBase_gp<Curve, gp_Ax2> Conic;
typedef instance<Conic, Geom_Circle , gp_Circ > Circle;
typedef instance<Conic, Geom_Ellipse , gp_Elips> Ellipse;
typedef instance<Conic, Geom_Hyperbola, gp_Hypr > Hyperbola;
typedef instance<Conic, Geom_Parabola , gp_Parab> Parabola;
typedef subBase_empty<Curve> Bounded;
typedef Delayed<Bounded, pBezier> Bezier;
typedef Delayed<Bounded, pBSpline> BSpline;
typedef Delayed<Bounded, pTrimmed> Trimmed;
typedef Delayed<Curve, pOffset> Offset;
};
#endif

View File

@ -0,0 +1,110 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <ShapePersistent_Geom_Surface.hxx>
#include <Geom_SurfaceOfLinearExtrusion.hxx>
#include <Geom_SurfaceOfRevolution.hxx>
#include <Geom_BezierSurface.hxx>
#include <Geom_BSplineSurface.hxx>
#include <Geom_RectangularTrimmedSurface.hxx>
#include <Geom_OffsetSurface.hxx>
#include <gp_Ax1.hxx>
Handle(Geom_Surface) ShapePersistent_Geom_Surface::pLinearExtrusion::Import()
const
{
if (myBasisCurve.IsNull())
return NULL;
return new Geom_SurfaceOfLinearExtrusion
(myBasisCurve->Import(), myDirection);
}
Handle(Geom_Surface) ShapePersistent_Geom_Surface::pRevolution::Import() const
{
if (myBasisCurve.IsNull())
return NULL;
return new Geom_SurfaceOfRevolution
(myBasisCurve->Import(), gp_Ax1 (myLocation, myDirection));
}
Handle(Geom_Surface) ShapePersistent_Geom_Surface::pBezier::Import() const
{
if (myPoles.IsNull())
return NULL;
if (myURational || myVRational)
{
if (myWeights.IsNull())
return NULL;
return new Geom_BezierSurface (*myPoles->Array(), *myWeights->Array());
}
else
return new Geom_BezierSurface (*myPoles->Array());
}
Handle(Geom_Surface) ShapePersistent_Geom_Surface::pBSpline::Import() const
{
if (myPoles.IsNull() || myUKnots.IsNull() || myVKnots.IsNull()
|| myUMultiplicities.IsNull() || myVMultiplicities.IsNull())
return NULL;
if (myURational || myVRational)
{
if (myWeights.IsNull())
return NULL;
return new Geom_BSplineSurface (*myPoles->Array(),
*myWeights->Array(),
*myUKnots->Array(),
*myVKnots->Array(),
*myUMultiplicities->Array(),
*myVMultiplicities->Array(),
myUSpineDegree,
myVSpineDegree,
myUPeriodic,
myVPeriodic);
}
else
return new Geom_BSplineSurface (*myPoles->Array(),
*myUKnots->Array(),
*myVKnots->Array(),
*myUMultiplicities->Array(),
*myVMultiplicities->Array(),
myUSpineDegree,
myVSpineDegree,
myUPeriodic,
myVPeriodic);
}
Handle(Geom_Surface) ShapePersistent_Geom_Surface::pRectangularTrimmed::Import()
const
{
if (myBasisSurface.IsNull())
return NULL;
return new Geom_RectangularTrimmedSurface
(myBasisSurface->Import(), myFirstU, myLastU, myFirstV, myLastV);
}
Handle(Geom_Surface) ShapePersistent_Geom_Surface::pOffset::Import() const
{
if (myBasisSurface.IsNull())
return NULL;
return new Geom_OffsetSurface (myBasisSurface->Import(), myOffsetValue);
}

View File

@ -0,0 +1,177 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _ShapePersistent_Geom_Surface_HeaderFile
#define _ShapePersistent_Geom_Surface_HeaderFile
#include <ShapePersistent_Geom.hxx>
#include <ShapePersistent_HArray2.hxx>
#include <StdLPersistent_HArray1.hxx>
#include <StdLPersistent_HArray2.hxx>
#include <Geom_Plane.hxx>
#include <Geom_ConicalSurface.hxx>
#include <Geom_CylindricalSurface.hxx>
#include <Geom_SphericalSurface.hxx>
#include <Geom_ToroidalSurface.hxx>
#include <gp_Ax3.hxx>
#include <gp_Cone.hxx>
#include <gp_Cylinder.hxx>
#include <gp_Sphere.hxx>
#include <gp_Torus.hxx>
class gp_Dir;
class gp_Pnt;
class ShapePersistent_Geom_Surface : private ShapePersistent_Geom
{
typedef Surface::PersistentBase pBase;
class pSweptData : protected StdObjMgt_ContentTypes
{
public:
inline void Read (StdObjMgt_ReadData& theReadData)
{ theReadData >> myBasisCurve >> myDirection; }
protected:
Reference <Curve> myBasisCurve;
StdObject_gp::Object <gp_Dir> myDirection;
};
struct pSwept : pBase, pSweptData {};
class pLinearExtrusion : public pSwept
{
public:
virtual Handle(Geom_Surface) Import() const;
};
class pRevolution : public pSwept
{
public:
inline void Read (StdObjMgt_ReadData& theReadData)
{
pSwept::Read (theReadData);
theReadData >> myLocation;
}
virtual Handle(Geom_Surface) Import() const;
private:
StdObject_gp::Object<gp_Pnt> myLocation;
};
typedef pBase pBounded;
class pBezier : public pBounded
{
public:
inline void Read (StdObjMgt_ReadData& theReadData)
{ theReadData >> myURational >> myVRational >> myPoles >> myWeights; }
virtual Handle(Geom_Surface) Import() const;
private:
Value <Standard_Boolean> myURational;
Value <Standard_Boolean> myVRational;
Reference <ShapePersistent_HArray2::Pnt> myPoles;
Reference <StdLPersistent_HArray2::Real> myWeights;
};
class pBSpline : public pBounded
{
public:
inline void Read (StdObjMgt_ReadData& theReadData)
{
theReadData >> myURational >> myVRational;
theReadData >> myUPeriodic >> myVPeriodic;
theReadData >> myUSpineDegree >> myVSpineDegree;
theReadData >> myPoles;
theReadData >> myWeights;
theReadData >> myUKnots >> myVKnots;
theReadData >> myUMultiplicities >> myVMultiplicities;
}
virtual Handle(Geom_Surface) Import() const;
private:
Value <Standard_Boolean> myURational;
Value <Standard_Boolean> myVRational;
Value <Standard_Boolean> myUPeriodic;
Value <Standard_Boolean> myVPeriodic;
Value <Standard_Integer> myUSpineDegree;
Value <Standard_Integer> myVSpineDegree;
Reference <ShapePersistent_HArray2::Pnt> myPoles;
Reference <StdLPersistent_HArray2::Real> myWeights;
Reference <StdLPersistent_HArray1::Real> myUKnots;
Reference <StdLPersistent_HArray1::Real> myVKnots;
Reference <StdLPersistent_HArray1::Integer> myUMultiplicities;
Reference <StdLPersistent_HArray1::Integer> myVMultiplicities;
};
class pRectangularTrimmed : public pBounded
{
public:
inline void Read (StdObjMgt_ReadData& theReadData)
{
theReadData >> myBasisSurface;
theReadData >> myFirstU >> myLastU >> myFirstV >> myLastV;
}
virtual Handle(Geom_Surface) Import() const;
private:
Reference<Surface> myBasisSurface;
Value<Standard_Real> myFirstU;
Value<Standard_Real> myLastU;
Value<Standard_Real> myFirstV;
Value<Standard_Real> myLastV;
};
class pOffset : public pBase
{
public:
inline void Read (StdObjMgt_ReadData& theReadData)
{ theReadData >> myBasisSurface >> myOffsetValue; }
virtual Handle(Geom_Surface) Import() const;
private:
Reference<Surface> myBasisSurface;
Value<Standard_Real> myOffsetValue;
};
public:
typedef subBase_gp<Surface, gp_Ax3> Elementary;
typedef instance<Elementary, Geom_Plane , gp_Ax3> Plane;
typedef instance<Elementary, Geom_ConicalSurface , gp_Cone> Conical;
typedef instance<Elementary, Geom_CylindricalSurface, gp_Cylinder> Cylindrical;
typedef instance<Elementary, Geom_SphericalSurface , gp_Sphere> Spherical;
typedef instance<Elementary, Geom_ToroidalSurface , gp_Torus> Toroidal;
typedef subBase<Surface, pSweptData> Swept;
typedef Delayed<Swept, pLinearExtrusion> LinearExtrusion;
typedef Delayed<Swept, pRevolution> Revolution;
typedef subBase_empty<Surface> Bounded;
typedef Delayed<Bounded, pBezier> Bezier;
typedef Delayed<Bounded, pBSpline> BSpline;
typedef Delayed<Bounded, pRectangularTrimmed> RectangularTrimmed;
typedef Delayed<Surface, pOffset> Offset;
};
#endif

View File

@ -0,0 +1,45 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <ShapePersistent_HArray1.hxx>
#include <StdObjMgt_ReadData.hxx>
#include <StdObject_gp.hxx>
template <class ArrayClass>
void ShapePersistent_HArray1::instance<ArrayClass>::readValue
(StdObjMgt_ReadData& theReadData, const Standard_Integer theIndex)
{
theReadData.ReadObject (StdObject_gp::Ref (this->myArray->ChangeValue (theIndex)));
}
template<>
void ShapePersistent_HArray1::instance<Poly_HArray1OfTriangle>::readValue
(StdObjMgt_ReadData& theReadData, const Standard_Integer theIndex)
{
Value<Standard_Integer> N1, N2, N3;
theReadData >> N1 >> N2 >> N3;
this->myArray->ChangeValue (theIndex).Set (N1, N2, N3);
}
template class ShapePersistent_HArray1::instance<TColgp_HArray1OfXYZ>;
template class ShapePersistent_HArray1::instance<TColgp_HArray1OfPnt>;
template class ShapePersistent_HArray1::instance<TColgp_HArray1OfDir>;
template class ShapePersistent_HArray1::instance<TColgp_HArray1OfVec>;
template class ShapePersistent_HArray1::instance<TColgp_HArray1OfXY>;
template class ShapePersistent_HArray1::instance<TColgp_HArray1OfPnt2d>;
template class ShapePersistent_HArray1::instance<TColgp_HArray1OfDir2d>;
template class ShapePersistent_HArray1::instance<TColgp_HArray1OfVec2d>;
template class ShapePersistent_HArray1::instance<TColgp_HArray1OfLin2d>;
template class ShapePersistent_HArray1::instance<TColgp_HArray1OfCirc2d>;
template class ShapePersistent_HArray1::instance<Poly_HArray1OfTriangle>;

View File

@ -0,0 +1,56 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _ShapePersistent_HArray1_HeaderFile
#define _ShapePersistent_HArray1_HeaderFile
#include <StdLPersistent_HArray1.hxx>
#include <TColgp_HArray1OfXYZ.hxx>
#include <TColgp_HArray1OfPnt.hxx>
#include <TColgp_HArray1OfDir.hxx>
#include <TColgp_HArray1OfVec.hxx>
#include <TColgp_HArray1OfXY.hxx>
#include <TColgp_HArray1OfPnt2d.hxx>
#include <TColgp_HArray1OfDir2d.hxx>
#include <TColgp_HArray1OfVec2d.hxx>
#include <TColgp_HArray1OfLin2d.hxx>
#include <TColgp_HArray1OfCirc2d.hxx>
#include <Poly_HArray1OfTriangle.hxx>
class ShapePersistent_HArray1 : private StdLPersistent_HArray1
{
template <class ArrayClass>
class instance : public StdLPersistent_HArray1::base<ArrayClass>
{
virtual void readValue (StdObjMgt_ReadData& theReadData,
const Standard_Integer theIndex);
};
public:
typedef instance<TColgp_HArray1OfXYZ> XYZ;
typedef instance<TColgp_HArray1OfPnt> Pnt;
typedef instance<TColgp_HArray1OfDir> Dir;
typedef instance<TColgp_HArray1OfVec> Vec;
typedef instance<TColgp_HArray1OfXY> XY;
typedef instance<TColgp_HArray1OfPnt2d> Pnt2d;
typedef instance<TColgp_HArray1OfDir2d> Dir2d;
typedef instance<TColgp_HArray1OfVec2d> Vec2d;
typedef instance<TColgp_HArray1OfLin2d> Lin2d;
typedef instance<TColgp_HArray1OfCirc2d> Circ2d;
typedef instance<Poly_HArray1OfTriangle> Triangle;
};
#endif

View File

@ -0,0 +1,38 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <ShapePersistent_HArray2.hxx>
#include <StdObjMgt_ReadData.hxx>
#include <StdObject_gp.hxx>
template <class ArrayClass>
void ShapePersistent_HArray2::instance<ArrayClass>::readValue (
StdObjMgt_ReadData& theReadData,
const Standard_Integer theRow,
const Standard_Integer theCol)
{
theReadData.ReadObject (
StdObject_gp::Ref (this->myArray->ChangeValue (theRow, theCol)));
}
template class ShapePersistent_HArray2::instance<TColgp_HArray2OfXYZ>;
template class ShapePersistent_HArray2::instance<TColgp_HArray2OfPnt>;
template class ShapePersistent_HArray2::instance<TColgp_HArray2OfDir>;
template class ShapePersistent_HArray2::instance<TColgp_HArray2OfVec>;
template class ShapePersistent_HArray2::instance<TColgp_HArray2OfXY>;
template class ShapePersistent_HArray2::instance<TColgp_HArray2OfPnt2d>;
template class ShapePersistent_HArray2::instance<TColgp_HArray2OfDir2d>;
template class ShapePersistent_HArray2::instance<TColgp_HArray2OfVec2d>;
template class ShapePersistent_HArray2::instance<TColgp_HArray2OfLin2d>;
template class ShapePersistent_HArray2::instance<TColgp_HArray2OfCirc2d>;

View File

@ -0,0 +1,55 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _ShapePersistent_HArray2_HeaderFile
#define _ShapePersistent_HArray2_HeaderFile
#include <StdLPersistent_HArray2.hxx>
#include <TColgp_HArray2OfXYZ.hxx>
#include <TColgp_HArray2OfPnt.hxx>
#include <TColgp_HArray2OfDir.hxx>
#include <TColgp_HArray2OfVec.hxx>
#include <TColgp_HArray2OfXY.hxx>
#include <TColgp_HArray2OfPnt2d.hxx>
#include <TColgp_HArray2OfDir2d.hxx>
#include <TColgp_HArray2OfVec2d.hxx>
#include <TColgp_HArray2OfLin2d.hxx>
#include <TColgp_HArray2OfCirc2d.hxx>
class ShapePersistent_HArray2 : private StdLPersistent_HArray2
{
template <class ArrayClass>
class instance : public StdLPersistent_HArray2::base<ArrayClass>
{
virtual void readValue (StdObjMgt_ReadData& theReadData,
const Standard_Integer theRow,
const Standard_Integer theCol);
};
public:
typedef instance<TColgp_HArray2OfXYZ> XYZ;
typedef instance<TColgp_HArray2OfPnt> Pnt;
typedef instance<TColgp_HArray2OfDir> Dir;
typedef instance<TColgp_HArray2OfVec> Vec;
typedef instance<TColgp_HArray2OfXY> XY;
typedef instance<TColgp_HArray2OfPnt2d> Pnt2d;
typedef instance<TColgp_HArray2OfDir2d> Dir2d;
typedef instance<TColgp_HArray2OfVec2d> Vec2d;
typedef instance<TColgp_HArray2OfLin2d> Lin2d;
typedef instance<TColgp_HArray2OfCirc2d> Circ2d;
};
#endif

View File

@ -0,0 +1,52 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <ShapePersistent_HSequence.hxx>
#include <StdObjMgt_ReadData.hxx>
template <class SequenceClass>
void ShapePersistent_HSequence::node<SequenceClass>::Read
(StdObjMgt_ReadData& theReadData)
{
theReadData >> myPreviuos >> myItem >> myNext;
}
template <class SequenceClass>
void ShapePersistent_HSequence::instance<SequenceClass>::Read
(StdObjMgt_ReadData& theReadData)
{
theReadData >> myFirst >> myLast >> mySize;
}
template <class SequenceClass>
Handle(SequenceClass)
ShapePersistent_HSequence::instance<SequenceClass>::Import() const
{
Handle(SequenceClass) aSequence = new SequenceClass;
for (Handle(Node) aNode = myFirst; aNode; aNode = aNode->Next())
aSequence->Append (aNode->Item());
return aSequence;
}
template class ShapePersistent_HSequence::node<TColgp_HSequenceOfXYZ>;
template class ShapePersistent_HSequence::node<TColgp_HSequenceOfPnt>;
template class ShapePersistent_HSequence::node<TColgp_HSequenceOfDir>;
template class ShapePersistent_HSequence::node<TColgp_HSequenceOfVec>;
template class ShapePersistent_HSequence::instance<TColgp_HSequenceOfXYZ>;
template class ShapePersistent_HSequence::instance<TColgp_HSequenceOfPnt>;
template class ShapePersistent_HSequence::instance<TColgp_HSequenceOfDir>;
template class ShapePersistent_HSequence::instance<TColgp_HSequenceOfVec>;

View File

@ -0,0 +1,75 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _ShapePersistent_HSequence_HeaderFile
#define _ShapePersistent_HSequence_HeaderFile
#include <StdObjMgt_Persistent.hxx>
#include <StdObject_gp.hxx>
#include <TColgp_HSequenceOfXYZ.hxx>
#include <TColgp_HSequenceOfPnt.hxx>
#include <TColgp_HSequenceOfDir.hxx>
#include <TColgp_HSequenceOfVec.hxx>
class ShapePersistent_HSequence
{
template <class SequenceClass>
class node : public StdObjMgt_Persistent
{
public:
typedef typename SequenceClass::value_type ItemType;
public:
//! Read persistent data from a file.
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
const Handle(node)& Previuos() const { return myPreviuos; }
const Handle(node)& Next() const { return myNext; }
const ItemType& Item() const { return myItem; }
private:
Reference<node> myPreviuos;
Reference<node> myNext;
StdObject_gp::Object<ItemType> myItem;
};
template <class SequenceClass>
class instance : public StdObjMgt_Persistent
{
public:
typedef node<SequenceClass> Node;
public:
//! Read persistent data from a file.
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
//! Import transient object from the persistent data.
Standard_EXPORT Handle(SequenceClass) Import() const;
private:
Reference<Node> myFirst;
Reference<Node> myLast;
Value<Standard_Integer> mySize;
};
public:
typedef instance<TColgp_HSequenceOfXYZ> XYZ;
typedef instance<TColgp_HSequenceOfPnt> Pnt;
typedef instance<TColgp_HSequenceOfDir> Dir;
typedef instance<TColgp_HSequenceOfVec> Vec;
};
#endif

View File

@ -0,0 +1,83 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <ShapePersistent_Poly.hxx>
#include <Poly_Polygon2D.hxx>
#include <Poly_Polygon3D.hxx>
#include <Poly_PolygonOnTriangulation.hxx>
#include <Poly_Triangulation.hxx>
Handle(Poly_Polygon2D) ShapePersistent_Poly::pPolygon2D::Import() const
{
if (myNodes.IsNull())
return NULL;
Handle(Poly_Polygon2D) aPolygon = new Poly_Polygon2D (*myNodes->Array());
aPolygon->Deflection (myDeflection);
return aPolygon;
}
Handle(Poly_Polygon3D) ShapePersistent_Poly::pPolygon3D::Import() const
{
if (myNodes.IsNull() || myParameters.IsNull())
return NULL;
Handle(Poly_Polygon3D) aPolygon = new Poly_Polygon3D (*myNodes->Array(),
*myParameters->Array());
aPolygon->Deflection (myDeflection);
return aPolygon;
}
Handle(Poly_PolygonOnTriangulation)
ShapePersistent_Poly::pPolygonOnTriangulation::Import() const
{
Handle(Poly_PolygonOnTriangulation) aPolygon;
if (myNodes)
{
if (myParameters)
aPolygon = new Poly_PolygonOnTriangulation (*myNodes->Array(),
*myParameters->Array());
else
aPolygon = new Poly_PolygonOnTriangulation (*myNodes->Array());
aPolygon->Deflection (myDeflection);
}
return aPolygon;
}
Handle(Poly_Triangulation) ShapePersistent_Poly::pTriangulation::Import() const
{
Handle(Poly_Triangulation) aTriangulation;
// Triangulation is not used
#if 0
if (myNodes && myTriangles)
{
if (myUVNodes)
aTriangulation = new Poly_Triangulation (*myNodes->Array(),
*myUVNodes->Array(),
*myTriangles->Array());
else
aTriangulation = new Poly_Triangulation (*myNodes->Array(),
*myTriangles->Array());
aTriangulation->Deflection (myDeflection);
}
#endif
return aTriangulation;
}

View File

@ -0,0 +1,99 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _ShapePersistent_Poly_HeaderFile
#define _ShapePersistent_Poly_HeaderFile
#include <StdObjMgt_SharedObject.hxx>
#include <StdObjMgt_ReadData.hxx>
#include <StdLPersistent_HArray1.hxx>
#include <ShapePersistent_HArray1.hxx>
class Poly_Polygon2D;
class Poly_Polygon3D;
class Poly_PolygonOnTriangulation;
class Poly_Triangulation;
class ShapePersistent_Poly : private StdObjMgt_SharedObject
{
class pPolygon2D : public PersistentBase
{
public:
inline void Read (StdObjMgt_ReadData& theReadData)
{ theReadData >> myDeflection >> myNodes; }
Handle(Poly_Polygon2D) Import() const;
private:
Value <Standard_Real> myDeflection;
Reference <ShapePersistent_HArray1::Pnt2d> myNodes;
};
class pPolygon3D : public PersistentBase
{
public:
inline void Read (StdObjMgt_ReadData& theReadData)
{ theReadData >> myDeflection >> myNodes >> myParameters; }
Handle(Poly_Polygon3D) Import() const;
private:
Value <Standard_Real> myDeflection;
Reference <ShapePersistent_HArray1::Pnt> myNodes;
Reference <StdLPersistent_HArray1::Real> myParameters;
};
class pPolygonOnTriangulation : public PersistentBase
{
public:
inline void Read (StdObjMgt_ReadData& theReadData)
{ theReadData >> myDeflection >> myNodes >> myParameters; }
Handle(Poly_PolygonOnTriangulation) Import() const;
private:
Value <Standard_Real> myDeflection;
Reference <StdLPersistent_HArray1::Integer> myNodes;
Reference <StdLPersistent_HArray1::Real> myParameters;
};
class pTriangulation : public PersistentBase
{
public:
inline void Read (StdObjMgt_ReadData& theReadData)
{ theReadData >> myDeflection >> myNodes >> myUVNodes >> myTriangles; }
Handle(Poly_Triangulation) Import() const;
private:
Value <Standard_Real> myDeflection;
Reference <ShapePersistent_HArray1::Pnt> myNodes;
Reference <ShapePersistent_HArray1::Pnt2d> myUVNodes;
Reference <ShapePersistent_HArray1::Triangle> myTriangles;
};
template <class Persistent, class Transient>
struct instance
: Delayed <DelayedBase<StdObjMgt_Persistent, Transient, Persistent> > {};
public:
typedef instance <pPolygon2D, Poly_Polygon2D> Polygon2D;
typedef instance <pPolygon3D, Poly_Polygon3D> Polygon3D;
typedef instance <pPolygonOnTriangulation,
Poly_PolygonOnTriangulation> PolygonOnTriangulation;
typedef instance <pTriangulation, Poly_Triangulation> Triangulation;
};
#endif

View File

@ -0,0 +1,96 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <ShapePersistent_TopoDS.hxx>
#include <BRep_Builder.hxx>
enum
{
ModifiedMask = 2,
CheckedMask = 4,
OrientableMask = 8,
ClosedMask = 16,
InfiniteMask = 32,
ConvexMask = 64
};
//=======================================================================
//function : Read
//purpose : Read persistent data from a file
//=======================================================================
void ShapePersistent_TopoDS::Shape::Read (StdObjMgt_ReadData& theReadData)
{
theReadData >> myEntry;
myShape.Read (theReadData);
}
void ShapePersistent_TopoDS::pTBase::setFlags
(const Handle(TopoDS_TShape)& theTShape) const
{
theTShape->Free (Standard_False); // Always frozen when coming from DB
theTShape->Modified (myFlags & ModifiedMask);
theTShape->Checked (myFlags & CheckedMask);
theTShape->Orientable (myFlags & OrientableMask);
theTShape->Closed (myFlags & ClosedMask);
theTShape->Infinite (myFlags & InfiniteMask);
theTShape->Convex (myFlags & ConvexMask);
}
static inline void AddShape
(TopoDS_Shape& theParent, const Handle(StdObjMgt_Persistent)& theRef)
{
Handle(ShapePersistent_TopoDS::Shape) aShape =
Handle(ShapePersistent_TopoDS::Shape)::DownCast (theRef);
if (aShape)
BRep_Builder().Add (theParent, aShape->Import());
}
static inline void AddShape
(TopoDS_Shape& theParent, const StdObject_Shape& theShape)
{
BRep_Builder().Add (theParent, theShape.Import());
}
template <class ShapesArray>
void ShapePersistent_TopoDS::pTBase::addShapesT
(TopoDS_Shape& theParent) const
{
Handle(ShapesArray) aShapes;
if (myShapes.Cast (aShapes))
{
typename ShapesArray::Iterator anIter (*aShapes->Array());
for (; anIter.More(); anIter.Next())
AddShape (theParent, anIter.Value());
}
}
template void ShapePersistent_TopoDS::pTBase::addShapesT
<StdLPersistent_HArray1::Persistent> (TopoDS_Shape& theParent) const;
template void ShapePersistent_TopoDS::pTBase::addShapesT
<StdPersistent_HArray1::Shape1> (TopoDS_Shape& theParent) const;
template <class Target>
Handle(TopoDS_TShape)
ShapePersistent_TopoDS::pTSimple<Target>::createTShape() const
{ return new Target; }
template class ShapePersistent_TopoDS::pTSimple<TopoDS_TWire>;
template class ShapePersistent_TopoDS::pTSimple<TopoDS_TShell>;
template class ShapePersistent_TopoDS::pTSimple<TopoDS_TSolid>;
template class ShapePersistent_TopoDS::pTSimple<TopoDS_TCompSolid>;
template class ShapePersistent_TopoDS::pTSimple<TopoDS_TCompound>;

View File

@ -0,0 +1,115 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _ShapePersistent_TopoDS_HeaderFile
#define _ShapePersistent_TopoDS_HeaderFile
#include <StdPersistent_TopoDS.hxx>
#include <StdPersistent_HArray1.hxx>
#include <StdLPersistent_HArray1.hxx>
#include <StdObject_Shape.hxx>
#include <TopoDS_TWire.hxx>
#include <TopoDS_TShell.hxx>
#include <TopoDS_TSolid.hxx>
#include <TopoDS_TCompSolid.hxx>
#include <TopoDS_TCompound.hxx>
class ShapePersistent_TopoDS : public StdPersistent_TopoDS
{
public:
class Shape : public StdObjMgt_Persistent
{
public:
//! Read persistent data from a file.
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
//! Import transient object from the persistent data.
TopoDS_Shape Import() const { return myShape.Import(); }
private:
Reference<> myEntry;
StdObject_Shape myShape;
};
protected:
class pTBase : public pTShape
{
public:
inline Handle(TopoDS_TShape) Import() const
{
Handle(TopoDS_TShape) aTShape = createTShape();
TopoDS_Shape aWrapperShape;
aWrapperShape.TShape (aTShape);
addShapes (aWrapperShape);
setFlags (aTShape);
return aTShape;
}
private:
virtual Handle(TopoDS_TShape) createTShape() const = 0;
virtual void addShapes (TopoDS_Shape& theParent) const = 0;
void setFlags (const Handle(TopoDS_TShape)& theTShape) const;
protected:
template <class ShapesArray>
void addShapesT (TopoDS_Shape& theParent) const;
};
private:
template <class Target>
class pTSimple : public pTBase
{ virtual Handle(TopoDS_TShape) createTShape() const; };
template <class Persistent, class ShapesArray>
class pTObject : public Persistent
{
virtual void addShapes (TopoDS_Shape& theParent) const
{
pTBase::addShapesT<ShapesArray> (theParent);
}
};
template <class Persistent, class ShapesArray>
struct tObjectT : Delayed <DelayedBase<TShape, TopoDS_TShape, pTBase>,
pTObject<Persistent, ShapesArray> > {};
protected:
template <class Persistent>
struct tObject : tObjectT<Persistent, StdLPersistent_HArray1::Persistent> {};
template <class Persistent>
struct tObject1 : tObjectT<Persistent, StdPersistent_HArray1::Shape1> {};
public:
typedef tObject <pTSimple<TopoDS_TWire> > TWire;
typedef tObject <pTSimple<TopoDS_TShell> > TShell;
typedef tObject <pTSimple<TopoDS_TSolid> > TSolid;
typedef tObject <pTSimple<TopoDS_TCompSolid> > TCompSolid;
typedef tObject <pTSimple<TopoDS_TCompound> > TCompound;
typedef tObject1 <pTSimple<TopoDS_TWire> > TWire1;
typedef tObject1 <pTSimple<TopoDS_TShell> > TShell1;
typedef tObject1 <pTSimple<TopoDS_TSolid> > TSolid1;
typedef tObject1 <pTSimple<TopoDS_TCompSolid> > TCompSolid1;
typedef tObject1 <pTSimple<TopoDS_TCompound> > TCompound1;
};
#endif

View File

@ -17,10 +17,10 @@
IMPLEMENT_STANDARD_RTTIEXT (StdDrivers_DocumentRetrievalDriver, StdLDrivers_DocumentRetrievalDriver)
//=======================================================================
//function : BindTypes
//function : bindTypes
//purpose : Register types
//=======================================================================
void StdDrivers_DocumentRetrievalDriver::BindTypes (StdObjMgt_MapOfInstantiators& theMap)
void StdDrivers_DocumentRetrievalDriver::bindTypes (StdObjMgt_MapOfInstantiators& theMap)
{
StdDrivers::BindTypes (theMap);
}

View File

@ -20,10 +20,11 @@
class StdDrivers_DocumentRetrievalDriver : public StdLDrivers_DocumentRetrievalDriver
{
public:
//! Register types.
Standard_EXPORT virtual void BindTypes (StdObjMgt_MapOfInstantiators& theMap) Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT (StdDrivers_DocumentRetrievalDriver, StdLDrivers_DocumentRetrievalDriver)
protected:
//! Register types.
Standard_EXPORT virtual void bindTypes (StdObjMgt_MapOfInstantiators& theMap) Standard_OVERRIDE;
};
#endif // _StdDrivers_DocumentRetrievalDriver_HeaderFile

View File

@ -13,8 +13,8 @@
#include <StdLDrivers_DocumentRetrievalDriver.hxx>
#include <StdLDrivers.hxx>
#include <StdLPersistent_PDocStd_Document.hxx>
#include <StdObjMgt_Persistent.hxx>
#include <StdObjMgt_MapOfInstantiators.hxx>
#include <StdObjMgt_ReadData.hxx>
@ -32,6 +32,7 @@
#include <Standard_ErrorHandler.hxx>
#include <Standard_NotImplemented.hxx>
#include <NCollection_Array1.hxx>
#include <NCollection_Handle.hxx>
#include <TDocStd_Document.hxx>
IMPLEMENT_STANDARD_RTTIEXT (StdLDrivers_DocumentRetrievalDriver, PCDM_RetrievalDriver)
@ -49,23 +50,47 @@ Handle(CDM_Document) StdLDrivers_DocumentRetrievalDriver::CreateDocument()
//function : Read
//purpose : Retrieve the content of a file into a new document
//=======================================================================
void StdLDrivers_DocumentRetrievalDriver::Read (const TCollection_ExtendedString& theFileName,
void StdLDrivers_DocumentRetrievalDriver::Read (
const TCollection_ExtendedString& theFileName,
const Handle(CDM_Document)& theNewDocument,
const Handle(CDM_Application)&)
{
// Read header data and persistent document
Storage_HeaderData aHeaderData;
Handle(StdObjMgt_Persistent) aPDocument = read (theFileName, aHeaderData);
// Import transient document from the persistent one
if (!aPDocument.IsNull())
{
aPDocument->ImportDocument (
Handle(TDocStd_Document)::DownCast (theNewDocument));
// Copy comments from the header data
theNewDocument->SetComments (aHeaderData.Comments());
}
}
//=======================================================================
//function : read
//purpose : Read persistent document from a file
//=======================================================================
Handle(StdObjMgt_Persistent) StdLDrivers_DocumentRetrievalDriver::read (
const TCollection_ExtendedString& theFileName,
Storage_HeaderData& theHeaderData)
{
Standard_Integer i;
// Create a driver appropriate for the given file
PCDM_BaseDriverPointer aFileDriver;
if (PCDM::FileDriverType (TCollection_AsciiString (theFileName), aFileDriver) == PCDM_TOFD_Unknown)
PCDM_BaseDriverPointer aFileDriverPtr;
if (PCDM::FileDriverType (TCollection_AsciiString (theFileName), aFileDriverPtr) == PCDM_TOFD_Unknown)
{
myReaderStatus = PCDM_RS_UnknownFileDriver;
return;
return NULL;
}
NCollection_Handle<Storage_BaseDriver> aFileDriver (aFileDriverPtr);
// Try to open the file
{
Standard_SStream aMsg;
try
{
OCC_CATCH_SIGNALS
@ -74,67 +99,51 @@ void StdLDrivers_DocumentRetrievalDriver::Read (const TCollection_ExtendedString
}
catch (Standard_Failure)
{
aMsg << Standard_Failure::Caught() << endl;
myReaderStatus = PCDM_RS_OpenError;
}
if (myReaderStatus != PCDM_RS_OK)
{
Standard_SStream aMsg;
aMsg << Standard_Failure::Caught() << endl;
Standard_Failure::Raise (aMsg);
return;
}
}
// Read header section
Storage_HeaderData hData;
if (!hData.Read (*aFileDriver))
{
RaiseOnStorageError (hData.ErrorStatus());
return;
}
if (!theHeaderData.Read (*aFileDriver))
raiseOnStorageError (theHeaderData.ErrorStatus());
// Read type section
Storage_TypeData tData;
if (!tData.Read (*aFileDriver))
{
RaiseOnStorageError (tData.ErrorStatus());
return;
}
Storage_TypeData aTypeData;
if (!aTypeData.Read (*aFileDriver))
raiseOnStorageError (aTypeData.ErrorStatus());
// Read root section
Storage_RootData rData;
if (!rData.Read (*aFileDriver))
{
RaiseOnStorageError (rData.ErrorStatus());
return;
}
Storage_RootData aRootData;
if (!aRootData.Read (*aFileDriver))
raiseOnStorageError (aRootData.ErrorStatus());
if (rData.NumberOfRoots() < 1)
if (aRootData.NumberOfRoots() < 1)
{
myReaderStatus = PCDM_RS_NoDocument;
Standard_SStream aMsg;
aMsg << "could not find any document in this file" << endl;
Standard_Failure::Raise (aMsg);
return;
}
// Select instantiators for the used types
NCollection_Array1<StdObjMgt_Persistent::Instantiator>
anInstantiators (1, tData.NumberOfTypes());
anInstantiators (1, aTypeData.NumberOfTypes());
{
StdObjMgt_MapOfInstantiators aMapOfInstantiators;
BindTypes (aMapOfInstantiators);
bindTypes (aMapOfInstantiators);
TColStd_SequenceOfAsciiString anUnknownTypes;
Standard_Integer aCurTypeNum;
TCollection_AsciiString aCurTypeName;
for (i = 1; i <= tData.NumberOfTypes(); i++)
for (i = 1; i <= aTypeData.NumberOfTypes(); i++)
{
aCurTypeName = tData.Type (i);
aCurTypeNum = tData.Type (aCurTypeName);
aCurTypeName = aTypeData.Type (i);
aCurTypeNum = aTypeData.Type (aCurTypeName);
StdObjMgt_Persistent::Instantiator anInstantiator;
if (aMapOfInstantiators.Find (aCurTypeName, anInstantiator))
@ -158,15 +167,13 @@ void StdLDrivers_DocumentRetrievalDriver::Read (const TCollection_ExtendedString
}
Standard_Failure::Raise (aMsg);
return;
}
}
// Read and parse reference section
StdObjMgt_ReadData aReadData (*aFileDriver, hData.NumberOfObjects());
StdObjMgt_ReadData aReadData (*aFileDriver, theHeaderData.NumberOfObjects());
if (RaiseOnStorageError (aFileDriver->BeginReadRefSection()))
return;
raiseOnStorageError (aFileDriver->BeginReadRefSection());
Standard_Integer len = aFileDriver->RefSectionSize();
for (i = 1; i <= len; i++)
@ -184,66 +191,36 @@ void StdLDrivers_DocumentRetrievalDriver::Read (const TCollection_ExtendedString
anError = Storage_VSTypeMismatch;
}
if (RaiseOnStorageError (anError))
return;
raiseOnStorageError (anError);
aReadData.CreateObject (aRef, anInstantiators (aType));
aReadData.CreatePersistentObject (aRef, anInstantiators (aType));
}
if (RaiseOnStorageError (aFileDriver->EndReadRefSection()))
return;
raiseOnStorageError (aFileDriver->EndReadRefSection());
// Read and parse data section
if (RaiseOnStorageError (aFileDriver->BeginReadDataSection()))
return;
raiseOnStorageError (aFileDriver->BeginReadDataSection());
for (i = 1; i <= hData.NumberOfObjects(); i++)
for (i = 1; i <= theHeaderData.NumberOfObjects(); i++)
{
Handle(StdObjMgt_Persistent) aPersistent = aReadData.Object (i);
if (!aPersistent.IsNull())
Storage_Error anError;
try
{
Standard_Integer aRef = 0, aType = 0;
Storage_Error anError;
try
{
OCC_CATCH_SIGNALS
aFileDriver->ReadPersistentObjectHeader (aRef, aType);
aFileDriver->BeginReadPersistentObjectData();
aPersistent->Read (aReadData);
aFileDriver->EndReadPersistentObjectData();
anError = Storage_VSOk;
}
catch (Storage_StreamTypeMismatchError) { anError = Storage_VSTypeMismatch; }
catch (Storage_StreamFormatError ) { anError = Storage_VSFormatError; }
catch (Storage_StreamReadError ) { anError = Storage_VSFormatError; }
if (RaiseOnStorageError (anError))
return;
OCC_CATCH_SIGNALS
aReadData.ReadPersistentObject (i);
anError = Storage_VSOk;
}
catch (Storage_StreamTypeMismatchError) { anError = Storage_VSTypeMismatch; }
catch (Storage_StreamFormatError ) { anError = Storage_VSFormatError; }
catch (Storage_StreamReadError ) { anError = Storage_VSFormatError; }
raiseOnStorageError (anError);
}
if (RaiseOnStorageError (aFileDriver->EndReadDataSection()))
return;
raiseOnStorageError (aFileDriver->EndReadDataSection());
// Close the file
aFileDriver->Close();
delete aFileDriver;
// Initialize transient document using the root object and comments
Handle(Storage_HSeqOfRoot) aRoots = rData.Roots();
Handle(Storage_Root) aFirstRoot = aRoots->First();
Handle(StdObjMgt_Persistent) aFirstRootObject =
aReadData.Object (aFirstRoot->Reference());
Handle(StdLPersistent_PDocStd_Document) aPDocument =
Handle(StdLPersistent_PDocStd_Document)::DownCast (aFirstRootObject);
if (!aPDocument.IsNull())
aPDocument->Import (theNewDocument);
theNewDocument->SetComments (hData.Comments());
// Get persistent document from the root object
return aReadData.PersistentObject (aRootData.Roots()->First()->Reference());
}
//=======================================================================
@ -260,65 +237,63 @@ void StdLDrivers_DocumentRetrievalDriver::Read (Standard_IStream&
}
//=======================================================================
//function : RaiseOnStorageError
//function : raiseOnStorageError
//purpose : Update the reader status and raise an exception
// appropriate for the given storage error
//=======================================================================
Standard_Boolean StdLDrivers_DocumentRetrievalDriver::RaiseOnStorageError (Storage_Error theError)
void StdLDrivers_DocumentRetrievalDriver::raiseOnStorageError (Storage_Error theError)
{
Standard_SStream aMsg;
switch (theError)
{
case Storage_VSOk:
return Standard_False;
break;
case Storage_VSOpenError:
case Storage_VSNotOpen:
case Storage_VSAlreadyOpen:
myReaderStatus = PCDM_RS_OpenError;
aMsg << "Stream Open Error" << endl;
break;
Standard_Failure::Raise (aMsg);
case Storage_VSModeError:
myReaderStatus = PCDM_RS_WrongStreamMode;
aMsg << "Stream is opened with a wrong mode for operation" << endl;
break;
Standard_Failure::Raise (aMsg);
case Storage_VSSectionNotFound:
myReaderStatus = PCDM_RS_FormatFailure;
aMsg << "Section is not found" << endl;
break;
Standard_Failure::Raise (aMsg);
case Storage_VSFormatError:
myReaderStatus = PCDM_RS_FormatFailure;
aMsg << "Wrong format error" << endl;
break;
Standard_Failure::Raise (aMsg);
case Storage_VSUnknownType:
myReaderStatus = PCDM_RS_TypeFailure;
aMsg << "Try to read an unknown type" << endl;
break;
Standard_Failure::Raise (aMsg);
case Storage_VSTypeMismatch:
myReaderStatus = PCDM_RS_TypeFailure;
aMsg << "Try to read a wrong primitive type" << endl;
break;
Standard_Failure::Raise (aMsg);
default:
myReaderStatus = PCDM_RS_DriverFailure;
aMsg << "Retrieval Driver Failure" << endl;
Standard_Failure::Raise (aMsg);
}
Standard_Failure::Raise (aMsg);
return Standard_True;
}
//=======================================================================
//function : BindTypes
//function : bindTypes
//purpose : Register types
//=======================================================================
void StdLDrivers_DocumentRetrievalDriver::BindTypes (StdObjMgt_MapOfInstantiators& theMap)
void StdLDrivers_DocumentRetrievalDriver::bindTypes (StdObjMgt_MapOfInstantiators& theMap)
{
StdLDrivers::BindTypes (theMap);
}

View File

@ -18,6 +18,7 @@
#include <Storage_Error.hxx>
class StdObjMgt_MapOfInstantiators;
class StdObjMgt_Persistent;
//! retrieval driver of a Part document
class StdLDrivers_DocumentRetrievalDriver : public PCDM_RetrievalDriver
@ -27,7 +28,8 @@ public:
Standard_EXPORT virtual Handle(CDM_Document) CreateDocument() Standard_OVERRIDE;
//! Retrieve the content of a file into a new document.
Standard_EXPORT virtual void Read (const TCollection_ExtendedString& theFileName,
Standard_EXPORT virtual void Read (
const TCollection_ExtendedString& theFileName,
const Handle(CDM_Document)& theNewDocument,
const Handle(CDM_Application)& theApplication) Standard_OVERRIDE;
@ -39,12 +41,18 @@ public:
DEFINE_STANDARD_RTTIEXT (StdLDrivers_DocumentRetrievalDriver, PCDM_RetrievalDriver)
private:
//! Update the reader status and raise an exception appropriate for the given storage error.
Standard_EXPORT Standard_Boolean RaiseOnStorageError (Storage_Error theError);
protected:
//! Register types.
Standard_EXPORT virtual void BindTypes (StdObjMgt_MapOfInstantiators& theMap);
Standard_EXPORT virtual void bindTypes (StdObjMgt_MapOfInstantiators& theMap);
private:
//! Read persistent document from a file.
Handle(StdObjMgt_Persistent) read (
const TCollection_ExtendedString& theFileName,
Storage_HeaderData& theHeaderData);
//! Update the reader status and raise an exception appropriate for the given storage error.
Standard_EXPORT void raiseOnStorageError (Storage_Error theError);
};
#endif // _StdLDrivers_DocumentRetrievalDriver_HeaderFile

2
src/StdLObject/FILES Normal file
View File

@ -0,0 +1,2 @@
StdLObject_GUID.cxx
StdLObject_GUID.hxx

View File

@ -11,27 +11,23 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <StdLPersistent_PColStd_HArray1Base.hxx>
#include <StdLObject_GUID.hxx>
#include <StdObjMgt_ReadData.hxx>
//=======================================================================
//function : Read
//purpose : Read persistent data from a file
//=======================================================================
void StdLPersistent_PColStd_HArray1Base::Read (StdObjMgt_ReadData& theReadData)
void StdLObject_GUID::Read (StdObjMgt_ReadData& theReadData)
{
Standard_Integer aLowerBound, anUpperBound;
theReadData >> aLowerBound >> anUpperBound;
CreateArray (aLowerBound, anUpperBound);
Value<Standard_Integer> a32b;
Value<Standard_ExtCharacter> a16b[3];
Value<Standard_Character> a8b [6];
theReadData.Driver().BeginReadObjectData();
theReadData >> a32b >> a16b[0] >> a16b[1] >> a16b[2];
theReadData >> a8b[0] >> a8b[1] >> a8b[2] >> a8b[3] >> a8b[4] >> a8b[5];
Standard_Integer aSize;
theReadData >> aSize;
for (Standard_Integer i = aLowerBound; i <= anUpperBound; i++)
ReadValue (theReadData, i);
theReadData.Driver().EndReadObjectData();
*static_cast<Standard_GUID*> (this) =
Standard_GUID (a32b, a16b[0], a16b[1], a16b[2],
a8b[0], a8b[1], a8b[2], a8b[3], a8b[4], a8b[5]);
}

View File

@ -0,0 +1,29 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _StdLObject_GUID_HeaderFile
#define _StdLObject_GUID_HeaderFile
#include <StdObjMgt_Attribute.hxx>
#include <Standard_GUID.hxx>
class StdLObject_GUID : public Standard_GUID, private StdObjMgt_ContentTypes
{
public:
void Read (StdObjMgt_ReadData& theReadData);
};
#endif

View File

@ -1,16 +1,28 @@
FILES
StdLPersistent.cxx
StdLPersistent.hxx
StdLPersistent_PCollection_HExtendedString.cxx
StdLPersistent_PCollection_HExtendedString.hxx
StdLPersistent_PColStd_HArray1.hxx
StdLPersistent_PColStd_HArray1Base.cxx
StdLPersistent_PColStd_HArray1Base.hxx
StdLPersistent_PDataStd_Integer.cxx
StdLPersistent_PDataStd_Integer.hxx
StdLPersistent_PDataStd_Name.cxx
StdLPersistent_PDataStd_Name.hxx
StdLPersistent_PDF_Data.cxx
StdLPersistent_PDF_Data.hxx
StdLPersistent_PDocStd_Document.cxx
StdLPersistent_PDocStd_Document.hxx
StdLPersistent_Collection.cxx
StdLPersistent_Collection.hxx
StdLPersistent_Data.cxx
StdLPersistent_Data.hxx
StdLPersistent_Dependency.cxx
StdLPersistent_Dependency.hxx
StdLPersistent_Document.cxx
StdLPersistent_Document.hxx
StdLPersistent_Function.hxx
StdLPersistent_HArray1OfPersistent.hxx
StdLPersistent_HArray1.cxx
StdLPersistent_HArray1.hxx
StdLPersistent_HArray2.cxx
StdLPersistent_HArray2.hxx
StdLPersistent_HString.cxx
StdLPersistent_HString.hxx
StdLPersistent_NamedData.cxx
StdLPersistent_NamedData.hxx
StdLPersistent_Real.hxx
StdLPersistent_TreeNode.cxx
StdLPersistent_TreeNode.hxx
StdLPersistent_Value.cxx
StdLPersistent_Value.hxx
StdLPersistent_Variable.hxx
StdLPersistent_Void.hxx
StdLPersistent_XLink.hxx

View File

@ -14,12 +14,22 @@
#include <StdLPersistent.hxx>
#include <StdObjMgt_MapOfInstantiators.hxx>
#include <StdLPersistent_PDocStd_Document.hxx>
#include <StdLPersistent_PDF_Data.hxx>
#include <StdLPersistent_PColStd_HArray1.hxx>
#include <StdLPersistent_PCollection_HExtendedString.hxx>
#include <StdLPersistent_PDataStd_Name.hxx>
#include <StdLPersistent_PDataStd_Integer.hxx>
#include <StdLPersistent_Document.hxx>
#include <StdLPersistent_Data.hxx>
#include <StdLPersistent_HString.hxx>
#include <StdLPersistent_HArray1.hxx>
#include <StdLPersistent_HArray2.hxx>
#include <StdLPersistent_Void.hxx>
#include <StdLPersistent_Real.hxx>
#include <StdLPersistent_Value.hxx>
#include <StdLPersistent_Collection.hxx>
#include <StdLPersistent_Dependency.hxx>
#include <StdLPersistent_Variable.hxx>
#include <StdLPersistent_XLink.hxx>
#include <StdLPersistent_Function.hxx>
#include <StdLPersistent_TreeNode.hxx>
#include <StdLPersistent_NamedData.hxx>
//=======================================================================
//function : BindTypes
@ -27,17 +37,65 @@
//=======================================================================
void StdLPersistent::BindTypes (StdObjMgt_MapOfInstantiators& theMap)
{
theMap.Bind <StdLPersistent_PDocStd_Document> ("PDocStd_Document");
theMap.Bind <StdLPersistent_PDF_Data> ("PDF_Data");
theMap.Bind <StdLPersistent_PDataStd_Name> ("PDataStd_Name");
theMap.Bind <StdLPersistent_PDataStd_Integer> ("PDataStd_Integer");
// Non-attribute data
theMap.Bind <StdLPersistent_Document> ("PDocStd_Document");
theMap.Bind <StdLPersistent_Data> ("PDF_Data");
theMap.Bind <StdLPersistent_PColStd_HArray1OfInteger>
("PColStd_HArray1OfInteger");
theMap.Bind <StdLPersistent_HString::Ascii> ("PCollection_HAsciiString");
theMap.Bind <StdLPersistent_HString::Extended> ("PCollection_HExtendedString");
theMap.Bind <StdLPersistent_PDF_HAttributeArray1>
("PDF_HAttributeArray1");
theMap.Bind <StdLPersistent_HArray1::Integer> ("PColStd_HArray1OfInteger");
theMap.Bind <StdLPersistent_HArray1::Real> ("PColStd_HArray1OfReal");
theMap.Bind <StdLPersistent_HArray1::Persistent> ("PColStd_HArray1OfExtendedString");
theMap.Bind <StdLPersistent_HArray1::Persistent> ("PDF_HAttributeArray1");
theMap.Bind <StdLPersistent_HArray1::Persistent> ("PDataStd_HArray1OfHAsciiString");
theMap.Bind <StdLPersistent_HArray1::Persistent> ("PDataStd_HArray1OfHArray1OfInteger");
theMap.Bind <StdLPersistent_HArray1::Persistent> ("PDataStd_HArray1OfHArray1OfReal");
theMap.Bind <StdLPersistent_HArray1::Byte> ("PDataStd_HArray1OfByte");
theMap.Bind <StdLPersistent_PCollection_HExtendedString>
("PCollection_HExtendedString");
theMap.Bind <StdLPersistent_HArray2::Integer> ("PColStd_HArray2OfInteger");
// Attributes
theMap.Bind <StdLPersistent_Void::Directory> ("PDataStd_Directory");
theMap.Bind <StdLPersistent_Void::Tick> ("PDataStd_Tick");
theMap.Bind <StdLPersistent_Void::NoteBook> ("PDataStd_NoteBook");
theMap.Bind <StdLPersistent_Value::Integer> ("PDataStd_Integer");
theMap.Bind <StdLPersistent_Value::TagSource> ("PDF_TagSource");
theMap.Bind <StdLPersistent_Value::Reference> ("PDF_Reference");
theMap.Bind <StdLPersistent_Value::UAttribute> ("PDataStd_UAttribute");
theMap.Bind <StdLPersistent_Value::Name> ("PDataStd_Name");
theMap.Bind <StdLPersistent_Value::Comment> ("PDataStd_Comment");
theMap.Bind <StdLPersistent_Value::AsciiString> ("PDataStd_AsciiString");
theMap.Bind <StdLPersistent_Collection::IntegerArray> ("PDataStd_IntegerArray");
theMap.Bind <StdLPersistent_Collection::RealArray> ("PDataStd_RealArray");
theMap.Bind <StdLPersistent_Collection::ByteArray> ("PDataStd_ByteArray");
theMap.Bind <StdLPersistent_Collection::ExtStringArray> ("PDataStd_ExtStringArray");
theMap.Bind <StdLPersistent_Collection::BooleanArray> ("PDataStd_BooleanArray");
theMap.Bind <StdLPersistent_Collection::ReferenceArray> ("PDataStd_ReferenceArray");
theMap.Bind <StdLPersistent_Collection::IntegerArray_1> ("PDataStd_IntegerArray_1");
theMap.Bind <StdLPersistent_Collection::RealArray_1> ("PDataStd_RealArray_1");
theMap.Bind <StdLPersistent_Collection::ByteArray_1> ("PDataStd_ByteArray_1");
theMap.Bind <StdLPersistent_Collection::ExtStringArray_1> ("PDataStd_ExtStringArray_1");
theMap.Bind <StdLPersistent_Collection::IntegerList> ("PDataStd_IntegerList");
theMap.Bind <StdLPersistent_Collection::RealList> ("PDataStd_RealList");
theMap.Bind <StdLPersistent_Collection::BooleanList> ("PDataStd_BooleanList");
theMap.Bind <StdLPersistent_Collection::ExtStringList> ("PDataStd_ExtStringList");
theMap.Bind <StdLPersistent_Collection::ReferenceList> ("PDataStd_ReferenceList");
theMap.Bind <StdLPersistent_Collection::IntPackedMap> ("PDataStd_IntPackedMap");
theMap.Bind <StdLPersistent_Collection::IntPackedMap_1> ("PDataStd_IntPackedMap_1");
theMap.Bind <StdLPersistent_Real> ("PDataStd_Real");
theMap.Bind <StdLPersistent_Dependency::Expression> ("PDataStd_Expression");
theMap.Bind <StdLPersistent_Dependency::Relation> ("PDataStd_Relation");
theMap.Bind <StdLPersistent_Variable> ("PDataStd_Variable");
theMap.Bind <StdLPersistent_XLink> ("PDocStd_XLink");
theMap.Bind <StdLPersistent_Function> ("PFunction_Function");
theMap.Bind <StdLPersistent_TreeNode> ("PDataStd_TreeNode");
theMap.Bind <StdLPersistent_NamedData> ("PDataStd_NamedData");
}

View File

@ -0,0 +1,260 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <StdLPersistent_Collection.hxx>
#include <TColStd_HPackedMapOfInteger.hxx>
#include <TCollection_HExtendedString.hxx>
struct StdLPersistent_Collection::noConversion
{
noConversion (const Handle(TDF_Data)&) {}
template <class Type>
Type operator() (Type theValue) const { return theValue; }
};
struct StdLPersistent_Collection::byteConverter
{
byteConverter (const Handle(TDF_Data)&) {}
Standard_Byte operator() (Standard_Integer theValue) const
{ return static_cast<Standard_Byte> (theValue); }
};
struct StdLPersistent_Collection::stringConverter
{
stringConverter (const Handle(TDF_Data)&) {}
const TCollection_ExtendedString& operator()
(const Handle(StdObjMgt_Persistent)& theValue) const
{
Handle(TCollection_HExtendedString) aString = theValue->ExtString();
if (aString)
return aString->String();
else
{
static TCollection_ExtendedString anEmptyString;
return anEmptyString;
}
}
};
struct StdLPersistent_Collection::referenceConverter
{
referenceConverter (const Handle(TDF_Data)& theDF) : myDF (theDF) {}
TDF_Label operator() (const Handle(StdObjMgt_Persistent)& theValue) const
{ return theValue->Label (myDF); }
private:
Handle(TDF_Data) myDF;
};
//=======================================================================
//function : Read
//purpose : Read persistent data from a file
//=======================================================================
template <class Persistent>
void StdLPersistent_Collection::booleanArrayBase<Persistent>::Read
(StdObjMgt_ReadData& theReadData)
{
StdLPersistent_Collection::booleanArrayBase<Persistent>::SingleRef::Read (theReadData);
theReadData >> myLower >> myUpper;
}
template <class Persistent>
template <class ArrayHandle, class Converter>
void StdLPersistent_Collection::booleanArrayBase<Persistent>::import
(const ArrayHandle& theArray, Converter theConverter) const
{
Handle(TColStd_HArray1OfByte) aByteArray =
new TColStd_HArray1OfByte (theArray->Lower(), theArray->Upper());
for (Standard_Integer i = theArray->Lower(); i <= theArray->Upper(); i++)
aByteArray->SetValue (i, theConverter (theArray->Value(i)));
this->myTransient->Init (myLower, myUpper);
this->myTransient->SetInternalArray (aByteArray);
}
template <class Persistent>
template <class ArrayHandle, class Converter>
void StdLPersistent_Collection::directArrayBase<Persistent>::import
(const ArrayHandle& theArray, Converter) const
{
this->myTransient->ChangeArray (theArray);
}
template <class Persistent>
template <class ArrayHandle, class Converter>
void StdLPersistent_Collection::arrayBase<Persistent>::import
(const ArrayHandle& theArray, Converter theConverter) const
{
this->myTransient->Init (theArray->Lower(), theArray->Upper());
for (Standard_Integer i = theArray->Lower(); i <= theArray->Upper(); i++)
this->myTransient->SetValue (i, theConverter (theArray->Value(i)));
}
template <class Persistent>
template <class ArrayHandle, class Converter>
void StdLPersistent_Collection::listBase<Persistent>::import
(const ArrayHandle& theArray, Converter theConverter) const
{
for (Standard_Integer i = theArray->Lower(); i <= theArray->Upper(); i++)
this->myTransient->Append (theConverter (theArray->Value(i)));
}
template <class Persistent>
template <class ArrayHandle, class Converter>
void StdLPersistent_Collection::mapBase<Persistent>::import
(const ArrayHandle& theArray, Converter theConverter) const
{
Handle(TColStd_HPackedMapOfInteger) anHMap = new TColStd_HPackedMapOfInteger;
for (Standard_Integer i = theArray->Lower(); i <= theArray->Upper(); i++)
anHMap->ChangeMap().Add (theConverter (theArray->Value(i)));
this->myTransient->ChangeMap (anHMap);
}
//=======================================================================
//function : ImportAttribute
//purpose : Import transient attribuite from the persistent data
//=======================================================================
template <template<class> class BaseT,
class HArrayClass,
class AttribClass,
class Converter>
void StdLPersistent_Collection::
instance<BaseT, HArrayClass, AttribClass, Converter>::ImportAttribute()
{
Handle(HArrayClass) anHArray;
if (this->myData.Cast (anHArray))
{
typename HArrayClass::ArrayHandle anArray = anHArray->Array();
if (anArray)
this->import (anArray, Converter (this->myTransient->Label().Data()));
this->myData.Nullify();
}
}
//=======================================================================
//function : Read
//purpose : Read persistent data from a file
//=======================================================================
template <class Instance>
void StdLPersistent_Collection::instance_1<Instance>::Read
(StdObjMgt_ReadData& theReadData)
{
Instance::Read (theReadData);
theReadData >> myDelta;
}
//=======================================================================
//function : ImportAttribute
//purpose : Import transient attribuite from the persistent data
//=======================================================================
template <class Instance>
void StdLPersistent_Collection::instance_1<Instance>::ImportAttribute()
{
Instance::ImportAttribute();
this->myTransient->SetDelta (myDelta);
}
template class StdLPersistent_Collection::instance
<StdLPersistent_Collection::booleanArrayBase,
StdLPersistent_Collection::integer,
TDataStd_BooleanArray,
StdLPersistent_Collection::byteConverter>;
template class StdLPersistent_Collection::instance
<StdLPersistent_Collection::directArrayBase,
StdLPersistent_Collection::integer,
TDataStd_IntegerArray,
StdLPersistent_Collection::noConversion>;
template class StdLPersistent_Collection::instance
<StdLPersistent_Collection::directArrayBase,
StdLPersistent_Collection::real,
TDataStd_RealArray,
StdLPersistent_Collection::noConversion>;
template class StdLPersistent_Collection::instance
<StdLPersistent_Collection::arrayBase,
StdLPersistent_Collection::integer,
TDataStd_ByteArray,
StdLPersistent_Collection::byteConverter>;
template class StdLPersistent_Collection::instance
<StdLPersistent_Collection::arrayBase,
StdLPersistent_Collection::persistent,
TDataStd_ExtStringArray,
StdLPersistent_Collection::stringConverter>;
template class StdLPersistent_Collection::instance
<StdLPersistent_Collection::arrayBase,
StdLPersistent_Collection::persistent,
TDataStd_ReferenceArray,
StdLPersistent_Collection::referenceConverter>;
template class StdLPersistent_Collection::instance
<StdLPersistent_Collection::listBase,
StdLPersistent_Collection::integer,
TDataStd_IntegerList,
StdLPersistent_Collection::noConversion>;
template class StdLPersistent_Collection::instance
<StdLPersistent_Collection::listBase,
StdLPersistent_Collection::real,
TDataStd_RealList,
StdLPersistent_Collection::noConversion>;
template class StdLPersistent_Collection::instance
<StdLPersistent_Collection::listBase,
StdLPersistent_Collection::integer,
TDataStd_BooleanList,
StdLPersistent_Collection::noConversion>;
template class StdLPersistent_Collection::instance
<StdLPersistent_Collection::listBase,
StdLPersistent_Collection::persistent,
TDataStd_ExtStringList,
StdLPersistent_Collection::stringConverter>;
template class StdLPersistent_Collection::instance
<StdLPersistent_Collection::listBase,
StdLPersistent_Collection::persistent,
TDataStd_ReferenceList,
StdLPersistent_Collection::referenceConverter>;
template class StdLPersistent_Collection::instance
<StdLPersistent_Collection::mapBase,
StdLPersistent_Collection::integer,
TDataStd_IntPackedMap,
StdLPersistent_Collection::noConversion>;
template class StdLPersistent_Collection::instance_1
<StdLPersistent_Collection::IntegerArray>;
template class StdLPersistent_Collection::instance_1
<StdLPersistent_Collection::RealArray>;
template class StdLPersistent_Collection::instance_1
<StdLPersistent_Collection::ByteArray>;
template class StdLPersistent_Collection::instance_1
<StdLPersistent_Collection::ExtStringArray>;
template class StdLPersistent_Collection::instance_1
<StdLPersistent_Collection::IntPackedMap>;

View File

@ -0,0 +1,197 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _StdLPersistent_Collection_HeaderFile
#define _StdLPersistent_Collection_HeaderFile
#include <StdObjMgt_Attribute.hxx>
#include <StdLPersistent_HArray1.hxx>
#include <TDataStd_IntegerArray.hxx>
#include <TDataStd_RealArray.hxx>
#include <TDataStd_ByteArray.hxx>
#include <TDataStd_ExtStringArray.hxx>
#include <TDataStd_BooleanArray.hxx>
#include <TDataStd_ReferenceArray.hxx>
#include <TDataStd_IntegerList.hxx>
#include <TDataStd_RealList.hxx>
#include <TDataStd_ExtStringList.hxx>
#include <TDataStd_BooleanList.hxx>
#include <TDataStd_ReferenceList.hxx>
#include <TDataStd_IntPackedMap.hxx>
class StdLPersistent_Collection : private StdObjMgt_ContentTypes
{
// Converters
struct noConversion;
struct byteConverter;
struct stringConverter;
struct referenceConverter;
// Base templates
template <class Base>
class booleanArrayBase : public Base
{
public:
//! Read persistent data from a file.
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
protected:
template <class ArrayHandle, class Converter>
inline void import (const ArrayHandle& theArray, Converter theConverter)
const;
protected:
Value<Standard_Integer> myLower;
Value<Standard_Integer> myUpper;
};
template <class Base>
class directArrayBase : public Base
{
protected:
template <class ArrayHandle, class Converter>
inline void import (const ArrayHandle& theArray, Converter theConverter)
const;
};
template <class Base>
class arrayBase : public Base
{
protected:
template <class ArrayHandle, class Converter>
inline void import (const ArrayHandle& theArray, Converter theConverter)
const;
};
template <class Base>
class listBase : public Base
{
protected:
template <class ArrayHandle, class Converter>
inline void import (const ArrayHandle& theArray, Converter theConverter)
const;
};
template <class Base>
class mapBase : public Base
{
protected:
template <class ArrayHandle, class Converter>
inline void import (const ArrayHandle& theArray, Converter theConverter)
const;
};
// Instance templates
template <template<class> class BaseT,
class HArrayClass,
class AttribClass,
class Converter>
class instance
: public BaseT <typename StdObjMgt_Attribute<AttribClass>::SingleRef>
{
public:
//! Import transient attribuite from the persistent data.
Standard_EXPORT virtual void ImportAttribute();
};
template <class Instance>
class instance_1 : public Instance
{
public:
//! Read persistent data from a file.
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
//! Import transient attribuite from the persistent data.
Standard_EXPORT virtual void ImportAttribute();
private:
Value<Standard_Boolean> myDelta;
};
// Collection type specialization
template<class HArrayClass, class AttribClass, class Converter = noConversion>
struct booleanArrayT
: instance<booleanArrayBase, HArrayClass, AttribClass, Converter> {};
template<class HArrayClass, class AttribClass, class Converter = noConversion>
struct directArrayT
: instance<directArrayBase, HArrayClass, AttribClass, Converter> {};
template<class HArrayClass, class AttribClass, class Converter = noConversion>
struct arrayT
: instance<arrayBase, HArrayClass, AttribClass, Converter> {};
template<class HArrayClass, class AttribClass, class Converter = noConversion>
struct listT
: instance<listBase, HArrayClass, AttribClass, Converter> {};
template<class HArrayClass, class AttribClass, class Converter = noConversion>
struct mapT
: instance<mapBase, HArrayClass, AttribClass, Converter> {};
// Internal array types
typedef StdLPersistent_HArray1::Integer integer;
typedef StdLPersistent_HArray1::Real real;
typedef StdLPersistent_HArray1::Persistent persistent;
public:
// Final specialization
typedef booleanArrayT <integer, TDataStd_BooleanArray, byteConverter>
BooleanArray;
typedef directArrayT <integer, TDataStd_IntegerArray>
IntegerArray;
typedef directArrayT <real, TDataStd_RealArray>
RealArray;
typedef arrayT <integer, TDataStd_ByteArray, byteConverter>
ByteArray;
typedef arrayT <persistent, TDataStd_ExtStringArray, stringConverter>
ExtStringArray;
typedef arrayT <persistent, TDataStd_ReferenceArray, referenceConverter>
ReferenceArray;
typedef listT <integer, TDataStd_IntegerList>
IntegerList;
typedef listT <real, TDataStd_RealList>
RealList;
typedef listT <integer, TDataStd_BooleanList>
BooleanList;
typedef listT <persistent, TDataStd_ExtStringList, stringConverter>
ExtStringList;
typedef listT <persistent, TDataStd_ReferenceList, referenceConverter>
ReferenceList;
typedef mapT <integer, TDataStd_IntPackedMap>
IntPackedMap;
typedef instance_1<IntegerArray> IntegerArray_1;
typedef instance_1<RealArray> RealArray_1;
typedef instance_1<ByteArray> ByteArray_1;
typedef instance_1<ExtStringArray> ExtStringArray_1;
typedef instance_1<IntPackedMap> IntPackedMap_1;
};
#endif

View File

@ -11,53 +11,50 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <StdLPersistent_PDF_Data.hxx>
#include <StdLPersistent_Data.hxx>
#include <StdObjMgt_ReadData.hxx>
#include <TDF_Data.hxx>
#include <TDF_Attribute.hxx>
//! Create a transient label tree from persistent data
class StdLPersistent_PDF_Data::Parser
class StdLPersistent_Data::Parser
{
public:
//! Start parsing a persistent data.
Parser (const StdLPersistent_PDF_Data& theSource)
: myLabelsIter (theSource.myLabels->Array())
, myAttribIter (theSource.myAttributes->Array()) {}
Parser (const TColStd_HArray1OfInteger& theLabels,
const StdLPersistent_HArray1OfPersistent& theAttributes)
: myLabelsIter (theLabels)
, myAttribIter (theAttributes) {}
//! Fill a transient label with data.
void FillLabel (TDF_Label theLabel)
{
Standard_Integer i;
// Read count of attributes
// Read attributes count
myLabelsIter.Next();
Standard_Integer anAttribCount = myLabelsIter.Value();
// Add attributes to the label
for (i = 0 ; i < anAttribCount; i++)
for (i = 0; i < anAttribCount; i++)
{
// read persistent attribute
const Handle(StdObjMgt_Persistent)& aPAttrib = myAttribIter.Value();
Handle(StdObjMgt_Persistent)& aPAttrib = myAttribIter.ChangeValue();
myAttribIter.Next();
// create transient attribute and add it to the label
if (!aPAttrib.IsNull())
{
Handle(TDF_Attribute) aTAttrib = aPAttrib->ImportAttribute();
if (!aTAttrib.IsNull())
theLabel.AddAttribute (aTAttrib);
}
if (aPAttrib)
theLabel.AddAttribute (aPAttrib->CreateAttribute());
}
// Read count of child labels
// Read child labels count
myLabelsIter.Next();
Standard_Integer aSubLabelsCount = myLabelsIter.Value();
// Create child labels
for (i = 0 ; i < aSubLabelsCount; i++)
for (i = 0; i < aSubLabelsCount; i++)
{
// read tag of child label
myLabelsIter.Next();
@ -70,15 +67,15 @@ public:
}
private:
NCollection_Array1<Standard_Integer >::Iterator myLabelsIter;
NCollection_Array1<Handle(StdObjMgt_Persistent)>::Iterator myAttribIter;
TColStd_HArray1OfInteger ::Iterator myLabelsIter;
StdLPersistent_HArray1OfPersistent::Iterator myAttribIter;
};
//=======================================================================
//function : Read
//purpose : Read persistent data from a file
//=======================================================================
void StdLPersistent_PDF_Data::Read (StdObjMgt_ReadData& theReadData)
void StdLPersistent_Data::Read (StdObjMgt_ReadData& theReadData)
{
theReadData >> myVersion >> myLabels >> myAttributes;
}
@ -87,12 +84,23 @@ void StdLPersistent_PDF_Data::Read (StdObjMgt_ReadData& theReadData)
//function : Import
//purpose : Import transient data from the persistent data
//=======================================================================
Handle(TDF_Data) StdLPersistent_PDF_Data::Import() const
Handle(TDF_Data) StdLPersistent_Data::Import() const
{
if (myLabels.IsNull() || myAttributes.IsNull())
return NULL;
// Create tree of labels and add empty transient attributes to them
Handle(TDF_Data) aData = new TDF_Data;
Parser (*this).FillLabel (aData->Root());
Parser (*myLabels->Array(), *myAttributes->Array()).FillLabel (aData->Root());
// Import transient attribuites from persistent data
StdLPersistent_HArray1OfPersistent::Iterator anAttribIter (*myAttributes->Array());
for (; anAttribIter.More(); anAttribIter.Next())
{
Handle(StdObjMgt_Persistent)& aPAttrib = anAttribIter.ChangeValue();
if (aPAttrib)
aPAttrib->ImportAttribute();
}
return aData;
}

View File

@ -12,17 +12,16 @@
// commercial license or contractual agreement.
#ifndef _StdLPersistent_PDF_Data_HeaderFile
#define _StdLPersistent_PDF_Data_HeaderFile
#ifndef _StdLPersistent_Data_HeaderFile
#define _StdLPersistent_Data_HeaderFile
#include <StdObjMgt_Persistent.hxx>
#include <StdLPersistent_PColStd_HArray1.hxx>
#include <StdLPersistent_HArray1.hxx>
class TDF_Data;
class StdLPersistent_PDF_Data : public StdObjMgt_Persistent
class StdLPersistent_Data : public StdObjMgt_Persistent
{
public:
//! Read persistent data from a file.
@ -35,9 +34,9 @@ private:
class Parser;
private:
Standard_Integer myVersion;
Handle(StdLPersistent_PColStd_HArray1OfInteger) myLabels;
Handle(StdLPersistent_PDF_HAttributeArray1) myAttributes;
Value <Standard_Integer> myVersion;
Reference <StdLPersistent_HArray1::Integer> myLabels;
Reference <StdLPersistent_HArray1::Persistent> myAttributes;
};
#endif

View File

@ -0,0 +1,51 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <StdLPersistent_Dependency.hxx>
static void ImportName (const Handle(TDataStd_Expression)& theAttribute,
const TCollection_ExtendedString& theName)
{ theAttribute->SetExpression (theName); }
static void ImportName (const Handle(TDataStd_Relation)& theAttribute,
const TCollection_ExtendedString& theName)
{ theAttribute->SetRelation (theName); }
//=======================================================================
//function : Import
//purpose : Import transient attribuite from the persistent data
//=======================================================================
template <class AttribClass>
void StdLPersistent_Dependency::instance<AttribClass>::Import
(const Handle(AttribClass)& theAttribute) const
{
if (myName)
ImportName (theAttribute, myName->Value()->String());
if (myVariables)
{
StdLPersistent_HArray1OfPersistent::Iterator anIter (*myVariables->Array());
for (; anIter.More(); anIter.Next())
{
const Handle(StdObjMgt_Persistent) aPersistent = anIter.Value();
if (aPersistent)
theAttribute->GetVariables().Append (aPersistent->GetAttribute());
}
}
}
template class StdLPersistent_Dependency::instance<TDataStd_Expression>;
template class StdLPersistent_Dependency::instance<TDataStd_Relation>;

View File

@ -0,0 +1,49 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _StdLPersistent_Dependency_HeaderFile
#define _StdLPersistent_Dependency_HeaderFile
#include <StdObjMgt_Attribute.hxx>
#include <StdLPersistent_HString.hxx>
#include <StdLPersistent_HArray1.hxx>
#include <TDataStd_Expression.hxx>
#include <TDataStd_Relation.hxx>
class StdLPersistent_Dependency
{
template <class AttribClass>
class instance : public StdObjMgt_Attribute<AttribClass>
{
public:
//! Read persistent data from a file.
inline void Read (StdObjMgt_ReadData& theReadData)
{ theReadData >> myName >> myVariables; }
//! Import transient attribuite from the persistent data.
void Import (const Handle(AttribClass)& theAttribute) const;
private:
StdObjMgt_ContentTypes::Reference<StdLPersistent_HString::Extended> myName;
StdObjMgt_ContentTypes::Reference<StdLPersistent_HArray1::Persistent> myVariables;
};
public:
typedef instance<TDataStd_Expression> Expression;
typedef instance<TDataStd_Relation> Relation;
};
#endif

View File

@ -11,19 +11,19 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <StdLPersistent_PDocStd_Document.hxx>
#include <StdLPersistent_PDF_Data.hxx>
#include <StdLPersistent_Document.hxx>
#include <StdLPersistent_Data.hxx>
#include <StdObjMgt_ReadData.hxx>
#include <TDocStd_Document.hxx>
#include <TDocStd_Owner.hxx>
//=======================================================================
//function : Read
//purpose : Read persistent data from a file
//=======================================================================
void StdLPersistent_PDocStd_Document::Read (StdObjMgt_ReadData& theReadData)
void StdLPersistent_Document::Read (StdObjMgt_ReadData& theReadData)
{
theReadData >> myData;
}
@ -32,13 +32,16 @@ void StdLPersistent_PDocStd_Document::Read (StdObjMgt_ReadData& theReadData)
//function : Import
//purpose : Import transient document from the persistent data
//=======================================================================
void StdLPersistent_PDocStd_Document::Import (const Handle(CDM_Document)& theDocument) const
void StdLPersistent_Document::ImportDocument
(const Handle(TDocStd_Document)& theDocument) const
{
Handle(TDocStd_Document) aDocument = Handle(TDocStd_Document)::DownCast (theDocument);
if (aDocument.IsNull() || myData.IsNull())
if (theDocument.IsNull() || myData.IsNull())
return;
Handle(TDF_Data) aData = myData->Import();
aDocument->SetData (aData);
TDocStd_Owner::SetDocument (aData, aDocument);
if (aData.IsNull())
return;
theDocument->SetData (aData);
TDocStd_Owner::SetDocument (aData, theDocument);
}

View File

@ -12,26 +12,27 @@
// commercial license or contractual agreement.
#ifndef _StdLPersistent_PDocStd_Document_HeaderFile
#define _StdLPersistent_PDocStd_Document_HeaderFile
#ifndef _StdLPersistent_Document_HeaderFile
#define _StdLPersistent_Document_HeaderFile
#include <StdObjMgt_Persistent.hxx>
class CDM_Document;
class StdLPersistent_PDF_Data;
class TDocStd_Document;
class StdLPersistent_Data;
class StdLPersistent_PDocStd_Document : public StdObjMgt_Persistent
class StdLPersistent_Document : public StdObjMgt_Persistent
{
public:
//! Read persistent data from a file.
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
//! Import transient document from the persistent data.
Standard_EXPORT void Import (const Handle(CDM_Document)& theDocument) const;
Standard_EXPORT virtual void ImportDocument
(const Handle(TDocStd_Document)& theDocument) const;
private:
Handle(StdLPersistent_PDF_Data) myData;
Reference<StdLPersistent_Data> myData;
};
#endif

View File

@ -0,0 +1,43 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _StdLPersistent_Function_HeaderFile
#define _StdLPersistent_Function_HeaderFile
#include <StdObjMgt_Attribute.hxx>
#include <StdLObject_GUID.hxx>
#include <TFunction_Function.hxx>
class StdLPersistent_Function : public StdObjMgt_Attribute<TFunction_Function>
{
public:
//! Read persistent data from a file.
inline void Read (StdObjMgt_ReadData& theReadData)
{ theReadData >> myDriverGUID >> myFailure; }
//! Import transient attribuite from the persistent data.
void Import (const Handle(TFunction_Function)& theAttribute) const
{
theAttribute->SetDriverGUID (myDriverGUID);
theAttribute->SetFailure (myFailure);
}
private:
Object<StdLObject_GUID> myDriverGUID;
Value<Standard_Integer> myFailure;
};
#endif

View File

@ -0,0 +1,55 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <StdLPersistent_HArray1.hxx>
#include <StdObjMgt_ReadData.hxx>
//=======================================================================
//function : Read
//purpose : Read persistent data from a file
//=======================================================================
void StdLPersistent_HArray1::commonBase::Read (StdObjMgt_ReadData& theReadData)
{
Value<Standard_Integer> aLowerBound, anUpperBound;
theReadData >> aLowerBound >> anUpperBound;
createArray (aLowerBound, anUpperBound);
theReadData.Driver().BeginReadObjectData();
Standard_Integer aSize;
theReadData.ReadValue (aSize);
for (Standard_Integer i = aLowerBound; i <= anUpperBound; i++)
readValue (theReadData, i);
theReadData.Driver().EndReadObjectData();
}
template <class ArrayClass, class ValueClass>
void StdLPersistent_HArray1::instance<ArrayClass, ValueClass>::readValue (
StdObjMgt_ReadData& theReadData,
const Standard_Integer theIndex)
{
ValueClass aValue;
theReadData >> aValue;
this->myArray->SetValue (theIndex, static_cast<typename ArrayClass::value_type> (aValue));
}
template class StdLPersistent_HArray1::instance<TColStd_HArray1OfInteger>;
template class StdLPersistent_HArray1::instance<TColStd_HArray1OfReal>;
template class StdLPersistent_HArray1::instance<TColStd_HArray1OfByte,
StdObjMgt_ContentTypes::Value<Standard_Character> >;
template class StdLPersistent_HArray1::instance<StdLPersistent_HArray1OfPersistent,
StdObjMgt_ContentTypes::Reference<> >;

View File

@ -0,0 +1,83 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _StdLPersistent_HArray1_HeaderFile
#define _StdLPersistent_HArray1_HeaderFile
#include <StdObjMgt_Persistent.hxx>
#include <StdLPersistent_HArray1OfPersistent.hxx>
#include <TColStd_HArray1OfInteger.hxx>
#include <TColStd_HArray1OfReal.hxx>
#include <TColStd_HArray1OfByte.hxx>
class TCollection_HExtendedString;
class TDF_Label;
class TDF_Data;
class StdLPersistent_HArray1 : protected StdObjMgt_ContentTypes
{
class commonBase : public StdObjMgt_Persistent
{
public:
//! Read persistent data from a file.
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
protected:
virtual void createArray (const Standard_Integer theLowerBound,
const Standard_Integer theUpperBound) = 0;
virtual void readValue (StdObjMgt_ReadData& theReadData,
const Standard_Integer theIndex) = 0;
};
protected:
template <class ArrayClass>
class base : public commonBase
{
public:
typedef Handle(ArrayClass) ArrayHandle;
typedef typename ArrayClass::value_type ValueType;
typedef typename ArrayClass::Iterator Iterator;
public:
//! Get the array.
const Handle(ArrayClass)& Array() const { return myArray; }
protected:
virtual void createArray (const Standard_Integer theLowerBound,
const Standard_Integer theUpperBound)
{ myArray = new ArrayClass (theLowerBound, theUpperBound); }
protected:
Handle(ArrayClass) myArray;
};
private:
template <class ArrayClass, class ValueClass = Value<typename ArrayClass::value_type> >
class instance : public base<ArrayClass>
{
protected:
Standard_EXPORT virtual void readValue (StdObjMgt_ReadData& theReadData,
const Standard_Integer theIndex);
};
public:
typedef instance<TColStd_HArray1OfInteger> Integer;
typedef instance<TColStd_HArray1OfReal> Real;
typedef instance<TColStd_HArray1OfByte, Value<Standard_Character> >Byte;
typedef instance<StdLPersistent_HArray1OfPersistent, Reference<> > Persistent;
};
#endif

View File

@ -11,26 +11,14 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _StdLPersistent_HArray1OfPersistent_HeaderFile
#define _StdLPersistent_HArray1OfPersistent_HeaderFile
#ifndef _StdLPersistent_PCollection_HExtendedString_HeaderFile
#define _StdLPersistent_PCollection_HExtendedString_HeaderFile
#include <NCollection_DefineHArray1.hxx>
#include <StdObjMgt_Persistent.hxx>
class TCollection_HExtendedString;
DEFINE_HARRAY1 (StdLPersistent_HArray1OfPersistent,
NCollection_Array1<Handle(StdObjMgt_Persistent)>)
class StdLPersistent_PCollection_HExtendedString : public StdObjMgt_Persistent
{
public:
//! Read persistent data from a file.
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
//! Get the value.
Handle(TCollection_HExtendedString) Value() const { return myValue; }
private:
Handle(TCollection_HExtendedString) myValue;
};
#endif
#endif // _StdLPersistent_HArray1OfPersistent_HeaderFile

View File

@ -0,0 +1,56 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <StdLPersistent_HArray2.hxx>
#include <StdObjMgt_ReadData.hxx>
#include <TColStd_HArray2OfInteger.hxx>
#include <TColStd_HArray2OfReal.hxx>
//=======================================================================
//function : Read
//purpose : Read persistent data from a file
//=======================================================================
void StdLPersistent_HArray2::commonBase::Read (StdObjMgt_ReadData& theReadData)
{
Value<Standard_Integer> aLowerRow, aLowerCol, anUpperRow, anUpperCol;
theReadData >> aLowerRow >> aLowerCol >> anUpperRow >> anUpperCol;
createArray (aLowerRow, aLowerCol, anUpperRow, anUpperCol);
theReadData.Driver().BeginReadObjectData();
Standard_Integer aSize;
theReadData.ReadValue (aSize);
for (Standard_Integer aRow = aLowerRow; aRow <= anUpperRow; aRow++)
for (Standard_Integer aCol = aLowerCol; aCol <= anUpperCol; aCol++)
readValue (theReadData, aRow, aCol);
theReadData.Driver().EndReadObjectData();
}
template <class ArrayClass>
void StdLPersistent_HArray2::instance<ArrayClass>::readValue (
StdObjMgt_ReadData& theReadData,
const Standard_Integer theRow,
const Standard_Integer theCol)
{
typename ArrayClass::value_type aValue;
theReadData.ReadValue (aValue);
this->myArray->SetValue (theRow, theCol, aValue);
}
template class StdLPersistent_HArray2::instance<TColStd_HArray2OfInteger>;
template class StdLPersistent_HArray2::instance<TColStd_HArray2OfReal>;

View File

@ -0,0 +1,82 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _StdLPersistent_HArray2_HeaderFile
#define _StdLPersistent_HArray2_HeaderFile
#include <StdObjMgt_Persistent.hxx>
#include <TColStd_HArray2OfInteger.hxx>
#include <TColStd_HArray2OfReal.hxx>
class StdLPersistent_HArray2
{
class commonBase : public StdObjMgt_Persistent
{
public:
//! Read persistent data from a file.
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
protected:
virtual void createArray (
const Standard_Integer theLowerRow, const Standard_Integer theLowerCol,
const Standard_Integer theUpperRow, const Standard_Integer theUpperCol)
= 0;
virtual void readValue (StdObjMgt_ReadData& theReadData,
const Standard_Integer theRow,
const Standard_Integer theCol) = 0;
};
protected:
template <class ArrayClass>
class base : public commonBase
{
public:
typedef Handle(ArrayClass) ArrayHandle;
public:
//! Get the array.
const Handle(ArrayClass)& Array() const { return myArray; }
protected:
virtual void createArray (
const Standard_Integer theLowerRow, const Standard_Integer theLowerCol,
const Standard_Integer theUpperRow, const Standard_Integer theUpperCol)
{
myArray = new ArrayClass (theLowerRow, theUpperRow,
theLowerCol, theUpperCol);
}
protected:
Handle(ArrayClass) myArray;
};
private:
template <class ArrayClass>
class instance : public base<ArrayClass>
{
protected:
Standard_EXPORT virtual void readValue (StdObjMgt_ReadData& theReadData,
const Standard_Integer theRow,
const Standard_Integer theCol);
};
public:
typedef instance<TColStd_HArray2OfInteger> Integer;
typedef instance<TColStd_HArray2OfReal> Real;
};
#endif

View File

@ -0,0 +1,81 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <StdLPersistent_HString.hxx>
#include <StdObjMgt_ReadData.hxx>
#include <TDF_Label.hxx>
#include <TDF_Tool.hxx>
//=======================================================================
//function : Read
//purpose : Read persistent data from a file
//=======================================================================
template <class StringClass, typename CharType>
void StdLPersistent_HString::instance<StringClass, CharType>::Read
(StdObjMgt_ReadData& theReadData)
{
theReadData.Driver().BeginReadObjectData();
Standard_Integer aSize;
theReadData.ReadValue (aSize);
myValue = new StringClass (aSize, 0);
for (Standard_Integer i = 1; i <= aSize; i++)
{
CharType aChar;
theReadData.ReadValue (aChar);
myValue->SetValue (i, aChar);
}
theReadData.Driver().EndReadObjectData();
}
//=======================================================================
//function : Label
//purpose : Get/create a label defined by referenced string
//=======================================================================
template <class StringClass, typename CharType>
TDF_Label StdLPersistent_HString::instance<StringClass, CharType>::Label
(const Handle(TDF_Data)& theDF) const
{
TDF_Label aLabel;
if (!myValue.IsNull())
TDF_Tool::Label (theDF, myValue->String(), aLabel, Standard_True);
return aLabel;
}
//=======================================================================
//function : AsciiString
//purpose : Get referenced ASCII string
//=======================================================================
Handle(TCollection_HAsciiString)
StdLPersistent_HString::Ascii::AsciiString() const
{ return myValue; }
//=======================================================================
//function : ExtString
//purpose : Get referenced extended string
//=======================================================================
Handle(TCollection_HExtendedString)
StdLPersistent_HString::Extended::ExtString() const
{ return myValue; }
template class StdLPersistent_HString::instance
<TCollection_HAsciiString, Standard_Character>;
template class StdLPersistent_HString::instance
<TCollection_HExtendedString, Standard_ExtCharacter>;

View File

@ -0,0 +1,62 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _StdLPersistent_HString_HeaderFile
#define _StdLPersistent_HString_HeaderFile
#include <StdObjMgt_Persistent.hxx>
#include <Standard_TypeDef.hxx>
#include <TCollection_HAsciiString.hxx>
#include <TCollection_HExtendedString.hxx>
class StdLPersistent_HString
{
template <class StringClass, typename CharType>
class instance : public StdObjMgt_Persistent
{
public:
//! Read persistent data from a file.
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
//! Get/create a label defined by referenced string.
Standard_EXPORT virtual TDF_Label Label (const Handle(TDF_Data)& theDF) const;
//! Get the value.
const Handle(StringClass)& Value() const { return myValue; }
protected:
Handle(StringClass) myValue;
};
public:
class Ascii
: public instance<TCollection_HAsciiString, Standard_Character>
{
public:
//! Get referenced ASCII string.
Standard_EXPORT virtual Handle(TCollection_HAsciiString) AsciiString() const;
};
class Extended
: public instance<TCollection_HExtendedString, Standard_ExtCharacter>
{
public:
//! Get referenced extended string.
Standard_EXPORT virtual Handle(TCollection_HExtendedString) ExtString() const;
};
};
#endif

View File

@ -0,0 +1,137 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <StdLPersistent_NamedData.hxx>
#include <TCollection_HExtendedString.hxx>
#include <TColStd_DataMapOfStringInteger.hxx>
#include <TDataStd_DataMapOfStringReal.hxx>
#include <TDataStd_DataMapOfStringString.hxx>
#include <TDataStd_DataMapOfStringByte.hxx>
#include <TDataStd_DataMapOfStringHArray1OfInteger.hxx>
#include <TDataStd_DataMapOfStringHArray1OfReal.hxx>
//=======================================================================
//function : Import
//purpose : Import transient attribuite from the persistent data
//=======================================================================
void StdLPersistent_NamedData::Import
(const Handle(TDataStd_NamedData)& theAttribute) const
{
if (myDimensions.IsNull())
return;
if (myInts)
{
TColStd_DataMapOfStringInteger aMap;
for (Standard_Integer i = lower(0); i <= upper(0); i++)
{
Standard_Integer aValue = 0;
aMap.Bind (myInts.Get (i, aValue), aValue);
}
theAttribute->ChangeIntegers (aMap);
}
if (myReals)
{
TDataStd_DataMapOfStringReal aMap;
for (Standard_Integer i = lower(1); i <= upper(1); i++)
{
Standard_Real aValue = 0.0;
aMap.Bind (myReals.Get (i, aValue), aValue);
}
theAttribute->ChangeReals (aMap);
}
if (myStrings)
{
TDataStd_DataMapOfStringString aMap;
for (Standard_Integer i = lower(2); i <= upper(2); i++)
{
Handle(StdObjMgt_Persistent) aValue;
aMap.Bind (myStrings.Get (i, aValue),
aValue ? aValue->ExtString()->String()
: TCollection_ExtendedString());
}
theAttribute->ChangeStrings (aMap);
}
if (myBytes)
{
TDataStd_DataMapOfStringByte aMap;
for (Standard_Integer i = lower(3); i <= upper(3); i++)
{
Standard_Byte aValue = 0;
aMap.Bind (myBytes.Get (i, aValue), aValue);
}
theAttribute->ChangeBytes (aMap);
}
if (myIntArrays)
{
TDataStd_DataMapOfStringHArray1OfInteger aMap;
for (Standard_Integer i = lower(4); i <= upper(4); i++)
{
Handle(StdObjMgt_Persistent) aValue;
const TCollection_ExtendedString& aKey = myIntArrays.Get (i, aValue);
Handle(StdLPersistent_HArray1::Integer) aPArray =
Handle(StdLPersistent_HArray1::Integer)::DownCast (aValue);
Handle(TColStd_HArray1OfInteger) aTArray;
if (aPArray)
aTArray = aPArray->Array();
aMap.Bind (aKey, aTArray);
}
theAttribute->ChangeArraysOfIntegers (aMap);
}
if (myRealArrays)
{
TDataStd_DataMapOfStringHArray1OfReal aMap;
for (Standard_Integer i = lower(5); i <= upper(5); i++)
{
Handle(StdObjMgt_Persistent) aValue;
const TCollection_ExtendedString& aKey = myRealArrays.Get (i, aValue);
Handle(StdLPersistent_HArray1::Real) aPArray =
Handle(StdLPersistent_HArray1::Real)::DownCast (aValue);
Handle(TColStd_HArray1OfReal) aTArray;
if (aPArray)
aTArray = aPArray->Array();
aMap.Bind (aKey, aTArray);
}
theAttribute->ChangeArraysOfReals (aMap);
}
}
Standard_Integer
StdLPersistent_NamedData::lower (Standard_Integer theIndex) const
{
const Handle(TColStd_HArray2OfInteger)& aDimensions = myDimensions->Array();
return aDimensions->Value (aDimensions->LowerRow() + theIndex,
aDimensions->LowerCol());
}
Standard_Integer
StdLPersistent_NamedData::upper (Standard_Integer theIndex) const
{
const Handle(TColStd_HArray2OfInteger)& aDimensions = myDimensions->Array();
return aDimensions->Value (aDimensions->LowerRow() + theIndex,
aDimensions->UpperCol());
}

View File

@ -0,0 +1,76 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _StdLPersistent_NamedData_HeaderFile
#define _StdLPersistent_NamedData_HeaderFile
#include <StdObjMgt_Attribute.hxx>
#include <StdLPersistent_HArray1.hxx>
#include <StdLPersistent_HArray2.hxx>
#include <TDataStd_NamedData.hxx>
#include <TCollection_HExtendedString.hxx>
class StdLPersistent_NamedData : public StdObjMgt_Attribute<TDataStd_NamedData>
{
template <class HValuesArray>
class element
{
public:
inline void Read (StdObjMgt_ReadData& theReadData)
{ theReadData >> myKeys >> myValues; }
inline operator bool() const
{ return ! myKeys.IsNull(); }
template <class Value>
inline const TCollection_ExtendedString& Get
(Standard_Integer theIndex, Value& theValue) const
{
if (myValues)
theValue = myValues->Array()->Value(theIndex);
return myKeys->Array()->Value(theIndex)->ExtString()->String();
}
private:
Reference <StdLPersistent_HArray1::Persistent> myKeys;
Reference <HValuesArray> myValues;
};
public:
//! Read persistent data from a file.
inline void Read (StdObjMgt_ReadData& theReadData)
{
theReadData >> myDimensions >>
myInts >> myReals >> myStrings >> myBytes >> myIntArrays >> myRealArrays;
}
//! Import transient attribuite from the persistent data.
void Import (const Handle(TDataStd_NamedData)& theAttribute) const;
private:
inline Standard_Integer lower (Standard_Integer theIndex) const;
inline Standard_Integer upper (Standard_Integer theIndex) const;
private:
Reference <StdLPersistent_HArray2::Integer> myDimensions;
Object <element<StdLPersistent_HArray1::Integer> > myInts;
Object <element<StdLPersistent_HArray1::Real> > myReals;
Object <element<StdLPersistent_HArray1::Persistent> > myStrings;
Object <element<StdLPersistent_HArray1::Byte> > myBytes;
Object <element<StdLPersistent_HArray1::Persistent> > myIntArrays;
Object <element<StdLPersistent_HArray1::Persistent> > myRealArrays;
};
#endif

View File

@ -1,62 +0,0 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _StdLPersistent_PColStd_HArray1_HeaderFile
#define _StdLPersistent_PColStd_HArray1_HeaderFile
#include <StdLPersistent_PColStd_HArray1Base.hxx>
#include <StdObjMgt_ReadData.hxx>
#include <NCollection_Handle.hxx>
#include <NCollection_Array1.hxx>
#include <Standard_TypeDef.hxx>
class StdObjMgt_Persistent;
template <class Type>
class StdLPersistent_PColStd_HArray1 : public StdLPersistent_PColStd_HArray1Base
{
public:
//! Get the value.
const NCollection_Array1<Type>& Array() const { return *myArray; }
protected:
virtual void CreateArray (const Standard_Integer theLowerBound,
const Standard_Integer theUpperBound)
{
myArray = new NCollection_Array1<Type> (theLowerBound, theUpperBound);
}
virtual void ReadValue (StdObjMgt_ReadData& theReadData,
const Standard_Integer theIndex)
{
Type aValue;
theReadData >> aValue;
myArray->SetValue (theIndex, aValue);
}
private:
NCollection_Handle<NCollection_Array1<Type>> myArray;
};
typedef StdLPersistent_PColStd_HArray1<Standard_Integer>
StdLPersistent_PColStd_HArray1OfInteger;
typedef StdLPersistent_PColStd_HArray1<Handle(StdObjMgt_Persistent)>
StdLPersistent_PDF_HAttributeArray1;
#endif

View File

@ -12,25 +12,32 @@
// commercial license or contractual agreement.
#ifndef _StdLPersistent_PDataStd_Name_HeaderFile
#define _StdLPersistent_PDataStd_Name_HeaderFile
#ifndef _StdLPersistent_Real_HeaderFile
#define _StdLPersistent_Real_HeaderFile
#include <StdObjMgt_Persistent.hxx>
#include <StdObjMgt_Attribute.hxx>
class StdLPersistent_PCollection_HExtendedString;
#include <TDataStd_Real.hxx>
#include <TDataStd_RealEnum.hxx>
class StdLPersistent_PDataStd_Name : public StdObjMgt_Persistent
class StdLPersistent_Real : public StdObjMgt_Attribute<TDataStd_Real>
{
public:
//! Read persistent data from a file.
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
inline void Read (StdObjMgt_ReadData& theReadData)
{ theReadData >> myValue >> myDimension; }
//! Import transient attribuite from the persistent data.
Standard_EXPORT virtual Handle(TDF_Attribute) ImportAttribute() const;
void Import (const Handle(TDataStd_Real)& theAttribute) const
{
theAttribute->Set (myValue);
theAttribute->SetDimension (myDimension);
}
private:
Handle(StdLPersistent_PCollection_HExtendedString) myString;
Value<Standard_Real> myValue;
Enum<TDataStd_RealEnum> myDimension;
};
#endif

View File

@ -0,0 +1,58 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <StdLPersistent_TreeNode.hxx>
//=======================================================================
//function : Read
//purpose : Read persistent data from a file
//=======================================================================
void StdLPersistent_TreeNode::Read (StdObjMgt_ReadData& theReadData)
{
myDynamicData = new dynamic;
theReadData >> myDynamicData->First >> myNext >> myDynamicData->TreeID;
}
//=======================================================================
//function : CreateAttribute
//purpose : Create an empty transient attribuite
//=======================================================================
Handle(TDF_Attribute) StdLPersistent_TreeNode::CreateAttribute()
{
Static::CreateAttribute();
myTransient->SetTreeID (myDynamicData->TreeID);
return myTransient;
}
//=======================================================================
//function : ImportAttribute
//purpose : Import transient attribuite from the persistent data
//=======================================================================
void StdLPersistent_TreeNode::ImportAttribute()
{
if (myDynamicData)
{
Handle(StdLPersistent_TreeNode) aChild = myDynamicData->First;
while (aChild)
{
if (aChild->myTransient)
myTransient->Append(aChild->myTransient);
StdLPersistent_TreeNode* aCurr = aChild.get();
aChild = aChild->myNext;
aCurr->myNext.Nullify(); // this reference is no longer needed
}
myDynamicData.Nullify();
}
}

View File

@ -0,0 +1,48 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _StdLPersistent_TreeNode_HeaderFile
#define _StdLPersistent_TreeNode_HeaderFile
#include <StdObjMgt_Attribute.hxx>
#include <StdLObject_GUID.hxx>
#include <TDataStd_TreeNode.hxx>
class StdLPersistent_TreeNode
: public StdObjMgt_Attribute<TDataStd_TreeNode>::Static
{
public:
//! Read persistent data from a file.
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
//! Create an empty transient attribuite
Standard_EXPORT virtual Handle(TDF_Attribute) CreateAttribute();
//! Import transient attribuite from the persistent data.
Standard_EXPORT virtual void ImportAttribute();
private:
struct dynamic : public Standard_Transient
{
Reference <StdLPersistent_TreeNode> First;
Object <StdLObject_GUID> TreeID;
};
Handle(dynamic) myDynamicData;
Reference<StdLPersistent_TreeNode> myNext;
};
#endif

View File

@ -0,0 +1,97 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <StdLPersistent_Value.hxx>
#include <TCollection_HExtendedString.hxx>
#include <Standard_GUID.hxx>
//=======================================================================
//function : ImportAttribute
//purpose : Import transient attribuite from the persistent data
//=======================================================================
template <class AttribClass>
void StdLPersistent_Value::integer<AttribClass>::ImportAttribute()
{
this->myTransient->Set (this->myData);
}
//=======================================================================
//function : ImportAttribute
//purpose : Import transient attribuite from the persistent data
//=======================================================================
template <class AttribClass, class HStringClass>
void StdLPersistent_Value::string<AttribClass, HStringClass>::ImportAttribute()
{
Handle(HStringClass) anHString;
if (this->myData.Cast (anHString))
{
this->myTransient->Set (anHString->Value()->String());
this->myData.Nullify();
}
}
//=======================================================================
//function : ImportAttribute
//purpose : Import transient attribuite from the persistent data
//=======================================================================
template<>
void StdLPersistent_Value::string<TDF_Reference>::ImportAttribute()
{
if (this->myData)
{
TDF_Label aLabel = myData->Label (this->myTransient->Label().Data());
if (!aLabel.IsNull())
this->myTransient->Set (aLabel);
this->myData.Nullify();
}
}
//=======================================================================
//function : ImportAttribute
//purpose : Import transient attribuite from the persistent data
//=======================================================================
template<>
void StdLPersistent_Value::string<TDataStd_UAttribute>::ImportAttribute()
{}
//=======================================================================
//function : CreateAttribute
//purpose : Create an empty transient attribuite
//=======================================================================
Handle(TDF_Attribute) StdLPersistent_Value::UAttribute::CreateAttribute()
{
string<TDataStd_UAttribute,StdLPersistent_HString::Extended>::CreateAttribute();
if (this->myData)
{
Handle(TCollection_HExtendedString) aString = this->myData->ExtString();
if (aString)
this->myTransient->SetID (Standard_GUID (aString->String().ToExtString()));
this->myData.Nullify();
}
return this->myTransient;
}
template class StdLPersistent_Value::integer <TDataStd_Integer>;
template class StdLPersistent_Value::integer <TDF_TagSource>;
template class StdLPersistent_Value::string <TDF_Reference>;
template class StdLPersistent_Value::string <TDataStd_UAttribute>;
template class StdLPersistent_Value::string <TDataStd_Name>;
template class StdLPersistent_Value::string <TDataStd_Comment>;
template class StdLPersistent_Value::string <TDataStd_AsciiString,
StdLPersistent_HString::Ascii>;

View File

@ -0,0 +1,67 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _StdLPersistent_Value_HeaderFile
#define _StdLPersistent_Value_HeaderFile
#include <StdObjMgt_Attribute.hxx>
#include <StdLPersistent_HString.hxx>
#include <TDataStd_Integer.hxx>
#include <TDF_TagSource.hxx>
#include <TDF_Reference.hxx>
#include <TDataStd_UAttribute.hxx>
#include <TDataStd_Name.hxx>
#include <TDataStd_Comment.hxx>
#include <TDataStd_AsciiString.hxx>
class StdLPersistent_Value
{
template <class AttribClass>
class integer : public StdObjMgt_Attribute<AttribClass>::SingleInt
{
public:
//! Import transient attribuite from the persistent data.
Standard_EXPORT virtual void ImportAttribute();
};
template <class AttribClass,
class HStringClass = StdLPersistent_HString::Extended>
class string : public StdObjMgt_Attribute<AttribClass>::SingleRef
{
public:
//! Import transient attribuite from the persistent data.
Standard_EXPORT virtual void ImportAttribute();
};
public:
typedef integer <TDataStd_Integer> Integer;
typedef integer <TDF_TagSource> TagSource;
typedef string <TDF_Reference> Reference;
typedef string <TDataStd_Name> Name;
typedef string <TDataStd_Comment> Comment;
typedef string <TDataStd_AsciiString,
StdLPersistent_HString::Ascii> AsciiString;
class UAttribute : public string <TDataStd_UAttribute>
{
public:
//! Create an empty transient attribuite
Standard_EXPORT virtual Handle(TDF_Attribute) CreateAttribute();
};
};
#endif

View File

@ -0,0 +1,44 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _StdLPersistent_Variable_HeaderFile
#define _StdLPersistent_Variable_HeaderFile
#include <StdObjMgt_Attribute.hxx>
#include <StdLPersistent_HString.hxx>
#include <TDataStd_Variable.hxx>
class StdLPersistent_Variable : public StdObjMgt_Attribute<TDataStd_Variable>
{
public:
//! Read persistent data from a file.
inline void Read (StdObjMgt_ReadData& theReadData)
{ theReadData >> myIsConstant >> myUnit; }
//! Import transient attribuite from the persistent data.
void Import (const Handle(TDataStd_Variable)& theAttribute) const
{
theAttribute->Constant (myIsConstant);
if (myUnit)
theAttribute->Unit (myUnit->Value()->String());
}
private:
Value <Standard_Boolean> myIsConstant;
Reference <StdLPersistent_HString::Ascii> myUnit;
};
#endif

View File

@ -0,0 +1,45 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _StdLPersistent_Void_HeaderFile
#define _StdLPersistent_Void_HeaderFile
#include <StdObjMgt_Attribute.hxx>
#include <TDataStd_Directory.hxx>
#include <TDataStd_Tick.hxx>
#include <TDataStd_NoteBook.hxx>
class StdLPersistent_Void
{
protected:
template <class AttribClass>
class instance : public StdObjMgt_Attribute<AttribClass>::Static
{
public:
//! Read persistent data from a file.
Standard_EXPORT virtual void Read (StdObjMgt_ReadData&) {}
//! Import transient attribuite from the persistent data
Standard_EXPORT virtual void ImportAttribute() {}
};
public:
typedef instance<TDataStd_Directory> Directory;
typedef instance<TDataStd_Tick> Tick;
typedef instance<TDataStd_NoteBook> NoteBook;
};
#endif

View File

@ -0,0 +1,46 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _StdLPersistent_XLink_HeaderFile
#define _StdLPersistent_XLink_HeaderFile
#include <StdObjMgt_Attribute.hxx>
#include <StdLPersistent_HString.hxx>
#include <TDocStd_XLink.hxx>
class StdLPersistent_XLink : public StdObjMgt_Attribute<TDocStd_XLink>
{
public:
//! Read persistent data from a file.
inline void Read (StdObjMgt_ReadData& theReadData)
{ theReadData >> myDocEntry >> myLabEntry; }
//! Import transient attribuite from the persistent data.
void Import (const Handle(TDocStd_XLink)& theAttribute) const
{
if (myDocEntry)
theAttribute->DocumentEntry (myDocEntry->Value()->String());
if (myLabEntry)
theAttribute->LabelEntry (myLabEntry->Value()->String());
}
private:
Reference<StdLPersistent_HString::Ascii> myDocEntry;
Reference<StdLPersistent_HString::Ascii> myLabEntry;
};
#endif

View File

@ -1,6 +1,9 @@
StdObjMgt_Attribute.hxx
StdObjMgt_ContentTypes.hxx
StdObjMgt_MapOfInstantiators.cxx
StdObjMgt_MapOfInstantiators.hxx
StdObjMgt_Persistent.cxx
StdObjMgt_Persistent.hxx
StdObjMgt_ReadData.cxx
StdObjMgt_ReadData.hxx
StdObjMgt_SharedObject.hxx

View File

@ -0,0 +1,91 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _StdObjMgt_Attribute_HeaderFile
#define _StdObjMgt_Attribute_HeaderFile
#include <StdObjMgt_Persistent.hxx>
#include <StdObjMgt_ReadData.hxx>
//! Root class for a temporary persistent object corresponding to an attribute.
template <class Transient>
class StdObjMgt_Attribute : public Standard_Transient,
protected StdObjMgt_ContentTypes
{
class base : public StdObjMgt_Persistent
{
public:
//! Create an empty transient attribuite
Standard_EXPORT virtual Handle(TDF_Attribute) CreateAttribute()
{ return myTransient = new Transient; }
//! Get transient attribuite for the persistent data
Standard_EXPORT virtual Handle(TDF_Attribute) GetAttribute() const
{ return Handle(TDF_Attribute)(myTransient); }
protected:
Handle(Transient) myTransient;
};
public:
class Static : public base {};
template <class DataType>
class Simple : public Static
{
public:
//! Read persistent data from a file.
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData)
{ theReadData >> myData; }
protected:
DataType myData;
};
struct SingleInt : Simple <Value<Standard_Integer> > {};
struct SingleRef : Simple <Reference<> > {};
private:
template <class Persistent>
class container : public base
{
public:
//! Read persistent data from a file.
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData)
{
myPersistent = new Persistent;
myPersistent->Read (theReadData);
}
//! Import transient attribuite from the persistent data
Standard_EXPORT virtual void ImportAttribute()
{
if (myPersistent && this->myTransient)
{
myPersistent->Import (this->myTransient);
myPersistent.Nullify();
}
}
private:
Handle(Persistent) myPersistent;
};
public:
template <class Persistent>
static Handle(StdObjMgt_Persistent) Instantiate()
{ return new container<Persistent>; }
};
#endif // _StdObjMgt_Attribute_HeaderFile

View File

@ -0,0 +1,102 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _StdObjMgt_ContentTypes_HeaderFile
#define _StdObjMgt_ContentTypes_HeaderFile
#include <StdObjMgt_ReadData.hxx>
class StdObjMgt_Persistent;
//! Root class for an object containing other obects.
class StdObjMgt_ContentTypes
{
template <typename Type>
class holder
{
public:
//! Return the value.
operator Type() const { return myValue; }
protected:
Type myValue;
};
template <typename Type>
struct enum_ : holder<Type>
{
//! Read the value from a file.
void Read (StdObjMgt_ReadData& theReadData)
{ theReadData.ReadEnum (this->myValue); }
};
template <typename Type>
struct value : holder<Type>
{
//! Read the value from a file.
void Read (StdObjMgt_ReadData& theReadData)
{ theReadData.ReadValue (this->myValue); }
};
template <class Class>
struct object : Class
{
//! Read object data from a file.
void Read (StdObjMgt_ReadData& theReadData)
{ theReadData.ReadObject ((Class&)*this); }
};
template <class Persistent>
struct referenceT : Handle(Persistent)
{
//! Read object data from a file.
void Read (StdObjMgt_ReadData& theReadData)
{ theReadData.ReadReference (*this); }
};
struct reference : Handle(StdObjMgt_Persistent)
{
//! Read object data from a file.
void Read (StdObjMgt_ReadData& theReadData)
{ Handle(StdObjMgt_Persistent)::operator= (theReadData.ReadReference()); }
//! Cast the reference to a target type.
template <class Persistent>
bool Cast (Handle(Persistent)& theTarget) const
{
theTarget = Handle(Persistent)::DownCast(*this);
return ! theTarget.IsNull();
}
};
public:
template <class Type>
struct Enum : StdObjMgt_ReadData::Content <enum_<Type> > {};
template <class Type>
struct Value : StdObjMgt_ReadData::Content <value<Type> > {};
template <class Class>
struct Object : StdObjMgt_ReadData::Content <object<Class> > {};
template <class Persistent = StdObjMgt_Persistent>
struct Reference : StdObjMgt_ReadData::Content <referenceT<Persistent> > {};
};
template<>
struct StdObjMgt_ContentTypes::Reference<StdObjMgt_Persistent>
: StdObjMgt_ReadData::Content <reference> {};
#endif // _StdObjMgt_ContentTypes_HeaderFile

View File

@ -25,21 +25,16 @@ class StdObjMgt_MapOfInstantiators
TCollection_AsciiString>
{
public:
template <class Type>
template <class Persistent>
void Bind (const TCollection_AsciiString& theTypeName)
{
NCollection_DataMap<TCollection_AsciiString,
StdObjMgt_Persistent::Instantiator,
TCollection_AsciiString>
::Bind (theTypeName, &Instantiate<Type>);
::Bind (theTypeName, Persistent::template Instantiate<Persistent>);
}
DEFINE_STANDARD_ALLOC
private:
template <class Type>
static Handle(StdObjMgt_Persistent) Instantiate()
{ return new Type; }
};
#endif // _StdObjMgt_MapOfInstantiators_HeaderFile

View File

@ -13,13 +13,65 @@
#include <StdObjMgt_Persistent.hxx>
//=======================================================================
//function : ImportDocument
//purpose : Import transient document from the persistent data
// (to be overriden by document class;
// does nothing by default for other classes).
//=======================================================================
void StdObjMgt_Persistent::ImportDocument
(const Handle(TDocStd_Document)&) const {}
//=======================================================================
//function : CreateAttribute
//purpose : Create an empty transient attribuite
// (to be overriden by attribute classes;
// does nothing and returns a null handle by default for other classes)
//=======================================================================
Handle(TDF_Attribute) StdObjMgt_Persistent::CreateAttribute()
{ return Handle(TDF_Attribute)(); }
//=======================================================================
//function : GetAttribute
//purpose : Get transient attribuite for the persistent data
// (to be overriden by attribute classes;
// returns a null handle by default for non-attribute classes)
//=======================================================================
Handle(TDF_Attribute) StdObjMgt_Persistent::GetAttribute() const
{ return Handle(TDF_Attribute)(); }
//=======================================================================
//function : ImportAttribute
//purpose : Import transient attribuite from the persistent data
//! (to be overriden by attribute classes;
//! returns a null handle by default for non-attribute classes)
// (to be overriden by attribute classes;
// does nothing by default for non-attribute classes)
//=======================================================================
Handle(TDF_Attribute) StdObjMgt_Persistent::ImportAttribute() const
{
return Handle(TDF_Attribute)();
}
void StdObjMgt_Persistent::ImportAttribute() {}
//=======================================================================
//function : AsciiString
//purpose : Get referenced ASCII string
// (to be overriden by ASCII string class;
// returns a null handle by default for other classes)
//=======================================================================
Handle(TCollection_HAsciiString) StdObjMgt_Persistent::AsciiString() const
{ return Handle(TCollection_HAsciiString)(); }
//=======================================================================
//function : ExtString
//purpose : Get referenced extended string
// (to be overriden by extended string class;
// returns a null handle by default for other classes)
//=======================================================================
Handle(TCollection_HExtendedString) StdObjMgt_Persistent::ExtString() const
{ return Handle(TCollection_HExtendedString)(); }
//=======================================================================
//function : Label
//purpose : Get a label expressed by referenced extended string
// (to be overriden by extended string class;
// returns a null label by default for other classes)
//=======================================================================
TDF_Label StdObjMgt_Persistent::Label (const Handle(TDF_Data)&) const
{ return TDF_Label(); }

View File

@ -18,26 +18,70 @@
#include <Standard.hxx>
#include <Standard_Handle.hxx>
#include <Standard_Transient.hxx>
#include <StdObjMgt_ContentTypes.hxx>
#include <TDF_Label.hxx>
class StdObjMgt_ReadData;
class TDocStd_Document;
class TDF_Attribute;
class TDF_Data;
class TCollection_HAsciiString;
class TCollection_HExtendedString;
//! Root class for a temporary object that reads data from a file and then
//! creates transient object using the data.
class StdObjMgt_Persistent : public Standard_Transient
//! Root class for a temporary persistent object that reads data from a file
//! and then creates transient object using the data.
class StdObjMgt_Persistent : public Standard_Transient,
protected StdObjMgt_ContentTypes
{
public:
//! Create a derived class instance.
//! Derived class instance create function.
typedef Handle(StdObjMgt_Persistent) (*Instantiator)();
//! Create a derived class instance.
template <class Persistent>
static Handle(StdObjMgt_Persistent) Instantiate()
{ return new Persistent; }
//! Read persistent data from a file.
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData) = 0;
//! Import transient attribuite from the persistent data
//! Import transient document from the persistent data
//! (to be overriden by document class;
//! does nothing by default for other classes).
Standard_EXPORT virtual void ImportDocument
(const Handle(TDocStd_Document)& theDocument) const;
//! Create an empty transient attribuite
//! (to be overriden by attribute classes;
//! does nothing and returns a null handle by default for other classes).
Standard_EXPORT virtual Handle(TDF_Attribute) CreateAttribute();
//! Get transient attribuite for the persistent data
//! (to be overriden by attribute classes;
//! returns a null handle by default for non-attribute classes).
Standard_EXPORT virtual Handle(TDF_Attribute) ImportAttribute() const;
Standard_EXPORT virtual Handle(TDF_Attribute) GetAttribute() const;
//! Import transient attribuite from the persistent data
//! (to be overriden by attribute classes;
//! does nothing by default for non-attribute classes).
Standard_EXPORT virtual void ImportAttribute();
//! Get referenced ASCII string
//! (to be overriden by ASCII string class;
//! returns a null handle by default for other classes).
Standard_EXPORT virtual Handle(TCollection_HAsciiString) AsciiString() const;
//! Get referenced extended string
//! (to be overriden by extended string class;
//! returns a null handle by default for other classes).
Standard_EXPORT virtual Handle(TCollection_HExtendedString) ExtString() const;
//! Get a label expressed by referenced extended string
//! (to be overriden by extended string class;
//! returns a null label by default for other classes).
Standard_EXPORT virtual TDF_Label Label (const Handle(TDF_Data)& theDF) const;
};
#endif // _StdObjMgt_Persistent_HeaderFile

View File

@ -12,20 +12,30 @@
// commercial license or contractual agreement.
#include <StdObjMgt_ReadData.hxx>
#include <StdObjMgt_Persistent.hxx>
StdObjMgt_ReadData::StdObjMgt_ReadData (Storage_BaseDriver& theDriver,
const Standard_Integer theNumberOfObjects)
: myDriver (&theDriver)
, myPersistentObjects (1, theNumberOfObjects) {}
StdObjMgt_ReadData::StdObjMgt_ReadData
(Storage_BaseDriver& theDriver, const Standard_Integer theNumberOfObjects)
: myDriver (&theDriver)
, myPersistentObjects (1, theNumberOfObjects) {}
void StdObjMgt_ReadData::ReadReference (Handle(StdObjMgt_Persistent)& theTarget)
void StdObjMgt_ReadData::ReadPersistentObject (const Standard_Integer theRef)
{
Handle(StdObjMgt_Persistent) aPersistent = myPersistentObjects (theRef);
if (aPersistent)
{
Standard_Integer aRef, aType;
myDriver->ReadPersistentObjectHeader (aRef, aType);
myDriver->BeginReadPersistentObjectData();
aPersistent->Read (*this);
myDriver->EndReadPersistentObjectData();
}
}
Handle(StdObjMgt_Persistent) StdObjMgt_ReadData::ReadReference()
{
Standard_Integer aRef;
myDriver->GetReference (aRef);
if (aRef)
theTarget = Object (aRef);
else
theTarget.Nullify();
return aRef ? PersistentObject (aRef) : NULL;
}

View File

@ -15,43 +15,69 @@
#define _StdObjMgt_ReadData_HeaderFile
#include <Standard.hxx>
#include <StdObjMgt_Persistent.hxx>
#include <NCollection_Array1.hxx>
#include <Storage_BaseDriver.hxx>
#include <NCollection_Array1.hxx>
class StdObjMgt_Persistent;
//! Auxiliary data used to read persistent objects from a file.
class StdObjMgt_ReadData
{
public:
Standard_EXPORT StdObjMgt_ReadData (Storage_BaseDriver& theDriver,
const Standard_Integer theNumberOfObjects);
void CreateObject (const Standard_Integer theRef,
StdObjMgt_Persistent::Instantiator theInstantiator)
{ myPersistentObjects (theRef) = theInstantiator(); }
Handle(StdObjMgt_Persistent) Object (const Standard_Integer theRef) const
{ return myPersistentObjects (theRef); }
Standard_EXPORT StdObjMgt_ReadData
(Storage_BaseDriver& theDriver, const Standard_Integer theNumberOfObjects);
Storage_BaseDriver& Driver() const
{ return *myDriver; }
Standard_EXPORT void ReadReference (Handle(StdObjMgt_Persistent)& theTarget);
template <class Type>
StdObjMgt_ReadData& operator >> (Type& aValue)
template <class Instantiator>
void CreatePersistentObject
(const Standard_Integer theRef, Instantiator theInstantiator)
{ myPersistentObjects (theRef) = theInstantiator(); }
Standard_EXPORT void ReadPersistentObject
(const Standard_Integer theRef);
Handle(StdObjMgt_Persistent) PersistentObject
(const Standard_Integer theRef) const
{ return myPersistentObjects (theRef); }
Standard_EXPORT Handle(StdObjMgt_Persistent) ReadReference();
template <class Persistent>
void ReadReference (Handle(Persistent)& theTarget)
{
*myDriver >> aValue;
return *this;
theTarget = Handle(Persistent)::DownCast (ReadReference());
}
template <class Object>
void ReadObject (Object& theObject)
{
myDriver->BeginReadObjectData();
theObject.Read (*this);
myDriver->EndReadObjectData();
}
template <class Type>
StdObjMgt_ReadData& operator >> (Handle(Type)& theTarget)
void ReadValue (Type& theValue)
{
Handle(StdObjMgt_Persistent) aTarget = theTarget;
ReadReference (aTarget);
theTarget = dynamic_cast<Type*> (aTarget.get());
*myDriver >> theValue;
}
template <class Type>
void ReadEnum (Type& theEnum)
{
Standard_Integer aValue;
*myDriver >> aValue;
theEnum = static_cast<Type> (aValue);
}
template <class Base> struct Content : Base {};
template <class Base>
StdObjMgt_ReadData& operator >> (Content<Base>& theContent)
{
theContent.Read (*this);
return *this;
}

View File

@ -0,0 +1,113 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _StdObjMgt_SharedObject_HeaderFile
#define _StdObjMgt_SharedObject_HeaderFile
#include <StdObjMgt_Persistent.hxx>
class StdObjMgt_SharedObject
{
public:
class PersistentBase : public Standard_Transient,
protected StdObjMgt_ContentTypes {};
template <class Transient>
class AbstractPersistentBase : public PersistentBase
{
public:
virtual Handle(Transient) Import() const = 0;
};
template <class Transient, class Base = StdObjMgt_Persistent>
class SharedBase : public Base
{
public:
//! Import transient object from the persistent data.
inline const Handle(Transient)& Import() { return myTransient; }
protected:
Handle(Transient) myTransient;
};
template <class Base,
class Transient,
class Persistent = AbstractPersistentBase<Transient> >
class DelayedBase : public Base
{
public:
typedef Transient TransientBase;
typedef Persistent PersistentBase;
//! Import transient object from the persistent data.
Standard_EXPORT virtual Handle(Transient) Import()
{ return myTransient; }
protected:
Handle(Transient) myTransient;
};
template <class Base,
class PersistentData,
class Transient = typename Base::TransientBase>
class IgnoreData : public Base
{
public:
//! Read persistent data from a file.
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData)
{ PersistentData().Read (theReadData); }
//! Import transient object from the persistent data.
Standard_EXPORT virtual Handle(Transient) Import()
{ return NULL; }
};
private:
template <class Base>
class delayedSubBase : public Base
{
public:
//! Import transient object from the persistent data.
Standard_EXPORT virtual Handle(typename Base::TransientBase) Import()
{
if (Base::myTransient.IsNull() && !myPersistent.IsNull())
{
Base::myTransient = myPersistent->Import();
myPersistent.Nullify();
}
return Base::myTransient;
}
protected:
Handle(typename Base::PersistentBase) myPersistent;
};
public:
template <class Base, class Persistent = typename Base::PersistentBase>
class Delayed : public delayedSubBase<Base>
{
public:
//! Read persistent data from a file.
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData)
{
Handle(Persistent) aPersistent = new Persistent;
aPersistent->Read (theReadData);
this->myPersistent = aPersistent;
}
};
};
#endif

5
src/StdObject/FILES Normal file
View File

@ -0,0 +1,5 @@
StdObject_gp.hxx
StdObject_Location.cxx
StdObject_Location.hxx
StdObject_Shape.cxx
StdObject_Shape.hxx

View File

@ -0,0 +1,29 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <StdObject_Location.hxx>
#include <StdPersistent_TopLoc.hxx>
//=======================================================================
//function : Import
//purpose : Import transient object from the persistent data
//=======================================================================
TopLoc_Location StdObject_Location::Import() const
{
Handle(StdPersistent_TopLoc::ItemLocation) anItemLocation;
if (myData.Cast (anItemLocation))
return anItemLocation->Import();
else
return TopLoc_Location();
}

View File

@ -12,23 +12,26 @@
// commercial license or contractual agreement.
#ifndef _StdLPersistent_PDataStd_Integer_HeaderFile
#define _StdLPersistent_PDataStd_Integer_HeaderFile
#ifndef _StdObject_Location_HeaderFile
#define _StdObject_Location_HeaderFile
#include <StdObjMgt_Persistent.hxx>
#include <StdObjMgt_ContentTypes.hxx>
#include <TopLoc_Location.hxx>
class StdLPersistent_PDataStd_Integer : public StdObjMgt_Persistent
class StdObject_Location : private StdObjMgt_ContentTypes
{
public:
//! Read persistent data from a file.
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
inline void Read (StdObjMgt_ReadData& theReadData)
{ theReadData >> myData; }
//! Import transient attribuite from the persistent data.
Standard_EXPORT virtual Handle(TDF_Attribute) ImportAttribute() const;
//! Import transient object from the persistent data.
TopLoc_Location Import() const;
private:
Standard_Integer myValue;
Reference<> myData;
};
#endif

View File

@ -11,30 +11,23 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <StdLPersistent_PCollection_HExtendedString.hxx>
#include <StdObject_Shape.hxx>
#include <StdObjMgt_ReadData.hxx>
#include <TCollection_HExtendedString.hxx>
//=======================================================================
//function : Read
//purpose : Read persistent data from a file
//function : Import
//purpose : Import transient object from the persistent data
//=======================================================================
void StdLPersistent_PCollection_HExtendedString::Read (StdObjMgt_ReadData& theReadData)
TopoDS_Shape StdObject_Shape::Import() const
{
theReadData.Driver().BeginReadObjectData();
TopoDS_Shape aShape;
Standard_Integer aSize;
theReadData >> aSize;
myValue = new TCollection_HExtendedString (aSize, 0);
if (myTShape)
aShape.TShape (myTShape->Import());
for (Standard_Integer i = 1; i <= aSize; i++)
{
Standard_ExtCharacter aChar;
theReadData >> aChar;
myValue->SetValue (i, aChar);
}
aShape.Location (myLocation.Import());
aShape.Orientation (myOrient);
theReadData.Driver().EndReadObjectData();
return aShape;
}

View File

@ -0,0 +1,42 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _StdObject_Shape_HeaderFile
#define _StdObject_Shape_HeaderFile
#include <StdObjMgt_ContentTypes.hxx>
#include <StdObject_Location.hxx>
#include <StdPersistent_TopoDS.hxx>
#include <TopAbs_Orientation.hxx>
#include <TopoDS_Shape.hxx>
class StdObject_Shape : private StdObjMgt_ContentTypes
{
public:
//! Read persistent data from a file.
inline void Read (StdObjMgt_ReadData& theReadData)
{ theReadData >> myTShape >> myLocation >> myOrient; }
//! Import transient object from the persistent data.
Standard_EXPORT TopoDS_Shape Import() const;
private:
Reference <StdPersistent_TopoDS::TShape> myTShape;
Object <StdObject_Location> myLocation;
Enum <TopAbs_Orientation> myOrient;
};
#endif

View File

@ -0,0 +1,414 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _StdObject_gp_HeaderFile
#define _StdObject_gp_HeaderFile
#include <StdObjMgt_ContentTypes.hxx>
class StdObject_gp : private StdObjMgt_ContentTypes
{
template <class Data>
struct object : Data
{ Standard_EXPORT void Read (StdObjMgt_ReadData& theReadData); };
public:
template <class Data>
struct Object : StdObjMgt_ContentTypes::Object <object<Data> > {};
template <class Data>
static Object<Data>& Ref (Data& theData)
{ return static_cast<Object<Data>&> (theData); }
};
// read vectors
#include <gp_Pnt2d.hxx>
#include <gp_Vec2d.hxx>
#include <gp_Dir2d.hxx>
#include <gp_Pnt.hxx>
#include <gp_Vec.hxx>
#include <gp_Dir.hxx>
inline StdObjMgt_ReadData& operator >> (StdObjMgt_ReadData& theReadData, gp_XY& theXY)
{
Standard_Real aX, aY;
theReadData.ReadValue(aX);
theReadData.ReadValue(aY);
theXY.SetCoord(aX, aY);
return theReadData;
}
inline StdObjMgt_ReadData& operator >> (StdObjMgt_ReadData& theReadData, gp_Pnt2d& thePnt)
{
Standard_Real aX, aY;
theReadData.ReadValue(aX);
theReadData.ReadValue(aY);
thePnt.SetCoord(aX, aY);
return theReadData;
}
inline StdObjMgt_ReadData& operator >> (StdObjMgt_ReadData& theReadData, gp_Vec2d& theVec)
{
Standard_Real aX, aY;
theReadData.ReadValue(aX);
theReadData.ReadValue(aY);
theVec.SetCoord(aX, aY);
return theReadData;
}
inline StdObjMgt_ReadData& operator >> (StdObjMgt_ReadData& theReadData, gp_Dir2d& theDir)
{
Standard_Real aX, aY;
theReadData.ReadValue(aX);
theReadData.ReadValue(aY);
theDir.SetCoord(aX, aY);
return theReadData;
}
inline StdObjMgt_ReadData& operator >> (StdObjMgt_ReadData& theReadData, gp_XYZ& theXYZ)
{
Standard_Real aX, aY, aZ;
theReadData.ReadValue(aX);
theReadData.ReadValue(aY);
theReadData.ReadValue(aZ);
theXYZ.SetCoord(aX, aY, aZ);
return theReadData;
}
inline StdObjMgt_ReadData& operator >> (StdObjMgt_ReadData& theReadData, gp_Pnt& thePnt)
{
Standard_Real aX, aY, aZ;
theReadData.ReadValue(aX);
theReadData.ReadValue(aY);
theReadData.ReadValue(aZ);
thePnt.SetCoord(aX, aY, aZ);
return theReadData;
}
inline StdObjMgt_ReadData& operator >> (StdObjMgt_ReadData& theReadData, gp_Vec& theVec)
{
Standard_Real aX, aY, aZ;
theReadData.ReadValue(aX);
theReadData.ReadValue(aY);
theReadData.ReadValue(aZ);
theVec.SetCoord(aX, aY, aZ);
return theReadData;
}
inline StdObjMgt_ReadData& operator >> (StdObjMgt_ReadData& theReadData, gp_Dir& theDir)
{
Standard_Real aX, aY, aZ;
theReadData.ReadValue(aX);
theReadData.ReadValue(aY);
theReadData.ReadValue(aZ);
theDir.SetCoord(aX, aY, aZ);
return theReadData;
}
// read axis placements
#include <gp_Ax2d.hxx>
#include <gp_Ax22d.hxx>
#include <gp_Ax1.hxx>
#include <gp_Ax2.hxx>
#include <gp_Ax3.hxx>
inline StdObjMgt_ReadData& operator >> (StdObjMgt_ReadData& theReadData, gp_Ax2d& theAx)
{
gp_Pnt2d aLoc;
gp_Dir2d aDir;
theReadData >> aLoc >> aDir;
theAx = gp_Ax2d (aLoc, aDir);
return theReadData;
}
inline StdObjMgt_ReadData& operator >> (StdObjMgt_ReadData& theReadData, gp_Ax22d& theAx)
{
gp_Pnt2d aLoc;
gp_Dir2d aYDir, aXDir;
theReadData >> aLoc >> aYDir >> aXDir;
theAx = gp_Ax22d (aLoc, aXDir, aYDir);
return theReadData;
}
inline StdObjMgt_ReadData& operator >> (StdObjMgt_ReadData& theReadData, gp_Ax1& theAx)
{
gp_XYZ aLoc;
gp_Dir aDir;
theReadData >> aLoc >> aDir;
theAx = gp_Ax1 (aLoc, aDir);
return theReadData;
}
inline StdObjMgt_ReadData& operator >> (StdObjMgt_ReadData& theReadData, gp_Ax2& theAx)
{
gp_Ax1 anAx;
gp_Dir aYDir, aXDir;
theReadData >> anAx >> aYDir >> aXDir;
theAx = gp_Ax2 (anAx.Location(), anAx.Direction(), aXDir);
return theReadData;
}
inline StdObjMgt_ReadData& operator >> (StdObjMgt_ReadData& theReadData, gp_Ax3& theAx)
{
gp_Ax1 anAx;
gp_Dir aYDir, aXDir;
theReadData >> anAx >> aYDir >> aXDir;
theAx = gp_Ax3 (anAx.Location(), anAx.Direction(), aXDir);
if (aYDir * theAx.YDirection() < 0.)
theAx.YReverse();
return theReadData;
}
// read curves
#include <gp_Lin2d.hxx>
#include <gp_Circ2d.hxx>
#include <gp_Elips2d.hxx>
#include <gp_Hypr2d.hxx>
#include <gp_Parab2d.hxx>
#include <gp_Lin.hxx>
#include <gp_Circ.hxx>
#include <gp_Elips.hxx>
#include <gp_Hypr.hxx>
#include <gp_Parab.hxx>
inline StdObjMgt_ReadData& operator >> (StdObjMgt_ReadData& theReadData, gp_Lin2d& theLin)
{
gp_Ax2d anAx;
theReadData >> anAx;
theLin.SetPosition(anAx);
return theReadData;
}
inline StdObjMgt_ReadData& operator >> (StdObjMgt_ReadData& theReadData, gp_Circ2d& theCirc)
{
gp_Ax22d anAx;
Standard_Real aRadius;
theReadData >> anAx;
theReadData.ReadValue(aRadius);
theCirc.SetAxis(anAx);
theCirc.SetRadius (aRadius);
return theReadData;
}
inline StdObjMgt_ReadData& operator >> (StdObjMgt_ReadData& theReadData, gp_Elips2d& theElips)
{
gp_Ax22d anAx;
Standard_Real aMajorRadius, aMinorRadius;
theReadData >> anAx;
theReadData.ReadValue(aMajorRadius);
theReadData.ReadValue(aMinorRadius);
theElips.SetAxis(anAx);
theElips.SetMajorRadius(aMajorRadius);
theElips.SetMinorRadius(aMinorRadius);
return theReadData;
}
inline StdObjMgt_ReadData& operator >> (StdObjMgt_ReadData& theReadData, gp_Hypr2d& theHypr)
{
gp_Ax22d anAx;
Standard_Real aMajorRadius, aMinorRadius;
theReadData >> anAx;
theReadData.ReadValue(aMajorRadius);
theReadData.ReadValue(aMinorRadius);
theHypr.SetAxis(anAx);
theHypr.SetMajorRadius(aMajorRadius);
theHypr.SetMinorRadius(aMinorRadius);
return theReadData;
}
inline StdObjMgt_ReadData& operator >> (StdObjMgt_ReadData& theReadData, gp_Parab2d& theParab)
{
gp_Ax22d anAx;
Standard_Real aFocalLength;
theReadData >> anAx;
theReadData.ReadValue(aFocalLength);
theParab.SetAxis(anAx);
theParab.SetFocal(aFocalLength);
return theReadData;
}
inline StdObjMgt_ReadData& operator >> (StdObjMgt_ReadData& theReadData, gp_Lin& theLin)
{
gp_Ax1 anAx;
theReadData >> anAx;
theLin.SetPosition(anAx);
return theReadData;
}
inline StdObjMgt_ReadData& operator >> (StdObjMgt_ReadData& theReadData, gp_Circ& theCirc)
{
gp_Ax2 anAx;
Standard_Real aRadius;
theReadData >> anAx;
theReadData.ReadValue(aRadius);
theCirc.SetPosition(anAx);
theCirc.SetRadius (aRadius);
return theReadData;
}
inline StdObjMgt_ReadData& operator >> (StdObjMgt_ReadData& theReadData, gp_Elips& theElips)
{
gp_Ax2 anAx;
Standard_Real aMajorRadius, aMinorRadius;
theReadData >> anAx;
theReadData.ReadValue(aMajorRadius);
theReadData.ReadValue(aMinorRadius);
theElips.SetPosition(anAx);
theElips.SetMajorRadius(aMajorRadius);
theElips.SetMinorRadius(aMinorRadius);
return theReadData;
}
inline StdObjMgt_ReadData& operator >> (StdObjMgt_ReadData& theReadData, gp_Hypr& theHypr)
{
gp_Ax2 anAx;
Standard_Real aMajorRadius, aMinorRadius;
theReadData >> anAx;
theReadData.ReadValue(aMajorRadius);
theReadData.ReadValue(aMinorRadius);
theHypr.SetPosition(anAx);
theHypr.SetMajorRadius(aMajorRadius);
theHypr.SetMinorRadius(aMinorRadius);
return theReadData;
}
inline StdObjMgt_ReadData& operator >> (StdObjMgt_ReadData& theReadData, gp_Parab& theParab)
{
gp_Ax2 anAx;
Standard_Real aFocalLength;
theReadData >> anAx;
theReadData.ReadValue(aFocalLength);
theParab.SetPosition(anAx);
theParab.SetFocal(aFocalLength);
return theReadData;
}
// read surfaces
#include <gp_Cone.hxx>
#include <gp_Cylinder.hxx>
#include <gp_Sphere.hxx>
#include <gp_Torus.hxx>
inline StdObjMgt_ReadData& operator >> (StdObjMgt_ReadData& theReadData, gp_Cone& theCone)
{
gp_Ax3 anAx;
Standard_Real aRadius, aSemiAngle;
theReadData >> anAx;
theReadData.ReadValue(aRadius);
theReadData.ReadValue(aSemiAngle);
theCone.SetPosition(anAx);
theCone.SetRadius(aRadius);
theCone.SetSemiAngle(aSemiAngle);
return theReadData;
}
inline StdObjMgt_ReadData& operator >> (StdObjMgt_ReadData& theReadData, gp_Cylinder& theCyl)
{
gp_Ax3 anAx;
Standard_Real aRadius;
theReadData >> anAx;
theReadData.ReadValue(aRadius);
theCyl.SetPosition(anAx);
theCyl.SetRadius(aRadius);
return theReadData;
}
inline StdObjMgt_ReadData& operator >> (StdObjMgt_ReadData& theReadData, gp_Sphere& theSph)
{
gp_Ax3 anAx;
Standard_Real aRadius;
theReadData >> anAx;
theReadData.ReadValue(aRadius);
theSph.SetPosition(anAx);
theSph.SetRadius(aRadius);
return theReadData;
}
inline StdObjMgt_ReadData& operator >> (StdObjMgt_ReadData& theReadData, gp_Torus& theTorus)
{
gp_Ax3 anAx;
Standard_Real aMajorRadius, aMinorRadius;
theReadData >> anAx;
theReadData.ReadValue(aMajorRadius);
theReadData.ReadValue(aMinorRadius);
theTorus.SetPosition(anAx);
theTorus.SetMajorRadius(aMajorRadius);
theTorus.SetMinorRadius(aMinorRadius);
return theReadData;
}
// read transformations
#include <gp_Mat2d.hxx>
#include <gp_Mat.hxx>
#include <gp_Trsf2d.hxx>
#include <gp_Trsf.hxx>
inline StdObjMgt_ReadData& operator >> (StdObjMgt_ReadData& theReadData, gp_Mat2d& theMat)
{
gp_XY aRow1, aRow2;
theReadData >> aRow1 >> aRow2;
theMat.SetRows(aRow1, aRow2);
return theReadData;
}
inline StdObjMgt_ReadData& operator >> (StdObjMgt_ReadData& theReadData, gp_Mat& theMat)
{
gp_XYZ aRow1, aRow2, aRow3;
theReadData >> aRow1 >> aRow2 >> aRow3;
theMat.SetRows(aRow1, aRow2, aRow3);
return theReadData;
}
inline StdObjMgt_ReadData& operator >> (StdObjMgt_ReadData& theReadData, gp_Trsf2d& theTrsf)
{
Standard_Real aScale;
gp_TrsfForm aForm;
gp_Mat2d aMat;
gp_XY aLoc;
theReadData.ReadValue(aScale);
theReadData.ReadEnum(aForm);
theReadData >> aMat >> aLoc;
theTrsf.SetValues(aScale * aMat(1, 1), aScale * aMat(1, 2), aLoc.X(),
aScale * aMat(2, 1), aScale * aMat(2, 2), aLoc.Y());
return theReadData;
}
inline StdObjMgt_ReadData& operator >> (StdObjMgt_ReadData& theReadData, gp_Trsf& theTrsf)
{
Standard_Real aScale;
gp_TrsfForm aForm;
gp_Mat aMat;
gp_XYZ aLoc;
theReadData.ReadValue(aScale);
theReadData.ReadEnum(aForm);
theReadData >> aMat >> aLoc;
theTrsf.SetValues(aScale * aMat(1, 1), aScale * aMat(1, 2), aScale * aMat(1, 3), aLoc.X(),
aScale * aMat(2, 1), aScale * aMat(2, 2), aScale * aMat(2, 3), aLoc.Y(),
aScale * aMat(3, 1), aScale * aMat(3, 2), aScale * aMat(3, 3), aLoc.Z());
return theReadData;
}
template<class T>
inline void StdObject_gp::object<T>::Read (StdObjMgt_ReadData& theReadData)
{
theReadData >> (*this);
}
#endif

View File

@ -1,3 +1,18 @@
FILES
StdPersistent.cxx
StdPersistent.hxx
StdPersistent_DataXtd.cxx
StdPersistent_DataXtd.hxx
StdPersistent_DataXtd_Constraint.cxx
StdPersistent_DataXtd_Constraint.hxx
StdPersistent_DataXtd_PatternStd.cxx
StdPersistent_DataXtd_PatternStd.hxx
StdPersistent_HArray1OfShape1.hxx
StdPersistent_HArray1.cxx
StdPersistent_HArray1.hxx
StdPersistent_Naming.cxx
StdPersistent_Naming.hxx
StdPersistent_PPrsStd.cxx
StdPersistent_PPrsStd.hxx
StdPersistent_TopLoc.cxx
StdPersistent_TopLoc.hxx
StdPersistent_TopoDS.hxx

View File

@ -14,10 +14,54 @@
#include <StdPersistent.hxx>
#include <StdObjMgt_MapOfInstantiators.hxx>
#include <StdPersistent_TopLoc.hxx>
#include <StdPersistent_TopoDS.hxx>
#include <StdPersistent_Naming.hxx>
#include <StdPersistent_HArray1.hxx>
#include <StdLPersistent_HArray1.hxx>
#include <StdPersistent_DataXtd.hxx>
#include <StdPersistent_DataXtd_Constraint.hxx>
#include <StdPersistent_DataXtd_PatternStd.hxx>
#include <StdPersistent_PPrsStd.hxx>
//=======================================================================
//function : BindTypes
//purpose : Register types
//=======================================================================
void StdPersistent::BindTypes (StdObjMgt_MapOfInstantiators& /*theMap*/)
void StdPersistent::BindTypes (StdObjMgt_MapOfInstantiators& theMap)
{
// Non-attribute data
theMap.Bind <StdPersistent_TopLoc::Datum3D> ("PTopLoc_Datum3D");
theMap.Bind <StdPersistent_TopLoc::ItemLocation> ("PTopLoc_ItemLocation");
theMap.Bind <StdPersistent_TopoDS::TShape> ("PTopoDS_TShape1");
theMap.Bind <StdPersistent_HArray1::Shape1> ("PTopoDS_HArray1OfShape1");
theMap.Bind <StdPersistent_Naming::Name> ("PNaming_Name");
theMap.Bind <StdPersistent_Naming::Name_1> ("PNaming_Name_1");
theMap.Bind <StdPersistent_Naming::Name_2> ("PNaming_Name_2");
theMap.Bind <StdLPersistent_HArray1::Persistent>
("PNaming_HArray1OfNamedShape");
// Attributes
theMap.Bind <StdPersistent_Naming::NamedShape> ("PNaming_NamedShape");
theMap.Bind <StdPersistent_Naming::Naming> ("PNaming_Naming");
theMap.Bind <StdPersistent_Naming::Naming_1> ("PNaming_Naming_1");
theMap.Bind <StdPersistent_Naming::Naming_2> ("PNaming_Naming_2");
theMap.Bind <StdPersistent_DataXtd::Shape> ("PDataXtd_Shape");
theMap.Bind <StdPersistent_DataXtd::Point> ("PDataXtd_Point");
theMap.Bind <StdPersistent_DataXtd::Axis> ("PDataXtd_Axis");
theMap.Bind <StdPersistent_DataXtd::Plane> ("PDataXtd_Plane");
theMap.Bind <StdPersistent_DataXtd::Placement> ("PDataXtd_Placement");
theMap.Bind <StdPersistent_DataXtd::Geometry> ("PDataXtd_Geometry");
theMap.Bind <StdPersistent_DataXtd::Position> ("PDataXtd_Position");
theMap.Bind <StdPersistent_DataXtd_Constraint> ("PDataXtd_Constraint");
theMap.Bind <StdPersistent_DataXtd_PatternStd> ("PDataXtd_PatternStd");
theMap.Bind <StdPersistent_PPrsStd::AISPresentation>
("PPrsStd_AISPresentation");
theMap.Bind <StdPersistent_PPrsStd::AISPresentation_1>
("PPrsStd_AISPresentation_1");
}

View File

@ -11,28 +11,19 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <StdLPersistent_PDataStd_Integer.hxx>
#include <StdPersistent_DataXtd.hxx>
#include <StdObjMgt_ReadData.hxx>
#include <TDataStd_Integer.hxx>
//=======================================================================
//function : Read
//purpose : Read persistent data from a file
//=======================================================================
void StdLPersistent_PDataStd_Integer::Read (StdObjMgt_ReadData& theReadData)
{
theReadData >> myValue;
}
//=======================================================================
//function : ImportAttribute
//purpose : Import transient attribuite from the persistent data
//=======================================================================
Handle(TDF_Attribute) StdLPersistent_PDataStd_Integer::ImportAttribute() const
{
Handle(TDataStd_Integer) aValue = new TDataStd_Integer;
aValue->Set (myValue);
return aValue;
}
void StdPersistent_DataXtd::Geometry::ImportAttribute()
{ myTransient->SetType (myData); }
//=======================================================================
//function : ImportAttribute
//purpose : Import transient attribuite from the persistent data
//=======================================================================
void StdPersistent_DataXtd::Position::ImportAttribute()
{ myTransient->SetPosition (myData); }

View File

@ -0,0 +1,65 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _StdPersistent_DataXtd_HeaderFile
#define _StdPersistent_DataXtd_HeaderFile
#include <StdObjMgt_ContentTypes.hxx>
#include <StdObjMgt_Attribute.hxx>
#include <StdLPersistent_Void.hxx>
#include <StdObject_gp.hxx>
#include <TDataXtd_Shape.hxx>
#include <TDataXtd_Point.hxx>
#include <TDataXtd_Axis.hxx>
#include <TDataXtd_Plane.hxx>
#include <TDataXtd_Placement.hxx>
#include <TDataXtd_Geometry.hxx>
#include <TDataXtd_Position.hxx>
class StdPersistent_DataXtd : private StdObjMgt_ContentTypes
{
class _void : private StdLPersistent_Void
{
public:
template <class AttribClass>
struct Instance : instance<AttribClass> {};
};
public:
typedef _void::Instance<TDataXtd_Shape> Shape;
typedef _void::Instance<TDataXtd_Point> Point;
typedef _void::Instance<TDataXtd_Axis> Axis;
typedef _void::Instance<TDataXtd_Plane> Plane;
typedef _void::Instance<TDataXtd_Placement> Placement;
class Geometry : public StdObjMgt_Attribute<TDataXtd_Geometry>::
Simple <Enum<TDataXtd_GeometryEnum> >
{
public:
//! Import transient attribuite from the persistent data.
Standard_EXPORT virtual void ImportAttribute();
};
class Position : public StdObjMgt_Attribute<TDataXtd_Position>::
Simple <StdObject_gp::Object<gp_Pnt> >
{
public:
//! Import transient attribuite from the persistent data.
Standard_EXPORT virtual void ImportAttribute();
};
};
#endif

View File

@ -0,0 +1,58 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <StdPersistent_DataXtd_Constraint.hxx>
#include <TNaming_NamedShape.hxx>
#include <TDataStd_Real.hxx>
//=======================================================================
//function : Import
//purpose : Import transient attribuite from the persistent data
//=======================================================================
void StdPersistent_DataXtd_Constraint::Import
(const Handle(TDataXtd_Constraint)& theAttribute) const
{
theAttribute->SetType (myType);
theAttribute->Reversed (myIsReversed);
theAttribute->Inverted (myIsInverted);
theAttribute->Verified (myIsVerified);
if (myGeometries)
{
Handle(StdLPersistent_HArray1OfPersistent) aGeometries = myGeometries->Array();
for (Standard_Integer i = 1; i <= aGeometries->Length(); i++)
{
Handle(StdObjMgt_Persistent) aPGeometry = aGeometries->Value(i);
if (aPGeometry)
{
Handle(TDF_Attribute) aTGeometry = aPGeometry->GetAttribute();
theAttribute->SetGeometry
(i, Handle(TNaming_NamedShape)::DownCast (aTGeometry));
}
}
}
if (myValue)
{
Handle(TDF_Attribute) aValue = myValue->GetAttribute();
theAttribute->SetValue (Handle(TDataStd_Real)::DownCast (aValue));
}
if (myPlane)
{
Handle(TDF_Attribute) aPlane = myPlane->GetAttribute();
theAttribute->SetPlane (Handle(TNaming_NamedShape)::DownCast (aPlane));
}
}

View File

@ -0,0 +1,49 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _StdPersistent_DataXtd_Constraint_HeaderFile
#define _StdPersistent_DataXtd_Constraint_HeaderFile
#include <StdObjMgt_Attribute.hxx>
#include <StdLPersistent_HArray1.hxx>
#include <TDataXtd_Constraint.hxx>
#include <TDataXtd_ConstraintEnum.hxx>
class StdPersistent_DataXtd_Constraint
: public StdObjMgt_Attribute<TDataXtd_Constraint>
{
public:
//! Read persistent data from a file.
inline void Read (StdObjMgt_ReadData& theReadData)
{
theReadData >> myType >> myGeometries >> myValue
>> myIsReversed >> myIsInverted >> myIsVerified >> myPlane;
}
//! Import transient attribuite from the persistent data.
void Import (const Handle(TDataXtd_Constraint)& theAttribute) const;
private:
Enum<TDataXtd_ConstraintEnum> myType;
Reference<StdLPersistent_HArray1::Persistent> myGeometries;
Reference<> myValue;
Value<Standard_Boolean> myIsReversed;
Value<Standard_Boolean> myIsInverted;
Value<Standard_Boolean> myIsVerified;
Reference<> myPlane;
};
#endif

View File

@ -0,0 +1,56 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <StdPersistent_DataXtd_PatternStd.hxx>
#include <TNaming_NamedShape.hxx>
#include <TDataStd_Real.hxx>
#include <TDataStd_Integer.hxx>
//=======================================================================
//function : Import
//purpose : Import transient attribuite from the persistent data
//=======================================================================
void StdPersistent_DataXtd_PatternStd::Import
(const Handle(TDataXtd_PatternStd)& theAttribute) const
{
if (mySignature < 5)
{
theAttribute->Axis1 (
Handle(TNaming_NamedShape)::DownCast (myAxis1->GetAttribute()));
theAttribute->Value1 (
Handle(TDataStd_Real)::DownCast (myValue1->GetAttribute()));
theAttribute->NbInstances1 (
Handle(TDataStd_Integer)::DownCast (myNb1->GetAttribute()));
if (mySignature > 2)
{
theAttribute->Axis2 (
Handle(TNaming_NamedShape)::DownCast (myAxis2->GetAttribute()));
theAttribute->Value2 (
Handle(TDataStd_Real)::DownCast (myValue2->GetAttribute()));
theAttribute->NbInstances2 (
Handle(TDataStd_Integer)::DownCast (myNb2->GetAttribute()));
}
}
else
{
theAttribute->Mirror (
Handle(TNaming_NamedShape)::DownCast (myMirror->GetAttribute()));
}
}

View File

@ -0,0 +1,50 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _StdPersistent_DataXtd_PatternStd_HeaderFile
#define _StdPersistent_DataXtd_PatternStd_HeaderFile
#include <StdObjMgt_Attribute.hxx>
#include <TDataXtd_PatternStd.hxx>
class StdPersistent_DataXtd_PatternStd
: public StdObjMgt_Attribute<TDataXtd_PatternStd>
{
public:
//! Read persistent data from a file.
inline void Read (StdObjMgt_ReadData& theReadData)
{
theReadData >> mySignature >> myAxis1Reversed >> myAxis2Reversed >>
myAxis1 >> myAxis2 >> myValue1 >> myValue2 >> myNb1 >> myNb2 >> myMirror;
}
//! Import transient attribuite from the persistent data.
void Import (const Handle(TDataXtd_PatternStd)& theAttribute) const;
private:
Value<Standard_Integer> mySignature;
Value<Standard_Boolean> myAxis1Reversed;
Value<Standard_Boolean> myAxis2Reversed;
Reference<> myAxis1;
Reference<> myAxis2;
Reference<> myValue1;
Reference<> myValue2;
Reference<> myNb1;
Reference<> myNb2;
Reference<> myMirror;
};
#endif

View File

@ -0,0 +1,22 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <StdPersistent_HArray1.hxx>
#include <StdObjMgt_ReadData.hxx>
void StdPersistent_HArray1::Shape1::readValue (StdObjMgt_ReadData& theReadData,
const Standard_Integer theIndex)
{
theReadData.ReadObject (myArray->ChangeValue (theIndex));
}

View File

@ -0,0 +1,32 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _StdPersistent_HArray1_HeaderFile
#define _StdPersistent_HArray1_HeaderFile
#include <StdLPersistent_HArray1.hxx>
#include <StdPersistent_HArray1OfShape1.hxx>
class StdPersistent_HArray1 : private StdLPersistent_HArray1
{
public:
class Shape1 : public StdLPersistent_HArray1::base<StdPersistent_HArray1OfShape1>
{
virtual void readValue (StdObjMgt_ReadData& theReadData,
const Standard_Integer theIndex);
};
};
#endif

View File

@ -0,0 +1,23 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _StdPersistent_HArray1OfShape1_HeaderFile
#define _StdPersistent_HArray1OfShape1_HeaderFile
#include <NCollection_DefineHArray1.hxx>
#include <StdObject_Shape.hxx>
DEFINE_HARRAY1 (StdPersistent_HArray1OfShape1, NCollection_Array1<StdObject_Shape>)
#endif // _StdPersistent_HArray1OfShape1_HeaderFile

View File

@ -0,0 +1,178 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <StdPersistent_Naming.hxx>
#include <StdObjMgt_ReadData.hxx>
#include <TNaming_Name.hxx>
#include <TNaming_Builder.hxx>
#include <TNaming_Iterator.hxx>
//=======================================================================
//function : Import
//purpose : Import transient attribuite from the persistent data
//=======================================================================
void StdPersistent_Naming::NamedShape::Import
(const Handle(TNaming_NamedShape)& theAttribute) const
{
theAttribute->SetVersion (myVersion);
if (myOldShapes.IsNull() || myNewShapes.IsNull())
return;
TNaming_Builder aBuilder (theAttribute->Label());
StdPersistent_HArray1OfShape1::Iterator aOldShapesIter (*myOldShapes->Array());
StdPersistent_HArray1OfShape1::Iterator aNewShapesIter (*myNewShapes->Array());
for (; aNewShapesIter.More(); aOldShapesIter.Next(), aNewShapesIter.Next())
{
TopoDS_Shape aOldShape = aOldShapesIter.Value().Import();
TopoDS_Shape aNewShape = aNewShapesIter.Value().Import();
switch (myShapeStatus)
{
case 0: aBuilder.Generated (aNewShape); break; // PRIMITIVE
case 1: aBuilder.Generated (aOldShape, aNewShape); break; // GENERATED
case 2: aBuilder.Modify (aOldShape, aNewShape); break; // MODIFY
case 3: aBuilder.Delete (aOldShape); break; // DELETE
case 4: aBuilder.Select (aNewShape, aOldShape); break; // SELECTED
case 5: aBuilder.Modify (aOldShape, aNewShape); break; // REPLACE
}
}
}
//=======================================================================
//function : Read
//purpose : Read persistent data from a file
//=======================================================================
void StdPersistent_Naming::Name::Read (StdObjMgt_ReadData& theReadData)
{
theReadData >> myType >> myShapeType >> myArgs >> myStop >> myIndex;
}
//=======================================================================
//function : Import
//purpose : Import transient object from the persistent data
//=======================================================================
void StdPersistent_Naming::Name::Import
(TNaming_Name& theName, const Handle(TDF_Data)&) const
{
theName.Type (myType);
theName.ShapeType (myShapeType);
if (myArgs)
{
StdLPersistent_HArray1OfPersistent::Iterator anIter (*myArgs->Array());
for (; anIter.More(); anIter.Next())
{
Handle(StdObjMgt_Persistent) aPersistent = anIter.Value();
if (aPersistent)
{
Handle(TDF_Attribute) anArg = aPersistent->GetAttribute();
theName.Append (Handle(TNaming_NamedShape)::DownCast (anArg));
}
}
}
if (myStop)
{
Handle(TDF_Attribute) aStop = myStop->GetAttribute();
theName.StopNamedShape (Handle(TNaming_NamedShape)::DownCast (aStop));
}
theName.Index (myIndex);
}
//=======================================================================
//function : Read
//purpose : Read persistent data from a file
//=======================================================================
void StdPersistent_Naming::Name_1::Read (StdObjMgt_ReadData& theReadData)
{
Name::Read (theReadData);
theReadData >> myContextLabel;
}
//=======================================================================
//function : Import
//purpose : Import transient object from the persistent data
//=======================================================================
void StdPersistent_Naming::Name_1::Import
(TNaming_Name& theName, const Handle(TDF_Data)& theDF) const
{
Name::Import (theName, theDF);
if (myContextLabel)
theName.ContextLabel (myContextLabel->Label (theDF));
}
//=======================================================================
//function : Read
//purpose : Read persistent data from a file
//=======================================================================
void StdPersistent_Naming::Name_2::Read (StdObjMgt_ReadData& theReadData)
{
Name_1::Read (theReadData);
theReadData >> myOrientation;
}
//=======================================================================
//function : Import
//purpose : Import transient object from the persistent data
//=======================================================================
void StdPersistent_Naming::Name_2::Import
(TNaming_Name& theName, const Handle(TDF_Data)& theDF) const
{
Name_1::Import (theName, theDF);
theName.Orientation (myOrientation);
}
//=======================================================================
//function : ImportAttribute
//purpose : Import transient attribuite from the persistent data
//=======================================================================
void StdPersistent_Naming::Naming::ImportAttribute()
{
Handle(Name) aName;
if (myData.Cast (aName))
{
aName->Import (myTransient->ChangeName(), myTransient->Label().Data());
myData.Nullify();
}
}
//=======================================================================
//function : ImportAttribute
//purpose : Import transient attribuite from the persistent data
//=======================================================================
void StdPersistent_Naming::Naming_1::ImportAttribute()
{
Naming::ImportAttribute();
Handle(TNaming_NamedShape) aNamedShape;
if (myTransient->Label().FindAttribute (TNaming_NamedShape::GetID(), aNamedShape)
&& aNamedShape->Evolution() == TNaming_SELECTED)
{
for (TNaming_Iterator anIter (aNamedShape); anIter.More(); anIter.Next())
{
const TopoDS_Shape& aOldShape = anIter.OldShape();
const TopoDS_Shape& aNewShape = anIter.NewShape();
if (!aOldShape.IsNull() && aOldShape.ShapeType() == TopAbs_VERTEX
&& !aNewShape.IsNull() && aNewShape.ShapeType() != TopAbs_VERTEX)
{
myTransient->ChangeName().Orientation (aOldShape.Orientation());
}
}
}
}

View File

@ -0,0 +1,118 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _StdPersistent_Naming_HeaderFile
#define _StdPersistent_Naming_HeaderFile
#include <StdObjMgt_Attribute.hxx>
#include <StdObjMgt_Persistent.hxx>
#include <StdPersistent_HArray1.hxx>
#include <StdLPersistent_HArray1.hxx>
#include <StdLPersistent_HString.hxx>
#include <TopAbs_ShapeEnum.hxx>
#include <TopAbs_Orientation.hxx>
#include <TNaming_NameType.hxx>
#include <TNaming_NamedShape.hxx>
#include <TNaming_Naming.hxx>
class TNaming_Name;
class StdPersistent_Naming
{
public:
class NamedShape : public StdObjMgt_Attribute<TNaming_NamedShape>
{
public:
//! Read persistent data from a file.
inline void Read (StdObjMgt_ReadData& theReadData)
{ theReadData >> myOldShapes >> myNewShapes >> myShapeStatus >> myVersion; }
//! Import transient attribuite from the persistent data.
void Import (const Handle(TNaming_NamedShape)& theAttribute) const;
private:
Reference <StdPersistent_HArray1::Shape1> myOldShapes;
Reference <StdPersistent_HArray1::Shape1> myNewShapes;
Value <Standard_Integer> myShapeStatus;
Value <Standard_Integer> myVersion;
};
class Name : public StdObjMgt_Persistent
{
public:
//! Read persistent data from a file.
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
//! Import transient object from the persistent data.
Standard_EXPORT virtual void Import
(TNaming_Name& theName, const Handle(TDF_Data)& theDF) const;
private:
Enum <TNaming_NameType> myType;
Enum <TopAbs_ShapeEnum> myShapeType;
Reference <StdLPersistent_HArray1::Persistent> myArgs;
Reference<> myStop;
Value <Standard_Integer> myIndex;
};
class Name_1 : public Name
{
public:
//! Read persistent data from a file.
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
//! Import transient object from the persistent data.
Standard_EXPORT virtual void Import
(TNaming_Name& theName, const Handle(TDF_Data)& theDF) const;
private:
Reference<StdLPersistent_HString::Ascii> myContextLabel;
};
class Name_2 : public Name_1
{
public:
//! Read persistent data from a file.
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
//! Import transient object from the persistent data.
Standard_EXPORT virtual void Import
(TNaming_Name& theName, const Handle(TDF_Data)& theDF) const;
private:
Enum<TopAbs_Orientation> myOrientation;
};
class Naming : public StdObjMgt_Attribute<TNaming_Naming>::SingleRef
{
public:
//! Import transient attribuite from the persistent data.
Standard_EXPORT virtual void ImportAttribute();
};
class Naming_1 : public Naming
{
public:
//! Import transient attribuite from the persistent data.
Standard_EXPORT virtual void ImportAttribute();
};
typedef Naming Naming_2;
};
#endif

View File

@ -0,0 +1,62 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <StdPersistent_PPrsStd.hxx>
//=======================================================================
//function : Import
//purpose : Import transient attribuite from the persistent data
//=======================================================================
void StdPersistent_PPrsStd::AISPresentation::Import
(const Handle(TDataXtd_Presentation)& theAttribute) const
{
theAttribute->SetDisplayed (myIsDisplayed);
Handle(TCollection_HExtendedString) aDriverGUID = myDriverGUID->ExtString();
if (aDriverGUID)
theAttribute->SetDriverGUID (
Standard_GUID (aDriverGUID->String().ToExtString()));
if (myColor != -1)
theAttribute->SetColor
(static_cast<Quantity_NameOfColor> ((Standard_Integer)myColor));
else
theAttribute->UnsetColor();
if (myMaterial != -1)
theAttribute->SetMaterialIndex (myMaterial);
else
theAttribute->UnsetMaterial();
if (myTransparency != -1.)
theAttribute->SetTransparency (myTransparency);
else
theAttribute->UnsetTransparency();
if (myWidth != -1.)
theAttribute->SetWidth (myWidth);
else
theAttribute->UnsetWidth();
}
//=======================================================================
//function : Import
//purpose : Import transient attribuite from the persistent data
//=======================================================================
void StdPersistent_PPrsStd::AISPresentation_1::Import
(const Handle(TDataXtd_Presentation)& theAttribute) const
{
AISPresentation::Import (theAttribute);
theAttribute->SetMode (myMode);
}

View File

@ -0,0 +1,66 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _StdPersistent_PPrsStd_PatternStd_HeaderFile
#define _StdPersistent_PPrsStd_PatternStd_HeaderFile
#include <StdObjMgt_Attribute.hxx>
#include <StdLPersistent_HString.hxx>
#include <TDataXtd_Presentation.hxx>
class StdPersistent_PPrsStd
{
public:
class AISPresentation : public StdObjMgt_Attribute<TDataXtd_Presentation>
{
public:
//! Read persistent data from a file.
inline void Read (StdObjMgt_ReadData& theReadData)
{
theReadData >> myIsDisplayed >> myDriverGUID
>> myTransparency >> myColor >> myMaterial >> myWidth;
}
//! Import transient attribuite from the persistent data.
void Import (const Handle(TDataXtd_Presentation)& theAttribute) const;
private:
Value<Standard_Boolean> myIsDisplayed;
Reference<> myDriverGUID;
Value<Standard_Real> myTransparency;
Value<Standard_Integer> myColor;
Value<Standard_Integer> myMaterial;
Value<Standard_Real> myWidth;
};
class AISPresentation_1 : public AISPresentation
{
public:
//! Read persistent data from a file.
inline void Read (StdObjMgt_ReadData& theReadData)
{
AISPresentation::Read (theReadData);
theReadData >> myMode;
}
//! Import transient attribuite from the persistent data.
void Import (const Handle(TDataXtd_Presentation)& theAttribute) const;
private:
Value<Standard_Integer> myMode;
};
};
#endif

View File

@ -0,0 +1,52 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <StdPersistent_TopLoc.hxx>
#include <StdObjMgt_ReadData.hxx>
#include <StdObject_gp.hxx>
#include <gp_Trsf.hxx>
//=======================================================================
//function : Read
//purpose : Read persistent data from a file
//=======================================================================
void StdPersistent_TopLoc::Datum3D::Read (StdObjMgt_ReadData& theReadData)
{
StdObject_gp::Object<gp_Trsf> aTrsf;
theReadData >> aTrsf;
myTransient = new TopLoc_Datum3D (aTrsf);
}
//=======================================================================
//function : Read
//purpose : Read persistent data from a file
//=======================================================================
void StdPersistent_TopLoc::ItemLocation::Read (StdObjMgt_ReadData& theReadData)
{
theReadData >> myDatum >> myPower >> myNext;
}
//=======================================================================
//function : Import
//purpose : Import transient object from the persistent data
//=======================================================================
TopLoc_Location StdPersistent_TopLoc::ItemLocation::Import() const
{
TopLoc_Location aNext = myNext.Import();
if (myDatum)
return aNext * TopLoc_Location (myDatum->Import()).Powered (myPower);
else
return aNext;
}

View File

@ -0,0 +1,52 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _StdPersistent_TopLoc_HeaderFile
#define _StdPersistent_TopLoc_HeaderFile
#include <StdObjMgt_SharedObject.hxx>
#include <StdObjMgt_Persistent.hxx>
#include <StdObject_Location.hxx>
#include <TopLoc_Datum3D.hxx>
#include <TopLoc_Location.hxx>
class StdPersistent_TopLoc
{
public:
class Datum3D : public StdObjMgt_SharedObject::SharedBase<TopLoc_Datum3D>
{
public:
//! Read persistent data from a file.
void Read (StdObjMgt_ReadData& theReadData);
};
class ItemLocation : public StdObjMgt_Persistent
{
public:
//! Read persistent data from a file.
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
//! Import transient object from the persistent data.
Standard_EXPORT TopLoc_Location Import() const;
private:
Reference<Datum3D> myDatum;
Value<Standard_Integer> myPower;
Object<StdObject_Location> myNext;
};
};
#endif

View File

@ -12,24 +12,31 @@
// commercial license or contractual agreement.
#ifndef _StdLPersistent_PColStd_HArray1Base_HeaderFile
#define _StdLPersistent_PColStd_HArray1Base_HeaderFile
#ifndef _StdPersistent_TopoDS_HeaderFile
#define _StdPersistent_TopoDS_HeaderFile
#include <StdObjMgt_Persistent.hxx>
#include <StdObjMgt_SharedObject.hxx>
#include <StdObjMgt_ReadData.hxx>
#include <TopoDS_TShape.hxx>
class StdLPersistent_PColStd_HArray1Base : public StdObjMgt_Persistent
class StdPersistent_TopoDS : protected StdObjMgt_SharedObject
{
public:
//! Read persistent data from a file.
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
protected:
virtual void CreateArray (const Standard_Integer theLowerBound,
const Standard_Integer theUpperBound) = 0;
class pTShape : public PersistentBase
{
public:
inline void Read (StdObjMgt_ReadData& theReadData)
{ theReadData >> myShapes >> myFlags; }
virtual void ReadValue (StdObjMgt_ReadData& theReadData,
const Standard_Integer theIndex) = 0;
protected:
Reference<> myShapes;
Value<Standard_Integer> myFlags;
};
public:
typedef IgnoreData<StdObjMgt_Persistent, pTShape, TopoDS_TShape> TShape;
};
#endif

View File

@ -1,3 +0,0 @@
project(TKShape)
OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit)

View File

@ -1,4 +0,0 @@
TKernel
TKG2d
TKMath
TKCDF

View File

@ -1,2 +0,0 @@
PACKAGES
EXTERNLIB

View File

@ -1 +0,0 @@
ShapePersistent

View File

@ -1,9 +1,9 @@
TKCDF
TKernel
TKCDF
TKCAF
TKShape
TKLCAF
TKStdL
TKG3d
TKBRep
TKMath
TKG2d
TKG3d
TKStdL

Some files were not shown because too many files have changed in this diff Show More