1 // Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // VISU OBJECT : interactive object for VISU entities implementation
24 // File : VISU_ColoredPrs3dCache_i.hh
25 // Author : Oleg UVAROV
28 #ifndef VISU_ColoredPrs3dFactory_HeaderFile
29 #define VISU_ColoredPrs3dFactory_HeaderFile
31 #include "SALOMEconfig.h"
32 #include CORBA_SERVER_HEADER(VISU_Gen)
33 #include CORBA_SERVER_HEADER(SALOMEDS)
36 #include "SALOME_GenericObjPointer.hh"
37 #include "VISU_DeformedShapeAndScalarMap_i.hh"
38 #include "VISU_Plot3D_i.hh"
39 #include "VISU_GaussPoints_i.hh"
40 #include "VISU_StreamLines_i.hh"
41 #include "VISU_Vectors_i.hh"
42 #include "VISU_CutLines_i.hh"
43 #include "VISU_CutSegment_i.hh"
44 #include "VISU_CutPlanes_i.hh"
45 #include "VISU_DeformedShape_i.hh"
46 #include "VISU_IsoSurfaces_i.hh"
47 #include "VISU_ScalarMap_i.hh"
48 #include "VISU_ColoredPrs3d_i.hh"
49 #include "VISU_Result_i.hh"
50 #include "VISU_TypeList.hxx"
56 //----------------------------------------------------------------------------
57 typedef TList<DeformedShapeAndScalarMap_i,
58 TList<DeformedShapeAndScalarMap_i,
59 TList<DeformedShape_i,
69 TNullType> > > > > > > > > > > >
70 TColoredPrs3dTypeList;
73 typedef TList<TInt2Type<TSCALARMAPONDEFORMEDSHAPE>,
74 TList<TInt2Type<TDEFORMEDSHAPEANDSCALARMAP>,
75 TList<TInt2Type<TDEFORMEDSHAPE>,
76 TList<TInt2Type<TSTREAMLINES>,
77 TList<TInt2Type<TGAUSSPOINTS>,
78 TList<TInt2Type<TSCALARMAP>,
79 TList<TInt2Type<TISOSURFACES>,
80 TList<TInt2Type<TCUTPLANES>,
81 TList<TInt2Type<TCUTLINES>,
82 TList<TInt2Type<TCUTSEGMENT>,
83 TList<TInt2Type<TVECTORS>,
84 TList<TInt2Type<TPLOT3D>,
85 TNullType> > > > > > > > > > > >
86 TColoredPrs3dEnumList;
89 //----------------------------------------------------------------------------
90 template <unsigned int type_enum>
91 struct TColoredEnum2Type
93 typedef typename TTypeAt<TColoredPrs3dTypeList, TIndexOf<TColoredPrs3dEnumList, TInt2Type<type_enum> >::value >::TResult TResult;
96 //----------------------------------------------------------------------------
98 struct TColoredType2Enum
100 typedef typename TTypeAt<TColoredPrs3dEnumList, TIndexOf<TColoredPrs3dTypeList, T>::value >::TResult TResult;
105 //----------------------------------------------------------------------------
106 template<typename TPrs3d_i>
108 CreatePrs3dByType(SALOMEDS::Study_ptr theStudy,
109 ColoredPrs3d_i::EPublishInStudyMode thePublishInStudyMode)
111 if(!theStudy->GetProperties()->IsLocked()){
112 typedef typename TPrs3d_i::TInterface TPrs3d;
113 if(TPrs3d_i* aPresent = new TPrs3d_i(thePublishInStudyMode)){
121 //----------------------------------------------------------------------------
122 template<unsigned int type_enum>
124 CreatePrs3dByEnum(SALOMEDS::Study_ptr theStudy,
125 ColoredPrs3d_i::EPublishInStudyMode thePublishInStudyMode)
127 typedef typename TL::TColoredEnum2Type<type_enum>::TResult TColoredPrs3d;
128 return CreatePrs3dByType<TColoredPrs3d>(theStudy,
129 thePublishInStudyMode);
133 //----------------------------------------------------------------------------
135 CreatePrs3d_i(VISUType theType,
136 SALOMEDS::Study_ptr theStudy,
137 ColoredPrs3d_i::EPublishInStudyMode thePublishInStudyMode);
140 //----------------------------------------------------------------------------
142 CreatColoredPrs3d(ColoredPrs3d_i* theColoredPrs3d,
144 const std::string& theMeshName,
145 VISU::Entity theEntity,
146 const std::string& theFieldName,
147 CORBA::Long theIteration);
150 //----------------------------------------------------------------------------
151 //Create 3D collored Presentation Of Different Types
152 template<typename TPrs3d_i> TPrs3d_i*
153 CreatePrs3d(Result_ptr theResult,
154 const std::string& theMeshName,
155 VISU::Entity theEntity,
156 const std::string& theFieldName,
157 CORBA::Long theTimeStampNumber)
159 typedef typename TPrs3d_i::TInterface TPrs3d;
160 typename TPrs3d::_var_type aPrs3d;
162 if(Result_i* aResult = dynamic_cast<Result_i*>(GetServant(theResult).in())){
163 SALOMEDS::Study_var aStudy = aResult->GetStudyDocument();
164 if(aStudy->GetProperties()->IsLocked())
167 if(TPrs3d_i::IsPossible(aResult, theMeshName, theEntity, theFieldName, theTimeStampNumber, true)){
168 TPrs3d_i* aPresent = new TPrs3d_i(ColoredPrs3d_i::EPublishUnderTimeStamp);
170 if(CreatColoredPrs3d(aPresent, aResult, theMeshName, theEntity, theFieldName, theTimeStampNumber))
173 aPresent->_remove_ref();
180 //----------------------------------------------------------------------------
181 template<typename TPrs3d_i>
182 typename TPrs3d_i::TInterface::_var_type
183 Prs3dOnField(Result_ptr theResult,
184 const std::string& theMeshName,
185 VISU::Entity theEntity,
186 const std::string& theFieldName,
187 CORBA::Long theTimeStampNumber)
189 if(TPrs3d_i* aPrs3d = CreatePrs3d<TPrs3d_i>(theResult,
194 return aPrs3d->_this();
195 typedef typename TPrs3d_i::TInterface TPrs3d;
196 return TPrs3d::_nil();
200 //----------------------------------------------------------------------------
201 //! Gets the memory required for cache
202 VISU_I_EXPORT VISU::ColoredPrs3dCache::EnlargeType
203 GetRequiredCacheMemory(VISU::VISUType theType,
204 VISU::Result_ptr theResult,
205 const std::string& theMeshName,
206 VISU::Entity theEntity,
207 const std::string& theFieldName,
208 CORBA::Long theTimeStampNumber,
209 CORBA::Float& theUsedMemory,
210 CORBA::Float& theRequiredMemory);
213 //----------------------------------------------------------------------------
214 //! Gets the memory required for cache
215 template<class TColoredPrs3d_i>
216 VISU::ColoredPrs3dCache::EnlargeType
217 GetRequiredCacheMemory(VISU::Result_ptr theResult,
218 const std::string& theMeshName,
219 VISU::Entity theEntity,
220 const std::string& theFieldName,
221 CORBA::Long theTimeStampNumber,
222 CORBA::Float& theUsedMemory,
223 CORBA::Float& theRequiredMemory)
225 typedef typename TL::TColoredType2Enum<TColoredPrs3d_i>::TResult TEnum;
226 VISU::VISUType aColoredPrs3dType = VISU::VISUType(TEnum::value);
227 return GetRequiredCacheMemory(aColoredPrs3dType,
238 //----------------------------------------------------------------------------
239 //! Creates ColoredPrs3dHolder by enumeration value and gets its first device
240 VISU_I_EXPORT ColoredPrs3d_i*
241 CreateHolder2GetDeviceByEnum(VISU::VISUType theType,
242 VISU::Result_ptr theResult,
243 const std::string& theMeshName,
244 VISU::Entity theEntity,
245 const std::string& theFieldName,
246 CORBA::Long theTimeStampNumber,
247 VISU::ColoredPrs3dCache::EnlargeType theEnlargeType,
248 CORBA::Float theRequiredMemory);
251 //----------------------------------------------------------------------------
252 //! Creates ColoredPrs3dHolder by type and gets its first device
253 template<class TColoredPrs3d_i>
255 CreateHolder2GetDeviceByType(VISU::Result_ptr theResult,
256 const std::string& theMeshName,
257 VISU::Entity theEntity,
258 const std::string& theFieldName,
259 CORBA::Long theTimeStampNumber,
260 VISU::ColoredPrs3dCache::EnlargeType theEnlargeType,
261 CORBA::Float theRequiredMemory)
263 typedef typename TL::TColoredType2Enum<TColoredPrs3d_i>::TResult TEnum;
264 VISU::VISUType aColoredPrs3dType = VISU::VISUType(TEnum::value);
265 ColoredPrs3d_i* aColoredPrs3d = CreateHolder2GetDeviceByEnum(aColoredPrs3dType,
273 return dynamic_cast<TColoredPrs3d_i*>(aColoredPrs3d);
277 //----------------------------------------------------------------------------
278 template<unsigned int colored_prs3d_type_enum>
279 struct TSameAsFactory
281 typedef typename TL::TColoredEnum2Type<colored_prs3d_type_enum>::TResult TColoredPrs3d;
284 Copy(ColoredPrs3d_i* theColoredPrs3dFrom, ColoredPrs3d_i* theColoredPrs3dTo)
286 theColoredPrs3dTo->SetCResult(theColoredPrs3dFrom->GetCResult());
287 theColoredPrs3dTo->SetMeshName(theColoredPrs3dFrom->GetCMeshName().c_str());
288 theColoredPrs3dTo->SetEntity(theColoredPrs3dFrom->GetEntity());
289 theColoredPrs3dTo->SetFieldName(theColoredPrs3dFrom->GetCFieldName().c_str());
290 theColoredPrs3dTo->SetTimeStampNumber(theColoredPrs3dFrom->GetTimeStampNumber());
291 theColoredPrs3dTo->SameAs(theColoredPrs3dFrom);
294 SALOME::GenericObjPtr<TColoredPrs3d>
295 Create(ColoredPrs3d_i* theColoredPrs3d,
296 ColoredPrs3d_i::EPublishInStudyMode thePublishInStudyMode,
297 bool theCreateAsTemporalObject = true)
299 SALOME::GenericObjPtr<TColoredPrs3d> aSameColoredPrs3d(new TColoredPrs3d(thePublishInStudyMode));
300 Copy(theColoredPrs3d, aSameColoredPrs3d);
301 if ( theCreateAsTemporalObject )
302 aSameColoredPrs3d->UnRegister();
303 return aSameColoredPrs3d;
307 //----------------------------------------------------------------------------
308 //! Check is possible to create ColoredPrs3dHolder with the given input
310 CheckIsPossible(VISU::VISUType theType,
311 const VISU::ColoredPrs3dHolder::BasicInput& theInput,
312 bool theMemoryCheck);
314 //----------------------------------------------------------------------------
315 //! Check is possible to create ColoredPrs3dHolder with the given input
316 template<unsigned int colored_prs3d_type_enum>
318 CheckIsPossible(const VISU::ColoredPrs3dHolder::BasicInput& theInput,
321 VISU::Result_i* aResult = dynamic_cast<VISU::Result_i*>( VISU::GetServant(theInput.myResult).in() );
322 std::string aMeshName = theInput.myMeshName.in();
323 VISU::Entity anEntity = theInput.myEntity;
324 std::string aFieldName = theInput.myFieldName.in();
325 CORBA::Long aTimeStampNumber = theInput.myTimeStampNumber;
327 typedef typename VISU::TL::TColoredEnum2Type<colored_prs3d_type_enum>::TResult TColoredPrs3d;
328 return TColoredPrs3d::IsPossible(aResult,
336 //----------------------------------------------------------------------------