1 // Author: Kirill Gavrilov
2 // Copyright (c) 2015-2019 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
15 #include <RWMesh_CoordinateSystemConverter.hxx>
17 #include <gp_Quaternion.hxx>
19 // ================================================================
20 // Function : RWMesh_CoordinateSystemConverter
22 // ================================================================
23 RWMesh_CoordinateSystemConverter::RWMesh_CoordinateSystemConverter()
24 : myInputLengthUnit (-1.0),
25 myOutputLengthUnit(-1.0),
26 myHasInputAx3 (Standard_False),
27 myHasOutputAx3(Standard_False),
30 myHasScale (Standard_False),
31 myIsEmpty (Standard_True)
36 // ================================================================
39 // ================================================================
40 void RWMesh_CoordinateSystemConverter::Init (const gp_Ax3& theInputSystem,
41 Standard_Real theInputLengthUnit,
42 const gp_Ax3& theOutputSystem,
43 Standard_Real theOutputLengthUnit)
45 myInputLengthUnit = theInputLengthUnit;
46 myOutputLengthUnit = theOutputLengthUnit;
47 myInputAx3 = theInputSystem;
48 myOutputAx3 = theOutputSystem;
49 if (theInputLengthUnit > 0.0
50 && theOutputLengthUnit > 0.0)
52 myUnitFactor = theInputLengthUnit / theOutputLengthUnit;
53 myHasScale = Abs(myUnitFactor - 1.0) > gp::Resolution();
58 myHasScale = Standard_False;
65 aTrsf.SetTransformation (theOutputSystem, theInputSystem);
66 if (aTrsf.TranslationPart().IsEqual (gp_XYZ (0.0, 0.0, 0.0), gp::Resolution())
67 && aTrsf.GetRotation().IsEqual (gp_Quaternion()))
74 myTrsfInv = aTrsf.Inverted();
75 myTrsf.GetMat4 (myNormTrsf);
76 myIsEmpty = !myHasScale && myTrsf.Form() == gp_Identity;