Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only accept ttk-triangulable input data objects #733

Open
JonasLukasczyk opened this issue Feb 25, 2022 · 0 comments
Open

Only accept ttk-triangulable input data objects #733

JonasLukasczyk opened this issue Feb 25, 2022 · 0 comments

Comments

@JonasLukasczyk
Copy link
Contributor

Currently most ttk filters have a FillInputPortInformation method that looks like this:

int ttkHelloWorld::FillInputPortInformation(int port, vtkInformation *info) {
  if(port == 0) {
    info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkDataSet");
    return 1;
  }
  return 0;
}

However, if the filter needs to derive a ttkTriangulation for the input data object then this might not be possible since vtkDataSet also includes data types that are not supported by ttkTriangulation. So if a filter will derive a ttkTriangulation one actually has to list all data types that are supported by ttkTriangulation:

int ttkHelloWorld::FillInputPortInformation(int port, vtkInformation *info) {
  if(port == 0) {
    info->Remove(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE());
    info->Append(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkImageData");
    info->Append(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkPolyData");
    info->Append(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkUnstructuredGrid");
    return 1;
  }
  return 0;
}

Since this is a very common use case we should add a new static method to ttkAlgorithm that handles this:

int ttkHelloWorld::FillInputPortInformation(int port, vtkInformation *info) {
  if(port == 0) {
    ttkAlgorithm::RequireTriangulableInputDataObject(info);    
    return 1;
  }
  return 0;
}

static void ttkAlgorithm::RequireTriangulableInputDataObject(vtkInformation *info){
    info->Remove(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE());
    info->Append(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkImageData");
    info->Append(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkPolyData");
    info->Append(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkUnstructuredGrid");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant