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 //! Read persistent data from a file.
47 Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
48 //! Write persistent data to a file.
49 Standard_EXPORT virtual void Write(StdObjMgt_WriteData& theWriteData) const;
50 //! Gets persistent child objects
51 virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
52 //! Returns persistent type name
53 virtual Standard_CString PName() const { return "PBRep_PointRepresentation"; }
54 //! Import transient object from the persistent data.
55 Standard_EXPORT void Import (BRep_ListOfPointRepresentation& thePoints) const;
58 virtual Handle(BRep_PointRepresentation) import() const;
61 StdObject_Location myLocation;
62 Standard_Real myParameter;
65 Handle(PointRepresentation) myNext;
68 class PointOnCurve : public PointRepresentation
70 friend class ShapePersistent_BRep;
73 virtual void Read (StdObjMgt_ReadData& theReadData);
74 virtual void Write (StdObjMgt_WriteData& theWriteData) const;
75 virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
76 virtual Standard_CString PName() const { return "PBRep_PointOnCurve"; }
77 virtual Handle(BRep_PointRepresentation) import() const;
80 Handle(ShapePersistent_Geom::Curve) myCurve;
83 class PointsOnSurface : public PointRepresentation
85 friend class ShapePersistent_BRep;
88 virtual void Read (StdObjMgt_ReadData& theReadData);
89 virtual void Write (StdObjMgt_WriteData& theWriteData) const;
90 virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
91 virtual Standard_CString PName() const { return "PBRep_PointsOnSurface"; }
94 Handle(ShapePersistent_Geom::Surface) mySurface;
97 class PointOnCurveOnSurface : public PointsOnSurface
99 friend class ShapePersistent_BRep;
102 virtual void Read (StdObjMgt_ReadData& theReadData);
103 virtual void Write (StdObjMgt_WriteData& theWriteData) const;
104 virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
105 virtual Standard_CString PName() const { return "PBRep_PointOnCurveOnSurface"; }
106 virtual Handle(BRep_PointRepresentation) import() const;
109 Handle(ShapePersistent_Geom2d::Curve) myPCurve;
112 class PointOnSurface : public PointsOnSurface
114 friend class ShapePersistent_BRep;
117 virtual void Read (StdObjMgt_ReadData& theReadData);
118 virtual void Write (StdObjMgt_WriteData& theWriteData) const;
119 virtual Standard_CString PName() const { return "PBRep_PointOnSurface"; }
120 virtual Handle(BRep_PointRepresentation) import() const;
123 Standard_Real myParameter2;
126 class CurveRepresentation : public StdObjMgt_Persistent
128 friend class ShapePersistent_BRep;
131 //! Read persistent data from a file.
132 Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
133 //! Write persistent data from a file.
134 Standard_EXPORT virtual void Write (StdObjMgt_WriteData& theWriteData) const;
135 //! Gets persistent child objects
136 virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
137 //! Returns persistent type name
138 virtual Standard_CString PName() const { return "PBRep_CurveRepresentation"; }
139 //! Import transient object from the persistent data.
140 Standard_EXPORT void Import (BRep_ListOfCurveRepresentation& theCurves) const;
143 virtual Handle(BRep_CurveRepresentation) import() const;
146 StdObject_Location myLocation;
149 Handle(CurveRepresentation) myNext;
152 class GCurve : public CurveRepresentation
154 friend class ShapePersistent_BRep;
157 virtual void Read (StdObjMgt_ReadData& theReadData);
158 virtual void Write (StdObjMgt_WriteData& theWriteData) const;
159 virtual Standard_CString PName() const { return "PBRep_GCurve"; }
162 Standard_Real myFirst;
163 Standard_Real myLast;
166 class Curve3D : public GCurve
168 friend class ShapePersistent_BRep;
171 virtual void Read (StdObjMgt_ReadData& theReadData);
172 virtual void Write (StdObjMgt_WriteData& theWriteData) const;
173 virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
174 virtual Standard_CString PName() const { return "PBRep_Curve3D"; }
175 virtual Handle(BRep_CurveRepresentation) import() const;
178 Handle(ShapePersistent_Geom::Curve) myCurve3D;
181 class CurveOnSurface : public GCurve
183 friend class ShapePersistent_BRep;
186 virtual void Read (StdObjMgt_ReadData& theReadData);
187 virtual void Write (StdObjMgt_WriteData& theWriteData) const;
188 virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
189 virtual Standard_CString PName() const { return "PBRep_CurveOnSurface"; }
190 virtual Handle(BRep_CurveRepresentation) import() const;
193 Handle(ShapePersistent_Geom2d::Curve) myPCurve;
194 Handle(ShapePersistent_Geom::Surface) mySurface;
199 class CurveOnClosedSurface : public CurveOnSurface
201 friend class ShapePersistent_BRep;
204 virtual void Read (StdObjMgt_ReadData& theReadData);
205 virtual void Write (StdObjMgt_WriteData& theWriteData) const;
206 virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
207 virtual Standard_CString PName() const { return "PBRep_CurveOnClosedSurface"; }
208 virtual Handle(BRep_CurveRepresentation) import() const;
211 Handle(ShapePersistent_Geom2d::Curve) myPCurve2;
212 Standard_Integer myContinuity;
217 class Polygon3D : public CurveRepresentation
219 friend class ShapePersistent_BRep;
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_Polygon3D"; }
226 virtual Handle(BRep_CurveRepresentation) import() const;
229 Handle(ShapePersistent_Poly::Polygon3D) myPolygon3D;
232 class PolygonOnTriangulation : public CurveRepresentation
234 friend class ShapePersistent_BRep;
237 virtual void Read (StdObjMgt_ReadData& theReadData);
238 virtual void Write (StdObjMgt_WriteData& theWriteData) const;
239 virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
240 virtual Standard_CString PName() const { return "PBRep_PolygonOnTriangulation"; }
241 virtual Handle(BRep_CurveRepresentation) import() const;
244 Handle(ShapePersistent_Poly::PolygonOnTriangulation) myPolygon;
245 Handle(ShapePersistent_Poly::Triangulation) myTriangulation;
248 class PolygonOnClosedTriangulation : public PolygonOnTriangulation
250 friend class ShapePersistent_BRep;
253 virtual void Read (StdObjMgt_ReadData& theReadData);
254 virtual void Write (StdObjMgt_WriteData& theWriteData) const;
255 virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
256 virtual Standard_CString PName() const { return "PBRep_PolygonOnClosedTriangulation"; }
257 virtual Handle(BRep_CurveRepresentation) import() const;
260 Handle(ShapePersistent_Poly::PolygonOnTriangulation) myPolygon2;
263 class PolygonOnSurface : public CurveRepresentation
265 friend class ShapePersistent_BRep;
268 virtual void Read (StdObjMgt_ReadData& theReadData);
269 virtual void Write (StdObjMgt_WriteData& theWriteData) const;
270 virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
271 virtual Standard_CString PName() const { return "PBRep_PolygonOnSurface"; }
272 virtual Handle(BRep_CurveRepresentation) import() const;
275 Handle(ShapePersistent_Poly::Polygon2D) myPolygon2D;
276 Handle(ShapePersistent_Geom::Surface) mySurface;
279 class PolygonOnClosedSurface : public PolygonOnSurface
281 friend class ShapePersistent_BRep;
284 virtual void Read (StdObjMgt_ReadData& theReadData);
285 virtual void Write (StdObjMgt_WriteData& theWriteData) const;
286 virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
287 virtual Standard_CString PName() const { return "PBRep_PolygonOnClosedSurface"; }
288 virtual Handle(BRep_CurveRepresentation) import() const;
291 Handle(ShapePersistent_Poly::Polygon2D) myPolygon2;
294 class CurveOn2Surfaces : public CurveRepresentation
296 friend class ShapePersistent_BRep;
299 virtual void Read (StdObjMgt_ReadData& theReadData);
300 virtual void Write (StdObjMgt_WriteData& theWriteData) const;
301 virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
302 virtual Standard_CString PName() const { return "PBRep_CurveOn2Surfaces"; }
303 virtual Handle(BRep_CurveRepresentation) import() const;
306 Handle(ShapePersistent_Geom::Surface) mySurface;
307 Handle(ShapePersistent_Geom::Surface) mySurface2;
308 StdObject_Location myLocation2;
309 Standard_Integer myContinuity;
313 class pTVertex : public pTBase
315 friend class ShapePersistent_BRep;
318 inline void Read (StdObjMgt_ReadData& theReadData)
320 pTBase::Read (theReadData);
321 theReadData >> myTolerance >> myPnt >> myPoints;
323 inline void Write (StdObjMgt_WriteData& theWriteData) const
325 pTBase::Write (theWriteData);
326 theWriteData << myTolerance << myPnt << myPoints;
328 inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
330 pTBase::PChildren(theChildren);
331 theChildren.Append(myPoints);
333 inline Standard_CString PName() const
334 { return "PBRep_TVertex"; }
337 virtual Handle(TopoDS_TShape) createTShape() const;
340 Standard_Real myTolerance;
342 Handle(PointRepresentation) myPoints;
345 class pTEdge : public pTBase
347 friend class ShapePersistent_BRep;
350 inline void Read (StdObjMgt_ReadData& theReadData)
352 pTBase::Read (theReadData);
353 theReadData >> myTolerance >> myFlags >> myCurves;
355 inline void Write (StdObjMgt_WriteData& theWriteData) const
357 pTBase::Write (theWriteData);
358 theWriteData << myTolerance << myFlags << myCurves;
360 inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
362 pTBase::PChildren(theChildren);
363 theChildren.Append(myCurves);
365 inline Standard_CString PName() const
366 { return "PBRep_TEdge"; }
369 virtual Handle(TopoDS_TShape) createTShape() const;
372 Standard_Real myTolerance;
373 Standard_Integer myFlags;
374 Handle(CurveRepresentation) myCurves;
377 class pTFace : public pTBase
379 friend class ShapePersistent_BRep;
382 inline void Read (StdObjMgt_ReadData& theReadData)
384 pTBase::Read (theReadData);
385 theReadData >> mySurface >> myTriangulation >> myLocation;
386 theReadData >> myTolerance >> myNaturalRestriction;
388 inline void Write (StdObjMgt_WriteData& theWriteData) const
390 pTBase::Write (theWriteData);
391 theWriteData << mySurface << myTriangulation << myLocation;
392 theWriteData << myTolerance << myNaturalRestriction;
394 inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
396 pTBase::PChildren(theChildren);
397 theChildren.Append(mySurface);
398 theChildren.Append(myTriangulation);
399 myLocation.PChildren(theChildren);
401 inline Standard_CString PName() const
402 { return "PBRep_TFace"; }
405 virtual Handle(TopoDS_TShape) createTShape() const;
408 Handle(ShapePersistent_Geom::Surface) mySurface;
409 Handle(ShapePersistent_Poly::Triangulation) myTriangulation;
410 StdObject_Location myLocation;
411 Standard_Real myTolerance;
412 Standard_Boolean myNaturalRestriction;
416 typedef tObject <pTVertex> TVertex;
417 typedef tObject <pTEdge> TEdge;
418 typedef tObject <pTFace> TFace;
420 typedef tObject1 <pTVertex> TVertex1;
421 typedef tObject1 <pTEdge> TEdge1;
422 typedef tObject1 <pTFace> TFace1;
425 //! Create a persistent object for a vertex
426 Standard_EXPORT static Handle(TVertex::pTObjectT) Translate (const TopoDS_Vertex& theVertex,
427 StdObjMgt_TransientPersistentMap& theMap);
428 //! Create a persistent object for an edge
429 Standard_EXPORT static Handle(TEdge::pTObjectT) Translate (const TopoDS_Edge& theEdge,
430 StdObjMgt_TransientPersistentMap& theMap,
431 ShapePersistent_TriangleMode theTriangleMode);
432 //! Create a persistent object for a face
433 Standard_EXPORT static Handle(TFace::pTObjectT) Translate (const TopoDS_Face& theFace,
434 StdObjMgt_TransientPersistentMap& theMap,
435 ShapePersistent_TriangleMode theTriangleMode);
436 //! Create a persistent object for a point on a 3D curve
437 Standard_EXPORT static Handle(PointOnCurve) Translate(Standard_Real theParam,
438 const Handle(Geom_Curve)& theCurve,
439 const TopLoc_Location& theLoc,
440 StdObjMgt_TransientPersistentMap& theMap);
441 //! Create a persistent object for a point on a 3D curve on a surface
442 Standard_EXPORT static Handle(PointOnCurveOnSurface) Translate (Standard_Real theParam,
443 const Handle(Geom2d_Curve)& theCurve,
444 const Handle(Geom_Surface)& theSurf,
445 const TopLoc_Location& theLoc,
446 StdObjMgt_TransientPersistentMap& theMap);
447 //! Create a persistent object for a point on a surface
448 Standard_EXPORT static Handle(PointOnSurface) Translate (Standard_Real theParam,
449 Standard_Real theParam2,
450 const Handle(Geom_Surface)& theSurf,
451 const TopLoc_Location& theLoc,
452 StdObjMgt_TransientPersistentMap& theMap);
453 //! Create a persistent object for a curve on a surface
454 Standard_EXPORT static Handle(CurveOnSurface) Translate (const Handle(Geom2d_Curve)& theCurve,
455 const Standard_Real theFirstParam,
456 const Standard_Real theLastParam,
457 const Handle(Geom_Surface)& theSurf,
458 const TopLoc_Location& theLoc,
459 StdObjMgt_TransientPersistentMap& theMap);
460 //! Create a persistent object for a curve on a closed surface
461 Standard_EXPORT static Handle(CurveOnClosedSurface) Translate (const Handle(Geom2d_Curve)& theCurve,
462 const Handle(Geom2d_Curve)& theCurve2,
463 const Standard_Real theFirstParam,
464 const Standard_Real theLastParam,
465 const Handle(Geom_Surface)& theSurf,
466 const TopLoc_Location& theLoc,
467 const GeomAbs_Shape theContinuity,
468 StdObjMgt_TransientPersistentMap& theMap);
469 //! Create a persistent object for a curve on two surfaces
470 Standard_EXPORT static Handle(CurveOn2Surfaces) Translate (const Handle(Geom_Surface)& theSurf,
471 const Handle(Geom_Surface)& theSurf2,
472 const TopLoc_Location& theLoc,
473 const TopLoc_Location& theLoc2,
474 const GeomAbs_Shape theContinuity,
475 StdObjMgt_TransientPersistentMap& theMap);
476 //! Create a persistent object for a 3D curve
477 Standard_EXPORT static Handle(Curve3D) Translate (const Handle(Geom_Curve)& theCurve,
478 const Standard_Real theFirstParam,
479 const Standard_Real theLastParam,
480 const TopLoc_Location& theLoc,
481 StdObjMgt_TransientPersistentMap& theMap);
482 //! Create a persistent object for a 3D polygon
483 Standard_EXPORT static Handle(Polygon3D) Translate (const Handle(Poly_Polygon3D)& thePoly,
484 const TopLoc_Location& theLoc,
485 StdObjMgt_TransientPersistentMap& theMap);
486 //! Create a persistent object for a polygon on a closed surface
487 Standard_EXPORT static Handle(PolygonOnClosedSurface) Translate (const Handle(Poly_Polygon2D)& thePoly,
488 const Handle(Poly_Polygon2D)& thePoly2,
489 const Handle(Geom_Surface)& theSurf,
490 const TopLoc_Location& theLoc,
491 StdObjMgt_TransientPersistentMap& theMap);
492 //! Create a persistent object for a polygon on a surface
493 Standard_EXPORT static Handle(PolygonOnSurface) Translate (const Handle(Poly_Polygon2D)& thePoly,
494 const Handle(Geom_Surface)& theSurf,
495 const TopLoc_Location& theLoc,
496 StdObjMgt_TransientPersistentMap& theMap);
497 //! Create a persistent object for a polygon on a surface
498 Standard_EXPORT static Handle(PolygonOnClosedTriangulation) Translate (const Handle(Poly_PolygonOnTriangulation)& thePolyOnTriang,
499 const Handle(Poly_PolygonOnTriangulation)& thePolyOnTriang2,
500 const Handle(Poly_Triangulation)& thePolyTriang,
501 const TopLoc_Location& theLoc,
502 StdObjMgt_TransientPersistentMap& theMap);
503 //! Create a persistent object for a polygon on a surface
504 Standard_EXPORT static Handle(PolygonOnTriangulation) Translate (const Handle(Poly_PolygonOnTriangulation)& thePolyOnTriang,
505 const Handle(Poly_Triangulation)& thePolyTriang,
506 const TopLoc_Location& theLoc,
507 StdObjMgt_TransientPersistentMap& theMap);