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 // File : VISU_Deformation_i.cc
26 #include "VISU_Deformation_i.hh"
27 #include "VISU_Result_i.hh"
28 #include "VISU_Prs3dUtils.hh"
30 #include "VISU_DeformationPL.hxx"
31 #include "VISU_Convertor.hxx"
32 #include "VISU_DeformationPL.hxx"
33 #include "VISUConfig.hh"
36 static int MYDEBUG = 0;
38 static int MYDEBUG = 0;
41 //---------------------------------------------------------------
42 VISU::Deformation_i::Deformation_i(VISU::ColoredPrs3d_i *thePrs3d):
43 myColoredPrs3d(thePrs3d)
45 if(MYDEBUG) MESSAGE("Deformation_i::Deformation_i()");
48 //---------------------------------------------------------------
49 VISU::Deformation_i::~Deformation_i()
51 if(MYDEBUG) MESSAGE("Deformation_i::~Deformation_i()");
54 //---------------------------------------------------------------
55 void VISU::Deformation_i::SetScale(CORBA::Double theScale)
57 if(MYDEBUG) MESSAGE("Deformation_i::SetScale()");
59 VISU::TSetModified aModified(GetColoredPrs3d());
61 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_DeformationPL, vtkFloatingPointType>
62 (GetSpecificDeformedPL(), &VISU_DeformationPL::SetScale, theScale));
65 //---------------------------------------------------------------
66 void VISU::Deformation_i::InitDeformedPipeLine(VISU_DeformationPL* theDeformedPipeLine){
68 if(MYDEBUG) MESSAGE("Deformation_i::InitDeformedPipeLine()");
69 myDeformationPL = theDeformedPipeLine;
72 //---------------------------------------------------------------
77 if(MYDEBUG) MESSAGE("Deformation_i::GetScale()");
78 return GetSpecificDeformedPL()->GetScale();
81 //---------------------------------------------------------------
82 VISU::Entity VISU::Deformation_i::GetVectorialFieldEntity(){
83 return myVectorialEntity;
86 //---------------------------------------------------------------
87 char* VISU::Deformation_i::GetVectorialFieldName(){
88 return CORBA::string_dup(myVectorialFieldName.c_str());
91 //---------------------------------------------------------------
92 void VISU::Deformation_i::
93 DeformationToStream(std::ostringstream& theStr)
95 Storable::DataToStream(theStr,"myScaleFactor", GetScale());
96 Storable::DataToStream(theStr,"myVectorialField", GetVectorialFieldName());
97 Storable::DataToStream(theStr,"myVectorialEntiry", GetVectorialFieldEntity());
101 //---------------------------------------------------------------
103 VISU::Deformation_i::RestoreDeformation(SALOMEDS::SObject_ptr theSObject,
104 const Storable::TRestoringMap& theMap)
106 SetScale(VISU::Storable::FindValue(theMap,"myScaleFactor").toDouble());
107 VISU::Entity anEntity = VISU::Entity(VISU::Storable::FindValue(theMap, "myVectorialEntiry").toInt());
109 SetVectorialField(anEntity,
110 VISU::Storable::FindValue(theMap, "myVectorialField").toLatin1().constData());
113 //---------------------------------------------------------------
115 VISU::Deformation_i::SameAsDeformation(const Deformation_i *aDeformedPrs){
116 if(const Deformation_i* aPrs = dynamic_cast<const Deformation_i*>(aDeformedPrs)) {
117 Deformation_i* anOrigin = const_cast<Deformation_i*>(aPrs);
119 CORBA::String_var aVectorialFieldName = anOrigin->GetVectorialFieldName();
120 VISU::Entity anEntity = anOrigin->GetVectorialFieldEntity();
121 this->SetVectorialField(anEntity,
122 aVectorialFieldName);
123 this->SetScale(anOrigin->GetScale());
127 void VISU::Deformation_i::SetVectorialField(Entity theEntity, const char* theFieldName){
128 if(MYDEBUG) MESSAGE("CutPlanes_i::SetVectorialField()");
130 bool anIsModified = false;
132 anIsModified |= GetVectorialFieldEntity() != theEntity;
135 anIsModified |= GetVectorialFieldName() != theFieldName;
140 ColoredPrs3d_i *aColoredPrs = GetColoredPrs3d();
141 int aTimeStampNumber = aColoredPrs->GetTimeStampNumber();
143 VISU::TEntity aEntity = VISU::TEntity(theEntity);
145 VISU::Result_i::PInput anInput = aColoredPrs->GetCResult()->GetInput(aColoredPrs->GetCMeshName(),
150 PField aVectorialField = anInput->GetField(aColoredPrs->GetCMeshName(), aEntity, theFieldName);
152 VISU::PUnstructuredGridIDMapper anIDMapper =
153 anInput->GetTimeStampOnMesh(aColoredPrs->GetCMeshName(),
157 if(GetSpecificDeformedPL() && anIDMapper) {
158 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_DeformationPL, VISU::PUnstructuredGridIDMapper>
159 (GetSpecificDeformedPL(), &VISU_DeformationPL::SetVectorialField, anIDMapper));
161 VISU::TSetModified aModified(GetColoredPrs3d());
163 myVectorialEntity = theEntity;
164 myVectorialFieldName = theFieldName;
165 myVectorialField = anIDMapper;