0029604: Uniform mechanism providing History of shape's modifications for OCCT algori...
[occt.git] / src / BRepTest / BRepTest_Objects.cxx
1 // Created on: 2018/03/21
2 // Created by: Eugeny MALTCHIKOV
3 // Copyright (c) 2018 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 #include <BRepTest_Objects.hxx>
17
18 //=======================================================================
19 //function : BRepTest_Session
20 //purpose  : Class for the objects in the session
21 //=======================================================================
22 class BRepTest_Session
23 {
24 public:
25
26   //! Empty constructor
27   BRepTest_Session() {}
28
29   //! Sets the History in the session
30   void SetHistory(const Handle(BRepTools_History)& theHistory)
31   {
32     myHistory = theHistory;
33   }
34
35   //! Add the History to the history in the session
36   void AddHistory(const Handle(BRepTools_History)& theHistory)
37   {
38     if (myHistory.IsNull())
39       myHistory = new BRepTools_History;
40     myHistory->Merge(theHistory);
41   }
42
43   //! Returns the history from the session
44   const Handle(BRepTools_History)& History() const
45   {
46     return myHistory;
47   }
48
49 private:
50
51   Handle(BRepTools_History) myHistory;
52 };
53
54 //=======================================================================
55 //function : GetSession
56 //purpose  : 
57 //=======================================================================
58 static BRepTest_Session& GetSession()
59 {
60   static BRepTest_Session* pSession = new BRepTest_Session();
61   return *pSession;
62 }
63
64 //=======================================================================
65 //function : SetHistory
66 //purpose  : 
67 //=======================================================================
68 void BRepTest_Objects::SetHistory(const Handle(BRepTools_History)& theHistory)
69 {
70   GetSession().SetHistory(theHistory);
71 }
72
73 //=======================================================================
74 //function : AddHistory
75 //purpose  : 
76 //=======================================================================
77 void BRepTest_Objects::AddHistory(const Handle(BRepTools_History)& theHistory)
78 {
79   GetSession().AddHistory(theHistory);
80 }
81
82 //=======================================================================
83 //function : History
84 //purpose  : 
85 //=======================================================================
86 Handle(BRepTools_History) BRepTest_Objects::History()
87 {
88   return GetSession().History();
89 }