1 // Copyright (C) 2007-2008 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
22 // VISU OBJECT : interactive object for VISU entities implementation
23 // File : VISU_ColoredPrs3dCache_i.hh
24 // Author : Oleg UVAROV
27 #ifndef VISU_ColoredPrs3dFactory_HeaderFile
28 #define VISU_ColoredPrs3dFactory_HeaderFile
30 #include "SALOMEconfig.h"
31 #include CORBA_SERVER_HEADER(VISU_Gen)
32 #include CORBA_SERVER_HEADER(SALOMEDS)
35 #include "SALOME_GenericObjPointer.hh"
36 #include "VISU_DeformedShapeAndScalarMap_i.hh"
37 #include "VISU_Plot3D_i.hh"
38 #include "VISU_GaussPoints_i.hh"
39 #include "VISU_StreamLines_i.hh"
40 #include "VISU_Vectors_i.hh"
41 #include "VISU_CutLines_i.hh"
42 #include "VISU_CutSegment_i.hh"
43 #include "VISU_CutPlanes_i.hh"
44 #include "VISU_DeformedShape_i.hh"
45 #include "VISU_IsoSurfaces_i.hh"
46 #include "VISU_ScalarMap_i.hh"
47 #include "VISU_ColoredPrs3d_i.hh"
48 #include "VISU_Result_i.hh"
49 #include "VISU_TypeList.hxx"
55 //----------------------------------------------------------------------------
56 typedef TList<DeformedShapeAndScalarMap_i,
57 TList<DeformedShapeAndScalarMap_i,
58 TList<DeformedShape_i,
68 TNullType> > > > > > > > > > > >
69 TColoredPrs3dTypeList;
72 typedef TList<TInt2Type<TSCALARMAPONDEFORMEDSHAPE>,
73 TList<TInt2Type<TDEFORMEDSHAPEANDSCALARMAP>,
74 TList<TInt2Type<TDEFORMEDSHAPE>,
75 TList<TInt2Type<TSTREAMLINES>,
76 TList<TInt2Type<TGAUSSPOINTS>,
77 TList<TInt2Type<TSCALARMAP>,
78 TList<TInt2Type<TISOSURFACES>,
79 TList<TInt2Type<TCUTPLANES>,
80 TList<TInt2Type<TCUTLINES>,
81 TList<TInt2Type<TCUTSEGMENT>,
82 TList<TInt2Type<TVECTORS>,
83 TList<TInt2Type<TPLOT3D>,
84 TNullType> > > > > > > > > > > >
85 TColoredPrs3dEnumList;
88 //----------------------------------------------------------------------------
89 template <unsigned int type_enum>
90 struct TColoredEnum2Type
92 typedef typename TTypeAt<TColoredPrs3dTypeList, TIndexOf<TColoredPrs3dEnumList, TInt2Type<type_enum> >::value >::TResult TResult;
95 //----------------------------------------------------------------------------
97 struct TColoredType2Enum
99 typedef typename TTypeAt<TColoredPrs3dEnumList, TIndexOf<TColoredPrs3dTypeList, T>::value >::TResult TResult;
104 //----------------------------------------------------------------------------
105 template<typename TPrs3d_i>
107 CreatePrs3dByType(SALOMEDS::Study_ptr theStudy,
108 ColoredPrs3d_i::EPublishInStudyMode thePublishInStudyMode)
110 if(!theStudy->GetProperties()->IsLocked()){
111 typedef typename TPrs3d_i::TInterface TPrs3d;
112 if(TPrs3d_i* aPresent = new TPrs3d_i(thePublishInStudyMode)){
120 //----------------------------------------------------------------------------
121 template<unsigned int type_enum>
123 CreatePrs3dByEnum(SALOMEDS::Study_ptr theStudy,
124 ColoredPrs3d_i::EPublishInStudyMode thePublishInStudyMode)
126 typedef typename TL::TColoredEnum2Type<type_enum>::TResult TColoredPrs3d;
127 return CreatePrs3dByType<TColoredPrs3d>(theStudy,
128 thePublishInStudyMode);
132 //----------------------------------------------------------------------------
134 CreatePrs3d_i(VISUType theType,
135 SALOMEDS::Study_ptr theStudy,
136 ColoredPrs3d_i::EPublishInStudyMode thePublishInStudyMode);
139 //----------------------------------------------------------------------------
141 CreatColoredPrs3d(ColoredPrs3d_i* theColoredPrs3d,
143 const std::string& theMeshName,
144 VISU::Entity theEntity,
145 const std::string& theFieldName,
146 CORBA::Long theIteration);
149 //----------------------------------------------------------------------------
150 //Create 3D collored Presentation Of Different Types
151 template<typename TPrs3d_i> TPrs3d_i*
152 CreatePrs3d(Result_ptr theResult,
153 const std::string& theMeshName,
154 VISU::Entity theEntity,
155 const std::string& theFieldName,
156 CORBA::Long theTimeStampNumber)
158 typedef typename TPrs3d_i::TInterface TPrs3d;
159 typename TPrs3d::_var_type aPrs3d;
161 if(Result_i* aResult = dynamic_cast<Result_i*>(GetServant(theResult).in())){
162 SALOMEDS::Study_var aStudy = aResult->GetStudyDocument();
163 if(aStudy->GetProperties()->IsLocked())
166 if(TPrs3d_i::IsPossible(aResult, theMeshName, theEntity, theFieldName, theTimeStampNumber, true)){
167 TPrs3d_i* aPresent = new TPrs3d_i(ColoredPrs3d_i::EPublishUnderTimeStamp);
169 if(CreatColoredPrs3d(aPresent, aResult, theMeshName, theEntity, theFieldName, theTimeStampNumber))
172 aPresent->_remove_ref();
179 //----------------------------------------------------------------------------
180 template<typename TPrs3d_i>
181 typename TPrs3d_i::TInterface::_var_type
182 Prs3dOnField(Result_ptr theResult,
183 const std::string& theMeshName,
184 VISU::Entity theEntity,
185 const std::string& theFieldName,
186 CORBA::Long theTimeStampNumber)
188 if(TPrs3d_i* aPrs3d = CreatePrs3d<TPrs3d_i>(theResult,
193 return aPrs3d->_this();
194 typedef typename TPrs3d_i::TInterface TPrs3d;
195 return TPrs3d::_nil();
199 //----------------------------------------------------------------------------
200 //! Gets the memory required for cache
201 VISU_I_EXPORT VISU::ColoredPrs3dCache::EnlargeType
202 GetRequiredCacheMemory(VISU::VISUType theType,
203 VISU::Result_ptr theResult,
204 const std::string& theMeshName,
205 VISU::Entity theEntity,
206 const std::string& theFieldName,
207 CORBA::Long theTimeStampNumber,
208 CORBA::Float& theUsedMemory,
209 CORBA::Float& theRequiredMemory);
212 //----------------------------------------------------------------------------
213 //! Gets the memory required for cache
214 template<class TColoredPrs3d_i>
215 VISU::ColoredPrs3dCache::EnlargeType
216 GetRequiredCacheMemory(VISU::Result_ptr theResult,
217 const std::string& theMeshName,
218 VISU::Entity theEntity,
219 const std::string& theFieldName,
220 CORBA::Long theTimeStampNumber,
221 CORBA::Float& theUsedMemory,
222 CORBA::Float& theRequiredMemory)
224 typedef typename TL::TColoredType2Enum<TColoredPrs3d_i>::TResult TEnum;
225 VISU::VISUType aColoredPrs3dType = VISU::VISUType(TEnum::value);
226 return GetRequiredCacheMemory(aColoredPrs3dType,
237 //----------------------------------------------------------------------------
238 //! Creates ColoredPrs3dHolder by enumeration value and gets its first device
239 VISU_I_EXPORT ColoredPrs3d_i*
240 CreateHolder2GetDeviceByEnum(VISU::VISUType theType,
241 VISU::Result_ptr theResult,
242 const std::string& theMeshName,
243 VISU::Entity theEntity,
244 const std::string& theFieldName,
245 CORBA::Long theTimeStampNumber,
246 VISU::ColoredPrs3dCache::EnlargeType theEnlargeType,
247 CORBA::Float theRequiredMemory);
250 //----------------------------------------------------------------------------
251 //! Creates ColoredPrs3dHolder by type and gets its first device
252 template<class TColoredPrs3d_i>
254 CreateHolder2GetDeviceByType(VISU::Result_ptr theResult,
255 const std::string& theMeshName,
256 VISU::Entity theEntity,
257 const std::string& theFieldName,
258 CORBA::Long theTimeStampNumber,
259 VISU::ColoredPrs3dCache::EnlargeType theEnlargeType,
260 CORBA::Float theRequiredMemory)
262 typedef typename TL::TColoredType2Enum<TColoredPrs3d_i>::TResult TEnum;
263 VISU::VISUType aColoredPrs3dType = VISU::VISUType(TEnum::value);
264 ColoredPrs3d_i* aColoredPrs3d = CreateHolder2GetDeviceByEnum(aColoredPrs3dType,
272 return dynamic_cast<TColoredPrs3d_i*>(aColoredPrs3d);
276 //----------------------------------------------------------------------------
277 template<unsigned int colored_prs3d_type_enum>
278 struct TSameAsFactory
280 typedef typename TL::TColoredEnum2Type<colored_prs3d_type_enum>::TResult TColoredPrs3d;
283 Copy(ColoredPrs3d_i* theColoredPrs3dFrom, ColoredPrs3d_i* theColoredPrs3dTo)
285 theColoredPrs3dTo->SetCResult(theColoredPrs3dFrom->GetCResult());
286 theColoredPrs3dTo->SetMeshName(theColoredPrs3dFrom->GetCMeshName().c_str());
287 theColoredPrs3dTo->SetEntity(theColoredPrs3dFrom->GetEntity());
288 theColoredPrs3dTo->SetFieldName(theColoredPrs3dFrom->GetCFieldName().c_str());
289 theColoredPrs3dTo->SetTimeStampNumber(theColoredPrs3dFrom->GetTimeStampNumber());
290 theColoredPrs3dTo->SameAs(theColoredPrs3dFrom);
293 SALOME::GenericObjPtr<TColoredPrs3d>
294 Create(ColoredPrs3d_i* theColoredPrs3d,
295 ColoredPrs3d_i::EPublishInStudyMode thePublishInStudyMode,
296 bool theCreateAsTemporalObject = true)
298 SALOME::GenericObjPtr<TColoredPrs3d> aSameColoredPrs3d(new TColoredPrs3d(thePublishInStudyMode));
299 Copy(theColoredPrs3d, aSameColoredPrs3d);
300 if ( theCreateAsTemporalObject )
301 aSameColoredPrs3d->Destroy();
302 return aSameColoredPrs3d;
306 //----------------------------------------------------------------------------
307 //! Check is possible to create ColoredPrs3dHolder with the given input
309 CheckIsPossible(VISU::VISUType theType,
310 const VISU::ColoredPrs3dHolder::BasicInput& theInput,
311 bool theMemoryCheck);
313 //----------------------------------------------------------------------------
314 //! Check is possible to create ColoredPrs3dHolder with the given input
315 template<unsigned int colored_prs3d_type_enum>
317 CheckIsPossible(const VISU::ColoredPrs3dHolder::BasicInput& theInput,
320 VISU::Result_i* aResult = dynamic_cast<VISU::Result_i*>( VISU::GetServant(theInput.myResult).in() );
321 std::string aMeshName = theInput.myMeshName.in();
322 VISU::Entity anEntity = theInput.myEntity;
323 std::string aFieldName = theInput.myFieldName.in();
324 CORBA::Long aTimeStampNumber = theInput.myTimeStampNumber;
326 typedef typename VISU::TL::TColoredEnum2Type<colored_prs3d_type_enum>::TResult TColoredPrs3d;
327 return TColoredPrs3d::IsPossible(aResult,
335 //----------------------------------------------------------------------------