1 // Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // File : VISU_Deformation_i.cc
24 #include "VISU_Deformation_i.hh"
25 #include "VISU_Result_i.hh"
26 #include "VISU_Prs3dUtils.hh"
28 #include "VISU_DeformationPL.hxx"
29 #include "VISU_Convertor.hxx"
30 #include "VISU_DeformationPL.hxx"
31 #include "VISUConfig.hh"
34 static int MYDEBUG = 0;
36 static int MYDEBUG = 0;
39 //---------------------------------------------------------------
40 VISU::Deformation_i::Deformation_i(VISU::ColoredPrs3d_i *thePrs3d):
41 myColoredPrs3d(thePrs3d)
43 if(MYDEBUG) MESSAGE("Deformation_i::Deformation_i()");
46 //---------------------------------------------------------------
47 VISU::Deformation_i::~Deformation_i()
49 if(MYDEBUG) MESSAGE("Deformation_i::~Deformation_i()");
52 //---------------------------------------------------------------
53 void VISU::Deformation_i::SetScale(CORBA::Double theScale)
55 if(MYDEBUG) MESSAGE("Deformation_i::SetScale()");
57 VISU::TSetModified aModified(GetColoredPrs3d());
59 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_DeformationPL, vtkFloatingPointType>
60 (GetSpecificDeformedPL(), &VISU_DeformationPL::SetScale, theScale));
63 //---------------------------------------------------------------
64 void VISU::Deformation_i::InitDeformedPipeLine(VISU_DeformationPL* theDeformedPipeLine){
66 if(MYDEBUG) MESSAGE("Deformation_i::InitDeformedPipeLine()");
67 myDeformationPL = theDeformedPipeLine;
70 //---------------------------------------------------------------
75 if(MYDEBUG) MESSAGE("Deformation_i::GetScale()");
76 return GetSpecificDeformedPL()->GetScale();
79 //---------------------------------------------------------------
80 VISU::Entity VISU::Deformation_i::GetVectorialFieldEntity(){
81 return myVectorialEntity;
84 //---------------------------------------------------------------
85 char* VISU::Deformation_i::GetVectorialFieldName(){
86 return CORBA::string_dup(myVectorialFieldName.c_str());
89 //---------------------------------------------------------------
90 void VISU::Deformation_i::
91 DeformationToStream(std::ostringstream& theStr)
93 Storable::DataToStream(theStr,"myScaleFactor", GetScale());
94 Storable::DataToStream(theStr,"myVectorialField", GetVectorialFieldName());
95 Storable::DataToStream(theStr,"myVectorialEntiry", GetVectorialFieldEntity());
99 //---------------------------------------------------------------
101 VISU::Deformation_i::RestoreDeformation(SALOMEDS::SObject_ptr theSObject,
102 const Storable::TRestoringMap& theMap)
104 SetScale(VISU::Storable::FindValue(theMap,"myScaleFactor").toDouble());
105 VISU::Entity anEntity = VISU::Entity(VISU::Storable::FindValue(theMap, "myVectorialEntiry").toInt());
107 SetVectorialField(anEntity,
108 VISU::Storable::FindValue(theMap, "myVectorialField").toLatin1().constData());
111 //---------------------------------------------------------------
113 VISU::Deformation_i::SameAsDeformation(const Deformation_i *aDeformedPrs){
114 if(const Deformation_i* aPrs = dynamic_cast<const Deformation_i*>(aDeformedPrs)) {
115 Deformation_i* anOrigin = const_cast<Deformation_i*>(aPrs);
117 CORBA::String_var aVectorialFieldName = anOrigin->GetVectorialFieldName();
118 VISU::Entity anEntity = anOrigin->GetVectorialFieldEntity();
119 this->SetVectorialField(anEntity,
120 aVectorialFieldName);
121 this->SetScale(anOrigin->GetScale());
125 void VISU::Deformation_i::SetVectorialField(Entity theEntity, const char* theFieldName){
126 if(MYDEBUG) MESSAGE("CutPlanes_i::SetVectorialField()");
128 bool anIsModified = false;
130 anIsModified |= GetVectorialFieldEntity() != theEntity;
133 anIsModified |= GetVectorialFieldName() != theFieldName;
138 ColoredPrs3d_i *aColoredPrs = GetColoredPrs3d();
139 int aTimeStampNumber = aColoredPrs->GetTimeStampNumber();
141 VISU::TEntity aEntity = VISU::TEntity(theEntity);
143 VISU::Result_i::PInput anInput = aColoredPrs->GetCResult()->GetInput(aColoredPrs->GetCMeshName(),
148 PField aVectorialField = anInput->GetField(aColoredPrs->GetCMeshName(), aEntity, theFieldName);
150 VISU::PUnstructuredGridIDMapper anIDMapper =
151 anInput->GetTimeStampOnMesh(aColoredPrs->GetCMeshName(),
155 if(GetSpecificDeformedPL() && anIDMapper) {
156 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_DeformationPL, VISU::PUnstructuredGridIDMapper>
157 (GetSpecificDeformedPL(), &VISU_DeformationPL::SetVectorialField, anIDMapper));
159 VISU::TSetModified aModified(GetColoredPrs3d());
161 myVectorialEntity = theEntity;
162 myVectorialFieldName = theFieldName;
163 myVectorialField = anIDMapper;