0026885: Visualization - drop redundant aspects from structure level
[occt.git] / src / Prs3d / Prs3d_Presentation.cxx
CommitLineData
b311480e 1// Copyright (c) 1995-1999 Matra Datavision
973c2be1 2// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 3//
973c2be1 4// This file is part of Open CASCADE Technology software library.
b311480e 5//
d5f74e42 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
973c2be1 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.
b311480e 11//
973c2be1 12// Alternatively, this file may be used under the terms of Open CASCADE
13// commercial license or contractual agreement.
b311480e 14
2831708b 15#include <Prs3d_Presentation.hxx>
7fd59977 16
42cf5bc1 17#include <Geom_Transformation.hxx>
7fd59977 18#include <gp_Ax1.hxx>
42cf5bc1 19#include <gp_Dir.hxx>
20#include <gp_Pnt.hxx>
7fd59977 21#include <gp_Trsf.hxx>
22#include <gp_Vec.hxx>
42cf5bc1 23#include <Graphic3d_DataStructureManager.hxx>
24#include <Graphic3d_Group.hxx>
25#include <Graphic3d_NameOfMaterial.hxx>
26#include <Graphic3d_Structure.hxx>
27#include <Graphic3d_StructureManager.hxx>
42cf5bc1 28#include <Prs3d_Root.hxx>
7fd59977 29#include <Standard_Real.hxx>
42cf5bc1 30#include <Standard_Type.hxx>
31#include <TColStd_Array2OfReal.hxx>
32
92efcf78 33IMPLEMENT_STANDARD_RTTIEXT(Prs3d_Presentation,Graphic3d_Structure)
34
7fd59977 35// OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
7fd59977 36// OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
7fd59977 37static void MakeGraphicTrsf (const Handle(Geom_Transformation)& aGeomTrsf,
38 TColStd_Array2OfReal& Array){
39 for (Standard_Integer i=1; i<=3; i++){
40 for (Standard_Integer j=1; j<=4; j++){
41 Array.SetValue(i,j,aGeomTrsf->Value(i,j));
42 }
43 }
44 Array.SetValue(4,1,0.);
45 Array.SetValue(4,2,0.);
46 Array.SetValue(4,3,0.);
47 Array.SetValue(4,4,1.);
48}
49
50//=======================================================================
51//function : Prs3d_Presentation
679ecdee 52//purpose :
7fd59977 53//=======================================================================
679ecdee 54Prs3d_Presentation::Prs3d_Presentation (const Handle(Graphic3d_StructureManager)& theViewer,
55 const Standard_Boolean theToInit)
56: Graphic3d_Structure (theViewer)
7fd59977 57{
679ecdee 58 if (!theToInit)
59 {
60 return;
7fd59977 61 }
679ecdee 62}
63
64//=======================================================================
65//function : Prs3d_Presentation
66//purpose :
67//=======================================================================
68Prs3d_Presentation::Prs3d_Presentation (const Handle(Graphic3d_StructureManager)& theViewer,
69 const Handle(Prs3d_Presentation)& thePrs)
70: Graphic3d_Structure (theViewer, thePrs)
71{
2831708b 72 //
7fd59977 73}
74
75//=======================================================================
7fd59977 76//function : Transform
77//purpose :
78//=======================================================================
79
80void Prs3d_Presentation::Transform(const Handle(Geom_Transformation)& aTransformation)
81{
82 TColStd_Array2OfReal Array (1,4,1,4);
83 MakeGraphicTrsf(aTransformation, Array);
84 SetTransform(Array, Graphic3d_TOC_REPLACE);
85}
86
7fd59977 87//=======================================================================
88//function : Transformation
89//purpose :
90//=======================================================================
91
92Handle(Geom_Transformation) Prs3d_Presentation::Transformation() const {
93TColStd_Array2OfReal matrix(1,4,1,4);
94
95 Graphic3d_Structure::Transform(matrix);
96
97 gp_Trsf trsf;
98 trsf.SetValues(
99 matrix.Value(1,1),matrix.Value(1,2),matrix.Value(1,3),matrix.Value(1,4),
100 matrix.Value(2,1),matrix.Value(2,2),matrix.Value(2,3),matrix.Value(2,4),
7a8c6a36 101 matrix.Value(3,1),matrix.Value(3,2),matrix.Value(3,3),matrix.Value(3,4));
7fd59977 102 Handle(Geom_Transformation) gtrsf = new Geom_Transformation(trsf);
103
104 return gtrsf;
105}
7fd59977 106
107//=======================================================================
108//function : Place
109//purpose :
110//=======================================================================
111void Prs3d_Presentation::Place (const Quantity_Length X,
112 const Quantity_Length Y,
113 const Quantity_Length Z)
114{
115 Handle(Geom_Transformation) aTransformation = new Geom_Transformation;
116 aTransformation->SetTranslation(gp_Vec(X,Y,Z));
117 TColStd_Array2OfReal Array (1,4,1,4);
118 MakeGraphicTrsf(aTransformation, Array);
119 SetTransform(Array, Graphic3d_TOC_REPLACE);
120}
121
122//=======================================================================
123//function : Multiply
124//purpose :
125//=======================================================================
126void Prs3d_Presentation::Multiply(const Handle(Geom_Transformation)& aTransformation)
127{
128 TColStd_Array2OfReal Array (1,4,1,4);
129 MakeGraphicTrsf(aTransformation, Array);
130 SetTransform(Array, Graphic3d_TOC_POSTCONCATENATE);
131}
132
133//=======================================================================
134//function : Move
135//purpose :
136//=======================================================================
137void Prs3d_Presentation::Move (const Quantity_Length X,
138 const Quantity_Length Y,
139 const Quantity_Length Z)
140{
141 Handle(Geom_Transformation) aTransformation = new Geom_Transformation;
142 aTransformation->SetTranslation(gp_Vec(X,Y,Z));
143 TColStd_Array2OfReal Array (1,4,1,4);
144 MakeGraphicTrsf(aTransformation, Array);
145 SetTransform(Array, Graphic3d_TOC_POSTCONCATENATE);
146}
147
7fd59977 148//=======================================================================
149//function : Connect
150//purpose :
151//=======================================================================
152void Prs3d_Presentation::Connect
153 ( const Handle(Prs3d_Presentation)& aPresentation)
154{
155 Graphic3d_Structure::Connect(aPresentation, Graphic3d_TOC_DESCENDANT);
156}
157
158
159//=======================================================================
160//function : Remove
161//purpose :
162//=======================================================================
163void Prs3d_Presentation::Remove (const Handle(Prs3d_Presentation)& aPresentation)
164{
165 Disconnect(aPresentation);
166}
167
168//=======================================================================
169//function : RemoveAll
170//purpose :
171//=======================================================================
172void Prs3d_Presentation::RemoveAll ()
173{
174 DisconnectAll(Graphic3d_TOC_DESCENDANT);
175}
176
177
178//=======================================================================
179//function : CurrentGroup
180//purpose :
181//=======================================================================
182Handle(Graphic3d_Group) Prs3d_Presentation::CurrentGroup () const
183{
b64d84be 184 if (Groups().IsEmpty())
185 {
186 return const_cast<Prs3d_Presentation* >(this)->NewGroup();
7fd59977 187 }
b64d84be 188 return Groups().Last();
7fd59977 189}
190
7fd59977 191//=======================================================================
192//function : Compute
193//purpose :
194//=======================================================================
195
196Handle(Graphic3d_Structure) Prs3d_Presentation::
197 Compute(const Handle(Graphic3d_DataStructureManager)& /*aProjector*/)
198{
199 return this;
200}
201
202//=======================================================================
203//function : Compute
204//purpose :
205//=======================================================================
206
857ffd5e 207void Prs3d_Presentation::Compute(const Handle(Graphic3d_DataStructureManager)& aDataStruct,
208 Handle(Graphic3d_Structure)& aStruct)
7fd59977 209{
210 Graphic3d_Structure::Compute(aDataStruct,aStruct );
211}
212
213//=======================================================================
214//function : Compute
215//purpose :
216//=======================================================================
217
857ffd5e 218Handle(Graphic3d_Structure) Prs3d_Presentation::Compute(const Handle(Graphic3d_DataStructureManager)& aDataStruc,
7fd59977 219 const TColStd_Array2OfReal& anArray)
220{
221 return Graphic3d_Structure::Compute(aDataStruc,anArray);
222}
223
224//=======================================================================
225//function : Compute
226//purpose :
227//=======================================================================
228
857ffd5e 229void Prs3d_Presentation::Compute(const Handle(Graphic3d_DataStructureManager)& aDataStruc,
7fd59977 230 const TColStd_Array2OfReal& anArray,
857ffd5e 231 Handle(Graphic3d_Structure)& aStruc)
7fd59977 232{
233 Graphic3d_Structure::Compute(aDataStruc,anArray,aStruc);
234}