FEM: port DataAlongLine filter to use arc length.

This makes it easier for the new data extraction to also plot data over line length.
This commit is contained in:
Stefan Tröger
2025-05-08 19:30:01 +02:00
parent 4c642e63c6
commit 8dd3e90896
2 changed files with 9 additions and 10 deletions

View File

@@ -382,18 +382,21 @@ FemPostDataAlongLineFilter::FemPostDataAlongLineFilter()
m_line->SetPoint2(vec2.x, vec2.y, vec2.z);
m_line->SetResolution(Resolution.getValue());
m_arclength = vtkSmartPointer<vtkAppendArcLength>::New();
m_arclength->SetInputConnection(m_line->GetOutputPort(0));
auto passthrough = vtkSmartPointer<vtkPassThrough>::New();
m_probe = vtkSmartPointer<vtkProbeFilter>::New();
m_probe->SetSourceConnection(passthrough->GetOutputPort(0));
m_probe->SetInputConnection(m_line->GetOutputPort());
m_probe->SetValidPointMaskArrayName("ValidPointArray");
m_probe->SetInputConnection(m_arclength->GetOutputPort());
m_probe->SetPassPointArrays(1);
m_probe->SetPassCellArrays(1);
m_probe->ComputeToleranceOff();
m_probe->SetTolerance(0.01);
clip.source = passthrough;
clip.algorithmStorage.push_back(m_arclength);
clip.target = m_probe;
addFilterPipeline(clip, "DataAlongLine");
@@ -488,12 +491,7 @@ void FemPostDataAlongLineFilter::GetAxisData()
return;
}
vtkDataArray* tcoords = dset->GetPointData()->GetTCoords("Texture Coordinates");
const Base::Vector3d& vec1 = Point1.getValue();
const Base::Vector3d& vec2 = Point2.getValue();
const Base::Vector3d diff = vec1 - vec2;
double Len = diff.Length();
vtkDataArray* alength = dset->GetPointData()->GetArray("arc_length");
for (vtkIdType i = 0; i < dset->GetNumberOfPoints(); ++i) {
double value = 0;
@@ -517,8 +515,7 @@ void FemPostDataAlongLineFilter::GetAxisData()
}
values.push_back(value);
double tcoord = tcoords->GetComponent(i, 0);
coords.push_back(tcoord * Len);
coords.push_back(alength->GetTuple1(i));
}
YAxisData.setValues(values);

View File

@@ -32,6 +32,7 @@
#include <vtkLineSource.h>
#include <vtkPointSource.h>
#include <vtkProbeFilter.h>
#include <vtkAppendArcLength.h>
#include <vtkSmartPointer.h>
#include <vtkTableBasedClipDataSet.h>
#include <vtkVectorNorm.h>
@@ -181,6 +182,7 @@ protected:
private:
vtkSmartPointer<vtkLineSource> m_line;
vtkSmartPointer<vtkAppendArcLength> m_arclength;
vtkSmartPointer<vtkProbeFilter> m_probe;
};