#include "vtkDemandDrivenPipeline.h"
#include "vtkDataObjectTreeIterator.h"
#include "vtkThreshold.h"
+#include "vtkMultiBlockDataGroupFilter.h"
+#include "vtkCompositeDataToUnstructuredGridFilter.h"
#include <map>
#include <deque>
}
template<class CellPointExtractor>
-vtkDataSet *FilterFamilies(vtkDataSet *input, const std::set<int>& idsToKeep, bool insideOut, const char *arrNameOfFamilyField,
+vtkDataSet *FilterFamilies(vtkSmartPointer<vtkThreshold>& thres,
+ vtkDataSet *input, const std::set<int>& idsToKeep, bool insideOut, const char *arrNameOfFamilyField,
const char *associationForThreshold, bool& catchAll, bool& catchSmth)
{
static const int VTK_DATA_ARRAY_DELETE=vtkDataArrayTemplate<double>::VTK_DATA_ARRAY_DELETE;
static const char ZE_SELECTION_ARR_NAME[]="@@ZeSelection@@";
vtkDataSet *output(input->NewInstance());
output->ShallowCopy(input);
- vtkSmartPointer<vtkThreshold> thres(vtkSmartPointer<vtkThreshold>::New());
thres->SetInputData(output);
vtkDataSetAttributes *dscIn(input->GetCellData()),*dscIn2(input->GetPointData());
vtkDataSetAttributes *dscOut(output->GetCellData()),*dscOut2(output->GetPointData());
std::set<int> idsToKeep(this->Internal->getIdsToKeep());
// first shrink the input
bool catchAll,catchSmth;
- vtkDataSet *tryOnCell(FilterFamilies<CellExtractor>(input,idsToKeep,this->InsideOut,
+ vtkSmartPointer<vtkThreshold> thres1(vtkSmartPointer<vtkThreshold>::New()),thres2(vtkSmartPointer<vtkThreshold>::New());
+ vtkDataSet *tryOnCell(FilterFamilies<CellExtractor>(thres1,input,idsToKeep,this->InsideOut,
MEDFileFieldRepresentationLeavesArrays::FAMILY_ID_CELL_NAME,"vtkDataObject::FIELD_ASSOCIATION_CELLS",catchAll,catchSmth));
if(tryOnCell)
{
{
if(catchSmth)
{
- vtkDataSet *tryOnNode(FilterFamilies<PointExtractor>(tryOnCell,idsToKeep,this->InsideOut,
+ vtkDataSet *tryOnNode(FilterFamilies<PointExtractor>(thres2,input,idsToKeep,this->InsideOut,
MEDFileFieldRepresentationLeavesArrays::FAMILY_ID_NODE_NAME,"vtkDataObject::FIELD_ASSOCIATION_POINTS",catchAll,catchSmth));
if(tryOnNode && catchSmth)
{
- output->ShallowCopy(tryOnNode);
+ vtkSmartPointer<vtkMultiBlockDataGroupFilter> mb(vtkSmartPointer<vtkMultiBlockDataGroupFilter>::New());
+ vtkSmartPointer<vtkCompositeDataToUnstructuredGridFilter> cd(vtkSmartPointer<vtkCompositeDataToUnstructuredGridFilter>::New());
+ mb->AddInputConnection(thres1->GetOutputPort());
+ mb->AddInputConnection(thres2->GetOutputPort());
+ cd->SetInputConnection(mb->GetOutputPort());
+ cd->SetMergePoints(0);
+ cd->Update();
+ output->ShallowCopy(cd->GetOutput());
tryOnCell->Delete();
- tryOnNode->Delete();//
+ tryOnNode->Delete();
return 1;
}
else
}
else
{
- vtkDataSet *tryOnNode(FilterFamilies<PointExtractor>(input,idsToKeep,this->InsideOut,
+ vtkDataSet *tryOnNode(FilterFamilies<PointExtractor>(thres1,input,idsToKeep,this->InsideOut,
MEDFileFieldRepresentationLeavesArrays::FAMILY_ID_NODE_NAME,"vtkDataObject::FIELD_ASSOCIATION_POINTS",catchAll,catchSmth));
if(tryOnNode)
{
}
else
{
- vtkDataSet *tryOnNode(FilterFamilies<PointExtractor>(input,idsToKeep,this->InsideOut,
+ vtkDataSet *tryOnNode(FilterFamilies<PointExtractor>(thres1,input,idsToKeep,this->InsideOut,
MEDFileFieldRepresentationLeavesArrays::FAMILY_ID_NODE_NAME,"vtkDataObject::FIELD_ASSOCIATION_POINTS",catchAll,catchSmth));
if(tryOnNode)
{
void vtkExtractGroup::SetGroupsFlagsStatus(const char *name, int status)
{
//std::cerr << "vtkExtractGroup::SetFieldsStatus(" << name << "," << status << ")" << std::endl;
+ if (GetNumberOfGroupsFlagsArrays()<1)
+ return;
this->Internal->setStatusOfEntryStr(name,(bool)status);
if(std::string(name)==GetGroupsFlagsArrayName(GetNumberOfGroupsFlagsArrays()-1))
this->Modified();