IntegrationPoints
ElevationSurface
ScaleVector
+ ExtraxtFieldFilter
)
FOREACH(_dir ${_subdirs})
--- /dev/null
+# Copyright (C) 2010-2013 CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+# create a paraview plugin containing server manager xml and the server
+# manager classes to build
+# this plugin can be loaded on the server side
+
+
+cmake_minimum_required(VERSION 2.8)
+
+FIND_PACKAGE(ParaView REQUIRED)
+INCLUDE(${PARAVIEW_USE_FILE})
+
+ADD_PARAVIEW_PLUGIN(ExtractFieldFilter "1.0"
+ SERVER_MANAGER_XML ExtractFieldFilter.xml
+ SERVER_MANAGER_SOURCES vtkExtractFieldFilter.cxx
+ GUI_RESOURCES pqExtractField.qrc
+ GUI_RESOURCE_FILES ExtractFieldGUI.xml
+ )
+
+INSTALL(
+ TARGETS ExtractFieldFilter
+ DESTINATION lib/paraview
+)
--- /dev/null
+<ServerManagerConfiguration>
+ <ProxyGroup name="filters">
+ <SourceProxy name="ExtractFieldFilter" class="vtkExtractFieldFilter" label="Extract Field">
+ <Documentation
+ long_help="The filter extracts data sets from multiblock data set input which are used as a support for the selected field."
+ short_help="Extracting of mesh support for selected field">
+ </Documentation>
+
+ <InputProperty
+ name="Input"
+ command="SetInputConnection">
+ <ProxyGroupDomain name="groups">
+ <Group name="sources"/>
+ <Group name="filters"/>
+ </ProxyGroupDomain>
+ <DataTypeDomain name="input_type">
+ <DataType value="vtkMultiBlockDataSet"/>
+ </DataTypeDomain>
+
+ <InputArrayDomain name="input_array">
+ </InputArrayDomain>
+ </InputProperty>
+
+ <StringVectorProperty command="SetInputArrayToProcess"
+ element_types="0 0 0 0 2"
+ label="Field name"
+ name="SelectInputScalars"
+ number_of_elements="5">
+
+ <ArrayListDomain attribute_type="Scalars"
+ name="array_list">
+ <RequiredProperties>
+ <Property function="Input"
+ name="Input" />
+ </RequiredProperties>
+ </ArrayListDomain>
+
+ <FieldDataDomain name="field_list">
+ <RequiredProperties>
+ <Property function="Input"
+ name="Input" />
+ </RequiredProperties>
+ </FieldDataDomain>
+
+ <Documentation>
+ This property lists the names of fields which can be used for extraction of mesh support.
+ </Documentation>
+ </StringVectorProperty>
+
+ </SourceProxy>
+ </ProxyGroup>
+</ServerManagerConfiguration>
--- /dev/null
+
+
+<ParaViewFilters>
+ <Category name="DataAnalysis" menu_label="&Data Analysis">
+ <!-- adds a new category and then adds our filter to it -->
+ <Proxy group="filters" name="ExtractFieldFilter" icon=":/ExtractFieldIcons/resources/extract_field.png" />
+ </Category>
+</ParaViewFilters>
\ No newline at end of file
--- /dev/null
+<RCC>
+ <qresource prefix="/ExtractFieldIcons" >
+ <file>resources/extract_field.png</file>
+ </qresource>
+</RCC>
\ No newline at end of file
--- /dev/null
+// Copyright (C) 2010-2013 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "vtkExtractFieldFilter.h"
+
+#include <vtkInformation.h>
+#include <vtkInformationVector.h>
+#include <vtkObjectFactory.h>
+#include <vtkMultiBlockDataSet.h>
+#include <vtkDataObjectTreeIterator.h>
+#include <vtkFieldData.h>
+#include <vtkStringArray.h>
+#include <vtkDataSet.h>
+#include <vtkPointData.h>
+#include <vtkCellData.h>
+#include <vtkDataArray.h>
+
+#include <string.h>
+
+using namespace std;
+
+vtkStandardNewMacro(vtkExtractFieldFilter);
+
+vtkExtractFieldFilter::vtkExtractFieldFilter()
+:vtkMultiBlockDataSetAlgorithm()
+{
+ this->FieldName = NULL;
+}
+
+
+vtkExtractFieldFilter::~vtkExtractFieldFilter()
+{
+}
+
+//----------------------------------------------------------------------------
+int vtkExtractFieldFilter::RequestData(vtkInformation* vtkNotUsed(request),
+ vtkInformationVector** theInputVector,
+ vtkInformationVector* theOutputVector)
+{
+ // get the info objects
+ vtkMultiBlockDataSet* aInput = vtkMultiBlockDataSet::GetData(theInputVector[0], 0);
+ vtkMultiBlockDataSet* aOutput = vtkMultiBlockDataSet::GetData(theOutputVector, 0);
+
+ aOutput->CopyStructure(aInput);
+
+ // Copy selected blocks over to the output.
+ vtkDataObjectTreeIterator* aIter = aInput->NewTreeIterator();
+ aIter->VisitOnlyLeavesOff();
+ for (aIter->InitTraversal(); !aIter->IsDoneWithTraversal(); aIter->GoToNextItem()) {
+ this->CopySubTree(aIter, aOutput, aInput);
+ }
+ aIter->Delete();
+ return 1;
+}
+
+
+//----------------------------------------------------------------------------
+void vtkExtractFieldFilter::CopySubTree(vtkDataObjectTreeIterator* theLoc,
+ vtkMultiBlockDataSet* theOutput,
+ vtkMultiBlockDataSet* theInput)
+{
+ vtkDataObject* aInputNode = theInput->GetDataSet(theLoc);
+ if (!aInputNode->IsA("vtkCompositeDataSet")) {
+ if (IsToCopy(aInputNode)) {
+ vtkDataObject* aClone = aInputNode->NewInstance();
+ aClone->ShallowCopy(aInputNode);
+ theOutput->SetDataSet(theLoc, aClone);
+ aClone->Delete();
+ }
+ } else {
+ vtkCompositeDataSet* aCInput = vtkCompositeDataSet::SafeDownCast(aInputNode);
+ vtkCompositeDataSet* aCOutput = vtkCompositeDataSet::SafeDownCast(theOutput->GetDataSet(theLoc));
+ vtkCompositeDataIterator* aIter = aCInput->NewIterator();
+ vtkDataObjectTreeIterator* aTreeIter = vtkDataObjectTreeIterator::SafeDownCast(aIter);
+ if (aTreeIter) {
+ aTreeIter->VisitOnlyLeavesOff();
+ }
+ for (aIter->InitTraversal(); !aIter->IsDoneWithTraversal(); aIter->GoToNextItem()) {
+ vtkDataObject* aCurNode = aIter->GetCurrentDataObject();
+ if (IsToCopy(aInputNode)) {
+ vtkDataObject* aClone = aCurNode->NewInstance();
+ aClone->ShallowCopy(aCurNode);
+ aCOutput->SetDataSet(aIter, aClone);
+ aClone->Delete();
+ }
+ }
+ aIter->Delete();
+ }
+
+}
+
+
+//----------------------------------------------------------------------------
+void vtkExtractFieldFilter::GetListOfFields(vtkDataObject* theObject, std::list<std::string>& theList) const
+{
+ theList.clear();
+
+ if (theObject->IsA("vtkDataSet")) {
+ vtkDataSet* aDataSet = vtkDataSet::SafeDownCast(theObject);
+ vtkPointData* aPntData = aDataSet->GetPointData();
+ int aNbArrays = aPntData->GetNumberOfArrays();
+ for (int i = 0; i < aNbArrays; i++) {
+ const char* aName = aPntData->GetArrayName(i);
+ theList.push_back(aName);
+ }
+ vtkCellData* aCellData = aDataSet->GetCellData();
+ aNbArrays = aCellData->GetNumberOfArrays();
+ for (int i = 0; i < aNbArrays; i++) {
+ const char* aName = aCellData->GetArrayName(i);
+ theList.push_back(aName);
+ }
+ }
+
+}
+
+
+//----------------------------------------------------------------------------
+bool vtkExtractFieldFilter::IsToCopy(vtkDataObject* theObject) const
+{
+ if (this->FieldName == NULL)
+ return true;
+
+ std::list<std::string> aList;
+ GetListOfFields(theObject, aList);
+
+ std::list<std::string>::const_iterator aIt;
+ std::string aTestStr = this->FieldName;
+ for (aIt = aList.begin(); aIt != aList.end(); ++aIt)
+ if (aTestStr.compare(*aIt) == 0)
+ return true;
+
+ return false;
+}
+
+
+
+//----------------------------------------------------------------------------
+void vtkExtractFieldFilter::SetInputArrayToProcess(int idx, int port, int connection,
+ int fieldAssociation, const char* name)
+{
+ this->SetFieldName(name);
+}
+
+
+//----------------------------------------------------------------------------
+void vtkExtractFieldFilter::PrintSelf(ostream& os, vtkIndent indent)
+{
+ this->Superclass::PrintSelf(os,indent);
+ os << indent << "Field name: " << FieldName << endl;
+}
+
--- /dev/null
+// Copyright (C) 2010-2013 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef __vtkExtractFieldFilter_h
+#define __vtkExtractFieldFilter_h
+
+#include <vtkMultiBlockDataSetAlgorithm.h>
+#include <list>
+#include <string>
+
+class vtkDataObjectTreeIterator;
+
+
+/**
+ * Implements a class of a filter which extract a support mesh of a data field.
+ * It processes MultiBlockDataSet data structure extracting blocks which contain
+ * a field with FieldName.
+ * If field name is not defined then the filter just copies input data to output data
+*/
+class vtkExtractFieldFilter : public vtkMultiBlockDataSetAlgorithm
+{
+public:
+ /// Returns pointer on a new instance of the class
+ static vtkExtractFieldFilter* New();
+
+ vtkTypeMacro(vtkExtractFieldFilter, vtkMultiBlockDataSetAlgorithm);
+
+ /// Prints current state of the objects
+ virtual void PrintSelf(ostream& os, vtkIndent indent);
+
+ /// This method is used for definition of a field name for filtering from GUI
+ virtual void SetInputArrayToProcess(int idx, int port, int connection,
+ int fieldAssociation, const char* name);
+
+ /// Set and Get methods for FieldName
+ vtkSetStringMacro(FieldName);
+ vtkGetStringMacro(FieldName);
+
+protected:
+ /// Constructor
+ vtkExtractFieldFilter();
+
+ /// Destructor
+ virtual ~vtkExtractFieldFilter();
+
+ /// A method which is called on filtering data
+ virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
+
+ /// Copies a sub-tree defined by a Data Set Block
+ void CopySubTree(vtkDataObjectTreeIterator* theLoc, vtkMultiBlockDataSet* theOutput, vtkMultiBlockDataSet* theInput);
+
+ /// Returns a list of strings with names of fields defined in the given Data Object
+ void GetListOfFields(vtkDataObject* theObject, std::list<std::string>& theList) const;
+
+ /// Returns True if the given Data Object has to be copied into output
+ bool IsToCopy(vtkDataObject* theObject) const;
+
+private:
+ /// Methods for copy of the filter: Not implemented
+ vtkExtractFieldFilter(const vtkExtractFieldFilter&); // Not implemented
+ void operator=(const vtkExtractFieldFilter&); // Not implemented
+
+ char* FieldName;
+};
+
+#endif