0025194: It is necessary to orthogonalize transformation matrix in gp_Trsf and gp_Trs...
[occt.git] / src / PrsMgr / PrsMgr_Prs.cxx
1 // Copyright (c) 1998-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 //
4 // This file is part of Open CASCADE Technology software library.
5 //
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.
11 //
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
14
15 #include <PrsMgr_Prs.ixx>
16 #include <PrsMgr_Presentation.hxx>
17 #include <Precision.hxx>
18 #include <gp_Trsf.hxx>
19 #include <Geom_Transformation.hxx>
20
21 PrsMgr_Prs::PrsMgr_Prs (const Handle(Graphic3d_StructureManager)& theStructManager,
22                         const PrsMgr_PresentationPointer&         thePrs,
23                         const PrsMgr_TypeOfPresentation3d         theTypeOfPresentation)
24 : Prs3d_Presentation (theStructManager),
25   myPresentation3d   (thePrs)
26 {
27   if (theTypeOfPresentation == PrsMgr_TOP_ProjectorDependant)
28     SetVisual(Graphic3d_TOS_COMPUTED);
29 }
30
31 //=======================================================================
32 //function : Compute
33 //purpose  : 
34 //=======================================================================
35
36 void PrsMgr_Prs::Compute()
37 {
38   myPresentation3d->Compute (this);
39 }
40
41 //=======================================================================
42 //function : Compute
43 //purpose  : 
44 //=======================================================================
45
46 Handle(Graphic3d_Structure) PrsMgr_Prs::Compute(const Handle(Graphic3d_DataStructureManager)& aProjector) {
47   return myPresentation3d->Compute(aProjector);
48 }
49 //=======================================================================
50 //function : Compute
51 //purpose  : 
52 //=======================================================================
53
54 Handle(Graphic3d_Structure) PrsMgr_Prs::Compute(const Handle(Graphic3d_DataStructureManager)& aProjector,
55                                                 const TColStd_Array2OfReal& AMatrix) 
56 {
57   gp_Trsf TheTrsf;
58   Standard_Integer LC(AMatrix.LowerCol()),LR(AMatrix.LowerRow());
59   TheTrsf.SetValues(AMatrix(LR,LC),AMatrix(LR,LC+1),AMatrix(LR,LC+2),AMatrix(LR,LC+3),
60                     AMatrix(LR+1,LC),AMatrix(LR+1,LC+1),AMatrix(LR+1,LC+2),AMatrix(LR+1,LC+3),
61                     AMatrix(LR+2,LC),AMatrix(LR+2,LC+1),AMatrix(LR+2,LC+2),AMatrix(LR+2,LC+3));
62    Handle(Geom_Transformation) G = new Geom_Transformation(TheTrsf);
63   
64   return myPresentation3d->Compute(aProjector,G);
65 }
66
67 //=======================================================================
68 //function : Compute
69 //purpose  : 
70 //=======================================================================
71
72 void PrsMgr_Prs::Compute(const Handle(Graphic3d_DataStructureManager)& aProjector,
73                          Handle(Graphic3d_Structure)& aGivenStruct) 
74 {
75   myPresentation3d->Compute(aProjector,aGivenStruct);
76 }
77
78
79 //=======================================================================
80 //function : Compute
81 //purpose  : 
82 //=======================================================================
83
84 void PrsMgr_Prs::Compute(const Handle(Graphic3d_DataStructureManager)& aProjector,
85                          const TColStd_Array2OfReal& AMatrix,
86                           Handle(Graphic3d_Structure)& aGivenStruct) 
87 {
88   gp_Trsf TheTrsf;
89   Standard_Integer LC(AMatrix.LowerCol()),LR(AMatrix.LowerRow());
90   TheTrsf.SetValues(AMatrix(LR,LC),AMatrix(LR,LC+1),AMatrix(LR,LC+2),AMatrix(LR,LC+3),
91                     AMatrix(LR+1,LC),AMatrix(LR+1,LC+1),AMatrix(LR+1,LC+2),AMatrix(LR+1,LC+3),
92                     AMatrix(LR+2,LC),AMatrix(LR+2,LC+1),AMatrix(LR+2,LC+2),AMatrix(LR+2,LC+3));
93   Handle(Geom_Transformation) G = new Geom_Transformation(TheTrsf);
94
95
96   myPresentation3d->Compute(aProjector,G,aGivenStruct);
97 }