b00b7f356585ab00d683c58fb85cedebd4767ba5
[occt.git] / src / PrsMgr / PrsMgr_Prs.cxx
1 // Copyright (c) 1998-1999 Matra Datavision
2 // Copyright (c) 1999-2012 OPEN CASCADE SAS
3 //
4 // The content of this file is subject to the Open CASCADE Technology Public
5 // License Version 6.5 (the "License"). You may not use the content of this file
6 // except in compliance with the License. Please obtain a copy of the License
7 // at http://www.opencascade.org and read it completely before using this file.
8 //
9 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
10 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
11 //
12 // The Original Code and all software distributed under the License is
13 // distributed on an "AS IS" basis, without warranty of any kind, and the
14 // Initial Developer hereby disclaims all such warranties, including without
15 // limitation, any warranties of merchantability, fitness for a particular
16 // purpose or non-infringement. Please see the License for the specific terms
17 // and conditions governing the rights and limitations under the License.
18
19 #include <PrsMgr_Prs.ixx>
20 #include <PrsMgr_Presentation3d.hxx>
21 #include <Precision.hxx>
22 #include <gp_Trsf.hxx>
23 #include <Geom_Transformation.hxx>
24
25 PrsMgr_Prs::PrsMgr_Prs (const Handle(Graphic3d_StructureManager)& aStructureManager,
26                         const PrsMgr_Presentation3dPointer& aPresentation3d, 
27                         const PrsMgr_TypeOfPresentation3d aTypeOfPresentation)
28 :Prs3d_Presentation(aStructureManager),myPresentation3d(aPresentation3d) 
29 {
30   
31   if (aTypeOfPresentation == PrsMgr_TOP_ProjectorDependant)
32     SetVisual(Graphic3d_TOS_COMPUTED);
33 }
34
35 //=======================================================================
36 //function : Compute
37 //purpose  : 
38 //=======================================================================
39
40 Handle(Graphic3d_Structure) PrsMgr_Prs::Compute(const Handle(Graphic3d_DataStructureManager)& aProjector) {
41   return myPresentation3d->Compute(aProjector);
42 }
43 //=======================================================================
44 //function : Compute
45 //purpose  : 
46 //=======================================================================
47
48 Handle(Graphic3d_Structure) PrsMgr_Prs::Compute(const Handle(Graphic3d_DataStructureManager)& aProjector,
49                                                 const TColStd_Array2OfReal& AMatrix) 
50 {
51   gp_Trsf TheTrsf;
52   Standard_Integer LC(AMatrix.LowerCol()),LR(AMatrix.LowerRow());
53   TheTrsf.SetValues(AMatrix(LR,LC),AMatrix(LR,LC+1),AMatrix(LR,LC+2),AMatrix(LR,LC+3),
54                     AMatrix(LR+1,LC),AMatrix(LR+1,LC+1),AMatrix(LR+1,LC+2),AMatrix(LR+1,LC+3),
55                     AMatrix(LR+2,LC),AMatrix(LR+2,LC+1),AMatrix(LR+2,LC+2),AMatrix(LR+2,LC+3),
56                     Precision::Angular(),Precision::Confusion());
57    Handle(Geom_Transformation) G = new Geom_Transformation(TheTrsf);
58   
59   return myPresentation3d->Compute(aProjector,G);
60 }
61
62 //=======================================================================
63 //function : Compute
64 //purpose  : 
65 //=======================================================================
66
67 void PrsMgr_Prs::Compute(const Handle(Graphic3d_DataStructureManager)& aProjector,
68                          Handle(Graphic3d_Structure)& aGivenStruct) 
69 {
70   myPresentation3d->Compute(aProjector,aGivenStruct);
71 }
72
73
74 //=======================================================================
75 //function : Compute
76 //purpose  : 
77 //=======================================================================
78
79 void PrsMgr_Prs::Compute(const Handle(Graphic3d_DataStructureManager)& aProjector,
80                          const TColStd_Array2OfReal& AMatrix,
81                           Handle(Graphic3d_Structure)& aGivenStruct) 
82 {
83   gp_Trsf TheTrsf;
84   Standard_Integer LC(AMatrix.LowerCol()),LR(AMatrix.LowerRow());
85   TheTrsf.SetValues(AMatrix(LR,LC),AMatrix(LR,LC+1),AMatrix(LR,LC+2),AMatrix(LR,LC+3),
86                     AMatrix(LR+1,LC),AMatrix(LR+1,LC+1),AMatrix(LR+1,LC+2),AMatrix(LR+1,LC+3),
87                     AMatrix(LR+2,LC),AMatrix(LR+2,LC+1),AMatrix(LR+2,LC+2),AMatrix(LR+2,LC+3),
88                     Precision::Angular(),Precision::Confusion());
89   Handle(Geom_Transformation) G = new Geom_Transformation(TheTrsf);
90
91
92   myPresentation3d->Compute(aProjector,G,aGivenStruct);
93 }