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:
parent
8ee09d686e
commit
26b1175924
10
src/main.cc
10
src/main.cc
@ -10,6 +10,7 @@
|
|||||||
#include <vtkOBJReader.h>
|
#include <vtkOBJReader.h>
|
||||||
#include <vtkPolyData.h>
|
#include <vtkPolyData.h>
|
||||||
#include <vtkPolyDataReader.h>
|
#include <vtkPolyDataReader.h>
|
||||||
|
#include <vtkSetGet.h>
|
||||||
#include <vtkUnstructuredGrid.h>
|
#include <vtkUnstructuredGrid.h>
|
||||||
#include <vtkUnstructuredGridReader.h>
|
#include <vtkUnstructuredGridReader.h>
|
||||||
#include <vtkXMLPolyDataReader.h>
|
#include <vtkXMLPolyDataReader.h>
|
||||||
@ -59,14 +60,16 @@ vtkSmartPointer<vtkAlgorithm> readerFromFileName(const char *fileName) {
|
|||||||
|
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
if (argc < 3 || argc > 5) {
|
if (!(argc == 3 || argc == 5)) {
|
||||||
std::cerr << "Usage: " << argv[0] << " tetmesh polydata [radiusScale]" << std::endl;
|
std::cerr << "Usage: " << argv[0] << " tetmesh polydata [radiusScale relaxationIterCount]" << std::endl;
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
double radiusScale = 2.;
|
double radiusScale = 2.;
|
||||||
if(argc == 4) {
|
int iterCount = 1;
|
||||||
|
if(argc > 3) {
|
||||||
radiusScale = std::stod(argv[3]);
|
radiusScale = std::stod(argv[3]);
|
||||||
|
iterCount = std::stoi(argv[4]);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto tetMeshReader = readerFromFileName(argv[1]);
|
auto tetMeshReader = readerFromFileName(argv[1]);
|
||||||
@ -88,6 +91,7 @@ int main(int argc, char **argv) {
|
|||||||
project->SetInputConnection(1, polyMeshReader->GetOutputPort());
|
project->SetInputConnection(1, polyMeshReader->GetOutputPort());
|
||||||
|
|
||||||
vtkNew<RelaxationFilter> relaxationFilter;
|
vtkNew<RelaxationFilter> relaxationFilter;
|
||||||
|
relaxationFilter->SetIterCount(iterCount);
|
||||||
relaxationFilter->SetInputConnection(project->GetOutputPort());
|
relaxationFilter->SetInputConnection(project->GetOutputPort());
|
||||||
|
|
||||||
vtkNew<DihedralAnglesFilter> dihedralAnglesFilter;
|
vtkNew<DihedralAnglesFilter> dihedralAnglesFilter;
|
||||||
|
@ -10,6 +10,10 @@
|
|||||||
|
|
||||||
vtkStandardNewMacro(RelaxationFilter);
|
vtkStandardNewMacro(RelaxationFilter);
|
||||||
|
|
||||||
|
RelaxationFilter::RelaxationFilter()
|
||||||
|
:IterCount(1) {
|
||||||
|
}
|
||||||
|
|
||||||
vtkTypeBool RelaxationFilter::RequestData(
|
vtkTypeBool RelaxationFilter::RequestData(
|
||||||
vtkInformation *request,
|
vtkInformation *request,
|
||||||
vtkInformationVector **inputVector,
|
vtkInformationVector **inputVector,
|
||||||
@ -33,6 +37,7 @@ vtkTypeBool RelaxationFilter::RequestData(
|
|||||||
output->BuildLinks();
|
output->BuildLinks();
|
||||||
double avg[3];
|
double avg[3];
|
||||||
|
|
||||||
|
for (int iter = 0; iter < IterCount; iter++) {
|
||||||
for (vtkIdType i = 0; i < surfacePoints->GetNumberOfValues(); i++) {
|
for (vtkIdType i = 0; i < surfacePoints->GetNumberOfValues(); i++) {
|
||||||
vtkIdType id = surfacePoints->GetValue(i);
|
vtkIdType id = surfacePoints->GetValue(i);
|
||||||
|
|
||||||
@ -71,5 +76,6 @@ vtkTypeBool RelaxationFilter::RequestData(
|
|||||||
}
|
}
|
||||||
|
|
||||||
output->SetPoints(newPoints);
|
output->SetPoints(newPoints);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -9,12 +9,16 @@ class RelaxationFilter : public vtkUnstructuredGridAlgorithm {
|
|||||||
public:
|
public:
|
||||||
static RelaxationFilter *New();
|
static RelaxationFilter *New();
|
||||||
vtkTypeMacro(RelaxationFilter, vtkUnstructuredGridAlgorithm);
|
vtkTypeMacro(RelaxationFilter, vtkUnstructuredGridAlgorithm);
|
||||||
|
RelaxationFilter();
|
||||||
vtkTypeBool RequestData(vtkInformation *request,
|
vtkTypeBool RequestData(vtkInformation *request,
|
||||||
vtkInformationVector **inputVector,
|
vtkInformationVector **inputVector,
|
||||||
vtkInformationVector *outputVector) override;
|
vtkInformationVector *outputVector) override;
|
||||||
|
vtkSetMacro(IterCount, int);
|
||||||
|
vtkGetMacro(IterCount, int);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
~RelaxationFilter() override = default;
|
~RelaxationFilter() override = default;
|
||||||
|
int IterCount;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user