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.cc
24 // Author : Oleg UVAROV
27 #include "VISU_ColoredPrs3dFactory.hh"
28 #include "VISU_ColoredPrs3dCache_i.hh"
30 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
34 #include <Standard_Failure.hxx>
37 #include <Standard_ErrorHandler.hxx>
41 //static int MYDEBUG = 0;
44 //static int MYDEBUG = 0;
51 //----------------------------------------------------------------------------
53 CreatColoredPrs3d(ColoredPrs3d_i* theColoredPrs3d,
55 const std::string& theMeshName,
56 VISU::Entity theEntity,
57 const std::string& theFieldName,
58 CORBA::Long theIteration)
66 theColoredPrs3d->SetCResult(theResult);
67 theColoredPrs3d->SetMeshName(theMeshName.c_str());
68 theColoredPrs3d->SetEntity(theEntity);
69 theColoredPrs3d->SetFieldName(theFieldName.c_str());
70 theColoredPrs3d->SetTimeStampNumber(theIteration);
71 if(theColoredPrs3d->Apply(false))
74 }catch(Standard_Failure) {
75 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
76 INFOS("Follow signal was occured :\n"<<aFail->GetMessageString());
77 }catch(std::exception& exc){
78 INFOS("Follow exception was occured :\n"<<exc.what());
80 INFOS("Unknown exception was occured!");
87 //----------------------------------------------------------------------------
89 CreatePrs3d_i(VISUType theType,
90 SALOMEDS::Study_ptr theStudy,
91 ColoredPrs3d_i::EPublishInStudyMode thePublishInStudyMode)
95 return VISU::CreatePrs3dByEnum<TSCALARMAP>(theStudy, thePublishInStudyMode);
97 return VISU::CreatePrs3dByEnum<TGAUSSPOINTS>(theStudy, thePublishInStudyMode);
99 return VISU::CreatePrs3dByEnum<TDEFORMEDSHAPE>(theStudy, thePublishInStudyMode);
100 case TSCALARMAPONDEFORMEDSHAPE:
101 case TDEFORMEDSHAPEANDSCALARMAP:
102 return VISU::CreatePrs3dByEnum<TDEFORMEDSHAPEANDSCALARMAP>(theStudy, thePublishInStudyMode);
104 return VISU::CreatePrs3dByEnum<TISOSURFACES>(theStudy, thePublishInStudyMode);
106 return VISU::CreatePrs3dByEnum<TSTREAMLINES>(theStudy, thePublishInStudyMode);
108 return VISU::CreatePrs3dByEnum<TPLOT3D>(theStudy, thePublishInStudyMode);
110 return VISU::CreatePrs3dByEnum<TCUTPLANES>(theStudy, thePublishInStudyMode);
112 return VISU::CreatePrs3dByEnum<TCUTLINES>(theStudy, thePublishInStudyMode);
114 return VISU::CreatePrs3dByEnum<TCUTSEGMENT>(theStudy, thePublishInStudyMode);
116 return VISU::CreatePrs3dByEnum<TVECTORS>(theStudy, thePublishInStudyMode);
122 //----------------------------------------------------------------------------
123 VISU::ColoredPrs3dCache::EnlargeType
124 GetRequiredCacheMemory(VISU::VISUType theType,
125 VISU::Result_ptr theResult,
126 const std::string& theMeshName,
127 VISU::Entity theEntity,
128 const std::string& theFieldName,
129 CORBA::Long theIteration,
130 CORBA::Float& theUsedMemory,
131 CORBA::Float& theRequiredMemory)
133 VISU::ColoredPrs3dCache::EnlargeType anEnlargeType = VISU::ColoredPrs3dCache::NO_ENLARGE;
134 if(Result_i* aResult = dynamic_cast<Result_i*>(GetServant(theResult).in())){
135 VISU::ColoredPrs3dHolder::BasicInput anInput;
136 anInput.myResult = VISU::Result::_duplicate(theResult);
137 anInput.myMeshName = theMeshName.c_str();
138 anInput.myEntity = theEntity;
139 anInput.myFieldName = theFieldName.c_str();
140 anInput.myTimeStampNumber = theIteration;
142 SALOMEDS::Study_var aStudy = aResult->GetStudyDocument();
143 VISU::ColoredPrs3dCache_var aCache = ColoredPrs3dCache_i::GetInstance(aStudy);
145 theUsedMemory = aCache->GetMemorySize();
146 anEnlargeType = aCache->GetRequiredMemory(theType, anInput, theRequiredMemory);
148 return anEnlargeType;
152 //----------------------------------------------------------------------------
153 VISU::ColoredPrs3d_i*
154 CreateHolder2GetDeviceByEnum(VISU::VISUType theType,
155 VISU::Result_ptr theResult,
156 const std::string& theMeshName,
157 VISU::Entity theEntity,
158 const std::string& theFieldName,
159 CORBA::Long theIteration,
160 VISU::ColoredPrs3dCache::EnlargeType theEnlargeType,
161 CORBA::Float theRequiredMemory)
163 VISU::ColoredPrs3d_i* aColoredPrs3d = NULL;
164 if(Result_i* aResult = dynamic_cast<Result_i*>(GetServant(theResult).in())){
165 VISU::ColoredPrs3dHolder::BasicInput anInput;
166 anInput.myResult = VISU::Result::_duplicate(theResult);
167 anInput.myMeshName = theMeshName.c_str();
168 anInput.myEntity = theEntity;
169 anInput.myFieldName = theFieldName.c_str();
170 anInput.myTimeStampNumber = theIteration;
172 SALOMEDS::Study_var aStudy = aResult->GetStudyDocument();
173 VISU::ColoredPrs3dCache_var aCache = ColoredPrs3dCache_i::GetInstance(aStudy);
175 if( theEnlargeType == VISU::ColoredPrs3dCache::ENLARGE )
176 aCache->SetLimitedMemory( theRequiredMemory );
178 VISU::ColoredPrs3dHolder_var aHolder = aCache->CreateHolder(theType, anInput);
180 if( CORBA::is_nil(aHolder) )
183 VISU::ColoredPrs3d_var aPrs3d = aHolder->GetDevice();
184 aColoredPrs3d = dynamic_cast<VISU::ColoredPrs3d_i*>(GetServant(aPrs3d).in());
186 return aColoredPrs3d;
190 //----------------------------------------------------------------------------
192 CheckIsPossible(VISU::VISUType theType,
193 const VISU::ColoredPrs3dHolder::BasicInput& theInput,
199 aMemory = CheckIsPossible<TSCALARMAP>(theInput, theMemoryCheck);
202 aMemory = CheckIsPossible<TGAUSSPOINTS>(theInput, theMemoryCheck);
205 aMemory = CheckIsPossible<TDEFORMEDSHAPE>(theInput, theMemoryCheck);
207 case TSCALARMAPONDEFORMEDSHAPE:
208 case TDEFORMEDSHAPEANDSCALARMAP:
209 aMemory = CheckIsPossible<TDEFORMEDSHAPEANDSCALARMAP>(theInput, theMemoryCheck);
212 aMemory = CheckIsPossible<TISOSURFACES>(theInput, theMemoryCheck);
215 aMemory = CheckIsPossible<TSTREAMLINES>(theInput, theMemoryCheck);
218 aMemory = CheckIsPossible<TPLOT3D>(theInput, theMemoryCheck);
221 aMemory = CheckIsPossible<TCUTPLANES>(theInput, theMemoryCheck);
224 aMemory = CheckIsPossible<TCUTLINES>(theInput, theMemoryCheck);
227 aMemory = CheckIsPossible<TCUTSEGMENT>(theInput, theMemoryCheck);
230 aMemory = CheckIsPossible<TVECTORS>(theInput, theMemoryCheck);
237 //----------------------------------------------------------------------------