0030675: Visualization - remove redundant proxy classes in hierarchy of PrsMgr_Presen...
[occt.git] / src / ShapePersistent / ShapePersistent_BRep.hxx
CommitLineData
ff205346 1// Copyright (c) 2015 OPEN CASCADE SAS
2//
3// This file is part of Open CASCADE Technology software library.
4//
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.
10//
11// Alternatively, this file may be used under the terms of Open CASCADE
12// commercial license or contractual agreement.
13
14
15#ifndef _ShapePersistent_BRep_HeaderFile
16#define _ShapePersistent_BRep_HeaderFile
17
18#include <ShapePersistent_TopoDS.hxx>
19#include <ShapePersistent_Geom.hxx>
20#include <ShapePersistent_Geom2d.hxx>
21#include <ShapePersistent_Poly.hxx>
ec964372 22#include <StdObjMgt_TransientPersistentMap.hxx>
ff205346 23#include <StdObject_Location.hxx>
45d8465e 24#include <StdObject_gp_Vectors.hxx>
ff205346 25
26#include <BRep_ListOfPointRepresentation.hxx>
27#include <BRep_ListOfCurveRepresentation.hxx>
28
29#include <gp_Pnt.hxx>
30#include <gp_Pnt2d.hxx>
ff205346 31
32class BRep_PointRepresentation;
33class BRep_CurveRepresentation;
ec964372 34class TopoDS_Vertex;
35class TopoDS_Edge;
36class TopoDS_Face;
ff205346 37
38class ShapePersistent_BRep : public ShapePersistent_TopoDS
39{
40public:
41 class PointRepresentation : public StdObjMgt_Persistent
42 {
ec964372 43 friend class ShapePersistent_BRep;
44
ff205346 45 public:
46 //! Read persistent data from a file.
47 Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
ec964372 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"; }
ff205346 54 //! Import transient object from the persistent data.
ec964372 55 Standard_EXPORT void Import (BRep_ListOfPointRepresentation& thePoints) const;
ff205346 56
57 protected:
58 virtual Handle(BRep_PointRepresentation) import() const;
59
60 protected:
45d8465e 61 StdObject_Location myLocation;
62 Standard_Real myParameter;
ff205346 63
64 private:
45d8465e 65 Handle(PointRepresentation) myNext;
ff205346 66 };
67
68 class PointOnCurve : public PointRepresentation
69 {
ec964372 70 friend class ShapePersistent_BRep;
71
ff205346 72 public:
73 virtual void Read (StdObjMgt_ReadData& theReadData);
ec964372 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"; }
ff205346 77 virtual Handle(BRep_PointRepresentation) import() const;
78
79 private:
45d8465e 80 Handle(ShapePersistent_Geom::Curve) myCurve;
ff205346 81 };
82
83 class PointsOnSurface : public PointRepresentation
84 {
ec964372 85 friend class ShapePersistent_BRep;
86
ff205346 87 public:
88 virtual void Read (StdObjMgt_ReadData& theReadData);
ec964372 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"; }
ff205346 92
93 protected:
45d8465e 94 Handle(ShapePersistent_Geom::Surface) mySurface;
ff205346 95 };
96
97 class PointOnCurveOnSurface : public PointsOnSurface
98 {
ec964372 99 friend class ShapePersistent_BRep;
100
ff205346 101 public:
102 virtual void Read (StdObjMgt_ReadData& theReadData);
ec964372 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"; }
ff205346 106 virtual Handle(BRep_PointRepresentation) import() const;
107
108 private:
45d8465e 109 Handle(ShapePersistent_Geom2d::Curve) myPCurve;
ff205346 110 };
111
112 class PointOnSurface : public PointsOnSurface
113 {
ec964372 114 friend class ShapePersistent_BRep;
115
ff205346 116 public:
117 virtual void Read (StdObjMgt_ReadData& theReadData);
ec964372 118 virtual void Write (StdObjMgt_WriteData& theWriteData) const;
119 virtual Standard_CString PName() const { return "PBRep_PointOnSurface"; }
ff205346 120 virtual Handle(BRep_PointRepresentation) import() const;
121
122 private:
45d8465e 123 Standard_Real myParameter2;
ff205346 124 };
125
126 class CurveRepresentation : public StdObjMgt_Persistent
127 {
ec964372 128 friend class ShapePersistent_BRep;
129
ff205346 130 public:
131 //! Read persistent data from a file.
132 Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
ec964372 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"; }
ff205346 139 //! Import transient object from the persistent data.
ec964372 140 Standard_EXPORT void Import (BRep_ListOfCurveRepresentation& theCurves) const;
ff205346 141
142 protected:
143 virtual Handle(BRep_CurveRepresentation) import() const;
144
145 protected:
45d8465e 146 StdObject_Location myLocation;
ff205346 147
148 private:
45d8465e 149 Handle(CurveRepresentation) myNext;
ff205346 150 };
151
152 class GCurve : public CurveRepresentation
153 {
ec964372 154 friend class ShapePersistent_BRep;
155
ff205346 156 public:
157 virtual void Read (StdObjMgt_ReadData& theReadData);
ec964372 158 virtual void Write (StdObjMgt_WriteData& theWriteData) const;
159 virtual Standard_CString PName() const { return "PBRep_GCurve"; }
ff205346 160
161 protected:
45d8465e 162 Standard_Real myFirst;
163 Standard_Real myLast;
ff205346 164 };
165
166 class Curve3D : public GCurve
167 {
ec964372 168 friend class ShapePersistent_BRep;
169
ff205346 170 public:
171 virtual void Read (StdObjMgt_ReadData& theReadData);
ec964372 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"; }
ff205346 175 virtual Handle(BRep_CurveRepresentation) import() const;
176
177 private:
45d8465e 178 Handle(ShapePersistent_Geom::Curve) myCurve3D;
ff205346 179 };
180
181 class CurveOnSurface : public GCurve
182 {
ec964372 183 friend class ShapePersistent_BRep;
184
ff205346 185 public:
186 virtual void Read (StdObjMgt_ReadData& theReadData);
ec964372 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"; }
ff205346 190 virtual Handle(BRep_CurveRepresentation) import() const;
191
192 protected:
45d8465e 193 Handle(ShapePersistent_Geom2d::Curve) myPCurve;
194 Handle(ShapePersistent_Geom::Surface) mySurface;
195 gp_Pnt2d myUV1;
196 gp_Pnt2d myUV2;
ff205346 197 };
198
199 class CurveOnClosedSurface : public CurveOnSurface
200 {
ec964372 201 friend class ShapePersistent_BRep;
202
ff205346 203 public:
204 virtual void Read (StdObjMgt_ReadData& theReadData);
ec964372 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"; }
ff205346 208 virtual Handle(BRep_CurveRepresentation) import() const;
209
210 private:
45d8465e 211 Handle(ShapePersistent_Geom2d::Curve) myPCurve2;
212 Standard_Integer myContinuity;
213 gp_Pnt2d myUV21;
214 gp_Pnt2d myUV22;
ff205346 215 };
216
217 class Polygon3D : public CurveRepresentation
218 {
ec964372 219 friend class ShapePersistent_BRep;
220
ff205346 221 public:
222 virtual void Read (StdObjMgt_ReadData& theReadData);
ec964372 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"; }
ff205346 226 virtual Handle(BRep_CurveRepresentation) import() const;
227
228 private:
45d8465e 229 Handle(ShapePersistent_Poly::Polygon3D) myPolygon3D;
ff205346 230 };
231
232 class PolygonOnTriangulation : public CurveRepresentation
233 {
ec964372 234 friend class ShapePersistent_BRep;
235
ff205346 236 public:
237 virtual void Read (StdObjMgt_ReadData& theReadData);
ec964372 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"; }
ff205346 241 virtual Handle(BRep_CurveRepresentation) import() const;
242
243 protected:
45d8465e 244 Handle(ShapePersistent_Poly::PolygonOnTriangulation) myPolygon;
245 Handle(ShapePersistent_Poly::Triangulation) myTriangulation;
ff205346 246 };
247
248 class PolygonOnClosedTriangulation : public PolygonOnTriangulation
249 {
ec964372 250 friend class ShapePersistent_BRep;
251
ff205346 252 public:
253 virtual void Read (StdObjMgt_ReadData& theReadData);
ec964372 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"; }
ff205346 257 virtual Handle(BRep_CurveRepresentation) import() const;
258
259 private:
45d8465e 260 Handle(ShapePersistent_Poly::PolygonOnTriangulation) myPolygon2;
ff205346 261 };
262
263 class PolygonOnSurface : public CurveRepresentation
264 {
ec964372 265 friend class ShapePersistent_BRep;
266
ff205346 267 public:
268 virtual void Read (StdObjMgt_ReadData& theReadData);
ec964372 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"; }
ff205346 272 virtual Handle(BRep_CurveRepresentation) import() const;
273
274 protected:
45d8465e 275 Handle(ShapePersistent_Poly::Polygon2D) myPolygon2D;
276 Handle(ShapePersistent_Geom::Surface) mySurface;
ff205346 277 };
278
279 class PolygonOnClosedSurface : public PolygonOnSurface
280 {
ec964372 281 friend class ShapePersistent_BRep;
282
ff205346 283 public:
284 virtual void Read (StdObjMgt_ReadData& theReadData);
ec964372 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"; }
ff205346 288 virtual Handle(BRep_CurveRepresentation) import() const;
289
290 private:
45d8465e 291 Handle(ShapePersistent_Poly::Polygon2D) myPolygon2;
ff205346 292 };
293
294 class CurveOn2Surfaces : public CurveRepresentation
295 {
ec964372 296 friend class ShapePersistent_BRep;
297
ff205346 298 public:
299 virtual void Read (StdObjMgt_ReadData& theReadData);
ec964372 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"; }
ff205346 303 virtual Handle(BRep_CurveRepresentation) import() const;
304
305 private:
45d8465e 306 Handle(ShapePersistent_Geom::Surface) mySurface;
307 Handle(ShapePersistent_Geom::Surface) mySurface2;
308 StdObject_Location myLocation2;
309 Standard_Integer myContinuity;
ff205346 310 };
311
312private:
313 class pTVertex : public pTBase
314 {
ec964372 315 friend class ShapePersistent_BRep;
316
ff205346 317 public:
318 inline void Read (StdObjMgt_ReadData& theReadData)
319 {
320 pTBase::Read (theReadData);
321 theReadData >> myTolerance >> myPnt >> myPoints;
322 }
ec964372 323 inline void Write (StdObjMgt_WriteData& theWriteData) const
324 {
325 pTBase::Write (theWriteData);
326 theWriteData << myTolerance << myPnt << myPoints;
327 }
328 inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
329 {
330 pTBase::PChildren(theChildren);
331 theChildren.Append(myPoints);
332 }
333 inline Standard_CString PName() const
334 { return "PBRep_TVertex"; }
ff205346 335
336 private:
337 virtual Handle(TopoDS_TShape) createTShape() const;
338
339 private:
45d8465e 340 Standard_Real myTolerance;
341 gp_Pnt myPnt;
342 Handle(PointRepresentation) myPoints;
ff205346 343 };
344
345 class pTEdge : public pTBase
346 {
ec964372 347 friend class ShapePersistent_BRep;
348
ff205346 349 public:
350 inline void Read (StdObjMgt_ReadData& theReadData)
351 {
352 pTBase::Read (theReadData);
353 theReadData >> myTolerance >> myFlags >> myCurves;
354 }
ec964372 355 inline void Write (StdObjMgt_WriteData& theWriteData) const
356 {
357 pTBase::Write (theWriteData);
358 theWriteData << myTolerance << myFlags << myCurves;
359 }
360 inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
361 {
362 pTBase::PChildren(theChildren);
363 theChildren.Append(myCurves);
364 }
365 inline Standard_CString PName() const
366 { return "PBRep_TEdge"; }
ff205346 367
368 private:
369 virtual Handle(TopoDS_TShape) createTShape() const;
370
371 private:
45d8465e 372 Standard_Real myTolerance;
373 Standard_Integer myFlags;
374 Handle(CurveRepresentation) myCurves;
ff205346 375 };
376
377 class pTFace : public pTBase
378 {
ec964372 379 friend class ShapePersistent_BRep;
380
ff205346 381 public:
382 inline void Read (StdObjMgt_ReadData& theReadData)
383 {
384 pTBase::Read (theReadData);
385 theReadData >> mySurface >> myTriangulation >> myLocation;
386 theReadData >> myTolerance >> myNaturalRestriction;
387 }
ec964372 388 inline void Write (StdObjMgt_WriteData& theWriteData) const
389 {
390 pTBase::Write (theWriteData);
391 theWriteData << mySurface << myTriangulation << myLocation;
392 theWriteData << myTolerance << myNaturalRestriction;
393 }
394 inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
395 {
396 pTBase::PChildren(theChildren);
397 theChildren.Append(mySurface);
398 theChildren.Append(myTriangulation);
399 myLocation.PChildren(theChildren);
400 }
401 inline Standard_CString PName() const
402 { return "PBRep_TFace"; }
ff205346 403
404 private:
405 virtual Handle(TopoDS_TShape) createTShape() const;
406
407 private:
45d8465e 408 Handle(ShapePersistent_Geom::Surface) mySurface;
409 Handle(ShapePersistent_Poly::Triangulation) myTriangulation;
410 StdObject_Location myLocation;
411 Standard_Real myTolerance;
412 Standard_Boolean myNaturalRestriction;
ff205346 413 };
414
415public:
416 typedef tObject <pTVertex> TVertex;
417 typedef tObject <pTEdge> TEdge;
418 typedef tObject <pTFace> TFace;
419
420 typedef tObject1 <pTVertex> TVertex1;
421 typedef tObject1 <pTEdge> TEdge1;
422 typedef tObject1 <pTFace> TFace1;
ec964372 423
424public:
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);
ff205346 508};
509
510#endif