1 // VISU OBJECT : interactive object for VISU entities implementation
3 // Copyright (C) 2003 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
24 // File: VISU_ScalarMapPL.cxx
25 // Author: Alexey PETROV
29 #include "VISU_ScalarMapPL.hxx"
30 #include "VISU_DataSetMapperHolder.hxx"
31 #include "VISU_FieldTransform.hxx"
33 #include "VISU_AppendFilter.hxx"
34 #include "VISU_MergeFilter.hxx"
35 #include "VISU_ConvertorUtils.hxx"
37 #include <vtkDataSet.h>
38 #include <vtkPointSet.h>
39 #include <vtkUnstructuredGrid.h>
41 #include <vtkDataSetMapper.h>
42 #include <vtkObjectFactory.h>
45 //----------------------------------------------------------------------------
46 vtkStandardNewMacro(VISU_ScalarMapPL);
49 //----------------------------------------------------------------------------
52 VISU_UnstructuredGridPL(this),
53 myAppendFilter(VISU_AppendFilter::New()),
54 myMergeFilter(VISU_MergeFilter::New())
56 SetIsShrinkable(true);
58 myAppendFilter->SetMergingInputs(true);
59 myAppendFilter->Delete();
61 myMergeFilter->SetMergingInputs(true);
62 myMergeFilter->Delete();
66 //----------------------------------------------------------------------------
72 //----------------------------------------------------------------------------
77 unsigned long int aTime = Superclass::GetMTime();
79 aTime = std::max(aTime, myAppendFilter->GetMTime());
80 aTime = std::max(aTime, myMergeFilter->GetMTime());
86 //----------------------------------------------------------------------------
89 ::OnCreateMapperHolder()
91 VISU_UnstructuredGridPL::OnCreateMapperHolder();
95 //----------------------------------------------------------------------------
104 myMergeFilter->SetGeometry(myAppendFilter->GetOutput());
106 vtkDataSet* aDataSet = GetClippedInput();
107 myMergeFilter->SetScalars(aDataSet);
108 myMergeFilter->SetVectors(aDataSet);
110 myMergeFilter->RemoveFields();
111 myMergeFilter->AddField("VISU_FIELD", aDataSet);
112 myMergeFilter->AddField("VISU_CELLS_MAPPER", aDataSet);
113 myMergeFilter->AddField("VISU_POINTS_MAPPER", aDataSet);
115 GetDataSetMapper()->SetInput(InsertCustomPL());
119 //----------------------------------------------------------------------------
124 Superclass::Update();
126 // std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-aScalarsOutput.vtk";
127 // VISU::WriteToFile(GetFieldTransformFilter()->GetUnstructuredGridOutput(), aFileName);
130 // std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-aGeomDataSet.vtk";
131 // VISU::WriteToFile(myAppendFilter->GetOutput(), aFileName);
134 // std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-myMergeFilter.vtk";
135 // VISU::WriteToFile(myMergeFilter->GetUnstructuredGridOutput(), aFileName);
140 //----------------------------------------------------------------------------
143 ::DoShallowCopy(VISU_PipeLine *thePipeLine,
146 Superclass::DoShallowCopy(thePipeLine, theIsCopyInput);
150 //----------------------------------------------------------------------------
153 ::SetSourceGeometry()
155 if(IsExternalGeometryUsed()){
157 myAppendFilter->AddInput(GetClippedInput());
162 //----------------------------------------------------------------------------
165 ::AddGeometry(vtkDataSet* theGeometry)
167 myAppendFilter->AddInput(theGeometry);
168 return GetNumberOfGeometry();
172 //----------------------------------------------------------------------------
175 ::GetGeometry(int theGeomNumber)
177 return vtkDataSet::SafeDownCast(myAppendFilter->GetInput(theGeomNumber));
181 //----------------------------------------------------------------------------
184 ::GetNumberOfGeometry()
186 return myAppendFilter->GetNumberOfInputConnections(0);
190 //----------------------------------------------------------------------------
193 ::IsExternalGeometryUsed()
195 return myAppendFilter->GetInput() != GetClippedInput();
199 //----------------------------------------------------------------------------
204 myAppendFilter->RemoveAllInputs();
208 //----------------------------------------------------------------------------
213 return GetMergedInput();
217 //----------------------------------------------------------------------------
222 if(myMergeFilter->GetInput())
223 myMergeFilter->Update();
224 return myMergeFilter->GetOutput();
228 //----------------------------------------------------------------------------