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

0028564: Support of applications using old persistence (ShapeSchema)

1. Bug fix in reading old persistent data using FSD_File storage driver
2. Persistence compatible with legacy format was restored for shapes
   a. Implemented a storage read / write wrapper for legacy persistence
   b. Added DRAW commands to read / write files in legacy format
   c. Added test cases for reading / writing operations with checking number of sub-shapes and physical properties
   d. Updated related sections of the development guide
This commit is contained in:
snn
2017-03-28 17:13:04 +03:00
committed by bugmaster
parent 632175c3a8
commit ec96437207
124 changed files with 7813 additions and 128 deletions

View File

@@ -9,6 +9,7 @@ ShapePersistent_Geom_Curve.hxx
ShapePersistent_Geom_Surface.cxx
ShapePersistent_Geom_Surface.hxx
ShapePersistent_Geom2d.hxx
ShapePersistent_Geom2d.cxx
ShapePersistent_Geom2d_Curve.cxx
ShapePersistent_Geom2d_Curve.hxx
ShapePersistent_HArray1.hxx
@@ -19,3 +20,4 @@ ShapePersistent_Poly.cxx
ShapePersistent_Poly.hxx
ShapePersistent_TopoDS.cxx
ShapePersistent_TopoDS.hxx
ShapePersistent_TriangleMode.hxx

View File

@@ -11,6 +11,8 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <Standard_NullObject.hxx>
#include <ShapePersistent_BRep.hxx>
#include <BRep_PointOnCurve.hxx>
@@ -30,6 +32,16 @@
#include <BRep_TEdge.hxx>
#include <BRep_TFace.hxx>
#include <Geom_Surface.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Face.hxx>
#include <Poly_Polygon2D.hxx>
#include <Poly_Polygon3D.hxx>
#include <Poly_PolygonOnTriangulation.hxx>
#include <Poly_Triangulation.hxx>
enum
{
@@ -40,17 +52,23 @@ enum
//=======================================================================
//function : Read
//purpose : Read persistent data from a file
// PointRepresentation
//=======================================================================
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::Write
(StdObjMgt_WriteData& theWriteData) const
{ theWriteData << myLocation << myParameter << myNext; }
void ShapePersistent_BRep::PointRepresentation::PChildren
(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
{
myLocation.PChildren(theChildren);
theChildren.Append(myNext);
}
void ShapePersistent_BRep::PointRepresentation::Import
(BRep_ListOfPointRepresentation& thePoints) const
{
@@ -64,6 +82,9 @@ Handle(BRep_PointRepresentation)
ShapePersistent_BRep::PointRepresentation::import() const
{ return NULL; }
//=======================================================================
// PointOnCurve
//=======================================================================
void ShapePersistent_BRep::PointOnCurve::Read
(StdObjMgt_ReadData& theReadData)
{
@@ -71,6 +92,20 @@ void ShapePersistent_BRep::PointOnCurve::Read
theReadData >> myCurve;
}
void ShapePersistent_BRep::PointOnCurve::Write
(StdObjMgt_WriteData& theWriteData) const
{
PointRepresentation::Write (theWriteData);
theWriteData << myCurve;
}
void ShapePersistent_BRep::PointOnCurve::PChildren
(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
{
PointRepresentation::PChildren(theChildren);
theChildren.Append(myCurve);
}
Handle(BRep_PointRepresentation)
ShapePersistent_BRep::PointOnCurve::import() const
{
@@ -82,6 +117,9 @@ Handle(BRep_PointRepresentation)
(myParameter, aCurve, myLocation.Import());
}
//=======================================================================
// PointsOnSurface
//=======================================================================
void ShapePersistent_BRep::PointsOnSurface::Read
(StdObjMgt_ReadData& theReadData)
{
@@ -89,6 +127,23 @@ void ShapePersistent_BRep::PointsOnSurface::Read
theReadData >> mySurface;
}
void ShapePersistent_BRep::PointsOnSurface::Write
(StdObjMgt_WriteData& theWriteData) const
{
PointRepresentation::Write (theWriteData);
theWriteData << mySurface;
}
void ShapePersistent_BRep::PointsOnSurface::PChildren
(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
{
PointRepresentation::PChildren(theChildren);
theChildren.Append(mySurface);
}
//=======================================================================
// PointOnCurveOnSurface
//=======================================================================
void ShapePersistent_BRep::PointOnCurveOnSurface::Read
(StdObjMgt_ReadData& theReadData)
{
@@ -96,6 +151,20 @@ void ShapePersistent_BRep::PointOnCurveOnSurface::Read
theReadData >> myPCurve;
}
void ShapePersistent_BRep::PointOnCurveOnSurface::Write
(StdObjMgt_WriteData& theWriteData) const
{
PointsOnSurface::Write (theWriteData);
theWriteData << myPCurve;
}
void ShapePersistent_BRep::PointOnCurveOnSurface::PChildren
(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
{
PointRepresentation::PChildren(theChildren);
theChildren.Append(myPCurve);
}
Handle(BRep_PointRepresentation)
ShapePersistent_BRep::PointOnCurveOnSurface::import() const
{
@@ -111,6 +180,9 @@ Handle(BRep_PointRepresentation)
(myParameter, aPCurve, aSurface, myLocation.Import());
}
//=======================================================================
// PointOnSurface
//=======================================================================
void ShapePersistent_BRep::PointOnSurface::Read
(StdObjMgt_ReadData& theReadData)
{
@@ -118,6 +190,13 @@ void ShapePersistent_BRep::PointOnSurface::Read
theReadData >> myParameter2;
}
void ShapePersistent_BRep::PointOnSurface::Write
(StdObjMgt_WriteData& theWriteData) const
{
PointsOnSurface::Write(theWriteData);
theWriteData << myParameter2;
}
Handle(BRep_PointRepresentation)
ShapePersistent_BRep::PointOnSurface::import() const
{
@@ -130,17 +209,23 @@ Handle(BRep_PointRepresentation)
}
//=======================================================================
//function : Read
//purpose : Read persistent data from a file
// CurveRepresentation
//=======================================================================
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::Write
(StdObjMgt_WriteData& theWriteData) const
{ theWriteData << myLocation << myNext; }
void ShapePersistent_BRep::CurveRepresentation::PChildren
(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
{
myLocation.PChildren(theChildren);
theChildren.Append(myNext);
}
void ShapePersistent_BRep::CurveRepresentation::Import
(BRep_ListOfCurveRepresentation& theCurves) const
{
@@ -154,6 +239,9 @@ Handle(BRep_CurveRepresentation)
ShapePersistent_BRep::CurveRepresentation::import() const
{ return NULL; }
//=======================================================================
// GCurve
//=======================================================================
void ShapePersistent_BRep::GCurve::Read
(StdObjMgt_ReadData& theReadData)
{
@@ -161,6 +249,16 @@ void ShapePersistent_BRep::GCurve::Read
theReadData >> myFirst >> myLast;
}
void ShapePersistent_BRep::GCurve::Write
(StdObjMgt_WriteData& theWriteData) const
{
CurveRepresentation::Write(theWriteData);
theWriteData << myFirst << myLast;
}
//=======================================================================
// Curve3D
//=======================================================================
void ShapePersistent_BRep::Curve3D::Read
(StdObjMgt_ReadData& theReadData)
{
@@ -168,6 +266,20 @@ void ShapePersistent_BRep::Curve3D::Read
theReadData >> myCurve3D;
}
void ShapePersistent_BRep::Curve3D::Write
(StdObjMgt_WriteData& theWriteData) const
{
GCurve::Write (theWriteData);
theWriteData << myCurve3D;
}
void ShapePersistent_BRep::Curve3D::PChildren
(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
{
GCurve::PChildren(theChildren);
theChildren.Append(myCurve3D);
}
Handle(BRep_CurveRepresentation)
ShapePersistent_BRep::Curve3D::import() const
{
@@ -182,6 +294,9 @@ Handle(BRep_CurveRepresentation)
return aRepresentation;
}
//=======================================================================
// CurveOnSurface
//=======================================================================
void ShapePersistent_BRep::CurveOnSurface::Read
(StdObjMgt_ReadData& theReadData)
{
@@ -189,6 +304,21 @@ void ShapePersistent_BRep::CurveOnSurface::Read
theReadData >> myPCurve >> mySurface >> myUV1 >> myUV2;
}
void ShapePersistent_BRep::CurveOnSurface::Write
(StdObjMgt_WriteData& theWriteData) const
{
GCurve::Write (theWriteData);
theWriteData << myPCurve << mySurface << myUV1 << myUV2;
}
void ShapePersistent_BRep::CurveOnSurface::PChildren
(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
{
GCurve::PChildren(theChildren);
theChildren.Append(myPCurve);
theChildren.Append(mySurface);
}
Handle(BRep_CurveRepresentation)
ShapePersistent_BRep::CurveOnSurface::import() const
{
@@ -209,6 +339,9 @@ Handle(BRep_CurveRepresentation)
return aRepresentation;
}
//=======================================================================
// CurveOnClosedSurface
//=======================================================================
void ShapePersistent_BRep::CurveOnClosedSurface::Read
(StdObjMgt_ReadData& theReadData)
{
@@ -216,6 +349,20 @@ void ShapePersistent_BRep::CurveOnClosedSurface::Read
theReadData >> myPCurve2 >> myContinuity >> myUV21 >> myUV22;
}
void ShapePersistent_BRep::CurveOnClosedSurface::Write
(StdObjMgt_WriteData& theWriteData) const
{
CurveOnSurface::Write (theWriteData);
theWriteData << myPCurve2 << myContinuity << myUV21 << myUV22;
}
void ShapePersistent_BRep::CurveOnClosedSurface::PChildren
(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
{
CurveOnSurface::PChildren(theChildren);
theChildren.Append(myPCurve2);
}
Handle(BRep_CurveRepresentation)
ShapePersistent_BRep::CurveOnClosedSurface::import() const
{
@@ -244,6 +391,9 @@ Handle(BRep_CurveRepresentation)
return aRepresentation;
}
//=======================================================================
// Polygon3D
//=======================================================================
void ShapePersistent_BRep::Polygon3D::Read
(StdObjMgt_ReadData& theReadData)
{
@@ -251,6 +401,20 @@ void ShapePersistent_BRep::Polygon3D::Read
theReadData >> myPolygon3D;
}
void ShapePersistent_BRep::Polygon3D::Write
(StdObjMgt_WriteData& theWriteData) const
{
CurveRepresentation::Write (theWriteData);
theWriteData << myPolygon3D;
}
void ShapePersistent_BRep::Polygon3D::PChildren
(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
{
CurveRepresentation::PChildren(theChildren);
theChildren.Append(myPolygon3D);
}
Handle(BRep_CurveRepresentation)
ShapePersistent_BRep::Polygon3D::import() const
{
@@ -261,6 +425,9 @@ Handle(BRep_CurveRepresentation)
return new BRep_Polygon3D (aPolygon3D, myLocation.Import());
}
//=======================================================================
// PolygonOnTriangulation
//=======================================================================
void ShapePersistent_BRep::PolygonOnTriangulation::Read
(StdObjMgt_ReadData& theReadData)
{
@@ -268,6 +435,21 @@ void ShapePersistent_BRep::PolygonOnTriangulation::Read
theReadData >> myPolygon >> myTriangulation;
}
void ShapePersistent_BRep::PolygonOnTriangulation::Write
(StdObjMgt_WriteData& theWriteData) const
{
CurveRepresentation::Write (theWriteData);
theWriteData << myPolygon << myTriangulation;
}
void ShapePersistent_BRep::PolygonOnTriangulation::PChildren
(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
{
CurveRepresentation::PChildren(theChildren);
theChildren.Append(myPolygon);
theChildren.Append(myTriangulation);
}
Handle(BRep_CurveRepresentation)
ShapePersistent_BRep::PolygonOnTriangulation::import() const
{
@@ -283,6 +465,9 @@ Handle(BRep_CurveRepresentation)
(aPolygon, aTriangulation, myLocation.Import());
}
//=======================================================================
// PolygonOnClosedTriangulation
//=======================================================================
void ShapePersistent_BRep::PolygonOnClosedTriangulation::Read
(StdObjMgt_ReadData& theReadData)
{
@@ -290,6 +475,20 @@ void ShapePersistent_BRep::PolygonOnClosedTriangulation::Read
theReadData >> myPolygon2;
}
void ShapePersistent_BRep::PolygonOnClosedTriangulation::Write
(StdObjMgt_WriteData& theWriteData) const
{
PolygonOnTriangulation::Write (theWriteData);
theWriteData << myPolygon2;
}
void ShapePersistent_BRep::PolygonOnClosedTriangulation::PChildren
(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
{
PolygonOnTriangulation::PChildren(theChildren);
theChildren.Append(myPolygon2);
}
Handle(BRep_CurveRepresentation)
ShapePersistent_BRep::PolygonOnClosedTriangulation::import() const
{
@@ -309,6 +508,9 @@ Handle(BRep_CurveRepresentation)
(aPolygon, aPolygon2, aTriangulation, myLocation.Import());
}
//=======================================================================
// PolygonOnSurface
//=======================================================================
void ShapePersistent_BRep::PolygonOnSurface::Read
(StdObjMgt_ReadData& theReadData)
{
@@ -316,6 +518,21 @@ void ShapePersistent_BRep::PolygonOnSurface::Read
theReadData >> myPolygon2D >> mySurface;
}
void ShapePersistent_BRep::PolygonOnSurface::Write
(StdObjMgt_WriteData& theWriteData) const
{
CurveRepresentation::Write (theWriteData);
theWriteData << myPolygon2D << mySurface;
}
void ShapePersistent_BRep::PolygonOnSurface::PChildren
(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
{
CurveRepresentation::PChildren(theChildren);
theChildren.Append(myPolygon2D);
theChildren.Append(mySurface);
}
Handle(BRep_CurveRepresentation)
ShapePersistent_BRep::PolygonOnSurface::import() const
{
@@ -330,6 +547,9 @@ Handle(BRep_CurveRepresentation)
return new BRep_PolygonOnSurface (aPolygon2D, aSurface, myLocation.Import());
}
//=======================================================================
// PolygonOnClosedSurface
//=======================================================================
void ShapePersistent_BRep::PolygonOnClosedSurface::Read
(StdObjMgt_ReadData& theReadData)
{
@@ -337,6 +557,20 @@ void ShapePersistent_BRep::PolygonOnClosedSurface::Read
theReadData >> myPolygon2;
}
void ShapePersistent_BRep::PolygonOnClosedSurface::Write
(StdObjMgt_WriteData& theWriteData) const
{
PolygonOnSurface::Write (theWriteData);
theWriteData << myPolygon2;
}
void ShapePersistent_BRep::PolygonOnClosedSurface::PChildren
(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
{
PolygonOnSurface::PChildren(theChildren);
theChildren.Append(myPolygon2);
}
Handle(BRep_CurveRepresentation)
ShapePersistent_BRep::PolygonOnClosedSurface::import() const
{
@@ -356,6 +590,9 @@ Handle(BRep_CurveRepresentation)
(aPolygon2D, aPolygon2, aSurface, myLocation.Import());
}
//=======================================================================
// CurveOn2Surfaces
//=======================================================================
void ShapePersistent_BRep::CurveOn2Surfaces::Read
(StdObjMgt_ReadData& theReadData)
{
@@ -363,6 +600,22 @@ void ShapePersistent_BRep::CurveOn2Surfaces::Read
theReadData >> mySurface >> mySurface2 >> myLocation2 >> myContinuity;
}
void ShapePersistent_BRep::CurveOn2Surfaces::Write
(StdObjMgt_WriteData& theWriteData) const
{
CurveRepresentation::Write (theWriteData);
theWriteData << mySurface << mySurface2 << myLocation2 << myContinuity;
}
void ShapePersistent_BRep::CurveOn2Surfaces::PChildren
(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
{
CurveRepresentation::PChildren(theChildren);
theChildren.Append(mySurface);
theChildren.Append(mySurface2);
myLocation2.PChildren(theChildren);
}
Handle(BRep_CurveRepresentation)
ShapePersistent_BRep::CurveOn2Surfaces::import() const
{
@@ -434,3 +687,464 @@ Handle(TopoDS_TShape) ShapePersistent_BRep::pTFace::createTShape() const
return aTFace;
}
//=======================================================================
//function : Translate
//purpose : Translates a shape to its persistent avatar
//=======================================================================
Handle(ShapePersistent_BRep::TVertex::pTObjectT)
ShapePersistent_BRep::Translate (const TopoDS_Vertex& theVertex,
StdObjMgt_TransientPersistentMap& theMap)
{
Handle(BRep_TVertex) TTV = Handle(BRep_TVertex)::DownCast (theVertex.TShape());
Handle(TVertex::pTObjectT) PTV = new TVertex::pTObjectT;
PTV->myPnt = TTV->Pnt();
PTV->myTolerance = TTV->Tolerance();
BRep_ListIteratorOfListOfPointRepresentation anItPR(TTV->Points());
Handle(PointRepresentation) PPR, CPPR;
while (anItPR.More())
{
const Handle(BRep_PointRepresentation)& PR = anItPR.Value();
if (PR->IsPointOnCurve()) {
Handle(PointOnCurve) POC = Translate(PR->Parameter(),
PR->Curve(),
PR->Location(),
theMap);
CPPR = POC;
}
else if (PR->IsPointOnCurveOnSurface()) {
Handle(PointOnCurveOnSurface) POCS = Translate(PR->Parameter(),
PR->PCurve(),
PR->Surface(),
PR->Location(),
theMap);
CPPR = POCS;
}
else if (PR->IsPointOnSurface()) {
Handle(PointOnSurface) POS = Translate(PR->Parameter(),
PR->Parameter2(),
PR->Surface(),
PR->Location(),
theMap);
CPPR = POS;
}
CPPR->myNext = PPR;
PPR = CPPR;
anItPR.Next();
}
PTV->myPoints = PPR;
return PTV;
}
//=======================================================================
//function : Translate
//purpose : Translates a shape to its persistent avatar
//=======================================================================
Handle(ShapePersistent_BRep::TEdge::pTObjectT)
ShapePersistent_BRep::Translate (const TopoDS_Edge& theEdge,
StdObjMgt_TransientPersistentMap& theMap,
ShapePersistent_TriangleMode theTriangleMode)
{
Handle(BRep_TEdge) TTE = Handle(BRep_TEdge)::DownCast (theEdge.TShape());
Handle(TEdge::pTObjectT) PTE = new TEdge::pTObjectT;
PTE->myTolerance = TTE->Tolerance();
if (TTE->SameParameter()) PTE->myFlags |= ParameterMask;
if (TTE->SameRange()) PTE->myFlags |= RangeMask;
if (TTE->Degenerated()) PTE->myFlags |= DegeneratedMask;
// Representations
BRep_ListIteratorOfListOfCurveRepresentation itcr(TTE->Curves());
Handle(CurveRepresentation) PCR, CPCR;
Handle(BRep_GCurve) GC;
Standard_Real f, l;
while (itcr.More())
{
const Handle(BRep_CurveRepresentation)& CR = itcr.Value();
GC = Handle(BRep_GCurve)::DownCast(CR);
if (!GC.IsNull())
{
GC->Range(f, l);
// CurveRepresentation is Curve3D
if (CR->IsCurve3D()) {
Handle(Curve3D) C3D = Translate(CR->Curve3D(), f, l, CR->Location(), theMap);
CPCR = C3D;
}
// CurveRepresentation is CurveOnSurface
else if (CR->IsCurveOnSurface())
{
Handle(BRep_CurveOnSurface)& theCOS = (Handle(BRep_CurveOnSurface)&) CR;
Handle(CurveOnSurface) COS;
// CurveRepresentation is CurveOnSurface
if (!CR->IsCurveOnClosedSurface())
{
COS = Translate(CR->PCurve(), f, l, CR->Surface(), CR->Location(), theMap);
}
// CurveRepresentation is CurveOnClosedSurface
else
{
// get UVPoints for the CurveOnClosedSurface definition.
Handle(BRep_CurveOnClosedSurface)& theCOCS =
(Handle(BRep_CurveOnClosedSurface)&) CR;
gp_Pnt2d Pnt21, Pnt22;
theCOCS->UVPoints2(Pnt21, Pnt22);
Handle(CurveOnClosedSurface) COCS = Translate(CR->PCurve(), CR->PCurve2(),
f, l, CR->Surface(),
CR->Location(), CR->Continuity(),
theMap);
COCS->myUV21 = Pnt21;
COCS->myUV22 = Pnt22;
COS = COCS;
}
// get UVPoints for the CurveOnSurface definition.
gp_Pnt2d Pnt1, Pnt2;
theCOS->UVPoints(Pnt1, Pnt2);
COS->myUV1 = Pnt1;
COS->myUV2 = Pnt2;
CPCR = COS;
}
}
// CurveRepresentation is CurveOn2Surfaces
else if (CR->IsRegularity())
{
Handle(CurveOn2Surfaces) R = Translate(CR->Surface(), CR->Surface2(),
CR->Location(), CR->Location2(),
CR->Continuity(),
theMap);
CPCR = R;
}
// CurveRepresentation is Polygon or Triangulation
else if (theTriangleMode == ShapePersistent_WithTriangle) {
// CurveRepresentation is Polygon3D
if (CR->IsPolygon3D()) {
Handle(Polygon3D) P3D = Translate(CR->Polygon3D(), CR->Location(), theMap);
CPCR = P3D;
}
// CurveRepresentation is PolygonOnSurface
else if (CR->IsPolygonOnSurface())
{
// CurveRepresentation is PolygonOnClosedSurface
if (CR->IsPolygonOnClosedSurface()) {
Handle(PolygonOnClosedSurface) PolOCS = Translate(CR->Polygon(), CR->Polygon2(),
CR->Surface(), CR->Location(),
theMap);
CPCR = PolOCS;
}
// CurveRepresentation is PolygonOnSurface
else
{
Handle(PolygonOnSurface) PolOS = Translate(CR->Polygon(), CR->Surface(),
CR->Location(), theMap);
CPCR = PolOS;
}
}
// CurveRepresentation is PolygonOnTriangulation
else if (CR->IsPolygonOnTriangulation())
{
// CurveRepresentation is PolygonOnClosedTriangulation
if (CR->IsPolygonOnClosedTriangulation())
{
Handle(PolygonOnClosedTriangulation) PolOCT = Translate(CR->PolygonOnTriangulation(),
CR->PolygonOnTriangulation2(),
CR->Triangulation(),
CR->Location(),
theMap);
CPCR = PolOCT;
}
// CurveRepresentation is PolygonOnTriangulation
else
{
Handle(PolygonOnTriangulation) PolOT = Translate(CR->PolygonOnTriangulation(),
CR->Triangulation(),
CR->Location(),
theMap);
CPCR = PolOT;
}
}
}
else
{
// jumps the curve representation
itcr.Next();
continue;
}
Standard_NullObject_Raise_if(CPCR.IsNull(), "Null CurveRepresentation");
CPCR->myNext = PCR;
PCR = CPCR;
itcr.Next();
}
// set
PTE->myCurves = PCR;
return PTE;
}
//=======================================================================
//function : Translate
//purpose : Translates a shape to its persistent avatar
//=======================================================================
Handle(ShapePersistent_BRep::TFace::pTObjectT)
ShapePersistent_BRep::Translate (const TopoDS_Face& theFace,
StdObjMgt_TransientPersistentMap& theMap,
ShapePersistent_TriangleMode theTriangleMode)
{
Handle(BRep_TFace) TTF = Handle(BRep_TFace)::DownCast (theFace.TShape());
Handle(TFace::pTObjectT) PTF = new TFace::pTObjectT;
PTF->myTolerance = TTF->Tolerance();
PTF->myLocation = StdObject_Location::Translate(TTF->Location(), theMap);
PTF->myNaturalRestriction = TTF->NaturalRestriction();
// Surface
PTF->mySurface = ShapePersistent_Geom::Translate(TTF->Surface(), theMap);
// Triangulation
if (theTriangleMode == ShapePersistent_WithTriangle) {
PTF->myTriangulation = ShapePersistent_Poly::Translate(TTF->Triangulation(), theMap);
}
return PTF;
}
//=======================================================================
//function : Translate
//purpose : Translates a shape to its persistent avatar
//=======================================================================
Handle(ShapePersistent_BRep::PointOnCurve)
ShapePersistent_BRep::Translate (Standard_Real theParam,
const Handle(Geom_Curve)& theCurve,
const TopLoc_Location& theLoc,
StdObjMgt_TransientPersistentMap& theMap)
{
Handle(PointOnCurve) aPPonC = new PointOnCurve;
aPPonC->myParameter = theParam;
aPPonC->myCurve = ShapePersistent_Geom::Translate(theCurve, theMap);
aPPonC->myLocation = StdObject_Location::Translate(theLoc, theMap);
return aPPonC;
}
//=======================================================================
//function : Translate
//purpose : Translates a shape to its persistent avatar
//=======================================================================
Handle(ShapePersistent_BRep::PointOnCurveOnSurface)
ShapePersistent_BRep::Translate(Standard_Real theParam,
const Handle(Geom2d_Curve)& theCurve,
const Handle(Geom_Surface)& theSurf,
const TopLoc_Location& theLoc,
StdObjMgt_TransientPersistentMap& theMap)
{
Handle(PointOnCurveOnSurface) aPPonConS = new PointOnCurveOnSurface;
aPPonConS->myParameter = theParam;
aPPonConS->myPCurve = ShapePersistent_Geom2d::Translate(theCurve, theMap);
aPPonConS->mySurface = ShapePersistent_Geom::Translate(theSurf, theMap);
aPPonConS->myLocation = StdObject_Location::Translate(theLoc, theMap);
return aPPonConS;
}
//=======================================================================
//function : Translate
//purpose : Translates a shape to its persistent avatar
//=======================================================================
Handle(ShapePersistent_BRep::PointOnSurface)
ShapePersistent_BRep::Translate(Standard_Real theParam,
Standard_Real theParam2,
const Handle(Geom_Surface)& theSurf,
const TopLoc_Location& theLoc,
StdObjMgt_TransientPersistentMap& theMap)
{
Handle(PointOnSurface) aPonS = new PointOnSurface;
aPonS->myParameter = theParam;
aPonS->myParameter2 = theParam2;
aPonS->mySurface = ShapePersistent_Geom::Translate(theSurf, theMap);
aPonS->myLocation = StdObject_Location::Translate(theLoc, theMap);
return aPonS;
}
//=======================================================================
//function : Translate
//purpose : Translates a shape to its persistent avatar
//=======================================================================
Handle(ShapePersistent_BRep::CurveOnSurface)
ShapePersistent_BRep::Translate(const Handle(Geom2d_Curve)& theCurve,
const Standard_Real theFirstParam,
const Standard_Real theLastParam,
const Handle(Geom_Surface)& theSurf,
const TopLoc_Location& theLoc,
StdObjMgt_TransientPersistentMap& theMap)
{
Handle(CurveOnSurface) aPConS = new CurveOnSurface;
aPConS->myPCurve = ShapePersistent_Geom2d::Translate(theCurve, theMap);
aPConS->myFirst = theFirstParam;
aPConS->myLast = theLastParam;
aPConS->mySurface = ShapePersistent_Geom::Translate(theSurf, theMap);
aPConS->myLocation = StdObject_Location::Translate(theLoc, theMap);
return aPConS;
}
//=======================================================================
//function : Translate
//purpose : Translates a shape to its persistent avatar
//=======================================================================
Handle(ShapePersistent_BRep::CurveOnClosedSurface)
ShapePersistent_BRep::Translate(const Handle(Geom2d_Curve)& theCurve,
const Handle(Geom2d_Curve)& theCurve2,
const Standard_Real theFirstParam,
const Standard_Real theLastParam,
const Handle(Geom_Surface)& theSurf,
const TopLoc_Location& theLoc,
const GeomAbs_Shape theContinuity,
StdObjMgt_TransientPersistentMap& theMap)
{
Handle(CurveOnClosedSurface) aPConCS = new CurveOnClosedSurface;
aPConCS->myPCurve = ShapePersistent_Geom2d::Translate(theCurve, theMap);
aPConCS->myPCurve2 = ShapePersistent_Geom2d::Translate(theCurve2, theMap);
aPConCS->myFirst = theFirstParam;
aPConCS->myLast = theLastParam;
aPConCS->mySurface = ShapePersistent_Geom::Translate(theSurf, theMap);
aPConCS->myLocation = StdObject_Location::Translate(theLoc, theMap);
aPConCS->myContinuity = theContinuity;
return aPConCS;
}
//=======================================================================
//function : Translate
//purpose : Translates a shape to its persistent avatar
//=======================================================================
Handle(ShapePersistent_BRep::CurveOn2Surfaces)
ShapePersistent_BRep::Translate(const Handle(Geom_Surface)& theSurf,
const Handle(Geom_Surface)& theSurf2,
const TopLoc_Location& theLoc,
const TopLoc_Location& theLoc2,
const GeomAbs_Shape theContinuity,
StdObjMgt_TransientPersistentMap& theMap)
{
Handle(CurveOn2Surfaces) aPCon2S = new CurveOn2Surfaces;
aPCon2S->mySurface = ShapePersistent_Geom::Translate(theSurf, theMap);
aPCon2S->mySurface2 = ShapePersistent_Geom::Translate(theSurf2, theMap);
aPCon2S->myLocation = StdObject_Location::Translate(theLoc, theMap);
aPCon2S->myLocation2 = StdObject_Location::Translate(theLoc2, theMap);
aPCon2S->myContinuity = theContinuity;
return aPCon2S;
}
//=======================================================================
//function : Translate
//purpose : Translates a shape to its persistent avatar
//=======================================================================
Handle(ShapePersistent_BRep::Curve3D)
ShapePersistent_BRep::Translate (const Handle(Geom_Curve)& theCurve,
const Standard_Real theFirstParam,
const Standard_Real theLastParam,
const TopLoc_Location& theLoc,
StdObjMgt_TransientPersistentMap& theMap)
{
Handle(Curve3D) aPCurve3D = new Curve3D;
aPCurve3D->myCurve3D = ShapePersistent_Geom::Translate(theCurve, theMap);
aPCurve3D->myLocation = StdObject_Location::Translate(theLoc, theMap);
aPCurve3D->myFirst = theFirstParam;
aPCurve3D->myLast = theLastParam;
return aPCurve3D;
}
//=======================================================================
//function : Translate
//purpose : Translates a shape to its persistent avatar
//=======================================================================
Handle(ShapePersistent_BRep::Polygon3D)
ShapePersistent_BRep::Translate(const Handle(Poly_Polygon3D)& thePoly,
const TopLoc_Location& theLoc,
StdObjMgt_TransientPersistentMap& theMap)
{
Handle(Polygon3D) aPPoly = new Polygon3D;
aPPoly->myPolygon3D = ShapePersistent_Poly::Translate(thePoly, theMap);
aPPoly->myLocation = StdObject_Location::Translate(theLoc, theMap);
return aPPoly;
}
//=======================================================================
//function : Translate
//purpose : Translates a shape to its persistent avatar
//=======================================================================
Handle(ShapePersistent_BRep::PolygonOnClosedSurface)
ShapePersistent_BRep::Translate(const Handle(Poly_Polygon2D)& thePoly,
const Handle(Poly_Polygon2D)& thePoly2,
const Handle(Geom_Surface)& theSurf,
const TopLoc_Location& theLoc,
StdObjMgt_TransientPersistentMap& theMap)
{
Handle(PolygonOnClosedSurface) aPPonCS = new PolygonOnClosedSurface;
aPPonCS->myPolygon2D = ShapePersistent_Poly::Translate(thePoly, theMap);
aPPonCS->myPolygon2 = ShapePersistent_Poly::Translate(thePoly2, theMap);
aPPonCS->mySurface = ShapePersistent_Geom::Translate(theSurf, theMap);
aPPonCS->myLocation = StdObject_Location::Translate(theLoc, theMap);
return aPPonCS;
}
//=======================================================================
//function : Translate
//purpose : Translates a shape to its persistent avatar
//=======================================================================
Handle(ShapePersistent_BRep::PolygonOnSurface)
ShapePersistent_BRep::Translate(const Handle(Poly_Polygon2D)& thePoly,
const Handle(Geom_Surface)& theSurf,
const TopLoc_Location& theLoc,
StdObjMgt_TransientPersistentMap& theMap)
{
Handle(PolygonOnSurface) aPPonS = new PolygonOnSurface;
aPPonS->myPolygon2D = ShapePersistent_Poly::Translate(thePoly, theMap);
aPPonS->mySurface = ShapePersistent_Geom::Translate(theSurf, theMap);
aPPonS->myLocation = StdObject_Location::Translate(theLoc, theMap);
return aPPonS;
}
//=======================================================================
//function : Translate
//purpose : Translates a shape to its persistent avatar
//=======================================================================
Handle(ShapePersistent_BRep::PolygonOnClosedTriangulation)
ShapePersistent_BRep::Translate(const Handle(Poly_PolygonOnTriangulation)& thePolyOnTriang,
const Handle(Poly_PolygonOnTriangulation)& thePolyOnTriang2,
const Handle(Poly_Triangulation)& thePolyTriang,
const TopLoc_Location& theLoc,
StdObjMgt_TransientPersistentMap& theMap)
{
Handle(PolygonOnClosedTriangulation) aPPonCS = new PolygonOnClosedTriangulation;
aPPonCS->myPolygon = ShapePersistent_Poly::Translate(thePolyOnTriang, theMap);
aPPonCS->myPolygon2 = ShapePersistent_Poly::Translate(thePolyOnTriang2, theMap);
aPPonCS->myTriangulation = ShapePersistent_Poly::Translate(thePolyTriang, theMap);
aPPonCS->myLocation = StdObject_Location::Translate(theLoc, theMap);
return aPPonCS;
}
//=======================================================================
//function : Translate
//purpose : Translates a shape to its persistent avatar
//=======================================================================
Handle(ShapePersistent_BRep::PolygonOnTriangulation)
ShapePersistent_BRep::Translate(const Handle(Poly_PolygonOnTriangulation)& thePolyOnTriang,
const Handle(Poly_Triangulation)& thePolyTriang,
const TopLoc_Location& theLoc,
StdObjMgt_TransientPersistentMap& theMap)
{
Handle(PolygonOnTriangulation) aPPonT = new PolygonOnTriangulation;
aPPonT->myPolygon = ShapePersistent_Poly::Translate(thePolyOnTriang, theMap);
aPPonT->myTriangulation = ShapePersistent_Poly::Translate(thePolyTriang, theMap);
aPPonT->myLocation = StdObject_Location::Translate(theLoc, theMap);
return aPPonT;
}

View File

@@ -19,6 +19,7 @@
#include <ShapePersistent_Geom.hxx>
#include <ShapePersistent_Geom2d.hxx>
#include <ShapePersistent_Poly.hxx>
#include <StdObjMgt_TransientPersistentMap.hxx>
#include <StdObject_Location.hxx>
#include <StdObject_gp_Vectors.hxx>
@@ -30,20 +31,28 @@
class BRep_PointRepresentation;
class BRep_CurveRepresentation;
class TopoDS_Vertex;
class TopoDS_Edge;
class TopoDS_Face;
class ShapePersistent_BRep : public ShapePersistent_TopoDS
{
public:
class PointRepresentation : public StdObjMgt_Persistent
{
friend class ShapePersistent_BRep;
public:
//! Read persistent data from a file.
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
//! Write persistent data to a file.
Standard_EXPORT virtual void Write(StdObjMgt_WriteData& theWriteData) const;
//! Gets persistent child objects
virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
//! Returns persistent type name
virtual Standard_CString PName() const { return "PBRep_PointRepresentation"; }
//! Import transient object from the persistent data.
Standard_EXPORT void Import (BRep_ListOfPointRepresentation& thePoints)
const;
Standard_EXPORT void Import (BRep_ListOfPointRepresentation& thePoints) const;
protected:
virtual Handle(BRep_PointRepresentation) import() const;
@@ -58,8 +67,13 @@ public:
class PointOnCurve : public PointRepresentation
{
friend class ShapePersistent_BRep;
public:
virtual void Read (StdObjMgt_ReadData& theReadData);
virtual void Write (StdObjMgt_WriteData& theWriteData) const;
virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
virtual Standard_CString PName() const { return "PBRep_PointOnCurve"; }
virtual Handle(BRep_PointRepresentation) import() const;
private:
@@ -68,8 +82,13 @@ public:
class PointsOnSurface : public PointRepresentation
{
friend class ShapePersistent_BRep;
public:
virtual void Read (StdObjMgt_ReadData& theReadData);
virtual void Write (StdObjMgt_WriteData& theWriteData) const;
virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
virtual Standard_CString PName() const { return "PBRep_PointsOnSurface"; }
protected:
Handle(ShapePersistent_Geom::Surface) mySurface;
@@ -77,8 +96,13 @@ public:
class PointOnCurveOnSurface : public PointsOnSurface
{
friend class ShapePersistent_BRep;
public:
virtual void Read (StdObjMgt_ReadData& theReadData);
virtual void Write (StdObjMgt_WriteData& theWriteData) const;
virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
virtual Standard_CString PName() const { return "PBRep_PointOnCurveOnSurface"; }
virtual Handle(BRep_PointRepresentation) import() const;
private:
@@ -87,8 +111,12 @@ public:
class PointOnSurface : public PointsOnSurface
{
friend class ShapePersistent_BRep;
public:
virtual void Read (StdObjMgt_ReadData& theReadData);
virtual void Write (StdObjMgt_WriteData& theWriteData) const;
virtual Standard_CString PName() const { return "PBRep_PointOnSurface"; }
virtual Handle(BRep_PointRepresentation) import() const;
private:
@@ -97,13 +125,19 @@ public:
class CurveRepresentation : public StdObjMgt_Persistent
{
friend class ShapePersistent_BRep;
public:
//! Read persistent data from a file.
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
//! Write persistent data from a file.
Standard_EXPORT virtual void Write (StdObjMgt_WriteData& theWriteData) const;
//! Gets persistent child objects
virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
//! Returns persistent type name
virtual Standard_CString PName() const { return "PBRep_CurveRepresentation"; }
//! Import transient object from the persistent data.
Standard_EXPORT void Import (BRep_ListOfCurveRepresentation& theCurves)
const;
Standard_EXPORT void Import (BRep_ListOfCurveRepresentation& theCurves) const;
protected:
virtual Handle(BRep_CurveRepresentation) import() const;
@@ -117,8 +151,12 @@ public:
class GCurve : public CurveRepresentation
{
friend class ShapePersistent_BRep;
public:
virtual void Read (StdObjMgt_ReadData& theReadData);
virtual void Write (StdObjMgt_WriteData& theWriteData) const;
virtual Standard_CString PName() const { return "PBRep_GCurve"; }
protected:
Standard_Real myFirst;
@@ -127,8 +165,13 @@ public:
class Curve3D : public GCurve
{
friend class ShapePersistent_BRep;
public:
virtual void Read (StdObjMgt_ReadData& theReadData);
virtual void Write (StdObjMgt_WriteData& theWriteData) const;
virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
virtual Standard_CString PName() const { return "PBRep_Curve3D"; }
virtual Handle(BRep_CurveRepresentation) import() const;
private:
@@ -137,8 +180,13 @@ public:
class CurveOnSurface : public GCurve
{
friend class ShapePersistent_BRep;
public:
virtual void Read (StdObjMgt_ReadData& theReadData);
virtual void Write (StdObjMgt_WriteData& theWriteData) const;
virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
virtual Standard_CString PName() const { return "PBRep_CurveOnSurface"; }
virtual Handle(BRep_CurveRepresentation) import() const;
protected:
@@ -150,8 +198,13 @@ public:
class CurveOnClosedSurface : public CurveOnSurface
{
friend class ShapePersistent_BRep;
public:
virtual void Read (StdObjMgt_ReadData& theReadData);
virtual void Write (StdObjMgt_WriteData& theWriteData) const;
virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
virtual Standard_CString PName() const { return "PBRep_CurveOnClosedSurface"; }
virtual Handle(BRep_CurveRepresentation) import() const;
private:
@@ -163,8 +216,13 @@ public:
class Polygon3D : public CurveRepresentation
{
friend class ShapePersistent_BRep;
public:
virtual void Read (StdObjMgt_ReadData& theReadData);
virtual void Write (StdObjMgt_WriteData& theWriteData) const;
virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
virtual Standard_CString PName() const { return "PBRep_Polygon3D"; }
virtual Handle(BRep_CurveRepresentation) import() const;
private:
@@ -173,8 +231,13 @@ public:
class PolygonOnTriangulation : public CurveRepresentation
{
friend class ShapePersistent_BRep;
public:
virtual void Read (StdObjMgt_ReadData& theReadData);
virtual void Write (StdObjMgt_WriteData& theWriteData) const;
virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
virtual Standard_CString PName() const { return "PBRep_PolygonOnTriangulation"; }
virtual Handle(BRep_CurveRepresentation) import() const;
protected:
@@ -184,8 +247,13 @@ public:
class PolygonOnClosedTriangulation : public PolygonOnTriangulation
{
friend class ShapePersistent_BRep;
public:
virtual void Read (StdObjMgt_ReadData& theReadData);
virtual void Write (StdObjMgt_WriteData& theWriteData) const;
virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
virtual Standard_CString PName() const { return "PBRep_PolygonOnClosedTriangulation"; }
virtual Handle(BRep_CurveRepresentation) import() const;
private:
@@ -194,8 +262,13 @@ public:
class PolygonOnSurface : public CurveRepresentation
{
friend class ShapePersistent_BRep;
public:
virtual void Read (StdObjMgt_ReadData& theReadData);
virtual void Write (StdObjMgt_WriteData& theWriteData) const;
virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
virtual Standard_CString PName() const { return "PBRep_PolygonOnSurface"; }
virtual Handle(BRep_CurveRepresentation) import() const;
protected:
@@ -205,8 +278,13 @@ public:
class PolygonOnClosedSurface : public PolygonOnSurface
{
friend class ShapePersistent_BRep;
public:
virtual void Read (StdObjMgt_ReadData& theReadData);
virtual void Write (StdObjMgt_WriteData& theWriteData) const;
virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
virtual Standard_CString PName() const { return "PBRep_PolygonOnClosedSurface"; }
virtual Handle(BRep_CurveRepresentation) import() const;
private:
@@ -215,8 +293,13 @@ public:
class CurveOn2Surfaces : public CurveRepresentation
{
friend class ShapePersistent_BRep;
public:
virtual void Read (StdObjMgt_ReadData& theReadData);
virtual void Write (StdObjMgt_WriteData& theWriteData) const;
virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
virtual Standard_CString PName() const { return "PBRep_CurveOn2Surfaces"; }
virtual Handle(BRep_CurveRepresentation) import() const;
private:
@@ -229,12 +312,26 @@ public:
private:
class pTVertex : public pTBase
{
friend class ShapePersistent_BRep;
public:
inline void Read (StdObjMgt_ReadData& theReadData)
{
pTBase::Read (theReadData);
theReadData >> myTolerance >> myPnt >> myPoints;
}
inline void Write (StdObjMgt_WriteData& theWriteData) const
{
pTBase::Write (theWriteData);
theWriteData << myTolerance << myPnt << myPoints;
}
inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
{
pTBase::PChildren(theChildren);
theChildren.Append(myPoints);
}
inline Standard_CString PName() const
{ return "PBRep_TVertex"; }
private:
virtual Handle(TopoDS_TShape) createTShape() const;
@@ -247,12 +344,26 @@ private:
class pTEdge : public pTBase
{
friend class ShapePersistent_BRep;
public:
inline void Read (StdObjMgt_ReadData& theReadData)
{
pTBase::Read (theReadData);
theReadData >> myTolerance >> myFlags >> myCurves;
}
inline void Write (StdObjMgt_WriteData& theWriteData) const
{
pTBase::Write (theWriteData);
theWriteData << myTolerance << myFlags << myCurves;
}
inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
{
pTBase::PChildren(theChildren);
theChildren.Append(myCurves);
}
inline Standard_CString PName() const
{ return "PBRep_TEdge"; }
private:
virtual Handle(TopoDS_TShape) createTShape() const;
@@ -265,6 +376,8 @@ private:
class pTFace : public pTBase
{
friend class ShapePersistent_BRep;
public:
inline void Read (StdObjMgt_ReadData& theReadData)
{
@@ -272,6 +385,21 @@ private:
theReadData >> mySurface >> myTriangulation >> myLocation;
theReadData >> myTolerance >> myNaturalRestriction;
}
inline void Write (StdObjMgt_WriteData& theWriteData) const
{
pTBase::Write (theWriteData);
theWriteData << mySurface << myTriangulation << myLocation;
theWriteData << myTolerance << myNaturalRestriction;
}
inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
{
pTBase::PChildren(theChildren);
theChildren.Append(mySurface);
theChildren.Append(myTriangulation);
myLocation.PChildren(theChildren);
}
inline Standard_CString PName() const
{ return "PBRep_TFace"; }
private:
virtual Handle(TopoDS_TShape) createTShape() const;
@@ -292,6 +420,91 @@ public:
typedef tObject1 <pTVertex> TVertex1;
typedef tObject1 <pTEdge> TEdge1;
typedef tObject1 <pTFace> TFace1;
public:
//! Create a persistent object for a vertex
Standard_EXPORT static Handle(TVertex::pTObjectT) Translate (const TopoDS_Vertex& theVertex,
StdObjMgt_TransientPersistentMap& theMap);
//! Create a persistent object for an edge
Standard_EXPORT static Handle(TEdge::pTObjectT) Translate (const TopoDS_Edge& theEdge,
StdObjMgt_TransientPersistentMap& theMap,
ShapePersistent_TriangleMode theTriangleMode);
//! Create a persistent object for a face
Standard_EXPORT static Handle(TFace::pTObjectT) Translate (const TopoDS_Face& theFace,
StdObjMgt_TransientPersistentMap& theMap,
ShapePersistent_TriangleMode theTriangleMode);
//! Create a persistent object for a point on a 3D curve
Standard_EXPORT static Handle(PointOnCurve) Translate(Standard_Real theParam,
const Handle(Geom_Curve)& theCurve,
const TopLoc_Location& theLoc,
StdObjMgt_TransientPersistentMap& theMap);
//! Create a persistent object for a point on a 3D curve on a surface
Standard_EXPORT static Handle(PointOnCurveOnSurface) Translate (Standard_Real theParam,
const Handle(Geom2d_Curve)& theCurve,
const Handle(Geom_Surface)& theSurf,
const TopLoc_Location& theLoc,
StdObjMgt_TransientPersistentMap& theMap);
//! Create a persistent object for a point on a surface
Standard_EXPORT static Handle(PointOnSurface) Translate (Standard_Real theParam,
Standard_Real theParam2,
const Handle(Geom_Surface)& theSurf,
const TopLoc_Location& theLoc,
StdObjMgt_TransientPersistentMap& theMap);
//! Create a persistent object for a curve on a surface
Standard_EXPORT static Handle(CurveOnSurface) Translate (const Handle(Geom2d_Curve)& theCurve,
const Standard_Real theFirstParam,
const Standard_Real theLastParam,
const Handle(Geom_Surface)& theSurf,
const TopLoc_Location& theLoc,
StdObjMgt_TransientPersistentMap& theMap);
//! Create a persistent object for a curve on a closed surface
Standard_EXPORT static Handle(CurveOnClosedSurface) Translate (const Handle(Geom2d_Curve)& theCurve,
const Handle(Geom2d_Curve)& theCurve2,
const Standard_Real theFirstParam,
const Standard_Real theLastParam,
const Handle(Geom_Surface)& theSurf,
const TopLoc_Location& theLoc,
const GeomAbs_Shape theContinuity,
StdObjMgt_TransientPersistentMap& theMap);
//! Create a persistent object for a curve on two surfaces
Standard_EXPORT static Handle(CurveOn2Surfaces) Translate (const Handle(Geom_Surface)& theSurf,
const Handle(Geom_Surface)& theSurf2,
const TopLoc_Location& theLoc,
const TopLoc_Location& theLoc2,
const GeomAbs_Shape theContinuity,
StdObjMgt_TransientPersistentMap& theMap);
//! Create a persistent object for a 3D curve
Standard_EXPORT static Handle(Curve3D) Translate (const Handle(Geom_Curve)& theCurve,
const Standard_Real theFirstParam,
const Standard_Real theLastParam,
const TopLoc_Location& theLoc,
StdObjMgt_TransientPersistentMap& theMap);
//! Create a persistent object for a 3D polygon
Standard_EXPORT static Handle(Polygon3D) Translate (const Handle(Poly_Polygon3D)& thePoly,
const TopLoc_Location& theLoc,
StdObjMgt_TransientPersistentMap& theMap);
//! Create a persistent object for a polygon on a closed surface
Standard_EXPORT static Handle(PolygonOnClosedSurface) Translate (const Handle(Poly_Polygon2D)& thePoly,
const Handle(Poly_Polygon2D)& thePoly2,
const Handle(Geom_Surface)& theSurf,
const TopLoc_Location& theLoc,
StdObjMgt_TransientPersistentMap& theMap);
//! Create a persistent object for a polygon on a surface
Standard_EXPORT static Handle(PolygonOnSurface) Translate (const Handle(Poly_Polygon2D)& thePoly,
const Handle(Geom_Surface)& theSurf,
const TopLoc_Location& theLoc,
StdObjMgt_TransientPersistentMap& theMap);
//! Create a persistent object for a polygon on a surface
Standard_EXPORT static Handle(PolygonOnClosedTriangulation) Translate (const Handle(Poly_PolygonOnTriangulation)& thePolyOnTriang,
const Handle(Poly_PolygonOnTriangulation)& thePolyOnTriang2,
const Handle(Poly_Triangulation)& thePolyTriang,
const TopLoc_Location& theLoc,
StdObjMgt_TransientPersistentMap& theMap);
//! Create a persistent object for a polygon on a surface
Standard_EXPORT static Handle(PolygonOnTriangulation) Translate (const Handle(Poly_PolygonOnTriangulation)& thePolyOnTriang,
const Handle(Poly_Triangulation)& thePolyTriang,
const TopLoc_Location& theLoc,
StdObjMgt_TransientPersistentMap& theMap);
};
#endif

View File

@@ -11,7 +11,11 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <Standard_NullObject.hxx>
#include <ShapePersistent_Geom.hxx>
#include <ShapePersistent_Geom_Curve.hxx>
#include <ShapePersistent_Geom_Surface.hxx>
#include <StdObject_gp_Axes.hxx>
#include <StdObject_gp_Vectors.hxx>
@@ -23,20 +27,125 @@
void ShapePersistent_Geom::Geometry::Read (StdObjMgt_ReadData&) {}
//=======================================================================
//function : Read
//purpose : Read persistent data from a file
//function : Write
//purpose : Write persistent data to a file
//=======================================================================
template<>
void ShapePersistent_Geom::instance<ShapePersistent_Geom::AxisPlacement,
Geom_Axis2Placement>
::Read (StdObjMgt_ReadData& theReadData)
{
gp_Ax1 anAxis;
gp_Dir anXDirection;
void ShapePersistent_Geom::Geometry::Write (StdObjMgt_WriteData&) const {}
theReadData >> anAxis >> anXDirection;
myTransient = new Geom_Axis2Placement (anAxis.Location(),
anAxis.Direction(),
anXDirection);
//=======================================================================
//function : PChildren
//purpose : Gets persistent objects
//=======================================================================
void ShapePersistent_Geom::Geometry::PChildren (SequenceOfPersistent&) const
{
}
//=======================================================================
//function : Translate
//purpose : Create a persistent object for a curve
//=======================================================================
Handle(ShapePersistent_Geom::Curve)
ShapePersistent_Geom::Translate (const Handle(Geom_Curve)& theCurve,
StdObjMgt_TransientPersistentMap& theMap)
{
Handle(Curve) aPC;
if (!theCurve.IsNull())
{
if (theMap.IsBound(theCurve))
aPC = Handle(Curve)::DownCast(theMap.Find(theCurve));
else
{
Handle(Standard_Type) aCT = theCurve->DynamicType();
if (aCT == STANDARD_TYPE(Geom_Line)) {
aPC = ShapePersistent_Geom_Curve::Translate(Handle(Geom_Line)::DownCast(theCurve), theMap);
}
else if (aCT == STANDARD_TYPE(Geom_Circle)) {
aPC = ShapePersistent_Geom_Curve::Translate(Handle(Geom_Circle)::DownCast(theCurve), theMap);
}
else if (aCT == STANDARD_TYPE(Geom_Ellipse)) {
aPC = ShapePersistent_Geom_Curve::Translate(Handle(Geom_Ellipse)::DownCast(theCurve), theMap);
}
else if (aCT == STANDARD_TYPE(Geom_Hyperbola)) {
aPC = ShapePersistent_Geom_Curve::Translate(Handle(Geom_Hyperbola)::DownCast(theCurve), theMap);
}
else if (aCT == STANDARD_TYPE(Geom_Parabola)) {
aPC = ShapePersistent_Geom_Curve::Translate(Handle(Geom_Parabola)::DownCast(theCurve), theMap);
}
else if (aCT == STANDARD_TYPE(Geom_BezierCurve)) {
aPC = ShapePersistent_Geom_Curve::Translate(Handle(Geom_BezierCurve)::DownCast(theCurve), theMap);
}
else if (aCT == STANDARD_TYPE(Geom_BSplineCurve)) {
aPC = ShapePersistent_Geom_Curve::Translate(Handle(Geom_BSplineCurve)::DownCast(theCurve), theMap);
}
else if (aCT == STANDARD_TYPE(Geom_TrimmedCurve)) {
aPC = ShapePersistent_Geom_Curve::Translate(Handle(Geom_TrimmedCurve)::DownCast(theCurve), theMap);
}
else if (aCT == STANDARD_TYPE(Geom_OffsetCurve)) {
aPC = ShapePersistent_Geom_Curve::Translate(Handle(Geom_OffsetCurve)::DownCast(theCurve), theMap);
}
else {
Standard_NullObject::Raise("No mapping for the current Transient Curve");
}
theMap.Bind(theCurve, aPC);
}
}
return aPC;
}
//=======================================================================
//function : Translate
//purpose : Create a persistent object for a surface
//=======================================================================
Handle(ShapePersistent_Geom::Surface)
ShapePersistent_Geom::Translate(const Handle(Geom_Surface)& theSurf,
StdObjMgt_TransientPersistentMap& theMap)
{
Handle(Surface) aPS;
if (!theSurf.IsNull())
{
if (theMap.IsBound(theSurf))
aPS = Handle(Surface)::DownCast(theMap.Find(theSurf));
else
{
Handle(Standard_Type) aST = theSurf->DynamicType();
if (aST == STANDARD_TYPE(Geom_Plane)) {
aPS = ShapePersistent_Geom_Surface::Translate(Handle(Geom_Plane)::DownCast(theSurf), theMap);
}
else if (aST == STANDARD_TYPE(Geom_CylindricalSurface)) {
aPS = ShapePersistent_Geom_Surface::Translate(Handle(Geom_CylindricalSurface)::DownCast(theSurf), theMap);
}
else if (aST == STANDARD_TYPE(Geom_ConicalSurface)) {
aPS = ShapePersistent_Geom_Surface::Translate(Handle(Geom_ConicalSurface)::DownCast(theSurf), theMap);
}
else if (aST == STANDARD_TYPE(Geom_SphericalSurface)) {
aPS = ShapePersistent_Geom_Surface::Translate(Handle(Geom_SphericalSurface)::DownCast(theSurf), theMap);
}
else if (aST == STANDARD_TYPE(Geom_ToroidalSurface)) {
aPS = ShapePersistent_Geom_Surface::Translate(Handle(Geom_ToroidalSurface)::DownCast(theSurf), theMap);
}
else if (aST == STANDARD_TYPE(Geom_SurfaceOfLinearExtrusion)) {
aPS = ShapePersistent_Geom_Surface::Translate(Handle(Geom_SurfaceOfLinearExtrusion)::DownCast(theSurf), theMap);
}
else if (aST == STANDARD_TYPE(Geom_SurfaceOfRevolution)) {
aPS = ShapePersistent_Geom_Surface::Translate(Handle(Geom_SurfaceOfRevolution)::DownCast(theSurf), theMap);
}
else if (aST == STANDARD_TYPE(Geom_BezierSurface)) {
aPS = ShapePersistent_Geom_Surface::Translate(Handle(Geom_BezierSurface)::DownCast(theSurf), theMap);
}
else if (aST == STANDARD_TYPE(Geom_BSplineSurface)) {
aPS = ShapePersistent_Geom_Surface::Translate(Handle(Geom_BSplineSurface)::DownCast(theSurf), theMap);
}
else if (aST == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) {
aPS = ShapePersistent_Geom_Surface::Translate(Handle(Geom_RectangularTrimmedSurface)::DownCast(theSurf), theMap);
}
else if (aST == STANDARD_TYPE(Geom_OffsetSurface)) {
aPS = ShapePersistent_Geom_Surface::Translate(Handle(Geom_OffsetSurface)::DownCast(theSurf), theMap);
}
else {
Standard_NullObject::Raise("No mapping for the current Transient Surface");
}
theMap.Bind(theSurf, aPS);
}
}
return aPS;
}

View File

@@ -15,7 +15,12 @@
#ifndef _ShapePersistent_Geom_HeaderFile
#define _ShapePersistent_Geom_HeaderFile
#include <Standard_NotImplemented.hxx>
#include <Standard_NullObject.hxx>
#include <StdObjMgt_WriteData.hxx>
#include <StdObjMgt_SharedObject.hxx>
#include <StdObjMgt_TransientPersistentMap.hxx>
#include <StdObject_gp_Vectors.hxx>
#include <StdObject_gp_Axes.hxx>
@@ -32,8 +37,7 @@
#include <Geom_Curve.hxx>
#include <Geom_Surface.hxx>
class ShapePersistent_Geom : protected StdObjMgt_SharedObject
class ShapePersistent_Geom : public StdObjMgt_SharedObject
{
public:
class Geometry : public StdObjMgt_Persistent
@@ -41,11 +45,32 @@ public:
public:
//! Read persistent data from a file.
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
//! Write persistent data to a file.
Standard_EXPORT virtual void Write (StdObjMgt_WriteData& theWriteData) const;
//! Gets persistent objects
Standard_EXPORT virtual void PChildren(SequenceOfPersistent& theChildren) const;
//! Returns persistent type name
Standard_EXPORT virtual Standard_CString PName() const { return "PGeom_Geometry"; }
};
protected:
template <class Transient>
struct geometryBase : DelayedBase<Geometry, Transient> {};
struct geometryBase : public DelayedBase<Geometry, Transient>
{
//! Write persistent data to a file.
Standard_EXPORT virtual void Write (StdObjMgt_WriteData&) const
{
Standard_NotImplemented::Raise("ShapePersistent_Geom::geometryBase::Write - not implemented");
}
//! Gets persistent child objects
Standard_EXPORT virtual void PChildren (StdObjMgt_Persistent::SequenceOfPersistent&) const { }
//! Returns persistent type name
Standard_EXPORT virtual Standard_CString PName() const
{
Standard_NotImplemented::Raise("ShapePersistent_Geom::geometryBase::PName - not implemented");
return "";
}
};
template <class Base, class PData>
class subBase : public Base
@@ -54,6 +79,20 @@ protected:
//! Read persistent data from a file.
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData)
{ PData().Read (theReadData); }
//! Write persistent data to a file.
Standard_EXPORT virtual void Write (StdObjMgt_WriteData& theWriteData) const
{ PData().Write(theWriteData); }
//! Gets persistent child objects
Standard_EXPORT virtual void PChildren (StdObjMgt_Persistent::SequenceOfPersistent&) const
{
Standard_NotImplemented::Raise("ShapePersistent_Geom::subBase::PChildren - not implemented");
}
//! Returns persistent type name
Standard_EXPORT virtual Standard_CString PName() const
{
Standard_NotImplemented::Raise("ShapePersistent_Geom::subBase::PName - not implemented");
return "";
}
};
template <class Base, class GpData>
@@ -61,15 +100,29 @@ protected:
{
public:
//! Read persistent data from a file.
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData)
Standard_EXPORT virtual void Read (StdObjMgt_ReadData&) { }
//! Write persistent data to a file.
Standard_EXPORT virtual void Write (StdObjMgt_WriteData&) const { }
//! Gets persistent child objects
Standard_EXPORT virtual void PChildren (StdObjMgt_Persistent::SequenceOfPersistent&) const { }
//! Returns persistent type name
Standard_EXPORT virtual Standard_CString PName() const
{
GpData aData;
theReadData >> aData;
Standard_NotImplemented::Raise("ShapePersistent_Geom::subBase_gp::PName - not implemented");
return "";
}
};
template <class Base>
struct subBase_empty : Base {};
struct subBase_empty : Base
{
//! Returns persistent type name
Standard_EXPORT virtual Standard_CString PName() const
{
Standard_NotImplemented::Raise("ShapePersistent_Geom::subBase_empty::PName - not implemented");
return "";
}
};
template <class Base, class Target, class Data = void>
class instance : public Base
@@ -80,7 +133,20 @@ protected:
{
Data aData;
theReadData >> aData;
this->myTransient = new Target (aData);
this->myTransient = new Target(aData);
}
//! Gets persistent child objects
Standard_EXPORT virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent&) const { }
//! Write persistent data to a file.
Standard_EXPORT virtual void Write(StdObjMgt_WriteData&) const
{
Standard_NotImplemented::Raise("ShapePersistent_Geom::instance::Write - not implemented");
}
//! Returns persistent type name
Standard_EXPORT virtual Standard_CString PName() const
{
Standard_NotImplemented::Raise("ShapePersistent_Geom::instance::PName - not implemented");
return "";
}
};
@@ -105,11 +171,203 @@ public:
typedef geometryBase<Geom_Curve> Curve;
typedef geometryBase<Geom_Surface> Surface;
public:
//! Create a persistent object for a curve
Standard_EXPORT static Handle(Curve) Translate (const Handle(Geom_Curve)& theCurve,
StdObjMgt_TransientPersistentMap& theMap);
//! Create a persistent object for a curve
Standard_EXPORT static Handle(Surface) Translate (const Handle(Geom_Surface)& theSurf,
StdObjMgt_TransientPersistentMap& theMap);
};
//=======================================================================
// Point
//=======================================================================
template<>
void ShapePersistent_Geom::instance<ShapePersistent_Geom::AxisPlacement,
Geom_Axis2Placement>
::Read (StdObjMgt_ReadData& theReadData);
inline Standard_CString ShapePersistent_Geom::subBase_empty<ShapePersistent_Geom::basic>
::PName() const { return "PGeom_Point"; }
//=======================================================================
// CartesianPoint
//=======================================================================
template<>
inline Standard_CString ShapePersistent_Geom::instance<ShapePersistent_Geom::Point,
Geom_CartesianPoint,
gp_Pnt>
::PName() const { return "PGeom_CartesianPoint"; }
template<>
inline void ShapePersistent_Geom::instance<ShapePersistent_Geom::Point,
Geom_CartesianPoint,
gp_Pnt>
::Write(StdObjMgt_WriteData& theWriteData) const
{
Handle(Geom_CartesianPoint) aMyGeom =
Handle(Geom_CartesianPoint)::DownCast(myTransient);
theWriteData << aMyGeom->Pnt();
}
//=======================================================================
// Vector
//=======================================================================
template<>
inline Standard_CString ShapePersistent_Geom::subBase_gp<ShapePersistent_Geom::basic,
gp_Vec>
::PName() const { return "PGeom_Vector"; }
//=======================================================================
// Direction
//=======================================================================
template<>
inline Standard_CString ShapePersistent_Geom::instance<ShapePersistent_Geom::Direction,
Geom_Direction,
gp_Dir>
::PName() const { return "PGeom_Direction"; }
template<>
inline void ShapePersistent_Geom::instance<ShapePersistent_Geom::Direction,
Geom_Direction,
gp_Dir>
::Write(StdObjMgt_WriteData& theWriteData) const
{
Handle(Geom_Direction) aMyGeom =
Handle(Geom_Direction)::DownCast(myTransient);
theWriteData << aMyGeom->Dir();
}
//=======================================================================
// VectorWithMagnitude
//=======================================================================
template<>
inline Standard_CString ShapePersistent_Geom::instance<ShapePersistent_Geom::VectorWithMagnitude,
Geom_VectorWithMagnitude,
gp_Vec>
::PName() const { return "PGeom_VectorWithMagnitude"; }
template<>
inline void ShapePersistent_Geom::instance<ShapePersistent_Geom::VectorWithMagnitude,
Geom_VectorWithMagnitude,
gp_Vec>
::Write(StdObjMgt_WriteData& theWriteData) const
{
Handle(Geom_VectorWithMagnitude) aMyGeom =
Handle(Geom_VectorWithMagnitude)::DownCast(myTransient);
theWriteData << aMyGeom->Vec();
}
//=======================================================================
// AxisPlacement
//=======================================================================
template<>
inline Standard_CString ShapePersistent_Geom::subBase_gp<ShapePersistent_Geom::basic,
gp_Ax1>
::PName() const { return "PGeom_AxisPlacement"; }
//=======================================================================
// Axis1Placement
//=======================================================================
template<>
inline Standard_CString ShapePersistent_Geom::instance<ShapePersistent_Geom::Axis1Placement,
Geom_Axis1Placement,
gp_Ax1>
::PName() const { return "PGeom_Axis1Placement"; }
template<>
inline void ShapePersistent_Geom::instance<ShapePersistent_Geom::Axis1Placement,
Geom_Axis1Placement,
gp_Ax1>
::Write(StdObjMgt_WriteData& theWriteData) const
{
Handle(Geom_Axis1Placement) aMyGeom =
Handle(Geom_Axis1Placement)::DownCast(myTransient);
write(theWriteData, aMyGeom->Ax1());
}
//=======================================================================
// Axis2Placement
//=======================================================================
template<>
inline Standard_CString ShapePersistent_Geom::instance<ShapePersistent_Geom::AxisPlacement,
Geom_Axis2Placement>
::PName() const { return "PGeom_Axis2Placement"; }
template<>
inline void ShapePersistent_Geom::instance<ShapePersistent_Geom::AxisPlacement,
Geom_Axis2Placement>
::Read (StdObjMgt_ReadData& theReadData)
{
gp_Ax1 anAxis;
gp_Dir anXDirection;
theReadData >> anAxis >> anXDirection;
myTransient = new Geom_Axis2Placement(anAxis.Location(),
anAxis.Direction(),
anXDirection);
}
template<>
inline void ShapePersistent_Geom::instance<ShapePersistent_Geom::AxisPlacement,
Geom_Axis2Placement>
::Write (StdObjMgt_WriteData& theWriteData) const
{
Handle(Geom_Axis2Placement) aMyGeom =
Handle(Geom_Axis2Placement)::DownCast(myTransient);
const gp_Ax1& anAxis = aMyGeom->Axis();
const gp_Dir& anXDirection = aMyGeom->Direction();
write(theWriteData, anAxis) << anXDirection;
}
//=======================================================================
// Transformation
//=======================================================================
template<>
inline Standard_CString ShapePersistent_Geom::instance<ShapePersistent_Geom::Transformation,
Geom_Transformation,
gp_Trsf>
::PName() const { return "PGeom_Transformation"; }
template<>
inline void ShapePersistent_Geom::instance<ShapePersistent_Geom::Transformation,
Geom_Transformation,
gp_Trsf>
::Write (StdObjMgt_WriteData& theWriteData) const
{
theWriteData << myTransient->Trsf();
}
//=======================================================================
// Geometry
//=======================================================================
template<>
inline Standard_CString ShapePersistent_Geom::geometryBase<Geom_Geometry>
::PName() const { return "PGeom_Geometry"; }
//=======================================================================
// Curve
//=======================================================================
template<>
inline Standard_CString ShapePersistent_Geom::geometryBase<Geom_Curve>
::PName() const { return "PGeom_Curve"; }
//=======================================================================
// Surface
//=======================================================================
template<>
inline Standard_CString ShapePersistent_Geom::geometryBase<Geom_Surface>
::PName() const { return "PGeom_Surface"; }
#endif

View File

@@ -0,0 +1,185 @@
#include <Standard_NullObject.hxx>
#include <ShapePersistent_Geom2d.hxx>
#include <ShapePersistent_Geom2d_Curve.hxx>
#include <Geom2d_BezierCurve.hxx>
#include <Geom2d_BSplineCurve.hxx>
#include <Geom2d_TrimmedCurve.hxx>
#include <Geom2d_OffsetCurve.hxx>
//=======================================================================
// Geometry
//=======================================================================
template<>
Standard_CString ShapePersistent_Geom::geometryBase<Geom2d_Geometry>
::PName() const { return "PGeom2d_Geometry"; }
//=======================================================================
// Point
//=======================================================================
template<>
Standard_CString ShapePersistent_Geom::subBase_empty<ShapePersistent_Geom2d::geometryBase<Geom2d_Geometry> >
::PName() const { return "PGeom2d_Point"; }
//=======================================================================
// CartesianPoint
//=======================================================================
template<>
Standard_CString ShapePersistent_Geom::instance<ShapePersistent_Geom2d::Point,
Geom2d_CartesianPoint,
gp_Pnt2d>
::PName() const { return "PGeom2d_CartesianPoint"; }
template<>
void ShapePersistent_Geom::instance<ShapePersistent_Geom2d::Point,
Geom2d_CartesianPoint,
gp_Pnt2d>
::Write(StdObjMgt_WriteData& theWriteData) const
{
Handle(Geom2d_CartesianPoint) aMyGeom =
Handle(Geom2d_CartesianPoint)::DownCast(myTransient);
theWriteData << aMyGeom->Pnt2d();
}
//=======================================================================
// Direction
//=======================================================================
template<>
Standard_CString ShapePersistent_Geom::instance<ShapePersistent_Geom2d::Direction,
Geom2d_Direction,
gp_Dir2d>
::PName() const { return "PGeom2d_Direction"; }
template<>
void ShapePersistent_Geom::instance<ShapePersistent_Geom2d::Direction,
Geom2d_Direction,
gp_Dir2d>
::Write(StdObjMgt_WriteData& theWriteData) const
{
Handle(Geom2d_Direction) aMyGeom =
Handle(Geom2d_Direction)::DownCast(myTransient);
theWriteData << aMyGeom->Dir2d();
}
//=======================================================================
// VectorWithMagnitude
//=======================================================================
template<>
Standard_CString ShapePersistent_Geom::instance<ShapePersistent_Geom2d::VectorWithMagnitude,
Geom2d_VectorWithMagnitude,
gp_Vec2d>
::PName() const { return "PGeom2d_VectorWithMagnitude"; }
template<>
void ShapePersistent_Geom::instance<ShapePersistent_Geom2d::VectorWithMagnitude,
Geom2d_VectorWithMagnitude,
gp_Vec2d>
::Write(StdObjMgt_WriteData& theWriteData) const
{
Handle(Geom2d_VectorWithMagnitude) aMyGeom =
Handle(Geom2d_VectorWithMagnitude)::DownCast(myTransient);
theWriteData << aMyGeom->Vec2d();
}
//=======================================================================
// AxisPlacement
//=======================================================================
template<>
Standard_CString ShapePersistent_Geom::instance<ShapePersistent_Geom2d::AxisPlacement,
Geom2d_AxisPlacement,
gp_Ax2d>
::PName() const { return "PGeom2d_AxisPlacement"; }
template<>
void ShapePersistent_Geom::instance<ShapePersistent_Geom2d::AxisPlacement,
Geom2d_AxisPlacement,
gp_Ax2d>
::Write(StdObjMgt_WriteData& theWriteData) const
{
Handle(Geom2d_AxisPlacement) aMyGeom =
Handle(Geom2d_AxisPlacement)::DownCast(myTransient);
write(theWriteData, aMyGeom->Ax2d());
}
//=======================================================================
// Transformation
//=======================================================================
template<>
Standard_CString ShapePersistent_Geom::instance<ShapePersistent_Geom2d::Transformation,
Geom2d_Transformation,
gp_Trsf2d>
::PName() const { return "PGeom2d_Transformation"; }
template<>
void ShapePersistent_Geom::instance<ShapePersistent_Geom2d::Transformation,
Geom2d_Transformation,
gp_Trsf2d>
::PChildren(StdObjMgt_Persistent::SequenceOfPersistent&) const
{
}
template<>
void ShapePersistent_Geom2d::instance<ShapePersistent_Geom2d::Transformation,
Geom2d_Transformation,
gp_Trsf2d>
::Write(StdObjMgt_WriteData& theWriteData) const
{
theWriteData << myTransient->Trsf2d();
}
//=======================================================================
// Curve
//=======================================================================
template<>
Standard_CString ShapePersistent_Geom::geometryBase<Geom2d_Curve>
::PName() const { return "PGeom2d_Curve"; }
Handle(ShapePersistent_Geom2d::Curve)
ShapePersistent_Geom2d::Translate(const Handle(Geom2d_Curve)& theCurve,
StdObjMgt_TransientPersistentMap& theMap)
{
Handle(ShapePersistent_Geom2d::Curve) aPC;
if (!theCurve.IsNull())
{
if (theMap.IsBound(theCurve))
aPC = Handle(ShapePersistent_Geom2d::Curve)::DownCast(theMap.Find(theCurve));
else
{
Handle(Standard_Type) aCT = theCurve->DynamicType();
if (aCT == STANDARD_TYPE(Geom2d_Line)) {
aPC = ShapePersistent_Geom2d_Curve::Translate(Handle(Geom2d_Line)::DownCast(theCurve), theMap);
}
else if (aCT == STANDARD_TYPE(Geom2d_Circle)) {
aPC = ShapePersistent_Geom2d_Curve::Translate(Handle(Geom2d_Circle)::DownCast(theCurve), theMap);
}
else if (aCT == STANDARD_TYPE(Geom2d_Ellipse)) {
aPC = ShapePersistent_Geom2d_Curve::Translate(Handle(Geom2d_Ellipse)::DownCast(theCurve), theMap);
}
else if (aCT == STANDARD_TYPE(Geom2d_Hyperbola)) {
aPC = ShapePersistent_Geom2d_Curve::Translate(Handle(Geom2d_Hyperbola)::DownCast(theCurve), theMap);
}
else if (aCT == STANDARD_TYPE(Geom2d_Parabola)) {
aPC = ShapePersistent_Geom2d_Curve::Translate(Handle(Geom2d_Parabola)::DownCast(theCurve), theMap);
}
else if (aCT == STANDARD_TYPE(Geom2d_BezierCurve)) {
aPC = ShapePersistent_Geom2d_Curve::Translate(Handle(Geom2d_BezierCurve)::DownCast(theCurve), theMap);
}
else if (aCT == STANDARD_TYPE(Geom2d_BSplineCurve)) {
aPC = ShapePersistent_Geom2d_Curve::Translate(Handle(Geom2d_BSplineCurve)::DownCast(theCurve), theMap);
}
else if (aCT == STANDARD_TYPE(Geom2d_TrimmedCurve)) {
aPC = ShapePersistent_Geom2d_Curve::Translate(Handle(Geom2d_TrimmedCurve)::DownCast(theCurve), theMap);
}
else if (aCT == STANDARD_TYPE(Geom2d_OffsetCurve)) {
aPC = ShapePersistent_Geom2d_Curve::Translate(Handle(Geom2d_OffsetCurve)::DownCast(theCurve), theMap);
}
else {
Standard_NullObject::Raise("No mapping for the current Transient Curve");
}
theMap.Bind(theCurve, aPC);
}
}
return aPC;
}

View File

@@ -15,6 +15,7 @@
#ifndef _ShapePersistent_Geom2d_HeaderFile
#define _ShapePersistent_Geom2d_HeaderFile
#include <StdObjMgt_TransientPersistentMap.hxx>
#include <ShapePersistent_Geom.hxx>
#include <Geom2d_CartesianPoint.hxx>
@@ -24,8 +25,7 @@
#include <Geom2d_Transformation.hxx>
#include <Geom2d_Curve.hxx>
class ShapePersistent_Geom2d : protected ShapePersistent_Geom
class ShapePersistent_Geom2d : public ShapePersistent_Geom
{
typedef geometryBase<Geom2d_Geometry> basic;
@@ -46,6 +46,114 @@ public:
gp_Trsf2d> Transformation;
typedef geometryBase<Geom2d_Curve> Curve;
public:
//! Create a persistent object for a curve
Standard_EXPORT static Handle(Curve) Translate (const Handle(Geom2d_Curve)& theCurve,
StdObjMgt_TransientPersistentMap& theMap);
};
//=======================================================================
// Geometry
//=======================================================================
template<>
Standard_CString ShapePersistent_Geom::geometryBase<Geom2d_Geometry>
::PName() const;
//=======================================================================
// Point
//=======================================================================
template<>
Standard_CString ShapePersistent_Geom::subBase_empty<
ShapePersistent_Geom2d::geometryBase<Geom2d_Geometry> >
::PName() const;
//=======================================================================
// CartesianPoint
//=======================================================================
template<>
Standard_CString ShapePersistent_Geom::instance<ShapePersistent_Geom2d::Point,
Geom2d_CartesianPoint,
gp_Pnt2d>
::PName() const;
template<>
void ShapePersistent_Geom::instance<ShapePersistent_Geom2d::Point,
Geom2d_CartesianPoint,
gp_Pnt2d>
::Write(StdObjMgt_WriteData& theWriteData) const;
//=======================================================================
// Direction
//=======================================================================
template<>
Standard_CString ShapePersistent_Geom::instance<ShapePersistent_Geom2d::Direction,
Geom2d_Direction,
gp_Dir2d>
::PName() const;
template<>
void ShapePersistent_Geom::instance<ShapePersistent_Geom2d::Direction,
Geom2d_Direction,
gp_Dir2d>
::Write(StdObjMgt_WriteData& theWriteData) const;
//=======================================================================
// VectorWithMagnitude
//=======================================================================
template<>
Standard_CString ShapePersistent_Geom::instance<ShapePersistent_Geom2d::VectorWithMagnitude,
Geom2d_VectorWithMagnitude,
gp_Vec2d>
::PName() const;
template<>
void ShapePersistent_Geom::instance<ShapePersistent_Geom2d::VectorWithMagnitude,
Geom2d_VectorWithMagnitude,
gp_Vec2d>
::Write(StdObjMgt_WriteData& theWriteData) const;
//=======================================================================
// AxisPlacement
//=======================================================================
template<>
Standard_CString ShapePersistent_Geom::instance<ShapePersistent_Geom2d::AxisPlacement,
Geom2d_AxisPlacement,
gp_Ax2d>
::PName() const;
template<>
void ShapePersistent_Geom::instance<ShapePersistent_Geom2d::AxisPlacement,
Geom2d_AxisPlacement,
gp_Ax2d>
::Write(StdObjMgt_WriteData& theWriteData) const;
//=======================================================================
// Transformation
//=======================================================================
template<>
Standard_CString ShapePersistent_Geom::instance<ShapePersistent_Geom2d::Transformation,
Geom2d_Transformation,
gp_Trsf2d>
::PName() const;
template<>
void ShapePersistent_Geom::instance<ShapePersistent_Geom2d::Transformation,
Geom2d_Transformation,
gp_Trsf2d>
::PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
template<>
void ShapePersistent_Geom::instance<ShapePersistent_Geom2d::Transformation,
Geom2d_Transformation,
gp_Trsf2d>
::Write(StdObjMgt_WriteData& theWriteData) const;
//=======================================================================
// Curve
//=======================================================================
template<>
Standard_CString ShapePersistent_Geom2d::geometryBase<Geom2d_Curve>
::PName() const;
#endif

View File

@@ -11,6 +11,8 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <Standard_NullObject.hxx>
#include <ShapePersistent_Geom2d_Curve.hxx>
#include <Geom2d_BezierCurve.hxx>
@@ -74,3 +76,308 @@ Handle(Geom2d_Curve) ShapePersistent_Geom2d_Curve::pOffset::Import() const
return new Geom2d_OffsetCurve (myBasisCurve->Import(), myOffsetValue);
}
//=======================================================================
// Line
//=======================================================================
template<>
Standard_CString ShapePersistent_Geom2d_Curve::instance<ShapePersistent_Geom2d::Curve,
Geom2d_Line,
gp_Ax2d>
::PName() const { return "PGeom2d_Line"; }
template<>
void ShapePersistent_Geom2d_Curve::instance<ShapePersistent_Geom2d::Curve,
Geom2d_Line,
gp_Ax2d>
::Write(StdObjMgt_WriteData& theWriteData) const
{
Handle(Geom2d_Line) aMyGeom =
Handle(Geom2d_Line)::DownCast(myTransient);
write(theWriteData, aMyGeom->Position());
}
Handle(ShapePersistent_Geom2d::Curve)
ShapePersistent_Geom2d_Curve::Translate(const Handle(Geom2d_Line)& theCurve,
StdObjMgt_TransientPersistentMap& theMap)
{
Handle(ShapePersistent_Geom2d::Curve) aPC;
if (!theCurve.IsNull())
{
if (theMap.IsBound(theCurve))
aPC = Handle(ShapePersistent_Geom2d::Curve)::DownCast(theMap.Find(theCurve));
else {
Handle(Line) aPT = new Line;
aPT->myTransient = theCurve;
aPC = aPT;
}
}
return aPC;
}
//=======================================================================
// Conic
//=======================================================================
template<>
Standard_CString ShapePersistent_Geom2d_Curve::subBase_gp<ShapePersistent_Geom2d::Curve,
gp_Ax22d>
::PName() const { return "PGeom2d_Conic"; }
//=======================================================================
// Circle
//=======================================================================
template<>
Standard_CString ShapePersistent_Geom2d_Curve::instance<ShapePersistent_Geom2d_Curve::Conic,
Geom2d_Circle,
gp_Circ2d>
::PName() const { return "PGeom2d_Circle"; }
template<>
void ShapePersistent_Geom2d_Curve::instance<ShapePersistent_Geom2d_Curve::Conic,
Geom2d_Circle,
gp_Circ2d>
::Write(StdObjMgt_WriteData& theWriteData) const
{
Handle(Geom2d_Circle) aMyGeom =
Handle(Geom2d_Circle)::DownCast(myTransient);
theWriteData << aMyGeom->Circ2d();
}
Handle(ShapePersistent_Geom2d::Curve)
ShapePersistent_Geom2d_Curve::Translate(const Handle(Geom2d_Circle)& theCurve,
StdObjMgt_TransientPersistentMap& theMap)
{
Handle(ShapePersistent_Geom2d::Curve) aPC;
if (!theCurve.IsNull())
{
if (theMap.IsBound(theCurve))
aPC = Handle(ShapePersistent_Geom2d::Curve)::DownCast(theMap.Find(theCurve));
else {
Handle(Circle) aPT = new Circle;
aPT->myTransient = theCurve;
aPC = aPT;
}
}
return aPC;
}
//=======================================================================
// Ellipse
//=======================================================================
template<>
Standard_CString ShapePersistent_Geom2d_Curve::instance<ShapePersistent_Geom2d_Curve::Conic,
Geom2d_Ellipse,
gp_Elips2d>
::PName() const { return "PGeom2d_Ellipse"; }
template<>
void ShapePersistent_Geom2d_Curve::instance<ShapePersistent_Geom2d_Curve::Conic,
Geom2d_Ellipse,
gp_Elips2d>
::Write(StdObjMgt_WriteData& theWriteData) const
{
Handle(Geom2d_Ellipse) aMyGeom =
Handle(Geom2d_Ellipse)::DownCast(myTransient);
theWriteData << aMyGeom->Elips2d();
}
Handle(ShapePersistent_Geom2d::Curve)
ShapePersistent_Geom2d_Curve::Translate(const Handle(Geom2d_Ellipse)& theCurve,
StdObjMgt_TransientPersistentMap& theMap)
{
Handle(ShapePersistent_Geom2d::Curve) aPC;
if (!theCurve.IsNull())
{
if (theMap.IsBound(theCurve))
aPC = Handle(ShapePersistent_Geom2d::Curve)::DownCast(theMap.Find(theCurve));
else {
Handle(Ellipse) aPT = new Ellipse;
aPT->myTransient = theCurve;
aPC = aPT;
}
}
return aPC;
}
//=======================================================================
// Hyperbola
//=======================================================================
template<>
Standard_CString ShapePersistent_Geom2d_Curve::instance<ShapePersistent_Geom2d_Curve::Conic,
Geom2d_Hyperbola,
gp_Hypr2d>
::PName() const { return "PGeom2d_Hyperbola"; }
template<>
void ShapePersistent_Geom2d_Curve::instance<ShapePersistent_Geom2d_Curve::Conic,
Geom2d_Hyperbola,
gp_Hypr2d>
::Write(StdObjMgt_WriteData& theWriteData) const
{
Handle(Geom2d_Hyperbola) aMyGeom =
Handle(Geom2d_Hyperbola)::DownCast(myTransient);
theWriteData << aMyGeom->Hypr2d();
}
Handle(ShapePersistent_Geom2d::Curve)
ShapePersistent_Geom2d_Curve::Translate(const Handle(Geom2d_Hyperbola)& theCurve,
StdObjMgt_TransientPersistentMap& theMap)
{
Handle(ShapePersistent_Geom2d::Curve) aPC;
if (!theCurve.IsNull())
{
if (theMap.IsBound(theCurve))
aPC = Handle(ShapePersistent_Geom2d::Curve)::DownCast(theMap.Find(theCurve));
else {
Handle(Hyperbola) aPT = new Hyperbola;
aPT->myTransient = theCurve;
aPC = aPT;
}
}
return aPC;
}
//=======================================================================
// Parabola
//=======================================================================
template<>
Standard_CString ShapePersistent_Geom2d_Curve::instance<ShapePersistent_Geom2d_Curve::Conic,
Geom2d_Parabola,
gp_Parab2d>
::PName() const { return "PGeom2d_Hyperbola"; }
template<>
void ShapePersistent_Geom2d_Curve::instance<ShapePersistent_Geom2d_Curve::Conic,
Geom2d_Parabola,
gp_Parab2d>
::Write(StdObjMgt_WriteData& theWriteData) const
{
Handle(Geom2d_Parabola) aMyGeom =
Handle(Geom2d_Parabola)::DownCast(myTransient);
theWriteData << aMyGeom->Parab2d();
}
Handle(ShapePersistent_Geom2d::Curve)
ShapePersistent_Geom2d_Curve::Translate(const Handle(Geom2d_Parabola)& theCurve,
StdObjMgt_TransientPersistentMap& theMap)
{
Handle(ShapePersistent_Geom2d::Curve) aPC;
if (!theCurve.IsNull())
{
if (theMap.IsBound(theCurve))
aPC = Handle(ShapePersistent_Geom2d::Curve)::DownCast(theMap.Find(theCurve));
else {
Handle(Parabola) aPT = new Parabola;
aPT->myTransient = theCurve;
aPC = aPT;
}
}
return aPC;
}
//=======================================================================
// BezierCurve
//=======================================================================
Handle(ShapePersistent_Geom2d::Curve)
ShapePersistent_Geom2d_Curve::Translate(const Handle(Geom2d_BezierCurve)& theCurve,
StdObjMgt_TransientPersistentMap& theMap)
{
Handle(ShapePersistent_Geom2d::Curve) aPC;
if (!theCurve.IsNull())
{
if (theMap.IsBound(theCurve))
aPC = Handle(ShapePersistent_Geom2d::Curve)::DownCast(theMap.Find(theCurve));
else {
Handle(Bezier) aPBC = new Bezier;
Handle(pBezier) aPpBC = new pBezier;
aPpBC->myRational = theCurve->IsRational();
aPpBC->myPoles = StdLPersistent_HArray1::Translate<TColgp_HArray1OfPnt2d>("PColgp_HArray1OfPnt2d", theCurve->Poles());
if (theCurve->IsRational()) {
aPpBC->myWeights = StdLPersistent_HArray1::Translate<TColStd_HArray1OfReal>(*theCurve->Weights());
}
aPBC->myPersistent = aPpBC;
aPC = aPBC;
}
}
return aPC;
}
//=======================================================================
// BSplineCurve
//=======================================================================
Handle(ShapePersistent_Geom2d::Curve)
ShapePersistent_Geom2d_Curve::Translate(const Handle(Geom2d_BSplineCurve)& theCurve,
StdObjMgt_TransientPersistentMap& theMap)
{
Handle(ShapePersistent_Geom2d::Curve) aPC;
if (!theCurve.IsNull())
{
if (theMap.IsBound(theCurve))
aPC = Handle(ShapePersistent_Geom2d::Curve)::DownCast(theMap.Find(theCurve));
else {
Handle(BSpline) aPBSC = new BSpline;
Handle(pBSpline) aPpBSC = new pBSpline;
aPpBSC->myRational = theCurve->IsRational();
aPpBSC->myPeriodic = theCurve->IsPeriodic();
aPpBSC->mySpineDegree = theCurve->Degree();
aPpBSC->myPoles = StdLPersistent_HArray1::Translate<TColgp_HArray1OfPnt2d>("PColgp_HArray1OfPnt2d", theCurve->Poles());
if (theCurve->IsRational()) {
aPpBSC->myWeights = StdLPersistent_HArray1::Translate<TColStd_HArray1OfReal>(*theCurve->Weights());
}
aPpBSC->myKnots = StdLPersistent_HArray1::Translate<TColStd_HArray1OfReal>(theCurve->Knots());
aPpBSC->myMultiplicities = StdLPersistent_HArray1::Translate<TColStd_HArray1OfInteger>(theCurve->Multiplicities());
aPBSC->myPersistent = aPpBSC;
aPC = aPBSC;
}
}
return aPC;
}
//=======================================================================
// TrimmedCurve
//=======================================================================
Handle(ShapePersistent_Geom2d::Curve)
ShapePersistent_Geom2d_Curve::Translate(const Handle(Geom2d_TrimmedCurve)& theCurve,
StdObjMgt_TransientPersistentMap& theMap)
{
Handle(ShapePersistent_Geom2d::Curve) aPC = new Trimmed;
if (!theCurve.IsNull())
{
if (theMap.IsBound(theCurve))
aPC = Handle(ShapePersistent_Geom2d::Curve)::DownCast(theMap.Find(theCurve));
else {
Handle(Trimmed) aPTC = new Trimmed;
Handle(pTrimmed) aPpTC = new pTrimmed;
aPpTC->myFirstU = theCurve->FirstParameter();
aPpTC->myLastU = theCurve->LastParameter();
aPpTC->myBasisCurve = ShapePersistent_Geom2d::Translate(theCurve->BasisCurve(), theMap);
aPTC->myPersistent = aPpTC;
aPC = aPTC;
}
}
return aPC;
}
//=======================================================================
// OffsetCurve
//=======================================================================
Handle(ShapePersistent_Geom2d::Curve)
ShapePersistent_Geom2d_Curve::Translate(const Handle(Geom2d_OffsetCurve)& theCurve,
StdObjMgt_TransientPersistentMap& theMap)
{
Handle(ShapePersistent_Geom2d::Curve) aPC = new Offset;
if (!theCurve.IsNull())
{
if (theMap.IsBound(theCurve))
aPC = Handle(ShapePersistent_Geom2d::Curve)::DownCast(theMap.Find(theCurve));
else {
Handle(Offset) aPOC = new Offset;
Handle(pOffset) aPpOC = new pOffset;
aPpOC->myOffsetValue = theCurve->Offset();
aPpOC->myBasisCurve = ShapePersistent_Geom2d::Translate(theCurve->BasisCurve(), theMap);
aPOC->myPersistent = aPpOC;
aPC = aPOC;
}
}
return aPC;
}

View File

@@ -15,6 +15,8 @@
#ifndef _ShapePersistent_Geom2d_Curve_HeaderFile
#define _ShapePersistent_Geom2d_Curve_HeaderFile
#include <StdObjMgt_TransientPersistentMap.hxx>
#include <ShapePersistent_Geom2d.hxx>
#include <ShapePersistent_HArray1.hxx>
#include <StdLPersistent_HArray1.hxx>
@@ -24,6 +26,10 @@
#include <Geom2d_Ellipse.hxx>
#include <Geom2d_Hyperbola.hxx>
#include <Geom2d_Parabola.hxx>
#include <Geom2d_BezierCurve.hxx>
#include <Geom2d_BSplineCurve.hxx>
#include <Geom2d_TrimmedCurve.hxx>
#include <Geom2d_OffsetCurve.hxx>
#include <gp_Circ2d.hxx>
#include <gp_Elips2d.hxx>
@@ -31,7 +37,7 @@
#include <gp_Parab2d.hxx>
class ShapePersistent_Geom2d_Curve : protected ShapePersistent_Geom2d
class ShapePersistent_Geom2d_Curve : public ShapePersistent_Geom2d
{
typedef Curve::PersistentBase pBase;
@@ -39,9 +45,20 @@ class ShapePersistent_Geom2d_Curve : protected ShapePersistent_Geom2d
class pBezier : public pBounded
{
friend class ShapePersistent_Geom2d_Curve;
public:
inline void Read (StdObjMgt_ReadData& theReadData)
{ theReadData >> myRational >> myPoles >> myWeights; }
inline void Write (StdObjMgt_WriteData& theWriteData) const
{ theWriteData << myRational << myPoles << myWeights; }
inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
{
theChildren.Append(myPoles);
theChildren.Append(myWeights);
}
inline Standard_CString PName() const
{ return "PGeom2d_BezierCurve"; }
virtual Handle(Geom2d_Curve) Import() const;
@@ -53,12 +70,28 @@ class ShapePersistent_Geom2d_Curve : protected ShapePersistent_Geom2d
class pBSpline : public pBounded
{
friend class ShapePersistent_Geom2d_Curve;
public:
inline void Read (StdObjMgt_ReadData& theReadData)
{
theReadData >> myRational >> myPeriodic >> mySpineDegree;
theReadData >> myPoles >> myWeights >> myKnots >> myMultiplicities;
}
inline void Write (StdObjMgt_WriteData& theWriteData) const
{
theWriteData << myRational << myPeriodic << mySpineDegree;
theWriteData << myPoles << myWeights << myKnots << myMultiplicities;
}
inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
{
theChildren.Append(myPoles);
theChildren.Append(myWeights);
theChildren.Append(myKnots);
theChildren.Append(myMultiplicities);
}
inline Standard_CString PName() const
{ return "PGeom2d_BSplineCurve"; }
virtual Handle(Geom2d_Curve) Import() const;
@@ -74,9 +107,17 @@ class ShapePersistent_Geom2d_Curve : protected ShapePersistent_Geom2d
class pTrimmed : public pBounded
{
friend class ShapePersistent_Geom2d_Curve;
public:
inline void Read (StdObjMgt_ReadData& theReadData)
{ theReadData >> myBasisCurve >> myFirstU >> myLastU; }
inline void Write (StdObjMgt_WriteData& theWriteData) const
{ theWriteData << myBasisCurve << myFirstU << myLastU; }
inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
{ theChildren.Append(myBasisCurve); }
inline Standard_CString PName() const
{ return "PGeom2d_TrimmedCurve"; }
virtual Handle(Geom2d_Curve) Import() const;
@@ -88,9 +129,17 @@ class ShapePersistent_Geom2d_Curve : protected ShapePersistent_Geom2d
class pOffset : public pBase
{
friend class ShapePersistent_Geom2d_Curve;
public:
inline void Read (StdObjMgt_ReadData& theReadData)
{ theReadData >> myBasisCurve >> myOffsetValue; }
inline void Write (StdObjMgt_WriteData& theWriteData) const
{ theWriteData << myBasisCurve << myOffsetValue; }
inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
{ theChildren.Append(myBasisCurve); }
inline Standard_CString PName() const
{ return "PGeom2d_OffsetCurve"; }
virtual Handle(Geom2d_Curve) Import() const;
@@ -114,6 +163,118 @@ public:
typedef Delayed<Bounded, pTrimmed> Trimmed;
typedef Delayed<Curve, pOffset> Offset;
public:
//! Create a persistent object for a line
Standard_EXPORT static Handle(Curve) Translate (const Handle(Geom2d_Line)& theCurve,
StdObjMgt_TransientPersistentMap& theMap);
//! Create a persistent object for a circle
Standard_EXPORT static Handle(Curve) Translate (const Handle(Geom2d_Circle)& theCurve,
StdObjMgt_TransientPersistentMap& theMap);
//! Create a persistent object for a ellipse
Standard_EXPORT static Handle(Curve) Translate (const Handle(Geom2d_Ellipse)& theCurve,
StdObjMgt_TransientPersistentMap& theMap);
//! Create a persistent object for a hyperbola
Standard_EXPORT static Handle(Curve) Translate (const Handle(Geom2d_Hyperbola)& theCurve,
StdObjMgt_TransientPersistentMap& theMap);
//! Create a persistent object for a parabola
Standard_EXPORT static Handle(Curve) Translate (const Handle(Geom2d_Parabola)& theCurve,
StdObjMgt_TransientPersistentMap& theMap);
//! Create a persistent object for a Bezier curve
Standard_EXPORT static Handle(Curve) Translate (const Handle(Geom2d_BezierCurve)& theCurve,
StdObjMgt_TransientPersistentMap& theMap);
//! Create a persistent object for a BSpline curve
Standard_EXPORT static Handle(Curve) Translate (const Handle(Geom2d_BSplineCurve)& theCurve,
StdObjMgt_TransientPersistentMap& theMap);
//! Create a persistent object for a trimmed curve
Standard_EXPORT static Handle(Curve) Translate (const Handle(Geom2d_TrimmedCurve)& theCurve,
StdObjMgt_TransientPersistentMap& theMap);
//! Create a persistent object for an offset curve
Standard_EXPORT static Handle(Curve) Translate (const Handle(Geom2d_OffsetCurve)& theCurve,
StdObjMgt_TransientPersistentMap& theMap);
};
//=======================================================================
// Line
//=======================================================================
template<>
Standard_CString ShapePersistent_Geom2d_Curve::instance<ShapePersistent_Geom2d::Curve,
Geom2d_Line,
gp_Ax2d>
::PName() const;
template<>
void ShapePersistent_Geom2d_Curve::instance<ShapePersistent_Geom2d::Curve,
Geom2d_Line,
gp_Ax2d>
::Write(StdObjMgt_WriteData& theWriteData) const;
//=======================================================================
// Conic
//=======================================================================
template<>
Standard_CString ShapePersistent_Geom2d_Curve::subBase_gp<ShapePersistent_Geom2d::Curve,
gp_Ax22d>
::PName() const;
//=======================================================================
// Circle
//=======================================================================
template<>
Standard_CString ShapePersistent_Geom2d_Curve::instance<ShapePersistent_Geom2d_Curve::Conic,
Geom2d_Circle,
gp_Circ2d>
::PName() const;
template<>
void ShapePersistent_Geom2d_Curve::instance<ShapePersistent_Geom2d_Curve::Conic,
Geom2d_Circle,
gp_Circ2d>
::Write(StdObjMgt_WriteData& theWriteData) const;
//=======================================================================
// Ellipse
//=======================================================================
template<>
Standard_CString ShapePersistent_Geom2d_Curve::instance<ShapePersistent_Geom2d_Curve::Conic,
Geom2d_Ellipse,
gp_Elips2d>
::PName() const;
template<>
void ShapePersistent_Geom2d_Curve::instance<ShapePersistent_Geom2d_Curve::Conic,
Geom2d_Ellipse,
gp_Elips2d>
::Write(StdObjMgt_WriteData& theWriteData) const;
//=======================================================================
// Hyperbola
//=======================================================================
template<>
Standard_CString ShapePersistent_Geom2d_Curve::instance<ShapePersistent_Geom2d_Curve::Conic,
Geom2d_Hyperbola,
gp_Hypr2d>
::PName() const;
template<>
void ShapePersistent_Geom2d_Curve::instance<ShapePersistent_Geom2d_Curve::Conic,
Geom2d_Hyperbola,
gp_Hypr2d>
::Write(StdObjMgt_WriteData& theWriteData) const;
//=======================================================================
// Parabola
//=======================================================================
template<>
Standard_CString ShapePersistent_Geom2d_Curve::instance<ShapePersistent_Geom2d_Curve::Conic,
Geom2d_Parabola,
gp_Parab2d>
::PName() const;
template<>
void ShapePersistent_Geom2d_Curve::instance<ShapePersistent_Geom2d_Curve::Conic,
Geom2d_Parabola,
gp_Parab2d>
::Write(StdObjMgt_WriteData& theWriteData) const;
#endif

View File

@@ -11,6 +11,8 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <Standard_NullObject.hxx>
#include <ShapePersistent_Geom_Curve.hxx>
#include <Geom_BezierCurve.hxx>
@@ -75,3 +77,309 @@ Handle(Geom_Curve) ShapePersistent_Geom_Curve::pOffset::Import() const
return new Geom_OffsetCurve
(myBasisCurve->Import(), myOffsetValue, myOffsetDirection);
}
//=======================================================================
// Line
//=======================================================================
template<>
Standard_CString ShapePersistent_Geom::instance<ShapePersistent_Geom::Curve,
Geom_Line,
gp_Ax1>
::PName() const { return "PGeom_Line"; }
template<>
void ShapePersistent_Geom::instance<ShapePersistent_Geom::Curve,
Geom_Line,
gp_Ax1>
::Write(StdObjMgt_WriteData& theWriteData) const
{
Handle(Geom_Line) aMyGeom =
Handle(Geom_Line)::DownCast(myTransient);
write(theWriteData, aMyGeom->Position());
}
Handle(ShapePersistent_Geom::Curve)
ShapePersistent_Geom_Curve::Translate(const Handle(Geom_Line)& theCurve,
StdObjMgt_TransientPersistentMap& theMap)
{
Handle(ShapePersistent_Geom::Curve) aPC;
if (!theCurve.IsNull())
{
if (theMap.IsBound(theCurve))
aPC = Handle(ShapePersistent_Geom::Curve)::DownCast(theMap.Find(theCurve));
else {
Handle(Line) aPT = new Line;
aPT->myTransient = theCurve;
aPC = aPT;
}
}
return aPC;
}
//=======================================================================
// Conic
//=======================================================================
template<>
Standard_CString ShapePersistent_Geom::subBase_gp<ShapePersistent_Geom::Curve,
gp_Ax2>
::PName() const { return "PGeom_Conic"; }
//=======================================================================
// Circle
//=======================================================================
template<>
Standard_CString ShapePersistent_Geom::instance<ShapePersistent_Geom_Curve::Conic,
Geom_Circle,
gp_Circ>
::PName() const { return "PGeom_Circle"; }
template<>
void ShapePersistent_Geom::instance<ShapePersistent_Geom_Curve::Conic,
Geom_Circle,
gp_Circ>
::Write(StdObjMgt_WriteData& theWriteData) const
{
Handle(Geom_Circle) aMyGeom =
Handle(Geom_Circle)::DownCast(myTransient);
theWriteData << aMyGeom->Circ();
}
Handle(ShapePersistent_Geom::Curve)
ShapePersistent_Geom_Curve::Translate(const Handle(Geom_Circle)& theCurve,
StdObjMgt_TransientPersistentMap& theMap)
{
Handle(ShapePersistent_Geom::Curve) aPC;
if (!theCurve.IsNull())
{
if (theMap.IsBound(theCurve))
aPC = Handle(ShapePersistent_Geom::Curve)::DownCast(theMap.Find(theCurve));
else {
Handle(Circle) aPT = new Circle;
aPT->myTransient = theCurve;
aPC = aPT;
}
}
return aPC;
}
//=======================================================================
// Ellipse
//=======================================================================
template<>
Standard_CString ShapePersistent_Geom::instance<ShapePersistent_Geom_Curve::Conic,
Geom_Ellipse,
gp_Elips>
::PName() const { return "PGeom_Ellipse"; }
template<>
void ShapePersistent_Geom::instance<ShapePersistent_Geom_Curve::Conic,
Geom_Ellipse,
gp_Elips>
::Write(StdObjMgt_WriteData& theWriteData) const
{
Handle(Geom_Ellipse) aMyGeom =
Handle(Geom_Ellipse)::DownCast(myTransient);
theWriteData << aMyGeom->Elips();
}
Handle(ShapePersistent_Geom::Curve)
ShapePersistent_Geom_Curve::Translate(const Handle(Geom_Ellipse)& theCurve,
StdObjMgt_TransientPersistentMap& theMap)
{
Handle(ShapePersistent_Geom::Curve) aPC;
if (!theCurve.IsNull())
{
if (theMap.IsBound(theCurve))
aPC = Handle(ShapePersistent_Geom::Curve)::DownCast(theMap.Find(theCurve));
else {
Handle(Ellipse) aPT = new Ellipse;
aPT->myTransient = theCurve;
aPC = aPT;
}
}
return aPC;
}
//=======================================================================
// Hyperbola
//=======================================================================
template<>
Standard_CString ShapePersistent_Geom::instance<ShapePersistent_Geom_Curve::Conic,
Geom_Hyperbola,
gp_Hypr>
::PName() const { return "PGeom_Hyperbola"; }
template<>
void ShapePersistent_Geom::instance<ShapePersistent_Geom_Curve::Conic,
Geom_Hyperbola,
gp_Hypr>
::Write(StdObjMgt_WriteData& theWriteData) const
{
Handle(Geom_Hyperbola) aMyGeom =
Handle(Geom_Hyperbola)::DownCast(myTransient);
theWriteData << aMyGeom->Hypr();
}
Handle(ShapePersistent_Geom::Curve)
ShapePersistent_Geom_Curve::Translate(const Handle(Geom_Hyperbola)& theCurve,
StdObjMgt_TransientPersistentMap& theMap)
{
Handle(ShapePersistent_Geom::Curve) aPC;
if (!theCurve.IsNull())
{
if (theMap.IsBound(theCurve))
aPC = Handle(ShapePersistent_Geom::Curve)::DownCast(theMap.Find(theCurve));
else {
Handle(Hyperbola) aPT = new Hyperbola;
aPT->myTransient = theCurve;
aPC = aPT;
}
}
return aPC;
}
//=======================================================================
// Parabola
//=======================================================================
template<>
Standard_CString ShapePersistent_Geom::instance<ShapePersistent_Geom_Curve::Conic,
Geom_Parabola,
gp_Parab>
::PName() const { return "PGeom_Parabola"; }
template<>
void ShapePersistent_Geom::instance<ShapePersistent_Geom_Curve::Conic,
Geom_Parabola,
gp_Parab>
::Write(StdObjMgt_WriteData& theWriteData) const
{
Handle(Geom_Parabola) aMyGeom =
Handle(Geom_Parabola)::DownCast(myTransient);
theWriteData << aMyGeom->Parab();
}
Handle(ShapePersistent_Geom::Curve)
ShapePersistent_Geom_Curve::Translate(const Handle(Geom_Parabola)& theCurve,
StdObjMgt_TransientPersistentMap& theMap)
{
Handle(ShapePersistent_Geom::Curve) aPC;
if (!theCurve.IsNull())
{
if (theMap.IsBound(theCurve))
aPC = Handle(ShapePersistent_Geom::Curve)::DownCast(theMap.Find(theCurve));
else {
Handle(Parabola) aPT = new Parabola;
aPT->myTransient = theCurve;
aPC = aPT;
}
}
return aPC;
}
//=======================================================================
// BezierCurve
//=======================================================================
Handle(ShapePersistent_Geom::Curve)
ShapePersistent_Geom_Curve::Translate(const Handle(Geom_BezierCurve)& theCurve,
StdObjMgt_TransientPersistentMap& theMap)
{
Handle(ShapePersistent_Geom::Curve) aPC;
if (!theCurve.IsNull())
{
if (theMap.IsBound(theCurve))
aPC = Handle(ShapePersistent_Geom::Curve)::DownCast(theMap.Find(theCurve));
else {
Handle(Bezier) aPBC = new Bezier;
Handle(pBezier) aPpBC = new pBezier;
aPpBC->myRational = theCurve->IsRational();
aPpBC->myPoles = StdLPersistent_HArray1::Translate<TColgp_HArray1OfPnt>("PColgp_HArray1OfPnt", theCurve->Poles());
if (theCurve->IsRational()) {
aPpBC->myWeights = StdLPersistent_HArray1::Translate<TColStd_HArray1OfReal>(*theCurve->Weights());
}
aPBC->myPersistent = aPpBC;
aPC = aPBC;
}
}
return aPC;
}
//=======================================================================
// BSplineCurve
//=======================================================================
Handle(ShapePersistent_Geom::Curve)
ShapePersistent_Geom_Curve::Translate(const Handle(Geom_BSplineCurve)& theCurve,
StdObjMgt_TransientPersistentMap& theMap)
{
Handle(ShapePersistent_Geom::Curve) aPC;
if (!theCurve.IsNull())
{
if (theMap.IsBound(theCurve))
aPC = Handle(ShapePersistent_Geom::Curve)::DownCast(theMap.Find(theCurve));
else {
Handle(BSpline) aPBSC = new BSpline;
Handle(pBSpline) aPpBSC = new pBSpline;
aPpBSC->myRational = theCurve->IsRational();
aPpBSC->myPeriodic = theCurve->IsPeriodic();
aPpBSC->mySpineDegree = theCurve->Degree();
aPpBSC->myPoles = StdLPersistent_HArray1::Translate<TColgp_HArray1OfPnt>("PColgp_HArray1OfPnt", theCurve->Poles());
if (theCurve->IsRational()) {
aPpBSC->myWeights = StdLPersistent_HArray1::Translate<TColStd_HArray1OfReal>(*theCurve->Weights());
}
aPpBSC->myKnots = StdLPersistent_HArray1::Translate<TColStd_HArray1OfReal>(theCurve->Knots());
aPpBSC->myMultiplicities = StdLPersistent_HArray1::Translate<TColStd_HArray1OfInteger>(theCurve->Multiplicities());
aPBSC->myPersistent = aPpBSC;
aPC = aPBSC;
}
}
return aPC;
}
//=======================================================================
// TrimmedCurve
//=======================================================================
Handle(ShapePersistent_Geom::Curve)
ShapePersistent_Geom_Curve::Translate(const Handle(Geom_TrimmedCurve)& theCurve,
StdObjMgt_TransientPersistentMap& theMap)
{
Handle(ShapePersistent_Geom::Curve) aPC;
if (!theCurve.IsNull())
{
if (theMap.IsBound(theCurve))
aPC = Handle(ShapePersistent_Geom::Curve)::DownCast(theMap.Find(theCurve));
else {
Handle(Trimmed) aPTC = new Trimmed;
Handle(pTrimmed) aPpTC = new pTrimmed;
aPpTC->myFirstU = theCurve->FirstParameter();
aPpTC->myLastU = theCurve->LastParameter();
aPpTC->myBasisCurve = ShapePersistent_Geom::Translate(theCurve->BasisCurve(), theMap);
aPTC->myPersistent = aPpTC;
aPC = aPTC;
}
}
return aPC;
}
//=======================================================================
// OffsetCurve
//=======================================================================
Handle(ShapePersistent_Geom::Curve)
ShapePersistent_Geom_Curve::Translate(const Handle(Geom_OffsetCurve)& theCurve,
StdObjMgt_TransientPersistentMap& theMap)
{
Handle(ShapePersistent_Geom::Curve) aPC;
if (!theCurve.IsNull())
{
if (theMap.IsBound(theCurve))
aPC = Handle(ShapePersistent_Geom::Curve)::DownCast(theMap.Find(theCurve));
else {
Handle(Offset) aPOC = new Offset;
Handle(pOffset) aPpOC = new pOffset;
aPpOC->myOffsetDirection = theCurve->Direction();
aPpOC->myOffsetValue = theCurve->Offset();
aPpOC->myBasisCurve = ShapePersistent_Geom::Translate(theCurve->BasisCurve(), theMap);
aPOC->myPersistent = aPpOC;
aPC = aPOC;
}
}
return aPC;
}

View File

@@ -15,6 +15,8 @@
#ifndef _ShapePersistent_Geom_Curve_HeaderFile
#define _ShapePersistent_Geom_Curve_HeaderFile
#include <StdObjMgt_TransientPersistentMap.hxx>
#include <ShapePersistent_Geom.hxx>
#include <ShapePersistent_HArray1.hxx>
#include <StdLPersistent_HArray1.hxx>
@@ -24,6 +26,10 @@
#include <Geom_Ellipse.hxx>
#include <Geom_Hyperbola.hxx>
#include <Geom_Parabola.hxx>
#include <Geom_BezierCurve.hxx>
#include <Geom_BSplineCurve.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <Geom_OffsetCurve.hxx>
#include <gp_Circ.hxx>
#include <gp_Elips.hxx>
@@ -32,7 +38,6 @@
class gp_Dir;
class ShapePersistent_Geom_Curve : private ShapePersistent_Geom
{
typedef Curve::PersistentBase pBase;
@@ -41,9 +46,19 @@ class ShapePersistent_Geom_Curve : private ShapePersistent_Geom
class pBezier : public pBounded
{
friend class ShapePersistent_Geom_Curve;
public:
inline void Read (StdObjMgt_ReadData& theReadData)
{ theReadData >> myRational >> myPoles >> myWeights; }
inline void Write(StdObjMgt_WriteData& theWriteData)
{ theWriteData << myRational << myPoles << myWeights; }
inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
{
theChildren.Append(myPoles);
theChildren.Append(myWeights);
}
inline Standard_CString PName() const { return "PGeom_BezierCurve"; }
virtual Handle(Geom_Curve) Import() const;
@@ -55,12 +70,27 @@ class ShapePersistent_Geom_Curve : private ShapePersistent_Geom
class pBSpline : public pBounded
{
friend class ShapePersistent_Geom_Curve;
public:
inline void Read (StdObjMgt_ReadData& theReadData)
{
theReadData >> myRational >> myPeriodic >> mySpineDegree;
theReadData >> myPoles >> myWeights >> myKnots >> myMultiplicities;
}
inline void Write (StdObjMgt_WriteData& theWriteData) const
{
theWriteData << myRational << myPeriodic << mySpineDegree;
theWriteData << myPoles << myWeights << myKnots << myMultiplicities;
}
inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
{
theChildren.Append(myPoles);
theChildren.Append(myWeights);
theChildren.Append(myKnots);
theChildren.Append(myMultiplicities);
}
inline Standard_CString PName() const { return "PGeom_BSplineCurve"; }
virtual Handle(Geom_Curve) Import() const;
@@ -76,9 +106,16 @@ class ShapePersistent_Geom_Curve : private ShapePersistent_Geom
class pTrimmed : public pBounded
{
friend class ShapePersistent_Geom_Curve;
public:
inline void Read (StdObjMgt_ReadData& theReadData)
{ theReadData >> myBasisCurve >> myFirstU >> myLastU; }
inline void Write (StdObjMgt_WriteData& theWriteData) const
{ theWriteData << myBasisCurve << myFirstU << myLastU; }
inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
{ theChildren.Append(myBasisCurve); }
inline Standard_CString PName() const { return "PGeom_TrimmedCurve"; }
virtual Handle(Geom_Curve) Import() const;
@@ -90,9 +127,16 @@ class ShapePersistent_Geom_Curve : private ShapePersistent_Geom
class pOffset : public pBase
{
friend class ShapePersistent_Geom_Curve;
public:
inline void Read (StdObjMgt_ReadData& theReadData)
{ theReadData >> myBasisCurve >> myOffsetDirection >> myOffsetValue; }
inline void Write (StdObjMgt_WriteData& theWriteData) const
{ theWriteData << myBasisCurve << myOffsetDirection << myOffsetValue; }
inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
{ theChildren.Append(myBasisCurve); }
inline Standard_CString PName() const { return "PGeom_OffsetCurve"; }
virtual Handle(Geom_Curve) Import() const;
@@ -117,6 +161,118 @@ public:
typedef Delayed<Bounded, pTrimmed> Trimmed;
typedef Delayed<Curve, pOffset> Offset;
public:
//! Create a persistent object for a line
Standard_EXPORT static Handle(Curve) Translate (const Handle(Geom_Line)& theCurve,
StdObjMgt_TransientPersistentMap& theMap);
//! Create a persistent object for a circle
Standard_EXPORT static Handle(Curve) Translate (const Handle(Geom_Circle)& theCurve,
StdObjMgt_TransientPersistentMap& theMap);
//! Create a persistent object for a ellipse
Standard_EXPORT static Handle(Curve) Translate (const Handle(Geom_Ellipse)& theCurve,
StdObjMgt_TransientPersistentMap& theMap);
//! Create a persistent object for a hyperbola
Standard_EXPORT static Handle(Curve) Translate (const Handle(Geom_Hyperbola)& theCurve,
StdObjMgt_TransientPersistentMap& theMap);
//! Create a persistent object for a parabola
Standard_EXPORT static Handle(Curve) Translate (const Handle(Geom_Parabola)& theCurve,
StdObjMgt_TransientPersistentMap& theMap);
//! Create a persistent object for a Bezier curve
Standard_EXPORT static Handle(Curve) Translate (const Handle(Geom_BezierCurve)& theCurve,
StdObjMgt_TransientPersistentMap& theMap);
//! Create a persistent object for a BSpline curve
Standard_EXPORT static Handle(Curve) Translate (const Handle(Geom_BSplineCurve)& theCurve,
StdObjMgt_TransientPersistentMap& theMap);
//! Create a persistent object for a trimmed curve
Standard_EXPORT static Handle(Curve) Translate (const Handle(Geom_TrimmedCurve)& theCurve,
StdObjMgt_TransientPersistentMap& theMap);
//! Create a persistent object for an offset curve
Standard_EXPORT static Handle(Curve) Translate (const Handle(Geom_OffsetCurve)& theCurve,
StdObjMgt_TransientPersistentMap& theMap);
};
//=======================================================================
// Line
//=======================================================================
template<>
Standard_CString ShapePersistent_Geom::instance<ShapePersistent_Geom::Curve,
Geom_Line,
gp_Ax1>
::PName() const;
template<>
void ShapePersistent_Geom::instance<ShapePersistent_Geom::Curve,
Geom_Line,
gp_Ax1>
::Write(StdObjMgt_WriteData& theWriteData) const;
//=======================================================================
// Conic
//=======================================================================
template<>
Standard_CString ShapePersistent_Geom::subBase_gp<ShapePersistent_Geom::Curve,
gp_Ax2>
::PName() const;
//=======================================================================
// Circle
//=======================================================================
template<>
Standard_CString ShapePersistent_Geom::instance<ShapePersistent_Geom_Curve::Conic,
Geom_Circle,
gp_Circ>
::PName() const;
template<>
void ShapePersistent_Geom::instance<ShapePersistent_Geom_Curve::Conic,
Geom_Circle,
gp_Circ>
::Write(StdObjMgt_WriteData& theWriteData) const;
//=======================================================================
// Ellipse
//=======================================================================
template<>
Standard_CString ShapePersistent_Geom::instance<ShapePersistent_Geom_Curve::Conic,
Geom_Ellipse,
gp_Elips>
::PName() const;
template<>
void ShapePersistent_Geom::instance<ShapePersistent_Geom_Curve::Conic,
Geom_Ellipse,
gp_Elips>
::Write(StdObjMgt_WriteData& theWriteData) const;
//=======================================================================
// Hyperbola
//=======================================================================
template<>
Standard_CString ShapePersistent_Geom::instance<ShapePersistent_Geom_Curve::Conic,
Geom_Hyperbola,
gp_Hypr>
::PName() const;
template<>
void ShapePersistent_Geom::instance<ShapePersistent_Geom_Curve::Conic,
Geom_Hyperbola,
gp_Hypr>
::Write(StdObjMgt_WriteData& theWriteData) const;
//=======================================================================
// Parabola
//=======================================================================
template<>
Standard_CString ShapePersistent_Geom::instance<ShapePersistent_Geom_Curve::Conic,
Geom_Parabola,
gp_Parab>
::PName() const;
template<>
void ShapePersistent_Geom::instance<ShapePersistent_Geom_Curve::Conic,
Geom_Parabola,
gp_Parab>
::Write(StdObjMgt_WriteData& theWriteData) const;
#endif

View File

@@ -12,6 +12,8 @@
// commercial license or contractual agreement.
#include <ShapePersistent_Geom_Surface.hxx>
#include <StdLPersistent_HArray1.hxx>
#include <ShapePersistent_HArray2.hxx>
#include <Geom_SurfaceOfLinearExtrusion.hxx>
#include <Geom_SurfaceOfRevolution.hxx>
@@ -108,3 +110,374 @@ Handle(Geom_Surface) ShapePersistent_Geom_Surface::pOffset::Import() const
return new Geom_OffsetSurface (myBasisSurface->Import(), myOffsetValue);
}
//=======================================================================
// Elementary
//=======================================================================
template<>
Standard_CString ShapePersistent_Geom::subBase_gp<ShapePersistent_Geom::Surface,
gp_Ax3>
::PName() const { return "PGeom_ElementarySurface"; }
//=======================================================================
// Plane
//=======================================================================
template<>
Standard_CString ShapePersistent_Geom::instance<ShapePersistent_Geom::subBase_gp<ShapePersistent_Geom::Surface, gp_Ax3>,
Geom_Plane,
gp_Ax3>
::PName() const { return "PGeom_Plane"; }
template<>
void ShapePersistent_Geom::instance<ShapePersistent_Geom::subBase_gp<ShapePersistent_Geom::Surface, gp_Ax3>,
Geom_Plane,
gp_Ax3>
::Write(StdObjMgt_WriteData& theWriteData) const
{
Handle(Geom_Plane) aMyGeom =
Handle(Geom_Plane)::DownCast(myTransient);
theWriteData << aMyGeom->Position();
}
Handle(ShapePersistent_Geom::Surface)
ShapePersistent_Geom_Surface::Translate(const Handle(Geom_Plane)& theSurf,
StdObjMgt_TransientPersistentMap& theMap)
{
Handle(ShapePersistent_Geom::Surface) aPS;
if (!theSurf.IsNull())
{
if (theMap.IsBound(theSurf))
aPS = Handle(ShapePersistent_Geom::Surface)::DownCast(theMap.Find(theSurf));
else
{
Handle(Plane) aPP = new Plane;
aPP->myTransient = theSurf;
aPS = aPP;
}
}
return aPS;
}
//=======================================================================
// Conical
//=======================================================================
template<>
Standard_CString ShapePersistent_Geom::instance<ShapePersistent_Geom::subBase_gp<ShapePersistent_Geom::Surface, gp_Ax3>,
Geom_ConicalSurface,
gp_Cone>
::PName() const { return "PGeom_ConicalSurface"; }
template<>
void ShapePersistent_Geom::instance<ShapePersistent_Geom::subBase_gp<ShapePersistent_Geom::Surface, gp_Ax3>,
Geom_ConicalSurface,
gp_Cone>
::Write(StdObjMgt_WriteData& theWriteData) const
{
Handle(Geom_ConicalSurface) aMyGeom =
Handle(Geom_ConicalSurface)::DownCast(myTransient);
theWriteData << aMyGeom->Cone();
}
Handle(ShapePersistent_Geom::Surface)
ShapePersistent_Geom_Surface::Translate(const Handle(Geom_ConicalSurface)& theSurf,
StdObjMgt_TransientPersistentMap& theMap)
{
Handle(ShapePersistent_Geom::Surface) aPS;
if (!theSurf.IsNull())
{
if (theMap.IsBound(theSurf))
aPS = Handle(ShapePersistent_Geom::Surface)::DownCast(theMap.Find(theSurf));
else
{
Handle(Conical) aPCon = new Conical;
aPCon->myTransient = theSurf;
aPS = aPCon;
}
}
return aPS;
}
//=======================================================================
// Cylindrical
//=======================================================================
template<>
Standard_CString ShapePersistent_Geom::instance<ShapePersistent_Geom::subBase_gp<ShapePersistent_Geom::Surface, gp_Ax3>,
Geom_CylindricalSurface,
gp_Cylinder>
::PName() const { return "PGeom_CylindricalSurface"; }
template<>
void ShapePersistent_Geom::instance<ShapePersistent_Geom::subBase_gp<ShapePersistent_Geom::Surface, gp_Ax3>,
Geom_CylindricalSurface,
gp_Cylinder>
::Write(StdObjMgt_WriteData& theWriteData) const
{
Handle(Geom_CylindricalSurface) aMyGeom =
Handle(Geom_CylindricalSurface)::DownCast(myTransient);
theWriteData << aMyGeom->Cylinder();
}
Handle(ShapePersistent_Geom::Surface)
ShapePersistent_Geom_Surface::Translate(const Handle(Geom_CylindricalSurface)& theSurf,
StdObjMgt_TransientPersistentMap& theMap)
{
Handle(ShapePersistent_Geom::Surface) aPS;
if (!theSurf.IsNull())
{
if (theMap.IsBound(theSurf))
aPS = Handle(ShapePersistent_Geom::Surface)::DownCast(theMap.Find(theSurf));
else
{
Handle(Cylindrical) aPCyl = new Cylindrical;
aPCyl->myTransient = theSurf;
aPS = aPCyl;
}
}
return aPS;
}
//=======================================================================
// Spherical
//=======================================================================
template<>
Standard_CString ShapePersistent_Geom::instance<ShapePersistent_Geom::subBase_gp<ShapePersistent_Geom::Surface, gp_Ax3>,
Geom_SphericalSurface,
gp_Sphere>
::PName() const { return "PGeom_SphericalSurface"; }
template<>
void ShapePersistent_Geom::instance<ShapePersistent_Geom::subBase_gp<ShapePersistent_Geom::Surface, gp_Ax3>,
Geom_SphericalSurface,
gp_Sphere>
::Write(StdObjMgt_WriteData& theWriteData) const
{
Handle(Geom_SphericalSurface) aMyGeom =
Handle(Geom_SphericalSurface)::DownCast(myTransient);
theWriteData << aMyGeom->Sphere();
}
Handle(ShapePersistent_Geom::Surface)
ShapePersistent_Geom_Surface::Translate(const Handle(Geom_SphericalSurface)& theSurf,
StdObjMgt_TransientPersistentMap& theMap)
{
Handle(ShapePersistent_Geom::Surface) aPS;
if (!theSurf.IsNull())
{
if (theMap.IsBound(theSurf))
aPS = Handle(ShapePersistent_Geom::Surface)::DownCast(theMap.Find(theSurf));
else
{
Handle(Spherical) aPSph = new Spherical;
aPSph->myTransient = theSurf;
aPS = aPSph;
}
}
return aPS;
}
//=======================================================================
// Toroidal
//=======================================================================
template<>
Standard_CString ShapePersistent_Geom::instance<ShapePersistent_Geom::subBase_gp<ShapePersistent_Geom::Surface, gp_Ax3>,
Geom_ToroidalSurface,
gp_Torus>
::PName() const { return "PGeom_ToroidalSurface"; }
template<>
void ShapePersistent_Geom::instance<ShapePersistent_Geom::subBase_gp<ShapePersistent_Geom::Surface, gp_Ax3>,
Geom_ToroidalSurface,
gp_Torus>
::Write(StdObjMgt_WriteData& theWriteData) const
{
Handle(Geom_ToroidalSurface) aMyGeom =
Handle(Geom_ToroidalSurface)::DownCast(myTransient);
theWriteData << aMyGeom->Torus();
}
Handle(ShapePersistent_Geom::Surface)
ShapePersistent_Geom_Surface::Translate(const Handle(Geom_ToroidalSurface)& theSurf,
StdObjMgt_TransientPersistentMap& theMap)
{
Handle(ShapePersistent_Geom::Surface) aPS;
if (!theSurf.IsNull())
{
if (theMap.IsBound(theSurf))
aPS = Handle(ShapePersistent_Geom::Surface)::DownCast(theMap.Find(theSurf));
else
{
Handle(Toroidal) aPTor = new Toroidal;
aPTor->myTransient = theSurf;
aPS = aPTor;
}
}
return aPS;
}
//=======================================================================
// LinearExtrusion
//=======================================================================
Handle(ShapePersistent_Geom::Surface)
ShapePersistent_Geom_Surface::Translate(const Handle(Geom_SurfaceOfLinearExtrusion)& theSurf,
StdObjMgt_TransientPersistentMap& theMap)
{
Handle(ShapePersistent_Geom::Surface) aPS;
if (!theSurf.IsNull())
{
if (theMap.IsBound(theSurf))
aPS = Handle(ShapePersistent_Geom::Surface)::DownCast(theMap.Find(theSurf));
else
{
Handle(LinearExtrusion) aPLE = new LinearExtrusion;
Handle(pLinearExtrusion) aPpLE = new pLinearExtrusion;
aPpLE->myDirection = theSurf->Direction();
aPpLE->myBasisCurve = ShapePersistent_Geom::Translate(theSurf->BasisCurve(), theMap);
aPLE->myPersistent = aPpLE;
aPS = aPLE;
}
}
return aPS;
}
//=======================================================================
// Revolution
//=======================================================================
Handle(ShapePersistent_Geom::Surface)
ShapePersistent_Geom_Surface::Translate(const Handle(Geom_SurfaceOfRevolution)& theSurf,
StdObjMgt_TransientPersistentMap& theMap)
{
Handle(ShapePersistent_Geom::Surface) aPS;
if (!theSurf.IsNull())
{
if (theMap.IsBound(theSurf))
aPS = Handle(ShapePersistent_Geom::Surface)::DownCast(theMap.Find(theSurf));
else
{
Handle(Revolution) aPR = new Revolution;
Handle(pRevolution) aPpR = new pRevolution;
aPpR->myLocation = theSurf->Location();
aPpR->myDirection = theSurf->Direction();
aPpR->myBasisCurve = ShapePersistent_Geom::Translate(theSurf->BasisCurve(), theMap);
aPR->myPersistent = aPpR;
aPS = aPR;
}
}
return aPS;
}
//=======================================================================
//
//=======================================================================
Handle(ShapePersistent_Geom::Surface)
ShapePersistent_Geom_Surface::Translate(const Handle(Geom_BezierSurface)& theSurf,
StdObjMgt_TransientPersistentMap& theMap)
{
Handle(ShapePersistent_Geom::Surface) aPS;
if (!theSurf.IsNull())
{
if (theMap.IsBound(theSurf))
aPS = Handle(ShapePersistent_Geom::Surface)::DownCast(theMap.Find(theSurf));
else
{
Handle(Bezier) aPB = new Bezier;
Handle(pBezier) aPpB = new pBezier;
aPpB->myURational = theSurf->IsURational();
aPpB->myVRational = theSurf->IsVRational();
aPpB->myPoles = StdLPersistent_HArray2::Translate<TColgp_HArray2OfPnt>("PColgp_HArray2OfPnt", theSurf->Poles());
if (theSurf->IsURational() || theSurf->IsVRational()) {
aPpB->myWeights = StdLPersistent_HArray2::Translate<TColStd_HArray2OfReal>(*theSurf->Weights());
}
aPB->myPersistent = aPpB;
aPS = aPB;
}
}
return aPS;
}
//=======================================================================
// BSpline
//=======================================================================
Handle(ShapePersistent_Geom::Surface)
ShapePersistent_Geom_Surface::Translate(const Handle(Geom_BSplineSurface)& theSurf,
StdObjMgt_TransientPersistentMap& theMap)
{
Handle(ShapePersistent_Geom::Surface) aPS;
if (!theSurf.IsNull())
{
if (theMap.IsBound(theSurf))
aPS = Handle(ShapePersistent_Geom::Surface)::DownCast(theMap.Find(theSurf));
else
{
Handle(BSpline) aPBS = new BSpline;
Handle(pBSpline) aPpBS = new pBSpline;
aPpBS->myURational = theSurf->IsURational();
aPpBS->myVRational = theSurf->IsVRational();
aPpBS->myUPeriodic = theSurf->IsUPeriodic();
aPpBS->myVPeriodic = theSurf->IsVPeriodic();
aPpBS->myUSpineDegree = theSurf->UDegree();
aPpBS->myVSpineDegree = theSurf->VDegree();
aPpBS->myPoles = StdLPersistent_HArray2::Translate<TColgp_HArray2OfPnt>("PColgp_HArray2OfPnt", theSurf->Poles());
if (theSurf->IsURational() || theSurf->IsVRational()) {
aPpBS->myWeights = StdLPersistent_HArray2::Translate<TColStd_HArray2OfReal>(*theSurf->Weights());
}
aPpBS->myUKnots = StdLPersistent_HArray1::Translate<TColStd_HArray1OfReal>(theSurf->UKnots());
aPpBS->myVKnots = StdLPersistent_HArray1::Translate<TColStd_HArray1OfReal>(theSurf->VKnots());
aPpBS->myUMultiplicities = StdLPersistent_HArray1::Translate<TColStd_HArray1OfInteger>(theSurf->UMultiplicities());
aPpBS->myVMultiplicities = StdLPersistent_HArray1::Translate<TColStd_HArray1OfInteger>(theSurf->VMultiplicities());
aPBS->myPersistent = aPpBS;
aPS = aPBS;
}
}
return aPS;
}
//=======================================================================
// RectangularTrimmed
//=======================================================================
Handle(ShapePersistent_Geom::Surface)
ShapePersistent_Geom_Surface::Translate(const Handle(Geom_RectangularTrimmedSurface)& theSurf,
StdObjMgt_TransientPersistentMap& theMap)
{
Handle(ShapePersistent_Geom::Surface) aPS;
if (!theSurf.IsNull())
{
if (theMap.IsBound(theSurf))
aPS = Handle(ShapePersistent_Geom::Surface)::DownCast(theMap.Find(theSurf));
else
{
Handle(RectangularTrimmed) aPRT = new RectangularTrimmed;
Handle(pRectangularTrimmed) aPpRT = new pRectangularTrimmed;
theSurf->Bounds(aPpRT->myFirstU, aPpRT->myLastU, aPpRT->myFirstV, aPpRT->myLastV);
aPpRT->myBasisSurface = ShapePersistent_Geom::Translate(theSurf->BasisSurface(), theMap);
aPRT->myPersistent = aPpRT;
aPS = aPRT;
}
}
return aPS;
}
//=======================================================================
// Offset
//=======================================================================
Handle(ShapePersistent_Geom::Surface)
ShapePersistent_Geom_Surface::Translate(const Handle(Geom_OffsetSurface)& theSurf,
StdObjMgt_TransientPersistentMap& theMap)
{
Handle(ShapePersistent_Geom::Surface) aPS;
if (!theSurf.IsNull())
{
if (theMap.IsBound(theSurf))
aPS = Handle(ShapePersistent_Geom::Surface)::DownCast(theMap.Find(theSurf));
else
{
Handle(Offset) aPO = new Offset;
Handle(pOffset) aPpO = new pOffset;
aPpO->myOffsetValue = theSurf->Offset();
aPpO->myBasisSurface = ShapePersistent_Geom::Translate(theSurf->BasisSurface(), theMap);
aPO->myPersistent = aPpO;
aPS = aPO;
}
}
return aPS;
}

View File

@@ -15,6 +15,8 @@
#ifndef _ShapePersistent_Geom_Surface_HeaderFile
#define _ShapePersistent_Geom_Surface_HeaderFile
#include <StdObjMgt_TransientPersistentMap.hxx>
#include <ShapePersistent_Geom.hxx>
#include <ShapePersistent_HArray2.hxx>
#include <StdLPersistent_HArray1.hxx>
@@ -25,6 +27,12 @@
#include <Geom_CylindricalSurface.hxx>
#include <Geom_SphericalSurface.hxx>
#include <Geom_ToroidalSurface.hxx>
#include <Geom_SurfaceOfLinearExtrusion.hxx>
#include <Geom_SurfaceOfRevolution.hxx>
#include <Geom_BezierSurface.hxx>
#include <Geom_BSplineSurface.hxx>
#include <Geom_RectangularTrimmedSurface.hxx>
#include <Geom_OffsetSurface.hxx>
#include <gp_Ax3.hxx>
#include <gp_Cone.hxx>
@@ -42,31 +50,54 @@ class ShapePersistent_Geom_Surface : private ShapePersistent_Geom
class pSweptData
{
friend class ShapePersistent_Geom_Surface;
public:
inline void Read (StdObjMgt_ReadData& theReadData)
{ theReadData >> myBasisCurve >> myDirection; }
inline void Write (StdObjMgt_WriteData& theWriteData) const
{ theWriteData << myBasisCurve << myDirection; }
inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
{ theChildren.Append(myBasisCurve); }
protected:
Handle(Curve) myBasisCurve;
gp_Dir myDirection;
};
struct pSwept : pBase, pSweptData {};
struct pSwept : pBase, pSweptData
{
inline Standard_CString PName() const
{ return "PGeom_SweptSurface"; }
};
class pLinearExtrusion : public pSwept
{
friend class ShapePersistent_Geom_Surface;
public:
virtual Handle(Geom_Surface) Import() const;
inline Standard_CString PName() const
{ return "PGeom_SurfaceOfLinearExtrusion"; }
};
class pRevolution : public pSwept
{
friend class ShapePersistent_Geom_Surface;
public:
inline void Read (StdObjMgt_ReadData& theReadData)
{
pSwept::Read (theReadData);
theReadData >> myLocation;
}
inline void Write (StdObjMgt_WriteData& theWriteData) const
{
pSwept::Write(theWriteData);
theWriteData << myLocation;
}
inline Standard_CString PName() const
{ return "PGeom_SurfaceOfRevolution"; }
virtual Handle(Geom_Surface) Import() const;
@@ -78,9 +109,20 @@ class ShapePersistent_Geom_Surface : private ShapePersistent_Geom
class pBezier : public pBounded
{
friend class ShapePersistent_Geom_Surface;
public:
inline void Read (StdObjMgt_ReadData& theReadData)
{ theReadData >> myURational >> myVRational >> myPoles >> myWeights; }
inline void Write (StdObjMgt_WriteData& theWriteData) const
{ theWriteData << myURational << myVRational << myPoles << myWeights; }
inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
{
theChildren.Append(myPoles);
theChildren.Append(myWeights);
}
inline Standard_CString PName() const
{ return "PGeom_BezierSurface"; }
virtual Handle(Geom_Surface) Import() const;
@@ -93,6 +135,8 @@ class ShapePersistent_Geom_Surface : private ShapePersistent_Geom
class pBSpline : public pBounded
{
friend class ShapePersistent_Geom_Surface;
public:
inline void Read (StdObjMgt_ReadData& theReadData)
{
@@ -104,6 +148,27 @@ class ShapePersistent_Geom_Surface : private ShapePersistent_Geom
theReadData >> myUKnots >> myVKnots;
theReadData >> myUMultiplicities >> myVMultiplicities;
}
inline void Write (StdObjMgt_WriteData& theWriteData) const
{
theWriteData << myURational << myVRational;
theWriteData << myUPeriodic << myVPeriodic;
theWriteData << myUSpineDegree << myVSpineDegree;
theWriteData << myPoles;
theWriteData << myWeights;
theWriteData << myUKnots << myVKnots;
theWriteData << myUMultiplicities << myVMultiplicities;
}
inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
{
theChildren.Append(myPoles);
theChildren.Append(myWeights);
theChildren.Append(myUKnots);
theChildren.Append(myVKnots);
theChildren.Append(myUMultiplicities);
theChildren.Append(myVMultiplicities);
}
inline Standard_CString PName() const
{ return "PGeom_BSplineSurface"; }
virtual Handle(Geom_Surface) Import() const;
@@ -124,12 +189,23 @@ class ShapePersistent_Geom_Surface : private ShapePersistent_Geom
class pRectangularTrimmed : public pBounded
{
friend class ShapePersistent_Geom_Surface;
public:
inline void Read (StdObjMgt_ReadData& theReadData)
{
theReadData >> myBasisSurface;
theReadData >> myFirstU >> myLastU >> myFirstV >> myLastV;
}
inline void Write (StdObjMgt_WriteData& theWriteData) const
{
theWriteData << myBasisSurface;
theWriteData << myFirstU << myLastU << myFirstV << myLastV;
}
inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
{ theChildren.Append(myBasisSurface); }
inline Standard_CString PName() const
{ return "PGeom_RectangularTrimmedSurface"; }
virtual Handle(Geom_Surface) Import() const;
@@ -143,9 +219,17 @@ class ShapePersistent_Geom_Surface : private ShapePersistent_Geom
class pOffset : public pBase
{
friend class ShapePersistent_Geom_Surface;
public:
inline void Read (StdObjMgt_ReadData& theReadData)
{ theReadData >> myBasisSurface >> myOffsetValue; }
inline void Write (StdObjMgt_WriteData& theWriteData) const
{ theWriteData << myBasisSurface << myOffsetValue; }
inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
{ theChildren.Append(myBasisSurface); }
inline Standard_CString PName() const
{ return "PGeom_OffsetSurface"; }
virtual Handle(Geom_Surface) Import() const;
@@ -172,6 +256,124 @@ public:
typedef Delayed<Bounded, pRectangularTrimmed> RectangularTrimmed;
typedef Delayed<Surface, pOffset> Offset;
public:
//! Create a persistent object for a plane
Standard_EXPORT static Handle(Surface) Translate (const Handle(Geom_Plane)& theSurf,
StdObjMgt_TransientPersistentMap& theMap);
//! Create a persistent object for a cylinder
Standard_EXPORT static Handle(Surface) Translate (const Handle(Geom_CylindricalSurface)& theSurf,
StdObjMgt_TransientPersistentMap& theMap);
//! Create a persistent object for a cone
Standard_EXPORT static Handle(Surface) Translate (const Handle(Geom_ConicalSurface)& theSurf,
StdObjMgt_TransientPersistentMap& theMap);
//! Create a persistent object for a sphere
Standard_EXPORT static Handle(Surface) Translate (const Handle(Geom_SphericalSurface)& theSurf,
StdObjMgt_TransientPersistentMap& theMap);
//! Create a persistent object for a torus
Standard_EXPORT static Handle(Surface) Translate (const Handle(Geom_ToroidalSurface)& theSurf,
StdObjMgt_TransientPersistentMap& theMap);
//! Create a persistent object for a surface of linear extrusion
Standard_EXPORT static Handle(Surface) Translate (const Handle(Geom_SurfaceOfLinearExtrusion)& theSurf,
StdObjMgt_TransientPersistentMap& theMap);
//! Create a persistent object for a surface of evolution
Standard_EXPORT static Handle(Surface) Translate (const Handle(Geom_SurfaceOfRevolution)& theSurf,
StdObjMgt_TransientPersistentMap& theMap);
//! Create a persistent object for a Bezier surface
Standard_EXPORT static Handle(Surface) Translate (const Handle(Geom_BezierSurface)& theSurf,
StdObjMgt_TransientPersistentMap& theMap);
//! Create a persistent object for a BSpline surface
Standard_EXPORT static Handle(Surface) Translate (const Handle(Geom_BSplineSurface)& theSurf,
StdObjMgt_TransientPersistentMap& theMap);
//! Create a persistent object for a rectangylar trimmed surface
Standard_EXPORT static Handle(Surface) Translate (const Handle(Geom_RectangularTrimmedSurface)& theSurf,
StdObjMgt_TransientPersistentMap& theMap);
//! Create a persistent object for an offset surface
Standard_EXPORT static Handle(Surface) Translate (const Handle(Geom_OffsetSurface)& theSurf,
StdObjMgt_TransientPersistentMap& theMap);
};
//=======================================================================
// Elementary
//=======================================================================
template<>
Standard_CString ShapePersistent_Geom::subBase_gp<ShapePersistent_Geom::Surface,
gp_Ax3>
::PName() const;
//=======================================================================
// Plane
//=======================================================================
template<>
Standard_CString ShapePersistent_Geom::instance<ShapePersistent_Geom::subBase_gp<ShapePersistent_Geom::Surface, gp_Ax3>,
Geom_Plane,
gp_Ax3>
::PName() const;
template<>
void ShapePersistent_Geom::instance<ShapePersistent_Geom::subBase_gp<ShapePersistent_Geom::Surface, gp_Ax3>,
Geom_Plane,
gp_Ax3>
::Write(StdObjMgt_WriteData& theWriteData) const;
//=======================================================================
// Conical
//=======================================================================
template<>
Standard_CString ShapePersistent_Geom::instance<ShapePersistent_Geom::subBase_gp<ShapePersistent_Geom::Surface, gp_Ax3>,
Geom_ConicalSurface,
gp_Cone>
::PName() const;
template<>
void ShapePersistent_Geom::instance<ShapePersistent_Geom::subBase_gp<ShapePersistent_Geom::Surface, gp_Ax3>,
Geom_ConicalSurface,
gp_Cone>
::Write(StdObjMgt_WriteData& theWriteData) const;
//=======================================================================
// Cylindrical
//=======================================================================
template<>
Standard_CString ShapePersistent_Geom::instance<ShapePersistent_Geom::subBase_gp<ShapePersistent_Geom::Surface, gp_Ax3>,
Geom_CylindricalSurface,
gp_Cylinder>
::PName() const;
template<>
void ShapePersistent_Geom::instance<ShapePersistent_Geom::subBase_gp<ShapePersistent_Geom::Surface, gp_Ax3>,
Geom_CylindricalSurface,
gp_Cylinder>
::Write(StdObjMgt_WriteData& theWriteData) const;
//=======================================================================
// Spherical
//=======================================================================
template<>
Standard_CString ShapePersistent_Geom::instance<ShapePersistent_Geom::subBase_gp<ShapePersistent_Geom::Surface, gp_Ax3>,
Geom_SphericalSurface,
gp_Sphere>
::PName() const;
template<>
void ShapePersistent_Geom::instance<ShapePersistent_Geom::subBase_gp<ShapePersistent_Geom::Surface, gp_Ax3>,
Geom_SphericalSurface,
gp_Sphere>
::Write(StdObjMgt_WriteData& theWriteData) const;
//=======================================================================
// Toroidal
//=======================================================================
template<>
Standard_CString ShapePersistent_Geom::instance<ShapePersistent_Geom::subBase_gp<ShapePersistent_Geom::Surface, gp_Ax3>,
Geom_ToroidalSurface,
gp_Torus>
::PName() const;
template<>
void ShapePersistent_Geom::instance<ShapePersistent_Geom::subBase_gp<ShapePersistent_Geom::Surface, gp_Ax3>,
Geom_ToroidalSurface,
gp_Torus>
::Write(StdObjMgt_WriteData& theWriteData) const;
#endif

View File

@@ -49,7 +49,7 @@ public:
};
inline StdObjMgt_ReadData& operator >>
(StdObjMgt_ReadData& theReadData, Poly_Triangle& theTriangle)
(StdObjMgt_ReadData::Object theReadData, Poly_Triangle& theTriangle)
{
Standard_Integer N1, N2, N3;
theReadData >> N1 >> N2 >> N3;
@@ -57,4 +57,13 @@ inline StdObjMgt_ReadData& operator >>
return theReadData;
}
inline StdObjMgt_WriteData& operator <<
(StdObjMgt_WriteData::Object theWriteData, const Poly_Triangle& theTriangle)
{
Standard_Integer N1, N2, N3;
theTriangle.Get(N1, N2, N3);
theWriteData << N1 << N2 << N3;
return theWriteData;
}
#endif

View File

@@ -11,8 +11,9 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <ShapePersistent_HSequence.hxx>
#include <StdObjMgt_ReadData.hxx>
#include <StdObjMgt_WriteData.hxx>
#include <ShapePersistent_HSequence.hxx>
template <class SequenceClass>
@@ -22,6 +23,13 @@ void ShapePersistent_HSequence::node<SequenceClass>::Read
theReadData >> myPreviuos >> myItem >> myNext;
}
template <class SequenceClass>
void ShapePersistent_HSequence::node<SequenceClass>::Write
(StdObjMgt_WriteData& theWriteData) const
{
theWriteData << myPreviuos << myItem << myNext;
}
template <class SequenceClass>
void ShapePersistent_HSequence::instance<SequenceClass>::Read
(StdObjMgt_ReadData& theReadData)
@@ -29,6 +37,13 @@ void ShapePersistent_HSequence::instance<SequenceClass>::Read
theReadData >> myFirst >> myLast >> mySize;
}
template <class SequenceClass>
void ShapePersistent_HSequence::instance<SequenceClass>::Write
(StdObjMgt_WriteData& theWriteData) const
{
theWriteData << myFirst << myLast << mySize;
}
template <class SequenceClass>
Handle(SequenceClass)
ShapePersistent_HSequence::instance<SequenceClass>::Import() const
@@ -50,3 +65,48 @@ template class ShapePersistent_HSequence::instance<TColgp_HSequenceOfXYZ>;
template class ShapePersistent_HSequence::instance<TColgp_HSequenceOfPnt>;
template class ShapePersistent_HSequence::instance<TColgp_HSequenceOfDir>;
template class ShapePersistent_HSequence::instance<TColgp_HSequenceOfVec>;
//=======================================================================
// XYZ
//=======================================================================
template<>
Standard_CString ShapePersistent_HSequence::instance<TColgp_HSequenceOfXYZ>
::PName() const { return "PColgp_HSequenceOfXYZ"; }
template<>
Standard_CString ShapePersistent_HSequence::node<TColgp_HSequenceOfXYZ>
::PName() const { return "PColgp_SeqNodeOfHSequenceOfXYZ"; }
//=======================================================================
// Pnt
//=======================================================================
template<>
Standard_CString ShapePersistent_HSequence::instance<TColgp_HSequenceOfPnt>
::PName() const { return "PColgp_HSequenceOfPnt"; }
template<>
Standard_CString ShapePersistent_HSequence::node<TColgp_HSequenceOfPnt>
::PName() const { return "PColgp_SeqNodeOfHSequenceOfPnt"; }
//=======================================================================
// Dir
//=======================================================================
template<>
Standard_CString ShapePersistent_HSequence::instance<TColgp_HSequenceOfDir>
::PName() const { return "PColgp_HSequenceOfDir"; }
template<>
Standard_CString ShapePersistent_HSequence::node<TColgp_HSequenceOfDir>
::PName() const { return "PColgp_SeqNodeOfHSequenceOffDir"; }
//=======================================================================
// Vec
//=======================================================================
template<>
Standard_CString ShapePersistent_HSequence::instance<TColgp_HSequenceOfVec>
::PName() const { return "PColgp_HSequenceOfVec"; }
template<>
Standard_CString ShapePersistent_HSequence::node<TColgp_HSequenceOfVec>
::PName() const { return "PColgp_SeqNodeOfHSequenceOfVec"; }

View File

@@ -15,6 +15,8 @@
#ifndef _ShapePersistent_HSequence_HeaderFile
#define _ShapePersistent_HSequence_HeaderFile
#include <Standard_NotImplemented.hxx>
#include <StdObjMgt_Persistent.hxx>
#include <StdObject_gp_Vectors.hxx>
@@ -36,6 +38,23 @@ class ShapePersistent_HSequence
//! Read persistent data from a file.
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
//! Write persistent data to a file.
Standard_EXPORT virtual void Write (StdObjMgt_WriteData& theWriteData) const;
//! Gets persistent objects
Standard_EXPORT virtual void PChildren (SequenceOfPersistent& theChildren) const
{
theChildren.Append(this->myPreviuos);
theChildren.Append(this->myNext);
}
//! Returns persistent type name
Standard_EXPORT virtual Standard_CString PName() const
{
Standard_NotImplemented::Raise("ShapePersistent_HSequence::node::PName - not implemented");
return "";
}
const Handle(node)& Previuos() const { return myPreviuos; }
const Handle(node)& Next() const { return myNext; }
const ItemType& Item() const { return myItem; }
@@ -56,6 +75,23 @@ class ShapePersistent_HSequence
//! Read persistent data from a file.
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
//! Write persistent data to a file.
Standard_EXPORT virtual void Write (StdObjMgt_WriteData& theWriteData) const;
//! Gets persistent objects
Standard_EXPORT virtual void PChildren(SequenceOfPersistent& theChildren) const
{
theChildren.Append(this->myFirst);
theChildren.Append(this->myLast);
}
//! Returns persistent type name
Standard_EXPORT virtual Standard_CString PName() const
{
Standard_NotImplemented::Raise("ShapePersistent_HSequence::instance::PName - not implemented");
return "";
}
//! Import transient object from the persistent data.
Standard_EXPORT Handle(SequenceClass) Import() const;
@@ -72,4 +108,48 @@ public:
typedef instance<TColgp_HSequenceOfVec> Vec;
};
//=======================================================================
// XYZ
//=======================================================================
template<>
Standard_CString ShapePersistent_HSequence::instance<TColgp_HSequenceOfXYZ>
::PName() const;
template<>
Standard_CString ShapePersistent_HSequence::node<TColgp_HSequenceOfXYZ>
::PName() const;
//=======================================================================
// Pnt
//=======================================================================
template<>
Standard_CString ShapePersistent_HSequence::instance<TColgp_HSequenceOfPnt>
::PName() const;
template<>
Standard_CString ShapePersistent_HSequence::node<TColgp_HSequenceOfPnt>
::PName() const;
//=======================================================================
// Dir
//=======================================================================
template<>
Standard_CString ShapePersistent_HSequence::instance<TColgp_HSequenceOfDir>
::PName() const;
template<>
Standard_CString ShapePersistent_HSequence::node<TColgp_HSequenceOfDir>
::PName() const;
//=======================================================================
// Vec
//=======================================================================
template<>
Standard_CString ShapePersistent_HSequence::instance<TColgp_HSequenceOfVec>
::PName() const;
template<>
Standard_CString ShapePersistent_HSequence::node<TColgp_HSequenceOfVec>
::PName() const;
#endif

View File

@@ -12,6 +12,7 @@
// commercial license or contractual agreement.
#include <ShapePersistent_Poly.hxx>
#include <ShapePersistent_HArray1.hxx>
#include <Poly_Polygon2D.hxx>
#include <Poly_Polygon3D.hxx>
@@ -19,6 +20,12 @@
#include <Poly_Triangulation.hxx>
void ShapePersistent_Poly::pPolygon2D::PChildren
(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
{
theChildren.Append(myNodes);
}
Handle(Poly_Polygon2D) ShapePersistent_Poly::pPolygon2D::Import() const
{
if (myNodes.IsNull())
@@ -29,6 +36,13 @@ Handle(Poly_Polygon2D) ShapePersistent_Poly::pPolygon2D::Import() const
return aPolygon;
}
void ShapePersistent_Poly::pPolygon3D::PChildren
(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
{
theChildren.Append(myNodes);
theChildren.Append(myParameters);
}
Handle(Poly_Polygon3D) ShapePersistent_Poly::pPolygon3D::Import() const
{
if (myNodes.IsNull() || myParameters.IsNull())
@@ -40,6 +54,13 @@ Handle(Poly_Polygon3D) ShapePersistent_Poly::pPolygon3D::Import() const
return aPolygon;
}
void ShapePersistent_Poly::pPolygonOnTriangulation::PChildren
(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
{
theChildren.Append(myNodes);
theChildren.Append(myParameters);
}
Handle(Poly_PolygonOnTriangulation)
ShapePersistent_Poly::pPolygonOnTriangulation::Import() const
{
@@ -59,12 +80,20 @@ Handle(Poly_PolygonOnTriangulation)
return aPolygon;
}
void ShapePersistent_Poly::pTriangulation::PChildren
(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
{
theChildren.Append(myNodes);
theChildren.Append(myUVNodes);
theChildren.Append(myTriangles);
}
Handle(Poly_Triangulation) ShapePersistent_Poly::pTriangulation::Import() const
{
Handle(Poly_Triangulation) aTriangulation;
// Triangulation is not used
#if 0
#if 1
if (myNodes && myTriangles)
{
if (myUVNodes)
@@ -81,3 +110,104 @@ Handle(Poly_Triangulation) ShapePersistent_Poly::pTriangulation::Import() const
return aTriangulation;
}
Handle(ShapePersistent_Poly::Polygon2D)
ShapePersistent_Poly::Translate(const Handle(Poly_Polygon2D)& thePoly,
StdObjMgt_TransientPersistentMap& theMap)
{
Handle(Polygon2D) aPP;
if (!thePoly.IsNull())
{
if (theMap.IsBound(thePoly))
aPP = Handle(Polygon2D)::DownCast(theMap.Find(thePoly));
else
{
aPP = new Polygon2D;
aPP->myPersistent = new pPolygon2D;
aPP->myPersistent->myDeflection = thePoly->Deflection();
aPP->myPersistent->myNodes =
StdLPersistent_HArray1::Translate<TColgp_HArray1OfPnt2d>("PColgp_HArray1OfPnt2d", thePoly->Nodes());
theMap.Bind(thePoly, aPP);
}
}
return aPP;
}
Handle(ShapePersistent_Poly::Polygon3D)
ShapePersistent_Poly::Translate(const Handle(Poly_Polygon3D)& thePoly,
StdObjMgt_TransientPersistentMap& theMap)
{
Handle(Polygon3D) aPP = new Polygon3D;
if (!thePoly.IsNull())
{
if (theMap.IsBound(thePoly))
aPP = Handle(Polygon3D)::DownCast(theMap.Find(thePoly));
else
{
aPP = new Polygon3D;
aPP->myPersistent = new pPolygon3D;
aPP->myPersistent->myDeflection = thePoly->Deflection();
aPP->myPersistent->myNodes =
StdLPersistent_HArray1::Translate<TColgp_HArray1OfPnt>("PColgp_HArray1OfPnt", thePoly->Nodes());
if (thePoly->HasParameters()) {
aPP->myPersistent->myParameters =
StdLPersistent_HArray1::Translate<TColStd_HArray1OfReal>(thePoly->Parameters());
}
theMap.Bind(thePoly, aPP);
}
}
return aPP;
}
Handle(ShapePersistent_Poly::PolygonOnTriangulation)
ShapePersistent_Poly::Translate(const Handle(Poly_PolygonOnTriangulation)& thePolyOnTriang,
StdObjMgt_TransientPersistentMap& theMap)
{
Handle(PolygonOnTriangulation) aPPonT;
if (!thePolyOnTriang.IsNull())
{
if (theMap.IsBound(thePolyOnTriang))
aPPonT = Handle(PolygonOnTriangulation)::DownCast(theMap.Find(thePolyOnTriang));
else
{
aPPonT = new PolygonOnTriangulation;
aPPonT->myPersistent = new pPolygonOnTriangulation;
aPPonT->myPersistent->myDeflection = thePolyOnTriang->Deflection();
aPPonT->myPersistent->myNodes =
StdLPersistent_HArray1::Translate<TColStd_HArray1OfInteger>(thePolyOnTriang->Nodes());
if (thePolyOnTriang->HasParameters()) {
aPPonT->myPersistent->myParameters =
StdLPersistent_HArray1::Translate<TColStd_HArray1OfReal>(thePolyOnTriang->Parameters()->Array1());
}
theMap.Bind(thePolyOnTriang, aPPonT);
}
}
return aPPonT;
}
Handle(ShapePersistent_Poly::Triangulation)
ShapePersistent_Poly::Translate(const Handle(Poly_Triangulation)& thePolyTriang,
StdObjMgt_TransientPersistentMap& theMap)
{
Handle(Triangulation) aPT;
if (!thePolyTriang.IsNull())
{
if (theMap.IsBound(thePolyTriang))
aPT = Handle(Triangulation)::DownCast(theMap.Find(thePolyTriang));
else
{
aPT = new Triangulation;
aPT->myPersistent = new pTriangulation;
aPT->myPersistent->myNodes =
StdLPersistent_HArray1::Translate<TColgp_HArray1OfPnt>("PColgp_HArray1OfPnt", thePolyTriang->Nodes());
aPT->myPersistent->myTriangles =
StdLPersistent_HArray1::Translate<Poly_HArray1OfTriangle>("PPoly_HArray1OfTriangle", thePolyTriang->Triangles());
if (thePolyTriang->HasUVNodes()) {
aPT->myPersistent->myUVNodes =
StdLPersistent_HArray1::Translate<TColgp_HArray1OfPnt2d>("PColgp_HArray1OfPnt2d", thePolyTriang->UVNodes());
}
theMap.Bind(thePolyTriang, aPT);
}
}
return aPT;
}

View File

@@ -16,7 +16,9 @@
#define _ShapePersistent_Poly_HeaderFile
#include <StdObjMgt_SharedObject.hxx>
#include <StdObjMgt_TransientPersistentMap.hxx>
#include <StdObjMgt_ReadData.hxx>
#include <StdObjMgt_WriteData.hxx>
#include <StdLPersistent_HArray1.hxx>
#include <ShapePersistent_HArray1.hxx>
@@ -30,9 +32,15 @@ class ShapePersistent_Poly : private StdObjMgt_SharedObject
{
class pPolygon2D : public Standard_Transient
{
friend class ShapePersistent_Poly;
public:
inline void Read (StdObjMgt_ReadData& theReadData)
{ theReadData >> myDeflection >> myNodes; }
inline void Write (StdObjMgt_WriteData& theWriteData) const
{ theWriteData << myDeflection << myNodes; }
Standard_EXPORT void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
inline Standard_CString PName() const { return "PPoly_Polygon2D"; }
Handle(Poly_Polygon2D) Import() const;
@@ -43,9 +51,15 @@ class ShapePersistent_Poly : private StdObjMgt_SharedObject
class pPolygon3D : public Standard_Transient
{
friend class ShapePersistent_Poly;
public:
inline void Read (StdObjMgt_ReadData& theReadData)
{ theReadData >> myDeflection >> myNodes >> myParameters; }
inline void Write (StdObjMgt_WriteData& theWriteData) const
{ theWriteData << myDeflection << myNodes << myParameters; }
Standard_EXPORT void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
inline Standard_CString PName() const { return "PPoly_Polygon3D"; }
Handle(Poly_Polygon3D) Import() const;
@@ -57,9 +71,15 @@ class ShapePersistent_Poly : private StdObjMgt_SharedObject
class pPolygonOnTriangulation : public Standard_Transient
{
friend class ShapePersistent_Poly;
public:
inline void Read (StdObjMgt_ReadData& theReadData)
{ theReadData >> myDeflection >> myNodes >> myParameters; }
inline void Write (StdObjMgt_WriteData& theWriteData) const
{ theWriteData << myDeflection << myNodes << myParameters; }
Standard_EXPORT void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
inline Standard_CString PName() const { return "PPoly_PolygonOnTriangulation"; }
Handle(Poly_PolygonOnTriangulation) Import() const;
@@ -71,9 +91,15 @@ class ShapePersistent_Poly : private StdObjMgt_SharedObject
class pTriangulation : public Standard_Transient
{
friend class ShapePersistent_Poly;
public:
inline void Read (StdObjMgt_ReadData& theReadData)
{ theReadData >> myDeflection >> myNodes >> myUVNodes >> myTriangles; }
inline void Write (StdObjMgt_WriteData& theWriteData) const
{ theWriteData << myDeflection << myNodes << myUVNodes << myTriangles; }
Standard_EXPORT void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
inline Standard_CString PName() const { return "PPoly_Triangulation"; }
Handle(Poly_Triangulation) Import() const;
@@ -86,7 +112,7 @@ class ShapePersistent_Poly : private StdObjMgt_SharedObject
template <class Persistent, class Transient>
struct instance
: Delayed <DelayedBase<StdObjMgt_Persistent, Transient, Persistent> > {};
: public Delayed <DelayedBase<StdObjMgt_Persistent, Transient, Persistent> > {};
public:
typedef instance <pPolygon2D, Poly_Polygon2D> Polygon2D;
@@ -94,6 +120,20 @@ public:
typedef instance <pPolygonOnTriangulation,
Poly_PolygonOnTriangulation> PolygonOnTriangulation;
typedef instance <pTriangulation, Poly_Triangulation> Triangulation;
public:
//! Create a persistent object for a 2D polygon
Standard_EXPORT static Handle(Polygon2D) Translate (const Handle(Poly_Polygon2D)& thePoly,
StdObjMgt_TransientPersistentMap& theMap);
//! Create a persistent object for a 3D polygon
Standard_EXPORT static Handle(Polygon3D) Translate (const Handle(Poly_Polygon3D)& thePoly,
StdObjMgt_TransientPersistentMap& theMap);
//! Create a persistent object for a triangulation
Standard_EXPORT static Handle(PolygonOnTriangulation) Translate (const Handle(Poly_PolygonOnTriangulation)& thePolyOnTriang,
StdObjMgt_TransientPersistentMap& theMap);
//! Create a persistent object for a polygon on triangulation
Standard_EXPORT static Handle(Triangulation) Translate(const Handle(Poly_Triangulation)& thePolyTriang,
StdObjMgt_TransientPersistentMap& theMap);
};
#endif

View File

@@ -12,9 +12,15 @@
// commercial license or contractual agreement.
#include <ShapePersistent_TopoDS.hxx>
#include <ShapePersistent_BRep.hxx>
#include <BRep_Builder.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Iterator.hxx>
#include <TopoDS_Vertex.hxx>
#include <Standard_Assert.hxx>
enum
{
@@ -26,7 +32,6 @@ enum
ConvexMask = 64
};
//=======================================================================
//function : Read
//purpose : Read persistent data from a file
@@ -37,6 +42,18 @@ void ShapePersistent_TopoDS::HShape::Read (StdObjMgt_ReadData& theReadData)
StdObject_Shape::read (theReadData);
}
void ShapePersistent_TopoDS::HShape::Write (StdObjMgt_WriteData& theWriteData) const
{
theWriteData << myEntry;
StdObject_Shape::write (theWriteData);
}
void ShapePersistent_TopoDS::HShape::PChildren(SequenceOfPersistent& theChildren) const
{
theChildren.Append(myEntry);
StdObject_Shape::PChildren(theChildren);
}
void ShapePersistent_TopoDS::pTBase::setFlags
(const Handle(TopoDS_TShape)& theTShape) const
{
@@ -94,3 +111,131 @@ template class ShapePersistent_TopoDS::pTSimple<TopoDS_TShell>;
template class ShapePersistent_TopoDS::pTSimple<TopoDS_TSolid>;
template class ShapePersistent_TopoDS::pTSimple<TopoDS_TCompSolid>;
template class ShapePersistent_TopoDS::pTSimple<TopoDS_TCompound>;
//=======================================================================
//function : Translate
//purpose : Creates a persistent object from a shape
//=======================================================================
Handle(ShapePersistent_TopoDS::HShape)
ShapePersistent_TopoDS::Translate (const TopoDS_Shape& theShape,
StdObjMgt_TransientPersistentMap& theMap,
ShapePersistent_TriangleMode theTriangleMode)
{
Handle(HShape) pHShape;
if (theShape.IsNull())
return pHShape;
pHShape = new HShape;
if (theMap.IsBound(theShape.TShape()))
{
// found in the registered
Handle(StdPersistent_TopoDS::TShape) aPShape =
Handle(StdPersistent_TopoDS::TShape)::DownCast(theMap.Find(theShape.TShape()));
pHShape->myTShape = aPShape;
}
else
{
pTShape* aPTShape = 0;
switch (theShape.ShapeType())
{
case TopAbs_VERTEX: {
Handle(ShapePersistent_BRep::TVertex) aPVertex = new ShapePersistent_BRep::TVertex;
pHShape->myTShape = aPVertex;
aPVertex->myPersistent = ShapePersistent_BRep::Translate(TopoDS::Vertex(theShape), theMap);
aPTShape = aPVertex->myPersistent.get();
} break;
case TopAbs_EDGE: {
Handle(ShapePersistent_BRep::TEdge) aPEdge = new ShapePersistent_BRep::TEdge;
pHShape->myTShape = aPEdge;
aPEdge->myPersistent = ShapePersistent_BRep::Translate(TopoDS::Edge(theShape), theMap, theTriangleMode);
aPTShape = aPEdge->myPersistent.get();
} break;
case TopAbs_FACE: {
Handle(ShapePersistent_BRep::TFace) aPFace = new ShapePersistent_BRep::TFace;
pHShape->myTShape = aPFace;
aPFace->myPersistent = ShapePersistent_BRep::Translate(TopoDS::Face(theShape), theMap, theTriangleMode);
aPTShape = aPFace->myPersistent.get();
} break;
case TopAbs_WIRE: {
Handle(TWire) aPWire = new TWire;
pHShape->myTShape = aPWire;
aPWire->myPersistent = new TWire::pTObjectT;
aPTShape = aPWire->myPersistent.get();
} break;
case TopAbs_SHELL: {
Handle(TShell) aPShell = new TShell;
pHShape->myTShape = aPShell;
aPShell->myPersistent = new TShell::pTObjectT;
aPTShape = aPShell->myPersistent.get();
} break;
case TopAbs_SOLID: {
Handle(TSolid) aPSolid = new TSolid;
pHShape->myTShape = aPSolid;
aPSolid->myPersistent = new TSolid::pTObjectT;
aPTShape = aPSolid->myPersistent.get();
} break;
case TopAbs_COMPSOLID: {
Handle(TCompSolid) aPCompSolid = new TCompSolid;
pHShape->myTShape = aPCompSolid;
aPCompSolid->myPersistent = new TCompSolid::pTObjectT;
aPTShape = aPCompSolid->myPersistent.get();
} break;
case TopAbs_COMPOUND: {
Handle(TCompound) aPComp = new TCompound;
pHShape->myTShape = aPComp;
aPComp->myPersistent = new TCompound::pTObjectT;
aPTShape = aPComp->myPersistent.get();
} break;
case TopAbs_SHAPE:
default:
Standard_ASSERT_INVOKE ("Unsupported shape type");
break;
}
// Register in the persistent map
theMap.Bind(theShape.TShape(), pHShape->myTShape);
// Shape flags
Standard_Integer aFlags = 0;
if (theShape.Modified()) aFlags |= ModifiedMask;
if (theShape.Checked()) aFlags |= CheckedMask;
if (theShape.Orientable()) aFlags |= OrientableMask;
if (theShape.Closed()) aFlags |= ClosedMask;
if (theShape.Infinite()) aFlags |= InfiniteMask;
if (theShape.Convex()) aFlags |= ConvexMask;
aPTShape->myFlags = aFlags;
// Copy current Shape
TopoDS_Shape S = theShape;
S.Orientation(TopAbs_FORWARD);
S.Location(TopLoc_Location());
// Count the number of <sub-shape> of the Shape's TShape
Standard_Integer nbElem = 0;
TopoDS_Iterator anItCount(S);
while (anItCount.More()) {
++nbElem;
anItCount.Next();
}
if (nbElem > 0)
{
Handle(StdLPersistent_HArray1OfPersistent) aShapes =
new StdLPersistent_HArray1OfPersistent(1, nbElem);
// translate <sub-shapes>
TopoDS_Iterator anItTrans(S);
for (Standard_Integer i = 1; anItTrans.More(); anItTrans.Next(), ++i) {
aShapes->SetValue(i, Translate(anItTrans.Value(), theMap, theTriangleMode));
}
aPTShape->myShapes = StdLPersistent_HArray1::Translate<StdLPersistent_HArray1OfPersistent>
("PTopoDS_HArray1OfHShape", aShapes->Array1());
}
}
pHShape->myOrient = theShape.Orientation();
pHShape->myLocation = StdObject_Location::Translate(theShape.Location(), theMap);
return pHShape;
}

View File

@@ -15,10 +15,13 @@
#ifndef _ShapePersistent_TopoDS_HeaderFile
#define _ShapePersistent_TopoDS_HeaderFile
#include <ShapePersistent_TriangleMode.hxx>
#include <StdPersistent_TopoDS.hxx>
#include <StdPersistent_HArray1.hxx>
#include <StdLPersistent_HArray1.hxx>
#include <StdObject_Shape.hxx>
#include <StdObjMgt_TransientPersistentMap.hxx>
#include <TopoDS_TWire.hxx>
#include <TopoDS_TShell.hxx>
@@ -35,6 +38,12 @@ public:
public:
//! Read persistent data from a file.
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
//! Write persistent data to a file
Standard_EXPORT virtual void Write (StdObjMgt_WriteData& theWriteData) const;
//! Gets persistent child objects
Standard_EXPORT virtual void PChildren(SequenceOfPersistent& theChildren) const;
//! Returns persistent type name
Standard_EXPORT virtual Standard_CString PName() const { return "PTopoDS_HShape"; }
private:
Handle(StdObjMgt_Persistent) myEntry;
@@ -72,27 +81,30 @@ protected:
private:
template <class Target>
class pTSimple : public pTBase
{ virtual Handle(TopoDS_TShape) createTShape() const; };
{
virtual Handle(TopoDS_TShape) createTShape() const;
public:
inline Standard_CString PName() const;
};
template <class Persistent, class ShapesArray>
class pTObject : public Persistent
{
virtual void addShapes (TopoDS_Shape& theParent) const
{
pTBase::addShapesT<ShapesArray> (theParent);
}
{ pTBase::addShapesT<ShapesArray> (theParent); }
};
template <class Persistent, class ShapesArray>
struct tObjectT : Delayed <DelayedBase<TShape, TopoDS_TShape, pTBase>,
pTObject<Persistent, ShapesArray> > {};
struct tObjectT : public Delayed <DelayedBase<TShape, TopoDS_TShape, pTBase>,
pTObject<Persistent, ShapesArray> >
{ typedef pTObject<Persistent, ShapesArray> pTObjectT; };
protected:
template <class Persistent>
struct tObject : tObjectT<Persistent, StdLPersistent_HArray1::Persistent> {};
struct tObject : public tObjectT<Persistent, StdLPersistent_HArray1::Persistent> { };
template <class Persistent>
struct tObject1 : tObjectT<Persistent, StdPersistent_HArray1::Shape1> {};
struct tObject1 : public tObjectT<Persistent, StdPersistent_HArray1::Shape1> { };
public:
typedef tObject <pTSimple<TopoDS_TWire> > TWire;
@@ -106,6 +118,32 @@ public:
typedef tObject1 <pTSimple<TopoDS_TSolid> > TSolid1;
typedef tObject1 <pTSimple<TopoDS_TCompSolid> > TCompSolid1;
typedef tObject1 <pTSimple<TopoDS_TCompound> > TCompound1;
public:
//! Create a persistent object for a shape
Standard_EXPORT static Handle(HShape) Translate (const TopoDS_Shape& theShape,
StdObjMgt_TransientPersistentMap& theMap,
ShapePersistent_TriangleMode theTriangleMode);
};
template<>
inline Standard_CString ShapePersistent_TopoDS::pTSimple<TopoDS_TWire>::PName() const
{ return "PTopoDS_TWire"; }
template<>
inline Standard_CString ShapePersistent_TopoDS::pTSimple<TopoDS_TShell>::PName() const
{ return "PTopoDS_TShell"; }
template<>
inline Standard_CString ShapePersistent_TopoDS::pTSimple<TopoDS_TSolid>::PName() const
{ return "PTopoDS_TSolid"; }
template<>
inline Standard_CString ShapePersistent_TopoDS::pTSimple<TopoDS_TCompSolid>::PName() const
{ return "PTopoDS_TCompSolid"; }
template<>
inline Standard_CString ShapePersistent_TopoDS::pTSimple<TopoDS_TCompound>::PName() const
{ return "PTopoDS_TCompound"; }
#endif

View File

@@ -0,0 +1,14 @@
#ifndef _ShapePersistent_TriangleMode_HeaderFile
#define _ShapePersistent_TriangleMode_HeaderFile
#include <Standard_PrimitiveTypes.hxx>
enum ShapePersistent_TriangleMode
{
ShapePersistent_WithTriangle,
ShapePersistent_WithoutTriangle
};
#endif // _ShapePersistent_TriangleMode_HeaderFile