54cc6a27cb3b0ad3ee10d84ed505e1ba5a7a4b49
[occt.git] / src / StdObject / StdObject_gp_Trsfs.hxx
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 _StdObject_gp_Trsfs_HeaderFile
16 #define _StdObject_gp_Trsfs_HeaderFile
17
18
19 #include <StdObject_gp_Vectors.hxx>
20
21 #include <gp_Mat2d.hxx>
22 #include <gp_Mat.hxx>
23 #include <gp_Trsf2d.hxx>
24 #include <gp_Trsf.hxx>
25
26
27 inline StdObjMgt_ReadData& operator >>
28   (StdObjMgt_ReadData::Object theReadData, gp_Mat2d& theMat)
29 {
30   theReadData
31     >> theMat(1, 1) >> theMat(1, 2)
32     >> theMat(2, 1) >> theMat(2, 2);
33   return theReadData;
34 }
35
36 inline StdObjMgt_WriteData& operator <<
37   (StdObjMgt_WriteData::Object theWriteData, const gp_Mat2d& theMat)
38 {
39   theWriteData
40     << theMat(1, 1) << theMat(1, 2)
41     << theMat(2, 1) << theMat(2, 2);
42   return theWriteData;
43 }
44
45 inline StdObjMgt_ReadData& operator >>
46   (StdObjMgt_ReadData::Object theReadData, gp_Mat& theMat)
47 {
48   theReadData
49     >> theMat(1, 1) >> theMat(1, 2) >> theMat(1, 3)
50     >> theMat(2, 1) >> theMat(2, 2) >> theMat(2, 3)
51     >> theMat(3, 1) >> theMat(3, 2) >> theMat(3, 3);
52   return theReadData;
53 }
54
55 inline StdObjMgt_WriteData& operator <<
56   (StdObjMgt_WriteData::Object theWriteData, const gp_Mat& theMat)
57 {
58   theWriteData
59     << theMat(1, 1) << theMat(1, 2) << theMat(1, 3)
60     << theMat(2, 1) << theMat(2, 2) << theMat(2, 3)
61     << theMat(3, 1) << theMat(3, 2) << theMat(3, 3);
62   return theWriteData;
63 }
64
65 inline StdObjMgt_ReadData& operator >>
66   (StdObjMgt_ReadData::Object theReadData, gp_Trsf2d& theTrsf)
67 {
68   Standard_Real    aScale;
69   Standard_Integer aForm;
70   gp_Mat2d         aMat;
71   gp_XY            aLoc;
72
73   theReadData >> aScale >> aForm >> aMat >> aLoc;
74
75   theTrsf.SetValues (aScale * aMat(1, 1), aScale * aMat(1, 2), aLoc.X(),
76                      aScale * aMat(2, 1), aScale * aMat(2, 2), aLoc.Y());
77
78   return theReadData;
79 }
80
81 inline StdObjMgt_WriteData& operator <<
82 (StdObjMgt_WriteData::Object theWriteData, const gp_Trsf2d& theTrsf)
83 {
84   Standard_Real    aScale = theTrsf.ScaleFactor();
85   Standard_Integer aForm  = theTrsf.Form();
86   const gp_Mat2d&  aMat   = theTrsf.HVectorialPart();
87   const gp_XY&     aLoc   = theTrsf.TranslationPart();
88
89   theWriteData << aScale << aForm << aMat << aLoc;
90
91   return theWriteData;
92 }
93
94 inline StdObjMgt_ReadData& operator >>
95   (StdObjMgt_ReadData::Object theReadData, gp_Trsf& theTrsf)
96 {
97   Standard_Real    aScale;
98   Standard_Integer aForm;
99   gp_Mat           aMat;
100   gp_XYZ           aLoc;
101
102   theReadData >> aScale >> aForm >> aMat >> aLoc;
103
104   theTrsf.SetValues (
105     aScale * aMat(1, 1), aScale * aMat(1, 2), aScale * aMat(1, 3), aLoc.X(),
106     aScale * aMat(2, 1), aScale * aMat(2, 2), aScale * aMat(2, 3), aLoc.Y(),
107     aScale * aMat(3, 1), aScale * aMat(3, 2), aScale * aMat(3, 3), aLoc.Z());
108
109   return theReadData;
110 }
111
112 inline StdObjMgt_WriteData& operator <<
113   (StdObjMgt_WriteData::Object theWriteData, const gp_Trsf& theTrsf)
114 {
115   Standard_Real    aScale = theTrsf.ScaleFactor();
116   Standard_Integer aForm  = theTrsf.Form();
117   const gp_Mat&    aMat   = theTrsf.HVectorialPart();
118   const gp_XYZ&    aLoc   = theTrsf.TranslationPart();
119
120   theWriteData << aScale << aForm << aMat << aLoc;
121
122   return theWriteData;
123 }
124
125 #endif