1 // Copyright (c) 2015 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
15 #ifndef _ShapePersistent_BRep_HeaderFile
16 #define _ShapePersistent_BRep_HeaderFile
18 #include <ShapePersistent_TopoDS.hxx>
19 #include <ShapePersistent_Geom.hxx>
20 #include <ShapePersistent_Geom2d.hxx>
21 #include <ShapePersistent_Poly.hxx>
22 #include <StdObjMgt_TransientPersistentMap.hxx>
23 #include <StdObject_Location.hxx>
24 #include <StdObject_gp_Vectors.hxx>
26 #include <BRep_ListOfPointRepresentation.hxx>
27 #include <BRep_ListOfCurveRepresentation.hxx>
30 #include <gp_Pnt2d.hxx>
32 class BRep_PointRepresentation;
33 class BRep_CurveRepresentation;
38 class ShapePersistent_BRep : public ShapePersistent_TopoDS
41 class PointRepresentation : public StdObjMgt_Persistent
43 friend class ShapePersistent_BRep;
46 //! Empty constructor.
51 //! Read persistent data from a file.
52 Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
53 //! Write persistent data to a file.
54 Standard_EXPORT virtual void Write(StdObjMgt_WriteData& theWriteData) const;
55 //! Gets persistent child objects
56 virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
57 //! Returns persistent type name
58 virtual Standard_CString PName() const { return "PBRep_PointRepresentation"; }
59 //! Import transient object from the persistent data.
60 Standard_EXPORT void Import (BRep_ListOfPointRepresentation& thePoints) const;
63 virtual Handle(BRep_PointRepresentation) import() const;
66 StdObject_Location myLocation;
67 Standard_Real myParameter;
70 Handle(PointRepresentation) myNext;
73 class PointOnCurve : public PointRepresentation
75 friend class ShapePersistent_BRep;
78 virtual void Read (StdObjMgt_ReadData& theReadData);
79 virtual void Write (StdObjMgt_WriteData& theWriteData) const;
80 virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
81 virtual Standard_CString PName() const { return "PBRep_PointOnCurve"; }
82 virtual Handle(BRep_PointRepresentation) import() const;
85 Handle(ShapePersistent_Geom::Curve) myCurve;
88 class PointsOnSurface : public PointRepresentation
90 friend class ShapePersistent_BRep;
93 virtual void Read (StdObjMgt_ReadData& theReadData);
94 virtual void Write (StdObjMgt_WriteData& theWriteData) const;
95 virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
96 virtual Standard_CString PName() const { return "PBRep_PointsOnSurface"; }
99 Handle(ShapePersistent_Geom::Surface) mySurface;
102 class PointOnCurveOnSurface : public PointsOnSurface
104 friend class ShapePersistent_BRep;
107 virtual void Read (StdObjMgt_ReadData& theReadData);
108 virtual void Write (StdObjMgt_WriteData& theWriteData) const;
109 virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
110 virtual Standard_CString PName() const { return "PBRep_PointOnCurveOnSurface"; }
111 virtual Handle(BRep_PointRepresentation) import() const;
114 Handle(ShapePersistent_Geom2d::Curve) myPCurve;
117 class PointOnSurface : public PointsOnSurface
119 friend class ShapePersistent_BRep;
126 virtual void Read (StdObjMgt_ReadData& theReadData);
127 virtual void Write (StdObjMgt_WriteData& theWriteData) const;
128 virtual Standard_CString PName() const { return "PBRep_PointOnSurface"; }
129 virtual Handle(BRep_PointRepresentation) import() const;
132 Standard_Real myParameter2;
135 class CurveRepresentation : public StdObjMgt_Persistent
137 friend class ShapePersistent_BRep;
140 //! Read persistent data from a file.
141 Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
142 //! Write persistent data from a file.
143 Standard_EXPORT virtual void Write (StdObjMgt_WriteData& theWriteData) const;
144 //! Gets persistent child objects
145 virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
146 //! Returns persistent type name
147 virtual Standard_CString PName() const { return "PBRep_CurveRepresentation"; }
148 //! Import transient object from the persistent data.
149 Standard_EXPORT void Import (BRep_ListOfCurveRepresentation& theCurves) const;
152 virtual Handle(BRep_CurveRepresentation) import() const;
155 StdObject_Location myLocation;
158 Handle(CurveRepresentation) myNext;
161 class GCurve : public CurveRepresentation
163 friend class ShapePersistent_BRep;
171 virtual void Read (StdObjMgt_ReadData& theReadData);
172 virtual void Write (StdObjMgt_WriteData& theWriteData) const;
173 virtual Standard_CString PName() const { return "PBRep_GCurve"; }
176 Standard_Real myFirst;
177 Standard_Real myLast;
180 class Curve3D : public GCurve
182 friend class ShapePersistent_BRep;
185 virtual void Read (StdObjMgt_ReadData& theReadData);
186 virtual void Write (StdObjMgt_WriteData& theWriteData) const;
187 virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
188 virtual Standard_CString PName() const { return "PBRep_Curve3D"; }
189 virtual Handle(BRep_CurveRepresentation) import() const;
192 Handle(ShapePersistent_Geom::Curve) myCurve3D;
195 class CurveOnSurface : public GCurve
197 friend class ShapePersistent_BRep;
200 virtual void Read (StdObjMgt_ReadData& theReadData);
201 virtual void Write (StdObjMgt_WriteData& theWriteData) const;
202 virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
203 virtual Standard_CString PName() const { return "PBRep_CurveOnSurface"; }
204 virtual Handle(BRep_CurveRepresentation) import() const;
207 Handle(ShapePersistent_Geom2d::Curve) myPCurve;
208 Handle(ShapePersistent_Geom::Surface) mySurface;
213 class CurveOnClosedSurface : public CurveOnSurface
215 friend class ShapePersistent_BRep;
218 CurveOnClosedSurface()
222 virtual void Read (StdObjMgt_ReadData& theReadData);
223 virtual void Write (StdObjMgt_WriteData& theWriteData) const;
224 virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
225 virtual Standard_CString PName() const { return "PBRep_CurveOnClosedSurface"; }
226 virtual Handle(BRep_CurveRepresentation) import() const;
229 Handle(ShapePersistent_Geom2d::Curve) myPCurve2;
230 Standard_Integer myContinuity;
235 class Polygon3D : public CurveRepresentation
237 friend class ShapePersistent_BRep;
240 virtual void Read (StdObjMgt_ReadData& theReadData);
241 virtual void Write (StdObjMgt_WriteData& theWriteData) const;
242 virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
243 virtual Standard_CString PName() const { return "PBRep_Polygon3D"; }
244 virtual Handle(BRep_CurveRepresentation) import() const;
247 Handle(ShapePersistent_Poly::Polygon3D) myPolygon3D;
250 class PolygonOnTriangulation : public CurveRepresentation
252 friend class ShapePersistent_BRep;
255 virtual void Read (StdObjMgt_ReadData& theReadData);
256 virtual void Write (StdObjMgt_WriteData& theWriteData) const;
257 virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
258 virtual Standard_CString PName() const { return "PBRep_PolygonOnTriangulation"; }
259 virtual Handle(BRep_CurveRepresentation) import() const;
262 Handle(ShapePersistent_Poly::PolygonOnTriangulation) myPolygon;
263 Handle(ShapePersistent_Poly::Triangulation) myTriangulation;
266 class PolygonOnClosedTriangulation : public PolygonOnTriangulation
268 friend class ShapePersistent_BRep;
271 virtual void Read (StdObjMgt_ReadData& theReadData);
272 virtual void Write (StdObjMgt_WriteData& theWriteData) const;
273 virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
274 virtual Standard_CString PName() const { return "PBRep_PolygonOnClosedTriangulation"; }
275 virtual Handle(BRep_CurveRepresentation) import() const;
278 Handle(ShapePersistent_Poly::PolygonOnTriangulation) myPolygon2;
281 class PolygonOnSurface : public CurveRepresentation
283 friend class ShapePersistent_BRep;
286 virtual void Read (StdObjMgt_ReadData& theReadData);
287 virtual void Write (StdObjMgt_WriteData& theWriteData) const;
288 virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
289 virtual Standard_CString PName() const { return "PBRep_PolygonOnSurface"; }
290 virtual Handle(BRep_CurveRepresentation) import() const;
293 Handle(ShapePersistent_Poly::Polygon2D) myPolygon2D;
294 Handle(ShapePersistent_Geom::Surface) mySurface;
297 class PolygonOnClosedSurface : public PolygonOnSurface
299 friend class ShapePersistent_BRep;
302 virtual void Read (StdObjMgt_ReadData& theReadData);
303 virtual void Write (StdObjMgt_WriteData& theWriteData) const;
304 virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
305 virtual Standard_CString PName() const { return "PBRep_PolygonOnClosedSurface"; }
306 virtual Handle(BRep_CurveRepresentation) import() const;
309 Handle(ShapePersistent_Poly::Polygon2D) myPolygon2;
312 class CurveOn2Surfaces : public CurveRepresentation
314 friend class ShapePersistent_BRep;
321 virtual void Read (StdObjMgt_ReadData& theReadData);
322 virtual void Write (StdObjMgt_WriteData& theWriteData) const;
323 virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
324 virtual Standard_CString PName() const { return "PBRep_CurveOn2Surfaces"; }
325 virtual Handle(BRep_CurveRepresentation) import() const;
328 Handle(ShapePersistent_Geom::Surface) mySurface;
329 Handle(ShapePersistent_Geom::Surface) mySurface2;
330 StdObject_Location myLocation2;
331 Standard_Integer myContinuity;
335 class pTVertex : public pTBase
337 friend class ShapePersistent_BRep;
344 inline void Read (StdObjMgt_ReadData& theReadData)
346 pTBase::Read (theReadData);
347 theReadData >> myTolerance >> myPnt >> myPoints;
349 inline void Write (StdObjMgt_WriteData& theWriteData) const
351 pTBase::Write (theWriteData);
352 theWriteData << myTolerance << myPnt << myPoints;
354 inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
356 pTBase::PChildren(theChildren);
357 theChildren.Append(myPoints);
359 inline Standard_CString PName() const
360 { return "PBRep_TVertex"; }
363 virtual Handle(TopoDS_TShape) createTShape() const;
366 Standard_Real myTolerance;
368 Handle(PointRepresentation) myPoints;
371 class pTEdge : public pTBase
373 friend class ShapePersistent_BRep;
381 inline void Read (StdObjMgt_ReadData& theReadData)
383 pTBase::Read (theReadData);
384 theReadData >> myTolerance >> myFlags >> myCurves;
386 inline void Write (StdObjMgt_WriteData& theWriteData) const
388 pTBase::Write (theWriteData);
389 theWriteData << myTolerance << myFlags << myCurves;
391 inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
393 pTBase::PChildren(theChildren);
394 theChildren.Append(myCurves);
396 inline Standard_CString PName() const
397 { return "PBRep_TEdge"; }
400 virtual Handle(TopoDS_TShape) createTShape() const;
403 Standard_Real myTolerance;
404 Standard_Integer myFlags;
405 Handle(CurveRepresentation) myCurves;
408 class pTFace : public pTBase
410 friend class ShapePersistent_BRep;
415 myNaturalRestriction(Standard_False)
418 inline void Read (StdObjMgt_ReadData& theReadData)
420 pTBase::Read (theReadData);
421 theReadData >> mySurface >> myTriangulation >> myLocation;
422 theReadData >> myTolerance >> myNaturalRestriction;
424 inline void Write (StdObjMgt_WriteData& theWriteData) const
426 pTBase::Write (theWriteData);
427 theWriteData << mySurface << myTriangulation << myLocation;
428 theWriteData << myTolerance << myNaturalRestriction;
430 inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
432 pTBase::PChildren(theChildren);
433 theChildren.Append(mySurface);
434 theChildren.Append(myTriangulation);
435 myLocation.PChildren(theChildren);
437 inline Standard_CString PName() const
438 { return "PBRep_TFace"; }
441 virtual Handle(TopoDS_TShape) createTShape() const;
444 Handle(ShapePersistent_Geom::Surface) mySurface;
445 Handle(ShapePersistent_Poly::Triangulation) myTriangulation;
446 StdObject_Location myLocation;
447 Standard_Real myTolerance;
448 Standard_Boolean myNaturalRestriction;
452 typedef tObject <pTVertex> TVertex;
453 typedef tObject <pTEdge> TEdge;
454 typedef tObject <pTFace> TFace;
456 typedef tObject1 <pTVertex> TVertex1;
457 typedef tObject1 <pTEdge> TEdge1;
458 typedef tObject1 <pTFace> TFace1;
461 //! Create a persistent object for a vertex
462 Standard_EXPORT static Handle(TVertex::pTObjectT) Translate (const TopoDS_Vertex& theVertex,
463 StdObjMgt_TransientPersistentMap& theMap);
464 //! Create a persistent object for an edge
465 Standard_EXPORT static Handle(TEdge::pTObjectT) Translate (const TopoDS_Edge& theEdge,
466 StdObjMgt_TransientPersistentMap& theMap,
467 ShapePersistent_TriangleMode theTriangleMode);
468 //! Create a persistent object for a face
469 Standard_EXPORT static Handle(TFace::pTObjectT) Translate (const TopoDS_Face& theFace,
470 StdObjMgt_TransientPersistentMap& theMap,
471 ShapePersistent_TriangleMode theTriangleMode);
472 //! Create a persistent object for a point on a 3D curve
473 Standard_EXPORT static Handle(PointOnCurve) Translate(Standard_Real theParam,
474 const Handle(Geom_Curve)& theCurve,
475 const TopLoc_Location& theLoc,
476 StdObjMgt_TransientPersistentMap& theMap);
477 //! Create a persistent object for a point on a 3D curve on a surface
478 Standard_EXPORT static Handle(PointOnCurveOnSurface) Translate (Standard_Real theParam,
479 const Handle(Geom2d_Curve)& theCurve,
480 const Handle(Geom_Surface)& theSurf,
481 const TopLoc_Location& theLoc,
482 StdObjMgt_TransientPersistentMap& theMap);
483 //! Create a persistent object for a point on a surface
484 Standard_EXPORT static Handle(PointOnSurface) Translate (Standard_Real theParam,
485 Standard_Real theParam2,
486 const Handle(Geom_Surface)& theSurf,
487 const TopLoc_Location& theLoc,
488 StdObjMgt_TransientPersistentMap& theMap);
489 //! Create a persistent object for a curve on a surface
490 Standard_EXPORT static Handle(CurveOnSurface) Translate (const Handle(Geom2d_Curve)& theCurve,
491 const Standard_Real theFirstParam,
492 const Standard_Real theLastParam,
493 const Handle(Geom_Surface)& theSurf,
494 const TopLoc_Location& theLoc,
495 StdObjMgt_TransientPersistentMap& theMap);
496 //! Create a persistent object for a curve on a closed surface
497 Standard_EXPORT static Handle(CurveOnClosedSurface) Translate (const Handle(Geom2d_Curve)& theCurve,
498 const Handle(Geom2d_Curve)& theCurve2,
499 const Standard_Real theFirstParam,
500 const Standard_Real theLastParam,
501 const Handle(Geom_Surface)& theSurf,
502 const TopLoc_Location& theLoc,
503 const GeomAbs_Shape theContinuity,
504 StdObjMgt_TransientPersistentMap& theMap);
505 //! Create a persistent object for a curve on two surfaces
506 Standard_EXPORT static Handle(CurveOn2Surfaces) Translate (const Handle(Geom_Surface)& theSurf,
507 const Handle(Geom_Surface)& theSurf2,
508 const TopLoc_Location& theLoc,
509 const TopLoc_Location& theLoc2,
510 const GeomAbs_Shape theContinuity,
511 StdObjMgt_TransientPersistentMap& theMap);
512 //! Create a persistent object for a 3D curve
513 Standard_EXPORT static Handle(Curve3D) Translate (const Handle(Geom_Curve)& theCurve,
514 const Standard_Real theFirstParam,
515 const Standard_Real theLastParam,
516 const TopLoc_Location& theLoc,
517 StdObjMgt_TransientPersistentMap& theMap);
518 //! Create a persistent object for a 3D polygon
519 Standard_EXPORT static Handle(Polygon3D) Translate (const Handle(Poly_Polygon3D)& thePoly,
520 const TopLoc_Location& theLoc,
521 StdObjMgt_TransientPersistentMap& theMap);
522 //! Create a persistent object for a polygon on a closed surface
523 Standard_EXPORT static Handle(PolygonOnClosedSurface) Translate (const Handle(Poly_Polygon2D)& thePoly,
524 const Handle(Poly_Polygon2D)& thePoly2,
525 const Handle(Geom_Surface)& theSurf,
526 const TopLoc_Location& theLoc,
527 StdObjMgt_TransientPersistentMap& theMap);
528 //! Create a persistent object for a polygon on a surface
529 Standard_EXPORT static Handle(PolygonOnSurface) Translate (const Handle(Poly_Polygon2D)& thePoly,
530 const Handle(Geom_Surface)& theSurf,
531 const TopLoc_Location& theLoc,
532 StdObjMgt_TransientPersistentMap& theMap);
533 //! Create a persistent object for a polygon on a surface
534 Standard_EXPORT static Handle(PolygonOnClosedTriangulation) Translate (const Handle(Poly_PolygonOnTriangulation)& thePolyOnTriang,
535 const Handle(Poly_PolygonOnTriangulation)& thePolyOnTriang2,
536 const Handle(Poly_Triangulation)& thePolyTriang,
537 const TopLoc_Location& theLoc,
538 StdObjMgt_TransientPersistentMap& theMap);
539 //! Create a persistent object for a polygon on a surface
540 Standard_EXPORT static Handle(PolygonOnTriangulation) Translate (const Handle(Poly_PolygonOnTriangulation)& thePolyOnTriang,
541 const Handle(Poly_Triangulation)& thePolyTriang,
542 const TopLoc_Location& theLoc,
543 StdObjMgt_TransientPersistentMap& theMap);