From ff205346c9bc70b7defa33824e8c4d41cced11a8 Mon Sep 17 00:00:00 2001 From: myn Date: Wed, 2 Mar 2016 23:04:30 +0300 Subject: [PATCH] 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 --- adm/MODULES | 2 +- adm/UDLIST | 3 +- src/OS/ApplicationFramework.tcl | 1 - src/ShapePersistent/FILES | 22 +- src/ShapePersistent/ShapePersistent.cxx | 326 +++++++++++++- src/ShapePersistent/ShapePersistent_BRep.cxx | 392 +++++++++++++++++ src/ShapePersistent/ShapePersistent_BRep.hxx | 298 +++++++++++++ .../ShapePersistent_Geom.cxx} | 33 +- src/ShapePersistent/ShapePersistent_Geom.hxx | 101 +++++ .../ShapePersistent_Geom2d.hxx | 51 +++ .../ShapePersistent_Geom2d_Curve.cxx | 76 ++++ .../ShapePersistent_Geom2d_Curve.hxx | 119 +++++ .../ShapePersistent_Geom_Curve.cxx | 77 ++++ .../ShapePersistent_Geom_Curve.hxx | 122 ++++++ .../ShapePersistent_Geom_Surface.cxx | 110 +++++ .../ShapePersistent_Geom_Surface.hxx | 177 ++++++++ .../ShapePersistent_HArray1.cxx | 45 ++ .../ShapePersistent_HArray1.hxx | 56 +++ .../ShapePersistent_HArray2.cxx | 38 ++ .../ShapePersistent_HArray2.hxx | 55 +++ .../ShapePersistent_HSequence.cxx | 52 +++ .../ShapePersistent_HSequence.hxx | 75 ++++ src/ShapePersistent/ShapePersistent_Poly.cxx | 83 ++++ src/ShapePersistent/ShapePersistent_Poly.hxx | 99 +++++ .../ShapePersistent_TopoDS.cxx | 96 ++++ .../ShapePersistent_TopoDS.hxx | 115 +++++ .../StdDrivers_DocumentRetrievalDriver.cxx | 4 +- .../StdDrivers_DocumentRetrievalDriver.hxx | 7 +- .../StdLDrivers_DocumentRetrievalDriver.cxx | 185 ++++---- .../StdLDrivers_DocumentRetrievalDriver.hxx | 18 +- src/StdLObject/FILES | 2 + .../StdLObject_GUID.cxx} | 24 +- src/StdLObject/StdLObject_GUID.hxx | 29 ++ src/StdLPersistent/FILES | 40 +- src/StdLPersistent/StdLPersistent.cxx | 90 +++- .../StdLPersistent_Collection.cxx | 260 +++++++++++ .../StdLPersistent_Collection.hxx | 197 +++++++++ ...t_PDF_Data.cxx => StdLPersistent_Data.cxx} | 52 ++- ...t_PDF_Data.hxx => StdLPersistent_Data.hxx} | 15 +- .../StdLPersistent_Dependency.cxx | 51 +++ .../StdLPersistent_Dependency.hxx | 49 +++ ...cument.cxx => StdLPersistent_Document.cxx} | 21 +- ...cument.hxx => StdLPersistent_Document.hxx} | 15 +- .../StdLPersistent_Function.hxx | 43 ++ src/StdLPersistent/StdLPersistent_HArray1.cxx | 55 +++ src/StdLPersistent/StdLPersistent_HArray1.hxx | 83 ++++ ...=> StdLPersistent_HArray1OfPersistent.hxx} | 24 +- src/StdLPersistent/StdLPersistent_HArray2.cxx | 56 +++ src/StdLPersistent/StdLPersistent_HArray2.hxx | 82 ++++ src/StdLPersistent/StdLPersistent_HString.cxx | 81 ++++ src/StdLPersistent/StdLPersistent_HString.hxx | 62 +++ .../StdLPersistent_NamedData.cxx | 137 ++++++ .../StdLPersistent_NamedData.hxx | 76 ++++ .../StdLPersistent_PColStd_HArray1.hxx | 62 --- ...taStd_Name.hxx => StdLPersistent_Real.hxx} | 23 +- .../StdLPersistent_TreeNode.cxx | 58 +++ .../StdLPersistent_TreeNode.hxx | 48 ++ src/StdLPersistent/StdLPersistent_Value.cxx | 97 ++++ src/StdLPersistent/StdLPersistent_Value.hxx | 67 +++ .../StdLPersistent_Variable.hxx | 44 ++ src/StdLPersistent/StdLPersistent_Void.hxx | 45 ++ src/StdLPersistent/StdLPersistent_XLink.hxx | 46 ++ src/StdObjMgt/FILES | 3 + src/StdObjMgt/StdObjMgt_Attribute.hxx | 91 ++++ src/StdObjMgt/StdObjMgt_ContentTypes.hxx | 102 +++++ .../StdObjMgt_MapOfInstantiators.hxx | 9 +- src/StdObjMgt/StdObjMgt_Persistent.cxx | 64 ++- src/StdObjMgt/StdObjMgt_Persistent.hxx | 56 ++- src/StdObjMgt/StdObjMgt_ReadData.cxx | 30 +- src/StdObjMgt/StdObjMgt_ReadData.hxx | 66 ++- src/StdObjMgt/StdObjMgt_SharedObject.hxx | 113 +++++ src/StdObject/FILES | 5 + src/StdObject/StdObject_Location.cxx | 29 ++ .../StdObject_Location.hxx} | 19 +- .../StdObject_Shape.cxx} | 27 +- src/StdObject/StdObject_Shape.hxx | 42 ++ src/StdObject/StdObject_gp.hxx | 414 ++++++++++++++++++ src/StdPersistent/FILES | 17 +- src/StdPersistent/StdPersistent.cxx | 46 +- .../StdPersistent_DataXtd.cxx} | 23 +- src/StdPersistent/StdPersistent_DataXtd.hxx | 65 +++ .../StdPersistent_DataXtd_Constraint.cxx | 58 +++ .../StdPersistent_DataXtd_Constraint.hxx | 49 +++ .../StdPersistent_DataXtd_PatternStd.cxx | 56 +++ .../StdPersistent_DataXtd_PatternStd.hxx | 50 +++ src/StdPersistent/StdPersistent_HArray1.cxx | 22 + src/StdPersistent/StdPersistent_HArray1.hxx | 32 ++ .../StdPersistent_HArray1OfShape1.hxx | 23 + src/StdPersistent/StdPersistent_Naming.cxx | 178 ++++++++ src/StdPersistent/StdPersistent_Naming.hxx | 118 +++++ src/StdPersistent/StdPersistent_PPrsStd.cxx | 62 +++ src/StdPersistent/StdPersistent_PPrsStd.hxx | 66 +++ src/StdPersistent/StdPersistent_TopLoc.cxx | 52 +++ src/StdPersistent/StdPersistent_TopLoc.hxx | 52 +++ .../StdPersistent_TopoDS.hxx} | 31 +- src/TKShape/CMakeLists.txt | 3 - src/TKShape/EXTERNLIB | 4 - src/TKShape/FILES | 2 - src/TKShape/PACKAGES | 1 - src/TKStd/EXTERNLIB | 8 +- src/TKStd/PACKAGES | 2 + src/TKStdL/EXTERNLIB | 3 +- src/TKStdL/PACKAGES | 1 + tests/bugs/caf/buc60756_std | 17 + tests/bugs/caf/buc60867_std | 12 + tests/bugs/caf/bug1454_std | 34 ++ tests/bugs/caf/bug1726_std | 26 ++ tests/bugs/caf/bug22788_1_std | 41 ++ tests/bugs/caf/bug22788_2_std | 32 ++ tests/bugs/caf/bug23766_2 | 2 +- tests/bugs/caf/bug5023_std | 39 ++ tests/bugs/modalg_5/bug24849_1_std | 21 + tests/bugs/modalg_5/bug24849_2_std | 21 + tests/bugs/modalg_5/bug25969_std | 37 ++ tests/bugs/moddata_3/bug23733_std | 40 ++ 115 files changed, 6851 insertions(+), 437 deletions(-) create mode 100644 src/ShapePersistent/ShapePersistent_BRep.cxx create mode 100644 src/ShapePersistent/ShapePersistent_BRep.hxx rename src/{StdLPersistent/StdLPersistent_PDataStd_Name.cxx => ShapePersistent/ShapePersistent_Geom.cxx} (60%) create mode 100644 src/ShapePersistent/ShapePersistent_Geom.hxx create mode 100644 src/ShapePersistent/ShapePersistent_Geom2d.hxx create mode 100644 src/ShapePersistent/ShapePersistent_Geom2d_Curve.cxx create mode 100644 src/ShapePersistent/ShapePersistent_Geom2d_Curve.hxx create mode 100644 src/ShapePersistent/ShapePersistent_Geom_Curve.cxx create mode 100644 src/ShapePersistent/ShapePersistent_Geom_Curve.hxx create mode 100644 src/ShapePersistent/ShapePersistent_Geom_Surface.cxx create mode 100644 src/ShapePersistent/ShapePersistent_Geom_Surface.hxx create mode 100644 src/ShapePersistent/ShapePersistent_HArray1.cxx create mode 100644 src/ShapePersistent/ShapePersistent_HArray1.hxx create mode 100644 src/ShapePersistent/ShapePersistent_HArray2.cxx create mode 100644 src/ShapePersistent/ShapePersistent_HArray2.hxx create mode 100644 src/ShapePersistent/ShapePersistent_HSequence.cxx create mode 100644 src/ShapePersistent/ShapePersistent_HSequence.hxx create mode 100644 src/ShapePersistent/ShapePersistent_Poly.cxx create mode 100644 src/ShapePersistent/ShapePersistent_Poly.hxx create mode 100644 src/ShapePersistent/ShapePersistent_TopoDS.cxx create mode 100644 src/ShapePersistent/ShapePersistent_TopoDS.hxx create mode 100644 src/StdLObject/FILES rename src/{StdLPersistent/StdLPersistent_PColStd_HArray1Base.cxx => StdLObject/StdLObject_GUID.cxx} (61%) create mode 100644 src/StdLObject/StdLObject_GUID.hxx create mode 100644 src/StdLPersistent/StdLPersistent_Collection.cxx create mode 100644 src/StdLPersistent/StdLPersistent_Collection.hxx rename src/StdLPersistent/{StdLPersistent_PDF_Data.cxx => StdLPersistent_Data.cxx} (63%) rename src/StdLPersistent/{StdLPersistent_PDF_Data.hxx => StdLPersistent_Data.hxx} (73%) create mode 100644 src/StdLPersistent/StdLPersistent_Dependency.cxx create mode 100644 src/StdLPersistent/StdLPersistent_Dependency.hxx rename src/StdLPersistent/{StdLPersistent_PDocStd_Document.cxx => StdLPersistent_Document.cxx} (73%) rename src/StdLPersistent/{StdLPersistent_PDocStd_Document.hxx => StdLPersistent_Document.hxx} (71%) create mode 100644 src/StdLPersistent/StdLPersistent_Function.hxx create mode 100644 src/StdLPersistent/StdLPersistent_HArray1.cxx create mode 100644 src/StdLPersistent/StdLPersistent_HArray1.hxx rename src/StdLPersistent/{StdLPersistent_PCollection_HExtendedString.hxx => StdLPersistent_HArray1OfPersistent.hxx} (56%) create mode 100644 src/StdLPersistent/StdLPersistent_HArray2.cxx create mode 100644 src/StdLPersistent/StdLPersistent_HArray2.hxx create mode 100644 src/StdLPersistent/StdLPersistent_HString.cxx create mode 100644 src/StdLPersistent/StdLPersistent_HString.hxx create mode 100644 src/StdLPersistent/StdLPersistent_NamedData.cxx create mode 100644 src/StdLPersistent/StdLPersistent_NamedData.hxx delete mode 100644 src/StdLPersistent/StdLPersistent_PColStd_HArray1.hxx rename src/StdLPersistent/{StdLPersistent_PDataStd_Name.hxx => StdLPersistent_Real.hxx} (57%) create mode 100644 src/StdLPersistent/StdLPersistent_TreeNode.cxx create mode 100644 src/StdLPersistent/StdLPersistent_TreeNode.hxx create mode 100644 src/StdLPersistent/StdLPersistent_Value.cxx create mode 100644 src/StdLPersistent/StdLPersistent_Value.hxx create mode 100644 src/StdLPersistent/StdLPersistent_Variable.hxx create mode 100644 src/StdLPersistent/StdLPersistent_Void.hxx create mode 100644 src/StdLPersistent/StdLPersistent_XLink.hxx create mode 100644 src/StdObjMgt/StdObjMgt_Attribute.hxx create mode 100644 src/StdObjMgt/StdObjMgt_ContentTypes.hxx create mode 100644 src/StdObjMgt/StdObjMgt_SharedObject.hxx create mode 100644 src/StdObject/FILES create mode 100644 src/StdObject/StdObject_Location.cxx rename src/{StdLPersistent/StdLPersistent_PDataStd_Integer.hxx => StdObject/StdObject_Location.hxx} (61%) rename src/{StdLPersistent/StdLPersistent_PCollection_HExtendedString.cxx => StdObject/StdObject_Shape.cxx} (58%) create mode 100644 src/StdObject/StdObject_Shape.hxx create mode 100644 src/StdObject/StdObject_gp.hxx rename src/{StdLPersistent/StdLPersistent_PDataStd_Integer.cxx => StdPersistent/StdPersistent_DataXtd.cxx} (68%) create mode 100644 src/StdPersistent/StdPersistent_DataXtd.hxx create mode 100644 src/StdPersistent/StdPersistent_DataXtd_Constraint.cxx create mode 100644 src/StdPersistent/StdPersistent_DataXtd_Constraint.hxx create mode 100644 src/StdPersistent/StdPersistent_DataXtd_PatternStd.cxx create mode 100644 src/StdPersistent/StdPersistent_DataXtd_PatternStd.hxx create mode 100644 src/StdPersistent/StdPersistent_HArray1.cxx create mode 100644 src/StdPersistent/StdPersistent_HArray1.hxx create mode 100644 src/StdPersistent/StdPersistent_HArray1OfShape1.hxx create mode 100644 src/StdPersistent/StdPersistent_Naming.cxx create mode 100644 src/StdPersistent/StdPersistent_Naming.hxx create mode 100644 src/StdPersistent/StdPersistent_PPrsStd.cxx create mode 100644 src/StdPersistent/StdPersistent_PPrsStd.hxx create mode 100644 src/StdPersistent/StdPersistent_TopLoc.cxx create mode 100644 src/StdPersistent/StdPersistent_TopLoc.hxx rename src/{StdLPersistent/StdLPersistent_PColStd_HArray1Base.hxx => StdPersistent/StdPersistent_TopoDS.hxx} (53%) delete mode 100644 src/TKShape/CMakeLists.txt delete mode 100644 src/TKShape/EXTERNLIB delete mode 100644 src/TKShape/FILES delete mode 100644 src/TKShape/PACKAGES create mode 100644 tests/bugs/caf/buc60756_std create mode 100644 tests/bugs/caf/buc60867_std create mode 100644 tests/bugs/caf/bug1454_std create mode 100644 tests/bugs/caf/bug1726_std create mode 100644 tests/bugs/caf/bug22788_1_std create mode 100644 tests/bugs/caf/bug22788_2_std create mode 100644 tests/bugs/caf/bug5023_std create mode 100644 tests/bugs/modalg_5/bug24849_1_std create mode 100644 tests/bugs/modalg_5/bug24849_2_std create mode 100644 tests/bugs/modalg_5/bug25969_std create mode 100644 tests/bugs/moddata_3/bug23733_std diff --git a/adm/MODULES b/adm/MODULES index a057fdee04..e2ef48470d 100644 --- a/adm/MODULES +++ b/adm/MODULES @@ -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 diff --git a/adm/UDLIST b/adm/UDLIST index 9e959532d3..26cf2ebd67 100644 --- a/adm/UDLIST +++ b/adm/UDLIST @@ -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 diff --git a/src/OS/ApplicationFramework.tcl b/src/OS/ApplicationFramework.tcl index 57ae8eab3b..40b982029f 100644 --- a/src/OS/ApplicationFramework.tcl +++ b/src/OS/ApplicationFramework.tcl @@ -27,7 +27,6 @@ proc ApplicationFramework:toolkits { } { FWOSPlugin \ TKStdL \ TKStd \ - TKShape \ TKTObj \ TKBinTObj \ TKXmlTObj \ diff --git a/src/ShapePersistent/FILES b/src/ShapePersistent/FILES index 5385b7cd7d..d90ed480ea 100644 --- a/src/ShapePersistent/FILES +++ b/src/ShapePersistent/FILES @@ -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 diff --git a/src/ShapePersistent/ShapePersistent.cxx b/src/ShapePersistent/ShapePersistent.cxx index 7670fa9c6a..ec9db1ef69 100644 --- a/src/ShapePersistent/ShapePersistent.cxx +++ b/src/ShapePersistent/ShapePersistent.cxx @@ -14,10 +14,334 @@ #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + //======================================================================= //function : BindTypes //purpose : Register types //======================================================================= -void ShapePersistent::BindTypes (StdObjMgt_MapOfInstantiators& /*theMap*/) +void ShapePersistent::BindTypes (StdObjMgt_MapOfInstantiators& theMap) { + theMap.Bind ("PTopoDS_HArray1OfHShape"); + + theMap.Bind ("PTopoDS_HShape"); + theMap.Bind ("PTopoDS_Vertex"); + theMap.Bind ("PTopoDS_Edge"); + theMap.Bind ("PTopoDS_Wire"); + theMap.Bind ("PTopoDS_Face"); + theMap.Bind ("PTopoDS_Shell"); + theMap.Bind ("PTopoDS_Solid"); + theMap.Bind ("PTopoDS_CompSolid"); + theMap.Bind ("PTopoDS_Compound"); + + theMap.Bind ("PTopoDS_TShape"); + + theMap.Bind ("PTopoDS_TVertex"); + theMap.Bind ("PTopoDS_TVertex1"); + theMap.Bind ("PTopoDS_TEdge"); + theMap.Bind ("PTopoDS_TEdge1"); + theMap.Bind ("PTopoDS_TFace"); + theMap.Bind ("PTopoDS_TFace1"); + + theMap.Bind ("PTopoDS_TWire"); + theMap.Bind ("PTopoDS_TWire1"); + theMap.Bind ("PTopoDS_TShell"); + theMap.Bind ("PTopoDS_TShell1"); + theMap.Bind ("PTopoDS_TSolid"); + theMap.Bind ("PTopoDS_TSolid1"); + theMap.Bind ("PTopoDS_TCompSolid"); + theMap.Bind ("PTopoDS_TCompSolid1"); + theMap.Bind ("PTopoDS_TCompound"); + theMap.Bind ("PTopoDS_TCompound1"); + + theMap.Bind ("PColgp_HArray1OfXYZ"); + theMap.Bind ("PColgp_HArray1OfPnt"); + theMap.Bind ("PColgp_HArray1OfDir"); + theMap.Bind ("PColgp_HArray1OfVec"); + theMap.Bind ("PColgp_HArray1OfXY"); + theMap.Bind ("PColgp_HArray1OfPnt2d"); + theMap.Bind ("PColgp_HArray1OfDir2d"); + theMap.Bind ("PColgp_HArray1OfVec2d"); + theMap.Bind ("PColgp_HArray1OfLin2d"); + theMap.Bind ("PColgp_HArray1OfCirc2d"); + theMap.Bind ("PPoly_HArray1OfTriangle"); + + theMap.Bind ("PColgp_HArray2OfXYZ"); + theMap.Bind ("PColgp_HArray2OfPnt"); + theMap.Bind ("PColgp_HArray2OfDir"); + theMap.Bind ("PColgp_HArray2OfVec"); + theMap.Bind ("PColgp_HArray2OfXY"); + theMap.Bind ("PColgp_HArray2OfPnt2d"); + theMap.Bind ("PColgp_HArray2OfDir2d"); + theMap.Bind ("PColgp_HArray2OfVec2d"); + theMap.Bind ("PColgp_HArray2OfLin2d"); + theMap.Bind ("PColgp_HArray2OfCirc2d"); + + theMap.Bind ("PColgp_HSequenceOfXYZ"); + theMap.Bind ("PColgp_HSequenceOfPnt"); + theMap.Bind ("PColgp_HSequenceOfDir"); + theMap.Bind ("PColgp_HSequenceOfVec"); + + theMap.Bind + ("PColgp_SeqNodeOfHSequenceOfXYZ"); + + theMap.Bind + ("PColgp_SeqNodeOfHSequenceOfPnt"); + + theMap.Bind + ("PColgp_SeqNodeOfHSequenceOfDir"); + + theMap.Bind + ("PColgp_SeqNodeOfHSequenceOfVec"); + + theMap.Bind + ("PGeom2d_Transformation"); + + theMap.Bind + ("PGeom2d_Geometry"); + + theMap.Bind + ("PGeom2d_Point"); + + theMap.Bind + ("PGeom2d_CartesianPoint"); + + theMap.Bind + ("PGeom2d_Vector"); + + theMap.Bind + ("PGeom2d_Direction"); + + theMap.Bind + ("PGeom2d_VectorWithMagnitude"); + + theMap.Bind + ("PGeom2d_AxisPlacement"); + + theMap.Bind + ("PGeom2d_Curve"); + + theMap.Bind + ("PGeom2d_Line"); + + theMap.Bind + ("PGeom2d_Conic"); + + theMap.Bind + ("PGeom2d_Circle"); + + theMap.Bind + ("PGeom2d_Ellipse"); + + theMap.Bind + ("PGeom2d_Hyperbola"); + + theMap.Bind + ("PGeom2d_Parabola"); + + theMap.Bind + ("PGeom2d_BoundedCurve"); + + theMap.Bind + ("PGeom2d_BezierCurve"); + + theMap.Bind + ("PGeom2d_BSplineCurve"); + + theMap.Bind + ("PGeom2d_TrimmedCurve"); + + theMap.Bind + ("PGeom2d_OffsetCurve"); + + theMap.Bind + ("PGeom_Transformation"); + + theMap.Bind + ("PGeom_Geometry"); + + theMap.Bind + ("PGeom_Point"); + + theMap.Bind + ("PGeom_CartesianPoint"); + + theMap.Bind + ("PGeom_Vector"); + + theMap.Bind + ("PGeom_Direction"); + + theMap.Bind + ("PGeom_VectorWithMagnitude"); + + theMap.Bind + ("PGeom_AxisPlacement"); + + theMap.Bind + ("PGeom_Axis1Placement"); + + theMap.Bind + ("PGeom_Axis2Placement"); + + theMap.Bind + ("PGeom_Curve"); + + theMap.Bind + ("PGeom_Line"); + + theMap.Bind + ("PGeom_Conic"); + + theMap.Bind + ("PGeom_Circle"); + + theMap.Bind + ("PGeom_Ellipse"); + + theMap.Bind + ("PGeom_Hyperbola"); + + theMap.Bind + ("PGeom_Parabola"); + + theMap.Bind + ("PGeom_BoundedCurve"); + + theMap.Bind + ("PGeom_BezierCurve"); + + theMap.Bind + ("PGeom_BSplineCurve"); + + theMap.Bind + ("PGeom_TrimmedCurve"); + + theMap.Bind + ("PGeom_OffsetCurve"); + + theMap.Bind + ("PGeom_Surface"); + + theMap.Bind + ("PGeom_ElementarySurface"); + + theMap.Bind + ("PGeom_Plane"); + + theMap.Bind + ("PGeom_ConicalSurface"); + + theMap.Bind + ("PGeom_CylindricalSurface"); + + theMap.Bind + ("PGeom_SphericalSurface"); + + theMap.Bind + ("PGeom_ToroidalSurface"); + + theMap.Bind + ("PGeom_SweptSurface"); + + theMap.Bind + ("PGeom_SurfaceOfLinearExtrusion"); + + theMap.Bind + ("PGeom_SurfaceOfRevolution"); + + theMap.Bind + ("PGeom_BoundedSurface"); + + theMap.Bind + ("PGeom_BezierSurface"); + + theMap.Bind + ("PGeom_BSplineSurface"); + + theMap.Bind + ("PGeom_RectangularTrimmedSurface"); + + theMap.Bind + ("PGeom_OffsetSurface"); + + theMap.Bind + ("PPoly_Polygon2D"); + + theMap.Bind + ("PPoly_Polygon3D"); + + theMap.Bind + ("PPoly_PolygonOnTriangulation"); + + theMap.Bind + ("PPoly_Triangulation"); + + theMap.Bind + ("PBRep_PointRepresentation"); + + theMap.Bind + ("PBRep_PointOnCurve"); + + theMap.Bind + ("PBRep_PointsOnSurface"); + + theMap.Bind + ("PBRep_PointOnCurveOnSurface"); + + theMap.Bind + ("PBRep_PointOnSurface"); + + theMap.Bind + ("PBRep_CurveRepresentation"); + + theMap.Bind + ("PBRep_GCurve"); + + theMap.Bind + ("PBRep_Curve3D"); + + theMap.Bind + ("PBRep_CurveOnSurface"); + + theMap.Bind + ("PBRep_CurveOnClosedSurface"); + + theMap.Bind + ("PBRep_Polygon3D"); + + theMap.Bind + ("PBRep_PolygonOnTriangulation"); + + theMap.Bind + ("PBRep_PolygonOnClosedTriangulation"); + + theMap.Bind + ("PBRep_PolygonOnSurface"); + + theMap.Bind + ("PBRep_PolygonOnClosedSurface"); + + theMap.Bind + ("PBRep_CurveOn2Surfaces"); + + theMap.Bind ("PBRep_TVertex"); + theMap.Bind ("PBRep_TVertex1"); + theMap.Bind ("PBRep_TEdge"); + theMap.Bind ("PBRep_TEdge1"); + theMap.Bind ("PBRep_TFace"); + theMap.Bind ("PBRep_TFace1"); } diff --git a/src/ShapePersistent/ShapePersistent_BRep.cxx b/src/ShapePersistent/ShapePersistent_BRep.cxx new file mode 100644 index 0000000000..cb401ca1ae --- /dev/null +++ b/src/ShapePersistent/ShapePersistent_BRep.cxx @@ -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 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + + +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; +} diff --git a/src/ShapePersistent/ShapePersistent_BRep.hxx b/src/ShapePersistent/ShapePersistent_BRep.hxx new file mode 100644 index 0000000000..6a660acde8 --- /dev/null +++ b/src/ShapePersistent/ShapePersistent_BRep.hxx @@ -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 +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include + +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 myLocation; + Value myParameter; + + private: + Reference myNext; + }; + + class PointOnCurve : public PointRepresentation + { + public: + virtual void Read (StdObjMgt_ReadData& theReadData); + virtual Handle(BRep_PointRepresentation) import() const; + + private: + Reference myCurve; + }; + + class PointsOnSurface : public PointRepresentation + { + public: + virtual void Read (StdObjMgt_ReadData& theReadData); + + protected: + Reference mySurface; + }; + + class PointOnCurveOnSurface : public PointsOnSurface + { + public: + virtual void Read (StdObjMgt_ReadData& theReadData); + virtual Handle(BRep_PointRepresentation) import() const; + + private: + Reference myPCurve; + }; + + class PointOnSurface : public PointsOnSurface + { + public: + virtual void Read (StdObjMgt_ReadData& theReadData); + virtual Handle(BRep_PointRepresentation) import() const; + + private: + Value 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 myLocation; + + private: + Reference myNext; + }; + + class GCurve : public CurveRepresentation + { + public: + virtual void Read (StdObjMgt_ReadData& theReadData); + + protected: + Value myFirst; + Value myLast; + }; + + class Curve3D : public GCurve + { + public: + virtual void Read (StdObjMgt_ReadData& theReadData); + virtual Handle(BRep_CurveRepresentation) import() const; + + private: + Reference myCurve3D; + }; + + class CurveOnSurface : public GCurve + { + public: + virtual void Read (StdObjMgt_ReadData& theReadData); + virtual Handle(BRep_CurveRepresentation) import() const; + + protected: + Reference myPCurve; + Reference mySurface; + StdObject_gp::Object myUV1; + StdObject_gp::Object myUV2; + }; + + class CurveOnClosedSurface : public CurveOnSurface + { + public: + virtual void Read (StdObjMgt_ReadData& theReadData); + virtual Handle(BRep_CurveRepresentation) import() const; + + private: + Reference myPCurve2; + Enum myContinuity; + StdObject_gp::Object myUV21; + StdObject_gp::Object myUV22; + }; + + class Polygon3D : public CurveRepresentation + { + public: + virtual void Read (StdObjMgt_ReadData& theReadData); + virtual Handle(BRep_CurveRepresentation) import() const; + + private: + Reference myPolygon3D; + }; + + class PolygonOnTriangulation : public CurveRepresentation + { + public: + virtual void Read (StdObjMgt_ReadData& theReadData); + virtual Handle(BRep_CurveRepresentation) import() const; + + protected: + Reference myPolygon; + Reference myTriangulation; + }; + + class PolygonOnClosedTriangulation : public PolygonOnTriangulation + { + public: + virtual void Read (StdObjMgt_ReadData& theReadData); + virtual Handle(BRep_CurveRepresentation) import() const; + + private: + Reference myPolygon2; + }; + + class PolygonOnSurface : public CurveRepresentation + { + public: + virtual void Read (StdObjMgt_ReadData& theReadData); + virtual Handle(BRep_CurveRepresentation) import() const; + + protected: + Reference myPolygon2D; + Reference mySurface; + }; + + class PolygonOnClosedSurface : public PolygonOnSurface + { + public: + virtual void Read (StdObjMgt_ReadData& theReadData); + virtual Handle(BRep_CurveRepresentation) import() const; + + private: + Reference myPolygon2; + }; + + class CurveOn2Surfaces : public CurveRepresentation + { + public: + virtual void Read (StdObjMgt_ReadData& theReadData); + virtual Handle(BRep_CurveRepresentation) import() const; + + private: + Reference mySurface; + Reference mySurface2; + Object myLocation2; + Enum 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 myTolerance; + StdObject_gp::Object myPnt; + Reference 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 myTolerance; + Value myFlags; + Reference 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 mySurface; + Reference myTriangulation; + Object myLocation; + Value myTolerance; + Value myNaturalRestriction; + }; + +public: + typedef tObject TVertex; + typedef tObject TEdge; + typedef tObject TFace; + + typedef tObject1 TVertex1; + typedef tObject1 TEdge1; + typedef tObject1 TFace1; +}; + +#endif diff --git a/src/StdLPersistent/StdLPersistent_PDataStd_Name.cxx b/src/ShapePersistent/ShapePersistent_Geom.cxx similarity index 60% rename from src/StdLPersistent/StdLPersistent_PDataStd_Name.cxx rename to src/ShapePersistent/ShapePersistent_Geom.cxx index ce8d076d54..17ae4cefed 100644 --- a/src/StdLPersistent/StdLPersistent_PDataStd_Name.cxx +++ b/src/ShapePersistent/ShapePersistent_Geom.cxx @@ -11,33 +11,30 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. -#include -#include +#include -#include - -#include -#include //======================================================================= //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 + ::Read (StdObjMgt_ReadData& theReadData) { - if (myString.IsNull() || myString->Value().IsNull()) - return NULL; + StdObject_gp::Object anAxis; + StdObject_gp::Object anXDirection; + + theReadData >> anAxis >> anXDirection; - Handle(TDataStd_Name) aName = new TDataStd_Name; - aName->Set (myString->Value()->String()); - return aName; + myTransient = new Geom_Axis2Placement (anAxis.Location(), + anAxis.Direction(), + anXDirection); } diff --git a/src/ShapePersistent/ShapePersistent_Geom.hxx b/src/ShapePersistent/ShapePersistent_Geom.hxx new file mode 100644 index 0000000000..9da47d7b6c --- /dev/null +++ b/src/ShapePersistent/ShapePersistent_Geom.hxx @@ -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 +#include + +#include +#include +#include +#include +#include +#include +#include +#include + + +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 + struct geometryBase : DelayedBase {}; + + template + class subBase : public Base + { + public: + //! Read persistent data from a file. + Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData) + { PData().Read (theReadData); } + }; + + template + struct subBase_gp : subBase > {}; + + template + struct subBase_empty : Base {}; + + template + class instance : public Base + { + public: + //! Read persistent data from a file. + Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData) + { + StdObject_gp::Object aData; + theReadData >> aData; + this->myTransient = new Target (aData); + } + }; + +private: + typedef geometryBase basic; + +public: + typedef subBase_empty Point; + typedef instance CartesianPoint; + + typedef subBase_gp Vector; + typedef instance Direction; + typedef instance VectorWithMagnitude; + + typedef subBase_gp AxisPlacement; + typedef instance Axis1Placement; + typedef instance Axis2Placement; + + typedef instance , + Geom_Transformation, + gp_Trsf> Transformation; + + typedef geometryBase Curve; + typedef geometryBase Surface; +}; + +template<> +void ShapePersistent_Geom::instance + ::Read (StdObjMgt_ReadData& theReadData); + +#endif diff --git a/src/ShapePersistent/ShapePersistent_Geom2d.hxx b/src/ShapePersistent/ShapePersistent_Geom2d.hxx new file mode 100644 index 0000000000..cd351ec609 --- /dev/null +++ b/src/ShapePersistent/ShapePersistent_Geom2d.hxx @@ -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 + +#include +#include +#include +#include +#include +#include + + +class ShapePersistent_Geom2d : protected ShapePersistent_Geom +{ + typedef geometryBase basic; + +public: + typedef ShapePersistent_Geom::Geometry Geometry; + + typedef subBase_empty Point; + typedef instance CartesianPoint; + + typedef subBase_gp Vector; + typedef instance Direction; + typedef instance VectorWithMagnitude; + + typedef instance AxisPlacement; + + typedef instance , + Geom2d_Transformation, + gp_Trsf2d> Transformation; + + typedef geometryBase Curve; +}; + +#endif diff --git a/src/ShapePersistent/ShapePersistent_Geom2d_Curve.cxx b/src/ShapePersistent/ShapePersistent_Geom2d_Curve.cxx new file mode 100644 index 0000000000..92f9bd00eb --- /dev/null +++ b/src/ShapePersistent/ShapePersistent_Geom2d_Curve.cxx @@ -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 + +#include +#include +#include +#include + + +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); +} diff --git a/src/ShapePersistent/ShapePersistent_Geom2d_Curve.hxx b/src/ShapePersistent/ShapePersistent_Geom2d_Curve.hxx new file mode 100644 index 0000000000..da39ac34c3 --- /dev/null +++ b/src/ShapePersistent/ShapePersistent_Geom2d_Curve.hxx @@ -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 +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + + +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 myRational; + Reference myPoles; + Reference 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 myRational; + Value myPeriodic; + Value mySpineDegree; + Reference myPoles; + Reference myWeights; + Reference myKnots; + Reference myMultiplicities; + }; + + class pTrimmed : public pBounded + { + public: + inline void Read (StdObjMgt_ReadData& theReadData) + { theReadData >> myBasisCurve >> myFirstU >> myLastU; } + + virtual Handle(Geom2d_Curve) Import() const; + + private: + Reference myBasisCurve; + Value myFirstU; + Value myLastU; + }; + + class pOffset : public pBase + { + public: + inline void Read (StdObjMgt_ReadData& theReadData) + { theReadData >> myBasisCurve >> myOffsetValue; } + + virtual Handle(Geom2d_Curve) Import() const; + + private: + Reference myBasisCurve; + Value myOffsetValue; + }; + +public: + typedef instance Line; + + typedef subBase_gp Conic; + typedef instance Circle; + typedef instance Ellipse; + typedef instance Hyperbola; + typedef instance Parabola; + + typedef subBase_empty Bounded; + typedef Delayed Bezier; + typedef Delayed BSpline; + typedef Delayed Trimmed; + + typedef Delayed Offset; +}; + +#endif diff --git a/src/ShapePersistent/ShapePersistent_Geom_Curve.cxx b/src/ShapePersistent/ShapePersistent_Geom_Curve.cxx new file mode 100644 index 0000000000..11b667df86 --- /dev/null +++ b/src/ShapePersistent/ShapePersistent_Geom_Curve.cxx @@ -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 + +#include +#include +#include +#include + + +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); +} diff --git a/src/ShapePersistent/ShapePersistent_Geom_Curve.hxx b/src/ShapePersistent/ShapePersistent_Geom_Curve.hxx new file mode 100644 index 0000000000..7ba8b41e61 --- /dev/null +++ b/src/ShapePersistent/ShapePersistent_Geom_Curve.hxx @@ -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 +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +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 myRational; + Reference myPoles; + Reference 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 myRational; + Value myPeriodic; + Value mySpineDegree; + Reference myPoles; + Reference myWeights; + Reference myKnots; + Reference myMultiplicities; + }; + + class pTrimmed : public pBounded + { + public: + inline void Read (StdObjMgt_ReadData& theReadData) + { theReadData >> myBasisCurve >> myFirstU >> myLastU; } + + virtual Handle(Geom_Curve) Import() const; + + private: + Reference myBasisCurve; + Value myFirstU; + Value myLastU; + }; + + class pOffset : public pBase + { + public: + inline void Read (StdObjMgt_ReadData& theReadData) + { theReadData >> myBasisCurve >> myOffsetDirection >> myOffsetValue; } + + virtual Handle(Geom_Curve) Import() const; + + private: + Reference myBasisCurve; + StdObject_gp::Object myOffsetDirection; + Value myOffsetValue; + }; + +public: + typedef instance Line; + + typedef subBase_gp Conic; + typedef instance Circle; + typedef instance Ellipse; + typedef instance Hyperbola; + typedef instance Parabola; + + typedef subBase_empty Bounded; + typedef Delayed Bezier; + typedef Delayed BSpline; + typedef Delayed Trimmed; + + typedef Delayed Offset; +}; + +#endif diff --git a/src/ShapePersistent/ShapePersistent_Geom_Surface.cxx b/src/ShapePersistent/ShapePersistent_Geom_Surface.cxx new file mode 100644 index 0000000000..ba383a0b3a --- /dev/null +++ b/src/ShapePersistent/ShapePersistent_Geom_Surface.cxx @@ -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 + +#include +#include +#include +#include +#include +#include + +#include + + +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); +} diff --git a/src/ShapePersistent/ShapePersistent_Geom_Surface.hxx b/src/ShapePersistent/ShapePersistent_Geom_Surface.hxx new file mode 100644 index 0000000000..380a9582a8 --- /dev/null +++ b/src/ShapePersistent/ShapePersistent_Geom_Surface.hxx @@ -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 +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +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 myBasisCurve; + StdObject_gp::Object 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 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 myURational; + Value myVRational; + Reference myPoles; + Reference 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 myURational; + Value myVRational; + Value myUPeriodic; + Value myVPeriodic; + Value myUSpineDegree; + Value myVSpineDegree; + Reference myPoles; + Reference myWeights; + Reference myUKnots; + Reference myVKnots; + Reference myUMultiplicities; + Reference 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 myBasisSurface; + Value myFirstU; + Value myLastU; + Value myFirstV; + Value myLastV; + }; + + class pOffset : public pBase + { + public: + inline void Read (StdObjMgt_ReadData& theReadData) + { theReadData >> myBasisSurface >> myOffsetValue; } + + virtual Handle(Geom_Surface) Import() const; + + private: + Reference myBasisSurface; + Value myOffsetValue; + }; + +public: + typedef subBase_gp Elementary; + typedef instance Plane; + typedef instance Conical; + typedef instance Cylindrical; + typedef instance Spherical; + typedef instance Toroidal; + + typedef subBase Swept; + typedef Delayed LinearExtrusion; + typedef Delayed Revolution; + + typedef subBase_empty Bounded; + typedef Delayed Bezier; + typedef Delayed BSpline; + typedef Delayed RectangularTrimmed; + + typedef Delayed Offset; +}; + +#endif diff --git a/src/ShapePersistent/ShapePersistent_HArray1.cxx b/src/ShapePersistent/ShapePersistent_HArray1.cxx new file mode 100644 index 0000000000..2c363f6a49 --- /dev/null +++ b/src/ShapePersistent/ShapePersistent_HArray1.cxx @@ -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 +#include +#include + + +template +void ShapePersistent_HArray1::instance::readValue + (StdObjMgt_ReadData& theReadData, const Standard_Integer theIndex) +{ + theReadData.ReadObject (StdObject_gp::Ref (this->myArray->ChangeValue (theIndex))); +} + +template<> +void ShapePersistent_HArray1::instance::readValue + (StdObjMgt_ReadData& theReadData, const Standard_Integer theIndex) +{ + Value N1, N2, N3; + theReadData >> N1 >> N2 >> N3; + this->myArray->ChangeValue (theIndex).Set (N1, N2, N3); +} + +template class ShapePersistent_HArray1::instance; +template class ShapePersistent_HArray1::instance; +template class ShapePersistent_HArray1::instance; +template class ShapePersistent_HArray1::instance; +template class ShapePersistent_HArray1::instance; +template class ShapePersistent_HArray1::instance; +template class ShapePersistent_HArray1::instance; +template class ShapePersistent_HArray1::instance; +template class ShapePersistent_HArray1::instance; +template class ShapePersistent_HArray1::instance; +template class ShapePersistent_HArray1::instance; diff --git a/src/ShapePersistent/ShapePersistent_HArray1.hxx b/src/ShapePersistent/ShapePersistent_HArray1.hxx new file mode 100644 index 0000000000..7619baacf7 --- /dev/null +++ b/src/ShapePersistent/ShapePersistent_HArray1.hxx @@ -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 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +class ShapePersistent_HArray1 : private StdLPersistent_HArray1 +{ + template + class instance : public StdLPersistent_HArray1::base + { + virtual void readValue (StdObjMgt_ReadData& theReadData, + const Standard_Integer theIndex); + }; + +public: + typedef instance XYZ; + typedef instance Pnt; + typedef instance Dir; + typedef instance Vec; + typedef instance XY; + typedef instance Pnt2d; + typedef instance Dir2d; + typedef instance Vec2d; + typedef instance Lin2d; + typedef instance Circ2d; + typedef instance Triangle; +}; + +#endif diff --git a/src/ShapePersistent/ShapePersistent_HArray2.cxx b/src/ShapePersistent/ShapePersistent_HArray2.cxx new file mode 100644 index 0000000000..6879e1744d --- /dev/null +++ b/src/ShapePersistent/ShapePersistent_HArray2.cxx @@ -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 +#include +#include + + +template +void ShapePersistent_HArray2::instance::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; +template class ShapePersistent_HArray2::instance; +template class ShapePersistent_HArray2::instance; +template class ShapePersistent_HArray2::instance; +template class ShapePersistent_HArray2::instance; +template class ShapePersistent_HArray2::instance; +template class ShapePersistent_HArray2::instance; +template class ShapePersistent_HArray2::instance; +template class ShapePersistent_HArray2::instance; +template class ShapePersistent_HArray2::instance; diff --git a/src/ShapePersistent/ShapePersistent_HArray2.hxx b/src/ShapePersistent/ShapePersistent_HArray2.hxx new file mode 100644 index 0000000000..bd3d6c8f51 --- /dev/null +++ b/src/ShapePersistent/ShapePersistent_HArray2.hxx @@ -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 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +class ShapePersistent_HArray2 : private StdLPersistent_HArray2 +{ + template + class instance : public StdLPersistent_HArray2::base + { + virtual void readValue (StdObjMgt_ReadData& theReadData, + const Standard_Integer theRow, + const Standard_Integer theCol); + }; + +public: + typedef instance XYZ; + typedef instance Pnt; + typedef instance Dir; + typedef instance Vec; + typedef instance XY; + typedef instance Pnt2d; + typedef instance Dir2d; + typedef instance Vec2d; + typedef instance Lin2d; + typedef instance Circ2d; +}; + +#endif diff --git a/src/ShapePersistent/ShapePersistent_HSequence.cxx b/src/ShapePersistent/ShapePersistent_HSequence.cxx new file mode 100644 index 0000000000..35af5f9c88 --- /dev/null +++ b/src/ShapePersistent/ShapePersistent_HSequence.cxx @@ -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 +#include + + +template +void ShapePersistent_HSequence::node::Read + (StdObjMgt_ReadData& theReadData) +{ + theReadData >> myPreviuos >> myItem >> myNext; +} + +template +void ShapePersistent_HSequence::instance::Read + (StdObjMgt_ReadData& theReadData) +{ + theReadData >> myFirst >> myLast >> mySize; +} + +template +Handle(SequenceClass) + ShapePersistent_HSequence::instance::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; +template class ShapePersistent_HSequence::node; +template class ShapePersistent_HSequence::node; +template class ShapePersistent_HSequence::node; + +template class ShapePersistent_HSequence::instance; +template class ShapePersistent_HSequence::instance; +template class ShapePersistent_HSequence::instance; +template class ShapePersistent_HSequence::instance; diff --git a/src/ShapePersistent/ShapePersistent_HSequence.hxx b/src/ShapePersistent/ShapePersistent_HSequence.hxx new file mode 100644 index 0000000000..ad96e71cfe --- /dev/null +++ b/src/ShapePersistent/ShapePersistent_HSequence.hxx @@ -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 +#include + +#include +#include +#include +#include + + +class ShapePersistent_HSequence +{ + template + 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 myPreviuos; + Reference myNext; + StdObject_gp::Object myItem; + }; + + template + class instance : public StdObjMgt_Persistent + { + public: + typedef node 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 myFirst; + Reference myLast; + Value mySize; + }; + +public: + typedef instance XYZ; + typedef instance Pnt; + typedef instance Dir; + typedef instance Vec; +}; + +#endif diff --git a/src/ShapePersistent/ShapePersistent_Poly.cxx b/src/ShapePersistent/ShapePersistent_Poly.cxx new file mode 100644 index 0000000000..869138514b --- /dev/null +++ b/src/ShapePersistent/ShapePersistent_Poly.cxx @@ -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 + +#include +#include +#include +#include + + +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; +} diff --git a/src/ShapePersistent/ShapePersistent_Poly.hxx b/src/ShapePersistent/ShapePersistent_Poly.hxx new file mode 100644 index 0000000000..e97a949b9a --- /dev/null +++ b/src/ShapePersistent/ShapePersistent_Poly.hxx @@ -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 +#include +#include +#include + +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 myDeflection; + Reference myNodes; + }; + + class pPolygon3D : public PersistentBase + { + public: + inline void Read (StdObjMgt_ReadData& theReadData) + { theReadData >> myDeflection >> myNodes >> myParameters; } + + Handle(Poly_Polygon3D) Import() const; + + private: + Value myDeflection; + Reference myNodes; + Reference myParameters; + }; + + class pPolygonOnTriangulation : public PersistentBase + { + public: + inline void Read (StdObjMgt_ReadData& theReadData) + { theReadData >> myDeflection >> myNodes >> myParameters; } + + Handle(Poly_PolygonOnTriangulation) Import() const; + + private: + Value myDeflection; + Reference myNodes; + Reference myParameters; + }; + + class pTriangulation : public PersistentBase + { + public: + inline void Read (StdObjMgt_ReadData& theReadData) + { theReadData >> myDeflection >> myNodes >> myUVNodes >> myTriangles; } + + Handle(Poly_Triangulation) Import() const; + + private: + Value myDeflection; + Reference myNodes; + Reference myUVNodes; + Reference myTriangles; + }; + + template + struct instance + : Delayed > {}; + +public: + typedef instance Polygon2D; + typedef instance Polygon3D; + typedef instance PolygonOnTriangulation; + typedef instance Triangulation; +}; + +#endif diff --git a/src/ShapePersistent/ShapePersistent_TopoDS.cxx b/src/ShapePersistent/ShapePersistent_TopoDS.cxx new file mode 100644 index 0000000000..0e4e315081 --- /dev/null +++ b/src/ShapePersistent/ShapePersistent_TopoDS.cxx @@ -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 + +#include + + +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 +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 + (TopoDS_Shape& theParent) const; + +template void ShapePersistent_TopoDS::pTBase::addShapesT + (TopoDS_Shape& theParent) const; + +template +Handle(TopoDS_TShape) + ShapePersistent_TopoDS::pTSimple::createTShape() const + { return new Target; } + +template class ShapePersistent_TopoDS::pTSimple; +template class ShapePersistent_TopoDS::pTSimple; +template class ShapePersistent_TopoDS::pTSimple; +template class ShapePersistent_TopoDS::pTSimple; +template class ShapePersistent_TopoDS::pTSimple; diff --git a/src/ShapePersistent/ShapePersistent_TopoDS.hxx b/src/ShapePersistent/ShapePersistent_TopoDS.hxx new file mode 100644 index 0000000000..ecee6077c9 --- /dev/null +++ b/src/ShapePersistent/ShapePersistent_TopoDS.hxx @@ -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 +#include +#include +#include + +#include +#include +#include +#include +#include + + +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 + void addShapesT (TopoDS_Shape& theParent) const; + }; + +private: + template + class pTSimple : public pTBase + { virtual Handle(TopoDS_TShape) createTShape() const; }; + + template + class pTObject : public Persistent + { + virtual void addShapes (TopoDS_Shape& theParent) const + { + pTBase::addShapesT (theParent); + } + }; + + template + struct tObjectT : Delayed , + pTObject > {}; + +protected: + template + struct tObject : tObjectT {}; + + template + struct tObject1 : tObjectT {}; + +public: + typedef tObject > TWire; + typedef tObject > TShell; + typedef tObject > TSolid; + typedef tObject > TCompSolid; + typedef tObject > TCompound; + + typedef tObject1 > TWire1; + typedef tObject1 > TShell1; + typedef tObject1 > TSolid1; + typedef tObject1 > TCompSolid1; + typedef tObject1 > TCompound1; +}; + +#endif diff --git a/src/StdDrivers/StdDrivers_DocumentRetrievalDriver.cxx b/src/StdDrivers/StdDrivers_DocumentRetrievalDriver.cxx index 4f2cfc1500..02d56130e2 100644 --- a/src/StdDrivers/StdDrivers_DocumentRetrievalDriver.cxx +++ b/src/StdDrivers/StdDrivers_DocumentRetrievalDriver.cxx @@ -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); } diff --git a/src/StdDrivers/StdDrivers_DocumentRetrievalDriver.hxx b/src/StdDrivers/StdDrivers_DocumentRetrievalDriver.hxx index d68339758a..2abfdb028b 100644 --- a/src/StdDrivers/StdDrivers_DocumentRetrievalDriver.hxx +++ b/src/StdDrivers/StdDrivers_DocumentRetrievalDriver.hxx @@ -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 diff --git a/src/StdLDrivers/StdLDrivers_DocumentRetrievalDriver.cxx b/src/StdLDrivers/StdLDrivers_DocumentRetrievalDriver.cxx index 05ce4ef2c3..355978062c 100644 --- a/src/StdLDrivers/StdLDrivers_DocumentRetrievalDriver.cxx +++ b/src/StdLDrivers/StdLDrivers_DocumentRetrievalDriver.cxx @@ -13,8 +13,8 @@ #include #include -#include +#include #include #include @@ -32,6 +32,7 @@ #include #include #include +#include #include 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 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 - 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; } - } - - if (RaiseOnStorageError (aFileDriver->EndReadDataSection())) - return; + catch (Storage_StreamTypeMismatchError) { anError = Storage_VSTypeMismatch; } + catch (Storage_StreamFormatError ) { anError = Storage_VSFormatError; } + catch (Storage_StreamReadError ) { anError = Storage_VSFormatError; } - // 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); + raiseOnStorageError (anError); + } - if (!aPDocument.IsNull()) - aPDocument->Import (theNewDocument); + raiseOnStorageError (aFileDriver->EndReadDataSection()); - 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); } diff --git a/src/StdLDrivers/StdLDrivers_DocumentRetrievalDriver.hxx b/src/StdLDrivers/StdLDrivers_DocumentRetrievalDriver.hxx index c5af92acff..dc076def5d 100644 --- a/src/StdLDrivers/StdLDrivers_DocumentRetrievalDriver.hxx +++ b/src/StdLDrivers/StdLDrivers_DocumentRetrievalDriver.hxx @@ -18,6 +18,7 @@ #include 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) +protected: + //! Register types. + Standard_EXPORT virtual void bindTypes (StdObjMgt_MapOfInstantiators& theMap); + private: - //! Update the reader status and raise an exception appropriate for the given storage error. - Standard_EXPORT Standard_Boolean RaiseOnStorageError (Storage_Error theError); + //! Read persistent document from a file. + Handle(StdObjMgt_Persistent) read ( + const TCollection_ExtendedString& theFileName, + Storage_HeaderData& theHeaderData); - //! Register types. - Standard_EXPORT virtual void BindTypes (StdObjMgt_MapOfInstantiators& theMap); + //! 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 diff --git a/src/StdLObject/FILES b/src/StdLObject/FILES new file mode 100644 index 0000000000..1df0b8cc05 --- /dev/null +++ b/src/StdLObject/FILES @@ -0,0 +1,2 @@ +StdLObject_GUID.cxx +StdLObject_GUID.hxx diff --git a/src/StdLPersistent/StdLPersistent_PColStd_HArray1Base.cxx b/src/StdLObject/StdLObject_GUID.cxx similarity index 61% rename from src/StdLPersistent/StdLPersistent_PColStd_HArray1Base.cxx rename to src/StdLObject/StdLObject_GUID.cxx index 571ebbe805..81c80fa9e4 100644 --- a/src/StdLPersistent/StdLPersistent_PColStd_HArray1Base.cxx +++ b/src/StdLObject/StdLObject_GUID.cxx @@ -11,27 +11,23 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. -#include +#include -#include //======================================================================= //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 a32b; + Value a16b[3]; + Value 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 (this) = + Standard_GUID (a32b, a16b[0], a16b[1], a16b[2], + a8b[0], a8b[1], a8b[2], a8b[3], a8b[4], a8b[5]); } diff --git a/src/StdLObject/StdLObject_GUID.hxx b/src/StdLObject/StdLObject_GUID.hxx new file mode 100644 index 0000000000..30afc1b9d7 --- /dev/null +++ b/src/StdLObject/StdLObject_GUID.hxx @@ -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 + +#include + + +class StdLObject_GUID : public Standard_GUID, private StdObjMgt_ContentTypes +{ +public: + void Read (StdObjMgt_ReadData& theReadData); +}; + +#endif diff --git a/src/StdLPersistent/FILES b/src/StdLPersistent/FILES index df9d0dc9fd..dafe9dd880 100644 --- a/src/StdLPersistent/FILES +++ b/src/StdLPersistent/FILES @@ -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 diff --git a/src/StdLPersistent/StdLPersistent.cxx b/src/StdLPersistent/StdLPersistent.cxx index e5e23f49e4..d4f00d9727 100644 --- a/src/StdLPersistent/StdLPersistent.cxx +++ b/src/StdLPersistent/StdLPersistent.cxx @@ -14,12 +14,22 @@ #include #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + //======================================================================= //function : BindTypes @@ -27,17 +37,65 @@ //======================================================================= void StdLPersistent::BindTypes (StdObjMgt_MapOfInstantiators& theMap) { - theMap.Bind ("PDocStd_Document"); - theMap.Bind ("PDF_Data"); - theMap.Bind ("PDataStd_Name"); - theMap.Bind ("PDataStd_Integer"); + // Non-attribute data + theMap.Bind ("PDocStd_Document"); + theMap.Bind ("PDF_Data"); + + theMap.Bind ("PCollection_HAsciiString"); + theMap.Bind ("PCollection_HExtendedString"); + + theMap.Bind ("PColStd_HArray1OfInteger"); + theMap.Bind ("PColStd_HArray1OfReal"); + theMap.Bind ("PColStd_HArray1OfExtendedString"); + theMap.Bind ("PDF_HAttributeArray1"); + theMap.Bind ("PDataStd_HArray1OfHAsciiString"); + theMap.Bind ("PDataStd_HArray1OfHArray1OfInteger"); + theMap.Bind ("PDataStd_HArray1OfHArray1OfReal"); + theMap.Bind ("PDataStd_HArray1OfByte"); + + theMap.Bind ("PColStd_HArray2OfInteger"); + + // Attributes + theMap.Bind ("PDataStd_Directory"); + theMap.Bind ("PDataStd_Tick"); + theMap.Bind ("PDataStd_NoteBook"); + + theMap.Bind ("PDataStd_Integer"); + theMap.Bind ("PDF_TagSource"); + theMap.Bind ("PDF_Reference"); + theMap.Bind ("PDataStd_UAttribute"); + + theMap.Bind ("PDataStd_Name"); + theMap.Bind ("PDataStd_Comment"); + theMap.Bind ("PDataStd_AsciiString"); + + theMap.Bind ("PDataStd_IntegerArray"); + theMap.Bind ("PDataStd_RealArray"); + theMap.Bind ("PDataStd_ByteArray"); + theMap.Bind ("PDataStd_ExtStringArray"); + theMap.Bind ("PDataStd_BooleanArray"); + theMap.Bind ("PDataStd_ReferenceArray"); + + theMap.Bind ("PDataStd_IntegerArray_1"); + theMap.Bind ("PDataStd_RealArray_1"); + theMap.Bind ("PDataStd_ByteArray_1"); + theMap.Bind ("PDataStd_ExtStringArray_1"); - theMap.Bind - ("PColStd_HArray1OfInteger"); + theMap.Bind ("PDataStd_IntegerList"); + theMap.Bind ("PDataStd_RealList"); + theMap.Bind ("PDataStd_BooleanList"); + theMap.Bind ("PDataStd_ExtStringList"); + theMap.Bind ("PDataStd_ReferenceList"); - theMap.Bind - ("PDF_HAttributeArray1"); + theMap.Bind ("PDataStd_IntPackedMap"); + theMap.Bind ("PDataStd_IntPackedMap_1"); - theMap.Bind - ("PCollection_HExtendedString"); + theMap.Bind ("PDataStd_Real"); + theMap.Bind ("PDataStd_Expression"); + theMap.Bind ("PDataStd_Relation"); + theMap.Bind ("PDataStd_Variable"); + theMap.Bind ("PDocStd_XLink"); + theMap.Bind ("PFunction_Function"); + theMap.Bind ("PDataStd_TreeNode"); + theMap.Bind ("PDataStd_NamedData"); } diff --git a/src/StdLPersistent/StdLPersistent_Collection.cxx b/src/StdLPersistent/StdLPersistent_Collection.cxx new file mode 100644 index 0000000000..ec44de43a8 --- /dev/null +++ b/src/StdLPersistent/StdLPersistent_Collection.cxx @@ -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 + +#include +#include + + +struct StdLPersistent_Collection::noConversion +{ + noConversion (const Handle(TDF_Data)&) {} + + template + 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 (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 +void StdLPersistent_Collection::booleanArrayBase::Read + (StdObjMgt_ReadData& theReadData) +{ + StdLPersistent_Collection::booleanArrayBase::SingleRef::Read (theReadData); + theReadData >> myLower >> myUpper; +} + +template +template +void StdLPersistent_Collection::booleanArrayBase::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 +template +void StdLPersistent_Collection::directArrayBase::import + (const ArrayHandle& theArray, Converter) const +{ + this->myTransient->ChangeArray (theArray); +} + +template +template +void StdLPersistent_Collection::arrayBase::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 +template +void StdLPersistent_Collection::listBase::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 +template +void StdLPersistent_Collection::mapBase::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 class BaseT, + class HArrayClass, + class AttribClass, + class Converter> +void StdLPersistent_Collection:: + instance::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 +void StdLPersistent_Collection::instance_1::Read + (StdObjMgt_ReadData& theReadData) +{ + Instance::Read (theReadData); + theReadData >> myDelta; +} + +//======================================================================= +//function : ImportAttribute +//purpose : Import transient attribuite from the persistent data +//======================================================================= +template +void StdLPersistent_Collection::instance_1::ImportAttribute() +{ + Instance::ImportAttribute(); + this->myTransient->SetDelta (myDelta); +} + + +template class StdLPersistent_Collection::instance + ; + +template class StdLPersistent_Collection::instance + ; + +template class StdLPersistent_Collection::instance + ; + +template class StdLPersistent_Collection::instance + ; + +template class StdLPersistent_Collection::instance + ; + +template class StdLPersistent_Collection::instance + ; + +template class StdLPersistent_Collection::instance + ; + +template class StdLPersistent_Collection::instance + ; + +template class StdLPersistent_Collection::instance + ; + +template class StdLPersistent_Collection::instance + ; + +template class StdLPersistent_Collection::instance + ; + +template class StdLPersistent_Collection::instance + ; + +template class StdLPersistent_Collection::instance_1 + ; + +template class StdLPersistent_Collection::instance_1 + ; + +template class StdLPersistent_Collection::instance_1 + ; + +template class StdLPersistent_Collection::instance_1 + ; + +template class StdLPersistent_Collection::instance_1 + ; diff --git a/src/StdLPersistent/StdLPersistent_Collection.hxx b/src/StdLPersistent/StdLPersistent_Collection.hxx new file mode 100644 index 0000000000..643e89d884 --- /dev/null +++ b/src/StdLPersistent/StdLPersistent_Collection.hxx @@ -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 +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +class StdLPersistent_Collection : private StdObjMgt_ContentTypes +{ + // Converters + struct noConversion; + struct byteConverter; + struct stringConverter; + struct referenceConverter; + + // Base templates + template + class booleanArrayBase : public Base + { + public: + //! Read persistent data from a file. + Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData); + + protected: + template + inline void import (const ArrayHandle& theArray, Converter theConverter) + const; + + protected: + Value myLower; + Value myUpper; + }; + + template + class directArrayBase : public Base + { + protected: + template + inline void import (const ArrayHandle& theArray, Converter theConverter) + const; + }; + + template + class arrayBase : public Base + { + protected: + template + inline void import (const ArrayHandle& theArray, Converter theConverter) + const; + }; + + template + class listBase : public Base + { + protected: + template + inline void import (const ArrayHandle& theArray, Converter theConverter) + const; + }; + + template + class mapBase : public Base + { + protected: + template + inline void import (const ArrayHandle& theArray, Converter theConverter) + const; + }; + + // Instance templates + template class BaseT, + class HArrayClass, + class AttribClass, + class Converter> + class instance + : public BaseT ::SingleRef> + { + public: + //! Import transient attribuite from the persistent data. + Standard_EXPORT virtual void ImportAttribute(); + }; + + template + 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 myDelta; + }; + + + // Collection type specialization + template + struct booleanArrayT + : instance {}; + + template + struct directArrayT + : instance {}; + + template + struct arrayT + : instance {}; + + template + struct listT + : instance {}; + + template + struct mapT + : instance {}; + + + // Internal array types + typedef StdLPersistent_HArray1::Integer integer; + typedef StdLPersistent_HArray1::Real real; + typedef StdLPersistent_HArray1::Persistent persistent; + +public: + // Final specialization + typedef booleanArrayT + BooleanArray; + + typedef directArrayT + IntegerArray; + + typedef directArrayT + RealArray; + + typedef arrayT + ByteArray; + + typedef arrayT + ExtStringArray; + + typedef arrayT + ReferenceArray; + + typedef listT + IntegerList; + + typedef listT + RealList; + + typedef listT + BooleanList; + + typedef listT + ExtStringList; + + typedef listT + ReferenceList; + + typedef mapT + IntPackedMap; + + typedef instance_1 IntegerArray_1; + typedef instance_1 RealArray_1; + typedef instance_1 ByteArray_1; + typedef instance_1 ExtStringArray_1; + typedef instance_1 IntPackedMap_1; +}; + +#endif diff --git a/src/StdLPersistent/StdLPersistent_PDF_Data.cxx b/src/StdLPersistent/StdLPersistent_Data.cxx similarity index 63% rename from src/StdLPersistent/StdLPersistent_PDF_Data.cxx rename to src/StdLPersistent/StdLPersistent_Data.cxx index 0ff63ea5ec..c36bb490a9 100644 --- a/src/StdLPersistent/StdLPersistent_PDF_Data.cxx +++ b/src/StdLPersistent/StdLPersistent_Data.cxx @@ -11,53 +11,50 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. -#include - +#include #include #include #include + //! 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::Iterator myLabelsIter; - NCollection_Array1::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; } diff --git a/src/StdLPersistent/StdLPersistent_PDF_Data.hxx b/src/StdLPersistent/StdLPersistent_Data.hxx similarity index 73% rename from src/StdLPersistent/StdLPersistent_PDF_Data.hxx rename to src/StdLPersistent/StdLPersistent_Data.hxx index eb2e13a323..441a677b82 100644 --- a/src/StdLPersistent/StdLPersistent_PDF_Data.hxx +++ b/src/StdLPersistent/StdLPersistent_Data.hxx @@ -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 - -#include +#include 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 myVersion; + Reference myLabels; + Reference myAttributes; }; #endif diff --git a/src/StdLPersistent/StdLPersistent_Dependency.cxx b/src/StdLPersistent/StdLPersistent_Dependency.cxx new file mode 100644 index 0000000000..6d61612386 --- /dev/null +++ b/src/StdLPersistent/StdLPersistent_Dependency.cxx @@ -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 + + +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 +void StdLPersistent_Dependency::instance::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; +template class StdLPersistent_Dependency::instance; diff --git a/src/StdLPersistent/StdLPersistent_Dependency.hxx b/src/StdLPersistent/StdLPersistent_Dependency.hxx new file mode 100644 index 0000000000..4d7884ad80 --- /dev/null +++ b/src/StdLPersistent/StdLPersistent_Dependency.hxx @@ -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 +#include +#include + +#include +#include + + +class StdLPersistent_Dependency +{ + template + class instance : public StdObjMgt_Attribute + { + 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 myName; + StdObjMgt_ContentTypes::Reference myVariables; + }; + +public: + typedef instance Expression; + typedef instance Relation; +}; + +#endif diff --git a/src/StdLPersistent/StdLPersistent_PDocStd_Document.cxx b/src/StdLPersistent/StdLPersistent_Document.cxx similarity index 73% rename from src/StdLPersistent/StdLPersistent_PDocStd_Document.cxx rename to src/StdLPersistent/StdLPersistent_Document.cxx index cee3e24574..b311af4ca0 100644 --- a/src/StdLPersistent/StdLPersistent_PDocStd_Document.cxx +++ b/src/StdLPersistent/StdLPersistent_Document.cxx @@ -11,19 +11,19 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. -#include -#include - +#include +#include #include #include #include + //======================================================================= //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); } diff --git a/src/StdLPersistent/StdLPersistent_PDocStd_Document.hxx b/src/StdLPersistent/StdLPersistent_Document.hxx similarity index 71% rename from src/StdLPersistent/StdLPersistent_PDocStd_Document.hxx rename to src/StdLPersistent/StdLPersistent_Document.hxx index 2a71a8315b..b68a03404e 100644 --- a/src/StdLPersistent/StdLPersistent_PDocStd_Document.hxx +++ b/src/StdLPersistent/StdLPersistent_Document.hxx @@ -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 -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 myData; }; #endif diff --git a/src/StdLPersistent/StdLPersistent_Function.hxx b/src/StdLPersistent/StdLPersistent_Function.hxx new file mode 100644 index 0000000000..845cb453bf --- /dev/null +++ b/src/StdLPersistent/StdLPersistent_Function.hxx @@ -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 +#include + +#include + + +class StdLPersistent_Function : public StdObjMgt_Attribute +{ +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 myDriverGUID; + Value myFailure; +}; + +#endif diff --git a/src/StdLPersistent/StdLPersistent_HArray1.cxx b/src/StdLPersistent/StdLPersistent_HArray1.cxx new file mode 100644 index 0000000000..ef0cb923ae --- /dev/null +++ b/src/StdLPersistent/StdLPersistent_HArray1.cxx @@ -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 +#include + + +//======================================================================= +//function : Read +//purpose : Read persistent data from a file +//======================================================================= +void StdLPersistent_HArray1::commonBase::Read (StdObjMgt_ReadData& theReadData) +{ + Value 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 +void StdLPersistent_HArray1::instance::readValue ( + StdObjMgt_ReadData& theReadData, + const Standard_Integer theIndex) +{ + ValueClass aValue; + theReadData >> aValue; + this->myArray->SetValue (theIndex, static_cast (aValue)); +} + + +template class StdLPersistent_HArray1::instance; +template class StdLPersistent_HArray1::instance; +template class StdLPersistent_HArray1::instance >; +template class StdLPersistent_HArray1::instance >; diff --git a/src/StdLPersistent/StdLPersistent_HArray1.hxx b/src/StdLPersistent/StdLPersistent_HArray1.hxx new file mode 100644 index 0000000000..c8c9bcecc8 --- /dev/null +++ b/src/StdLPersistent/StdLPersistent_HArray1.hxx @@ -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 +#include +#include +#include +#include + +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 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 instance : public base + { + protected: + Standard_EXPORT virtual void readValue (StdObjMgt_ReadData& theReadData, + const Standard_Integer theIndex); + }; + +public: + typedef instance Integer; + typedef instance Real; + typedef instance >Byte; + typedef instance > Persistent; +}; + +#endif diff --git a/src/StdLPersistent/StdLPersistent_PCollection_HExtendedString.hxx b/src/StdLPersistent/StdLPersistent_HArray1OfPersistent.hxx similarity index 56% rename from src/StdLPersistent/StdLPersistent_PCollection_HExtendedString.hxx rename to src/StdLPersistent/StdLPersistent_HArray1OfPersistent.hxx index acb5d3ce37..e22a6ae8e8 100644 --- a/src/StdLPersistent/StdLPersistent_PCollection_HExtendedString.hxx +++ b/src/StdLPersistent/StdLPersistent_HArray1OfPersistent.hxx @@ -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 #include -class TCollection_HExtendedString; +DEFINE_HARRAY1 (StdLPersistent_HArray1OfPersistent, + NCollection_Array1) - -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 diff --git a/src/StdLPersistent/StdLPersistent_HArray2.cxx b/src/StdLPersistent/StdLPersistent_HArray2.cxx new file mode 100644 index 0000000000..99135e4a17 --- /dev/null +++ b/src/StdLPersistent/StdLPersistent_HArray2.cxx @@ -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 +#include + +#include +#include + + +//======================================================================= +//function : Read +//purpose : Read persistent data from a file +//======================================================================= +void StdLPersistent_HArray2::commonBase::Read (StdObjMgt_ReadData& theReadData) +{ + Value 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 +void StdLPersistent_HArray2::instance::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; +template class StdLPersistent_HArray2::instance; diff --git a/src/StdLPersistent/StdLPersistent_HArray2.hxx b/src/StdLPersistent/StdLPersistent_HArray2.hxx new file mode 100644 index 0000000000..045bcb55a9 --- /dev/null +++ b/src/StdLPersistent/StdLPersistent_HArray2.hxx @@ -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 + +#include +#include + + +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 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 instance : public base + { + protected: + Standard_EXPORT virtual void readValue (StdObjMgt_ReadData& theReadData, + const Standard_Integer theRow, + const Standard_Integer theCol); + }; + +public: + typedef instance Integer; + typedef instance Real; +}; + +#endif diff --git a/src/StdLPersistent/StdLPersistent_HString.cxx b/src/StdLPersistent/StdLPersistent_HString.cxx new file mode 100644 index 0000000000..04000c45c7 --- /dev/null +++ b/src/StdLPersistent/StdLPersistent_HString.cxx @@ -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 +#include +#include +#include + + +//======================================================================= +//function : Read +//purpose : Read persistent data from a file +//======================================================================= +template +void StdLPersistent_HString::instance::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 +TDF_Label StdLPersistent_HString::instance::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 + ; + +template class StdLPersistent_HString::instance + ; diff --git a/src/StdLPersistent/StdLPersistent_HString.hxx b/src/StdLPersistent/StdLPersistent_HString.hxx new file mode 100644 index 0000000000..a608d24e3d --- /dev/null +++ b/src/StdLPersistent/StdLPersistent_HString.hxx @@ -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 + +#include +#include +#include + + +class StdLPersistent_HString +{ + template + 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 + { + public: + //! Get referenced ASCII string. + Standard_EXPORT virtual Handle(TCollection_HAsciiString) AsciiString() const; + }; + + class Extended + : public instance + { + public: + //! Get referenced extended string. + Standard_EXPORT virtual Handle(TCollection_HExtendedString) ExtString() const; + }; +}; + +#endif diff --git a/src/StdLPersistent/StdLPersistent_NamedData.cxx b/src/StdLPersistent/StdLPersistent_NamedData.cxx new file mode 100644 index 0000000000..01a68d19fe --- /dev/null +++ b/src/StdLPersistent/StdLPersistent_NamedData.cxx @@ -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 + +#include + +#include +#include +#include +#include +#include +#include + + +//======================================================================= +//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()); +} diff --git a/src/StdLPersistent/StdLPersistent_NamedData.hxx b/src/StdLPersistent/StdLPersistent_NamedData.hxx new file mode 100644 index 0000000000..56d40e2bbc --- /dev/null +++ b/src/StdLPersistent/StdLPersistent_NamedData.hxx @@ -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 +#include +#include + +#include +#include + +class StdLPersistent_NamedData : public StdObjMgt_Attribute +{ + template + class element + { + public: + inline void Read (StdObjMgt_ReadData& theReadData) + { theReadData >> myKeys >> myValues; } + + inline operator bool() const + { return ! myKeys.IsNull(); } + + template + 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 myKeys; + Reference 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 myDimensions; + Object > myInts; + Object > myReals; + Object > myStrings; + Object > myBytes; + Object > myIntArrays; + Object > myRealArrays; +}; + +#endif diff --git a/src/StdLPersistent/StdLPersistent_PColStd_HArray1.hxx b/src/StdLPersistent/StdLPersistent_PColStd_HArray1.hxx deleted file mode 100644 index f1e2c0c37f..0000000000 --- a/src/StdLPersistent/StdLPersistent_PColStd_HArray1.hxx +++ /dev/null @@ -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 - -#include - -#include -#include - -#include - -class StdObjMgt_Persistent; - - -template -class StdLPersistent_PColStd_HArray1 : public StdLPersistent_PColStd_HArray1Base -{ -public: - //! Get the value. - const NCollection_Array1& Array() const { return *myArray; } - -protected: - virtual void CreateArray (const Standard_Integer theLowerBound, - const Standard_Integer theUpperBound) - { - myArray = new NCollection_Array1 (theLowerBound, theUpperBound); - } - - virtual void ReadValue (StdObjMgt_ReadData& theReadData, - const Standard_Integer theIndex) - { - Type aValue; - theReadData >> aValue; - myArray->SetValue (theIndex, aValue); - } - -private: - NCollection_Handle> myArray; -}; - -typedef StdLPersistent_PColStd_HArray1 - StdLPersistent_PColStd_HArray1OfInteger; - -typedef StdLPersistent_PColStd_HArray1 - StdLPersistent_PDF_HAttributeArray1; - -#endif diff --git a/src/StdLPersistent/StdLPersistent_PDataStd_Name.hxx b/src/StdLPersistent/StdLPersistent_Real.hxx similarity index 57% rename from src/StdLPersistent/StdLPersistent_PDataStd_Name.hxx rename to src/StdLPersistent/StdLPersistent_Real.hxx index e0d2d11df3..5cac248878 100644 --- a/src/StdLPersistent/StdLPersistent_PDataStd_Name.hxx +++ b/src/StdLPersistent/StdLPersistent_Real.hxx @@ -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 +#include -class StdLPersistent_PCollection_HExtendedString; +#include +#include -class StdLPersistent_PDataStd_Name : public StdObjMgt_Persistent +class StdLPersistent_Real : public StdObjMgt_Attribute { 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 myValue; + Enum myDimension; }; #endif diff --git a/src/StdLPersistent/StdLPersistent_TreeNode.cxx b/src/StdLPersistent/StdLPersistent_TreeNode.cxx new file mode 100644 index 0000000000..7e45aa6b3d --- /dev/null +++ b/src/StdLPersistent/StdLPersistent_TreeNode.cxx @@ -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 + + +//======================================================================= +//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(); + } +} diff --git a/src/StdLPersistent/StdLPersistent_TreeNode.hxx b/src/StdLPersistent/StdLPersistent_TreeNode.hxx new file mode 100644 index 0000000000..cc4ee2a00a --- /dev/null +++ b/src/StdLPersistent/StdLPersistent_TreeNode.hxx @@ -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 +#include + +#include + + +class StdLPersistent_TreeNode + : public StdObjMgt_Attribute::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 First; + Object TreeID; + }; + + Handle(dynamic) myDynamicData; + Reference myNext; +}; + +#endif diff --git a/src/StdLPersistent/StdLPersistent_Value.cxx b/src/StdLPersistent/StdLPersistent_Value.cxx new file mode 100644 index 0000000000..130ec7a691 --- /dev/null +++ b/src/StdLPersistent/StdLPersistent_Value.cxx @@ -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 + +#include +#include + + +//======================================================================= +//function : ImportAttribute +//purpose : Import transient attribuite from the persistent data +//======================================================================= +template +void StdLPersistent_Value::integer::ImportAttribute() +{ + this->myTransient->Set (this->myData); +} + +//======================================================================= +//function : ImportAttribute +//purpose : Import transient attribuite from the persistent data +//======================================================================= +template +void StdLPersistent_Value::string::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::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::ImportAttribute() +{} + +//======================================================================= +//function : CreateAttribute +//purpose : Create an empty transient attribuite +//======================================================================= +Handle(TDF_Attribute) StdLPersistent_Value::UAttribute::CreateAttribute() +{ + string::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 ; +template class StdLPersistent_Value::integer ; + +template class StdLPersistent_Value::string ; +template class StdLPersistent_Value::string ; +template class StdLPersistent_Value::string ; +template class StdLPersistent_Value::string ; +template class StdLPersistent_Value::string ; diff --git a/src/StdLPersistent/StdLPersistent_Value.hxx b/src/StdLPersistent/StdLPersistent_Value.hxx new file mode 100644 index 0000000000..9bffe45bbb --- /dev/null +++ b/src/StdLPersistent/StdLPersistent_Value.hxx @@ -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 +#include + +#include +#include +#include +#include +#include +#include +#include + + +class StdLPersistent_Value +{ + template + class integer : public StdObjMgt_Attribute::SingleInt + { + public: + //! Import transient attribuite from the persistent data. + Standard_EXPORT virtual void ImportAttribute(); + }; + + template + class string : public StdObjMgt_Attribute::SingleRef + { + public: + //! Import transient attribuite from the persistent data. + Standard_EXPORT virtual void ImportAttribute(); + }; + +public: + typedef integer Integer; + typedef integer TagSource; + + typedef string Reference; + typedef string Name; + typedef string Comment; + typedef string AsciiString; + + class UAttribute : public string + { + public: + //! Create an empty transient attribuite + Standard_EXPORT virtual Handle(TDF_Attribute) CreateAttribute(); + }; +}; + +#endif diff --git a/src/StdLPersistent/StdLPersistent_Variable.hxx b/src/StdLPersistent/StdLPersistent_Variable.hxx new file mode 100644 index 0000000000..2d78212aea --- /dev/null +++ b/src/StdLPersistent/StdLPersistent_Variable.hxx @@ -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 +#include + +#include + + +class StdLPersistent_Variable : public StdObjMgt_Attribute +{ +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 myIsConstant; + Reference myUnit; +}; + +#endif diff --git a/src/StdLPersistent/StdLPersistent_Void.hxx b/src/StdLPersistent/StdLPersistent_Void.hxx new file mode 100644 index 0000000000..5c8ad248fb --- /dev/null +++ b/src/StdLPersistent/StdLPersistent_Void.hxx @@ -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 + +#include +#include +#include + + +class StdLPersistent_Void +{ +protected: + template + class instance : public StdObjMgt_Attribute::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 Directory; + typedef instance Tick; + typedef instance NoteBook; +}; + +#endif diff --git a/src/StdLPersistent/StdLPersistent_XLink.hxx b/src/StdLPersistent/StdLPersistent_XLink.hxx new file mode 100644 index 0000000000..940f6c372c --- /dev/null +++ b/src/StdLPersistent/StdLPersistent_XLink.hxx @@ -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 +#include + +#include + + +class StdLPersistent_XLink : public StdObjMgt_Attribute +{ +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 myDocEntry; + Reference myLabEntry; +}; + +#endif diff --git a/src/StdObjMgt/FILES b/src/StdObjMgt/FILES index 9ac838a3f2..c07fc4bd43 100644 --- a/src/StdObjMgt/FILES +++ b/src/StdObjMgt/FILES @@ -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 diff --git a/src/StdObjMgt/StdObjMgt_Attribute.hxx b/src/StdObjMgt/StdObjMgt_Attribute.hxx new file mode 100644 index 0000000000..897606d343 --- /dev/null +++ b/src/StdObjMgt/StdObjMgt_Attribute.hxx @@ -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 +#include + + +//! Root class for a temporary persistent object corresponding to an attribute. +template +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 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 > {}; + struct SingleRef : Simple > {}; + +private: + template + 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 + static Handle(StdObjMgt_Persistent) Instantiate() + { return new container; } +}; + +#endif // _StdObjMgt_Attribute_HeaderFile diff --git a/src/StdObjMgt/StdObjMgt_ContentTypes.hxx b/src/StdObjMgt/StdObjMgt_ContentTypes.hxx new file mode 100644 index 0000000000..5455fe08fc --- /dev/null +++ b/src/StdObjMgt/StdObjMgt_ContentTypes.hxx @@ -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 + +class StdObjMgt_Persistent; + + +//! Root class for an object containing other obects. +class StdObjMgt_ContentTypes +{ + template + class holder + { + public: + //! Return the value. + operator Type() const { return myValue; } + + protected: + Type myValue; + }; + + template + struct enum_ : holder + { + //! Read the value from a file. + void Read (StdObjMgt_ReadData& theReadData) + { theReadData.ReadEnum (this->myValue); } + }; + + template + struct value : holder + { + //! Read the value from a file. + void Read (StdObjMgt_ReadData& theReadData) + { theReadData.ReadValue (this->myValue); } + }; + + template + struct object : Class + { + //! Read object data from a file. + void Read (StdObjMgt_ReadData& theReadData) + { theReadData.ReadObject ((Class&)*this); } + }; + + template + 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 + bool Cast (Handle(Persistent)& theTarget) const + { + theTarget = Handle(Persistent)::DownCast(*this); + return ! theTarget.IsNull(); + } + }; + +public: + template + struct Enum : StdObjMgt_ReadData::Content > {}; + + template + struct Value : StdObjMgt_ReadData::Content > {}; + + template + struct Object : StdObjMgt_ReadData::Content > {}; + + template + struct Reference : StdObjMgt_ReadData::Content > {}; +}; + +template<> +struct StdObjMgt_ContentTypes::Reference + : StdObjMgt_ReadData::Content {}; + +#endif // _StdObjMgt_ContentTypes_HeaderFile diff --git a/src/StdObjMgt/StdObjMgt_MapOfInstantiators.hxx b/src/StdObjMgt/StdObjMgt_MapOfInstantiators.hxx index 791acdf6c1..87142c0003 100644 --- a/src/StdObjMgt/StdObjMgt_MapOfInstantiators.hxx +++ b/src/StdObjMgt/StdObjMgt_MapOfInstantiators.hxx @@ -25,21 +25,16 @@ class StdObjMgt_MapOfInstantiators TCollection_AsciiString> { public: - template + template void Bind (const TCollection_AsciiString& theTypeName) { NCollection_DataMap - ::Bind (theTypeName, &Instantiate); + ::Bind (theTypeName, Persistent::template Instantiate); } DEFINE_STANDARD_ALLOC - -private: - template - static Handle(StdObjMgt_Persistent) Instantiate() - { return new Type; } }; #endif // _StdObjMgt_MapOfInstantiators_HeaderFile diff --git a/src/StdObjMgt/StdObjMgt_Persistent.cxx b/src/StdObjMgt/StdObjMgt_Persistent.cxx index ad1b42ef71..66901f6526 100644 --- a/src/StdObjMgt/StdObjMgt_Persistent.cxx +++ b/src/StdObjMgt/StdObjMgt_Persistent.cxx @@ -13,13 +13,65 @@ #include + +//======================================================================= +//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) +//======================================================================= +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) //======================================================================= -Handle(TDF_Attribute) StdObjMgt_Persistent::ImportAttribute() const -{ - return Handle(TDF_Attribute)(); -} +TDF_Label StdObjMgt_Persistent::Label (const Handle(TDF_Data)&) const + { return TDF_Label(); } diff --git a/src/StdObjMgt/StdObjMgt_Persistent.hxx b/src/StdObjMgt/StdObjMgt_Persistent.hxx index 87f06e573b..5c7f68f3d8 100644 --- a/src/StdObjMgt/StdObjMgt_Persistent.hxx +++ b/src/StdObjMgt/StdObjMgt_Persistent.hxx @@ -18,26 +18,70 @@ #include #include #include +#include + +#include 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 + 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 diff --git a/src/StdObjMgt/StdObjMgt_ReadData.cxx b/src/StdObjMgt/StdObjMgt_ReadData.cxx index c6636004d3..99472cbdbc 100644 --- a/src/StdObjMgt/StdObjMgt_ReadData.cxx +++ b/src/StdObjMgt/StdObjMgt_ReadData.cxx @@ -12,20 +12,30 @@ // commercial license or contractual agreement. #include +#include -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; } diff --git a/src/StdObjMgt/StdObjMgt_ReadData.hxx b/src/StdObjMgt/StdObjMgt_ReadData.hxx index 09b2ee8b33..b952ba06a0 100644 --- a/src/StdObjMgt/StdObjMgt_ReadData.hxx +++ b/src/StdObjMgt/StdObjMgt_ReadData.hxx @@ -15,43 +15,69 @@ #define _StdObjMgt_ReadData_HeaderFile #include -#include -#include #include +#include +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 + 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 + void ReadReference (Handle(Persistent)& theTarget) + { + theTarget = Handle(Persistent)::DownCast (ReadReference()); + } + + template + void ReadObject (Object& theObject) + { + myDriver->BeginReadObjectData(); + theObject.Read (*this); + myDriver->EndReadObjectData(); + } + template - StdObjMgt_ReadData& operator >> (Type& aValue) + void ReadValue (Type& theValue) { - *myDriver >> aValue; - return *this; + *myDriver >> theValue; } template - StdObjMgt_ReadData& operator >> (Handle(Type)& theTarget) + void ReadEnum (Type& theEnum) + { + Standard_Integer aValue; + *myDriver >> aValue; + theEnum = static_cast (aValue); + } + + template struct Content : Base {}; + + template + StdObjMgt_ReadData& operator >> (Content& theContent) { - Handle(StdObjMgt_Persistent) aTarget = theTarget; - ReadReference (aTarget); - theTarget = dynamic_cast (aTarget.get()); + theContent.Read (*this); return *this; } diff --git a/src/StdObjMgt/StdObjMgt_SharedObject.hxx b/src/StdObjMgt/StdObjMgt_SharedObject.hxx new file mode 100644 index 0000000000..d2b8998387 --- /dev/null +++ b/src/StdObjMgt/StdObjMgt_SharedObject.hxx @@ -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 + + +class StdObjMgt_SharedObject +{ +public: + class PersistentBase : public Standard_Transient, + protected StdObjMgt_ContentTypes {}; + + template + class AbstractPersistentBase : public PersistentBase + { + public: + virtual Handle(Transient) Import() const = 0; + }; + + template + 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 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 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 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 Delayed : public delayedSubBase + { + 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 diff --git a/src/StdObject/FILES b/src/StdObject/FILES new file mode 100644 index 0000000000..3fe5d9780c --- /dev/null +++ b/src/StdObject/FILES @@ -0,0 +1,5 @@ +StdObject_gp.hxx +StdObject_Location.cxx +StdObject_Location.hxx +StdObject_Shape.cxx +StdObject_Shape.hxx diff --git a/src/StdObject/StdObject_Location.cxx b/src/StdObject/StdObject_Location.cxx new file mode 100644 index 0000000000..3515b5b9db --- /dev/null +++ b/src/StdObject/StdObject_Location.cxx @@ -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 +#include + + +//======================================================================= +//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(); +} diff --git a/src/StdLPersistent/StdLPersistent_PDataStd_Integer.hxx b/src/StdObject/StdObject_Location.hxx similarity index 61% rename from src/StdLPersistent/StdLPersistent_PDataStd_Integer.hxx rename to src/StdObject/StdObject_Location.hxx index 7dd29030b8..9bfa7aa0af 100644 --- a/src/StdLPersistent/StdLPersistent_PDataStd_Integer.hxx +++ b/src/StdObject/StdObject_Location.hxx @@ -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 +#include +#include -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 diff --git a/src/StdLPersistent/StdLPersistent_PCollection_HExtendedString.cxx b/src/StdObject/StdObject_Shape.cxx similarity index 58% rename from src/StdLPersistent/StdLPersistent_PCollection_HExtendedString.cxx rename to src/StdObject/StdObject_Shape.cxx index 5f2dfd52e7..e8c85f94fa 100644 --- a/src/StdLPersistent/StdLPersistent_PCollection_HExtendedString.cxx +++ b/src/StdObject/StdObject_Shape.cxx @@ -11,30 +11,23 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. -#include - +#include #include -#include //======================================================================= -//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; } diff --git a/src/StdObject/StdObject_Shape.hxx b/src/StdObject/StdObject_Shape.hxx new file mode 100644 index 0000000000..2a57fd7b9b --- /dev/null +++ b/src/StdObject/StdObject_Shape.hxx @@ -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 +#include +#include + +#include +#include + + +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 myTShape; + Object myLocation; + Enum myOrient; +}; + +#endif diff --git a/src/StdObject/StdObject_gp.hxx b/src/StdObject/StdObject_gp.hxx new file mode 100644 index 0000000000..2d5c272742 --- /dev/null +++ b/src/StdObject/StdObject_gp.hxx @@ -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 + +class StdObject_gp : private StdObjMgt_ContentTypes +{ + template + struct object : Data + { Standard_EXPORT void Read (StdObjMgt_ReadData& theReadData); }; + +public: + template + struct Object : StdObjMgt_ContentTypes::Object > {}; + + template + static Object& Ref (Data& theData) + { return static_cast&> (theData); } +}; + +// read vectors + +#include +#include +#include +#include +#include +#include + +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 +#include +#include +#include +#include + +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 +#include +#include +#include +#include +#include +#include +#include +#include +#include + +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 +#include +#include +#include + +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 +#include +#include +#include + +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 +inline void StdObject_gp::object::Read (StdObjMgt_ReadData& theReadData) +{ + theReadData >> (*this); +} + + +#endif diff --git a/src/StdPersistent/FILES b/src/StdPersistent/FILES index e60a9fa4df..5a716b7cc1 100644 --- a/src/StdPersistent/FILES +++ b/src/StdPersistent/FILES @@ -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 diff --git a/src/StdPersistent/StdPersistent.cxx b/src/StdPersistent/StdPersistent.cxx index 783a9571fb..94cd3c5714 100644 --- a/src/StdPersistent/StdPersistent.cxx +++ b/src/StdPersistent/StdPersistent.cxx @@ -14,10 +14,54 @@ #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + //======================================================================= //function : BindTypes //purpose : Register types //======================================================================= -void StdPersistent::BindTypes (StdObjMgt_MapOfInstantiators& /*theMap*/) +void StdPersistent::BindTypes (StdObjMgt_MapOfInstantiators& theMap) { + // Non-attribute data + theMap.Bind ("PTopLoc_Datum3D"); + theMap.Bind ("PTopLoc_ItemLocation"); + theMap.Bind ("PTopoDS_TShape1"); + theMap.Bind ("PTopoDS_HArray1OfShape1"); + theMap.Bind ("PNaming_Name"); + theMap.Bind ("PNaming_Name_1"); + theMap.Bind ("PNaming_Name_2"); + + theMap.Bind + ("PNaming_HArray1OfNamedShape"); + + // Attributes + theMap.Bind ("PNaming_NamedShape"); + theMap.Bind ("PNaming_Naming"); + theMap.Bind ("PNaming_Naming_1"); + theMap.Bind ("PNaming_Naming_2"); + + theMap.Bind ("PDataXtd_Shape"); + theMap.Bind ("PDataXtd_Point"); + theMap.Bind ("PDataXtd_Axis"); + theMap.Bind ("PDataXtd_Plane"); + theMap.Bind ("PDataXtd_Placement"); + theMap.Bind ("PDataXtd_Geometry"); + theMap.Bind ("PDataXtd_Position"); + theMap.Bind ("PDataXtd_Constraint"); + theMap.Bind ("PDataXtd_PatternStd"); + + theMap.Bind + ("PPrsStd_AISPresentation"); + + theMap.Bind + ("PPrsStd_AISPresentation_1"); } diff --git a/src/StdLPersistent/StdLPersistent_PDataStd_Integer.cxx b/src/StdPersistent/StdPersistent_DataXtd.cxx similarity index 68% rename from src/StdLPersistent/StdLPersistent_PDataStd_Integer.cxx rename to src/StdPersistent/StdPersistent_DataXtd.cxx index 2203e3153f..40d5479bee 100644 --- a/src/StdLPersistent/StdLPersistent_PDataStd_Integer.cxx +++ b/src/StdPersistent/StdPersistent_DataXtd.cxx @@ -11,28 +11,19 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. -#include +#include -#include - -#include //======================================================================= -//function : Read -//purpose : Read persistent data from a file +//function : ImportAttribute +//purpose : Import transient attribuite from the persistent data //======================================================================= -void StdLPersistent_PDataStd_Integer::Read (StdObjMgt_ReadData& theReadData) -{ - theReadData >> myValue; -} +void StdPersistent_DataXtd::Geometry::ImportAttribute() + { myTransient->SetType (myData); } //======================================================================= //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::Position::ImportAttribute() + { myTransient->SetPosition (myData); } diff --git a/src/StdPersistent/StdPersistent_DataXtd.hxx b/src/StdPersistent/StdPersistent_DataXtd.hxx new file mode 100644 index 0000000000..376d064f81 --- /dev/null +++ b/src/StdPersistent/StdPersistent_DataXtd.hxx @@ -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 +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + + +class StdPersistent_DataXtd : private StdObjMgt_ContentTypes +{ + class _void : private StdLPersistent_Void + { + public: + template + struct Instance : instance {}; + }; + +public: + typedef _void::Instance Shape; + typedef _void::Instance Point; + typedef _void::Instance Axis; + typedef _void::Instance Plane; + typedef _void::Instance Placement; + + class Geometry : public StdObjMgt_Attribute:: + Simple > + { + public: + //! Import transient attribuite from the persistent data. + Standard_EXPORT virtual void ImportAttribute(); + }; + + class Position : public StdObjMgt_Attribute:: + Simple > + { + public: + //! Import transient attribuite from the persistent data. + Standard_EXPORT virtual void ImportAttribute(); + }; +}; + +#endif diff --git a/src/StdPersistent/StdPersistent_DataXtd_Constraint.cxx b/src/StdPersistent/StdPersistent_DataXtd_Constraint.cxx new file mode 100644 index 0000000000..e5437edb50 --- /dev/null +++ b/src/StdPersistent/StdPersistent_DataXtd_Constraint.cxx @@ -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 + +#include +#include + + +//======================================================================= +//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)); + } +} diff --git a/src/StdPersistent/StdPersistent_DataXtd_Constraint.hxx b/src/StdPersistent/StdPersistent_DataXtd_Constraint.hxx new file mode 100644 index 0000000000..8302ff35ab --- /dev/null +++ b/src/StdPersistent/StdPersistent_DataXtd_Constraint.hxx @@ -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 +#include + +#include +#include + + +class StdPersistent_DataXtd_Constraint + : public StdObjMgt_Attribute +{ +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 myType; + Reference myGeometries; + Reference<> myValue; + Value myIsReversed; + Value myIsInverted; + Value myIsVerified; + Reference<> myPlane; +}; + +#endif diff --git a/src/StdPersistent/StdPersistent_DataXtd_PatternStd.cxx b/src/StdPersistent/StdPersistent_DataXtd_PatternStd.cxx new file mode 100644 index 0000000000..4a556f261e --- /dev/null +++ b/src/StdPersistent/StdPersistent_DataXtd_PatternStd.cxx @@ -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 + +#include +#include +#include + + +//======================================================================= +//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())); + } +} diff --git a/src/StdPersistent/StdPersistent_DataXtd_PatternStd.hxx b/src/StdPersistent/StdPersistent_DataXtd_PatternStd.hxx new file mode 100644 index 0000000000..f0a8893374 --- /dev/null +++ b/src/StdPersistent/StdPersistent_DataXtd_PatternStd.hxx @@ -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 + +#include + + +class StdPersistent_DataXtd_PatternStd + : public StdObjMgt_Attribute +{ +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 mySignature; + Value myAxis1Reversed; + Value myAxis2Reversed; + Reference<> myAxis1; + Reference<> myAxis2; + Reference<> myValue1; + Reference<> myValue2; + Reference<> myNb1; + Reference<> myNb2; + Reference<> myMirror; +}; + +#endif diff --git a/src/StdPersistent/StdPersistent_HArray1.cxx b/src/StdPersistent/StdPersistent_HArray1.cxx new file mode 100644 index 0000000000..957c7c2150 --- /dev/null +++ b/src/StdPersistent/StdPersistent_HArray1.cxx @@ -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 +#include + + +void StdPersistent_HArray1::Shape1::readValue (StdObjMgt_ReadData& theReadData, + const Standard_Integer theIndex) +{ + theReadData.ReadObject (myArray->ChangeValue (theIndex)); +} diff --git a/src/StdPersistent/StdPersistent_HArray1.hxx b/src/StdPersistent/StdPersistent_HArray1.hxx new file mode 100644 index 0000000000..cd0cf96a4c --- /dev/null +++ b/src/StdPersistent/StdPersistent_HArray1.hxx @@ -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 +#include + + +class StdPersistent_HArray1 : private StdLPersistent_HArray1 +{ +public: + class Shape1 : public StdLPersistent_HArray1::base + { + virtual void readValue (StdObjMgt_ReadData& theReadData, + const Standard_Integer theIndex); + }; +}; + +#endif diff --git a/src/StdPersistent/StdPersistent_HArray1OfShape1.hxx b/src/StdPersistent/StdPersistent_HArray1OfShape1.hxx new file mode 100644 index 0000000000..31940e74f4 --- /dev/null +++ b/src/StdPersistent/StdPersistent_HArray1OfShape1.hxx @@ -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 +#include + +DEFINE_HARRAY1 (StdPersistent_HArray1OfShape1, NCollection_Array1) + +#endif // _StdPersistent_HArray1OfShape1_HeaderFile diff --git a/src/StdPersistent/StdPersistent_Naming.cxx b/src/StdPersistent/StdPersistent_Naming.cxx new file mode 100644 index 0000000000..d239a8309b --- /dev/null +++ b/src/StdPersistent/StdPersistent_Naming.cxx @@ -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 +#include + +#include +#include +#include + + +//======================================================================= +//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()); + } + } + } +} diff --git a/src/StdPersistent/StdPersistent_Naming.hxx b/src/StdPersistent/StdPersistent_Naming.hxx new file mode 100644 index 0000000000..90c2cfe9a1 --- /dev/null +++ b/src/StdPersistent/StdPersistent_Naming.hxx @@ -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 +#include +#include +#include +#include + +#include +#include + +#include + +#include +#include + +class TNaming_Name; + + +class StdPersistent_Naming +{ +public: + class NamedShape : public StdObjMgt_Attribute + { + 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 myOldShapes; + Reference myNewShapes; + Value myShapeStatus; + Value 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 myType; + Enum myShapeType; + Reference myArgs; + Reference<> myStop; + Value 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 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 myOrientation; + }; + + class Naming : public StdObjMgt_Attribute::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 diff --git a/src/StdPersistent/StdPersistent_PPrsStd.cxx b/src/StdPersistent/StdPersistent_PPrsStd.cxx new file mode 100644 index 0000000000..986eabda37 --- /dev/null +++ b/src/StdPersistent/StdPersistent_PPrsStd.cxx @@ -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 + + +//======================================================================= +//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 ((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); +} diff --git a/src/StdPersistent/StdPersistent_PPrsStd.hxx b/src/StdPersistent/StdPersistent_PPrsStd.hxx new file mode 100644 index 0000000000..b2887326f9 --- /dev/null +++ b/src/StdPersistent/StdPersistent_PPrsStd.hxx @@ -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 +#include + +#include + +class StdPersistent_PPrsStd +{ +public: + class AISPresentation : public StdObjMgt_Attribute + { + 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 myIsDisplayed; + Reference<> myDriverGUID; + Value myTransparency; + Value myColor; + Value myMaterial; + Value 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 myMode; + }; +}; + +#endif diff --git a/src/StdPersistent/StdPersistent_TopLoc.cxx b/src/StdPersistent/StdPersistent_TopLoc.cxx new file mode 100644 index 0000000000..00ffcda8aa --- /dev/null +++ b/src/StdPersistent/StdPersistent_TopLoc.cxx @@ -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 +#include +#include + +#include + + +//======================================================================= +//function : Read +//purpose : Read persistent data from a file +//======================================================================= +void StdPersistent_TopLoc::Datum3D::Read (StdObjMgt_ReadData& theReadData) +{ + StdObject_gp::Object 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; +} diff --git a/src/StdPersistent/StdPersistent_TopLoc.hxx b/src/StdPersistent/StdPersistent_TopLoc.hxx new file mode 100644 index 0000000000..891921f5d1 --- /dev/null +++ b/src/StdPersistent/StdPersistent_TopLoc.hxx @@ -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 +#include +#include + +#include +#include + + +class StdPersistent_TopLoc +{ +public: + class Datum3D : public StdObjMgt_SharedObject::SharedBase + { + 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 myDatum; + Value myPower; + Object myNext; + }; +}; + +#endif diff --git a/src/StdLPersistent/StdLPersistent_PColStd_HArray1Base.hxx b/src/StdPersistent/StdPersistent_TopoDS.hxx similarity index 53% rename from src/StdLPersistent/StdLPersistent_PColStd_HArray1Base.hxx rename to src/StdPersistent/StdPersistent_TopoDS.hxx index cf1cdf51e2..5fc3d80eaa 100644 --- a/src/StdLPersistent/StdLPersistent_PColStd_HArray1Base.hxx +++ b/src/StdPersistent/StdPersistent_TopoDS.hxx @@ -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 +#include +#include +#include -class StdLPersistent_PColStd_HArray1Base : public StdObjMgt_Persistent -{ -public: - //! Read persistent data from a file. - Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData); +class StdPersistent_TopoDS : protected StdObjMgt_SharedObject +{ 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 myFlags; + }; + +public: + typedef IgnoreData TShape; }; #endif diff --git a/src/TKShape/CMakeLists.txt b/src/TKShape/CMakeLists.txt deleted file mode 100644 index 51ec161be1..0000000000 --- a/src/TKShape/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -project(TKShape) - -OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit) diff --git a/src/TKShape/EXTERNLIB b/src/TKShape/EXTERNLIB deleted file mode 100644 index 6d653e133d..0000000000 --- a/src/TKShape/EXTERNLIB +++ /dev/null @@ -1,4 +0,0 @@ -TKernel -TKG2d -TKMath -TKCDF diff --git a/src/TKShape/FILES b/src/TKShape/FILES deleted file mode 100644 index c999897bf1..0000000000 --- a/src/TKShape/FILES +++ /dev/null @@ -1,2 +0,0 @@ -PACKAGES -EXTERNLIB diff --git a/src/TKShape/PACKAGES b/src/TKShape/PACKAGES deleted file mode 100644 index 78502df69d..0000000000 --- a/src/TKShape/PACKAGES +++ /dev/null @@ -1 +0,0 @@ -ShapePersistent diff --git a/src/TKStd/EXTERNLIB b/src/TKStd/EXTERNLIB index 4ff518ab88..605da78e45 100644 --- a/src/TKStd/EXTERNLIB +++ b/src/TKStd/EXTERNLIB @@ -1,9 +1,9 @@ -TKCDF TKernel +TKCDF TKCAF -TKShape TKLCAF -TKStdL -TKG3d +TKBRep TKMath TKG2d +TKG3d +TKStdL diff --git a/src/TKStd/PACKAGES b/src/TKStd/PACKAGES index c6bcead911..1fbe61e464 100644 --- a/src/TKStd/PACKAGES +++ b/src/TKStd/PACKAGES @@ -1,2 +1,4 @@ StdDrivers +StdObject StdPersistent +ShapePersistent diff --git a/src/TKStdL/EXTERNLIB b/src/TKStdL/EXTERNLIB index fad76526d3..cd1b434a34 100644 --- a/src/TKStdL/EXTERNLIB +++ b/src/TKStdL/EXTERNLIB @@ -1,4 +1,3 @@ -TKCDF TKernel -TKShape +TKCDF TKLCAF diff --git a/src/TKStdL/PACKAGES b/src/TKStdL/PACKAGES index 893f13689c..6d5a70e0fa 100644 --- a/src/TKStdL/PACKAGES +++ b/src/TKStdL/PACKAGES @@ -1,3 +1,4 @@ StdLDrivers +StdLObject StdLPersistent StdObjMgt diff --git a/tests/bugs/caf/buc60756_std b/tests/bugs/caf/buc60756_std new file mode 100644 index 0000000000..3091dc365c --- /dev/null +++ b/tests/bugs/caf/buc60756_std @@ -0,0 +1,17 @@ +puts "===========" +puts "BUC60756" +puts "BUC60761" +puts "BUC60762" +puts "BUC60764" +puts "===========" + +Open [locate_data_file BUC60756_Doc.std] D + +###################################################################### +catch {file delete ${imagedir}/Doc2.cbf} + +Format D BinOcaf +SaveAs D ${imagedir}/Doc2.cbf +Close D +Open ${imagedir}/Doc2.cbf D + diff --git a/tests/bugs/caf/buc60867_std b/tests/bugs/caf/buc60867_std new file mode 100644 index 0000000000..7fc9a65c33 --- /dev/null +++ b/tests/bugs/caf/buc60867_std @@ -0,0 +1,12 @@ +puts "===========" +puts "BUC60867" +puts "===========" + +pload QAcommands + +set ResultError [ BUC60867 [locate_data_file BUC60756_Doc.std] ] + +if { [regexp "0" $ResultError] != 1 } { + puts "Error : 1" +} + diff --git a/tests/bugs/caf/bug1454_std b/tests/bugs/caf/bug1454_std new file mode 100644 index 0000000000..8464ff1367 --- /dev/null +++ b/tests/bugs/caf/bug1454_std @@ -0,0 +1,34 @@ + +puts "===== OCC1454 =====" +####################################################################################### +# Improve performance of TDF_Label::FindChild +####################################################################################### + +puts "Info: Open the document with 80000 sublabels of the label 0:2" +dchrono h reset +dchrono h start +Open [locate_data_file OCC1726.std] D +dchrono h stop +set TimeList [dchrono h show] + +regexp {Elapsed time: [-0-9.+eE]+ Hours ([-0-9.+eE]+) Minutes ([-0-9.+eE]+) Seconds} $TimeList full ElapsedTime_min ElapsedTime_sec +regexp {CPU user time: ([-0-9.+eE]+) seconds} $TimeList full CPUusertime +regexp {CPU system time: ([-0-9.+eE]+) seconds} $TimeList full CPUsystemtime + +puts "ElapsedTime = ${ElapsedTime_min} min ${ElapsedTime_sec} sec CPUusertime = ${CPUusertime} CPUsystemtime = ${CPUsystemtime}" + +if { ${ElapsedTime_sec} > 20.0 || ${ElapsedTime_min} != 0 } { + puts "Elapsed time is more then 20.0 seconds - Faulty" + puts "Faulty OCC1454" +} elseif { ${CPUusertime} > 12 } { + puts "CPUusertime is more then 12 seconds - Faulty" + puts "Faulty OCC1454" +} elseif { ${CPUsystemtime} > 0.6 } { + puts "CPUsystemtime is more then 0.6 seconds" + puts "Faulty OCC1454" +} else { + puts "Elapsed time is less then 20 seconds - OK" + puts "CPU user time is less then 12 seconds - OK" + puts "CPU system time is less then 0.6 seconds - OK" + puts "OK for OCC1454" +} diff --git a/tests/bugs/caf/bug1726_std b/tests/bugs/caf/bug1726_std new file mode 100644 index 0000000000..828829c878 --- /dev/null +++ b/tests/bugs/caf/bug1726_std @@ -0,0 +1,26 @@ +puts "================" +puts "OCC1726" +puts "================" +puts "" +####################################################################################### +# TDF_LabelNode::~TDF_LabelNode causes stack overflow +####################################################################################### + +puts "Info: Open the document with 80000 sublabels of the label 0:2" +chrono h reset; chrono h start +Open [locate_data_file OCC1726.std] D +chrono h stop; chrono h show + +set IsGood 1 +puts "Info: Close the document" +chrono h reset; chrono h start +if [catch {Close D} result] { + set IsGood 0 +} +chrono h stop; chrono h show + +if { ${IsGood} == 0} { + puts "Faulty OCC1726" +} else { + puts "OK OCC1726" +} diff --git a/tests/bugs/caf/bug22788_1_std b/tests/bugs/caf/bug22788_1_std new file mode 100644 index 0000000000..9bbfbfdfd2 --- /dev/null +++ b/tests/bugs/caf/bug22788_1_std @@ -0,0 +1,41 @@ +puts "============" +puts "OCC22788" +puts "============" +puts "" +####################################################################### +# +####################################################################### + +pload QAcommands + +set BugNumber OCC22788 + +NewDocument D MDTV-Standard + +set aFile OCC22788.std + +Open [locate_data_file ${aFile}] D + +Close D + +return + +set log [OCC159 D] + +set list [split ${log}] +set ll [llength ${list}] + +if { ${ll} < 13 } { + puts "OCC159: Error" +} else { + set DocRefCount1 [lindex ${list} 2] + set DocOwner1 [lindex ${list} 5] + set DocOwner2 [lindex ${list} 8] + set DocRefCount2 [lindex ${list} 11] + set deltaRefCount [expr ${DocRefCount1} - ${DocRefCount2}] + if { ${DocOwner2} == "NULL" && ${deltaRefCount} >= 1 } then { + puts "OCC159: OK" + } else { + puts "OCC159: Error" + } +} diff --git a/tests/bugs/caf/bug22788_2_std b/tests/bugs/caf/bug22788_2_std new file mode 100644 index 0000000000..da36cfd707 --- /dev/null +++ b/tests/bugs/caf/bug22788_2_std @@ -0,0 +1,32 @@ +puts "================" +puts "OCC22788" +puts "================" +puts "" +####################################################################################### +# Exception during closing of document due to corrupted memory. +###################################################################################### + +set BugNumber OCC22788 + +set aFile [locate_data_file OCC22788.std] + +Open ${aFile} D + +GetShape D 0:2 result +smallview +fit + +set catch_status 0 +if { [catch {Close D} catch_result] } { + set catch_status 1 +} + +if { ${catch_status} != 0 } { + puts "Faulty ${BugNumber}" +} else { + puts "OK ${BugNumber}" +} + +checkprops result -s 220000 +checkshape result +set 2dviewer 0 diff --git a/tests/bugs/caf/bug23766_2 b/tests/bugs/caf/bug23766_2 index 3fd43f60fc..65245b3eac 100755 --- a/tests/bugs/caf/bug23766_2 +++ b/tests/bugs/caf/bug23766_2 @@ -8,7 +8,7 @@ puts "" # test to check compatibility of old std format -Open [locate_data_file bug23766_ttt1_old.cbf] D +Open [locate_data_file bug23766_ttt1_old.std] D GetShape D 0:1:2:1:2 E1 set info1 [whatis E1] diff --git a/tests/bugs/caf/bug5023_std b/tests/bugs/caf/bug5023_std new file mode 100644 index 0000000000..4f255adf8d --- /dev/null +++ b/tests/bugs/caf/bug5023_std @@ -0,0 +1,39 @@ +puts "================" +puts "OCC5023" +puts "================" +puts "" +###################################################### +# Performance regression in opening OCAF file +###################################################### + +set aFile [locate_data_file OCC5023.std] + +puts "Info: Restore the document" + +if [info exists DD] { + catch {Close DD}; unset DD +} + +dchrono h reset +dchrono h start + +Open ${aFile} DD +dchrono h stop +set list [dchrono h show] +Close DD + +regexp {CPU user time: +([-0-9.+eE]+)} $list full CPU_user_time + +set Good_CPU_user_time 2. + +set CPU_user_time_percent [expr (${CPU_user_time} - ${Good_CPU_user_time}) / ${Good_CPU_user_time} * 100.] +set percent_max 0.1 + +puts "CPU_user_time = ${CPU_user_time}" +puts "Good_CPU_user_time = ${Good_CPU_user_time}" +puts "CPU_user_time_percent = ${CPU_user_time_percent}" + +if {${CPU_user_time_percent} > ${percent_max}} { + puts "Faulty OCC5023 : CPU user time is wrong" +} + diff --git a/tests/bugs/modalg_5/bug24849_1_std b/tests/bugs/modalg_5/bug24849_1_std new file mode 100644 index 0000000000..d80d339b2e --- /dev/null +++ b/tests/bugs/modalg_5/bug24849_1_std @@ -0,0 +1,21 @@ +puts "================" +puts "CR24849" +puts "================" +puts "" +############################################### +## Crash on Pipe creation +############################################### + +pload DCAF + +Open [locate_data_file bug24849_Study1_GEOM.sgd] D + +GetShape D 0:1:465:1:1:2 f +GetShape D 0:1:283:1:1:2 w +explode w e +wire ww w_1 + +pipe result ww f 2 + +checknbshapes result -vertex 4 -edge 8 -wire 7 -face 7 -shell 2 -solid 2 -compsolid 0 -compound 1 -shape 31 +set 2dviewer 1 diff --git a/tests/bugs/modalg_5/bug24849_2_std b/tests/bugs/modalg_5/bug24849_2_std new file mode 100644 index 0000000000..4f25d48b37 --- /dev/null +++ b/tests/bugs/modalg_5/bug24849_2_std @@ -0,0 +1,21 @@ +puts "================" +puts "CR24849" +puts "================" +puts "" +############################################### +## Crash on Pipe creation +############################################### + +pload DCAF + +Open [locate_data_file bug24849_Study1_GEOM.sgd] D + +GetShape D 0:1:465:1:1:2 f +GetShape D 0:1:283:1:1:2 w +explode w e +wire ww w_2 + +pipe result ww f 2 + +checknbshapes result -vertex 4 -edge 8 -wire 7 -face 7 -shell 2 -solid 2 -compsolid 0 -compound 1 -shape 31 +set 2dviewer 1 diff --git a/tests/bugs/modalg_5/bug25969_std b/tests/bugs/modalg_5/bug25969_std new file mode 100644 index 0000000000..a67278601f --- /dev/null +++ b/tests/bugs/modalg_5/bug25969_std @@ -0,0 +1,37 @@ +puts "================" +puts "CR25969" +puts "================" +puts "" +############################################### +## Wrong result obtained by 2d classifier algorithm. +############################################### + +pload DCAF + +Open [locate_data_file bug25969_pal22851.sgd] D + +GetShape D 0:1:15:1:1:2 b1 +GetShape D 0:1:29:1:1:2 b2 + +explode b1 +explode b2 + +bop b1_2 b2_1 +bopcut r + +explode r f +copy r_4 f +pcurve f + +point p 12.658283198213592 21.045164979270297 + +set cls1 [b2dclassifx f p] +if { [regexp {OUT} $cls1] } { + puts "Error : Wrong result of 2d classifier algorithm" +} else { + puts "OK : Good result of 2d classifier algorithm" +} + +smallview +fit +set only_screen_axo 1 diff --git a/tests/bugs/moddata_3/bug23733_std b/tests/bugs/moddata_3/bug23733_std new file mode 100644 index 0000000000..e80fd46c2c --- /dev/null +++ b/tests/bugs/moddata_3/bug23733_std @@ -0,0 +1,40 @@ +puts "================" +puts "CR23733" +puts "================" +puts "" +############################################### +## PCurve for edge on face creation failure +############################################### + +pload DCAF TOPTEST + +Open [locate_data_file bug_glue_edges_GEOM.sgd] D + +GetShape D 0:1:9686:1:1:2 s1 +GetShape D 0:1:9449:1:1:2 s2 +explode s1 e +explode s2 f + +#should create pcurve +bhaspc s1_100 s2_2 do +#should report OK +set info1 [bhaspc s1_100 s2_2] +if { [regexp {No} ${info1}] == 1 } { + puts "Faulty: No 2D curves detected" +} + +#should create pcurve +bhaspc s1_40 s2_54 do +#should report OK +set info2 [bhaspc s1_40 s2_54] +if { [regexp {No} ${info2}] == 1 } { + puts "Faulty: No 2D curves detected" +} + +#should create pcurve +bhaspc s1_22 s2_123 do +#should report OK +set info3 [bhaspc s1_22 s2_123] +if { [regexp {No} ${info3}] == 1 } { + puts "Faulty: No 2D curves detected" +} -- 2.20.1