mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-09-13 14:27:08 +03:00
Compare commits
3 Commits
V7_8_1
...
CR0-710-Fi
Author | SHA1 | Date | |
---|---|---|---|
|
b7ae013d9d | ||
|
686120f2fb | ||
|
5c8d6b4466 |
@@ -247,6 +247,7 @@ n StdObjMgt
|
||||
n StdDrivers
|
||||
n StdObject
|
||||
n StdPersistent
|
||||
n StdStorage
|
||||
n ShapePersistent
|
||||
n TDF
|
||||
n TDataStd
|
||||
|
@@ -333,6 +333,8 @@ The applications that used these data persistence tools need to be updated to us
|
||||
|
||||
The existing data files in standard formats can be converted using OCCT 6.9.1 or a previous version, as follows.
|
||||
|
||||
@note Reading / writing custom files capability from OCCT 6.9.1 is restored in OCCT 7.2.0. See details in @ref upgrade_720_persistence section.
|
||||
|
||||
#### CSFDB files
|
||||
|
||||
Files in *CSFDB* format (usually with extension .csfdb) contain OCCT shape data that can be converted to BRep format.
|
||||
@@ -1103,3 +1105,127 @@ The following classes have been changed:
|
||||
* The last optional argument *RemoveInvalidFaces* has been removed from the constructor of class *BRepOffset_MakeOffset* and method *Initialize*.
|
||||
* The public method *BOPDS_DS::VerticesOnIn* has been renamed into *SubShapesOnIn* and the new output parameter *theCommonPB* has been added.
|
||||
|
||||
@section upgrade_occt720 Upgrade to OCCT 7.2.0
|
||||
|
||||
@subsection upgrade_occt720_correction_of_Offset_API Corrections in BRepOffset API
|
||||
|
||||
Class *BRepOffsetAPI_MakeOffsetShape*:
|
||||
* *BRepOffsetAPI_MakeOffsetShape::BRepOffsetAPI_MakeOffsetShape()* - constructor with parameters has been deleted.
|
||||
* *BRepOffsetAPI_MakeOffsetShape::PerformByJoin()* - method has been added. This method is old algorithm behaviour.
|
||||
|
||||
The code below shows new calling procedure:
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
|
||||
BRepOffsetAPI_MakeOffsetShape OffsetMaker;
|
||||
OffsetMaker.PerformByJoin(Shape, OffsetValue, Tolerance);
|
||||
NewShape = OffsetMaker.Shape();
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Class *BRepOffsetAPI_MakeThickSolid*:
|
||||
* *BRepOffsetAPI_MakeThickSolid::BRepOffsetAPI_MakeThickSolid()* - constructor with parameters has been deleted.
|
||||
* *BRepOffsetAPI_MakeThickSolid::MakeThickSolidByJoin()* - method has been added. This method is old algorithm behaviour.
|
||||
|
||||
The code below shows new calling procedure:
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
|
||||
BRepOffsetAPI_MakeThickSolid BodyMaker;
|
||||
BodyMaker.MakeThickSolidByJoin(myBody, facesToRemove, -myThickness / 50, 1.e-3);
|
||||
myBody = BodyMaker.Shape();
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
@subsection upgrade_720_persistence Restore OCCT 6.9.1 persistence
|
||||
|
||||
Capability of reading / writing files in legacy CSFDB format using functionality provided by *Storage* package and *ShapeSchema* from OCCT 6.9.1 has been restored in OCCT 7.2.0.
|
||||
|
||||
In DRAW Test Harness, commands fsdread / fsdwrite can be used to read and write shapes from / to that format.
|
||||
|
||||
The following code examples demonstrate how to read and store shapes from / to that format driver using *StdStorage* class.
|
||||
|
||||
Reading CSFDB file:
|
||||
|
||||
~~~~
|
||||
// aDriver should be created and opened for reading
|
||||
Handle(StdStorage_Data) aData;
|
||||
|
||||
// Read data from the driver
|
||||
// StdStorage::Read creates aData instance automatically if it is null
|
||||
Storage_Error anError = StdStorage::Read(aFileName, aData);
|
||||
if (anError != Storage_VSOk)
|
||||
{
|
||||
// Error processing
|
||||
}
|
||||
|
||||
// Get root objects
|
||||
Handle(StdStorage_RootData) aRootData = aData->RootData();
|
||||
Handle(StdStorage_HSequenceOfRoots) aRoots = aRootData->Roots();
|
||||
if (!aRoots.IsNull())
|
||||
{
|
||||
// Iterator over the sequence of root objects
|
||||
for (StdStorage_HSequenceOfRoots::Iterator anIt(*aRoots); anIt.More(); anIt.Next())
|
||||
{
|
||||
Handle(StdStorage_Root)& aRoot = anIt.ChangeValue();
|
||||
// Get a persistent root's object
|
||||
Handle(StdObjMgt_Persistent) aPObject = aRoot->Object();
|
||||
if (!aPObject.IsNull())
|
||||
{
|
||||
Handle(ShapePersistent_TopoDS::HShape) aHShape = Handle(ShapePersistent_TopoDS::HShape)::DownCast(aPObject);
|
||||
if (aHShape) // Downcast to an expected type to import transient data
|
||||
{
|
||||
TopoDS_Shape aShape = aHShape->Import();
|
||||
shapes.Append(aShape);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
~~~~
|
||||
|
||||
Writing CSFDB file:
|
||||
|
||||
~~~~
|
||||
// Create a file driver
|
||||
NCollection_Handle<Storage_BaseDriver> aFileDriver(new FSD_File());
|
||||
|
||||
// Try to open the file driver for writing
|
||||
try
|
||||
{
|
||||
OCC_CATCH_SIGNALS
|
||||
PCDM_ReadWriter::Open(*aFileDriver, TCollection_ExtendedString(CStringA(filename).GetBuffer()), Storage_VSWrite);
|
||||
}
|
||||
catch (Standard_Failure& e)
|
||||
{
|
||||
// Error processing
|
||||
}
|
||||
|
||||
// Create a storage data instance
|
||||
Handle(StdStorage_Data) aData = new StdStorage_Data;
|
||||
// Set an axiliary application name (optional)
|
||||
aData->HeaderData()->SetApplicationName(TCollection_ExtendedString("Application"));
|
||||
|
||||
// Provide a map to track sharing
|
||||
StdObjMgt_TransientPersistentMap aMap;
|
||||
// Iterator over a collection of shapes
|
||||
for (Standard_Integer i = 1; i <= shapes.Length(); ++i)
|
||||
{
|
||||
TopoDS_Shape aShape = shapes.Value(i);
|
||||
// Translate a shape to a persistent object
|
||||
Handle(ShapePersistent_TopoDS::HShape) aPShape =
|
||||
ShapePersistent_TopoDS::Translate(aShape, aMap, ShapePersistent_WithTriangle);
|
||||
if (aPShape.IsNull())
|
||||
{
|
||||
// Error processing
|
||||
}
|
||||
|
||||
// Construct a root name
|
||||
TCollection_AsciiString aName = "Shape_";
|
||||
aName += i;
|
||||
|
||||
// Add a root to storage data
|
||||
Handle(StdStorage_Root) aRoot = new StdStorage_Root(aName, aPShape);
|
||||
aData->RootData()->AddRoot(aRoot);
|
||||
}
|
||||
|
||||
// Write storage data to the driver
|
||||
Storage_Error anError = StdStorage::Write(*aFileDriver, aData);
|
||||
if (anError != Storage_VSOk)
|
||||
{
|
||||
// Error processing
|
||||
}
|
||||
~~~~
|
||||
|
@@ -484,10 +484,12 @@ The collection for shapes can be found in the *TopTools* package. As *BRepOffset
|
||||
facesToRemove.Append(faceToRemove);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
All the necessary data are now available so you can create your hollowed solid by calling the *BRepOffsetAPI_MakeThickSolid* constructor:
|
||||
All the necessary data are now available so you can create your hollowed solid by calling the *BRepOffsetAPI_MakeThickSolid* MakeThickSolidByJoin method:
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
|
||||
MyBody = BRepOffsetAPI_MakeThickSolid(myBody, facesToRemove, -myThickness / 50, 1.e-3);
|
||||
BRepOffsetAPI_MakeThickSolid BodyMaker;
|
||||
BodyMaker.MakeThickSolidByJoin(myBody, facesToRemove, -myThickness / 50, 1.e-3);
|
||||
myBody = BodyMaker.Shape();
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
@@ -812,7 +814,9 @@ Complete definition of MakeBottle function (defined in the file src/MakeBottle.c
|
||||
|
||||
TopTools_ListOfShape facesToRemove;
|
||||
facesToRemove.Append(faceToRemove);
|
||||
myBody = BRepOffsetAPI_MakeThickSolid(myBody, facesToRemove, -myThickness / 50, 1.e-3);
|
||||
BRepOffsetAPI_MakeThickSolid BodyMaker;
|
||||
BodyMaker.MakeThickSolidByJoin(myBody, facesToRemove, -myThickness / 50, 1.e-3);
|
||||
myBody = BodyMaker.Shape();
|
||||
// Threading : Create Surfaces
|
||||
Handle(Geom_CylindricalSurface) aCyl1 = new Geom_CylindricalSurface(neckAx2, myNeckRadius * 0.99);
|
||||
Handle(Geom_CylindricalSurface) aCyl2 = new Geom_CylindricalSurface(neckAx2, myNeckRadius * 1.05);
|
||||
|
@@ -2100,11 +2100,44 @@ These classes provide the following services:
|
||||
* Creation of tapered shapes using draft angles;
|
||||
* Creation of sweeps.
|
||||
|
||||
@subsection occt_modalg_7_1 Shelling
|
||||
@subsection occt_modalg_7_1 Offset computation
|
||||
|
||||
Offset computation can be performed using *BRepOffsetAPI_MakeOffsetShape*. This class provides API to the two different offset algorithms:
|
||||
|
||||
Offset algorithm based on computation of the analytical continuation. Meaning of the parameters can be found in *BRepOffsetAPI_MakeOffsetShape::PerformByJoin* method description. The list below demonstrates principal scheme of this algorithm:
|
||||
|
||||
* At the first step, the offsets are computed.
|
||||
* After this, the analytical continuations are computed for each offset.
|
||||
* Pairwise intersection is computed according to the original topological information (sharing, number of neighbors, etc.).
|
||||
* The offset shape is assembled.
|
||||
|
||||
The second algorithm is based on the fact that the offset computation for a single face without continuation can always be built. The list below shows simple offset algorithm:
|
||||
* Each surface is mapped to its geometric offset surface.
|
||||
* For each edge, pcurves are mapped to the same pcurves on offset surfaces.
|
||||
* For each edge, 3d curve is constructed by re-approximation of pcurve on the first offset face.
|
||||
* Position of each vertex in a result shell is computed as average point of all ends of edges sharing that vertex.
|
||||
* Tolerances are updated according to the resulting geometry.
|
||||
The possible drawback of the simple algorithm is that it leads, in general case, to tolerance increasing. The tolerances have to grow in order to cover the gaps between the neighbor faces in the output. It should be noted that the actual tolerance growth depends on the offset distance and the quality of joints between the input faces. Anyway the good input shell (smooth connections between adjacent faces) will lead to good result.
|
||||
|
||||
The snippets below show usage examples:
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
|
||||
BRepOffsetAPI_MakeOffsetShape OffsetMaker1;
|
||||
// Computes offset shape using analytical continuation mechanism.
|
||||
OffsetMaker1.PerformByJoin(Shape, OffsetValue, Tolerance);
|
||||
if (OffsetMaker1.IsDone())
|
||||
NewShape = OffsetMaker1.Shape();
|
||||
|
||||
BRepOffsetAPI_MakeOffsetShape OffsetMaker2;
|
||||
// Computes offset shape using simple algorithm.
|
||||
OffsetMaker2.PerformBySimple(Shape, OffsetValue);
|
||||
if (OffsetMaker2.IsDone())
|
||||
NewShape = OffsetMaker2.Shape();
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
@subsection occt_modalg_7_2 Shelling
|
||||
|
||||
Shelling is used to offset given faces of a solid by a specific value. It rounds or intersects adjacent faces along its edges depending on the convexity of the edge.
|
||||
|
||||
The constructor *BRepOffsetAPI_MakeThickSolid* shelling operator takes the solid, the list of faces to remove and an offset value as input.
|
||||
The MakeThickSolidByJoin method of the *BRepOffsetAPI_MakeThickSolid* takes the solid, the list of faces to remove and an offset value as input.
|
||||
|
||||
~~~~~
|
||||
TopoDS_Solid SolidInitial = ...;
|
||||
@@ -2119,17 +2152,28 @@ for (Standard_Integer i = 1 ;i <= n; i++) {
|
||||
LCF.Append(SF);
|
||||
}
|
||||
|
||||
Result = BRepOffsetAPI_MakeThickSolid (SolidInitial,
|
||||
LCF,
|
||||
Of,
|
||||
Tol);
|
||||
BRepOffsetAPI_MakeThickSolid SolidMaker;
|
||||
SolidMaker.MakeThickSolidByJoin(SolidInitial,
|
||||
LCF,
|
||||
Of,
|
||||
Tol);
|
||||
if (SolidMaker.IsDone())
|
||||
Result = SolidMaker.Shape();
|
||||
~~~~~
|
||||
|
||||
@image html /user_guides/modeling_algos/images/modeling_algos_image042.png "Shelling"
|
||||
@image latex /user_guides/modeling_algos/images/modeling_algos_image042.png "Shelling"
|
||||
|
||||
Also it is possible to create solid between shell, offset shell. This functionality can be called using *BRepOffsetAPI_MakeThickSolid::MakeThickSolidBySimple* method. The code below shows usage example:
|
||||
|
||||
@subsection occt_modalg_7_2 Draft Angle
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
|
||||
BRepOffsetAPI_MakeThickSolid SolidMaker;
|
||||
SolidMaker.MakeThickSolidBySimple(Shell, OffsetValue);
|
||||
if (myDone.IsDone())
|
||||
Solid = SolidMaker.Shape();
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
@subsection occt_modalg_7_3 Draft Angle
|
||||
|
||||
*BRepOffsetAPI_DraftAngle* class allows modifying a shape by applying draft angles to its planar, cylindrical and conical faces.
|
||||
|
||||
@@ -2182,7 +2226,7 @@ else {
|
||||
@image html /user_guides/modeling_algos/images/modeling_algos_image043.png "DraftAngle"
|
||||
@image latex /user_guides/modeling_algos/images/modeling_algos_image043.png "DraftAngle"
|
||||
|
||||
@subsection occt_modalg_7_3 Pipe Constructor
|
||||
@subsection occt_modalg_7_4 Pipe Constructor
|
||||
|
||||
*BRepOffsetAPI_MakePipe* class allows creating a pipe from a Spine, which is a Wire and a Profile which is a Shape. This implementation is limited to spines with smooth transitions, sharp transitions are precessed by *BRepOffsetAPI_MakePipeShell*. To be more precise the continuity must be G1, which means that the tangent must have the same direction, though not necessarily the same magnitude, at neighboring edges.
|
||||
|
||||
@@ -2197,7 +2241,7 @@ TopoDS_Shape Pipe = BRepOffsetAPI_MakePipe(Spine,Profile);
|
||||
@image html /user_guides/modeling_algos/images/modeling_algos_image044.png "Example of a Pipe"
|
||||
@image latex /user_guides/modeling_algos/images/modeling_algos_image044.png "Example of a Pipe"
|
||||
|
||||
@subsection occt_modalg_7_4 Evolved Solid
|
||||
@subsection occt_modalg_7_5 Evolved Solid
|
||||
|
||||
*BRepOffsetAPI_MakeEvolved* class allows creating an evolved solid from a Spine (planar face or wire) and a profile (wire).
|
||||
|
||||
|
@@ -2558,8 +2558,10 @@ void CModelingDoc::OnThickLocal()
|
||||
Ex.Next(); //this is the front face
|
||||
TopoDS_Shape aFace = Ex.Current();
|
||||
aList.Append(aFace);
|
||||
|
||||
TopoDS_Shape aThickSolid = BRepOffsetAPI_MakeThickSolid(S1,aList,10,0.01);
|
||||
|
||||
BRepOffsetAPI_MakeThickSolid aSolidMaker;
|
||||
aSolidMaker.MakeThickSolidByJoin(S1,aList,10,0.01);
|
||||
TopoDS_Shape aThickSolid = aSolidMaker.Shape();
|
||||
|
||||
Handle(AIS_Shape) ais1 = new AIS_Shape(aThickSolid);
|
||||
myAISContext->SetColor(ais1,Quantity_NOC_RED,Standard_False);
|
||||
@@ -2607,7 +2609,9 @@ void CModelingDoc::OnOffsetLocal()
|
||||
Fit();
|
||||
Sleep(500);
|
||||
|
||||
TopoDS_Shape anOffsetShape1 = BRepOffsetAPI_MakeOffsetShape(S1,60,0.01);
|
||||
BRepOffsetAPI_MakeOffsetShape aShapeMaker1;
|
||||
aShapeMaker1.PerformByJoin(S1,60,0.01);
|
||||
TopoDS_Shape anOffsetShape1 = aShapeMaker1.Shape();
|
||||
|
||||
Handle(AIS_Shape) ais1 = new AIS_Shape(anOffsetShape1);
|
||||
myAISContext->SetColor(ais1,Quantity_NOC_MATRABLUE,Standard_False);
|
||||
@@ -2627,8 +2631,10 @@ void CModelingDoc::OnOffsetLocal()
|
||||
Fit();
|
||||
Sleep(500);
|
||||
|
||||
TopoDS_Shape anOffsetShape2 = BRepOffsetAPI_MakeOffsetShape(S2,-40,0.01,
|
||||
BRepOffset_Skin,Standard_False,Standard_False,GeomAbs_Arc);
|
||||
BRepOffsetAPI_MakeOffsetShape aShapeMaker2;
|
||||
aShapeMaker2.PerformByJoin(S2,-40,0.01,
|
||||
BRepOffset_Skin,Standard_False,Standard_False,GeomAbs_Arc);
|
||||
TopoDS_Shape anOffsetShape2 = aShapeMaker2.Shape();
|
||||
|
||||
Handle(AIS_Shape) ais2 = new AIS_Shape(anOffsetShape2);
|
||||
myAISContext->SetColor(ais2,Quantity_NOC_MATRABLUE);
|
||||
|
@@ -140,7 +140,9 @@ MakeBottle(const Standard_Real myWidth, const Standard_Real myHeight,
|
||||
|
||||
TopTools_ListOfShape facesToRemove;
|
||||
facesToRemove.Append(faceToRemove);
|
||||
myBody = BRepOffsetAPI_MakeThickSolid(myBody, facesToRemove, -myThickness / 50, 1.e-3);
|
||||
BRepOffsetAPI_MakeThickSolid aSolidMaker;
|
||||
aSolidMaker.MakeThickSolidByJoin(myBody, facesToRemove, -myThickness / 50, 1.e-3);
|
||||
myBody = aSolidMaker.Shape();
|
||||
// Threading : Create Surfaces
|
||||
Handle(Geom_CylindricalSurface) aCyl1 = new Geom_CylindricalSurface(neckAx2, myNeckRadius * 0.99);
|
||||
Handle(Geom_CylindricalSurface) aCyl2 = new Geom_CylindricalSurface(neckAx2, myNeckRadius * 1.05);
|
||||
|
661
src/BRepOffset/BRepOffset_MakeSimpleOffset.cxx
Normal file
661
src/BRepOffset/BRepOffset_MakeSimpleOffset.cxx
Normal file
@@ -0,0 +1,661 @@
|
||||
// Created on: 2016-10-13
|
||||
// Created by: Alexander MALYSHEV
|
||||
// Copyright (c) 1995-1999 Matra Datavision
|
||||
// Copyright (c) 1999-2016 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
// Include self.
|
||||
#include <BRepOffset_MakeSimpleOffset.hxx>
|
||||
|
||||
#include <Adaptor3d_CurveOnSurface.hxx>
|
||||
#include <BRep_Builder.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <BRepLib.hxx>
|
||||
#include <BRepLib_MakeEdge.hxx>
|
||||
#include <BRepLib_MakeFace.hxx>
|
||||
#include <BRepTools_Quilt.hxx>
|
||||
#include <BRepAdaptor_HCurve2d.hxx>
|
||||
#include <BRepAdaptor_HSurface.hxx>
|
||||
#include <BRepAdaptor_Surface.hxx>
|
||||
#include <BRepOffset_SimpleOffset.hxx>
|
||||
#include <BRepTools_Modifier.hxx>
|
||||
#include <Geom_TrimmedCurve.hxx>
|
||||
#include <Geom2d_Line.hxx>
|
||||
#include <GeomFill_Generator.hxx>
|
||||
#include <Extrema_LocateExtPC.hxx>
|
||||
#include <NCollection_List.hxx>
|
||||
#include <ShapeAnalysis_FreeBounds.hxx>
|
||||
#include <ShapeFix_Edge.hxx>
|
||||
#include <TopExp.hxx>
|
||||
#include <TopExp_Explorer.hxx>
|
||||
#include <TopoDS_Edge.hxx>
|
||||
#include <TopoDS_Face.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
|
||||
#include <TopTools_ListIteratorOfListOfShape.hxx>
|
||||
|
||||
|
||||
//=============================================================================
|
||||
//function : BRepOffset_MakeSimpleOffset
|
||||
//purpose : Constructor
|
||||
//=============================================================================
|
||||
BRepOffset_MakeSimpleOffset::BRepOffset_MakeSimpleOffset()
|
||||
: myIsBuildSolid(Standard_False),
|
||||
myMaxAngle(0.0),
|
||||
myError(BRepOffsetSimple_OK),
|
||||
myIsDone(Standard_False)
|
||||
{
|
||||
myReShape = new ShapeBuild_ReShape();
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : BRepOffset_MakeSimpleOffset
|
||||
//purpose : Constructor
|
||||
//=============================================================================
|
||||
BRepOffset_MakeSimpleOffset::BRepOffset_MakeSimpleOffset(const TopoDS_Shape& theInputShape,
|
||||
const Standard_Real theOffsetValue)
|
||||
: myInputShape(theInputShape),
|
||||
myOffsetValue(theOffsetValue),
|
||||
myIsBuildSolid(Standard_False),
|
||||
myMaxAngle(0.0),
|
||||
myError(BRepOffsetSimple_OK),
|
||||
myIsDone(Standard_False)
|
||||
{
|
||||
myReShape = new ShapeBuild_ReShape();
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : Initialize
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
void BRepOffset_MakeSimpleOffset::Initialize(const TopoDS_Shape& theInputShape,
|
||||
const Standard_Real theOffsetValue)
|
||||
{
|
||||
myInputShape = theInputShape;
|
||||
myOffsetValue = theOffsetValue;
|
||||
Clear();
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : GetErrorMessage
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
TCollection_AsciiString BRepOffset_MakeSimpleOffset::GetErrorMessage() const
|
||||
{
|
||||
TCollection_AsciiString anError = "";
|
||||
|
||||
if (myError == BRepOffsetSimple_NullInputShape)
|
||||
{
|
||||
anError = "Null input shape";
|
||||
return anError;
|
||||
}
|
||||
else if (myError == BRepOffsetSimple_ErrorOffsetComputation)
|
||||
{
|
||||
anError = "Error during offset construction";
|
||||
return anError;
|
||||
}
|
||||
else if (myError == BRepOffsetSimple_ErrorWallFaceComputation)
|
||||
{
|
||||
anError = "Error during building wall face";
|
||||
return anError;
|
||||
}
|
||||
else if (myError == BRepOffsetSimple_ErrorInvalidNbShells)
|
||||
{
|
||||
anError = "Result contains two or more shells";
|
||||
return anError;
|
||||
}
|
||||
else if (myError == BRepOffsetSimple_ErrorNonClosedShell)
|
||||
{
|
||||
anError = "Result shell is not closed";
|
||||
return anError;
|
||||
}
|
||||
|
||||
return anError;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : Clear
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
void BRepOffset_MakeSimpleOffset::Clear()
|
||||
{
|
||||
myIsDone = Standard_False;
|
||||
myError = BRepOffsetSimple_OK;
|
||||
myMaxAngle = 0.0;
|
||||
myMapVE.Clear();
|
||||
myReShape->Clear(); // Clear possible stored modifications.
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : GetSafeOffset
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
Standard_Real BRepOffset_MakeSimpleOffset::GetSafeOffset(const Standard_Real theExpectedToler)
|
||||
{
|
||||
if (myInputShape.IsNull())
|
||||
return 0.0; // Input shape is null.
|
||||
|
||||
// Compute max angle in faces junctions.
|
||||
if (myMaxAngle == 0.0) // Non-initialized.
|
||||
ComputeMaxAngle();
|
||||
|
||||
Standard_Real aMaxTol = 0.0;
|
||||
aMaxTol = BRep_Tool::MaxTolerance(myInputShape, TopAbs_VERTEX);
|
||||
|
||||
const Standard_Real anExpOffset = Max((theExpectedToler - aMaxTol) / (2.0 * myMaxAngle),
|
||||
0.0); // Minimal distance can't be lower than 0.0.
|
||||
return anExpOffset;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : Perform
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
void BRepOffset_MakeSimpleOffset::Perform()
|
||||
{
|
||||
// Clear result of previous computations.
|
||||
Clear();
|
||||
|
||||
// Check shape existence.
|
||||
if (myInputShape.IsNull())
|
||||
{
|
||||
myError = BRepOffsetSimple_NullInputShape;
|
||||
return;
|
||||
}
|
||||
|
||||
if (myMaxAngle == 0.0) // Non-initialized.
|
||||
ComputeMaxAngle();
|
||||
|
||||
myBuilder.Init(myInputShape);
|
||||
Handle(BRepOffset_SimpleOffset) aMapper = new BRepOffset_SimpleOffset(myInputShape, myOffsetValue);
|
||||
myBuilder.Perform(aMapper);
|
||||
|
||||
if (!myBuilder.IsDone())
|
||||
{
|
||||
myError = BRepOffsetSimple_ErrorOffsetComputation;
|
||||
return;
|
||||
}
|
||||
|
||||
myResShape = myBuilder.ModifiedShape(myInputShape);
|
||||
|
||||
// Fix degeneracy. Degenerated edge should be mapped to the degenerated.
|
||||
BRep_Builder aBB;
|
||||
TopExp_Explorer anExpSE(myInputShape, TopAbs_EDGE);
|
||||
for(; anExpSE.More(); anExpSE.Next())
|
||||
{
|
||||
const TopoDS_Edge & aCurrEdge = TopoDS::Edge(anExpSE.Current());
|
||||
|
||||
if (!BRep_Tool::Degenerated(aCurrEdge))
|
||||
continue;
|
||||
|
||||
const TopoDS_Edge & anEdge = TopoDS::Edge(myBuilder.ModifiedShape(aCurrEdge));
|
||||
aBB.Degenerated(anEdge, Standard_True);
|
||||
}
|
||||
|
||||
// Restore walls for solid.
|
||||
if (myIsBuildSolid && !BuildMissingWalls())
|
||||
return;
|
||||
|
||||
myIsDone = Standard_True;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : tgtfaces
|
||||
//purpose : check the angle at the border between two squares.
|
||||
// Two shares should have a shared front edge.
|
||||
//=============================================================================
|
||||
static void tgtfaces(const TopoDS_Edge& Ed,
|
||||
const TopoDS_Face& F1,
|
||||
const TopoDS_Face& F2,
|
||||
const Standard_Boolean couture,
|
||||
Standard_Real& theResAngle)
|
||||
{
|
||||
// Check that pcurves exist on both faces of edge.
|
||||
Standard_Real aFirst,aLast;
|
||||
Handle(Geom2d_Curve) aCurve;
|
||||
aCurve = BRep_Tool::CurveOnSurface(Ed,F1,aFirst,aLast);
|
||||
if(aCurve.IsNull())
|
||||
return;
|
||||
aCurve = BRep_Tool::CurveOnSurface(Ed,F2,aFirst,aLast);
|
||||
if(aCurve.IsNull())
|
||||
return;
|
||||
|
||||
Standard_Real u;
|
||||
TopoDS_Edge E = Ed;
|
||||
BRepAdaptor_Surface aBAS1(F1,Standard_False);
|
||||
BRepAdaptor_Surface aBAS2(F2,Standard_False);
|
||||
|
||||
Handle(BRepAdaptor_HSurface) HS1 = new BRepAdaptor_HSurface (aBAS1);
|
||||
Handle(BRepAdaptor_HSurface) HS2;
|
||||
if(couture) HS2 = HS1;
|
||||
else HS2 = new BRepAdaptor_HSurface(aBAS2);
|
||||
//case when edge lies on the one face
|
||||
|
||||
E.Orientation(TopAbs_FORWARD);
|
||||
BRepAdaptor_Curve2d C2d1(E, F1);
|
||||
if(couture) E.Orientation(TopAbs_REVERSED);
|
||||
BRepAdaptor_Curve2d C2d2(E,F2);
|
||||
|
||||
Standard_Boolean rev1 = (F1.Orientation() == TopAbs_REVERSED);
|
||||
Standard_Boolean rev2 = (F2.Orientation() == TopAbs_REVERSED);
|
||||
Standard_Real f,l,eps;
|
||||
BRep_Tool::Range(E,f,l);
|
||||
Extrema_LocateExtPC ext;
|
||||
|
||||
eps = (l - f) / 100.0;
|
||||
f += eps; // to avoid calculations on
|
||||
l -= eps; // points of pointed squares.
|
||||
gp_Pnt2d p;
|
||||
gp_Pnt pp1,pp2;//,PP;
|
||||
gp_Vec du1, dv1;
|
||||
gp_Vec du2, dv2;
|
||||
gp_Vec d1,d2;
|
||||
Standard_Real norm;
|
||||
|
||||
const Standard_Integer NBPNT = 23;
|
||||
for(Standard_Integer i = 0; i <= NBPNT; i++)
|
||||
{
|
||||
// First suppose that this is sameParameter
|
||||
u = f + (l - f) * i / NBPNT;
|
||||
|
||||
// take derivatives of surfaces at the same u, and compute normals
|
||||
C2d1.D0(u,p);
|
||||
HS1->D1 (p.X(), p.Y(), pp1, du1, dv1);
|
||||
d1 = (du1.Crossed(dv1));
|
||||
norm = d1.Magnitude();
|
||||
if (norm > 1.e-12) d1 /= norm;
|
||||
else continue; // skip degenerated point
|
||||
if(rev1) d1.Reverse();
|
||||
|
||||
C2d2.D0(u,p);
|
||||
HS2->D1 (p.X(), p.Y(), pp2, du2, dv2);
|
||||
d2 = (du2.Crossed(dv2));
|
||||
norm = d2.Magnitude();
|
||||
if (norm > 1.e-12) d2 /= norm;
|
||||
else continue; // skip degenerated point
|
||||
if(rev2) d2.Reverse();
|
||||
|
||||
// Compute angle.
|
||||
Standard_Real aCurrentAng = d1.Angle(d2);
|
||||
|
||||
theResAngle = Max(theResAngle, aCurrentAng);
|
||||
}
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
// function : ComputeMaxAngleOnShape
|
||||
// purpose : Code the regularities on all edges of the shape, boundary of
|
||||
// two faces that do not have it.
|
||||
//=============================================================================
|
||||
static void ComputeMaxAngleOnShape(const TopoDS_Shape& S,
|
||||
Standard_Real& theResAngle)
|
||||
{
|
||||
TopTools_IndexedDataMapOfShapeListOfShape M;
|
||||
TopExp::MapShapesAndAncestors(S,TopAbs_EDGE,TopAbs_FACE,M);
|
||||
TopTools_ListIteratorOfListOfShape It;
|
||||
TopExp_Explorer Ex;
|
||||
TopoDS_Face F1,F2;
|
||||
Standard_Boolean found, couture;
|
||||
for(Standard_Integer i = 1; i <= M.Extent(); i++)
|
||||
{
|
||||
TopoDS_Edge E = TopoDS::Edge(M.FindKey(i));
|
||||
found = Standard_False; couture = Standard_False;
|
||||
F1.Nullify();
|
||||
for(It.Initialize(M.FindFromIndex(i));It.More() && !found;It.Next())
|
||||
{
|
||||
if(F1.IsNull()) { F1 = TopoDS::Face(It.Value()); }
|
||||
else
|
||||
{
|
||||
if(!F1.IsSame(TopoDS::Face(It.Value())))
|
||||
{
|
||||
found = Standard_True;
|
||||
F2 = TopoDS::Face(It.Value());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!found && !F1.IsNull()){//is it a sewing edge?
|
||||
TopAbs_Orientation orE = E.Orientation();
|
||||
TopoDS_Edge curE;
|
||||
for(Ex.Init(F1,TopAbs_EDGE);Ex.More() && !found;Ex.Next()){
|
||||
curE= TopoDS::Edge(Ex.Current());
|
||||
if(E.IsSame(curE) && orE != curE.Orientation())
|
||||
{
|
||||
found = Standard_True;
|
||||
couture = Standard_True;
|
||||
F2 = F1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(found)
|
||||
{
|
||||
if(BRep_Tool::Continuity(E,F1,F2)<=GeomAbs_C0)
|
||||
{
|
||||
try
|
||||
{
|
||||
tgtfaces(E, F1, F2, couture, theResAngle);
|
||||
}
|
||||
catch(Standard_Failure)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : ComputeMaxAngle
|
||||
//purpose : Computes max angle in faces junction
|
||||
//=============================================================================
|
||||
void BRepOffset_MakeSimpleOffset::ComputeMaxAngle()
|
||||
{
|
||||
ComputeMaxAngleOnShape(myInputShape, myMaxAngle);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : BuildMissingWalls
|
||||
//purpose : Builds walls to the result solid.
|
||||
//=============================================================================
|
||||
Standard_Boolean BRepOffset_MakeSimpleOffset::BuildMissingWalls()
|
||||
{
|
||||
// Internal list of new faces.
|
||||
TopoDS_Compound aNewFaces;
|
||||
BRep_Builder aBB;
|
||||
aBB.MakeCompound(aNewFaces);
|
||||
|
||||
// Compute outer bounds of original shape.
|
||||
ShapeAnalysis_FreeBounds aFB(myInputShape);
|
||||
const TopoDS_Compound& aFreeWires = aFB.GetClosedWires();
|
||||
|
||||
// Build linear faces on each edge and its image.
|
||||
TopExp_Explorer anExpCW(aFreeWires,TopAbs_WIRE);
|
||||
for(; anExpCW.More() ; anExpCW.Next())
|
||||
{
|
||||
const TopoDS_Wire& aCurWire = TopoDS::Wire(anExpCW.Current());
|
||||
|
||||
// Iterate over outer edges in outer wires.
|
||||
TopExp_Explorer anExpWE(aCurWire, TopAbs_EDGE);
|
||||
for(; anExpWE.More() ; anExpWE.Next())
|
||||
{
|
||||
const TopoDS_Edge& aCurEdge = TopoDS::Edge(anExpWE.Current());
|
||||
|
||||
TopoDS_Face aNewFace = BuildWallFace(aCurEdge);
|
||||
|
||||
if (aNewFace.IsNull())
|
||||
{
|
||||
myError = BRepOffsetSimple_ErrorWallFaceComputation;
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
aBB.Add(aNewFaces, aNewFace);
|
||||
}
|
||||
}
|
||||
|
||||
// Update edges from wall faces.
|
||||
ShapeFix_Edge aSFE;
|
||||
aSFE.SetContext(myReShape);
|
||||
TopExp_Explorer anExpCE(aNewFaces, TopAbs_EDGE);
|
||||
for ( ; anExpCE.More() ; anExpCE.Next())
|
||||
{
|
||||
// Fix same parameter and same range flags.
|
||||
const TopoDS_Edge& aCurrEdge = TopoDS::Edge(anExpCE.Current());
|
||||
aSFE.FixSameParameter(aCurrEdge);
|
||||
}
|
||||
|
||||
// Update result to be compound.
|
||||
TopoDS_Compound aResCompound;
|
||||
aBB.MakeCompound(aResCompound);
|
||||
|
||||
// Add old faces the result.
|
||||
TopExp_Explorer anExpSF(myInputShape, TopAbs_FACE);
|
||||
for ( ; anExpSF.More() ; anExpSF.Next())
|
||||
aBB.Add(aResCompound, anExpSF.Current());
|
||||
|
||||
// Add new faces the result.
|
||||
anExpSF.Init(myResShape, TopAbs_FACE);
|
||||
for ( ; anExpSF.More() ; anExpSF.Next())
|
||||
aBB.Add(aResCompound, anExpSF.Current());
|
||||
|
||||
// Add wall faces to the result.
|
||||
TopExp_Explorer anExpCF(aNewFaces, TopAbs_FACE);
|
||||
for ( ; anExpCF.More() ; anExpCF.Next())
|
||||
{
|
||||
const TopoDS_Face& aF = TopoDS::Face(anExpCF.Current());
|
||||
aBB.Add(aResCompound, aF);
|
||||
}
|
||||
|
||||
// Apply stored modifications.
|
||||
aResCompound = TopoDS::Compound(myReShape->Apply(aResCompound));
|
||||
|
||||
// Create result shell.
|
||||
BRepTools_Quilt aQuilt;
|
||||
aQuilt.Add(aResCompound);
|
||||
TopoDS_Shape aShells = aQuilt.Shells();
|
||||
|
||||
TopExp_Explorer anExpSSh(aShells, TopAbs_SHELL);
|
||||
TopoDS_Shell aResShell;
|
||||
for ( ; anExpSSh.More() ; anExpSSh.Next() )
|
||||
{
|
||||
if (!aResShell.IsNull())
|
||||
{
|
||||
// Shell is not null -> explorer contains two or more shells.
|
||||
myError = BRepOffsetSimple_ErrorInvalidNbShells;
|
||||
return Standard_False;
|
||||
}
|
||||
aResShell = TopoDS::Shell(anExpSSh.Current());
|
||||
}
|
||||
|
||||
if (!BRep_Tool::IsClosed(aResShell))
|
||||
{
|
||||
myError = BRepOffsetSimple_ErrorNonClosedShell;
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
// Create result solid.
|
||||
TopoDS_Solid aResSolid;
|
||||
aBB.MakeSolid(aResSolid);
|
||||
aBB.Add(aResSolid, aResShell);
|
||||
myResShape = aResSolid;
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : BuildWallFace
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
TopoDS_Face BRepOffset_MakeSimpleOffset::BuildWallFace(const TopoDS_Edge& theOrigEdge)
|
||||
{
|
||||
TopoDS_Face aResFace;
|
||||
|
||||
// Get offset edge. offset edge is revered to create correct wire.
|
||||
TopoDS_Edge aNewEdge = TopoDS::Edge(myBuilder.ModifiedShape(theOrigEdge));
|
||||
aNewEdge.Orientation(TopAbs_REVERSED);
|
||||
|
||||
TopoDS_Vertex aNewV1, aNewV2;
|
||||
TopExp::Vertices(aNewEdge, aNewV1, aNewV2);
|
||||
|
||||
// Wire contour is:
|
||||
// theOrigEdge (forcible forward) -> wall1 -> aNewEdge (forcible reversed) -> wall2
|
||||
// Firstly it is necessary to create copy of original shape with forward direction.
|
||||
// This simplifies walls creation.
|
||||
TopoDS_Edge anOrigCopy = theOrigEdge;
|
||||
anOrigCopy.Orientation(TopAbs_FORWARD);
|
||||
TopoDS_Vertex aV1, aV2;
|
||||
TopExp::Vertices(anOrigCopy, aV1, aV2);
|
||||
|
||||
// To simplify work with map.
|
||||
TopoDS_Vertex aForwardV1 = TopoDS::Vertex(aV1.Oriented(TopAbs_FORWARD));
|
||||
TopoDS_Vertex aForwardV2 = TopoDS::Vertex(aV2.Oriented(TopAbs_FORWARD));
|
||||
|
||||
// Check existence of edges in stored map: Edge1
|
||||
TopoDS_Edge aWall1;
|
||||
if (myMapVE.IsBound(aForwardV2))
|
||||
{
|
||||
// Edge exists - get it from map.
|
||||
aWall1 = myMapVE(aForwardV2);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Edge does not exist - create it and add to the map.
|
||||
BRepLib_MakeEdge aME1(TopoDS::Vertex(aV2.Oriented(TopAbs_FORWARD)),
|
||||
TopoDS::Vertex(aNewV2.Oriented(TopAbs_REVERSED)));
|
||||
if (!aME1.IsDone())
|
||||
return aResFace;
|
||||
aWall1 = aME1.Edge();
|
||||
|
||||
myMapVE.Bind(aForwardV2, aWall1);
|
||||
}
|
||||
|
||||
// Check existence of edges in stored map: Edge2
|
||||
TopoDS_Edge aWall2;
|
||||
if (myMapVE.IsBound(aForwardV1))
|
||||
{
|
||||
// Edge exists - get it from map.
|
||||
aWall2 = TopoDS::Edge(myMapVE(aForwardV1).Oriented(TopAbs_REVERSED));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Edge does not exist - create it and add to the map.
|
||||
BRepLib_MakeEdge aME2(TopoDS::Vertex(aV1.Oriented(TopAbs_FORWARD)),
|
||||
TopoDS::Vertex(aNewV1.Oriented(TopAbs_REVERSED)));
|
||||
if (!aME2.IsDone())
|
||||
return aResFace;
|
||||
aWall2 = aME2.Edge();
|
||||
|
||||
myMapVE.Bind(aForwardV1, aWall2);
|
||||
|
||||
// Orient it in reversed direction.
|
||||
aWall2.Orientation(TopAbs_REVERSED);
|
||||
}
|
||||
|
||||
BRep_Builder aBB;
|
||||
|
||||
TopoDS_Wire aWire;
|
||||
aBB.MakeWire(aWire);
|
||||
aBB.Add(aWire, anOrigCopy);
|
||||
aBB.Add(aWire, aWall1);
|
||||
aBB.Add(aWire, aNewEdge);
|
||||
aBB.Add(aWire, aWall2);
|
||||
|
||||
// Build 3d curves on wire
|
||||
BRepLib::BuildCurves3d( aWire );
|
||||
|
||||
// Try to build using simple planar approach.
|
||||
TopoDS_Face aF;
|
||||
try
|
||||
{
|
||||
// Call of face maker is wrapped by try/catch since it generates exceptions sometimes.
|
||||
BRepLib_MakeFace aFM(aWire, Standard_True);
|
||||
if (aFM.IsDone())
|
||||
aF = aFM.Face();
|
||||
}
|
||||
catch(Standard_Failure)
|
||||
{
|
||||
}
|
||||
|
||||
if (aF.IsNull()) // Exception in face maker or result is not computed.
|
||||
{
|
||||
// Build using thrusections.
|
||||
Standard_Boolean ToReverse = Standard_False;
|
||||
Standard_Real fpar, lpar, fparOE, lparOE;
|
||||
Handle(Geom_Curve) EdgeCurve = BRep_Tool::Curve(theOrigEdge, fpar, lpar);
|
||||
Handle(Geom_TrimmedCurve) TrEdgeCurve = new Geom_TrimmedCurve( EdgeCurve, fpar, lpar );
|
||||
Handle(Geom_Curve) OffsetCurve = BRep_Tool::Curve(aNewEdge, fparOE, lparOE);
|
||||
Handle(Geom_TrimmedCurve) TrOffsetCurve = new Geom_TrimmedCurve( OffsetCurve, fparOE, lparOE );
|
||||
|
||||
GeomFill_Generator ThrusecGenerator;
|
||||
ThrusecGenerator.AddCurve( TrEdgeCurve );
|
||||
ThrusecGenerator.AddCurve( TrOffsetCurve );
|
||||
ThrusecGenerator.Perform( Precision::PConfusion() );
|
||||
Handle(Geom_Surface) theSurf = ThrusecGenerator.Surface();
|
||||
//theSurf = new Geom_SurfaceOfLinearExtrusion( TrOffsetCurve, OffsetDir );
|
||||
Standard_Real Uf, Ul, Vf, Vl;
|
||||
theSurf->Bounds(Uf, Ul, Vf, Vl);
|
||||
TopLoc_Location Loc;
|
||||
Handle(Geom2d_Line) EdgeLine2d, OELine2d, aLine2d, aLine2d2;
|
||||
EdgeLine2d = new Geom2d_Line(gp_Pnt2d(0., Vf), gp_Dir2d(1., 0.));
|
||||
aBB.UpdateEdge(theOrigEdge, EdgeLine2d, theSurf, Loc, Precision::Confusion());
|
||||
OELine2d = new Geom2d_Line(gp_Pnt2d(0., Vl), gp_Dir2d(1., 0.));
|
||||
aBB.UpdateEdge(aNewEdge, OELine2d, theSurf, Loc, Precision::Confusion());
|
||||
Standard_Real UonV1 = (ToReverse)? Ul : Uf;
|
||||
Standard_Real UonV2 = (ToReverse)? Uf : Ul;
|
||||
aLine2d = new Geom2d_Line(gp_Pnt2d(UonV2, 0.), gp_Dir2d(0., 1.));
|
||||
aLine2d2 = new Geom2d_Line(gp_Pnt2d(UonV1, 0.), gp_Dir2d(0., 1.));
|
||||
if (aWall1.IsSame(aWall2))
|
||||
{
|
||||
aBB.UpdateEdge(aWall1, aLine2d, aLine2d2, theSurf, Loc, Precision::Confusion());
|
||||
Handle(Geom_Curve) BSplC34 = theSurf->UIso( Uf );
|
||||
aBB.UpdateEdge(aWall1, BSplC34, Precision::Confusion());
|
||||
aBB.Range(aWall1, Vf, Vl);
|
||||
}
|
||||
else
|
||||
{
|
||||
aBB.SameParameter(aWall1, Standard_False);
|
||||
aBB.SameRange(aWall1, Standard_False);
|
||||
aBB.SameParameter(aWall2, Standard_False);
|
||||
aBB.SameRange(aWall2, Standard_False);
|
||||
aBB.UpdateEdge(aWall1, aLine2d, theSurf, Loc, Precision::Confusion());
|
||||
aBB.Range(aWall1, theSurf, Loc, Vf, Vl);
|
||||
aBB.UpdateEdge(aWall2, aLine2d2, theSurf, Loc, Precision::Confusion());
|
||||
aBB.Range(aWall2, theSurf, Loc, Vf, Vl);
|
||||
Handle(Geom_Curve) BSplC3 = theSurf->UIso( UonV2 );
|
||||
aBB.UpdateEdge(aWall1, BSplC3, Precision::Confusion());
|
||||
aBB.Range(aWall1, Vf, Vl, Standard_True); //only for 3d curve
|
||||
Handle(Geom_Curve) BSplC4 = theSurf->UIso( UonV1 );
|
||||
aBB.UpdateEdge(aWall2, BSplC4, Precision::Confusion());
|
||||
aBB.Range(aWall2, Vf, Vl, Standard_True); //only for 3d curve
|
||||
}
|
||||
|
||||
aF = BRepLib_MakeFace(theSurf, aWire);
|
||||
|
||||
}
|
||||
|
||||
return aF;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : Generated
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
const TopoDS_Shape BRepOffset_MakeSimpleOffset::Generated(const TopoDS_Shape& theShape) const
|
||||
{
|
||||
// Shape generated by modification.
|
||||
TopoDS_Shape aRes;
|
||||
aRes = myBuilder.ModifiedShape(theShape);
|
||||
|
||||
if (aRes.IsNull())
|
||||
return aRes;
|
||||
|
||||
// Shape modifications obtained in scope of shape healing.
|
||||
aRes = myReShape->Apply(aRes);
|
||||
|
||||
return aRes;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : Modified
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
const TopoDS_Shape BRepOffset_MakeSimpleOffset::Modified(const TopoDS_Shape& theShape) const
|
||||
{
|
||||
TopoDS_Shape aRes, anEmptyShape;
|
||||
|
||||
// Get modification status and new shape.
|
||||
Standard_Integer aModStatus = myReShape->Status(theShape, aRes);
|
||||
|
||||
if (aModStatus == 0)
|
||||
return anEmptyShape; // No modifications are applied to the shape or its sub-shapes.
|
||||
|
||||
return aRes;
|
||||
}
|
||||
|
168
src/BRepOffset/BRepOffset_MakeSimpleOffset.hxx
Normal file
168
src/BRepOffset/BRepOffset_MakeSimpleOffset.hxx
Normal file
@@ -0,0 +1,168 @@
|
||||
// Created on: 2016-10-13
|
||||
// Created by: Alexander MALYSHEV
|
||||
// Copyright (c) 1999-2016 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _BRepOffset_MakeSimpleOffset_HeaderFile
|
||||
#define _BRepOffset_MakeSimpleOffset_HeaderFile
|
||||
|
||||
#include <BRepTools_Modifier.hxx>
|
||||
#include <ShapeBuild_ReShape.hxx>
|
||||
#include <NCollection_DataMap.hxx>
|
||||
#include <Standard_Macro.hxx>
|
||||
#include <Standard_Real.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <TopoDS_Edge.hxx>
|
||||
#include <TopoDS_Face.hxx>
|
||||
#include <TopoDS_Vertex.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
|
||||
|
||||
enum BRepOffsetSimple_Status
|
||||
{
|
||||
BRepOffsetSimple_OK,
|
||||
BRepOffsetSimple_NullInputShape,
|
||||
BRepOffsetSimple_ErrorOffsetComputation,
|
||||
BRepOffsetSimple_ErrorWallFaceComputation,
|
||||
BRepOffsetSimple_ErrorInvalidNbShells,
|
||||
BRepOffsetSimple_ErrorNonClosedShell
|
||||
};
|
||||
|
||||
//! This class represents simple offset algorithm itself. It builds simple offset without intersection.
|
||||
//! Solid can be created using SetBuildSolidFlag method (set flag to true). By default shell will be constructed.
|
||||
//!
|
||||
//! Algorithm:
|
||||
//! 1. Build source-image maps for vertices, edges and faces.BRepTools_Modification class will be used
|
||||
//! to store this information. An image of a shared edge can be constructed from the corresponding edge
|
||||
//! of the first iterated face.
|
||||
//! 2. Run BRepTools_Modifier to obtain offset shape.
|
||||
// 3. Ensure topological integrity of the output shape.
|
||||
//!
|
||||
//! Limitations:
|
||||
//! According to the algorithm nature result depends on the smoothness of input data. Smooth (G1-continuity) input shape
|
||||
//! will lead to the good result.
|
||||
//!
|
||||
//! The possible drawback of the simple algorithm is that it leads, in general case, to tolerance increasing.
|
||||
//! The tolerances have to grow in order to cover the gaps between the neighbor faces in the output.
|
||||
//! It should be noted that the actual tolerance growth depends on the offset distance and the quality of
|
||||
//! joints between the input faces. Anyway the good input shell (smooth connections between adjacent faces)
|
||||
//! will lead to good result.
|
||||
class BRepOffset_MakeSimpleOffset
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
//! Constructor. Does nothing.
|
||||
Standard_EXPORT BRepOffset_MakeSimpleOffset();
|
||||
|
||||
//! Constructor.
|
||||
Standard_EXPORT BRepOffset_MakeSimpleOffset(const TopoDS_Shape& theInputShape,
|
||||
const Standard_Real theOffsetValue);
|
||||
|
||||
//! Initialies shape for modifications.
|
||||
Standard_EXPORT void Initialize(const TopoDS_Shape& theInputShape,
|
||||
const Standard_Real theOffsetValue);
|
||||
|
||||
//! Computes offset shape.
|
||||
Standard_EXPORT void Perform();
|
||||
|
||||
//! Gets error message.
|
||||
Standard_EXPORT TCollection_AsciiString GetErrorMessage() const;
|
||||
|
||||
//! Gets error code.
|
||||
BRepOffsetSimple_Status GetError() const { return myError; }
|
||||
|
||||
// Inline methods.
|
||||
//! Gets solid building flag.
|
||||
Standard_Boolean GetBuildSolidFlag() const { return myIsBuildSolid; }
|
||||
|
||||
//! Sets solid building flag.
|
||||
void SetBuildSolidFlag(const Standard_Boolean theBuildFlag) { myIsBuildSolid = theBuildFlag; }
|
||||
|
||||
//! Gets offset value.
|
||||
Standard_Real GetOffsetValue() const { return myOffsetValue; }
|
||||
|
||||
//! Sets offset value.
|
||||
void SetOffsetValue(const Standard_Real theOffsetValue) { myOffsetValue = theOffsetValue; }
|
||||
|
||||
//! Gets done state.
|
||||
Standard_Boolean IsDone() const { return myIsDone; }
|
||||
|
||||
//! Returns result shape.
|
||||
const TopoDS_Shape& GetResultShape() const { return myResShape; }
|
||||
|
||||
//! Computes max safe offset value for the given tolerance.
|
||||
Standard_Real GetSafeOffset(const Standard_Real theExpectedToler);
|
||||
|
||||
//! Returnes result shape for the given one (if exists).
|
||||
Standard_EXPORT const TopoDS_Shape Generated(const TopoDS_Shape& theShape) const;
|
||||
|
||||
//! Returnes modified shape for the given one (if exists).
|
||||
Standard_EXPORT const TopoDS_Shape Modified(const TopoDS_Shape& theShape) const;
|
||||
|
||||
protected:
|
||||
|
||||
//! Computes max angle in faces junction.
|
||||
void ComputeMaxAngle();
|
||||
|
||||
//! Clears previous result.
|
||||
void Clear();
|
||||
|
||||
private:
|
||||
|
||||
//! Builds face on specified wall.
|
||||
TopoDS_Face BuildWallFace(const TopoDS_Edge& theOrigEdge);
|
||||
|
||||
//! Builds missing walls.
|
||||
Standard_Boolean BuildMissingWalls();
|
||||
|
||||
// Input data.
|
||||
|
||||
//! Input shape.
|
||||
TopoDS_Shape myInputShape;
|
||||
|
||||
//! Offset value.
|
||||
Standard_Real myOffsetValue;
|
||||
|
||||
//! Solid building flag. True means solid construction.
|
||||
Standard_Boolean myIsBuildSolid;
|
||||
|
||||
// Internal data.
|
||||
|
||||
//! Maximal angle in faces junction. This value helps to estimate result tolerance.
|
||||
Standard_Real myMaxAngle;
|
||||
|
||||
//! Error message.
|
||||
BRepOffsetSimple_Status myError;
|
||||
|
||||
//! Done state.
|
||||
Standard_Boolean myIsDone;
|
||||
|
||||
//! Map of vertex - wall edge.
|
||||
//! Used to build shared edge between adjacent wall faces.
|
||||
NCollection_DataMap<TopoDS_Vertex, TopoDS_Edge> myMapVE;
|
||||
|
||||
//! Used for histrory support.
|
||||
BRepTools_Modifier myBuilder;
|
||||
|
||||
//! Used for history support.
|
||||
Handle(ShapeBuild_ReShape) myReShape;
|
||||
|
||||
// Output data.
|
||||
|
||||
//! Result shape.
|
||||
TopoDS_Shape myResShape;
|
||||
|
||||
};
|
||||
|
||||
#endif // _BRepOffset_MakeSimpleOffset_HeaderFile
|
412
src/BRepOffset/BRepOffset_SimpleOffset.cxx
Normal file
412
src/BRepOffset/BRepOffset_SimpleOffset.cxx
Normal file
@@ -0,0 +1,412 @@
|
||||
// Created on: 2016-10-14
|
||||
// Created by: Alexander MALYSHEV
|
||||
// Copyright (c) 1995-1999 Matra Datavision
|
||||
// Copyright (c) 1999-2016 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
// Include self.
|
||||
#include <BRepOffset_SimpleOffset.hxx>
|
||||
|
||||
#include <Adaptor3d_CurveOnSurface.hxx>
|
||||
#include <BRepBuilderAPI_MakeEdge.hxx>
|
||||
#include <BRepLib.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <Geom_OffsetSurface.hxx>
|
||||
#include <GeomAdaptor_Curve.hxx>
|
||||
#include <Geom2dAdaptor_HCurve.hxx>
|
||||
#include <GeomAdaptor_HSurface.hxx>
|
||||
#include <NCollection_Vector.hxx>
|
||||
#include <ShapeAnalysis_Edge.hxx>
|
||||
#include <TopExp.hxx>
|
||||
#include <TopExp_Explorer.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopoDS_Face.hxx>
|
||||
#include <TopoDS_Edge.hxx>
|
||||
#include <TopoDS_Vertex.hxx>
|
||||
|
||||
static const Standard_Integer NCONTROL=22;
|
||||
|
||||
|
||||
//=============================================================================
|
||||
//function : BRepOffset_SimpleOffset
|
||||
//purpose : Constructor
|
||||
//=============================================================================
|
||||
BRepOffset_SimpleOffset::BRepOffset_SimpleOffset(const TopoDS_Shape& theInputShape,
|
||||
const Standard_Real theOffsetValue)
|
||||
: myOffsetValue(theOffsetValue)
|
||||
{
|
||||
FillOffsetData(theInputShape);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : NewSurface
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
Standard_Boolean BRepOffset_SimpleOffset::NewSurface(const TopoDS_Face& F,
|
||||
Handle(Geom_Surface)& S,
|
||||
TopLoc_Location& L,
|
||||
Standard_Real& Tol,
|
||||
Standard_Boolean& RevWires,
|
||||
Standard_Boolean& RevFace)
|
||||
{
|
||||
if (!myFaceInfo.IsBound(F))
|
||||
return Standard_False;
|
||||
|
||||
const NewFaceData& aNFD = myFaceInfo.Find(F);
|
||||
|
||||
S = aNFD.myOffsetS;
|
||||
L = aNFD.myL;
|
||||
Tol = aNFD.myTol;
|
||||
RevWires = aNFD.myRevWires;
|
||||
RevFace = aNFD.myRevFace;
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : NewCurve
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
Standard_Boolean BRepOffset_SimpleOffset::NewCurve(const TopoDS_Edge& E,
|
||||
Handle(Geom_Curve)& C,
|
||||
TopLoc_Location& L,
|
||||
Standard_Real& Tol)
|
||||
{
|
||||
if (!myEdgeInfo.IsBound(E))
|
||||
return Standard_False;
|
||||
|
||||
const NewEdgeData& aNED = myEdgeInfo.Find(E);
|
||||
|
||||
C = aNED.myOffsetC;
|
||||
L = aNED.myL;
|
||||
Tol = aNED.myTol;
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : NewPoint
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
Standard_Boolean BRepOffset_SimpleOffset::NewPoint (const TopoDS_Vertex& V,
|
||||
gp_Pnt& P,
|
||||
Standard_Real& Tol)
|
||||
{
|
||||
if (!myVertexInfo.IsBound(V))
|
||||
return Standard_False;
|
||||
|
||||
const NewVertexData& aNVD = myVertexInfo.Find(V);
|
||||
|
||||
P = aNVD.myP;
|
||||
Tol = aNVD.myTol;
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : NewCurve2d
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
Standard_Boolean BRepOffset_SimpleOffset::NewCurve2d (const TopoDS_Edge& E,
|
||||
const TopoDS_Face& F,
|
||||
const TopoDS_Edge& /*NewE*/,
|
||||
const TopoDS_Face& /*NewF*/,
|
||||
Handle(Geom2d_Curve)& C,
|
||||
Standard_Real& Tol)
|
||||
{
|
||||
// Use original pcurve.
|
||||
Standard_Real aF, aL;
|
||||
C = BRep_Tool::CurveOnSurface(E, F, aF, aL);
|
||||
Tol = BRep_Tool::Tolerance(E);
|
||||
|
||||
if (myEdgeInfo.IsBound(E))
|
||||
Tol = myEdgeInfo.Find(E).myTol;
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : NewParameter
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
Standard_Boolean BRepOffset_SimpleOffset::NewParameter (const TopoDS_Vertex& V,
|
||||
const TopoDS_Edge& E,
|
||||
Standard_Real& P,
|
||||
Standard_Real& Tol)
|
||||
{
|
||||
// Use original parameter.
|
||||
P = BRep_Tool::Parameter(V, E);
|
||||
Tol = BRep_Tool::Tolerance(V);
|
||||
|
||||
if (myVertexInfo.IsBound(V))
|
||||
Tol = myVertexInfo.Find(V).myTol;
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : NewParameter
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
GeomAbs_Shape BRepOffset_SimpleOffset::Continuity (const TopoDS_Edge& E,
|
||||
const TopoDS_Face& F1,
|
||||
const TopoDS_Face& F2,
|
||||
const TopoDS_Edge& /*NewE*/,
|
||||
const TopoDS_Face& /*NewF1*/,
|
||||
const TopoDS_Face& /*NewF2*/)
|
||||
{
|
||||
// Compute result using original continuity.
|
||||
return BRep_Tool::Continuity(E, F1, F2);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : FillOffsetData
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
void BRepOffset_SimpleOffset::FillOffsetData(const TopoDS_Shape& theShape)
|
||||
{
|
||||
// Clears old data.
|
||||
myFaceInfo.Clear();
|
||||
myEdgeInfo.Clear();
|
||||
myVertexInfo.Clear();
|
||||
|
||||
// Faces loop. Compute offset surface for each face.
|
||||
TopExp_Explorer anExpSF(theShape, TopAbs_FACE);
|
||||
for(; anExpSF.More(); anExpSF.Next())
|
||||
{
|
||||
const TopoDS_Face& aCurrFace = TopoDS::Face(anExpSF.Current());
|
||||
FillFaceData(aCurrFace);
|
||||
}
|
||||
|
||||
// Iterate over edges to compute 3d curve.
|
||||
TopTools_IndexedDataMapOfShapeListOfShape aEdgeFaceMap;
|
||||
TopExp::MapShapesAndAncestors(theShape, TopAbs_EDGE, TopAbs_FACE, aEdgeFaceMap);
|
||||
for (Standard_Integer anIdx = 1; anIdx <= aEdgeFaceMap.Size(); ++anIdx)
|
||||
{
|
||||
const TopoDS_Edge& aCurrEdge = TopoDS::Edge(aEdgeFaceMap.FindKey(anIdx));
|
||||
FillEdgeData(aCurrEdge, aEdgeFaceMap, anIdx);
|
||||
}
|
||||
|
||||
// Iterate over vertices to compute new vertex.
|
||||
TopTools_IndexedDataMapOfShapeListOfShape aVertexEdgeMap;
|
||||
TopExp::MapShapesAndAncestors(theShape, TopAbs_VERTEX, TopAbs_EDGE, aVertexEdgeMap);
|
||||
for (Standard_Integer anIdx = 1; anIdx <= aVertexEdgeMap.Size(); ++anIdx)
|
||||
{
|
||||
const TopoDS_Vertex & aCurrVertex = TopoDS::Vertex(aVertexEdgeMap.FindKey(anIdx));
|
||||
FillVertexData(aCurrVertex, aVertexEdgeMap, anIdx);
|
||||
}
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : FillFaceData
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
void BRepOffset_SimpleOffset::FillFaceData(const TopoDS_Face& theFace)
|
||||
{
|
||||
NewFaceData aNFD;
|
||||
aNFD.myRevWires = Standard_False;
|
||||
aNFD.myRevFace = Standard_False;
|
||||
aNFD.myTol = BRep_Tool::Tolerance(theFace);
|
||||
|
||||
// Create offset surface.
|
||||
|
||||
// Any existing transformation is applied to the surface.
|
||||
// New face will have null transformation.
|
||||
Handle(Geom_Surface) aS = BRep_Tool::Surface(theFace);
|
||||
|
||||
// Take into account face orientation.
|
||||
Standard_Real aMult = 1.0;
|
||||
if (theFace.Orientation() == TopAbs_REVERSED)
|
||||
aMult = -1.0;
|
||||
|
||||
aNFD.myOffsetS = new Geom_OffsetSurface(aS, aMult * myOffsetValue, Standard_True);
|
||||
aNFD.myL = TopLoc_Location(); // Null transformation.
|
||||
|
||||
// Save offset surface in map.
|
||||
myFaceInfo.Bind(theFace, aNFD);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : FillEdgeData
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
void BRepOffset_SimpleOffset::FillEdgeData(const TopoDS_Edge& theEdge,
|
||||
const TopTools_IndexedDataMapOfShapeListOfShape& theEdgeFaceMap,
|
||||
const Standard_Integer theIdx)
|
||||
{
|
||||
const TopTools_ListOfShape& aFacesList = theEdgeFaceMap(theIdx);
|
||||
|
||||
if (aFacesList.Size() == 0)
|
||||
return; // Free edges are skipped.
|
||||
|
||||
// Get offset surface.
|
||||
const TopoDS_Face& aCurrFace = TopoDS::Face(aFacesList.First());
|
||||
|
||||
if (!myFaceInfo.IsBound(aCurrFace))
|
||||
return;
|
||||
|
||||
// No need to deal with transformation - it is applied in fill faces data method.
|
||||
const NewFaceData & aNFD = myFaceInfo.Find(aCurrFace);
|
||||
Handle(Geom_Surface) anOffsetSurf = aNFD.myOffsetS;
|
||||
|
||||
// Compute offset 3d curve.
|
||||
Standard_Real aF, aL;
|
||||
Handle(Geom2d_Curve) aC2d = BRep_Tool::CurveOnSurface(theEdge, aCurrFace, aF, aL);
|
||||
|
||||
BRepBuilderAPI_MakeEdge anEdgeMaker(aC2d, anOffsetSurf, aF, aL);
|
||||
TopoDS_Edge aNewEdge = anEdgeMaker.Edge();
|
||||
|
||||
// Compute max tolerance. Vertex tolerance usage is taken from existing offset computation algorithm.
|
||||
// This piece of code significantly influences resulting performance.
|
||||
Standard_Real aTol = BRep_Tool::MaxTolerance(theEdge, TopAbs_VERTEX);
|
||||
BRepLib::BuildCurves3d(aNewEdge, aTol);
|
||||
|
||||
NewEdgeData aNED;
|
||||
aNED.myOffsetC = BRep_Tool::Curve(aNewEdge, aNED.myL, aF, aL);
|
||||
|
||||
// Iterate over adjacent faces for the current edge and compute max deviation.
|
||||
Standard_Real anEdgeTol = 0.0;
|
||||
TopTools_ListOfShape::Iterator anIter(aFacesList);
|
||||
for ( ; !aNED.myOffsetC.IsNull() && anIter.More() ; anIter.Next())
|
||||
{
|
||||
const TopoDS_Face& aCurFace = TopoDS::Face(anIter.Value());
|
||||
|
||||
if (!myFaceInfo.IsBound(aCurFace))
|
||||
continue;
|
||||
|
||||
// Create offset curve on surface.
|
||||
const Handle(Geom2d_Curve) aC2dNew = BRep_Tool::CurveOnSurface(theEdge, aCurFace, aF, aL);
|
||||
const Handle(Adaptor2d_HCurve2d) aHCurve2d = new Geom2dAdaptor_HCurve(aC2dNew, aF, aL);
|
||||
const Handle(Adaptor3d_HSurface) aHSurface = new GeomAdaptor_HSurface(myFaceInfo.Find(aCurFace).myOffsetS);
|
||||
Adaptor3d_CurveOnSurface aCurveOnSurf(aHCurve2d, aHSurface);
|
||||
|
||||
// Extract 3d-curve (it is not null).
|
||||
const GeomAdaptor_Curve aCurve3d(aNED.myOffsetC, aF, aL);
|
||||
|
||||
// It is necessary to compute maximal deviation (tolerance).
|
||||
Standard_Real aMaxTol = 0.0;
|
||||
ShapeAnalysis_Edge::ComputeDeviation(aCurve3d, aCurveOnSurf, Standard_True, aMaxTol, NCONTROL);
|
||||
anEdgeTol = Max (anEdgeTol, aMaxTol);
|
||||
}
|
||||
aNED.myTol = Max(BRep_Tool::Tolerance(aNewEdge), anEdgeTol);
|
||||
|
||||
// Save computed 3d curve in map.
|
||||
myEdgeInfo.Bind(theEdge, aNED);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : FillVertexData
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
void BRepOffset_SimpleOffset::FillVertexData(const TopoDS_Vertex& theVertex,
|
||||
const TopTools_IndexedDataMapOfShapeListOfShape& theVertexEdgeMap,
|
||||
const Standard_Integer theIdx)
|
||||
{
|
||||
// Algorithm:
|
||||
// Find adjacent edges for the given vertex.
|
||||
// Find corresponding end on the each adjacent edge.
|
||||
// Get offset points for founded end.
|
||||
// Set result vertex position as barycenter of founded points.
|
||||
|
||||
gp_Pnt aCurrPnt = BRep_Tool::Pnt(theVertex);
|
||||
|
||||
const TopTools_ListOfShape& aEdgesList = theVertexEdgeMap(theIdx);
|
||||
|
||||
if (aEdgesList.Size() == 0)
|
||||
return; // Free verices are skipped.
|
||||
|
||||
// Array to store offset points.
|
||||
NCollection_Vector<gp_Pnt> anOffsetPointVec;
|
||||
|
||||
Standard_Real aMaxEdgeTol = 0.0;
|
||||
|
||||
// Iterate over adjacent edges.
|
||||
TopTools_ListOfShape::Iterator anIterEdges(aEdgesList);
|
||||
for (; anIterEdges.More() ; anIterEdges.Next() )
|
||||
{
|
||||
const TopoDS_Edge& aCurrEdge = TopoDS::Edge(anIterEdges.Value());
|
||||
|
||||
if (!myEdgeInfo.IsBound(aCurrEdge))
|
||||
continue; // Skip shared edges with wrong orientation.
|
||||
|
||||
// Find the closest bound.
|
||||
Standard_Real aF, aL;
|
||||
Handle(Geom_Curve) aC3d = BRep_Tool::Curve(aCurrEdge, aF, aL);
|
||||
|
||||
// Protection from degenerated edges.
|
||||
if (aC3d.IsNull())
|
||||
continue;
|
||||
|
||||
const gp_Pnt aPntF = aC3d->Value(aF);
|
||||
const gp_Pnt aPntL = aC3d->Value(aL);
|
||||
|
||||
const Standard_Real aSqDistF = aPntF.SquareDistance(aCurrPnt);
|
||||
const Standard_Real aSqDistL = aPntL.SquareDistance(aCurrPnt);
|
||||
|
||||
Standard_Real aMinParam = aF, aMaxParam = aL;
|
||||
if (aSqDistL < aSqDistF)
|
||||
{
|
||||
// Square distance to last point is closer.
|
||||
aMinParam = aL; aMaxParam = aF;
|
||||
}
|
||||
|
||||
// Compute point on offset edge.
|
||||
const NewEdgeData& aNED = myEdgeInfo.Find(aCurrEdge);
|
||||
const Handle(Geom_Curve) &anOffsetCurve = aNED.myOffsetC;
|
||||
const gp_Pnt anOffsetPoint = anOffsetCurve->Value(aMinParam);
|
||||
anOffsetPointVec.Append(anOffsetPoint);
|
||||
|
||||
// Handle situation when edge is closed.
|
||||
TopoDS_Vertex aV1, aV2;
|
||||
TopExp::Vertices(aCurrEdge, aV1, aV2);
|
||||
if (aV1.IsSame(aV2))
|
||||
{
|
||||
const gp_Pnt anOffsetPointLast = anOffsetCurve->Value(aMaxParam);
|
||||
anOffsetPointVec.Append(anOffsetPointLast);
|
||||
}
|
||||
|
||||
aMaxEdgeTol = Max(aMaxEdgeTol, aNED.myTol);
|
||||
}
|
||||
|
||||
// NCollection_Vector starts from 0 by default.
|
||||
// It's better to use lower() and upper() in this case instead of direct indexes range.
|
||||
gp_Pnt aCenter(0.0, 0.0, 0.0);
|
||||
for(Standard_Integer i = anOffsetPointVec.Lower();
|
||||
i <= anOffsetPointVec.Upper();
|
||||
++i)
|
||||
{
|
||||
aCenter.SetXYZ(aCenter.XYZ() + anOffsetPointVec.Value(i).XYZ());
|
||||
}
|
||||
aCenter.SetXYZ(aCenter.XYZ() / anOffsetPointVec.Size());
|
||||
|
||||
// Compute max distance.
|
||||
Standard_Real aSqMaxDist = 0.0;
|
||||
for(Standard_Integer i = anOffsetPointVec.Lower();
|
||||
i <= anOffsetPointVec.Upper();
|
||||
++i)
|
||||
{
|
||||
const Standard_Real aSqDist = aCenter.SquareDistance(anOffsetPointVec.Value(i));
|
||||
if (aSqDist > aSqMaxDist)
|
||||
aSqMaxDist = aSqDist;
|
||||
}
|
||||
|
||||
const Standard_Real aResTol = Max(aMaxEdgeTol, Sqrt(aSqMaxDist));
|
||||
|
||||
const Standard_Real aMultCoeff = 1.001; // Avoid tolernace problems.
|
||||
NewVertexData aNVD;
|
||||
aNVD.myP = aCenter;
|
||||
aNVD.myTol = aResTol * aMultCoeff;
|
||||
|
||||
// Save computed vertex info.
|
||||
myVertexInfo.Bind(theVertex, aNVD);
|
||||
}
|
183
src/BRepOffset/BRepOffset_SimpleOffset.hxx
Normal file
183
src/BRepOffset/BRepOffset_SimpleOffset.hxx
Normal file
@@ -0,0 +1,183 @@
|
||||
// Created on: 2016-10-14
|
||||
// Created by: Alexander MALYSHEV
|
||||
// Copyright (c) 1999-2016 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _BRepOffset_SimpleOffset_HeaderFile
|
||||
#define _BRepOffset_SimpleOffset_HeaderFile
|
||||
|
||||
#include <BRepTools_Modification.hxx>
|
||||
#include <GeomAbs_Shape.hxx>
|
||||
#include <Geom2d_Curve.hxx>
|
||||
#include <Standard_Real.hxx>
|
||||
#include <Standard_Macro.hxx>
|
||||
#include <Standard_Type.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
|
||||
#include <NCollection_DataMap.hxx>
|
||||
|
||||
|
||||
class BRepOffset_SimpleOffset;
|
||||
DEFINE_STANDARD_HANDLE(BRepOffset_SimpleOffset, BRepTools_Modification)
|
||||
|
||||
//! This class represents mechanism of simple offset algorithm i. e.
|
||||
//! topology-preserve offset construction without intersection.
|
||||
//!
|
||||
//! The list below shows mapping scheme:
|
||||
//! - Each surface is mapped to its geometric offset surface.
|
||||
//! - For each edge, pcurves are mapped to the same pcurves on offset surfaces.
|
||||
//! - For each edge, 3d curve is constructed by re-approximation of pcurve on the first offset face.
|
||||
//! - Position of each vertex in a result shell is computed as average point of all ends of edges shared by that vertex.
|
||||
//! - Tolerances are updated according to the resulting geometry.
|
||||
class BRepOffset_SimpleOffset : public BRepTools_Modification
|
||||
{
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_RTTI_INLINE(BRepOffset_SimpleOffset, BRepTools_Modification)
|
||||
|
||||
//! Constructor.
|
||||
Standard_EXPORT BRepOffset_SimpleOffset(const TopoDS_Shape& theInputShape,
|
||||
const Standard_Real theOffsetValue);
|
||||
|
||||
//! Returns Standard_True if the face <F> has been
|
||||
//! modified. In this case, <S> is the new geometric
|
||||
//! support of the face, <L> the new location,<Tol>
|
||||
//! the new tolerance.<RevWires> has to be set to
|
||||
//! Standard_True when the modification reverses the
|
||||
//! normal of the surface.(the wires have to be
|
||||
//! reversed). <RevFace> has to be set to
|
||||
//! Standard_True if the orientation of the modified
|
||||
//! face changes in the shells which contain it. --
|
||||
//! Here, <RevFace> will return Standard_True if the
|
||||
//! -- gp_Trsf is negative.
|
||||
Standard_EXPORT Standard_Boolean NewSurface (const TopoDS_Face& F,
|
||||
Handle(Geom_Surface)& S,
|
||||
TopLoc_Location& L,
|
||||
Standard_Real& Tol,
|
||||
Standard_Boolean& RevWires,
|
||||
Standard_Boolean& RevFace) Standard_OVERRIDE;
|
||||
|
||||
//! Returns Standard_True if the edge <E> has been
|
||||
//! modified. In this case, <C> is the new geometric
|
||||
//! support of the edge, <L> the new location, <Tol>
|
||||
//! the new tolerance. Otherwise, returns
|
||||
//! Standard_False, and <C>, <L>, <Tol> are not
|
||||
//! significant.
|
||||
Standard_EXPORT Standard_Boolean NewCurve (const TopoDS_Edge& E,
|
||||
Handle(Geom_Curve)& C,
|
||||
TopLoc_Location& L,
|
||||
Standard_Real& Tol) Standard_OVERRIDE;
|
||||
|
||||
//! Returns Standard_True if the vertex <V> has been
|
||||
//! modified. In this case, <P> is the new geometric
|
||||
//! support of the vertex, <Tol> the new tolerance.
|
||||
//! Otherwise, returns Standard_False, and <P>, <Tol>
|
||||
//! are not significant.
|
||||
Standard_EXPORT Standard_Boolean NewPoint (const TopoDS_Vertex& V,
|
||||
gp_Pnt& P,
|
||||
Standard_Real& Tol) Standard_OVERRIDE;
|
||||
|
||||
//! Returns Standard_True if the edge <E> has a new
|
||||
//! curve on surface on the face <F>.In this case, <C>
|
||||
//! is the new geometric support of the edge, <L> the
|
||||
//! new location, <Tol> the new tolerance.
|
||||
//! Otherwise, returns Standard_False, and <C>, <L>,
|
||||
//! <Tol> are not significant.
|
||||
Standard_EXPORT Standard_Boolean NewCurve2d (const TopoDS_Edge& E,
|
||||
const TopoDS_Face& F,
|
||||
const TopoDS_Edge& NewE,
|
||||
const TopoDS_Face& NewF,
|
||||
Handle(Geom2d_Curve)& C,
|
||||
Standard_Real& Tol) Standard_OVERRIDE;
|
||||
|
||||
//! Returns Standard_True if the Vertex <V> has a new
|
||||
//! parameter on the edge <E>. In this case, <P> is
|
||||
//! the parameter, <Tol> the new tolerance.
|
||||
//! Otherwise, returns Standard_False, and <P>, <Tol>
|
||||
//! are not significant.
|
||||
Standard_EXPORT Standard_Boolean NewParameter (const TopoDS_Vertex& V,
|
||||
const TopoDS_Edge& E,
|
||||
Standard_Real& P,
|
||||
Standard_Real& Tol) Standard_OVERRIDE;
|
||||
|
||||
//! Returns the continuity of <NewE> between <NewF1>
|
||||
//! and <NewF2>.
|
||||
//!
|
||||
//! <NewE> is the new edge created from <E>. <NewF1>
|
||||
//! (resp. <NewF2>) is the new face created from <F1>
|
||||
//! (resp. <F2>).
|
||||
Standard_EXPORT GeomAbs_Shape Continuity (const TopoDS_Edge& E,
|
||||
const TopoDS_Face& F1,
|
||||
const TopoDS_Face& F2,
|
||||
const TopoDS_Edge& NewE,
|
||||
const TopoDS_Face& NewF1,
|
||||
const TopoDS_Face& NewF2) Standard_OVERRIDE;
|
||||
|
||||
private:
|
||||
|
||||
//! Method to fill new face data for single face.
|
||||
void FillFaceData(const TopoDS_Face& theFace);
|
||||
|
||||
//! Method to fill new edge data for single edge.
|
||||
void FillEdgeData(const TopoDS_Edge& theEdge,
|
||||
const TopTools_IndexedDataMapOfShapeListOfShape& theEdgeFaceMap,
|
||||
const Standard_Integer theIdx);
|
||||
|
||||
//! Method to fill new vertex data for single vertex.
|
||||
void FillVertexData(const TopoDS_Vertex& theVertex,
|
||||
const TopTools_IndexedDataMapOfShapeListOfShape& theVertexEdgeMap,
|
||||
const Standard_Integer theIdx);
|
||||
|
||||
struct NewFaceData
|
||||
{
|
||||
Handle(Geom_Surface) myOffsetS;
|
||||
TopLoc_Location myL;
|
||||
Standard_Real myTol;
|
||||
Standard_Boolean myRevWires;
|
||||
Standard_Boolean myRevFace;
|
||||
};
|
||||
|
||||
struct NewEdgeData
|
||||
{
|
||||
Handle(Geom_Curve) myOffsetC; // Resulting curve.
|
||||
TopLoc_Location myL;
|
||||
Standard_Real myTol;
|
||||
};
|
||||
|
||||
struct NewVertexData
|
||||
{
|
||||
gp_Pnt myP;
|
||||
Standard_Real myTol;
|
||||
};
|
||||
|
||||
//! Fills offset data.
|
||||
void FillOffsetData(const TopoDS_Shape& theInputShape);
|
||||
|
||||
//! Copy-assignment constructor and copy constructor are not allowed.
|
||||
void operator=(const BRepOffset_SimpleOffset&);
|
||||
BRepOffset_SimpleOffset(const BRepOffset_SimpleOffset&);
|
||||
|
||||
//! Map of faces to new faces information.
|
||||
NCollection_DataMap<TopoDS_Face, NewFaceData> myFaceInfo;
|
||||
|
||||
//! Map of edges to new edges information.
|
||||
NCollection_DataMap<TopoDS_Edge, NewEdgeData> myEdgeInfo;
|
||||
|
||||
//! Map of vertices to new vertices information.
|
||||
NCollection_DataMap<TopoDS_Vertex, NewVertexData> myVertexInfo;
|
||||
|
||||
//! Offset value.
|
||||
Standard_Real myOffsetValue;
|
||||
};
|
||||
|
||||
#endif // _BRepOffset_SimpleOffset_HeaderFile
|
@@ -23,9 +23,13 @@ BRepOffset_MakeLoops.hxx
|
||||
BRepOffset_MakeOffset.cxx
|
||||
BRepOffset_MakeOffset_1.cxx
|
||||
BRepOffset_MakeOffset.hxx
|
||||
BRepOffset_MakeSimpleOffset.cxx
|
||||
BRepOffset_MakeSimpleOffset.hxx
|
||||
BRepOffset_Mode.hxx
|
||||
BRepOffset_Offset.cxx
|
||||
BRepOffset_Offset.hxx
|
||||
BRepOffset_SimpleOffset.cxx
|
||||
BRepOffset_SimpleOffset.hxx
|
||||
BRepOffset_Offset.lxx
|
||||
BRepOffset_Status.hxx
|
||||
BRepOffset_Tool.cxx
|
||||
|
@@ -14,9 +14,6 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
// Modified by skv - Tue Mar 15 16:20:43 2005
|
||||
// Add methods for supporting history.
|
||||
|
||||
#include <BRepOffset_MakeOffset.hxx>
|
||||
#include <BRepOffsetAPI_MakeOffsetShape.hxx>
|
||||
#include <Standard_ConstructionError.hxx>
|
||||
@@ -28,6 +25,7 @@
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
BRepOffsetAPI_MakeOffsetShape::BRepOffsetAPI_MakeOffsetShape()
|
||||
: myLastUsedAlgo(OffsetAlgo_NONE)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -35,29 +33,72 @@ BRepOffsetAPI_MakeOffsetShape::BRepOffsetAPI_MakeOffsetShape()
|
||||
//function : BRepOffsetAPI_MakeOffsetShape
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
BRepOffsetAPI_MakeOffsetShape::BRepOffsetAPI_MakeOffsetShape(const TopoDS_Shape& S,
|
||||
const Standard_Real Offset,
|
||||
const Standard_Real Tol,
|
||||
const BRepOffset_Mode Mode,
|
||||
const Standard_Boolean Intersection,
|
||||
const Standard_Boolean SelfInter,
|
||||
const GeomAbs_JoinType Join,
|
||||
const Standard_Boolean RemoveIntEdges)
|
||||
: myLastUsedAlgo(OffsetAlgo_NONE)
|
||||
{
|
||||
PerformByJoin(S, Offset, Tol, Mode, Intersection, SelfInter, Join, RemoveIntEdges);
|
||||
}
|
||||
|
||||
BRepOffsetAPI_MakeOffsetShape::BRepOffsetAPI_MakeOffsetShape
|
||||
(const TopoDS_Shape& S,
|
||||
const Standard_Real Offset,
|
||||
const Standard_Real Tol,
|
||||
const BRepOffset_Mode Mode,
|
||||
//=======================================================================
|
||||
//function : PerformByJoin
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void BRepOffsetAPI_MakeOffsetShape::PerformByJoin
|
||||
(const TopoDS_Shape& S,
|
||||
const Standard_Real Offset,
|
||||
const Standard_Real Tol,
|
||||
const BRepOffset_Mode Mode,
|
||||
const Standard_Boolean Intersection,
|
||||
const Standard_Boolean SelfInter,
|
||||
const GeomAbs_JoinType Join,
|
||||
const Standard_Boolean RemoveIntEdges)
|
||||
{
|
||||
NotDone();
|
||||
myLastUsedAlgo = OffsetAlgo_JOIN;
|
||||
|
||||
myOffsetShape.Initialize (S,Offset,Tol,Mode,Intersection,SelfInter,
|
||||
Join, Standard_False, RemoveIntEdges);
|
||||
Build();
|
||||
myOffsetShape.MakeOffsetShape();
|
||||
|
||||
if (!myOffsetShape.IsDone())
|
||||
return;
|
||||
|
||||
myShape = myOffsetShape.Shape();
|
||||
Done();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : PerformBySimple
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void BRepOffsetAPI_MakeOffsetShape::PerformBySimple(const TopoDS_Shape& theS,
|
||||
const Standard_Real theOffsetValue)
|
||||
{
|
||||
NotDone();
|
||||
myLastUsedAlgo = OffsetAlgo_SIMPLE;
|
||||
|
||||
mySimpleOffsetShape.Initialize(theS, theOffsetValue);
|
||||
mySimpleOffsetShape.Perform();
|
||||
|
||||
if (!mySimpleOffsetShape.IsDone())
|
||||
return;
|
||||
|
||||
myShape = mySimpleOffsetShape.GetResultShape();
|
||||
Done();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function :MakeOffset
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const BRepOffset_MakeOffset& BRepOffsetAPI_MakeOffsetShape::MakeOffset() const
|
||||
const BRepOffset_MakeOffset& BRepOffsetAPI_MakeOffsetShape::MakeOffset() const
|
||||
{
|
||||
return myOffsetShape;
|
||||
}
|
||||
@@ -66,72 +107,74 @@ const BRepOffset_MakeOffset& BRepOffsetAPI_MakeOffsetShape::MakeOffset() const
|
||||
//function : Build
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BRepOffsetAPI_MakeOffsetShape::Build()
|
||||
{
|
||||
if (!IsDone()) {
|
||||
myOffsetShape.MakeOffsetShape();
|
||||
if (!myOffsetShape.IsDone()) return;
|
||||
myShape = myOffsetShape.Shape();
|
||||
Done();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Generated
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const TopTools_ListOfShape& BRepOffsetAPI_MakeOffsetShape::Generated (const TopoDS_Shape& S)
|
||||
|
||||
{
|
||||
const TopTools_ListOfShape& BRepOffsetAPI_MakeOffsetShape::Generated (const TopoDS_Shape& S)
|
||||
{
|
||||
myGenerated.Clear();
|
||||
if (!myOffsetShape.ClosingFaces().Contains(S)) {
|
||||
|
||||
if (myLastUsedAlgo == OffsetAlgo_JOIN && !myOffsetShape.ClosingFaces().Contains(S))
|
||||
{
|
||||
myOffsetShape.OffsetFacesFromShapes ().LastImage (S, myGenerated);
|
||||
|
||||
if (!myOffsetShape.ClosingFaces().IsEmpty()) {
|
||||
|
||||
if (!myOffsetShape.ClosingFaces().IsEmpty())
|
||||
{
|
||||
// Reverse generated shapes in case of small solids.
|
||||
// Useful only for faces without influence on others.
|
||||
TopTools_ListIteratorOfListOfShape it(myGenerated);
|
||||
for (; it.More(); it.Next())
|
||||
it.Value().Reverse();
|
||||
it.Value().Reverse();
|
||||
}
|
||||
}
|
||||
else if (myLastUsedAlgo == OffsetAlgo_SIMPLE)
|
||||
{
|
||||
TopoDS_Shape aGenShape = mySimpleOffsetShape.Generated(S);
|
||||
if (!aGenShape.IsNull())
|
||||
myGenerated.Append(aGenShape);
|
||||
}
|
||||
|
||||
return myGenerated;
|
||||
}
|
||||
|
||||
|
||||
// Modified by skv - Tue Mar 15 16:20:43 2005 Begin
|
||||
|
||||
//=======================================================================
|
||||
//function : GeneratedEdge
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const TopTools_ListOfShape& BRepOffsetAPI_MakeOffsetShape::GeneratedEdge (const TopoDS_Shape& S)
|
||||
|
||||
{
|
||||
const TopTools_ListOfShape& BRepOffsetAPI_MakeOffsetShape::GeneratedEdge (const TopoDS_Shape& S)
|
||||
{
|
||||
myGenerated.Clear();
|
||||
myOffsetShape.OffsetEdgesFromShapes ().LastImage (S, myGenerated);
|
||||
|
||||
if (!myGenerated.IsEmpty()) {
|
||||
if (S.IsSame(myGenerated.First()))
|
||||
myGenerated.RemoveFirst();
|
||||
if (myLastUsedAlgo == OffsetAlgo_JOIN)
|
||||
{
|
||||
myOffsetShape.OffsetEdgesFromShapes().LastImage (S, myGenerated);
|
||||
|
||||
if (!myGenerated.IsEmpty())
|
||||
{
|
||||
if (S.IsSame(myGenerated.First()))
|
||||
myGenerated.RemoveFirst();
|
||||
}
|
||||
}
|
||||
else if (myLastUsedAlgo == OffsetAlgo_SIMPLE)
|
||||
{
|
||||
TopoDS_Shape aGenShape = mySimpleOffsetShape.Generated(S);
|
||||
if (!aGenShape.IsNull())
|
||||
myGenerated.Append(aGenShape);
|
||||
}
|
||||
|
||||
return myGenerated;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : GetJoinType
|
||||
//purpose : Query offset join type.
|
||||
//=======================================================================
|
||||
|
||||
GeomAbs_JoinType BRepOffsetAPI_MakeOffsetShape::GetJoinType() const
|
||||
{
|
||||
return myOffsetShape.GetJoinType();
|
||||
}
|
||||
|
||||
// Modified by skv - Tue Mar 15 16:20:43 2005 End
|
||||
|
@@ -22,6 +22,7 @@
|
||||
#include <Standard_Handle.hxx>
|
||||
|
||||
#include <BRepOffset_MakeOffset.hxx>
|
||||
#include <BRepOffset_MakeSimpleOffset.hxx>
|
||||
#include <BRepBuilderAPI_MakeShape.hxx>
|
||||
#include <Standard_Real.hxx>
|
||||
#include <BRepOffset_Mode.hxx>
|
||||
@@ -44,9 +45,24 @@ public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
|
||||
//! Constructor does nothing.
|
||||
Standard_EXPORT BRepOffsetAPI_MakeOffsetShape();
|
||||
|
||||
|
||||
//! Deprecated constructor. Please avoid usage of this constructor.
|
||||
Standard_DEPRECATED("Deprecated constructor. Please use constructor without parameters and one of perform methods.")
|
||||
Standard_EXPORT BRepOffsetAPI_MakeOffsetShape(const TopoDS_Shape& S,
|
||||
const Standard_Real Offset,
|
||||
const Standard_Real Tol,
|
||||
const BRepOffset_Mode Mode = BRepOffset_Skin,
|
||||
const Standard_Boolean Intersection = Standard_False,
|
||||
const Standard_Boolean SelfInter = Standard_False,
|
||||
const GeomAbs_JoinType Join = GeomAbs_Arc,
|
||||
const Standard_Boolean RemoveIntEdges = Standard_False);
|
||||
|
||||
//! Constructs offset shape for the given one using simple algorithm without intersections computation.
|
||||
Standard_EXPORT void PerformBySimple(const TopoDS_Shape& theS,
|
||||
const Standard_Real theOffsetValue);
|
||||
|
||||
//! Constructs a shape parallel to the shape S, where
|
||||
//! - S may be a face, a shell, a solid or a compound of these shape kinds;
|
||||
//! - Offset is the offset value. The offset shape is constructed:
|
||||
@@ -102,22 +118,22 @@ public:
|
||||
//! Exceptions
|
||||
//! Geom_UndefinedDerivative if the underlying
|
||||
//! geometry of S is BSpline with continuity C0.
|
||||
Standard_EXPORT BRepOffsetAPI_MakeOffsetShape(const TopoDS_Shape& S,
|
||||
const Standard_Real Offset,
|
||||
const Standard_Real Tol,
|
||||
const BRepOffset_Mode Mode = BRepOffset_Skin,
|
||||
const Standard_Boolean Intersection = Standard_False,
|
||||
const Standard_Boolean SelfInter = Standard_False,
|
||||
const GeomAbs_JoinType Join = GeomAbs_Arc,
|
||||
const Standard_Boolean RemoveIntEdges = Standard_False);
|
||||
Standard_EXPORT void PerformByJoin(const TopoDS_Shape& S,
|
||||
const Standard_Real Offset,
|
||||
const Standard_Real Tol,
|
||||
const BRepOffset_Mode Mode = BRepOffset_Skin,
|
||||
const Standard_Boolean Intersection = Standard_False,
|
||||
const Standard_Boolean SelfInter = Standard_False,
|
||||
const GeomAbs_JoinType Join = GeomAbs_Arc,
|
||||
const Standard_Boolean RemoveIntEdges = Standard_False);
|
||||
|
||||
//! Returns instance of the unrelying intersection / arc algorithm.
|
||||
Standard_EXPORT virtual const BRepOffset_MakeOffset& MakeOffset() const;
|
||||
|
||||
//! Builds the resulting shape (redefined from MakeShape).
|
||||
|
||||
//! Does nothing.
|
||||
Standard_EXPORT virtual void Build() Standard_OVERRIDE;
|
||||
|
||||
//! Returns the list of shapes generated from the
|
||||
//! shape <S>.
|
||||
//! Returns the list of shapes generated from the shape <S>.
|
||||
Standard_EXPORT virtual const TopTools_ListOfShape& Generated (const TopoDS_Shape& S) Standard_OVERRIDE;
|
||||
|
||||
//! Returns the list of edges generated from the shape <S>.
|
||||
@@ -126,28 +142,19 @@ public:
|
||||
//! Returns offset join type.
|
||||
Standard_EXPORT GeomAbs_JoinType GetJoinType() const;
|
||||
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
enum OffsetAlgo_Type
|
||||
{
|
||||
OffsetAlgo_NONE,
|
||||
OffsetAlgo_JOIN,
|
||||
OffsetAlgo_SIMPLE
|
||||
};
|
||||
|
||||
OffsetAlgo_Type myLastUsedAlgo;
|
||||
|
||||
BRepOffset_MakeOffset myOffsetShape;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
BRepOffset_MakeSimpleOffset mySimpleOffsetShape;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _BRepOffsetAPI_MakeOffsetShape_HeaderFile
|
||||
|
@@ -22,22 +22,44 @@
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <TopTools_ListIteratorOfListOfShape.hxx>
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepOffsetAPI_MakeThickSolid
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
BRepOffsetAPI_MakeThickSolid::BRepOffsetAPI_MakeThickSolid()
|
||||
{
|
||||
// Build only solids.
|
||||
mySimpleOffsetShape.SetBuildSolidFlag(Standard_True);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepOffsetAPI_MakeThickSolid
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
BRepOffsetAPI_MakeThickSolid::BRepOffsetAPI_MakeThickSolid(const TopoDS_Shape& S,
|
||||
const TopTools_ListOfShape& ClosingFaces,
|
||||
const Standard_Real Offset,
|
||||
const Standard_Real Tol,
|
||||
const BRepOffset_Mode Mode,
|
||||
const Standard_Boolean Intersection,
|
||||
const Standard_Boolean SelfInter,
|
||||
const GeomAbs_JoinType Join,
|
||||
const Standard_Boolean RemoveIntEdges)
|
||||
{
|
||||
// Build only solids.
|
||||
mySimpleOffsetShape.SetBuildSolidFlag(Standard_True);
|
||||
|
||||
BRepOffsetAPI_MakeThickSolid::BRepOffsetAPI_MakeThickSolid
|
||||
(const TopoDS_Shape& S,
|
||||
MakeThickSolidByJoin(S, ClosingFaces, Offset, Tol,
|
||||
Mode, Intersection, SelfInter, Join, RemoveIntEdges);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : MakeThickSolidByJoin
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void BRepOffsetAPI_MakeThickSolid::MakeThickSolidByJoin
|
||||
(const TopoDS_Shape& S,
|
||||
const TopTools_ListOfShape& ClosingFaces,
|
||||
const Standard_Real Offset,
|
||||
const Standard_Real Tol,
|
||||
@@ -47,51 +69,78 @@ BRepOffsetAPI_MakeThickSolid::BRepOffsetAPI_MakeThickSolid
|
||||
const GeomAbs_JoinType Join,
|
||||
const Standard_Boolean RemoveIntEdges)
|
||||
{
|
||||
NotDone();
|
||||
myLastUsedAlgo = OffsetAlgo_JOIN;
|
||||
|
||||
myOffsetShape.Initialize (S,Offset,Tol,Mode,Intersection,SelfInter,
|
||||
Join, Standard_False, RemoveIntEdges);
|
||||
TopTools_ListIteratorOfListOfShape it(ClosingFaces);
|
||||
for (; it.More(); it.Next()) {
|
||||
for (; it.More(); it.Next())
|
||||
myOffsetShape.AddFace(TopoDS::Face(it.Value()));
|
||||
}
|
||||
Build();
|
||||
|
||||
myOffsetShape.MakeThickSolid();
|
||||
if (!myOffsetShape.IsDone())
|
||||
return;
|
||||
|
||||
myShape = myOffsetShape.Shape();
|
||||
Done();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : virtual
|
||||
//function : MakeThickSolidBySimple
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BRepOffsetAPI_MakeThickSolid::Build()
|
||||
void BRepOffsetAPI_MakeThickSolid::MakeThickSolidBySimple(const TopoDS_Shape& theS,
|
||||
const Standard_Real theOffsetValue)
|
||||
{
|
||||
if (!IsDone()) {
|
||||
myOffsetShape.MakeThickSolid();
|
||||
if (!myOffsetShape.IsDone()) return;
|
||||
myShape = myOffsetShape.Shape();
|
||||
Done();
|
||||
}
|
||||
NotDone();
|
||||
myLastUsedAlgo = OffsetAlgo_SIMPLE;
|
||||
|
||||
mySimpleOffsetShape.Initialize(theS, theOffsetValue);
|
||||
mySimpleOffsetShape.Perform();
|
||||
|
||||
if (!mySimpleOffsetShape.IsDone())
|
||||
return;
|
||||
|
||||
myShape = mySimpleOffsetShape.GetResultShape();
|
||||
Done();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Build
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void BRepOffsetAPI_MakeThickSolid::Build()
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Modified
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const TopTools_ListOfShape& BRepOffsetAPI_MakeThickSolid::Modified (const TopoDS_Shape& F)
|
||||
|
||||
const TopTools_ListOfShape& BRepOffsetAPI_MakeThickSolid::Modified (const TopoDS_Shape& F)
|
||||
{
|
||||
myGenerated.Clear();
|
||||
if (myOffsetShape.OffsetFacesFromShapes().HasImage(F)) {
|
||||
if (myOffsetShape.ClosingFaces().Contains(F)) {
|
||||
myOffsetShape.OffsetFacesFromShapes().LastImage (F, myGenerated);
|
||||
// Les face du resultat sont orientees comme dans la piece initiale.
|
||||
//si offset a l interieur.
|
||||
|
||||
if (myLastUsedAlgo == OffsetAlgo_JOIN && myOffsetShape.OffsetFacesFromShapes().HasImage(F))
|
||||
{
|
||||
if (myOffsetShape.ClosingFaces().Contains(F))
|
||||
{
|
||||
myOffsetShape.OffsetFacesFromShapes().LastImage (F, myGenerated);
|
||||
|
||||
// Reverse generated shapes in case of small solids.
|
||||
// Useful only for faces without influence on others.
|
||||
TopTools_ListIteratorOfListOfShape it(myGenerated);
|
||||
for (; it.More(); it.Next())
|
||||
it.Value().Reverse();
|
||||
|
||||
it.Value().Reverse();
|
||||
}
|
||||
}
|
||||
else if (myLastUsedAlgo == OffsetAlgo_SIMPLE)
|
||||
{
|
||||
TopoDS_Shape aModShape = mySimpleOffsetShape.Modified(F);
|
||||
if (!aModShape.IsNull())
|
||||
myGenerated.Append(aModShape);
|
||||
}
|
||||
|
||||
return myGenerated;
|
||||
}
|
||||
|
@@ -51,9 +51,29 @@ public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
|
||||
//! Constructor does nothing.
|
||||
Standard_EXPORT BRepOffsetAPI_MakeThickSolid();
|
||||
|
||||
|
||||
//! Deprecated constructor. Please avoid usage of this constructor.
|
||||
Standard_DEPRECATED("Deprecated constructor. Please use constructor without parameters and one of make methods.")
|
||||
Standard_EXPORT BRepOffsetAPI_MakeThickSolid(const TopoDS_Shape& S,
|
||||
const TopTools_ListOfShape& ClosingFaces,
|
||||
const Standard_Real Offset,
|
||||
const Standard_Real Tol,
|
||||
const BRepOffset_Mode Mode = BRepOffset_Skin,
|
||||
const Standard_Boolean Intersection = Standard_False,
|
||||
const Standard_Boolean SelfInter = Standard_False,
|
||||
const GeomAbs_JoinType Join = GeomAbs_Arc,
|
||||
const Standard_Boolean RemoveIntEdges = Standard_False);
|
||||
|
||||
//! Constructs solid using simple algorithm.
|
||||
//! According to its nature it is not possible to set list of the closing faces.
|
||||
//! This algorithm does not support faces removing. It is caused by fact that
|
||||
//! intersections are not computed during offset creation.
|
||||
//! Non-closed shell or face is expected as input.
|
||||
Standard_EXPORT void MakeThickSolidBySimple(const TopoDS_Shape& theS,
|
||||
const Standard_Real theOffsetValue);
|
||||
|
||||
//! Constructs a hollowed solid from
|
||||
//! the solid S by removing the set of faces ClosingFaces from S, where:
|
||||
//! Offset defines the thickness of the walls. Its sign indicates
|
||||
@@ -94,44 +114,22 @@ public:
|
||||
//! Since the algorithm of MakeThickSolid is based on
|
||||
//! MakeOffsetShape algorithm, the warnings are the same as for
|
||||
//! MakeOffsetShape.
|
||||
Standard_EXPORT BRepOffsetAPI_MakeThickSolid(const TopoDS_Shape& S,
|
||||
const TopTools_ListOfShape& ClosingFaces,
|
||||
const Standard_Real Offset,
|
||||
const Standard_Real Tol,
|
||||
const BRepOffset_Mode Mode = BRepOffset_Skin,
|
||||
const Standard_Boolean Intersection = Standard_False,
|
||||
const Standard_Boolean SelfInter = Standard_False,
|
||||
const GeomAbs_JoinType Join = GeomAbs_Arc,
|
||||
const Standard_Boolean RemoveIntEdges = Standard_False);
|
||||
|
||||
//! Builds the resulting shape (redefined from MakeOffsetShape).
|
||||
Standard_EXPORT void MakeThickSolidByJoin(const TopoDS_Shape& S,
|
||||
const TopTools_ListOfShape& ClosingFaces,
|
||||
const Standard_Real Offset,
|
||||
const Standard_Real Tol,
|
||||
const BRepOffset_Mode Mode = BRepOffset_Skin,
|
||||
const Standard_Boolean Intersection = Standard_False,
|
||||
const Standard_Boolean SelfInter = Standard_False,
|
||||
const GeomAbs_JoinType Join = GeomAbs_Arc,
|
||||
const Standard_Boolean RemoveIntEdges = Standard_False);
|
||||
|
||||
// Does nothing.
|
||||
Standard_EXPORT virtual void Build() Standard_OVERRIDE;
|
||||
|
||||
//! Returns the list of shapes modified from the shape
|
||||
//! <S>.
|
||||
Standard_EXPORT virtual const TopTools_ListOfShape& Modified (const TopoDS_Shape& S) Standard_OVERRIDE;
|
||||
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _BRepOffsetAPI_MakeThickSolid_HeaderFile
|
||||
|
@@ -54,8 +54,8 @@
|
||||
#include <LocOpe_FindEdges.hxx>
|
||||
#include <LocOpe_FindEdgesInFace.hxx>
|
||||
|
||||
#include <BRepOffsetAPI_MakeOffsetShape.hxx>
|
||||
#include <BRepOffsetAPI_MakeThickSolid.hxx>
|
||||
#include <BRepOffset_MakeOffset.hxx>
|
||||
#include <BRepOffset_MakeSimpleOffset.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <BRep_Builder.hxx>
|
||||
#include <DBRep.hxx>
|
||||
@@ -2239,6 +2239,52 @@ static Standard_Integer BOSS(Draw_Interpretor& theCommands,
|
||||
return 1;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : ComputeSimpleOffset
|
||||
//purpose : Computes simple offset.
|
||||
//=============================================================================
|
||||
static Standard_Integer ComputeSimpleOffset(Draw_Interpretor& theCommands,
|
||||
Standard_Integer narg,
|
||||
const char** a)
|
||||
{
|
||||
if (narg != 4 && narg != 5)
|
||||
{
|
||||
theCommands << "offsetshapesimple result shape offsetvalue [solid]\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Input data.
|
||||
TopoDS_Shape aShape = DBRep::Get(a[2]);
|
||||
if (aShape.IsNull())
|
||||
{
|
||||
theCommands << "Input shape is null";
|
||||
return 0;
|
||||
}
|
||||
const Standard_Real anOffsetValue = Draw::Atof(a[3]);
|
||||
if (Abs(anOffsetValue) < gp::Resolution())
|
||||
{
|
||||
theCommands << "Null offset value";
|
||||
return 0;
|
||||
}
|
||||
|
||||
BRepOffset_MakeSimpleOffset aMaker(aShape, anOffsetValue);
|
||||
if (narg == 5 && !strcasecmp(a[4],"solid") )
|
||||
{
|
||||
aMaker.SetBuildSolidFlag(Standard_True);
|
||||
}
|
||||
|
||||
aMaker.Perform();
|
||||
|
||||
if (!aMaker.IsDone())
|
||||
{
|
||||
theCommands << "ERROR:" << aMaker.GetErrorMessage() << "\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
DBRep::Set(a[1], aMaker.GetResultShape());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : FeatureCommands
|
||||
@@ -2385,4 +2431,7 @@ void BRepTest::FeatureCommands (Draw_Interpretor& theCommands)
|
||||
" Perform fillet on top and bottom edges of dprism :bossage dprism result radtop radbottom First/LastShape (1/2)",
|
||||
__FILE__,BOSS);
|
||||
|
||||
theCommands.Add("offsetshapesimple",
|
||||
"offsetshapesimple result shape offsetvalue [solid]",
|
||||
__FILE__, ComputeSimpleOffset);
|
||||
}
|
||||
|
@@ -154,4 +154,5 @@ void DDocStd::AllCommands(Draw_Interpretor& theCommands)
|
||||
DDocStd::DocumentCommands(theCommands);
|
||||
DDocStd::ToolsCommands(theCommands);
|
||||
DDocStd::MTMCommands(theCommands);
|
||||
DDocStd::ShapeSchemaCommands(theCommands);
|
||||
}
|
||||
|
@@ -83,7 +83,8 @@ public:
|
||||
//! Create, Add, Remove, Open, Commit, Undo, Redo, SetNestedMode
|
||||
Standard_EXPORT static void MTMCommands (Draw_Interpretor& theCommands);
|
||||
|
||||
|
||||
//! ShapeSchema_Read
|
||||
Standard_EXPORT static void ShapeSchemaCommands(Draw_Interpretor& theCommands);
|
||||
|
||||
|
||||
protected:
|
||||
|
221
src/DDocStd/DDocStd_ShapeSchemaCommands.cxx
Normal file
221
src/DDocStd/DDocStd_ShapeSchemaCommands.cxx
Normal file
@@ -0,0 +1,221 @@
|
||||
|
||||
#include <DDocStd.hxx>
|
||||
#include <DBRep.hxx>
|
||||
#include <FSD_File.hxx>
|
||||
#include <FSD_CmpFile.hxx>
|
||||
#include <FSD_BinaryFile.hxx>
|
||||
#include <BRep_Builder.hxx>
|
||||
#include <NCollection_Handle.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <TopTools_SequenceOfShape.hxx>
|
||||
#include <Storage_BaseDriver.hxx>
|
||||
#include <StdStorage.hxx>
|
||||
#include <StdStorage_Data.hxx>
|
||||
#include <StdStorage_HeaderData.hxx>
|
||||
#include <StdStorage_RootData.hxx>
|
||||
#include <StdStorage_TypeData.hxx>
|
||||
#include <ShapePersistent_TopoDS.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : DDocStd_ShapeSchema_Write
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer DDocStd_fsdwrite(Draw_Interpretor& theDI,
|
||||
Standard_Integer theArgNb,
|
||||
const char** theArgs)
|
||||
{
|
||||
if (theArgNb < 3)
|
||||
{
|
||||
theDI << "Usage : fsdwrite shapes filename [gen | cmp | bin]\n";
|
||||
theDI << " Arguments:\n";
|
||||
theDI << " shapes : list os shape names\n";
|
||||
theDI << " filename : output file name\n";
|
||||
theDI << " Storage driver:\n";
|
||||
theDI << " gen : FSD_File driver (default)\n";
|
||||
theDI << " cmp : FSD_CmpFile driver\n";
|
||||
theDI << " bin : FSD_BinaryFile driver\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
NCollection_Handle<Storage_BaseDriver> aFileDriver(new FSD_File);
|
||||
|
||||
Standard_Boolean hasStorageDriver = Standard_False;
|
||||
Standard_Integer iArgN = theArgNb - 1;
|
||||
|
||||
if (strncmp(theArgs[iArgN], "gen", 3) == 0)
|
||||
{
|
||||
aFileDriver = new FSD_File;
|
||||
hasStorageDriver = Standard_True;
|
||||
}
|
||||
else if (strncmp(theArgs[iArgN], "cmp", 3) == 0)
|
||||
{
|
||||
aFileDriver = new FSD_CmpFile;
|
||||
hasStorageDriver = Standard_True;
|
||||
}
|
||||
else if (strncmp(theArgs[iArgN], "bin", 3) == 0)
|
||||
{
|
||||
aFileDriver = new FSD_BinaryFile;
|
||||
hasStorageDriver = Standard_True;
|
||||
}
|
||||
|
||||
if (hasStorageDriver) --iArgN;
|
||||
|
||||
Storage_Error aStatus = aFileDriver->Open(theArgs[iArgN], Storage_VSWrite);
|
||||
if (aStatus != Storage_VSOk) {
|
||||
theDI << "Error : couldn't open file '" << "' for writing (" << aStatus << ")\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
TopTools_SequenceOfShape aShapes;
|
||||
NCollection_DataMap<TCollection_AsciiString, Standard_Integer> aShapeNames;
|
||||
for (Standard_Integer i = 1; i < iArgN; ++i)
|
||||
{
|
||||
TopoDS_Shape aShape = DBRep::Get(theArgs[i]);
|
||||
if (aShape.IsNull())
|
||||
{
|
||||
theDI << "Error : null shape " << theArgs[i] << "\n";
|
||||
return 1;
|
||||
}
|
||||
aShapes.Append(aShape);
|
||||
if (aShapeNames.IsBound(theArgs[i]))
|
||||
aShapeNames.ChangeFind(theArgs[i]) += 1;
|
||||
else
|
||||
aShapeNames.Bind(theArgs[i], 1);
|
||||
}
|
||||
|
||||
Handle(StdStorage_Data) aData = new StdStorage_Data;
|
||||
|
||||
aData->HeaderData()->SetApplicationName(TCollection_ExtendedString("DDocStd_ShapeSchema_Write"));
|
||||
|
||||
StdObjMgt_TransientPersistentMap aMap;
|
||||
for (Standard_Integer i = 1; i <= aShapes.Length(); ++i)
|
||||
{
|
||||
TopoDS_Shape aShape = aShapes.Value(i);
|
||||
|
||||
Handle(ShapePersistent_TopoDS::HShape) aPShape =
|
||||
ShapePersistent_TopoDS::Translate(aShape, aMap, ShapePersistent_WithTriangle);
|
||||
if (aPShape.IsNull())
|
||||
{
|
||||
theDI << "Error : couldn't translate shape " << theArgs[i] << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
TCollection_AsciiString aName = theArgs[i];
|
||||
if (aShapeNames.IsBound(aName))
|
||||
{
|
||||
Standard_Integer n = aShapeNames.Find(theArgs[i]);
|
||||
if (n > 1)
|
||||
{
|
||||
aName += "_";
|
||||
aName += n;
|
||||
}
|
||||
}
|
||||
|
||||
Handle(StdStorage_Root) aRoot = new StdStorage_Root(aName, aPShape);
|
||||
aData->RootData()->AddRoot(aRoot);
|
||||
}
|
||||
|
||||
Storage_Error anError = StdStorage::Write(*aFileDriver, aData);
|
||||
|
||||
aFileDriver->Close();
|
||||
|
||||
if (anError != Storage_VSOk)
|
||||
{
|
||||
theDI << "Error : " << anError << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DDocStd_ShapeSchema_Read
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer DDocStd_fsdread(Draw_Interpretor& theDI,
|
||||
Standard_Integer theArgNb,
|
||||
const char** theArgs)
|
||||
{
|
||||
if (theArgNb < 3)
|
||||
{
|
||||
theDI << "Usage : fsdread filename shape\n";
|
||||
theDI << " Arguments:\n";
|
||||
theDI << " filename : input file name\n";
|
||||
theDI << " shape : name of an output shape,\n";
|
||||
theDI << " root shapes will be put into a compound\n";
|
||||
theDI << " in case of multiple roots in the file\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
Handle(StdStorage_Data) aData;
|
||||
Storage_Error anError = StdStorage::Read(TCollection_AsciiString(theArgs[1]), aData);
|
||||
if (anError != Storage_VSOk)
|
||||
{
|
||||
theDI << "Error : " << anError << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
TopTools_SequenceOfShape aShapes;
|
||||
|
||||
Handle(StdStorage_TypeData) aTypeData = aData->TypeData();
|
||||
Handle(StdStorage_RootData) aRootData = aData->RootData();
|
||||
Handle(StdStorage_HSequenceOfRoots) aRoots = aRootData->Roots();
|
||||
if (!aRoots.IsNull())
|
||||
{
|
||||
for (StdStorage_HSequenceOfRoots::Iterator anIt(*aRoots); anIt.More(); anIt.Next())
|
||||
{
|
||||
Handle(StdStorage_Root)& aRoot = anIt.ChangeValue();
|
||||
Handle(StdObjMgt_Persistent) aPObject = aRoot->Object();
|
||||
if (!aPObject.IsNull())
|
||||
{
|
||||
Handle(ShapePersistent_TopoDS::HShape) aHShape = Handle(ShapePersistent_TopoDS::HShape)::DownCast(aPObject);
|
||||
if (aHShape) // shapes are expected
|
||||
{
|
||||
TopoDS_Shape aShape = aHShape->Import();
|
||||
aShapes.Append(aShape);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
theDI << "Info : " << aTypeData->NumberOfTypes() << " type(s)\n";
|
||||
theDI << " " << aRoots->Length() << " root(s)\n";
|
||||
theDI << " " << aShapes.Length() << " shape(s) translated\n";
|
||||
|
||||
if (aShapes.Length() > 1)
|
||||
{
|
||||
BRep_Builder aB;
|
||||
TopoDS_Compound aC;
|
||||
aB.MakeCompound(aC);
|
||||
for (Standard_Integer i = 1; i <= aShapes.Length(); ++i)
|
||||
aB.Add(aC, aShapes.Value(i));
|
||||
DBRep::Set(theArgs[2], aC);
|
||||
}
|
||||
else
|
||||
DBRep::Set(theArgs[2], aShapes.First());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ShapeSchemaCommands
|
||||
//purpose : registers shape schema related commands in Draw interpreter
|
||||
//=======================================================================
|
||||
|
||||
void DDocStd::ShapeSchemaCommands(Draw_Interpretor& theCommands)
|
||||
{
|
||||
static Standard_Boolean done = Standard_False;
|
||||
if (done) return;
|
||||
done = Standard_True;
|
||||
|
||||
const char* g = "Shape persistence commands";
|
||||
|
||||
theCommands.Add("fsdwrite",
|
||||
"fsdrite shape filename [driver]",
|
||||
__FILE__, DDocStd_fsdwrite, g);
|
||||
|
||||
theCommands.Add("fsdread",
|
||||
"fsdread filename shape",
|
||||
__FILE__, DDocStd_fsdread, g);
|
||||
|
||||
}
|
@@ -6,4 +6,5 @@ DDocStd_DrawDocument.cxx
|
||||
DDocStd_DrawDocument.hxx
|
||||
DDocStd_MTMCommands.cxx
|
||||
DDocStd_ToolsCommands.cxx
|
||||
DDocStd_ShapeSchemaCommands.cxx
|
||||
IDNames.tcl
|
||||
|
@@ -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
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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
|
||||
|
185
src/ShapePersistent/ShapePersistent_Geom2d.cxx
Normal file
185
src/ShapePersistent/ShapePersistent_Geom2d.cxx
Normal 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;
|
||||
}
|
@@ -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
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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"; }
|
||||
|
@@ -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
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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
|
||||
|
14
src/ShapePersistent/ShapePersistent_TriangleMode.hxx
Normal file
14
src/ShapePersistent/ShapePersistent_TriangleMode.hxx
Normal 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
|
@@ -42,7 +42,7 @@
|
||||
//! - "dev" for official (certified) version (master branch) between releases
|
||||
//! - "beta..." or "rc..." for beta releases or release candidates
|
||||
//! - "project..." for version containing project-specific fixes
|
||||
#define OCC_VERSION_DEVELOPMENT "dev"
|
||||
#define OCC_VERSION_DEVELOPMENT "spe-patch"
|
||||
|
||||
// Derived (manually): version as real and string (major.minor)
|
||||
#define OCC_VERSION 7.1
|
||||
|
@@ -131,8 +131,8 @@ Handle(StdObjMgt_Persistent) StdLDrivers_DocumentRetrievalDriver::read (
|
||||
NCollection_Array1<StdObjMgt_Persistent::Instantiator>
|
||||
anInstantiators (1, aTypeData.NumberOfTypes());
|
||||
{
|
||||
StdObjMgt_MapOfInstantiators aMapOfInstantiators;
|
||||
bindTypes (aMapOfInstantiators);
|
||||
StdObjMgt_MapOfInstantiators aMapOfInst;
|
||||
bindTypes (aMapOfInst);
|
||||
|
||||
TColStd_SequenceOfAsciiString anUnknownTypes;
|
||||
Standard_Integer aCurTypeNum;
|
||||
@@ -144,7 +144,7 @@ Handle(StdObjMgt_Persistent) StdLDrivers_DocumentRetrievalDriver::read (
|
||||
aCurTypeNum = aTypeData.Type (aCurTypeName);
|
||||
|
||||
StdObjMgt_Persistent::Instantiator anInstantiator;
|
||||
if (aMapOfInstantiators.Find (aCurTypeName, anInstantiator))
|
||||
if (aMapOfInst.Find(aCurTypeName, anInstantiator))
|
||||
anInstantiators (aCurTypeNum) = anInstantiator;
|
||||
else
|
||||
anUnknownTypes.Append (aCurTypeName);
|
||||
|
@@ -13,6 +13,7 @@
|
||||
|
||||
#include <StdLPersistent_Data.hxx>
|
||||
#include <StdObjMgt_ReadData.hxx>
|
||||
#include <StdObjMgt_WriteData.hxx>
|
||||
|
||||
#include <TDF_Data.hxx>
|
||||
#include <TDF_Attribute.hxx>
|
||||
@@ -80,6 +81,15 @@ void StdLPersistent_Data::Read (StdObjMgt_ReadData& theReadData)
|
||||
theReadData >> myVersion >> myLabels >> myAttributes;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Write
|
||||
//purpose : Write persistent data to a file
|
||||
//=======================================================================
|
||||
void StdLPersistent_Data::Write (StdObjMgt_WriteData& theWriteData) const
|
||||
{
|
||||
theWriteData << myVersion << myLabels << myAttributes;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Import
|
||||
//purpose : Import transient data from the persistent data
|
||||
|
@@ -26,6 +26,17 @@ class StdLPersistent_Data : public StdObjMgt_Persistent
|
||||
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(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
|
||||
{
|
||||
theChildren.Append(myLabels);
|
||||
theChildren.Append(myAttributes);
|
||||
}
|
||||
//! Returns persistent type name
|
||||
Standard_EXPORT virtual Standard_CString PName() const
|
||||
{ return "PDF_Data"; }
|
||||
|
||||
//! Import transient data from the persistent data.
|
||||
Standard_EXPORT Handle(TDF_Data) Import() const;
|
||||
|
@@ -32,6 +32,17 @@ class StdLPersistent_Dependency
|
||||
//! Read persistent data from a file.
|
||||
inline void Read (StdObjMgt_ReadData& theReadData)
|
||||
{ theReadData >> myName >> myVariables; }
|
||||
//! Write persistent data to a file.
|
||||
inline void Write (StdObjMgt_WriteData& theWriteData) const
|
||||
{ theWriteData << myName << myVariables; }
|
||||
//! Gets persistent child objects
|
||||
inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
|
||||
{
|
||||
theChildren.Append(myName);
|
||||
theChildren.Append(myVariables);
|
||||
}
|
||||
//! Returns persistent type name
|
||||
Standard_CString PName() const;
|
||||
|
||||
//! Import transient attribuite from the persistent data.
|
||||
void Import (const Handle(AttribClass)& theAttribute) const;
|
||||
@@ -46,4 +57,12 @@ public:
|
||||
typedef instance<TDataStd_Relation> Relation;
|
||||
};
|
||||
|
||||
template<>
|
||||
inline Standard_CString StdLPersistent_Dependency::instance<TDataStd_Expression>::PName() const
|
||||
{ return "PDataStd_Expression"; }
|
||||
|
||||
template<>
|
||||
inline Standard_CString StdLPersistent_Dependency::instance<TDataStd_Relation>::PName() const
|
||||
{ return "PDataStd_Relation"; }
|
||||
|
||||
#endif
|
||||
|
@@ -14,6 +14,7 @@
|
||||
#include <StdLPersistent_Document.hxx>
|
||||
#include <StdLPersistent_Data.hxx>
|
||||
#include <StdObjMgt_ReadData.hxx>
|
||||
#include <StdObjMgt_WriteData.hxx>
|
||||
|
||||
#include <TDocStd_Document.hxx>
|
||||
#include <TDocStd_Owner.hxx>
|
||||
@@ -28,6 +29,24 @@ void StdLPersistent_Document::Read (StdObjMgt_ReadData& theReadData)
|
||||
theReadData >> myData;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Write
|
||||
//purpose : Write persistent data to a file
|
||||
//=======================================================================
|
||||
void StdLPersistent_Document::Write (StdObjMgt_WriteData& theWriteData) const
|
||||
{
|
||||
theWriteData << myData;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : PChildren
|
||||
//purpose : Gets persistent child objects
|
||||
//=======================================================================
|
||||
void StdLPersistent_Document::PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
|
||||
{
|
||||
theChildren.Append(myData);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Import
|
||||
//purpose : Import transient document from the persistent data
|
||||
|
@@ -26,6 +26,13 @@ class StdLPersistent_Document : public StdObjMgt_Persistent
|
||||
public:
|
||||
//! Read persistent data from a file.
|
||||
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
|
||||
//! Read persistent data from a file.
|
||||
Standard_EXPORT virtual void Write (StdObjMgt_WriteData& theWriteData) 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
|
||||
{ return "PDocStd_Document"; }
|
||||
|
||||
//! Import transient document from the persistent data.
|
||||
Standard_EXPORT virtual void ImportDocument
|
||||
|
@@ -27,6 +27,13 @@ public:
|
||||
//! Read persistent data from a file.
|
||||
inline void Read (StdObjMgt_ReadData& theReadData)
|
||||
{ theReadData >> myDriverGUID >> myFailure; }
|
||||
//! Write persistent data to a file.
|
||||
inline void Write (StdObjMgt_WriteData& theWriteData) const
|
||||
{ theWriteData << myDriverGUID << myFailure; }
|
||||
//! Gets persistent child objects
|
||||
inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent&) const {}
|
||||
//! Returns persistent type name
|
||||
inline Standard_CString PName() const { return "PFunction_Function"; }
|
||||
|
||||
//! Import transient attribuite from the persistent data.
|
||||
void Import (const Handle(TFunction_Function)& theAttribute) const
|
||||
|
@@ -32,3 +32,21 @@ void StdLPersistent_HArray1::base::Read (StdObjMgt_ReadData& theReadData)
|
||||
for (Standard_Integer i = aLowerBound; i <= anUpperBound; i++)
|
||||
readValue (anObjectData, i);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Write
|
||||
//purpose : Write persistent data to a file
|
||||
//=======================================================================
|
||||
void StdLPersistent_HArray1::base::Write (StdObjMgt_WriteData& theWriteData) const
|
||||
{
|
||||
Standard_Integer aLowerBound = lowerBound(), anUpperBound = upperBound();
|
||||
theWriteData << aLowerBound << anUpperBound;
|
||||
|
||||
StdObjMgt_WriteData::Object anObjectData(theWriteData);
|
||||
|
||||
Standard_Integer aSize = anUpperBound - aLowerBound + 1;
|
||||
anObjectData << aSize;
|
||||
|
||||
for (Standard_Integer i = aLowerBound; i <= anUpperBound; i++)
|
||||
writeValue(theWriteData, i);
|
||||
}
|
||||
|
@@ -15,8 +15,12 @@
|
||||
#ifndef _StdLPersistent_HArray1_HeaderFile
|
||||
#define _StdLPersistent_HArray1_HeaderFile
|
||||
|
||||
#include <Standard_NotImplemented.hxx>
|
||||
#include <Standard_NullValue.hxx>
|
||||
|
||||
#include <StdObjMgt_Persistent.hxx>
|
||||
#include <StdObjMgt_ReadData.hxx>
|
||||
#include <StdObjMgt_WriteData.hxx>
|
||||
|
||||
#include <NCollection_DefineHArray1.hxx>
|
||||
|
||||
@@ -40,19 +44,27 @@ class StdLPersistent_HArray1
|
||||
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;
|
||||
|
||||
protected:
|
||||
virtual Standard_Integer lowerBound() const = 0;
|
||||
virtual Standard_Integer upperBound() const = 0;
|
||||
virtual void createArray (const Standard_Integer theLowerBound,
|
||||
const Standard_Integer theUpperBound) = 0;
|
||||
|
||||
virtual void readValue (StdObjMgt_ReadData& theReadData,
|
||||
const Standard_Integer theIndex) = 0;
|
||||
virtual void writeValue(StdObjMgt_WriteData& theWriteData,
|
||||
const Standard_Integer theIndex) const = 0;
|
||||
};
|
||||
|
||||
protected:
|
||||
template <class ArrayClass>
|
||||
class instance : public base
|
||||
{
|
||||
friend class StdLPersistent_HArray1;
|
||||
|
||||
public:
|
||||
typedef Handle(ArrayClass) ArrayHandle;
|
||||
typedef typename ArrayClass::value_type ValueType;
|
||||
@@ -63,27 +75,105 @@ protected:
|
||||
const Handle(ArrayClass)& Array() const { return myArray; }
|
||||
|
||||
protected:
|
||||
virtual void createArray (const Standard_Integer theLowerBound,
|
||||
virtual Standard_Integer lowerBound() const { return myArray->Lower(); }
|
||||
virtual Standard_Integer upperBound() const { return myArray->Upper(); }
|
||||
virtual void createArray(const Standard_Integer theLowerBound,
|
||||
const Standard_Integer theUpperBound)
|
||||
{ myArray = new ArrayClass (theLowerBound, theUpperBound); }
|
||||
|
||||
virtual void readValue (StdObjMgt_ReadData& theReadData,
|
||||
const Standard_Integer theIndex)
|
||||
{ theReadData >> myArray->ChangeValue (theIndex); }
|
||||
virtual void writeValue(StdObjMgt_WriteData& theWriteData,
|
||||
const Standard_Integer theIndex) const
|
||||
{ theWriteData << myArray->Value(theIndex); }
|
||||
virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
|
||||
{ return PChildrenT(theChildren); }
|
||||
virtual Standard_CString PName() const
|
||||
{ return PNameT(); }
|
||||
Standard_CString PNameT() const
|
||||
{
|
||||
Standard_NotImplemented::Raise("StdLPersistent_HArray1::instance::PName - not implemented");
|
||||
return "";
|
||||
}
|
||||
void PChildrenT(StdObjMgt_Persistent::SequenceOfPersistent&) const {}
|
||||
|
||||
protected:
|
||||
Handle(ArrayClass) myArray;
|
||||
};
|
||||
|
||||
template <class ArrayClass>
|
||||
class named_instance : public instance<ArrayClass>
|
||||
{
|
||||
friend class StdLPersistent_HArray1;
|
||||
|
||||
public:
|
||||
virtual Standard_CString PName() const
|
||||
{
|
||||
Standard_NullValue_Raise_if(!myPName,
|
||||
"StdLPersistent_HArray1::named_instance::PName - name not set");
|
||||
return myPName;
|
||||
}
|
||||
|
||||
protected:
|
||||
named_instance(Standard_CString thePName) : myPName(thePName) {}
|
||||
|
||||
Standard_CString myPName;
|
||||
};
|
||||
|
||||
public:
|
||||
typedef instance<TColStd_HArray1OfInteger> Integer;
|
||||
typedef instance<TColStd_HArray1OfReal> Real;
|
||||
typedef instance<TColStd_HArray1OfByte> Byte;
|
||||
typedef instance<StdLPersistent_HArray1OfPersistent> Persistent;
|
||||
|
||||
public:
|
||||
template <class ArrayClass>
|
||||
static Handle(instance<ArrayClass>) Translate(const ArrayClass& theArray)
|
||||
{
|
||||
Handle(instance<ArrayClass>) aPArray = new instance<ArrayClass>;
|
||||
aPArray->myArray = new ArrayClass(theArray.Lower(), theArray.Upper());
|
||||
for (Standard_Integer i = theArray.Lower(); i <= theArray.Upper(); ++i)
|
||||
aPArray->myArray->ChangeValue(i) = theArray.Value(i);
|
||||
return aPArray;
|
||||
}
|
||||
template <class ArrayClass>
|
||||
static Handle(instance<ArrayClass>) Translate(Standard_CString thePName, const ArrayClass& theArray)
|
||||
{
|
||||
Handle(named_instance<ArrayClass>) aPArray = new named_instance<ArrayClass>(thePName);
|
||||
aPArray->myArray = new ArrayClass(theArray.Lower(), theArray.Upper());
|
||||
for (Standard_Integer i = theArray.Lower(); i <= theArray.Upper(); ++i)
|
||||
aPArray->myArray->ChangeValue(i) = theArray.Value(i);
|
||||
return aPArray;
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
inline Standard_CString StdLPersistent_HArray1::instance<TColStd_HArray1OfInteger>::PNameT() const
|
||||
{ return "PColStd_HArray1OfInteger"; }
|
||||
|
||||
template<>
|
||||
inline Standard_CString StdLPersistent_HArray1::instance<TColStd_HArray1OfReal>::PNameT() const
|
||||
{ return "PColStd_HArray1OfReal"; }
|
||||
|
||||
template<>
|
||||
inline Standard_CString StdLPersistent_HArray1::instance<TColStd_HArray1OfByte>::PNameT() const
|
||||
{ return "PColStd_HArray1OfByte"; }
|
||||
|
||||
inline StdObjMgt_ReadData& operator >>
|
||||
(StdObjMgt_ReadData& theReadData, Standard_Byte& theByte)
|
||||
{ return theReadData >> reinterpret_cast<Standard_Character&> (theByte); }
|
||||
|
||||
inline StdObjMgt_WriteData& operator >>
|
||||
(StdObjMgt_WriteData& theWriteData, const Standard_Byte& theByte)
|
||||
{ return theWriteData << reinterpret_cast<const Standard_Character&> (theByte); }
|
||||
|
||||
template<>
|
||||
inline void StdLPersistent_HArray1::instance<StdLPersistent_HArray1OfPersistent>::PChildrenT
|
||||
(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
|
||||
{
|
||||
for (Standard_Integer i = myArray->Lower(); i <= myArray->Upper(); ++i)
|
||||
theChildren.Append(myArray->Value(i));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -36,3 +36,24 @@ void StdLPersistent_HArray2::base::Read (StdObjMgt_ReadData& theReadData)
|
||||
for (Standard_Integer aCol = aLowerCol; aCol <= anUpperCol; aCol++)
|
||||
readValue (anObjectData, aRow, aCol);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Read
|
||||
//purpose : Read persistent data from a file
|
||||
//=======================================================================
|
||||
void StdLPersistent_HArray2::base::Write (StdObjMgt_WriteData& theWriteData) const
|
||||
{
|
||||
Standard_Integer aLowerRow, aLowerCol, anUpperRow, anUpperCol;
|
||||
lowerBound(aLowerRow, aLowerCol);
|
||||
upperBound(anUpperRow, anUpperCol);
|
||||
theWriteData << aLowerRow << aLowerCol << anUpperRow << anUpperCol;
|
||||
|
||||
StdObjMgt_WriteData::Object anObjectData(theWriteData);
|
||||
|
||||
Standard_Integer aSize = (anUpperRow - aLowerRow + 1) * (anUpperCol - aLowerCol + 1);
|
||||
anObjectData << aSize;
|
||||
|
||||
for (Standard_Integer aRow = aLowerRow; aRow <= anUpperRow; aRow++)
|
||||
for (Standard_Integer aCol = aLowerCol; aCol <= anUpperCol; aCol++)
|
||||
writeValue(anObjectData, aRow, aCol);
|
||||
}
|
||||
|
@@ -15,8 +15,12 @@
|
||||
#ifndef _StdLPersistent_HArray2_HeaderFile
|
||||
#define _StdLPersistent_HArray2_HeaderFile
|
||||
|
||||
#include <Standard_NotImplemented.hxx>
|
||||
#include <Standard_NullValue.hxx>
|
||||
|
||||
#include <StdObjMgt_Persistent.hxx>
|
||||
#include <StdObjMgt_ReadData.hxx>
|
||||
#include <StdObjMgt_WriteData.hxx>
|
||||
|
||||
#include <NCollection_DefineHArray2.hxx>
|
||||
|
||||
@@ -36,8 +40,15 @@ class StdLPersistent_HArray2
|
||||
//! Read persistent data from a file.
|
||||
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
|
||||
|
||||
//! Read persistent data from a file.
|
||||
Standard_EXPORT virtual void Write (StdObjMgt_WriteData& theWriteData) const;
|
||||
|
||||
protected:
|
||||
virtual void createArray (
|
||||
virtual void lowerBound(Standard_Integer& theRow,
|
||||
Standard_Integer& theCol) const = 0;
|
||||
virtual void upperBound(Standard_Integer& theRow,
|
||||
Standard_Integer& theCol) const = 0;
|
||||
virtual void createArray(
|
||||
const Standard_Integer theLowerRow, const Standard_Integer theLowerCol,
|
||||
const Standard_Integer theUpperRow, const Standard_Integer theUpperCol)
|
||||
= 0;
|
||||
@@ -45,12 +56,17 @@ class StdLPersistent_HArray2
|
||||
virtual void readValue (StdObjMgt_ReadData& theReadData,
|
||||
const Standard_Integer theRow,
|
||||
const Standard_Integer theCol) = 0;
|
||||
virtual void writeValue(StdObjMgt_WriteData& theWriteData,
|
||||
const Standard_Integer theRow,
|
||||
const Standard_Integer theCol) const = 0;
|
||||
};
|
||||
|
||||
protected:
|
||||
template <class ArrayClass>
|
||||
class instance : public base
|
||||
{
|
||||
friend class StdLPersistent_HArray2;
|
||||
|
||||
public:
|
||||
typedef Handle(ArrayClass) ArrayHandle;
|
||||
|
||||
@@ -59,27 +75,114 @@ protected:
|
||||
const Handle(ArrayClass)& Array() const { return myArray; }
|
||||
|
||||
protected:
|
||||
virtual void createArray (
|
||||
virtual void lowerBound(Standard_Integer& theRow,
|
||||
Standard_Integer& theCol) const
|
||||
{
|
||||
theRow = myArray->LowerRow();
|
||||
theCol = myArray->LowerCol();
|
||||
}
|
||||
virtual void upperBound(Standard_Integer& theRow,
|
||||
Standard_Integer& theCol) const
|
||||
{
|
||||
theRow = myArray->UpperRow();
|
||||
theCol = myArray->UpperCol();
|
||||
}
|
||||
virtual void createArray(
|
||||
const Standard_Integer theLowerRow, const Standard_Integer theLowerCol,
|
||||
const Standard_Integer theUpperRow, const Standard_Integer theUpperCol)
|
||||
{
|
||||
myArray = new ArrayClass (theLowerRow, theUpperRow,
|
||||
theLowerCol, theUpperCol);
|
||||
}
|
||||
|
||||
virtual void readValue (StdObjMgt_ReadData& theReadData,
|
||||
const Standard_Integer theRow,
|
||||
const Standard_Integer theCol)
|
||||
{ theReadData >> myArray->ChangeValue (theRow, theCol); }
|
||||
virtual void writeValue(StdObjMgt_WriteData& theWriteData,
|
||||
const Standard_Integer theRow,
|
||||
const Standard_Integer theCol) const
|
||||
{
|
||||
theWriteData << myArray->Value(theRow, theCol);
|
||||
}
|
||||
virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
|
||||
{ return PChildrenT(theChildren); }
|
||||
virtual Standard_CString PName() const
|
||||
{ return PNameT(); }
|
||||
Standard_CString PNameT() const
|
||||
{
|
||||
Standard_NotImplemented::Raise("StdLPersistent_HArray2::instance::PName - not implemented");
|
||||
return "";
|
||||
}
|
||||
void PChildrenT(StdObjMgt_Persistent::SequenceOfPersistent&) const {}
|
||||
|
||||
protected:
|
||||
Handle(ArrayClass) myArray;
|
||||
};
|
||||
|
||||
template <class ArrayClass>
|
||||
class named_instance : public instance<ArrayClass>
|
||||
{
|
||||
friend class StdLPersistent_HArray2;
|
||||
|
||||
public:
|
||||
virtual Standard_CString PName() const
|
||||
{
|
||||
Standard_NullValue_Raise_if(!myPName,
|
||||
"StdLPersistent_HArray2::named_instance::PName - name not set");
|
||||
return myPName;
|
||||
}
|
||||
|
||||
protected:
|
||||
named_instance(Standard_CString thePName) : myPName(thePName) {}
|
||||
|
||||
Standard_CString myPName;
|
||||
};
|
||||
|
||||
public:
|
||||
typedef instance<TColStd_HArray2OfInteger> Integer;
|
||||
typedef instance<TColStd_HArray2OfReal> Real;
|
||||
typedef instance<StdLPersistent_HArray2OfPersistent> Persistent;
|
||||
|
||||
public:
|
||||
template <class ArrayClass>
|
||||
static Handle(instance<ArrayClass>) Translate(const ArrayClass& theArray)
|
||||
{
|
||||
Handle(instance<ArrayClass>) aPArray = new instance<ArrayClass>;
|
||||
aPArray->myArray = new ArrayClass(theArray.LowerRow(), theArray.UpperRow(),
|
||||
theArray.LowerCol(), theArray.UpperCol());
|
||||
for (Standard_Integer i = theArray.LowerRow(); i <= theArray.UpperRow(); ++i)
|
||||
for (Standard_Integer j = theArray.LowerCol(); j <= theArray.UpperCol(); ++j)
|
||||
aPArray->myArray->ChangeValue(i, j) = theArray.Value(i, j);
|
||||
return aPArray;
|
||||
}
|
||||
template <class ArrayClass>
|
||||
static Handle(instance<ArrayClass>) Translate(Standard_CString thePName, const ArrayClass& theArray)
|
||||
{
|
||||
Handle(named_instance<ArrayClass>) aPArray = new named_instance<ArrayClass>(thePName);
|
||||
aPArray->myArray = new ArrayClass(theArray.LowerRow(), theArray.UpperRow(),
|
||||
theArray.LowerCol(), theArray.UpperCol());
|
||||
for (Standard_Integer i = theArray.LowerRow(); i <= theArray.UpperRow(); ++i)
|
||||
for (Standard_Integer j = theArray.LowerCol(); j <= theArray.UpperCol(); ++j)
|
||||
aPArray->myArray->ChangeValue(i, j) = theArray.Value(i, j);
|
||||
return aPArray;
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
inline Standard_CString StdLPersistent_HArray2::instance<TColStd_HArray2OfInteger>::PNameT() const
|
||||
{ return "PColStd_HArray2OfInteger"; }
|
||||
|
||||
template<>
|
||||
inline Standard_CString StdLPersistent_HArray2::instance<TColStd_HArray2OfReal>::PNameT() const
|
||||
{ return "PColStd_HArray2OfReal"; }
|
||||
|
||||
template<>
|
||||
inline void StdLPersistent_HArray2::instance<StdLPersistent_HArray2OfPersistent>::PChildrenT
|
||||
(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
|
||||
{
|
||||
for (Standard_Integer i = myArray->LowerRow(); i <= myArray->UpperRow(); ++i)
|
||||
for (Standard_Integer j = myArray->LowerCol(); j <= myArray->UpperCol(); ++j)
|
||||
theChildren.Append(myArray->Value(i, j));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -13,6 +13,7 @@
|
||||
|
||||
#include <StdLPersistent_HString.hxx>
|
||||
#include <StdObjMgt_ReadData.hxx>
|
||||
#include <StdObjMgt_WriteData.hxx>
|
||||
#include <TDF_Label.hxx>
|
||||
#include <TDF_Tool.hxx>
|
||||
|
||||
@@ -39,6 +40,26 @@ void StdLPersistent_HString::instance<StringClass, CharType>::Read
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Write
|
||||
//purpose : Write persistent data to a file
|
||||
//=======================================================================
|
||||
template <class StringClass, typename CharType>
|
||||
void StdLPersistent_HString::instance<StringClass, CharType>::Write
|
||||
(StdObjMgt_WriteData& theWriteData) const
|
||||
{
|
||||
StdObjMgt_WriteData::Object anObjectData(theWriteData);
|
||||
|
||||
Standard_Integer aSize = myValue->Length();
|
||||
anObjectData << aSize;
|
||||
|
||||
for (Standard_Integer i = 1; i <= aSize; i++)
|
||||
{
|
||||
CharType aChar (0);
|
||||
anObjectData << aChar;
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Label
|
||||
//purpose : Get/create a label defined by referenced string
|
||||
|
@@ -30,6 +30,9 @@ class StdLPersistent_HString
|
||||
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;
|
||||
Standard_EXPORT virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent&) const { }
|
||||
|
||||
//! Get/create a label defined by referenced string.
|
||||
Standard_EXPORT virtual TDF_Label Label (const Handle(TDF_Data)& theDF) const;
|
||||
@@ -48,6 +51,8 @@ public:
|
||||
public:
|
||||
//! Get referenced ASCII string.
|
||||
Standard_EXPORT virtual Handle(TCollection_HAsciiString) AsciiString() const;
|
||||
|
||||
inline Standard_CString PName() const { return "PCollection_HAsciiString"; }
|
||||
};
|
||||
|
||||
class Extended
|
||||
@@ -56,6 +61,8 @@ public:
|
||||
public:
|
||||
//! Get referenced extended string.
|
||||
Standard_EXPORT virtual Handle(TCollection_HExtendedString) ExtString() const;
|
||||
|
||||
inline Standard_CString PName() const { return "PCollection_HExtendedString"; }
|
||||
};
|
||||
};
|
||||
|
||||
|
@@ -32,6 +32,8 @@ class StdLPersistent_NamedData : public StdObjMgt_Attribute<TDataStd_NamedData>
|
||||
|
||||
inline void Read (StdObjMgt_ReadData& theReadData)
|
||||
{ theReadData >> myKeys >> myValues; }
|
||||
inline void Write (StdObjMgt_WriteData& theWriteData) const
|
||||
{ theWriteData << myKeys << myValues; }
|
||||
|
||||
inline operator bool() const
|
||||
{ return !myKeys.IsNull(); }
|
||||
@@ -60,6 +62,24 @@ public:
|
||||
myRealArrays.Read (theReadData);
|
||||
}
|
||||
|
||||
//! Write persistent data to a file.
|
||||
inline void Write (StdObjMgt_WriteData& theWriteData) const
|
||||
{
|
||||
theWriteData << myDimensions;
|
||||
myInts.Write(theWriteData);
|
||||
myReals.Write(theWriteData);
|
||||
myStrings.Write(theWriteData);
|
||||
myBytes.Write(theWriteData);
|
||||
myIntArrays.Write(theWriteData);
|
||||
myRealArrays.Write(theWriteData);
|
||||
}
|
||||
|
||||
//! Gets persistent child objects
|
||||
void PChildren(StdObjMgt_Persistent::SequenceOfPersistent&) const {}
|
||||
|
||||
//! Returns persistent type name
|
||||
Standard_CString PName() const { return "PDataStd_NamedData"; }
|
||||
|
||||
//! Import transient attribuite from the persistent data.
|
||||
void Import (const Handle(TDataStd_NamedData)& theAttribute) const;
|
||||
|
||||
|
@@ -26,13 +26,20 @@ public:
|
||||
//! Read persistent data from a file.
|
||||
inline void Read (StdObjMgt_ReadData& theReadData)
|
||||
{ theReadData >> myValue >> myDimension; }
|
||||
//! Write persistent data from a file.
|
||||
inline void Write (StdObjMgt_WriteData& theWriteData) const
|
||||
{ theWriteData << myValue << myDimension; }
|
||||
//! Gets persistent child objects
|
||||
void PChildren(StdObjMgt_Persistent::SequenceOfPersistent&) const {}
|
||||
//! Returns persistent type name
|
||||
Standard_CString PName() const { return "PDataStd_Real"; }
|
||||
|
||||
//! Import transient attribuite from the persistent data.
|
||||
void Import (const Handle(TDataStd_Real)& theAttribute) const
|
||||
{
|
||||
theAttribute->Set (myValue);
|
||||
theAttribute->SetDimension (static_cast<TDataStd_RealEnum> (myDimension));
|
||||
theAttribute->SetID(TDataStd_Real::GetID());
|
||||
theAttribute->SetID(TDataStd_Real::GetID());
|
||||
}
|
||||
|
||||
private:
|
||||
|
@@ -24,6 +24,27 @@ void StdLPersistent_TreeNode::Read (StdObjMgt_ReadData& theReadData)
|
||||
theReadData >> myDynamicData->First >> myNext >> myDynamicData->TreeID;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Write
|
||||
//purpose : Write persistent data to a file
|
||||
//=======================================================================
|
||||
void StdLPersistent_TreeNode::Write (StdObjMgt_WriteData& theWriteData) const
|
||||
{
|
||||
theWriteData << myDynamicData->First << myNext << myDynamicData->TreeID;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : PChildren
|
||||
//purpose : Gets persistent child objects
|
||||
//=======================================================================
|
||||
void StdLPersistent_TreeNode::PChildren
|
||||
(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
|
||||
{
|
||||
theChildren.Append(myNext);
|
||||
if (!myDynamicData.IsNull())
|
||||
theChildren.Append(myDynamicData->First);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : CreateAttribute
|
||||
//purpose : Create an empty transient attribuite
|
||||
|
@@ -28,6 +28,16 @@ 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(StdObjMgt_Persistent::SequenceOfPersistent&) const;
|
||||
|
||||
//! Returns persistent type name
|
||||
Standard_EXPORT virtual Standard_CString PName() const
|
||||
{ return "PDataStd_TreeNode"; }
|
||||
|
||||
//! Create an empty transient attribuite
|
||||
Standard_EXPORT virtual Handle(TDF_Attribute) CreateAttribute();
|
||||
|
||||
|
@@ -48,15 +48,27 @@ class StdLPersistent_Value
|
||||
|
||||
public:
|
||||
|
||||
typedef integer <TDF_TagSource> TagSource;
|
||||
typedef string <TDF_Reference> Reference;
|
||||
typedef string <TDataStd_Comment> Comment;
|
||||
class TagSource : public integer <TDF_TagSource> {
|
||||
public:
|
||||
Standard_CString PName() const { return "PDF_TagSource"; }
|
||||
};
|
||||
|
||||
class Reference : public string <TDF_Reference> {
|
||||
public:
|
||||
Standard_CString PName() const { return "PDF_Reference"; }
|
||||
};
|
||||
|
||||
class Comment : public string <TDataStd_Comment> {
|
||||
public:
|
||||
Standard_CString PName() const { return "PDF_Comment"; }
|
||||
};
|
||||
|
||||
class UAttribute : public string <TDataStd_UAttribute>
|
||||
{
|
||||
public:
|
||||
//! Create an empty transient attribuite
|
||||
Standard_EXPORT virtual Handle(TDF_Attribute) CreateAttribute();
|
||||
Standard_CString PName() const { return "PDataStd_UAttribute"; }
|
||||
};
|
||||
|
||||
class Integer : public integer <TDataStd_Integer>
|
||||
@@ -64,6 +76,7 @@ public:
|
||||
public:
|
||||
//! Create an empty transient attribuite
|
||||
Standard_EXPORT virtual Handle(TDF_Attribute) CreateAttribute();
|
||||
Standard_CString PName() const { return "PDataStd_Integer"; }
|
||||
};
|
||||
|
||||
class Name : public string <TDataStd_Name>
|
||||
@@ -71,6 +84,7 @@ public:
|
||||
public:
|
||||
//! Create an empty transient attribuite
|
||||
Standard_EXPORT virtual Handle(TDF_Attribute) CreateAttribute();
|
||||
Standard_CString PName() const { return "PDataStd_Name"; }
|
||||
};
|
||||
|
||||
class AsciiString : public string <TDataStd_AsciiString, StdLPersistent_HString::Ascii>
|
||||
@@ -78,7 +92,23 @@ public:
|
||||
public:
|
||||
//! Create an empty transient attribuite
|
||||
Standard_EXPORT virtual Handle(TDF_Attribute) CreateAttribute();
|
||||
Standard_CString PName() const { return "PDataStd_AsciiString"; }
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
template<>
|
||||
inline Standard_CString StdObjMgt_Attribute<TDF_TagSource>::Simple<Standard_Integer>::PName() const
|
||||
{ return "PDF_TagSource"; }
|
||||
|
||||
template<>
|
||||
template<>
|
||||
inline Standard_CString StdObjMgt_Attribute<TDF_Reference>::Simple<Handle(StdObjMgt_Persistent)>::PName() const
|
||||
{ return "PDF_Reference"; }
|
||||
|
||||
template<>
|
||||
template<>
|
||||
inline Standard_CString StdObjMgt_Attribute<TDataStd_Comment>::Simple<Handle(StdObjMgt_Persistent)>::PName() const
|
||||
{ return "PDataStd_Comment"; }
|
||||
|
||||
#endif
|
||||
|
@@ -27,6 +27,14 @@ public:
|
||||
//! Read persistent data from a file.
|
||||
inline void Read (StdObjMgt_ReadData& theReadData)
|
||||
{ theReadData >> myIsConstant >> myUnit; }
|
||||
//! Write persistent data to a file.
|
||||
inline void Write (StdObjMgt_WriteData& theWriteData) const
|
||||
{ theWriteData << myIsConstant << myUnit; }
|
||||
//! Gets persistent child objects
|
||||
inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
|
||||
{ theChildren.Append(myUnit); }
|
||||
//! Returns persistent type name
|
||||
inline Standard_CString PName() const { return "PDataStd_Variable"; }
|
||||
|
||||
//! Import transient attribuite from the persistent data.
|
||||
void Import (const Handle(TDataStd_Variable)& theAttribute) const
|
||||
|
@@ -31,6 +31,12 @@ protected:
|
||||
public:
|
||||
//! Read persistent data from a file.
|
||||
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
|
||||
inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent&) const {}
|
||||
//! Returns persistent type name
|
||||
Standard_CString PName() const;
|
||||
|
||||
//! Import transient attribuite from the persistent data
|
||||
Standard_EXPORT virtual void ImportAttribute() {}
|
||||
@@ -42,4 +48,16 @@ public:
|
||||
typedef instance<TDataStd_NoteBook> NoteBook;
|
||||
};
|
||||
|
||||
template<>
|
||||
inline Standard_CString StdLPersistent_Void::instance<TDataStd_Directory>::PName() const
|
||||
{ return "PDataStd_Directory"; }
|
||||
|
||||
template<>
|
||||
inline Standard_CString StdLPersistent_Void::instance<TDataStd_Tick>::PName() const
|
||||
{ return "PDataStd_Tick"; }
|
||||
|
||||
template<>
|
||||
inline Standard_CString StdLPersistent_Void::instance<TDataStd_NoteBook>::PName() const
|
||||
{ return "PDataStd_Notebook"; }
|
||||
|
||||
#endif
|
||||
|
@@ -27,6 +27,17 @@ public:
|
||||
//! Read persistent data from a file.
|
||||
inline void Read (StdObjMgt_ReadData& theReadData)
|
||||
{ theReadData >> myDocEntry >> myLabEntry; }
|
||||
//! Write persistent data to a file.
|
||||
inline void Write (StdObjMgt_WriteData& theWriteData) const
|
||||
{ theWriteData << myDocEntry << myLabEntry; }
|
||||
//! Gets persistent child objects
|
||||
inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
|
||||
{
|
||||
theChildren.Append(myDocEntry);
|
||||
theChildren.Append(myLabEntry);
|
||||
}
|
||||
//! Returns persistent type name
|
||||
inline Standard_CString PName() const { return "PDocStd_XLink"; }
|
||||
|
||||
//! Import transient attribuite from the persistent data.
|
||||
void Import (const Handle(TDocStd_XLink)& theAttribute) const
|
||||
|
@@ -1,8 +1,10 @@
|
||||
StdObjMgt_Attribute.hxx
|
||||
StdObjMgt_MapOfInstantiators.cxx
|
||||
StdObjMgt_MapOfInstantiators.hxx
|
||||
StdObjMgt_Persistent.cxx
|
||||
StdObjMgt_Persistent.hxx
|
||||
StdObjMgt_ReadData.cxx
|
||||
StdObjMgt_ReadData.hxx
|
||||
StdObjMgt_WriteData.hxx
|
||||
StdObjMgt_WriteData.cxx
|
||||
StdObjMgt_SharedObject.hxx
|
||||
StdObjMgt_TransientPersistentMap.hxx
|
||||
|
@@ -16,6 +16,7 @@
|
||||
|
||||
#include <StdObjMgt_Persistent.hxx>
|
||||
#include <StdObjMgt_ReadData.hxx>
|
||||
#include <StdObjMgt_WriteData.hxx>
|
||||
|
||||
|
||||
//! Root class for a temporary persistent object corresponding to an attribute.
|
||||
@@ -31,7 +32,7 @@ class StdObjMgt_Attribute : public Standard_Transient
|
||||
|
||||
//! Get transient attribuite for the persistent data
|
||||
Standard_EXPORT virtual Handle(TDF_Attribute) GetAttribute() const
|
||||
{ return Handle(TDF_Attribute)(myTransient); }
|
||||
{ return Handle(TDF_Attribute)(myTransient); }
|
||||
|
||||
protected:
|
||||
Handle(Transient) myTransient;
|
||||
@@ -47,6 +48,11 @@ public:
|
||||
//! Read persistent data from a file.
|
||||
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData)
|
||||
{ theReadData >> myData; }
|
||||
//! Write persistent data to a file.
|
||||
Standard_EXPORT virtual void Write (StdObjMgt_WriteData& theWriteData) const
|
||||
{ theWriteData << myData; }
|
||||
Standard_EXPORT virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent&) const { }
|
||||
Standard_EXPORT virtual Standard_CString PName() const { return "StdObjMgt_Attribute::undefined"; }
|
||||
|
||||
protected:
|
||||
DataType myData;
|
||||
@@ -66,6 +72,12 @@ private:
|
||||
myPersistent = new Persistent;
|
||||
myPersistent->Read (theReadData);
|
||||
}
|
||||
//! Write persistent data to a file.
|
||||
Standard_EXPORT virtual void Write(StdObjMgt_WriteData& theWriteData) const
|
||||
{ myPersistent->Write(theWriteData); }
|
||||
Standard_EXPORT virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent&) const { }
|
||||
Standard_EXPORT virtual Standard_CString PName() const
|
||||
{ return myPersistent->PName(); }
|
||||
|
||||
//! Import transient attribuite from the persistent data
|
||||
Standard_EXPORT virtual void ImportAttribute()
|
||||
|
@@ -13,6 +13,12 @@
|
||||
|
||||
#include <StdObjMgt_Persistent.hxx>
|
||||
|
||||
StdObjMgt_Persistent::StdObjMgt_Persistent()
|
||||
: myTypeNum(0)
|
||||
, myRefNum(0)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ImportDocument
|
||||
|
@@ -18,10 +18,12 @@
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
#include <Standard_Transient.hxx>
|
||||
#include <NCollection_Sequence.hxx>
|
||||
|
||||
#include <TDF_Label.hxx>
|
||||
|
||||
class StdObjMgt_ReadData;
|
||||
class StdObjMgt_WriteData;
|
||||
class TDocStd_Document;
|
||||
class TDF_Attribute;
|
||||
class TDF_Data;
|
||||
@@ -34,6 +36,8 @@ class TCollection_HExtendedString;
|
||||
class StdObjMgt_Persistent : public Standard_Transient
|
||||
{
|
||||
public:
|
||||
Standard_EXPORT StdObjMgt_Persistent();
|
||||
|
||||
//! Derived class instance create function.
|
||||
typedef Handle(StdObjMgt_Persistent) (*Instantiator)();
|
||||
|
||||
@@ -45,6 +49,17 @@ public:
|
||||
//! Read persistent data from a file.
|
||||
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData) = 0;
|
||||
|
||||
//! Write persistent data to a file.
|
||||
Standard_EXPORT virtual void Write (StdObjMgt_WriteData& theWriteData) const = 0;
|
||||
|
||||
typedef NCollection_Sequence<Handle(StdObjMgt_Persistent)> SequenceOfPersistent;
|
||||
|
||||
//! Gets persistent child objects
|
||||
Standard_EXPORT virtual void PChildren (SequenceOfPersistent&) const = 0;
|
||||
|
||||
//! Returns persistent type name
|
||||
Standard_EXPORT virtual Standard_CString PName() const = 0;
|
||||
|
||||
//! Import transient document from the persistent data
|
||||
//! (to be overriden by document class;
|
||||
//! does nothing by default for other classes).
|
||||
@@ -80,6 +95,22 @@ public:
|
||||
//! (to be overriden by extended string class;
|
||||
//! returns a null label by default for other classes).
|
||||
Standard_EXPORT virtual TDF_Label Label (const Handle(TDF_Data)& theDF) const;
|
||||
|
||||
//! Returns the assigned persistent type number
|
||||
Standard_Integer TypeNum() const { return myTypeNum; }
|
||||
|
||||
//! Assigns a persistent type number to the object
|
||||
void TypeNum(Standard_Integer theTypeNum) { myTypeNum = theTypeNum; }
|
||||
|
||||
//! Returns the object reference number
|
||||
Standard_Integer RefNum() const { return myRefNum; }
|
||||
|
||||
//! Sets an object reference number
|
||||
void RefNum(Standard_Integer theRefNum) { myRefNum = theRefNum; }
|
||||
|
||||
private:
|
||||
Standard_Integer myTypeNum;
|
||||
Standard_Integer myRefNum;
|
||||
};
|
||||
|
||||
#endif // _StdObjMgt_Persistent_HeaderFile
|
||||
|
@@ -93,6 +93,8 @@ class StdObjMgt_ReadData::Object
|
||||
public:
|
||||
Object (StdObjMgt_ReadData& theData) : myReadData (&theData)
|
||||
{ myReadData->myDriver->BeginReadObjectData(); }
|
||||
Object(const StdObjMgt_ReadData::Object& theOther) : myReadData(theOther.myReadData)
|
||||
{ myReadData->myDriver->BeginReadObjectData(); }
|
||||
|
||||
~Object()
|
||||
{ myReadData->myDriver->EndReadObjectData(); }
|
||||
@@ -106,6 +108,8 @@ public:
|
||||
|
||||
private:
|
||||
StdObjMgt_ReadData* myReadData;
|
||||
|
||||
StdObjMgt_ReadData::Object& operator = (const StdObjMgt_ReadData::Object&);
|
||||
};
|
||||
|
||||
Standard_EXPORT StdObjMgt_ReadData& operator >>
|
||||
|
@@ -15,9 +15,9 @@
|
||||
#ifndef _StdObjMgt_SharedObject_HeaderFile
|
||||
#define _StdObjMgt_SharedObject_HeaderFile
|
||||
|
||||
#include <Standard_NoSuchObject.hxx>
|
||||
#include <StdObjMgt_Persistent.hxx>
|
||||
|
||||
|
||||
class StdObjMgt_SharedObject
|
||||
{
|
||||
public:
|
||||
@@ -28,15 +28,19 @@ public:
|
||||
virtual Handle(Transient) Import() const = 0;
|
||||
};
|
||||
|
||||
template <class Transient, class Base = StdObjMgt_Persistent>
|
||||
template <class TransientT, class Base = StdObjMgt_Persistent>
|
||||
class SharedBase : public Base
|
||||
{
|
||||
public:
|
||||
//! Changes transient object
|
||||
inline void Transient(const Handle(TransientT)& theTransient)
|
||||
{ myTransient = theTransient; }
|
||||
|
||||
//! Import transient object from the persistent data.
|
||||
inline const Handle(Transient)& Import() { return myTransient; }
|
||||
inline const Handle(TransientT)& Import() { return myTransient; }
|
||||
|
||||
protected:
|
||||
Handle(Transient) myTransient;
|
||||
Handle(TransientT) myTransient;
|
||||
};
|
||||
|
||||
template <class Base,
|
||||
@@ -52,7 +56,7 @@ public:
|
||||
Standard_EXPORT virtual Handle(Transient) Import()
|
||||
{ return myTransient; }
|
||||
|
||||
protected:
|
||||
public:
|
||||
Handle(Transient) myTransient;
|
||||
};
|
||||
|
||||
@@ -65,6 +69,15 @@ public:
|
||||
//! Read persistent data from a file.
|
||||
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData)
|
||||
{ PersistentData().Read (theReadData); }
|
||||
//! Write persistent data to a file.
|
||||
Standard_EXPORT virtual void Write (StdObjMgt_WriteData& theWriteData) const
|
||||
{ PersistentData().Write (theWriteData); }
|
||||
//! Gets persistent child objects
|
||||
Standard_EXPORT virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
|
||||
{ PersistentData().PChildren(theChildren); }
|
||||
//! Returns persistent type name
|
||||
Standard_EXPORT virtual Standard_CString PName() const
|
||||
{ return PersistentData().PName(); }
|
||||
|
||||
//! Import transient object from the persistent data.
|
||||
Standard_EXPORT virtual Handle(Transient) Import()
|
||||
@@ -88,7 +101,7 @@ private:
|
||||
return Base::myTransient;
|
||||
}
|
||||
|
||||
protected:
|
||||
public:
|
||||
Handle(typename Base::PersistentBase) myPersistent;
|
||||
};
|
||||
|
||||
@@ -96,6 +109,19 @@ public:
|
||||
template <class Base, class Persistent = typename Base::PersistentBase>
|
||||
class Delayed : public delayedSubBase<Base>
|
||||
{
|
||||
private:
|
||||
template <class T1, class T2>
|
||||
struct DownCast {
|
||||
static Handle(T1) make(const Handle(T2)& theT2)
|
||||
{ return Handle(T1)::DownCast(theT2); }
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct DownCast<T, T> {
|
||||
static Handle(T) make(const Handle(T)& theT)
|
||||
{ return theT; }
|
||||
};
|
||||
|
||||
public:
|
||||
//! Read persistent data from a file.
|
||||
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData)
|
||||
@@ -104,6 +130,33 @@ public:
|
||||
aPersistent->Read (theReadData);
|
||||
this->myPersistent = aPersistent;
|
||||
}
|
||||
//! Write persistent data to a file.
|
||||
Standard_EXPORT virtual void Write(StdObjMgt_WriteData& theWriteData) const
|
||||
{
|
||||
Handle(Persistent) aPersistent =
|
||||
DownCast<Persistent, typename Base::PersistentBase>::make(this->myPersistent);
|
||||
Standard_NoSuchObject_Raise_if(aPersistent.IsNull(),
|
||||
"StdObjMgt_SharedObject::Delayed::Write - persistent object wasn't set for writing!");
|
||||
aPersistent->Write(theWriteData);
|
||||
}
|
||||
//! Gets persistent child objects
|
||||
Standard_EXPORT virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
|
||||
{
|
||||
Handle(Persistent) aPersistent =
|
||||
DownCast<Persistent, typename Base::PersistentBase>::make(this->myPersistent);
|
||||
Standard_NoSuchObject_Raise_if(aPersistent.IsNull(),
|
||||
"StdObjMgt_SharedObject::Delayed::PChildren - persistent object wasn't set for writing!");
|
||||
aPersistent->PChildren(theChildren);
|
||||
}
|
||||
//! Returns persistent type name
|
||||
Standard_EXPORT virtual Standard_CString PName() const
|
||||
{
|
||||
Handle(Persistent) aPersistent =
|
||||
DownCast<Persistent, typename Base::PersistentBase>::make(this->myPersistent);
|
||||
Standard_NoSuchObject_Raise_if(aPersistent.IsNull(),
|
||||
"StdObjMgt_SharedObject::Delayed::PName - persistent object wasn't set for writing!");
|
||||
return aPersistent->PName();
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
|
12
src/StdObjMgt/StdObjMgt_TransientPersistentMap.hxx
Normal file
12
src/StdObjMgt/StdObjMgt_TransientPersistentMap.hxx
Normal file
@@ -0,0 +1,12 @@
|
||||
|
||||
#ifndef _StdObjMgt_TransientPersistentMap_HeaderFile
|
||||
#define _StdObjMgt_TransientPersistentMap_HeaderFile
|
||||
|
||||
#include <NCollection_DataMap.hxx>
|
||||
|
||||
class Standard_Transient;
|
||||
class StdObjMgt_Persistent;
|
||||
|
||||
typedef NCollection_DataMap<Handle(Standard_Transient), Handle(StdObjMgt_Persistent)> StdObjMgt_TransientPersistentMap;
|
||||
|
||||
#endif // _StdObjMgt_TransientPersistentMap_HeaderFile
|
71
src/StdObjMgt/StdObjMgt_WriteData.cxx
Normal file
71
src/StdObjMgt/StdObjMgt_WriteData.cxx
Normal file
@@ -0,0 +1,71 @@
|
||||
// Copyright (c) 2017 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <StdObjMgt_WriteData.hxx>
|
||||
#include <StdObjMgt_Persistent.hxx>
|
||||
|
||||
#include <Standard_GUID.hxx>
|
||||
|
||||
|
||||
StdObjMgt_WriteData::StdObjMgt_WriteData (Storage_BaseDriver& theDriver)
|
||||
: myDriver (&theDriver)
|
||||
{
|
||||
}
|
||||
|
||||
void StdObjMgt_WriteData::WritePersistentObject (const Handle(StdObjMgt_Persistent)& thePersistent)
|
||||
{
|
||||
if (thePersistent)
|
||||
{
|
||||
myDriver->WritePersistentObjectHeader(thePersistent->RefNum(), thePersistent->TypeNum());
|
||||
myDriver->BeginWritePersistentObjectData();
|
||||
thePersistent->Write(*this);
|
||||
myDriver->EndWritePersistentObjectData();
|
||||
}
|
||||
}
|
||||
|
||||
StdObjMgt_WriteData& StdObjMgt_WriteData::operator << (const Handle(StdObjMgt_Persistent)& thePersistent)
|
||||
{
|
||||
*myDriver << (thePersistent ? thePersistent->RefNum() : 0);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : operator >>
|
||||
//purpose : Read persistent data from a file
|
||||
//=======================================================================
|
||||
StdObjMgt_WriteData& operator <<
|
||||
(StdObjMgt_WriteData::Object theWriteData, const Standard_GUID& theGUID)
|
||||
{
|
||||
const Standard_UUID anUUID = theGUID.ToUUID();
|
||||
|
||||
Standard_Integer a32b;
|
||||
Standard_ExtCharacter a16b[3];
|
||||
Standard_Character a8b [6];
|
||||
|
||||
// see Standard_GUID::Standard_GUID(const Standard_UUID& aWntGuid)
|
||||
a32b = anUUID.Data1;
|
||||
a16b[0] = anUUID.Data2;
|
||||
a16b[1] = anUUID.Data3;
|
||||
a16b[2] = (anUUID.Data4[0] << 8) | (anUUID.Data4[1]);
|
||||
a8b[0] = anUUID.Data4[2];
|
||||
a8b[1] = anUUID.Data4[3];
|
||||
a8b[2] = anUUID.Data4[4];
|
||||
a8b[3] = anUUID.Data4[5];
|
||||
a8b[4] = anUUID.Data4[6];
|
||||
a8b[5] = anUUID.Data4[7];
|
||||
|
||||
theWriteData << a32b << a16b[0] << a16b[1] << a16b[2];
|
||||
theWriteData << a8b[0] << a8b[1] << a8b[2] << a8b[3] << a8b[4] << a8b[5];
|
||||
|
||||
return theWriteData;
|
||||
}
|
101
src/StdObjMgt/StdObjMgt_WriteData.hxx
Normal file
101
src/StdObjMgt/StdObjMgt_WriteData.hxx
Normal file
@@ -0,0 +1,101 @@
|
||||
// Copyright (c) 2017 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _StdObjMgt_WriteData_HeaderFile
|
||||
#define _StdObjMgt_WriteData_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Storage_BaseDriver.hxx>
|
||||
|
||||
class StdObjMgt_Persistent;
|
||||
class Standard_GUID;
|
||||
|
||||
//! Auxiliary data used to write persistent objects to a file.
|
||||
class StdObjMgt_WriteData
|
||||
{
|
||||
public:
|
||||
|
||||
class Object;
|
||||
|
||||
Standard_EXPORT StdObjMgt_WriteData
|
||||
(Storage_BaseDriver& theDriver);
|
||||
|
||||
Standard_EXPORT void WritePersistentObject
|
||||
(const Handle(StdObjMgt_Persistent)& thePersistent);
|
||||
|
||||
template <class Persistent>
|
||||
StdObjMgt_WriteData& operator << (const Handle(Persistent)& thePersistent)
|
||||
{
|
||||
*myDriver << (thePersistent ? thePersistent->RefNum() : 0);
|
||||
return *this;
|
||||
}
|
||||
|
||||
Standard_EXPORT StdObjMgt_WriteData& operator << (const Handle(StdObjMgt_Persistent)& thePersistent);
|
||||
|
||||
template <class Type>
|
||||
StdObjMgt_WriteData& WriteValue(const Type& theValue)
|
||||
{
|
||||
*myDriver << theValue;
|
||||
return *this;
|
||||
}
|
||||
|
||||
StdObjMgt_WriteData& operator << (const Standard_Character& theValue)
|
||||
{ return WriteValue(theValue); }
|
||||
|
||||
StdObjMgt_WriteData& operator << (const Standard_ExtCharacter& theValue)
|
||||
{ return WriteValue(theValue); }
|
||||
|
||||
StdObjMgt_WriteData& operator << (const Standard_Integer& theValue)
|
||||
{ return WriteValue(theValue); }
|
||||
|
||||
StdObjMgt_WriteData& operator << (const Standard_Boolean& theValue)
|
||||
{ return WriteValue(theValue); }
|
||||
|
||||
StdObjMgt_WriteData& operator << (const Standard_Real& theValue)
|
||||
{ return WriteValue(theValue); }
|
||||
|
||||
StdObjMgt_WriteData& operator << (const Standard_ShortReal& theValue)
|
||||
{ return WriteValue(theValue); }
|
||||
|
||||
private:
|
||||
Storage_BaseDriver* myDriver;
|
||||
};
|
||||
|
||||
class StdObjMgt_WriteData::Object
|
||||
{
|
||||
public:
|
||||
Object (StdObjMgt_WriteData& theData) : myWriteData(&theData)
|
||||
{ myWriteData->myDriver->BeginWriteObjectData(); }
|
||||
Object (const StdObjMgt_WriteData::Object& theOther) : myWriteData(theOther.myWriteData)
|
||||
{ myWriteData->myDriver->BeginWriteObjectData(); }
|
||||
|
||||
~Object()
|
||||
{ myWriteData->myDriver->EndWriteObjectData(); }
|
||||
|
||||
operator StdObjMgt_WriteData& ()
|
||||
{ return *myWriteData; }
|
||||
|
||||
template <class Data>
|
||||
StdObjMgt_WriteData& operator << (Data& theData)
|
||||
{ return *myWriteData << theData; }
|
||||
|
||||
private:
|
||||
StdObjMgt_WriteData* myWriteData;
|
||||
|
||||
StdObjMgt_WriteData::Object& operator = (const StdObjMgt_WriteData::Object&);
|
||||
};
|
||||
|
||||
Standard_EXPORT StdObjMgt_WriteData& operator <<
|
||||
(StdObjMgt_WriteData::Object theWriteData, const Standard_GUID& theGUID);
|
||||
|
||||
#endif // _StdObjMgt_WriteData_HeaderFile
|
@@ -14,6 +14,28 @@
|
||||
#include <StdObject_Location.hxx>
|
||||
#include <StdPersistent_TopLoc.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : Translate
|
||||
//purpose : Creates a persistent wrapper object for a location
|
||||
//=======================================================================
|
||||
StdObject_Location
|
||||
StdObject_Location::Translate (const TopLoc_Location& theLoc,
|
||||
StdObjMgt_TransientPersistentMap& theMap)
|
||||
{
|
||||
StdObject_Location aLoc;
|
||||
if (!theLoc.IsIdentity())
|
||||
aLoc.myData = StdPersistent_TopLoc::Translate(theLoc, theMap);
|
||||
return aLoc;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Location
|
||||
//purpose : Changes current location
|
||||
//=======================================================================
|
||||
void StdObject_Location::PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
|
||||
{
|
||||
theChildren.Append(myData);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Import
|
||||
|
@@ -16,21 +16,33 @@
|
||||
#define _StdObject_Location_HeaderFile
|
||||
|
||||
#include <StdObjMgt_ReadData.hxx>
|
||||
#include <StdObjMgt_WriteData.hxx>
|
||||
#include <StdObjMgt_Persistent.hxx>
|
||||
#include <StdObjMgt_TransientPersistentMap.hxx>
|
||||
|
||||
#include <TopLoc_Location.hxx>
|
||||
|
||||
|
||||
class StdObject_Location
|
||||
{
|
||||
public:
|
||||
|
||||
//! Gets persistent child objects
|
||||
Standard_EXPORT void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
|
||||
|
||||
//! Import transient object from the persistent data.
|
||||
TopLoc_Location Import() const;
|
||||
|
||||
//! Creates a persistent wrapper object for a location
|
||||
Standard_EXPORT static StdObject_Location Translate (const TopLoc_Location& theLoc,
|
||||
StdObjMgt_TransientPersistentMap& theMap);
|
||||
|
||||
private:
|
||||
Handle(StdObjMgt_Persistent) myData;
|
||||
|
||||
friend StdObjMgt_ReadData& operator >>
|
||||
(StdObjMgt_ReadData::Object, StdObject_Location&);
|
||||
friend StdObjMgt_WriteData& operator <<
|
||||
(StdObjMgt_WriteData::Object, const StdObject_Location&);
|
||||
};
|
||||
|
||||
//! Read persistent data from a file.
|
||||
@@ -40,4 +52,11 @@ inline StdObjMgt_ReadData& operator >>
|
||||
return theReadData >> theLocation.myData;
|
||||
}
|
||||
|
||||
//! Write persistent data to a file.
|
||||
inline StdObjMgt_WriteData& operator <<
|
||||
(StdObjMgt_WriteData::Object theWriteData, const StdObject_Location& theLocation)
|
||||
{
|
||||
return theWriteData << theLocation.myData;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -31,3 +31,13 @@ TopoDS_Shape StdObject_Shape::Import() const
|
||||
|
||||
return aShape;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : PChildren
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void StdObject_Shape::PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
|
||||
{
|
||||
theChildren.Append(myTShape);
|
||||
myLocation.PChildren(theChildren);
|
||||
}
|
@@ -16,6 +16,7 @@
|
||||
#define _StdObject_Shape_HeaderFile
|
||||
|
||||
#include <StdObjMgt_ReadData.hxx>
|
||||
#include <StdObjMgt_WriteData.hxx>
|
||||
#include <StdObject_Location.hxx>
|
||||
#include <StdPersistent_TopoDS.hxx>
|
||||
|
||||
@@ -24,22 +25,32 @@
|
||||
|
||||
class StdObject_Shape
|
||||
{
|
||||
friend class ShapePersistent_TopoDS;
|
||||
|
||||
public:
|
||||
//! Import transient object from the persistent data.
|
||||
Standard_EXPORT TopoDS_Shape Import() const;
|
||||
|
||||
Standard_EXPORT void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
|
||||
|
||||
protected:
|
||||
//! Read persistent data from a file.
|
||||
inline void read (StdObjMgt_ReadData& theReadData)
|
||||
{ theReadData >> myTShape >> myLocation >> myOrient; }
|
||||
|
||||
private:
|
||||
//! Write persistent data to a file.
|
||||
inline void write (StdObjMgt_WriteData& theWriteData) const
|
||||
{ theWriteData << myTShape << myLocation << myOrient; }
|
||||
|
||||
protected:
|
||||
Handle(StdPersistent_TopoDS::TShape) myTShape;
|
||||
StdObject_Location myLocation;
|
||||
Standard_Integer myOrient;
|
||||
|
||||
friend StdObjMgt_ReadData& operator >>
|
||||
(StdObjMgt_ReadData::Object, StdObject_Shape&);
|
||||
friend StdObjMgt_WriteData& operator <<
|
||||
(StdObjMgt_WriteData::Object, const StdObject_Shape&);
|
||||
};
|
||||
|
||||
//! Read persistent data from a file.
|
||||
@@ -50,4 +61,12 @@ inline StdObjMgt_ReadData& operator >>
|
||||
return theReadData;
|
||||
}
|
||||
|
||||
//! Write persistent data to a file.
|
||||
inline StdObjMgt_WriteData& operator <<
|
||||
(StdObjMgt_WriteData::Object theWriteData, const StdObject_Shape& theShape)
|
||||
{
|
||||
theShape.write (theWriteData);
|
||||
return theWriteData;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -35,6 +35,24 @@ inline StdObjMgt_ReadData& operator >>
|
||||
return theReadData;
|
||||
}
|
||||
|
||||
inline StdObjMgt_WriteData&
|
||||
write (StdObjMgt_WriteData::Object theWriteData, const gp_Ax2d& theAx)
|
||||
{
|
||||
const gp_Pnt2d& aLoc = theAx.Location();
|
||||
const gp_Dir2d& aDir = theAx.Direction();
|
||||
theWriteData << aLoc << aDir;
|
||||
return theWriteData;
|
||||
}
|
||||
|
||||
inline StdObjMgt_WriteData& operator <<
|
||||
(StdObjMgt_WriteData::Object theWriteData, const gp_Ax2d& theAx)
|
||||
{
|
||||
const gp_Pnt2d& aLoc = theAx.Location();
|
||||
const gp_Dir2d& aDir = theAx.Direction();
|
||||
theWriteData << aLoc << aDir;
|
||||
return theWriteData;
|
||||
}
|
||||
|
||||
inline StdObjMgt_ReadData& operator >>
|
||||
(StdObjMgt_ReadData::Object theReadData, gp_Ax22d& theAx)
|
||||
{
|
||||
@@ -45,16 +63,44 @@ inline StdObjMgt_ReadData& operator >>
|
||||
return theReadData;
|
||||
}
|
||||
|
||||
inline StdObjMgt_WriteData& operator <<
|
||||
(StdObjMgt_WriteData::Object theWriteData, const gp_Ax22d& theAx)
|
||||
{
|
||||
const gp_Pnt2d& aLoc = theAx.Location();
|
||||
const gp_Dir2d& aYDir = theAx.YDirection();
|
||||
const gp_Dir2d& aXDir = theAx.XDirection();
|
||||
theWriteData << aLoc << aYDir << aXDir;
|
||||
return theWriteData;
|
||||
}
|
||||
|
||||
inline StdObjMgt_ReadData& operator >>
|
||||
(StdObjMgt_ReadData::Object theReadData, gp_Ax1& theAx)
|
||||
{
|
||||
gp_XYZ aLoc;
|
||||
gp_Pnt aLoc;
|
||||
gp_Dir aDir;
|
||||
theReadData >> aLoc >> aDir;
|
||||
theAx = gp_Ax1 (aLoc, aDir);
|
||||
return theReadData;
|
||||
}
|
||||
|
||||
inline StdObjMgt_WriteData&
|
||||
write(StdObjMgt_WriteData::Object theWriteData, const gp_Ax1& theAx)
|
||||
{
|
||||
const gp_Pnt& aLoc = theAx.Location();
|
||||
const gp_Dir& aDir = theAx.Direction();
|
||||
theWriteData << aLoc << aDir;
|
||||
return theWriteData;
|
||||
}
|
||||
|
||||
inline StdObjMgt_WriteData& operator <<
|
||||
(StdObjMgt_WriteData::Object theWriteData, const gp_Ax1& theAx)
|
||||
{
|
||||
const gp_Pnt& aLoc = theAx.Location();
|
||||
const gp_Dir& aDir = theAx.Direction();
|
||||
theWriteData << aLoc << aDir;
|
||||
return theWriteData;
|
||||
}
|
||||
|
||||
inline StdObjMgt_ReadData& operator >>
|
||||
(StdObjMgt_ReadData::Object theReadData, gp_Ax2& theAx)
|
||||
{
|
||||
@@ -65,6 +111,16 @@ inline StdObjMgt_ReadData& operator >>
|
||||
return theReadData;
|
||||
}
|
||||
|
||||
inline StdObjMgt_WriteData& operator <<
|
||||
(StdObjMgt_WriteData::Object theWriteData, const gp_Ax2& theAx)
|
||||
{
|
||||
const gp_Ax1& anAx = theAx.Axis();
|
||||
const gp_Dir& aYDir = theAx.YDirection();
|
||||
const gp_Dir& aXDir = theAx.XDirection();
|
||||
theWriteData << anAx << aYDir << aXDir;
|
||||
return theWriteData;
|
||||
}
|
||||
|
||||
inline StdObjMgt_ReadData& operator >>
|
||||
(StdObjMgt_ReadData::Object theReadData, gp_Ax3& theAx)
|
||||
{
|
||||
@@ -77,5 +133,15 @@ inline StdObjMgt_ReadData& operator >>
|
||||
return theReadData;
|
||||
}
|
||||
|
||||
inline StdObjMgt_WriteData& operator <<
|
||||
(StdObjMgt_WriteData::Object theWriteData, const gp_Ax3& theAx)
|
||||
{
|
||||
const gp_Ax1& anAx = theAx.Axis();
|
||||
const gp_Dir& aYDir = theAx.YDirection();
|
||||
const gp_Dir& aXDir = theAx.XDirection();
|
||||
theWriteData << anAx << aYDir << aXDir;
|
||||
return theWriteData;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
@@ -31,7 +31,7 @@
|
||||
|
||||
|
||||
inline StdObjMgt_ReadData& operator >>
|
||||
(StdObjMgt_ReadData::Object theReadData, gp_Lin2d& theLin)
|
||||
(StdObjMgt_ReadData& theReadData, gp_Lin2d& theLin)
|
||||
{
|
||||
gp_Ax2d anAx;
|
||||
theReadData >> anAx;
|
||||
@@ -39,8 +39,16 @@ inline StdObjMgt_ReadData& operator >>
|
||||
return theReadData;
|
||||
}
|
||||
|
||||
inline StdObjMgt_WriteData& operator <<
|
||||
(StdObjMgt_WriteData& theWriteData, const gp_Lin2d& theLin)
|
||||
{
|
||||
const gp_Ax2d& anAx = theLin.Position();
|
||||
write (theWriteData, anAx);
|
||||
return theWriteData;
|
||||
}
|
||||
|
||||
inline StdObjMgt_ReadData& operator >>
|
||||
(StdObjMgt_ReadData::Object theReadData, gp_Circ2d& theCirc)
|
||||
(StdObjMgt_ReadData& theReadData, gp_Circ2d& theCirc)
|
||||
{
|
||||
gp_Ax22d anAx;
|
||||
Standard_Real aRadius;
|
||||
@@ -53,8 +61,17 @@ inline StdObjMgt_ReadData& operator >>
|
||||
return theReadData;
|
||||
}
|
||||
|
||||
inline StdObjMgt_WriteData& operator <<
|
||||
(StdObjMgt_WriteData& theWriteData, const gp_Circ2d& theCirc)
|
||||
{
|
||||
const gp_Ax22d& anAx = theCirc.Position();
|
||||
Standard_Real aRadius = theCirc.Radius();
|
||||
theWriteData << anAx << aRadius;
|
||||
return theWriteData;
|
||||
}
|
||||
|
||||
inline StdObjMgt_ReadData& operator >>
|
||||
(StdObjMgt_ReadData::Object theReadData, gp_Elips2d& theElips)
|
||||
(StdObjMgt_ReadData& theReadData, gp_Elips2d& theElips)
|
||||
{
|
||||
gp_Ax22d anAx;
|
||||
Standard_Real aMajorRadius, aMinorRadius;
|
||||
@@ -68,8 +85,18 @@ inline StdObjMgt_ReadData& operator >>
|
||||
return theReadData;
|
||||
}
|
||||
|
||||
inline StdObjMgt_WriteData& operator <<
|
||||
(StdObjMgt_WriteData& theWriteData, const gp_Elips2d& theElips)
|
||||
{
|
||||
const gp_Ax22d& anAx = theElips.Axis();
|
||||
Standard_Real aMajorRadius = theElips.MajorRadius();
|
||||
Standard_Real aMinorRadius = theElips.MinorRadius();
|
||||
theWriteData << anAx << aMajorRadius << aMinorRadius;
|
||||
return theWriteData;
|
||||
}
|
||||
|
||||
inline StdObjMgt_ReadData& operator >>
|
||||
(StdObjMgt_ReadData::Object theReadData, gp_Hypr2d& theHypr)
|
||||
(StdObjMgt_ReadData& theReadData, gp_Hypr2d& theHypr)
|
||||
{
|
||||
gp_Ax22d anAx;
|
||||
Standard_Real aMajorRadius, aMinorRadius;
|
||||
@@ -83,8 +110,18 @@ inline StdObjMgt_ReadData& operator >>
|
||||
return theReadData;
|
||||
}
|
||||
|
||||
inline StdObjMgt_WriteData& operator <<
|
||||
(StdObjMgt_WriteData& theWriteData, const gp_Hypr2d& theHypr)
|
||||
{
|
||||
const gp_Ax22d& anAx = theHypr.Axis();
|
||||
Standard_Real aMajorRadius = theHypr.MajorRadius();
|
||||
Standard_Real aMinorRadius = theHypr.MinorRadius();
|
||||
theWriteData << anAx << aMajorRadius << aMinorRadius;
|
||||
return theWriteData;
|
||||
}
|
||||
|
||||
inline StdObjMgt_ReadData& operator >>
|
||||
(StdObjMgt_ReadData::Object theReadData, gp_Parab2d& theParab)
|
||||
(StdObjMgt_ReadData& theReadData, gp_Parab2d& theParab)
|
||||
{
|
||||
gp_Ax22d anAx;
|
||||
Standard_Real aFocalLength;
|
||||
@@ -97,8 +134,17 @@ inline StdObjMgt_ReadData& operator >>
|
||||
return theReadData;
|
||||
}
|
||||
|
||||
inline StdObjMgt_WriteData& operator <<
|
||||
(StdObjMgt_WriteData& theWriteData, const gp_Parab2d& theParab)
|
||||
{
|
||||
const gp_Ax22d& anAx = theParab.Axis();
|
||||
Standard_Real aFocalLength = theParab.Focal();
|
||||
theWriteData << anAx << aFocalLength;
|
||||
return theWriteData;
|
||||
}
|
||||
|
||||
inline StdObjMgt_ReadData& operator >>
|
||||
(StdObjMgt_ReadData::Object theReadData, gp_Lin& theLin)
|
||||
(StdObjMgt_ReadData& theReadData, gp_Lin& theLin)
|
||||
{
|
||||
gp_Ax1 anAx;
|
||||
theReadData >> anAx;
|
||||
@@ -106,8 +152,16 @@ inline StdObjMgt_ReadData& operator >>
|
||||
return theReadData;
|
||||
}
|
||||
|
||||
inline StdObjMgt_WriteData& operator <<
|
||||
(StdObjMgt_WriteData& theWriteData, const gp_Lin& theLin)
|
||||
{
|
||||
const gp_Ax1& anAx = theLin.Position();
|
||||
write (theWriteData, anAx);
|
||||
return theWriteData;
|
||||
}
|
||||
|
||||
inline StdObjMgt_ReadData& operator >>
|
||||
(StdObjMgt_ReadData::Object theReadData, gp_Circ& theCirc)
|
||||
(StdObjMgt_ReadData& theReadData, gp_Circ& theCirc)
|
||||
{
|
||||
gp_Ax2 anAx;
|
||||
Standard_Real aRadius;
|
||||
@@ -120,8 +174,17 @@ inline StdObjMgt_ReadData& operator >>
|
||||
return theReadData;
|
||||
}
|
||||
|
||||
inline StdObjMgt_WriteData& operator <<
|
||||
(StdObjMgt_WriteData& theWriteData, const gp_Circ& theCirc)
|
||||
{
|
||||
const gp_Ax2& anAx = theCirc.Position();
|
||||
Standard_Real aRadius = theCirc.Radius();
|
||||
theWriteData << anAx << aRadius;
|
||||
return theWriteData;
|
||||
}
|
||||
|
||||
inline StdObjMgt_ReadData& operator >>
|
||||
(StdObjMgt_ReadData::Object theReadData, gp_Elips& theElips)
|
||||
(StdObjMgt_ReadData& theReadData, gp_Elips& theElips)
|
||||
{
|
||||
gp_Ax2 anAx;
|
||||
Standard_Real aMajorRadius, aMinorRadius;
|
||||
@@ -135,8 +198,18 @@ inline StdObjMgt_ReadData& operator >>
|
||||
return theReadData;
|
||||
}
|
||||
|
||||
inline StdObjMgt_WriteData& operator <<
|
||||
(StdObjMgt_WriteData& theWriteData, const gp_Elips& theElips)
|
||||
{
|
||||
const gp_Ax2& anAx = theElips.Position();
|
||||
Standard_Real aMajorRadius = theElips.MajorRadius();
|
||||
Standard_Real aMinorRadius = theElips.MinorRadius();
|
||||
theWriteData << anAx << aMajorRadius << aMinorRadius;
|
||||
return theWriteData;
|
||||
}
|
||||
|
||||
inline StdObjMgt_ReadData& operator >>
|
||||
(StdObjMgt_ReadData::Object theReadData, gp_Hypr& theHypr)
|
||||
(StdObjMgt_ReadData& theReadData, gp_Hypr& theHypr)
|
||||
{
|
||||
gp_Ax2 anAx;
|
||||
Standard_Real aMajorRadius, aMinorRadius;
|
||||
@@ -150,8 +223,18 @@ inline StdObjMgt_ReadData& operator >>
|
||||
return theReadData;
|
||||
}
|
||||
|
||||
inline StdObjMgt_WriteData& operator <<
|
||||
(StdObjMgt_WriteData& theWriteData, const gp_Hypr& theHypr)
|
||||
{
|
||||
const gp_Ax2& anAx = theHypr.Position();
|
||||
Standard_Real aMajorRadius = theHypr.MajorRadius();
|
||||
Standard_Real aMinorRadius = theHypr.MinorRadius();
|
||||
theWriteData << anAx << aMajorRadius << aMinorRadius;
|
||||
return theWriteData;
|
||||
}
|
||||
|
||||
inline StdObjMgt_ReadData& operator >>
|
||||
(StdObjMgt_ReadData::Object theReadData, gp_Parab& theParab)
|
||||
(StdObjMgt_ReadData& theReadData, gp_Parab& theParab)
|
||||
{
|
||||
gp_Ax2 anAx;
|
||||
Standard_Real aFocalLength;
|
||||
@@ -164,5 +247,14 @@ inline StdObjMgt_ReadData& operator >>
|
||||
return theReadData;
|
||||
}
|
||||
|
||||
inline StdObjMgt_WriteData& operator <<
|
||||
(StdObjMgt_WriteData& theWriteData, const gp_Parab& theParab)
|
||||
{
|
||||
const gp_Ax2& anAx = theParab.Position();
|
||||
Standard_Real aFocalLength = theParab.Focal();
|
||||
theWriteData << anAx << aFocalLength;
|
||||
return theWriteData;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
@@ -25,7 +25,7 @@
|
||||
|
||||
|
||||
inline StdObjMgt_ReadData& operator >>
|
||||
(StdObjMgt_ReadData::Object theReadData, gp_Cone& theCone)
|
||||
(StdObjMgt_ReadData& theReadData, gp_Cone& theCone)
|
||||
{
|
||||
gp_Ax3 anAx;
|
||||
Standard_Real aRadius, aSemiAngle;
|
||||
@@ -39,8 +39,18 @@ inline StdObjMgt_ReadData& operator >>
|
||||
return theReadData;
|
||||
}
|
||||
|
||||
inline StdObjMgt_WriteData& operator <<
|
||||
(StdObjMgt_WriteData& theWriteData, const gp_Cone& theCone)
|
||||
{
|
||||
const gp_Ax3& anAx = theCone.Position();
|
||||
Standard_Real aRadius = theCone.RefRadius();
|
||||
Standard_Real aSemiAngle = theCone.SemiAngle();
|
||||
theWriteData << anAx << aRadius << aSemiAngle;
|
||||
return theWriteData;
|
||||
}
|
||||
|
||||
inline StdObjMgt_ReadData& operator >>
|
||||
(StdObjMgt_ReadData::Object theReadData, gp_Cylinder& theCyl)
|
||||
(StdObjMgt_ReadData& theReadData, gp_Cylinder& theCyl)
|
||||
{
|
||||
gp_Ax3 anAx;
|
||||
Standard_Real aRadius;
|
||||
@@ -53,8 +63,17 @@ inline StdObjMgt_ReadData& operator >>
|
||||
return theReadData;
|
||||
}
|
||||
|
||||
inline StdObjMgt_WriteData& operator <<
|
||||
(StdObjMgt_WriteData& theWriteData, const gp_Cylinder& theCyl)
|
||||
{
|
||||
const gp_Ax3& anAx = theCyl.Position();
|
||||
Standard_Real aRadius = theCyl.Radius();
|
||||
theWriteData << anAx << aRadius;
|
||||
return theWriteData;
|
||||
}
|
||||
|
||||
inline StdObjMgt_ReadData& operator >>
|
||||
(StdObjMgt_ReadData::Object theReadData, gp_Sphere& theSph)
|
||||
(StdObjMgt_ReadData& theReadData, gp_Sphere& theSph)
|
||||
{
|
||||
gp_Ax3 anAx;
|
||||
Standard_Real aRadius;
|
||||
@@ -67,8 +86,17 @@ inline StdObjMgt_ReadData& operator >>
|
||||
return theReadData;
|
||||
}
|
||||
|
||||
inline StdObjMgt_WriteData& operator <<
|
||||
(StdObjMgt_WriteData& theWriteData, const gp_Sphere& theSph)
|
||||
{
|
||||
const gp_Ax3& anAx = theSph.Position();
|
||||
Standard_Real aRadius = theSph.Radius();
|
||||
theWriteData << anAx << aRadius;
|
||||
return theWriteData;
|
||||
}
|
||||
|
||||
inline StdObjMgt_ReadData& operator >>
|
||||
(StdObjMgt_ReadData::Object theReadData, gp_Torus& theTorus)
|
||||
(StdObjMgt_ReadData& theReadData, gp_Torus& theTorus)
|
||||
{
|
||||
gp_Ax3 anAx;
|
||||
Standard_Real aMajorRadius, aMinorRadius;
|
||||
@@ -82,5 +110,15 @@ inline StdObjMgt_ReadData& operator >>
|
||||
return theReadData;
|
||||
}
|
||||
|
||||
inline StdObjMgt_WriteData& operator <<
|
||||
(StdObjMgt_WriteData& theWriteData, const gp_Torus& theTorus)
|
||||
{
|
||||
const gp_Ax3& anAx = theTorus.Position();
|
||||
Standard_Real aMajorRadius = theTorus.MajorRadius();
|
||||
Standard_Real aMinorRadius = theTorus.MinorRadius();
|
||||
theWriteData << anAx << aMajorRadius << aMinorRadius;
|
||||
return theWriteData;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
@@ -27,21 +27,41 @@
|
||||
inline StdObjMgt_ReadData& operator >>
|
||||
(StdObjMgt_ReadData::Object theReadData, gp_Mat2d& theMat)
|
||||
{
|
||||
gp_XY aRow1, aRow2;
|
||||
theReadData >> aRow1 >> aRow2;
|
||||
theMat.SetRows (aRow1, aRow2);
|
||||
theReadData
|
||||
>> theMat(1, 1) >> theMat(1, 2)
|
||||
>> theMat(2, 1) >> theMat(2, 2);
|
||||
return theReadData;
|
||||
}
|
||||
|
||||
inline StdObjMgt_WriteData& operator <<
|
||||
(StdObjMgt_WriteData::Object theWriteData, const gp_Mat2d& theMat)
|
||||
{
|
||||
theWriteData
|
||||
<< theMat(1, 1) << theMat(1, 2)
|
||||
<< theMat(2, 1) << theMat(2, 2);
|
||||
return theWriteData;
|
||||
}
|
||||
|
||||
inline StdObjMgt_ReadData& operator >>
|
||||
(StdObjMgt_ReadData::Object theReadData, gp_Mat& theMat)
|
||||
{
|
||||
gp_XYZ aRow1, aRow2, aRow3;
|
||||
theReadData >> aRow1 >> aRow2 >> aRow3;
|
||||
theMat.SetRows (aRow1, aRow2, aRow3);
|
||||
theReadData
|
||||
>> theMat(1, 1) >> theMat(1, 2) >> theMat(1, 3)
|
||||
>> theMat(2, 1) >> theMat(2, 2) >> theMat(2, 3)
|
||||
>> theMat(3, 1) >> theMat(3, 2) >> theMat(3, 3);
|
||||
return theReadData;
|
||||
}
|
||||
|
||||
inline StdObjMgt_WriteData& operator <<
|
||||
(StdObjMgt_WriteData::Object theWriteData, const gp_Mat& theMat)
|
||||
{
|
||||
theWriteData
|
||||
<< theMat(1, 1) << theMat(1, 2) << theMat(1, 3)
|
||||
<< theMat(2, 1) << theMat(2, 2) << theMat(2, 3)
|
||||
<< theMat(3, 1) << theMat(3, 2) << theMat(3, 3);
|
||||
return theWriteData;
|
||||
}
|
||||
|
||||
inline StdObjMgt_ReadData& operator >>
|
||||
(StdObjMgt_ReadData::Object theReadData, gp_Trsf2d& theTrsf)
|
||||
{
|
||||
@@ -58,6 +78,19 @@ inline StdObjMgt_ReadData& operator >>
|
||||
return theReadData;
|
||||
}
|
||||
|
||||
inline StdObjMgt_WriteData& operator <<
|
||||
(StdObjMgt_WriteData::Object theWriteData, const gp_Trsf2d& theTrsf)
|
||||
{
|
||||
Standard_Real aScale = theTrsf.ScaleFactor();
|
||||
Standard_Integer aForm = theTrsf.Form();
|
||||
const gp_Mat2d& aMat = theTrsf.HVectorialPart();
|
||||
const gp_XY& aLoc = theTrsf.TranslationPart();
|
||||
|
||||
theWriteData << aScale << aForm << aMat << aLoc;
|
||||
|
||||
return theWriteData;
|
||||
}
|
||||
|
||||
inline StdObjMgt_ReadData& operator >>
|
||||
(StdObjMgt_ReadData::Object theReadData, gp_Trsf& theTrsf)
|
||||
{
|
||||
@@ -76,5 +109,17 @@ inline StdObjMgt_ReadData& operator >>
|
||||
return theReadData;
|
||||
}
|
||||
|
||||
inline StdObjMgt_WriteData& operator <<
|
||||
(StdObjMgt_WriteData::Object theWriteData, const gp_Trsf& theTrsf)
|
||||
{
|
||||
Standard_Real aScale = theTrsf.ScaleFactor();
|
||||
Standard_Integer aForm = theTrsf.Form();
|
||||
const gp_Mat& aMat = theTrsf.HVectorialPart();
|
||||
const gp_XYZ& aLoc = theTrsf.TranslationPart();
|
||||
|
||||
theWriteData << aScale << aForm << aMat << aLoc;
|
||||
|
||||
return theWriteData;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -17,6 +17,7 @@
|
||||
|
||||
|
||||
#include <StdObjMgt_ReadData.hxx>
|
||||
#include <StdObjMgt_WriteData.hxx>
|
||||
|
||||
#include <gp_Pnt2d.hxx>
|
||||
#include <gp_Vec2d.hxx>
|
||||
@@ -35,68 +36,126 @@ inline StdObjMgt_ReadData& operator >>
|
||||
return theReadData;
|
||||
}
|
||||
|
||||
inline StdObjMgt_WriteData& operator <<
|
||||
(StdObjMgt_WriteData::Object theWriteData, const gp_XY& theXY)
|
||||
{
|
||||
Standard_Real aX = theXY.X(), aY = theXY.Y();
|
||||
theWriteData << aX << aY;
|
||||
return theWriteData;
|
||||
}
|
||||
|
||||
inline StdObjMgt_ReadData& operator >>
|
||||
(StdObjMgt_ReadData::Object theReadData, gp_Pnt2d& thePnt)
|
||||
{
|
||||
Standard_Real aX, aY;
|
||||
theReadData >> aX >> aY;
|
||||
thePnt.SetCoord (aX, aY);
|
||||
gp_XY aXY;
|
||||
theReadData >> aXY;
|
||||
thePnt.SetXY (aXY);
|
||||
return theReadData;
|
||||
}
|
||||
|
||||
inline StdObjMgt_WriteData& operator <<
|
||||
(StdObjMgt_WriteData::Object theWriteData, const gp_Pnt2d& thePnt)
|
||||
{
|
||||
theWriteData << thePnt.XY();
|
||||
return theWriteData;
|
||||
}
|
||||
|
||||
inline StdObjMgt_ReadData& operator >>
|
||||
(StdObjMgt_ReadData::Object theReadData, gp_Vec2d& theVec)
|
||||
{
|
||||
Standard_Real aX, aY;
|
||||
theReadData >> aX >> aY;
|
||||
theVec.SetCoord (aX, aY);
|
||||
gp_XY aXY;
|
||||
theReadData >> aXY;
|
||||
theVec.SetXY (aXY);
|
||||
return theReadData;
|
||||
}
|
||||
|
||||
inline StdObjMgt_WriteData& operator <<
|
||||
(StdObjMgt_WriteData::Object theWriteData, const gp_Vec2d& theVec)
|
||||
{
|
||||
theWriteData << theVec.XY();
|
||||
return theWriteData;
|
||||
}
|
||||
|
||||
inline StdObjMgt_ReadData& operator >>
|
||||
(StdObjMgt_ReadData::Object theReadData, gp_Dir2d& theDir)
|
||||
{
|
||||
Standard_Real aX, aY;
|
||||
theReadData >> aX >> aY;
|
||||
theDir.SetCoord (aX, aY);
|
||||
gp_XY aXY;
|
||||
theReadData >> aXY;
|
||||
theDir.SetXY (aXY);
|
||||
return theReadData;
|
||||
}
|
||||
|
||||
inline StdObjMgt_WriteData& operator <<
|
||||
(StdObjMgt_WriteData::Object theWriteData, const gp_Dir2d& theDir)
|
||||
{
|
||||
theWriteData << theDir.XY();
|
||||
return theWriteData;
|
||||
}
|
||||
|
||||
inline StdObjMgt_ReadData& operator >>
|
||||
(StdObjMgt_ReadData::Object theReadData, gp_XYZ& theXYZ)
|
||||
{
|
||||
Standard_Real aX, aY, aZ;
|
||||
theReadData >> aX >> aY >> aZ;
|
||||
theXYZ.SetCoord (aX, aY, aZ);
|
||||
theXYZ.SetCoord(aX, aY, aZ);
|
||||
return theReadData;
|
||||
}
|
||||
|
||||
inline StdObjMgt_WriteData& operator <<
|
||||
(StdObjMgt_WriteData::Object theWriteData, const gp_XYZ& theXYZ)
|
||||
{
|
||||
Standard_Real aX = theXYZ.X(), aY = theXYZ.Y(), aZ = theXYZ.Z();
|
||||
theWriteData << aX << aY << aZ;
|
||||
return theWriteData;
|
||||
}
|
||||
|
||||
inline StdObjMgt_ReadData& operator >>
|
||||
(StdObjMgt_ReadData::Object theReadData, gp_Pnt& thePnt)
|
||||
{
|
||||
Standard_Real aX, aY, aZ;
|
||||
theReadData >> aX >> aY >> aZ;
|
||||
thePnt.SetCoord (aX, aY, aZ);
|
||||
gp_XYZ aXYZ;
|
||||
theReadData >> aXYZ;
|
||||
thePnt.SetXYZ (aXYZ);
|
||||
return theReadData;
|
||||
}
|
||||
|
||||
inline StdObjMgt_WriteData& operator <<
|
||||
(StdObjMgt_WriteData::Object theWriteData, const gp_Pnt& thePnt)
|
||||
{
|
||||
theWriteData << thePnt.XYZ();
|
||||
return theWriteData;
|
||||
}
|
||||
|
||||
inline StdObjMgt_ReadData& operator >>
|
||||
(StdObjMgt_ReadData::Object theReadData, gp_Vec& theVec)
|
||||
{
|
||||
Standard_Real aX, aY, aZ;
|
||||
theReadData >> aX >> aY >> aZ;
|
||||
theVec.SetCoord (aX, aY, aZ);
|
||||
gp_XYZ aXYZ;
|
||||
theReadData >> aXYZ;
|
||||
theVec.SetXYZ (aXYZ);
|
||||
return theReadData;
|
||||
}
|
||||
|
||||
inline StdObjMgt_WriteData& operator <<
|
||||
(StdObjMgt_WriteData::Object theWriteData, const gp_Vec& theVec)
|
||||
{
|
||||
theWriteData << theVec.XYZ();
|
||||
return theWriteData;
|
||||
}
|
||||
|
||||
inline StdObjMgt_ReadData& operator >>
|
||||
(StdObjMgt_ReadData::Object theReadData, gp_Dir& theDir)
|
||||
{
|
||||
Standard_Real aX, aY, aZ;
|
||||
theReadData >> aX >> aY >> aZ;
|
||||
theDir.SetCoord (aX, aY, aZ);
|
||||
gp_XYZ aXYZ;
|
||||
theReadData >> aXYZ;
|
||||
theDir.SetXYZ(aXYZ);
|
||||
return theReadData;
|
||||
}
|
||||
|
||||
inline StdObjMgt_WriteData& operator <<
|
||||
(StdObjMgt_WriteData::Object theWriteData, const gp_Dir& theDir)
|
||||
{
|
||||
theWriteData << theDir.XYZ();
|
||||
return theWriteData;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
@@ -16,7 +16,6 @@
|
||||
#define _StdPersistent_HeaderFile
|
||||
|
||||
#include <Standard_Macro.hxx>
|
||||
|
||||
class StdObjMgt_MapOfInstantiators;
|
||||
|
||||
class StdPersistent
|
||||
|
@@ -59,4 +59,34 @@ public:
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
inline Standard_CString StdLPersistent_Void::instance<TDataXtd_Shape>::PName() const
|
||||
{ return "PDataXtd_Shape"; }
|
||||
|
||||
template<>
|
||||
inline Standard_CString StdLPersistent_Void::instance<TDataXtd_Point>::PName() const
|
||||
{ return "PDataXtd_Point"; }
|
||||
|
||||
template<>
|
||||
inline Standard_CString StdLPersistent_Void::instance<TDataXtd_Axis>::PName() const
|
||||
{ return "PDataXtd_Axis"; }
|
||||
|
||||
template<>
|
||||
inline Standard_CString StdLPersistent_Void::instance<TDataXtd_Plane>::PName() const
|
||||
{ return "PDataXtd_Plane"; }
|
||||
|
||||
template<>
|
||||
inline Standard_CString StdLPersistent_Void::instance<TDataXtd_Placement>::PName() const
|
||||
{ return "PDataXtd_Placement"; }
|
||||
|
||||
template<>
|
||||
template<>
|
||||
inline Standard_CString StdObjMgt_Attribute<TDataXtd_Geometry>::Simple<Standard_Integer>::PName() const
|
||||
{ return "PDataXtd_Geometry"; }
|
||||
|
||||
template<>
|
||||
template<>
|
||||
inline Standard_CString StdObjMgt_Attribute<TDataXtd_Position>::Simple<gp_Pnt>::PName() const
|
||||
{ return "PDataXtd_Position"; }
|
||||
|
||||
#endif
|
||||
|
@@ -31,6 +31,21 @@ public:
|
||||
theReadData >> myType >> myGeometries >> myValue
|
||||
>> myIsReversed >> myIsInverted >> myIsVerified >> myPlane;
|
||||
}
|
||||
//! Write persistent data to a file.
|
||||
inline void Write (StdObjMgt_WriteData& theWriteData) const
|
||||
{
|
||||
theWriteData << myType << myGeometries << myValue
|
||||
<< myIsReversed << myIsInverted << myIsVerified << myPlane;
|
||||
}
|
||||
//! Gets persistent child objects
|
||||
inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
|
||||
{
|
||||
theChildren.Append(myGeometries);
|
||||
theChildren.Append(myValue);
|
||||
theChildren.Append(myPlane);
|
||||
}
|
||||
//! Returns persistent type name
|
||||
inline Standard_CString PName() const { return "PDataXtd_Constraint"; }
|
||||
|
||||
//! Import transient attribuite from the persistent data.
|
||||
void Import (const Handle(TDataXtd_Constraint)& theAttribute) const;
|
||||
|
@@ -30,6 +30,25 @@ public:
|
||||
theReadData >> mySignature >> myAxis1Reversed >> myAxis2Reversed >>
|
||||
myAxis1 >> myAxis2 >> myValue1 >> myValue2 >> myNb1 >> myNb2 >> myMirror;
|
||||
}
|
||||
//! Write persistent data to a file.
|
||||
inline void Write(StdObjMgt_WriteData& theWriteData)
|
||||
{
|
||||
theWriteData << mySignature << myAxis1Reversed << myAxis2Reversed <<
|
||||
myAxis1 << myAxis2 << myValue1 << myValue2 << myNb1 << myNb2 << myMirror;
|
||||
}
|
||||
//! Gets persistent child objects
|
||||
inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
|
||||
{
|
||||
theChildren.Append(myAxis1);
|
||||
theChildren.Append(myAxis2);
|
||||
theChildren.Append(myValue1);
|
||||
theChildren.Append(myValue2);
|
||||
theChildren.Append(myNb1);
|
||||
theChildren.Append(myNb2);
|
||||
theChildren.Append(myMirror);
|
||||
}
|
||||
//! Returns persistent type name
|
||||
inline Standard_CString PName() const { return "PDataXtd_PatternStd"; }
|
||||
|
||||
//! Import transient attribuite from the persistent data.
|
||||
void Import (const Handle(TDataXtd_PatternStd)& theAttribute) const;
|
||||
|
@@ -61,6 +61,15 @@ void StdPersistent_Naming::Name::Read (StdObjMgt_ReadData& theReadData)
|
||||
theReadData >> myType >> myShapeType >> myArgs >> myStop >> myIndex;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Write
|
||||
//purpose : Write persistent data to a file
|
||||
//=======================================================================
|
||||
void StdPersistent_Naming::Name::Write (StdObjMgt_WriteData& theWriteData) const
|
||||
{
|
||||
theWriteData << myType << myShapeType << myArgs << myStop << myIndex;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Import
|
||||
//purpose : Import transient object from the persistent data
|
||||
@@ -104,6 +113,16 @@ void StdPersistent_Naming::Name_1::Read (StdObjMgt_ReadData& theReadData)
|
||||
theReadData >> myContextLabel;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Write
|
||||
//purpose : Write persistent data to a file
|
||||
//=======================================================================
|
||||
void StdPersistent_Naming::Name_1::Write (StdObjMgt_WriteData& theWriteData) const
|
||||
{
|
||||
Name::Write (theWriteData);
|
||||
theWriteData << myContextLabel;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Import
|
||||
//purpose : Import transient object from the persistent data
|
||||
@@ -126,6 +145,16 @@ void StdPersistent_Naming::Name_2::Read (StdObjMgt_ReadData& theReadData)
|
||||
theReadData >> myOrientation;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Write
|
||||
//purpose : Write persistent data to a file
|
||||
//=======================================================================
|
||||
void StdPersistent_Naming::Name_2::Write (StdObjMgt_WriteData& theWriteData) const
|
||||
{
|
||||
Name_1::Write (theWriteData);
|
||||
theWriteData << myOrientation;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Import
|
||||
//purpose : Import transient object from the persistent data
|
||||
|
@@ -35,7 +35,18 @@ public:
|
||||
public:
|
||||
//! Read persistent data from a file.
|
||||
inline void Read (StdObjMgt_ReadData& theReadData)
|
||||
{ theReadData >> myOldShapes >> myNewShapes >> myShapeStatus >> myVersion; }
|
||||
{ theReadData >> myOldShapes >> myNewShapes >> myShapeStatus >> myVersion; }
|
||||
//! Read persistent data from a file.
|
||||
inline void Write (StdObjMgt_WriteData& theWriteData) const
|
||||
{ theWriteData << myOldShapes << myNewShapes << myShapeStatus << myVersion; }
|
||||
//! Gets persistent child objects
|
||||
inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
|
||||
{
|
||||
if (!myOldShapes.IsNull()) theChildren.Append(myOldShapes);
|
||||
if (!myNewShapes.IsNull()) theChildren.Append(myNewShapes);
|
||||
}
|
||||
//! Returns persistent type name
|
||||
inline Standard_CString PName() const { return "PNaming_NamedShape"; }
|
||||
|
||||
//! Import transient attribuite from the persistent data.
|
||||
void Import (const Handle(TNaming_NamedShape)& theAttribute) const;
|
||||
@@ -52,6 +63,16 @@ public:
|
||||
public:
|
||||
//! Read persistent data from a file.
|
||||
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
|
||||
//! Read persistent data from a file.
|
||||
Standard_EXPORT virtual void Write (StdObjMgt_WriteData& theWriteData) const;
|
||||
//! Gets persistent child objects
|
||||
inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
|
||||
{
|
||||
if (!myArgs.IsNull()) theChildren.Append(myArgs);
|
||||
if (!myStop.IsNull()) theChildren.Append(myStop);
|
||||
}
|
||||
//! Returns persistent type name
|
||||
inline Standard_CString PName() const { return "PNaming_Name"; }
|
||||
|
||||
//! Import transient object from the persistent data.
|
||||
Standard_EXPORT virtual void Import
|
||||
@@ -70,6 +91,16 @@ public:
|
||||
public:
|
||||
//! Read persistent data from a file.
|
||||
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
|
||||
//! Read persistent data from a file.
|
||||
Standard_EXPORT virtual void Write (StdObjMgt_WriteData& theWriteData) const;
|
||||
//! Gets persistent child objects
|
||||
inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
|
||||
{
|
||||
Name::PChildren(theChildren);
|
||||
if (!myContextLabel.IsNull()) theChildren.Append(myContextLabel);
|
||||
}
|
||||
//! Returns persistent type name
|
||||
inline Standard_CString PName() const { return "PNaming_Name_1"; }
|
||||
|
||||
//! Import transient object from the persistent data.
|
||||
Standard_EXPORT virtual void Import
|
||||
@@ -84,6 +115,13 @@ public:
|
||||
public:
|
||||
//! Read persistent data from a file.
|
||||
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
|
||||
//! Read persistent data from a file.
|
||||
Standard_EXPORT virtual void Write (StdObjMgt_WriteData& theWriteData) const;
|
||||
//! Gets persistent child objects
|
||||
inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
|
||||
{ Name_1::PChildren(theChildren); }
|
||||
//! Returns persistent type name
|
||||
inline Standard_CString PName() const { return "PNaming_Name_2"; }
|
||||
|
||||
//! Import transient object from the persistent data.
|
||||
Standard_EXPORT virtual void Import
|
||||
|
@@ -32,6 +32,19 @@ public:
|
||||
theReadData >> myIsDisplayed >> myDriverGUID
|
||||
>> myTransparency >> myColor >> myMaterial >> myWidth;
|
||||
}
|
||||
//! Write persistent data to a file.
|
||||
inline void Write (StdObjMgt_WriteData& theWriteData) const
|
||||
{
|
||||
theWriteData << myIsDisplayed << myDriverGUID
|
||||
<< myTransparency << myColor << myMaterial << myWidth;
|
||||
}
|
||||
//! Gets persistent child objects
|
||||
inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
|
||||
{
|
||||
theChildren.Append(myDriverGUID);
|
||||
}
|
||||
//! Returns persistent type name
|
||||
inline Standard_CString PName() const { return "PPrsStd_AISPresentation"; }
|
||||
|
||||
//! Import transient attribuite from the persistent data.
|
||||
void Import (const Handle(TDataXtd_Presentation)& theAttribute) const;
|
||||
@@ -54,6 +67,14 @@ public:
|
||||
AISPresentation::Read (theReadData);
|
||||
theReadData >> myMode;
|
||||
}
|
||||
//! Write persistent data to a file.
|
||||
inline void Write (StdObjMgt_WriteData& theWriteData)
|
||||
{
|
||||
AISPresentation::Write (theWriteData);
|
||||
theWriteData << myMode;
|
||||
}
|
||||
//! Returns persistent type name
|
||||
inline Standard_CString PName() const { return "PPrsStd_AISPresentation_1"; }
|
||||
|
||||
//! Import transient attribuite from the persistent data.
|
||||
void Import (const Handle(TDataXtd_Presentation)& theAttribute) const;
|
||||
|
@@ -13,6 +13,7 @@
|
||||
|
||||
#include <StdPersistent_TopLoc.hxx>
|
||||
#include <StdObjMgt_ReadData.hxx>
|
||||
#include <StdObjMgt_WriteData.hxx>
|
||||
#include <StdObject_gp_Trsfs.hxx>
|
||||
|
||||
|
||||
@@ -27,6 +28,11 @@ void StdPersistent_TopLoc::Datum3D::Read (StdObjMgt_ReadData& theReadData)
|
||||
myTransient = new TopLoc_Datum3D (aTrsf);
|
||||
}
|
||||
|
||||
void StdPersistent_TopLoc::Datum3D::Write(StdObjMgt_WriteData& theWriteData) const
|
||||
{
|
||||
theWriteData << myTransient->Transformation();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Read
|
||||
//purpose : Read persistent data from a file
|
||||
@@ -36,6 +42,26 @@ void StdPersistent_TopLoc::ItemLocation::Read (StdObjMgt_ReadData& theReadData)
|
||||
theReadData >> myDatum >> myPower >> myNext;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Write
|
||||
//purpose : Write persistent data to a file
|
||||
//=======================================================================
|
||||
void StdPersistent_TopLoc::ItemLocation::Write (StdObjMgt_WriteData& theWriteData) const
|
||||
{
|
||||
theWriteData << myDatum << myPower << myNext;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : PChildren
|
||||
//purpose : Gets persistent child objects
|
||||
//=======================================================================
|
||||
void StdPersistent_TopLoc::ItemLocation::PChildren
|
||||
(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
|
||||
{
|
||||
theChildren.Append(myDatum);
|
||||
myNext.PChildren(theChildren);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Import
|
||||
//purpose : Import transient object from the persistent data
|
||||
@@ -48,3 +74,40 @@ TopLoc_Location StdPersistent_TopLoc::ItemLocation::Import() const
|
||||
else
|
||||
return aNext;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Translate
|
||||
//purpose : Create a persistent object from a location
|
||||
//=======================================================================
|
||||
Handle(StdPersistent_TopLoc::ItemLocation)
|
||||
StdPersistent_TopLoc::Translate (const TopLoc_Location& theLoc,
|
||||
StdObjMgt_TransientPersistentMap& theMap)
|
||||
{
|
||||
Handle(ItemLocation) aPLoc = new ItemLocation;
|
||||
aPLoc->myDatum = Translate(theLoc.FirstDatum(), theMap);
|
||||
aPLoc->myPower = theLoc.FirstPower();
|
||||
aPLoc->myNext = StdObject_Location::Translate(theLoc.NextLocation(), theMap);
|
||||
return aPLoc;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Translate
|
||||
//purpose : Create a persistent object from a location datum
|
||||
//=======================================================================
|
||||
Handle(StdPersistent_TopLoc::Datum3D)
|
||||
StdPersistent_TopLoc::Translate (const Handle(TopLoc_Datum3D)& theDatum,
|
||||
StdObjMgt_TransientPersistentMap& theMap)
|
||||
{
|
||||
Handle(Datum3D) aPDatum;
|
||||
if (theMap.IsBound(theDatum))
|
||||
{
|
||||
aPDatum = Handle(Datum3D)::DownCast(theMap.Find(theDatum));
|
||||
}
|
||||
else
|
||||
{
|
||||
aPDatum = new Datum3D;
|
||||
aPDatum->Transient(theDatum);
|
||||
theMap.Bind(theDatum, aPDatum);
|
||||
}
|
||||
return aPDatum;
|
||||
}
|
||||
|
@@ -18,6 +18,7 @@
|
||||
#include <StdObjMgt_SharedObject.hxx>
|
||||
#include <StdObjMgt_Persistent.hxx>
|
||||
#include <StdObject_Location.hxx>
|
||||
#include <StdObjMgt_TransientPersistentMap.hxx>
|
||||
|
||||
#include <TopLoc_Datum3D.hxx>
|
||||
#include <TopLoc_Location.hxx>
|
||||
@@ -31,13 +32,29 @@ public:
|
||||
public:
|
||||
//! Read persistent data from a file.
|
||||
void Read (StdObjMgt_ReadData& theReadData);
|
||||
//! Write persistent data to a file.
|
||||
void Write (StdObjMgt_WriteData& theWriteData) const;
|
||||
//! Gets persistent child objects
|
||||
Standard_EXPORT virtual void PChildren(SequenceOfPersistent&) const { }
|
||||
//! Returns persistent type name
|
||||
Standard_EXPORT virtual Standard_CString PName () const
|
||||
{ return "PTopLoc_Datum3D"; }
|
||||
};
|
||||
|
||||
class ItemLocation : public StdObjMgt_Persistent
|
||||
{
|
||||
friend class StdPersistent_TopLoc;
|
||||
|
||||
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 "PTopLoc_ItemLocation"; }
|
||||
|
||||
//! Import transient object from the persistent data.
|
||||
Standard_EXPORT TopLoc_Location Import() const;
|
||||
@@ -47,6 +64,12 @@ public:
|
||||
Standard_Integer myPower;
|
||||
StdObject_Location myNext;
|
||||
};
|
||||
|
||||
public:
|
||||
Standard_EXPORT static Handle(ItemLocation) Translate (const TopLoc_Location& theLoc,
|
||||
StdObjMgt_TransientPersistentMap& theMap);
|
||||
Standard_EXPORT static Handle(Datum3D) Translate (const Handle(TopLoc_Datum3D)& theDatum,
|
||||
StdObjMgt_TransientPersistentMap& theMap);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -17,6 +17,7 @@
|
||||
|
||||
#include <StdObjMgt_SharedObject.hxx>
|
||||
#include <StdObjMgt_ReadData.hxx>
|
||||
#include <StdObjMgt_WriteData.hxx>
|
||||
|
||||
#include <TopoDS_TShape.hxx>
|
||||
|
||||
@@ -26,9 +27,19 @@ class StdPersistent_TopoDS : protected StdObjMgt_SharedObject
|
||||
protected:
|
||||
class pTShape : public Standard_Transient
|
||||
{
|
||||
friend class ShapePersistent_TopoDS;
|
||||
|
||||
DEFINE_STANDARD_RTTI_INLINE(pTShape, Standard_Transient)
|
||||
|
||||
public:
|
||||
inline void Read (StdObjMgt_ReadData& theReadData)
|
||||
{ theReadData >> myShapes >> myFlags; }
|
||||
inline void Write (StdObjMgt_WriteData& theWriteData) const
|
||||
{ theWriteData << myShapes << myFlags; }
|
||||
inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
|
||||
{ theChildren.Append(myShapes); }
|
||||
inline Standard_CString PName() const
|
||||
{ return "PTopoDS_TShape"; }
|
||||
|
||||
protected:
|
||||
Handle(StdObjMgt_Persistent) myShapes;
|
||||
|
18
src/StdStorage/FILES
Normal file
18
src/StdStorage/FILES
Normal file
@@ -0,0 +1,18 @@
|
||||
StdStorage.cxx
|
||||
StdStorage.hxx
|
||||
StdStorage_Data.cxx
|
||||
StdStorage_Data.hxx
|
||||
StdStorage_HeaderData.cxx
|
||||
StdStorage_HeaderData.hxx
|
||||
StdStorage_Root.cxx
|
||||
StdStorage_Root.hxx
|
||||
StdStorage_RootData.cxx
|
||||
StdStorage_RootData.hxx
|
||||
StdStorage_HSequenceOfRoots.hxx
|
||||
StdStorage_SequenceOfRoots.hxx
|
||||
StdStorage_MapOfRoots.hxx
|
||||
StdStorage_TypeData.cxx
|
||||
StdStorage_TypeData.hxx
|
||||
StdStorage_MapOfTypes.hxx
|
||||
StdStorage_BacketOfPersistent.cxx
|
||||
StdStorage_BacketOfPersistent.hxx
|
319
src/StdStorage/StdStorage.cxx
Normal file
319
src/StdStorage/StdStorage.cxx
Normal file
@@ -0,0 +1,319 @@
|
||||
// Copyright (c) 2017 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <NCollection_Handle.hxx>
|
||||
#include <NCollection_Array1.hxx>
|
||||
#include <PCDM.hxx>
|
||||
#include <PCDM_BaseDriverPointer.hxx>
|
||||
#include <PCDM_ReadWriter.hxx>
|
||||
#include <Standard_ErrorHandler.hxx>
|
||||
#include <Standard_NullObject.hxx>
|
||||
#include <StdObjMgt_Persistent.hxx>
|
||||
#include <StdObjMgt_ReadData.hxx>
|
||||
#include <StdObjMgt_WriteData.hxx>
|
||||
#include <StdStorage.hxx>
|
||||
#include <StdStorage_Data.hxx>
|
||||
#include <StdStorage_HeaderData.hxx>
|
||||
#include <StdStorage_TypeData.hxx>
|
||||
#include <StdStorage_RootData.hxx>
|
||||
#include <StdStorage_HSequenceOfRoots.hxx>
|
||||
#include <StdStorage_BacketOfPersistent.hxx>
|
||||
#include <Storage.hxx>
|
||||
#include <Storage_BaseDriver.hxx>
|
||||
#include <Storage_StreamTypeMismatchError.hxx>
|
||||
#include <Storage_StreamFormatError.hxx>
|
||||
#include <Storage_StreamWriteError.hxx>
|
||||
|
||||
#include <locale.h>
|
||||
#include <stdio.h>
|
||||
|
||||
//=======================================================================
|
||||
// StdStorage::Version
|
||||
//=======================================================================
|
||||
TCollection_AsciiString StdStorage::Version()
|
||||
{
|
||||
TCollection_AsciiString v("1.3");
|
||||
return v;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// StdStorage::Read
|
||||
// Reads data from a file
|
||||
//=======================================================================
|
||||
Storage_Error StdStorage::Read(const TCollection_AsciiString& theFileName,
|
||||
Handle(StdStorage_Data)& theData)
|
||||
{
|
||||
// Create a driver appropriate for the given file
|
||||
PCDM_BaseDriverPointer aDriverPtr;
|
||||
if (PCDM::FileDriverType(theFileName, aDriverPtr) == PCDM_TOFD_Unknown)
|
||||
return Storage_VSWrongFileDriver;
|
||||
|
||||
NCollection_Handle<Storage_BaseDriver> aDriver(aDriverPtr);
|
||||
|
||||
// Try to open the file
|
||||
try
|
||||
{
|
||||
OCC_CATCH_SIGNALS
|
||||
PCDM_ReadWriter::Open(*aDriver, theFileName, Storage_VSRead);
|
||||
}
|
||||
catch (Standard_Failure)
|
||||
{
|
||||
return Storage_VSOpenError;
|
||||
}
|
||||
|
||||
return Read(*aDriver, theData);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// StdStorage::Read
|
||||
// Reads data from a pre-opened for reading driver
|
||||
//=======================================================================
|
||||
Storage_Error StdStorage::Read(Storage_BaseDriver& theDriver,
|
||||
Handle(StdStorage_Data)& theData)
|
||||
{
|
||||
if (theData.IsNull())
|
||||
theData = new StdStorage_Data;
|
||||
else
|
||||
theData->Clear();
|
||||
|
||||
Handle(StdStorage_HeaderData) aHeaderData = theData->HeaderData();
|
||||
Handle(StdStorage_TypeData) aTypeData = theData->TypeData();
|
||||
Handle(StdStorage_RootData) aRootData = theData->RootData();
|
||||
|
||||
// Read header section
|
||||
if (!aHeaderData->Read(theDriver))
|
||||
return aHeaderData->ErrorStatus();
|
||||
|
||||
// Read types section
|
||||
if (!aTypeData->Read(theDriver))
|
||||
return aTypeData->ErrorStatus();
|
||||
|
||||
// Select instantiators for the used types
|
||||
NCollection_Array1<StdObjMgt_Persistent::Instantiator>
|
||||
anInstantiators(1, aTypeData->NumberOfTypes());
|
||||
for (Standard_Integer i = 1; i <= aTypeData->NumberOfTypes(); i++)
|
||||
{
|
||||
StdObjMgt_Persistent::Instantiator anInstantiator =
|
||||
aTypeData->Instantiator(i);
|
||||
if (anInstantiator)
|
||||
anInstantiators(i) = anInstantiator;
|
||||
else
|
||||
return Storage_VSUnknownType;
|
||||
}
|
||||
|
||||
// Read root section
|
||||
if (!aRootData->Read(theDriver))
|
||||
return aRootData->ErrorStatus();
|
||||
|
||||
Storage_Error anError;
|
||||
|
||||
// Read and parse reference section
|
||||
StdObjMgt_ReadData aReadData(theDriver, aHeaderData->NumberOfObjects());
|
||||
|
||||
anError = theDriver.BeginReadRefSection();
|
||||
if (anError != Storage_VSOk)
|
||||
return anError;
|
||||
|
||||
Standard_Integer aNbRefs = theDriver.RefSectionSize();
|
||||
for (Standard_Integer i = 1; i <= aNbRefs; i++)
|
||||
{
|
||||
Standard_Integer aRef = 0, aType = 0;
|
||||
try
|
||||
{
|
||||
OCC_CATCH_SIGNALS
|
||||
theDriver.ReadReferenceType(aRef, aType);
|
||||
anError = Storage_VSOk;
|
||||
}
|
||||
catch (Storage_StreamTypeMismatchError)
|
||||
{
|
||||
anError = Storage_VSTypeMismatch;
|
||||
}
|
||||
|
||||
if (anError != Storage_VSOk)
|
||||
return anError;
|
||||
|
||||
aReadData.CreatePersistentObject(aRef, anInstantiators(aType));
|
||||
}
|
||||
|
||||
anError = theDriver.EndReadRefSection();
|
||||
if (anError != Storage_VSOk)
|
||||
return anError;
|
||||
|
||||
// Read and parse data section
|
||||
anError = theDriver.BeginReadDataSection();
|
||||
if (anError != Storage_VSOk)
|
||||
return anError;
|
||||
|
||||
for (Standard_Integer i = 1; i <= aHeaderData->NumberOfObjects(); i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
OCC_CATCH_SIGNALS
|
||||
aReadData.ReadPersistentObject(i);
|
||||
anError = Storage_VSOk;
|
||||
}
|
||||
catch (Storage_StreamTypeMismatchError) { anError = Storage_VSTypeMismatch; }
|
||||
catch (Storage_StreamFormatError) { anError = Storage_VSFormatError; }
|
||||
catch (Storage_StreamReadError) { anError = Storage_VSFormatError; }
|
||||
|
||||
if (anError != Storage_VSOk)
|
||||
return anError;
|
||||
}
|
||||
|
||||
anError = theDriver.EndReadDataSection();
|
||||
if (anError != Storage_VSOk)
|
||||
return anError;
|
||||
|
||||
Handle(StdStorage_HSequenceOfRoots) aRoots = aRootData->Roots();
|
||||
if (!aRoots.IsNull())
|
||||
{
|
||||
for (StdStorage_HSequenceOfRoots::Iterator anIt(*aRoots); anIt.More(); anIt.Next())
|
||||
{
|
||||
Handle(StdStorage_Root)& aRoot = anIt.ChangeValue();
|
||||
aRoot->SetObject(aReadData.PersistentObject(aRoot->Reference()));
|
||||
}
|
||||
}
|
||||
|
||||
return Storage_VSOk;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// StdStorage::currentDate
|
||||
//=======================================================================
|
||||
static TCollection_AsciiString currentDate()
|
||||
{
|
||||
#define SLENGTH 80
|
||||
|
||||
char nowstr[SLENGTH];
|
||||
time_t nowbin;
|
||||
struct tm *nowstruct;
|
||||
if (time(&nowbin) != (time_t)-1)
|
||||
{
|
||||
nowstruct = localtime(&nowbin);
|
||||
strftime(nowstr, SLENGTH, "%m/%d/%Y", nowstruct);
|
||||
}
|
||||
TCollection_AsciiString t(nowstr);
|
||||
return t;
|
||||
|
||||
#undef SLENGTH
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// StdStorage::Write
|
||||
//=======================================================================
|
||||
Storage_Error StdStorage::Write(Storage_BaseDriver& theDriver,
|
||||
const Handle(StdStorage_Data)& theData)
|
||||
{
|
||||
Standard_NullObject_Raise_if(theData.IsNull(), "Null storage data");
|
||||
|
||||
Handle(StdStorage_HeaderData) aHeaderData = theData->HeaderData();
|
||||
Handle(StdStorage_TypeData) aTypeData = theData->TypeData();
|
||||
Handle(StdStorage_RootData) aRootData = theData->RootData();
|
||||
|
||||
aHeaderData->SetCreationDate(currentDate());
|
||||
|
||||
Handle(StdStorage_HSequenceOfRoots) aRoots = aRootData->Roots();
|
||||
|
||||
StdStorage_BucketOfPersistent aPObjs;
|
||||
|
||||
if (!aRoots.IsNull())
|
||||
{
|
||||
StdObjMgt_Persistent::SequenceOfPersistent aPQueue;
|
||||
for (StdStorage_HSequenceOfRoots::Iterator anIt(*aRoots); anIt.More(); anIt.Next())
|
||||
{
|
||||
Handle(StdStorage_Root) aRoot = anIt.ChangeValue();
|
||||
Handle(StdObjMgt_Persistent) aPObj = aRoot->Object();
|
||||
if (!aPObj.IsNull()) {
|
||||
aPQueue.Append(aPObj);
|
||||
}
|
||||
}
|
||||
while (!aPQueue.IsEmpty())
|
||||
{
|
||||
StdObjMgt_Persistent::SequenceOfPersistent aPQueue1;
|
||||
for (StdObjMgt_Persistent::SequenceOfPersistent::Iterator anIt(aPQueue); anIt.More(); anIt.Next())
|
||||
{
|
||||
Handle(StdObjMgt_Persistent)& aPObj = anIt.ChangeValue();
|
||||
if (!aPObj.IsNull())
|
||||
{
|
||||
if (aPObj->TypeNum() == 0 && aPObj->RefNum() == 0)
|
||||
{
|
||||
aPObj->TypeNum(aTypeData->AddType(aPObj));
|
||||
Standard_Integer anPObjId = aPObjs.Length() + 1;
|
||||
aPObj->RefNum(anPObjId);
|
||||
aPObjs.Append(aPObj);
|
||||
aPObj->PChildren(aPQueue1);
|
||||
}
|
||||
}
|
||||
}
|
||||
aPQueue.Assign(aPQueue1);
|
||||
}
|
||||
}
|
||||
|
||||
aHeaderData->SetStorageVersion(StdStorage::Version());
|
||||
aHeaderData->SetNumberOfObjects(aPObjs.Length());
|
||||
|
||||
try {
|
||||
// Write header section
|
||||
if (!aHeaderData->Write(theDriver))
|
||||
return aHeaderData->ErrorStatus();
|
||||
|
||||
// Write types section
|
||||
if (!aTypeData->Write(theDriver))
|
||||
return aTypeData->ErrorStatus();
|
||||
|
||||
// Write root section
|
||||
if (!aRootData->Write(theDriver))
|
||||
return aRootData->ErrorStatus();
|
||||
|
||||
Storage_Error anError;
|
||||
|
||||
// Write reference section
|
||||
anError = theDriver.BeginWriteRefSection();
|
||||
if (anError != Storage_VSOk)
|
||||
return anError;
|
||||
|
||||
theDriver.SetRefSectionSize(aPObjs.Length());
|
||||
for (StdStorage_BucketIterator anIt(&aPObjs); anIt.More(); anIt.Next())
|
||||
{
|
||||
Handle(StdObjMgt_Persistent) aPObj = anIt.Value();
|
||||
if (!aPObj.IsNull())
|
||||
theDriver.WriteReferenceType(aPObj->RefNum(), aPObj->TypeNum());
|
||||
}
|
||||
|
||||
anError = theDriver.EndWriteRefSection();
|
||||
if (anError != Storage_VSOk)
|
||||
return anError;
|
||||
|
||||
// Write data section
|
||||
anError = theDriver.BeginWriteDataSection();
|
||||
if (anError != Storage_VSOk)
|
||||
return anError;
|
||||
|
||||
StdObjMgt_WriteData aWriteData(theDriver);
|
||||
for (StdStorage_BucketIterator anIt(&aPObjs); anIt.More(); anIt.Next())
|
||||
{
|
||||
Handle(StdObjMgt_Persistent) aPObj = anIt.Value();
|
||||
if (!aPObj.IsNull())
|
||||
aWriteData.WritePersistentObject(aPObj);
|
||||
}
|
||||
|
||||
anError = theDriver.EndWriteDataSection();
|
||||
if (anError != Storage_VSOk)
|
||||
return anError;
|
||||
}
|
||||
catch (Storage_StreamWriteError) {
|
||||
return Storage_VSWriteError;
|
||||
}
|
||||
|
||||
return Storage_VSOk;
|
||||
}
|
72
src/StdStorage/StdStorage.hxx
Normal file
72
src/StdStorage/StdStorage.hxx
Normal file
@@ -0,0 +1,72 @@
|
||||
// Copyright (c) 2017 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _StdStorage_HeaderFile
|
||||
#define _StdStorage_HeaderFile
|
||||
|
||||
#include <Standard_Macro.hxx>
|
||||
#include <Storage_Error.hxx>
|
||||
class StdStorage_Data;
|
||||
class Storage_BaseDriver;
|
||||
class TCollection_AsciiString;
|
||||
|
||||
//! StdStorage package is used to write and read persistent objects.
|
||||
//! These objects are read and written by a retrieval or storage
|
||||
//! algorithm (compatible with legacy Storage_Schema) in a container
|
||||
//! (disk, memory, network ...). Drivers (FSD_File objects) assign a physical
|
||||
//! container for data to be stored or retrieved.
|
||||
//! The standard procedure for an application in reading a container is
|
||||
//! to call one of the Read functions providing either a file path or a driver
|
||||
//! opened for reading. Thes function update the instance of the StdStorage_Data
|
||||
//! class which contains the data being read.
|
||||
//! The standard procedure for an application in writing a container is the following:
|
||||
//! - open the driver in writing mode,
|
||||
//! - create an instance of the StdStorage_Data class, then
|
||||
//! add the persistent data to write with the function AddRoot,
|
||||
//! - call the function Write from the storage, setting the driver and the
|
||||
//! Storage_Data instance as parameters,
|
||||
//! - close the driver.
|
||||
class StdStorage
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//! Returns the version of Storage's read/write routines
|
||||
Standard_EXPORT static TCollection_AsciiString Version();
|
||||
|
||||
//! Returns the data read from a file located at theFileName.
|
||||
//! The storage format is compartible with legacy persistent one.
|
||||
//! These data are aggregated in a StdStorage_Data object which may be
|
||||
//! browsed in order to extract the root objects from the container.
|
||||
//! Note: - theData object will be created if it is null or cleared otherwise.
|
||||
Standard_EXPORT static Storage_Error Read(const TCollection_AsciiString& theFileName,
|
||||
Handle(StdStorage_Data)& theData);
|
||||
|
||||
//! Returns the data read from the container defined by theDriver.
|
||||
//! The storage format is compartible with legacy persistent one.
|
||||
//! These data are aggregated in a StdStorage_Data object which may be
|
||||
//! browsed in order to extract the root objects from the container.
|
||||
//! Note: - theData object will be created if it is null or cleared otherwise.
|
||||
Standard_EXPORT static Storage_Error Read(Storage_BaseDriver& theDriver,
|
||||
Handle(StdStorage_Data)& theData);
|
||||
|
||||
//! Writes the data aggregated in theData object into the container defined by
|
||||
//! theDriver. The storage format is compartible with legacy persistent one.
|
||||
//! Note: - theData may aggregate several root objects to be stored together.
|
||||
//! - createion date specified in the srorage header will be overwritten.
|
||||
Standard_EXPORT static Storage_Error Write(Storage_BaseDriver& theDriver,
|
||||
const Handle(StdStorage_Data)& theData);
|
||||
|
||||
};
|
||||
|
||||
#endif // _StdStorage_HeaderFile
|
213
src/StdStorage/StdStorage_BacketOfPersistent.cxx
Normal file
213
src/StdStorage/StdStorage_BacketOfPersistent.cxx
Normal file
@@ -0,0 +1,213 @@
|
||||
// Copyright (c) 2017 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <StdStorage_BacketOfPersistent.hxx>
|
||||
#include <StdObjMgt_Persistent.hxx>
|
||||
|
||||
StdStorage_Bucket::~StdStorage_Bucket()
|
||||
{
|
||||
Standard::Free(mySpace);
|
||||
mySpace = 0L;
|
||||
mySpaceSize = 0;
|
||||
Clear();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Clear
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void StdStorage_Bucket::Clear()
|
||||
{
|
||||
myCurrentSpace = -1;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Append
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void StdStorage_Bucket::Append(StdObjMgt_Persistent *sp)
|
||||
{
|
||||
++myCurrentSpace;
|
||||
mySpace[myCurrentSpace] = sp;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Value
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
StdObjMgt_Persistent* StdStorage_Bucket::Value(const Standard_Integer theIndex) const
|
||||
{
|
||||
return mySpace[theIndex];
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Storage_BucketOfPersistent
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
StdStorage_BucketOfPersistent::StdStorage_BucketOfPersistent
|
||||
(const Standard_Integer theBucketSize, const Standard_Integer theBucketNumber)
|
||||
: myNumberOfBucket(1), myNumberOfBucketAllocated(theBucketNumber)
|
||||
, myBucketSize(theBucketSize)
|
||||
{
|
||||
myBuckets = (StdStorage_Bucket**)Standard::Allocate
|
||||
(sizeof(StdStorage_Bucket*) * theBucketNumber);
|
||||
myBuckets[0] = new StdStorage_Bucket(myBucketSize);
|
||||
myCurrentBucket = myBuckets[0];
|
||||
myLength = 0;
|
||||
myCurrentBucketNumber = 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Clear
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void StdStorage_BucketOfPersistent::Clear()
|
||||
{
|
||||
if (myBuckets) {
|
||||
Standard_Integer i;
|
||||
|
||||
for (i = 1; i < myNumberOfBucket; i++) delete myBuckets[i];
|
||||
myNumberOfBucket = 1;
|
||||
myCurrentBucket = myBuckets[0];
|
||||
myCurrentBucket->Clear();
|
||||
myCurrentBucketNumber = 0;
|
||||
myLength = 0;
|
||||
}
|
||||
}
|
||||
|
||||
StdStorage_BucketOfPersistent::~StdStorage_BucketOfPersistent()
|
||||
{
|
||||
Clear();
|
||||
delete myBuckets[0];
|
||||
Standard::Free(myBuckets);
|
||||
myBuckets = 0L;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Value
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
StdObjMgt_Persistent* StdStorage_BucketOfPersistent::Value
|
||||
(const Standard_Integer theIndex)
|
||||
{
|
||||
Standard_Integer theInd, theCurrentBucketNumber, tecurrentind = theIndex - 1;
|
||||
theCurrentBucketNumber = tecurrentind / myBucketSize;
|
||||
theInd = tecurrentind - (myBucketSize * theCurrentBucketNumber);
|
||||
|
||||
return myBuckets[theCurrentBucketNumber]->mySpace[theInd];
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Append
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void StdStorage_BucketOfPersistent::Append(const Handle(StdObjMgt_Persistent)& sp)
|
||||
{
|
||||
myCurrentBucket->myCurrentSpace++;
|
||||
|
||||
if (myCurrentBucket->myCurrentSpace != myBucketSize) {
|
||||
myLength++;
|
||||
myCurrentBucket->mySpace[myCurrentBucket->myCurrentSpace] = sp.operator->();
|
||||
return;
|
||||
}
|
||||
|
||||
myCurrentBucket->myCurrentSpace--;
|
||||
myNumberOfBucket++;
|
||||
myCurrentBucketNumber++;
|
||||
|
||||
if (myNumberOfBucket > myNumberOfBucketAllocated) {
|
||||
Standard_Size e = sizeof(StdStorage_Bucket*) * myNumberOfBucketAllocated;
|
||||
myBuckets = (StdStorage_Bucket**)Standard::Reallocate(myBuckets, e * 2);
|
||||
myNumberOfBucketAllocated *= 2;
|
||||
}
|
||||
|
||||
myBuckets[myCurrentBucketNumber] = new StdStorage_Bucket(myBucketSize);
|
||||
myCurrentBucket = myBuckets[myCurrentBucketNumber];
|
||||
myCurrentBucket->myCurrentSpace++;
|
||||
myLength++;
|
||||
myCurrentBucket->mySpace[myCurrentBucket->myCurrentSpace] = sp.operator->();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Storage_BucketIterator
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
StdStorage_BucketIterator::StdStorage_BucketIterator
|
||||
(StdStorage_BucketOfPersistent* aBucketManager)
|
||||
{
|
||||
if (aBucketManager) {
|
||||
myBucket = aBucketManager;
|
||||
myCurrentBucket = myBucket->myBuckets[0];
|
||||
myBucketNumber = aBucketManager->myNumberOfBucket;
|
||||
myCurrentBucketIndex = 0;
|
||||
myCurrentIndex = 0;
|
||||
myMoreObject = Standard_True;
|
||||
}
|
||||
else myMoreObject = Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Reset
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void StdStorage_BucketIterator::Reset()
|
||||
{
|
||||
if (myBucket) {
|
||||
myCurrentBucket = myBucket->myBuckets[0];
|
||||
myBucketNumber = myBucket->myNumberOfBucket;
|
||||
myCurrentIndex = 0;
|
||||
myCurrentBucketIndex = 0;
|
||||
myMoreObject = Standard_True;
|
||||
}
|
||||
else myMoreObject = Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Init
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void StdStorage_BucketIterator::Init(StdStorage_BucketOfPersistent* aBucketManager)
|
||||
{
|
||||
if (aBucketManager) {
|
||||
myBucket = aBucketManager;
|
||||
myCurrentBucket = myBucket->myBuckets[0];
|
||||
myBucketNumber = aBucketManager->myNumberOfBucket;
|
||||
myCurrentIndex = 0;
|
||||
myCurrentBucketIndex = 0;
|
||||
myMoreObject = Standard_True;
|
||||
}
|
||||
else myMoreObject = Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Next
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void StdStorage_BucketIterator::Next()
|
||||
{
|
||||
if (!myMoreObject) return;
|
||||
|
||||
if (myCurrentIndex < myCurrentBucket->myCurrentSpace) {
|
||||
myCurrentIndex++;
|
||||
}
|
||||
else {
|
||||
myCurrentIndex = 0;
|
||||
myCurrentBucketIndex++;
|
||||
if (myCurrentBucketIndex < myBucketNumber) {
|
||||
myCurrentBucket = myBucket->myBuckets[myCurrentBucketIndex];
|
||||
}
|
||||
else {
|
||||
myMoreObject = Standard_False;
|
||||
}
|
||||
}
|
||||
}
|
114
src/StdStorage/StdStorage_BacketOfPersistent.hxx
Normal file
114
src/StdStorage/StdStorage_BacketOfPersistent.hxx
Normal file
@@ -0,0 +1,114 @@
|
||||
// Copyright (c) 2017 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _StdStorage_BucketOfPersistent_HeaderFile
|
||||
#define _StdStorage_BucketOfPersistent_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
#include <Standard_Integer.hxx>
|
||||
|
||||
class StdStorage_BucketOfPersistent;
|
||||
class StdStorage_BucketIterator;
|
||||
class StdObjMgt_Persistent;
|
||||
|
||||
class StdStorage_Bucket
|
||||
{
|
||||
friend class StdStorage_BucketIterator;
|
||||
friend class StdStorage_BucketOfPersistent;
|
||||
|
||||
StdObjMgt_Persistent** mySpace;
|
||||
Standard_Integer mySpaceSize;
|
||||
Standard_Integer myCurrentSpace;
|
||||
|
||||
void Append(StdObjMgt_Persistent *);
|
||||
|
||||
StdObjMgt_Persistent* Value(const Standard_Integer theIndex) const;
|
||||
|
||||
public:
|
||||
|
||||
StdStorage_Bucket() : mySpace(0L), mySpaceSize(200000), myCurrentSpace(-1)
|
||||
{
|
||||
mySpace = (StdObjMgt_Persistent**)Standard::Allocate(sizeof(StdObjMgt_Persistent*) * mySpaceSize);
|
||||
}
|
||||
|
||||
StdStorage_Bucket(const Standard_Integer theSpaceSize) : mySpace(0L), mySpaceSize(theSpaceSize), myCurrentSpace(-1)
|
||||
{
|
||||
mySpace = (StdObjMgt_Persistent**)Standard::Allocate(sizeof(StdObjMgt_Persistent*) * mySpaceSize);
|
||||
}
|
||||
|
||||
void Clear();
|
||||
|
||||
~StdStorage_Bucket();
|
||||
};
|
||||
|
||||
class StdStorage_BucketOfPersistent
|
||||
{
|
||||
friend class StdStorage_BucketIterator;
|
||||
StdStorage_Bucket** myBuckets;
|
||||
Standard_Integer myNumberOfBucket;
|
||||
Standard_Integer myNumberOfBucketAllocated;
|
||||
StdStorage_Bucket* myCurrentBucket;
|
||||
Standard_Integer myCurrentBucketNumber;
|
||||
Standard_Integer myLength;
|
||||
Standard_Integer myBucketSize;
|
||||
|
||||
public:
|
||||
StdStorage_BucketOfPersistent(const Standard_Integer theBucketSize = 300000, const Standard_Integer theBucketNumber = 100);
|
||||
|
||||
Standard_Integer Length() const
|
||||
{
|
||||
return myLength;
|
||||
}
|
||||
|
||||
void Append(const Handle(StdObjMgt_Persistent)& sp);
|
||||
|
||||
StdObjMgt_Persistent* Value(const Standard_Integer theIndex);
|
||||
|
||||
void Clear();
|
||||
|
||||
~StdStorage_BucketOfPersistent();
|
||||
};
|
||||
|
||||
class StdStorage_BucketIterator
|
||||
{
|
||||
StdStorage_BucketOfPersistent *myBucket;
|
||||
StdStorage_Bucket *myCurrentBucket;
|
||||
Standard_Integer myCurrentBucketIndex;
|
||||
Standard_Integer myCurrentIndex;
|
||||
Standard_Integer myBucketNumber;
|
||||
Standard_Boolean myMoreObject;
|
||||
|
||||
public:
|
||||
StdStorage_BucketIterator(StdStorage_BucketOfPersistent*);
|
||||
|
||||
void Init(StdStorage_BucketOfPersistent*);
|
||||
void Reset();
|
||||
|
||||
StdObjMgt_Persistent* Value() const
|
||||
{
|
||||
if (myCurrentBucket) {
|
||||
return myCurrentBucket->mySpace[myCurrentIndex];
|
||||
}
|
||||
else return 0L;
|
||||
}
|
||||
|
||||
Standard_Boolean More() const
|
||||
{
|
||||
return myMoreObject;
|
||||
}
|
||||
|
||||
void Next();
|
||||
};
|
||||
|
||||
#endif // _StdStorage_BucketOfPersistent_HeaderFile
|
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2015 OPEN CASCADE SAS
|
||||
// Copyright (c) 2017 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
@@ -11,5 +11,21 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <StdStorage_Data.hxx>
|
||||
#include <StdStorage_HeaderData.hxx>
|
||||
#include <StdStorage_TypeData.hxx>
|
||||
#include <StdStorage_RootData.hxx>
|
||||
|
||||
#include <StdObjMgt_MapOfInstantiators.hxx>
|
||||
StdStorage_Data::StdStorage_Data()
|
||||
: myHeaderData(new StdStorage_HeaderData)
|
||||
, myTypeData(new StdStorage_TypeData)
|
||||
, myRootData(new StdStorage_RootData)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void StdStorage_Data::Clear()
|
||||
{
|
||||
myTypeData->Clear();
|
||||
myRootData->Clear();
|
||||
}
|
90
src/StdStorage/StdStorage_Data.hxx
Normal file
90
src/StdStorage/StdStorage_Data.hxx
Normal file
@@ -0,0 +1,90 @@
|
||||
// Copyright (c) 2017 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _StdStorage_Data_HeaderFile
|
||||
#define _StdStorage_Data_HeaderFile
|
||||
|
||||
#include <MMgt_TShared.hxx>
|
||||
#include <Standard_Macro.hxx>
|
||||
class StdStorage_HeaderData;
|
||||
class StdStorage_TypeData;
|
||||
class StdStorage_RootData;
|
||||
|
||||
//! A picture memorizing the stored in a
|
||||
//! container (for example, in a file).
|
||||
//! A StdStorage_Data object represents either:
|
||||
//! - persistent data to be written into a container,
|
||||
//! or
|
||||
//! - persistent data which are read from a container.
|
||||
//! A StdStorage_Data object is used in both the
|
||||
//! storage and retrieval operations:
|
||||
//! - Storage mechanism: create an empty
|
||||
//! StdStorage_Data object, then add successively
|
||||
//! persistent objects (roots) to be stored using
|
||||
//! the StdStorage_RootData's function AddRoot. When the set of
|
||||
//! data is complete, write it to a container using the
|
||||
//! function Write in your StdStorage algorithm.
|
||||
//! - Retrieval mechanism: a StdStorage_Data
|
||||
//! object is returned by the Read function from
|
||||
//! your StdStorage algorithm. Use the StdStorage_RootData's
|
||||
//! functions NumberOfRoots and Roots to find the roots which
|
||||
//! were stored in the read container.
|
||||
//! The roots of a StdStorage_Data object may share
|
||||
//! references on objects. The shared internal
|
||||
//! references of a StdStorage_Data object are
|
||||
//! maintained by the storage/retrieval mechanism.
|
||||
//! Note: References shared by objects which are
|
||||
//! contained in two distinct StdStorage_Data objects
|
||||
//! are not maintained by the storage/retrieval
|
||||
//! mechanism: external references are not
|
||||
//! supported by Storage_Schema algorithm
|
||||
class StdStorage_Data
|
||||
: public MMgt_TShared
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//! Creates an empty set of data.
|
||||
//! You explicitly create a StdStorage_Data object
|
||||
//! when preparing the set of objects to be stored
|
||||
//! together in a container (for example, in a file).
|
||||
//! Then use the function StdStorage_RootData's AddRoot
|
||||
//! to add persistent objects to the set of data.
|
||||
//! A StdStorage_Data object is also returned by the
|
||||
//! Read function of a StdStorage algorithm. Use the
|
||||
//! StdStorage_RootData's functions NumberOfRoots and
|
||||
//! Roots to find the roots which were stored in the
|
||||
//! read container.
|
||||
Standard_EXPORT StdStorage_Data();
|
||||
|
||||
//! Makes the container empty
|
||||
Standard_EXPORT void Clear();
|
||||
|
||||
//! Returns the header data section
|
||||
Handle(StdStorage_HeaderData) HeaderData() { return myHeaderData; }
|
||||
|
||||
//! Returns the type data section
|
||||
Handle(StdStorage_TypeData) TypeData() { return myTypeData; }
|
||||
|
||||
//! Returns the root data section
|
||||
Handle(StdStorage_RootData) RootData() { return myRootData; }
|
||||
|
||||
private:
|
||||
|
||||
Handle(StdStorage_HeaderData) myHeaderData;
|
||||
Handle(StdStorage_TypeData) myTypeData;
|
||||
Handle(StdStorage_RootData) myRootData;
|
||||
|
||||
};
|
||||
|
||||
#endif // _StdStorage_Data_HeaderFile
|
11
src/StdStorage/StdStorage_HSequenceOfRoots.hxx
Normal file
11
src/StdStorage/StdStorage_HSequenceOfRoots.hxx
Normal file
@@ -0,0 +1,11 @@
|
||||
|
||||
#ifndef StdStorage_HSequenceOfRoots_HeaderFile
|
||||
#define StdStorage_HSequenceOfRoots_HeaderFile
|
||||
|
||||
#include <StdStorage_Root.hxx>
|
||||
#include <StdStorage_SequenceOfRoots.hxx>
|
||||
#include <NCollection_DefineHSequence.hxx>
|
||||
|
||||
DEFINE_HSEQUENCE(StdStorage_HSequenceOfRoots, StdStorage_SequenceOfRoots)
|
||||
|
||||
#endif // StdStorage_HSequenceOfRoots_HeaderFile
|
324
src/StdStorage/StdStorage_HeaderData.cxx
Normal file
324
src/StdStorage/StdStorage_HeaderData.cxx
Normal file
@@ -0,0 +1,324 @@
|
||||
// Copyright (c) 2017 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <Standard_ErrorHandler.hxx>
|
||||
#include <StdStorage_HeaderData.hxx>
|
||||
#include <Storage_BaseDriver.hxx>
|
||||
#include <Storage_StreamTypeMismatchError.hxx>
|
||||
#include <Storage_StreamExtCharParityError.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <TCollection_ExtendedString.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(StdStorage_HeaderData, MMgt_TShared)
|
||||
|
||||
StdStorage_HeaderData::StdStorage_HeaderData()
|
||||
: myNBObj(0), myErrorStatus(Storage_VSOk)
|
||||
{
|
||||
}
|
||||
|
||||
Standard_Boolean StdStorage_HeaderData::Read(Storage_BaseDriver& theDriver)
|
||||
{
|
||||
// Check driver open mode
|
||||
if (theDriver.OpenMode() != Storage_VSRead
|
||||
&& theDriver.OpenMode() != Storage_VSReadWrite)
|
||||
{
|
||||
myErrorStatus = Storage_VSModeError;
|
||||
myErrorStatusExt = "OpenMode";
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
// Read info section
|
||||
myErrorStatus = theDriver.BeginReadInfoSection();
|
||||
if (myErrorStatus != Storage_VSOk)
|
||||
{
|
||||
myErrorStatusExt = "BeginReadInfoSection";
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
OCC_CATCH_SIGNALS
|
||||
theDriver.ReadInfo(myNBObj,
|
||||
myStorageVersion,
|
||||
myDate,
|
||||
mySchemaName,
|
||||
mySchemaVersion,
|
||||
myApplicationName,
|
||||
myApplicationVersion,
|
||||
myDataType,
|
||||
myUserInfo);
|
||||
}
|
||||
catch (Storage_StreamTypeMismatchError)
|
||||
{
|
||||
myErrorStatus = Storage_VSTypeMismatch;
|
||||
myErrorStatusExt = "ReadInfo";
|
||||
return Standard_False;
|
||||
}
|
||||
catch (Storage_StreamExtCharParityError)
|
||||
{
|
||||
myErrorStatus = Storage_VSExtCharParityError;
|
||||
myErrorStatusExt = "ReadInfo";
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
myErrorStatus = theDriver.EndReadInfoSection();
|
||||
if (myErrorStatus != Storage_VSOk)
|
||||
{
|
||||
myErrorStatusExt = "EndReadInfoSection";
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
// Read comment section
|
||||
myErrorStatus = theDriver.BeginReadCommentSection();
|
||||
if (myErrorStatus != Storage_VSOk)
|
||||
{
|
||||
myErrorStatusExt = "BeginReadCommentSection";
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
OCC_CATCH_SIGNALS
|
||||
theDriver.ReadComment(myComments);
|
||||
}
|
||||
catch (Storage_StreamTypeMismatchError)
|
||||
{
|
||||
myErrorStatus = Storage_VSTypeMismatch;
|
||||
myErrorStatusExt = "ReadComment";
|
||||
return Standard_False;
|
||||
}
|
||||
catch (Storage_StreamExtCharParityError)
|
||||
{
|
||||
myErrorStatus = Storage_VSExtCharParityError;
|
||||
myErrorStatusExt = "ReadComment";
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
myErrorStatus = theDriver.EndReadCommentSection();
|
||||
if (myErrorStatus != Storage_VSOk)
|
||||
{
|
||||
myErrorStatusExt = "EndReadCommentSection";
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
Standard_Boolean StdStorage_HeaderData::Write(Storage_BaseDriver& theDriver)
|
||||
{
|
||||
// Check driver open mode
|
||||
if (theDriver.OpenMode() != Storage_VSWrite
|
||||
&& theDriver.OpenMode() != Storage_VSReadWrite)
|
||||
{
|
||||
myErrorStatus = Storage_VSModeError;
|
||||
myErrorStatusExt = "OpenMode";
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
// Write info section
|
||||
myErrorStatus = theDriver.BeginWriteInfoSection();
|
||||
if (myErrorStatus != Storage_VSOk)
|
||||
{
|
||||
myErrorStatusExt = "BeginWriteInfoSection";
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
OCC_CATCH_SIGNALS
|
||||
theDriver.WriteInfo(myNBObj,
|
||||
myStorageVersion,
|
||||
myDate,
|
||||
mySchemaName,
|
||||
mySchemaVersion,
|
||||
myApplicationName,
|
||||
myApplicationVersion,
|
||||
myDataType,
|
||||
myUserInfo);
|
||||
}
|
||||
catch (Storage_StreamTypeMismatchError)
|
||||
{
|
||||
myErrorStatus = Storage_VSTypeMismatch;
|
||||
myErrorStatusExt = "WriteInfo";
|
||||
return Standard_False;
|
||||
}
|
||||
catch (Storage_StreamExtCharParityError)
|
||||
{
|
||||
myErrorStatus = Storage_VSExtCharParityError;
|
||||
myErrorStatusExt = "WriteInfo";
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
myErrorStatus = theDriver.EndWriteInfoSection();
|
||||
if (myErrorStatus != Storage_VSOk)
|
||||
{
|
||||
myErrorStatusExt = "EndWriteInfoSection";
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
// Write comment section
|
||||
myErrorStatus = theDriver.BeginWriteCommentSection();
|
||||
if (myErrorStatus != Storage_VSOk)
|
||||
{
|
||||
myErrorStatusExt = "BeginWriteCommentSection";
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
OCC_CATCH_SIGNALS
|
||||
theDriver.WriteComment(myComments);
|
||||
}
|
||||
catch (Storage_StreamTypeMismatchError)
|
||||
{
|
||||
myErrorStatus = Storage_VSTypeMismatch;
|
||||
myErrorStatusExt = "WriteComment";
|
||||
return Standard_False;
|
||||
}
|
||||
catch (Storage_StreamExtCharParityError)
|
||||
{
|
||||
myErrorStatus = Storage_VSExtCharParityError;
|
||||
myErrorStatusExt = "WriteComment";
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
myErrorStatus = theDriver.EndWriteCommentSection();
|
||||
if (myErrorStatus != Storage_VSOk)
|
||||
{
|
||||
myErrorStatusExt = "EndWriteCommentSection";
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
TCollection_AsciiString StdStorage_HeaderData::CreationDate() const
|
||||
{
|
||||
return myDate;
|
||||
}
|
||||
|
||||
void StdStorage_HeaderData::SetSchemaVersion(const TCollection_AsciiString& aVersion)
|
||||
{
|
||||
mySchemaVersion = aVersion;
|
||||
}
|
||||
|
||||
TCollection_AsciiString StdStorage_HeaderData::SchemaVersion() const
|
||||
{
|
||||
return mySchemaVersion;
|
||||
}
|
||||
|
||||
void StdStorage_HeaderData::SetSchemaName(const TCollection_AsciiString& aSchemaName)
|
||||
{
|
||||
mySchemaName = aSchemaName;
|
||||
}
|
||||
|
||||
void StdStorage_HeaderData::SetApplicationVersion(const TCollection_AsciiString& aVersion)
|
||||
{
|
||||
myApplicationVersion = aVersion;
|
||||
}
|
||||
|
||||
TCollection_AsciiString StdStorage_HeaderData::ApplicationVersion() const
|
||||
{
|
||||
return myApplicationVersion;
|
||||
}
|
||||
|
||||
void StdStorage_HeaderData::SetApplicationName(const TCollection_ExtendedString& aName)
|
||||
{
|
||||
myApplicationName = aName;
|
||||
}
|
||||
|
||||
TCollection_ExtendedString StdStorage_HeaderData::ApplicationName() const
|
||||
{
|
||||
return myApplicationName;
|
||||
}
|
||||
|
||||
void StdStorage_HeaderData::SetDataType(const TCollection_ExtendedString& aName)
|
||||
{
|
||||
myDataType = aName;
|
||||
}
|
||||
|
||||
TCollection_ExtendedString StdStorage_HeaderData::DataType() const
|
||||
{
|
||||
return myDataType;
|
||||
}
|
||||
|
||||
void StdStorage_HeaderData::AddToUserInfo(const TCollection_AsciiString& theUserInfo)
|
||||
{
|
||||
myUserInfo.Append(theUserInfo);
|
||||
}
|
||||
|
||||
const TColStd_SequenceOfAsciiString& StdStorage_HeaderData::UserInfo() const
|
||||
{
|
||||
return myUserInfo;
|
||||
}
|
||||
|
||||
void StdStorage_HeaderData::AddToComments(const TCollection_ExtendedString& aComments)
|
||||
{
|
||||
myComments.Append(aComments);
|
||||
}
|
||||
|
||||
const TColStd_SequenceOfExtendedString& StdStorage_HeaderData::Comments() const
|
||||
{
|
||||
return myComments;
|
||||
}
|
||||
|
||||
Standard_Integer StdStorage_HeaderData::NumberOfObjects() const
|
||||
{
|
||||
return myNBObj;
|
||||
}
|
||||
|
||||
void StdStorage_HeaderData::SetNumberOfObjects(const Standard_Integer anObjectNumber)
|
||||
{
|
||||
myNBObj = anObjectNumber;
|
||||
}
|
||||
|
||||
void StdStorage_HeaderData::SetStorageVersion(const TCollection_AsciiString& v)
|
||||
{
|
||||
myStorageVersion = v;
|
||||
}
|
||||
|
||||
void StdStorage_HeaderData::SetCreationDate(const TCollection_AsciiString& d)
|
||||
{
|
||||
myDate = d;
|
||||
}
|
||||
|
||||
TCollection_AsciiString StdStorage_HeaderData::StorageVersion() const
|
||||
{
|
||||
return myStorageVersion;
|
||||
}
|
||||
|
||||
Storage_Error StdStorage_HeaderData::ErrorStatus() const
|
||||
{
|
||||
return myErrorStatus;
|
||||
}
|
||||
|
||||
void StdStorage_HeaderData::SetErrorStatus(const Storage_Error anError)
|
||||
{
|
||||
myErrorStatus = anError;
|
||||
}
|
||||
|
||||
TCollection_AsciiString StdStorage_HeaderData::ErrorStatusExtension() const
|
||||
{
|
||||
return myErrorStatusExt;
|
||||
}
|
||||
|
||||
void StdStorage_HeaderData::SetErrorStatusExtension(const TCollection_AsciiString& anErrorExt)
|
||||
{
|
||||
myErrorStatusExt = anErrorExt;
|
||||
}
|
||||
|
||||
void StdStorage_HeaderData::ClearErrorStatus()
|
||||
{
|
||||
myErrorStatus = Storage_VSOk;
|
||||
myErrorStatusExt.Clear();
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user