Commit d1a0788e authored by Mathieu Westphal's avatar Mathieu Westphal

Using new PointCellData conversion feature

 * Exposing new PointCellData conversion option

 In VTK, the PointData to CellData and CellData to PointData filters
 just got new properties to be able to only process certain arrays
 instead of systematically processing all arrays. We expose
 the properties in the xml of these filter so they can be used
 in ParaView. This also addd a test for PointCellData conversion.

 * Using these properties with AutoConvert properties
 AutoConvert properties settings allows user to use
 some filter with Point/Cell data filters even when
 they do not accept it. The conversion is done
 in vtkPVPostFilter but it uses to convert all
 arrays instead of only the needed one.
 This uses the new PointData to CellData and CellData to
 PointData filter properties to be able to convert
 only the needed arrays.
parent 59183e95
......@@ -100,6 +100,7 @@ SET (TESTS_WITHOUT_BASELINES
${CMAKE_CURRENT_SOURCE_DIR}/OpenHelp.xml
${CMAKE_CURRENT_SOURCE_DIR}/PartialArrayInLineChart.xml
${CMAKE_CURRENT_SOURCE_DIR}/PluginEULA.xml
${CMAKE_CURRENT_SOURCE_DIR}/PointCellDataConversion.xml
${CMAKE_CURRENT_SOURCE_DIR}/Preview.xml
${CMAKE_CURRENT_SOURCE_DIR}/SearchBox.xml
${CMAKE_CURRENT_SOURCE_DIR}/ServerConnectDialog.xml
......
This diff is collapsed.
* Exposing new PointCellData conversion option
In VTK, the PointData to CellData and CellData to PointData filters
just got new properties to be able to only process certain arrays
instead of systematically processing all arrays. We expose
the properties in the xml of these filter so they can be used
in ParaView.
* Using these properties with AutoConvert properties
AutoConvert properties settings allows user to use
some filter with Point/Cell data even when
they do not accept it. The conversion is done
in vtkPVPostFilter but it used to convert all
arrays instead of only the needed one.
This uses the new PointData to CellData and CellData to
PointData filter properties to be able to convert
only the needed arrays.
......@@ -1223,6 +1223,32 @@
<Documentation>This property specifies the input to the Cell Data to
Point Data filter.</Documentation>
</InputProperty>
<IntVectorProperty command="SetProcessAllArrays"
default_values="1"
name="ProcessAllArrays"
number_of_elements="1">
<BooleanDomain name="bool" />
<Documentation>The value of this property controls whether all input
cell arrays will be processed and converted into point arrays.</Documentation>
</IntVectorProperty>
<StringVectorProperty clean_command="ClearCellDataArrays"
command="AddCellDataArray"
name="CellDataArrays"
label="Cell Data Array to process"
number_of_elements_per_command="1"
repeat_command="1">
<Documentation>Add a cell array by name to be converted to point array.</Documentation>
<ArrayListDomain input_domain_name="input_array" name="array_list">
<RequiredProperties>
<Property function="Input" name="Input" />
</RequiredProperties>
</ArrayListDomain>
<Hints>
<PropertyWidgetDecorator type="ShowWidgetDecorator">
<Property name="ProcessAllArrays" function="boolean_invert" />
</PropertyWidgetDecorator>
</Hints>
</StringVectorProperty>
<IntVectorProperty command="SetPassCellData"
default_values="0"
name="PassCellData"
......@@ -4744,6 +4770,32 @@ array.
<Documentation>This property specifies the input to the Point Data to
Cell Data filter.</Documentation>
</InputProperty>
<IntVectorProperty command="SetProcessAllArrays"
default_values="1"
name="ProcessAllArrays"
number_of_elements="1">
<BooleanDomain name="bool" />
<Documentation>The value of this property controls whether all input
point arrays will be processed and converted into cell arrays.</Documentation>
</IntVectorProperty>
<StringVectorProperty clean_command="ClearPointDataArrays"
command="AddPointDataArray"
name="PointDataArrays"
label="Point Data Array to process"
number_of_elements_per_command="1"
repeat_command="1">
<Documentation>Add a point array by name to be converted to cell array.</Documentation>
<ArrayListDomain input_domain_name="input_array" name="array_list">
<RequiredProperties>
<Property function="Input" name="Input" />
</RequiredProperties>
</ArrayListDomain>
<Hints>
<PropertyWidgetDecorator type="ShowWidgetDecorator">
<Property name="ProcessAllArrays" function="boolean_invert" />
</PropertyWidgetDecorator>
</Hints>
</StringVectorProperty>
<IntVectorProperty command="SetPassPointData"
default_values="0"
name="PassPointData"
......
......@@ -52,6 +52,7 @@ void vtkPVCompositeDataPipeline::CopyDefaultInformation(vtkInformation* request,
// object.
vtkInformationVector* inArrayVec = algorithmInfo->Get(vtkAlgorithm::INPUT_ARRAYS_TO_PROCESS());
int num_arrays = inArrayVec ? inArrayVec->GetNumberOfInformationObjects() : 0;
int informationIndex = 0;
for (int array_index = 0; array_index < num_arrays; array_index++)
{
vtkInformation* arrayInfo = this->Algorithm->GetInputArrayInformation(array_index);
......@@ -73,7 +74,8 @@ void vtkPVCompositeDataPipeline::CopyDefaultInformation(vtkInformation* request,
if (pvpfe)
{
assert(this->Algorithm->GetInputConnection(port, connection)->GetIndex() == 0);
pvpfe->SetPostArrayToProcessInformation(0, arrayInfo);
pvpfe->SetPostArrayToProcessInformation(informationIndex, arrayInfo);
informationIndex++;
}
}
}
......
......@@ -252,14 +252,6 @@ int vtkPVPostFilter::RequestData(
//----------------------------------------------------------------------------
int vtkPVPostFilter::DoAnyNeededConversions(vtkDataObject* output)
{
// get the array to convert info
vtkInformationVector* postVector =
this->Information->Get(vtkPVPostFilterExecutive::POST_ARRAYS_TO_PROCESS());
vtkInformation* postArrayInfo = postVector->GetInformationObject(0);
const char* name = postArrayInfo->Get(vtkDataObject::FIELD_NAME());
int fieldAssociation = postArrayInfo->Get(vtkDataObject::FIELD_ASSOCIATION());
vtkCompositeDataSet* cd = vtkCompositeDataSet::SafeDownCast(output);
if (cd)
{
......@@ -269,29 +261,42 @@ int vtkPVPostFilter::DoAnyNeededConversions(vtkDataObject* output)
vtkDataSet* dataset = vtkDataSet::SafeDownCast(iter->GetCurrentDataObject());
if (dataset)
{
std::string demangled_name, demagled_component_name;
DeMangleArrayName(name, dataset, demangled_name, demagled_component_name);
this->DoAnyNeededConversions(
dataset, name, fieldAssociation, demangled_name.c_str(), demagled_component_name.c_str());
this->DoAnyNeededConversions(dataset);
}
}
iter->Delete();
return 1;
}
else
{
vtkDataSet* dataset = vtkDataSet::SafeDownCast(output);
if (dataset)
{
std::string demangled_name, demagled_component_name;
DeMangleArrayName(name, dataset, demangled_name, demagled_component_name);
return this->DoAnyNeededConversions(
dataset, name, fieldAssociation, demangled_name.c_str(), demagled_component_name.c_str());
this->DoAnyNeededConversions(dataset);
}
}
return 0;
return 1;
}
//----------------------------------------------------------------------------
int vtkPVPostFilter::DoAnyNeededConversions(vtkDataSet* dataset)
{
// get the array to convert info
vtkInformationVector* postVector =
this->Information->Get(vtkPVPostFilterExecutive::POST_ARRAYS_TO_PROCESS());
for (int i = 0; i < postVector->GetNumberOfInformationObjects(); i++)
{
vtkInformation* postArrayInfo = postVector->GetInformationObject(i);
const char* name = postArrayInfo->Get(vtkDataObject::FIELD_NAME());
int fieldAssociation = postArrayInfo->Get(vtkDataObject::FIELD_ASSOCIATION());
std::string demangled_name, demagled_component_name;
DeMangleArrayName(name, dataset, demangled_name, demagled_component_name);
this->DoAnyNeededConversions(
dataset, name, fieldAssociation, demangled_name.c_str(), demagled_component_name.c_str());
}
return 1;
}
//----------------------------------------------------------------------------
......@@ -334,16 +339,26 @@ int vtkPVPostFilter::DoAnyNeededConversions(vtkDataSet* output, const char* requ
if (fieldAssociation == vtkDataObject::FIELD_ASSOCIATION_POINTS)
{
if (cellData->GetAbstractArray(requested_name) || cellData->GetAbstractArray(demangled_name))
vtkAbstractArray* array = cellData->GetAbstractArray(requested_name);
if (!array)
{
array = cellData->GetAbstractArray(demangled_name);
}
if (array)
{
this->CellDataToPointData(output);
this->CellDataToPointData(output, array->GetName());
}
}
else if (fieldAssociation == vtkDataObject::FIELD_ASSOCIATION_CELLS)
{
if (pointData->GetAbstractArray(requested_name) || pointData->GetAbstractArray(demangled_name))
vtkAbstractArray* array = pointData->GetAbstractArray(requested_name);
if (!array)
{
array = pointData->GetAbstractArray(demangled_name);
}
if (array)
{
this->PointDataToCellData(output);
this->PointDataToCellData(output, array->GetName());
}
}
......@@ -364,7 +379,7 @@ int vtkPVPostFilter::DoAnyNeededConversions(vtkDataSet* output, const char* requ
}
//----------------------------------------------------------------------------
void vtkPVPostFilter::CellDataToPointData(vtkDataSet* output)
void vtkPVPostFilter::CellDataToPointData(vtkDataSet* output, const char* name)
{
vtkDataObject* clone = output->NewInstance();
clone->ShallowCopy(output);
......@@ -372,6 +387,8 @@ void vtkPVPostFilter::CellDataToPointData(vtkDataSet* output)
vtkCellDataToPointData* converter = vtkCellDataToPointData::New();
converter->SetInputData(clone);
converter->PassCellDataOn();
converter->ProcessAllArraysOff();
converter->AddCellDataArray(name);
converter->Update();
output->ShallowCopy(converter->GetOutputDataObject(0));
converter->Delete();
......@@ -379,7 +396,7 @@ void vtkPVPostFilter::CellDataToPointData(vtkDataSet* output)
}
//----------------------------------------------------------------------------
void vtkPVPostFilter::PointDataToCellData(vtkDataSet* output)
void vtkPVPostFilter::PointDataToCellData(vtkDataSet* output, const char* name)
{
vtkDataObject* clone = output->NewInstance();
clone->ShallowCopy(output);
......@@ -387,6 +404,8 @@ void vtkPVPostFilter::PointDataToCellData(vtkDataSet* output)
vtkPointDataToCellData* converter = vtkPointDataToCellData::New();
converter->SetInputData(clone);
converter->PassPointDataOn();
converter->ProcessAllArraysOff();
converter->AddPointDataArray(name);
converter->Update();
output->ShallowCopy(converter->GetOutputDataObject(0));
converter->Delete();
......
......@@ -58,10 +58,11 @@ protected:
int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) VTK_OVERRIDE;
int DoAnyNeededConversions(vtkDataObject* output);
int DoAnyNeededConversions(vtkDataSet* dataset);
int DoAnyNeededConversions(vtkDataSet* output, const char* requested_name, int fieldAssociation,
const char* demangled_name, const char* demagled_component_name);
void CellDataToPointData(vtkDataSet* output);
void PointDataToCellData(vtkDataSet* output);
void CellDataToPointData(vtkDataSet* output, const char* name);
void PointDataToCellData(vtkDataSet* output, const char* name);
int ExtractComponent(vtkDataSetAttributes* dsa, const char* requested_name,
const char* demangled_name, const char* demagled_component_name);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment