1 // Created on: 2001-08-02
2 // Created by: Alexander GRIGORIEV
3 // Copyright (c) 2001-2012 OPEN CASCADE SAS
5 // The content of this file is subject to the Open CASCADE Technology Public
6 // License Version 6.5 (the "License"). You may not use the content of this file
7 // except in compliance with the License. Please obtain a copy of the License
8 // at http://www.opencascade.org and read it completely before using this file.
10 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13 // The Original Code and all software distributed under the License is
14 // distributed on an "AS IS" basis, without warranty of any kind, and the
15 // Initial Developer hereby disclaims all such warranties, including without
16 // limitation, any warranties of merchantability, fitness for a particular
17 // purpose or non-infringement. Please see the License for the specific terms
18 // and conditions governing the rights and limitations under the License.
21 #include <XmlObjMgt_GP.ixx>
25 static const char * Translate (const char * theStr, gp_Mat& M);
26 static const char * Translate (const char * theStr, gp_XYZ& P);
30 //=======================================================================
31 //function : Translate
33 //=======================================================================
34 XmlObjMgt_DOMString XmlObjMgt_GP::Translate (const gp_Trsf& aTrsf)
37 XmlObjMgt_DOMString S1 (Translate(aTrsf.HVectorialPart())),
38 S2 (Translate(aTrsf.TranslationPart()));
39 Sprintf (buf, "%.17g %d %s %s", aTrsf.ScaleFactor(), aTrsf.Form(),
40 S1.GetString(), S2.GetString());
42 return XmlObjMgt_DOMString (buf);
45 //=======================================================================
46 //function : Translate
48 //=======================================================================
49 XmlObjMgt_DOMString XmlObjMgt_GP::Translate (const gp_Mat& aMat)
52 XmlObjMgt_DOMString S1 (Translate(aMat.Row(1))),
53 S2 (Translate(aMat.Row(2))),
54 S3 (Translate(aMat.Row(3)));
55 Sprintf (buf, "%s %s %s", S1.GetString(), S2.GetString(), S3.GetString());
56 return XmlObjMgt_DOMString (buf);
59 //=======================================================================
60 //function : Translate
62 //=======================================================================
63 XmlObjMgt_DOMString XmlObjMgt_GP::Translate (const gp_XYZ& anXYZ)
66 Sprintf (buf, "%.17g %.17g %.17g", anXYZ.X(), anXYZ.Y(), anXYZ.Z());
67 return XmlObjMgt_DOMString (buf);
72 //=======================================================================
73 //function : Translate
75 //=======================================================================
76 Standard_Boolean XmlObjMgt_GP::Translate
77 (const XmlObjMgt_DOMString& theStr, gp_Trsf& T)
79 Standard_Boolean aResult = Standard_False;
80 const char * aStr = theStr.GetString();
83 Standard_Real aScaleFactor = Standard_Real(Strtod (aStr, &ptr));
84 if (ptr != aStr && errno != ERANGE && errno != EINVAL)
86 T._CSFDB_Setgp_Trsfscale(aScaleFactor);
88 Standard_Integer aForm = Standard_Integer(strtol(aStr, &ptr, 10));
89 if (ptr != aStr && errno != ERANGE && errno != EINVAL) {
90 T._CSFDB_Setgp_Trsfshape((gp_TrsfForm)aForm);
94 aStr = ::Translate(aStr, (gp_Mat&)T._CSFDB_Getgp_Trsfmatrix());
98 ::Translate(aStr, (gp_XYZ&)T._CSFDB_Getgp_Trsfloc());
99 aResult = Standard_True;
106 //=======================================================================
107 //function : Translate
109 //=======================================================================
110 Standard_Boolean XmlObjMgt_GP::Translate
111 (const XmlObjMgt_DOMString& theStr, gp_Mat& M)
113 return (::Translate (theStr.GetString(), M) != 0);
116 //=======================================================================
117 //function : Translate
119 //=======================================================================
120 Standard_Boolean XmlObjMgt_GP::Translate
121 (const XmlObjMgt_DOMString& theStr, gp_XYZ& P)
123 return (::Translate (theStr.GetString(), P) != 0);
126 //=======================================================================
127 //function : Translate
129 //=======================================================================
130 static const char * Translate (const char * theStr, gp_Mat& M)
134 theStr = Translate(theStr, aC);
137 theStr = Translate(theStr, aC);
140 theStr = Translate(theStr, aC);
148 //=======================================================================
149 //function : Translate
151 //=======================================================================
152 static const char * Translate (const char * theStr, gp_XYZ& P)
157 Standard_Real aC = Strtod (theStr, &ptr);
158 if (ptr != theStr && errno != ERANGE && errno != EINVAL) {
161 aC = Strtod (theStr, &ptr);
162 if (ptr != theStr && errno != ERANGE && errno != EINVAL) {
165 aC = Strtod (theStr, &ptr);
166 if (ptr != theStr && errno != ERANGE && errno != EINVAL) {