1 // Copyright (C) 2007-2010 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.cc
25 // Author : Oleg UVAROV
28 #include "VISU_ColoredPrs3dFactory.hh"
29 #include "VISU_ColoredPrs3dCache_i.hh"
31 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
35 #include <Standard_Failure.hxx>
38 #include <Standard_ErrorHandler.hxx>
42 //static int MYDEBUG = 0;
45 //static int MYDEBUG = 0;
52 //----------------------------------------------------------------------------
54 CreatColoredPrs3d(ColoredPrs3d_i* theColoredPrs3d,
56 const std::string& theMeshName,
57 VISU::Entity theEntity,
58 const std::string& theFieldName,
59 CORBA::Long theIteration)
67 theColoredPrs3d->SetCResult(theResult);
68 theColoredPrs3d->SetMeshName(theMeshName.c_str());
69 theColoredPrs3d->SetEntity(theEntity);
70 theColoredPrs3d->SetFieldName(theFieldName.c_str());
71 theColoredPrs3d->SetTimeStampNumber(theIteration);
72 if(theColoredPrs3d->Apply(false))
75 }catch(Standard_Failure) {
76 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
77 INFOS("Follow signal was occured :\n"<<aFail->GetMessageString());
78 }catch(std::exception& exc){
79 INFOS("Follow exception was occured :\n"<<exc.what());
81 INFOS("Unknown exception was occured!");
88 //----------------------------------------------------------------------------
90 CreatePrs3d_i(VISUType theType,
91 SALOMEDS::Study_ptr theStudy,
92 ColoredPrs3d_i::EPublishInStudyMode thePublishInStudyMode)
96 return VISU::CreatePrs3dByEnum<TSCALARMAP>(theStudy, thePublishInStudyMode);
98 return VISU::CreatePrs3dByEnum<TGAUSSPOINTS>(theStudy, thePublishInStudyMode);
100 return VISU::CreatePrs3dByEnum<TDEFORMEDSHAPE>(theStudy, thePublishInStudyMode);
101 case TSCALARMAPONDEFORMEDSHAPE:
102 case TDEFORMEDSHAPEANDSCALARMAP:
103 return VISU::CreatePrs3dByEnum<TDEFORMEDSHAPEANDSCALARMAP>(theStudy, thePublishInStudyMode);
105 return VISU::CreatePrs3dByEnum<TISOSURFACES>(theStudy, thePublishInStudyMode);
107 return VISU::CreatePrs3dByEnum<TSTREAMLINES>(theStudy, thePublishInStudyMode);
109 return VISU::CreatePrs3dByEnum<TPLOT3D>(theStudy, thePublishInStudyMode);
111 return VISU::CreatePrs3dByEnum<TCUTPLANES>(theStudy, thePublishInStudyMode);
113 return VISU::CreatePrs3dByEnum<TCUTLINES>(theStudy, thePublishInStudyMode);
115 return VISU::CreatePrs3dByEnum<TCUTSEGMENT>(theStudy, thePublishInStudyMode);
117 return VISU::CreatePrs3dByEnum<TVECTORS>(theStudy, thePublishInStudyMode);
123 //----------------------------------------------------------------------------
124 VISU::ColoredPrs3dCache::EnlargeType
125 GetRequiredCacheMemory(VISU::VISUType theType,
126 VISU::Result_ptr theResult,
127 const std::string& theMeshName,
128 VISU::Entity theEntity,
129 const std::string& theFieldName,
130 CORBA::Long theIteration,
131 CORBA::Float& theUsedMemory,
132 CORBA::Float& theRequiredMemory)
134 VISU::ColoredPrs3dCache::EnlargeType anEnlargeType = VISU::ColoredPrs3dCache::NO_ENLARGE;
135 if(Result_i* aResult = dynamic_cast<Result_i*>(GetServant(theResult).in())){
136 VISU::ColoredPrs3dHolder::BasicInput anInput;
137 anInput.myResult = VISU::Result::_duplicate(theResult);
138 anInput.myMeshName = theMeshName.c_str();
139 anInput.myEntity = theEntity;
140 anInput.myFieldName = theFieldName.c_str();
141 anInput.myTimeStampNumber = theIteration;
143 SALOMEDS::Study_var aStudy = aResult->GetStudyDocument();
144 VISU::ColoredPrs3dCache_var aCache = ColoredPrs3dCache_i::GetInstance(aStudy);
146 theUsedMemory = aCache->GetMemorySize();
147 anEnlargeType = aCache->GetRequiredMemory(theType, anInput, theRequiredMemory);
149 return anEnlargeType;
153 //----------------------------------------------------------------------------
154 VISU::ColoredPrs3d_i*
155 CreateHolder2GetDeviceByEnum(VISU::VISUType theType,
156 VISU::Result_ptr theResult,
157 const std::string& theMeshName,
158 VISU::Entity theEntity,
159 const std::string& theFieldName,
160 CORBA::Long theIteration,
161 VISU::ColoredPrs3dCache::EnlargeType theEnlargeType,
162 CORBA::Float theRequiredMemory)
164 VISU::ColoredPrs3d_i* aColoredPrs3d = NULL;
165 if(Result_i* aResult = dynamic_cast<Result_i*>(GetServant(theResult).in())){
166 VISU::ColoredPrs3dHolder::BasicInput anInput;
167 anInput.myResult = VISU::Result::_duplicate(theResult);
168 anInput.myMeshName = theMeshName.c_str();
169 anInput.myEntity = theEntity;
170 anInput.myFieldName = theFieldName.c_str();
171 anInput.myTimeStampNumber = theIteration;
173 SALOMEDS::Study_var aStudy = aResult->GetStudyDocument();
174 VISU::ColoredPrs3dCache_var aCache = ColoredPrs3dCache_i::GetInstance(aStudy);
176 if( theEnlargeType == VISU::ColoredPrs3dCache::ENLARGE )
177 aCache->SetLimitedMemory( theRequiredMemory );
179 VISU::ColoredPrs3dHolder_var aHolder = aCache->CreateHolder(theType, anInput);
181 if( CORBA::is_nil(aHolder) )
184 VISU::ColoredPrs3d_var aPrs3d = aHolder->GetDevice();
185 aColoredPrs3d = dynamic_cast<VISU::ColoredPrs3d_i*>(GetServant(aPrs3d).in());
187 return aColoredPrs3d;
191 //----------------------------------------------------------------------------
193 CheckIsPossible(VISU::VISUType theType,
194 const VISU::ColoredPrs3dHolder::BasicInput& theInput,
200 aMemory = CheckIsPossible<TSCALARMAP>(theInput, theMemoryCheck);
203 aMemory = CheckIsPossible<TGAUSSPOINTS>(theInput, theMemoryCheck);
206 aMemory = CheckIsPossible<TDEFORMEDSHAPE>(theInput, theMemoryCheck);
208 case TSCALARMAPONDEFORMEDSHAPE:
209 case TDEFORMEDSHAPEANDSCALARMAP:
210 aMemory = CheckIsPossible<TDEFORMEDSHAPEANDSCALARMAP>(theInput, theMemoryCheck);
213 aMemory = CheckIsPossible<TISOSURFACES>(theInput, theMemoryCheck);
216 aMemory = CheckIsPossible<TSTREAMLINES>(theInput, theMemoryCheck);
219 aMemory = CheckIsPossible<TPLOT3D>(theInput, theMemoryCheck);
222 aMemory = CheckIsPossible<TCUTPLANES>(theInput, theMemoryCheck);
225 aMemory = CheckIsPossible<TCUTLINES>(theInput, theMemoryCheck);
228 aMemory = CheckIsPossible<TCUTSEGMENT>(theInput, theMemoryCheck);
231 aMemory = CheckIsPossible<TVECTORS>(theInput, theMemoryCheck);
238 //----------------------------------------------------------------------------