add the ability to control the number of iterations of the algorithm

of relaxation of the tetrahedral mesh of the program of tetrahedral
mesh generation
This commit is contained in:
papush! 2022-03-23 15:25:24 +01:00
parent 8ee09d686e
commit 26b1175924
3 changed files with 43 additions and 29 deletions

View File

@ -10,6 +10,7 @@
#include <vtkOBJReader.h>
#include <vtkPolyData.h>
#include <vtkPolyDataReader.h>
#include <vtkSetGet.h>
#include <vtkUnstructuredGrid.h>
#include <vtkUnstructuredGridReader.h>
#include <vtkXMLPolyDataReader.h>
@ -59,14 +60,16 @@ vtkSmartPointer<vtkAlgorithm> readerFromFileName(const char *fileName) {
int main(int argc, char **argv) {
if (argc < 3 || argc > 5) {
std::cerr << "Usage: " << argv[0] << " tetmesh polydata [radiusScale]" << std::endl;
if (!(argc == 3 || argc == 5)) {
std::cerr << "Usage: " << argv[0] << " tetmesh polydata [radiusScale relaxationIterCount]" << std::endl;
return EXIT_FAILURE;
}
double radiusScale = 2.;
if(argc == 4) {
int iterCount = 1;
if(argc > 3) {
radiusScale = std::stod(argv[3]);
iterCount = std::stoi(argv[4]);
}
auto tetMeshReader = readerFromFileName(argv[1]);
@ -88,6 +91,7 @@ int main(int argc, char **argv) {
project->SetInputConnection(1, polyMeshReader->GetOutputPort());
vtkNew<RelaxationFilter> relaxationFilter;
relaxationFilter->SetIterCount(iterCount);
relaxationFilter->SetInputConnection(project->GetOutputPort());
vtkNew<DihedralAnglesFilter> dihedralAnglesFilter;

View File

@ -10,6 +10,10 @@
vtkStandardNewMacro(RelaxationFilter);
RelaxationFilter::RelaxationFilter()
:IterCount(1) {
}
vtkTypeBool RelaxationFilter::RequestData(
vtkInformation *request,
vtkInformationVector **inputVector,
@ -33,6 +37,7 @@ vtkTypeBool RelaxationFilter::RequestData(
output->BuildLinks();
double avg[3];
for (int iter = 0; iter < IterCount; iter++) {
for (vtkIdType i = 0; i < surfacePoints->GetNumberOfValues(); i++) {
vtkIdType id = surfacePoints->GetValue(i);
@ -71,5 +76,6 @@ vtkTypeBool RelaxationFilter::RequestData(
}
output->SetPoints(newPoints);
}
return true;
}

View File

@ -9,12 +9,16 @@ class RelaxationFilter : public vtkUnstructuredGridAlgorithm {
public:
static RelaxationFilter *New();
vtkTypeMacro(RelaxationFilter, vtkUnstructuredGridAlgorithm);
RelaxationFilter();
vtkTypeBool RequestData(vtkInformation *request,
vtkInformationVector **inputVector,
vtkInformationVector *outputVector) override;
vtkSetMacro(IterCount, int);
vtkGetMacro(IterCount, int);
protected:
~RelaxationFilter() override = default;
int IterCount;
};