Skip to content
Snippets Groups Projects
Commit b6c202ec authored by Berk Geveci's avatar Berk Geveci Committed by Kitware Robot
Browse files

Merge topic 'contour-convenience-funcs'


e4654b93 Added convenience methods to vtkContourFilter.

Acked-by: default avatarKitware Robot <kwrobot@kitware.com>
Acked-by: default avatarbuildbot <buildbot@kitware.com>
Reviewed-by: Cory Quammen's avatarCory Quammen <cory.quammen@kitware.com>
Merge-request: !10857
parents dfead653 e4654b93
Branches
No related tags found
No related merge requests found
......@@ -54,7 +54,7 @@ int TestContourImplicitArrays(int argc, char* argv[])
vtkNew<vtkContourFilter> contour;
contour->SetInputData(baseGrid);
contour->SetValue(0, 0.0);
contour->SetContourValues({ 0.0 });
contour->Update();
......
......@@ -59,9 +59,8 @@ int TestResampleWithDataSet2(int argc, char* argv[])
// Render
vtkNew<vtkContourFilter> toPoly;
toPoly->SetInputData(result);
toPoly->SetInputArrayToProcess(
0, 0, 0, vtkDataObject::FIELD_ASSOCIATION_POINTS, "vtkValidPointMask");
toPoly->SetValue(0, 0.5);
toPoly->SetInputArray("vtkValidPointMask");
toPoly->SetContourValues({ 0.5 });
vtkNew<vtkArrayCalculator> calculator;
calculator->SetInputConnection(toPoly->GetOutputPort());
......
......@@ -79,6 +79,8 @@ public:
int GetNumberOfContours();
void GenerateValues(int numContours, double range[2]);
void GenerateValues(int numContours, double rangeStart, double rangeEnd);
void SetContourValues(const std::vector<double>& values);
std::vector<double> GetContourValues();
///@}
/**
......@@ -206,6 +208,16 @@ public:
vtkBooleanMacro(FastMode, bool);
///@}
/**
* Sets the name of the input array to be used for generating
* the isosurfaces. This is a convenience method and it calls
* SetInputArrayToProcess().
*/
void SetInputArray(const std::string& name)
{
this->SetInputArrayToProcess(0, 0, 0, vtkDataObject::FIELD_ASSOCIATION_POINTS, name.c_str());
}
protected:
vtkContourFilter();
~vtkContourFilter() override;
......@@ -319,5 +331,36 @@ inline void vtkContourFilter::GenerateValues(int numContours, double rangeStart,
this->ContourValues->GenerateValues(numContours, rangeStart, rangeEnd);
}
/**
* Convenience method to set all of the contour values at once.
* Loops over the vector elements and calls SetValue()
*/
inline void vtkContourFilter::SetContourValues(const std::vector<double>& values)
{
int numContours = static_cast<int>(values.size());
this->SetNumberOfContours(numContours);
for (int i = 0; i < numContours; i++)
{
this->SetValue(i, values[i]);
}
}
/**
* Convenience method to get all of the contour values at once.
* The returned vector is a copy and cannot be used to modify
* contour values.
*/
inline std::vector<double> vtkContourFilter::GetContourValues()
{
std::vector<double> contours;
int numContours = this->GetNumberOfContours();
contours.reserve(numContours);
for (int i = 0; i < numContours; i++)
{
contours.push_back(this->GetValue(i));
}
return contours;
}
VTK_ABI_NAMESPACE_END
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment