Compare commits
No commits in common. "52fc7bd32e6241fe41515f7ce3fd08756284d5ce" and "6c2e3e8a897b18c00c7315e6855b9caa9a389b2b" have entirely different histories.
52fc7bd32e
...
6c2e3e8a89
@ -12,7 +12,6 @@ set(VTK_COMPONENTS
|
|||||||
VTK::IOGeometry
|
VTK::IOGeometry
|
||||||
VTK::IOXML
|
VTK::IOXML
|
||||||
VTK::FiltersModeling
|
VTK::FiltersModeling
|
||||||
VTK::FiltersPoints
|
|
||||||
VTK::vtksys)
|
VTK::vtksys)
|
||||||
set(ENABLE_VIEWER OFF CACHE BOOL "Enable the 3D viewer, depends on Qt.")
|
set(ENABLE_VIEWER OFF CACHE BOOL "Enable the 3D viewer, depends on Qt.")
|
||||||
if(ENABLE_VIEWER)
|
if(ENABLE_VIEWER)
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
#include <vtkXMLUnstructuredGridReader.h>
|
#include <vtkXMLUnstructuredGridReader.h>
|
||||||
#include <vtkXMLUnstructuredGridWriter.h>
|
#include <vtkXMLUnstructuredGridWriter.h>
|
||||||
#include <vtksys/SystemTools.hxx>
|
#include <vtksys/SystemTools.hxx>
|
||||||
#include <vtkPointSmoothingFilter.h>
|
|
||||||
|
|
||||||
#ifdef USE_VIEWER
|
#ifdef USE_VIEWER
|
||||||
#include <vtkCamera.h>
|
#include <vtkCamera.h>
|
||||||
@ -83,11 +82,8 @@ int main(int argc, char **argv) {
|
|||||||
vtkNew<DihedralAnglesFilter> dihedralAnglesFilter;
|
vtkNew<DihedralAnglesFilter> dihedralAnglesFilter;
|
||||||
dihedralAnglesFilter->SetInputConnection(project->GetOutputPort());
|
dihedralAnglesFilter->SetInputConnection(project->GetOutputPort());
|
||||||
|
|
||||||
vtkNew<vtkPointSmoothingFilter> pointSmoothingFilter;
|
|
||||||
pointSmoothingFilter->SetInputConnection(dihedralAnglesFilter->GetOutputPoort());
|
|
||||||
|
|
||||||
vtkNew<vtkXMLUnstructuredGridWriter> writer;
|
vtkNew<vtkXMLUnstructuredGridWriter> writer;
|
||||||
writer->SetInputConnection(pointSmoothingFilter->GetOutputPort());
|
writer->SetInputConnection(dihedralAnglesFilter->GetOutputPort());
|
||||||
writer->SetDataModeToAscii();
|
writer->SetDataModeToAscii();
|
||||||
writer->SetFileName("out.vtu");
|
writer->SetFileName("out.vtu");
|
||||||
writer->Write();
|
writer->Write();
|
||||||
|
@ -71,19 +71,6 @@ static void closestPolyMeshPoint(vtkPolyData *polyMesh,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void findPointsWithinRadius(double radius, vtkPointSet *pointSet,
|
|
||||||
const double *point, vtkIdList *points) {
|
|
||||||
for (vtkIdType i = 0; i < pointSet->GetNumberOfPoints(); i++) {
|
|
||||||
double vec[3];
|
|
||||||
vtkMath::Subtract(point, pointSet->GetPoint(i), vec);
|
|
||||||
double dist = vtkMath::Norm(vec);
|
|
||||||
if (dist < radius) {
|
|
||||||
points->InsertNextId(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void moveSurfacePoint(vtkUnstructuredGrid *tetMesh,
|
static void moveSurfacePoint(vtkUnstructuredGrid *tetMesh,
|
||||||
vtkPolyData *polyMesh,
|
vtkPolyData *polyMesh,
|
||||||
vtkIdType pointId,
|
vtkIdType pointId,
|
||||||
@ -100,15 +87,14 @@ static void moveSurfacePoint(vtkUnstructuredGrid *tetMesh,
|
|||||||
|
|
||||||
closestPolyMeshPoint(polyMesh, point, kdTree, links, direction, &distance);
|
closestPolyMeshPoint(polyMesh, point, kdTree, links, direction, &distance);
|
||||||
vtkNew<vtkIdList> affectedPoints;
|
vtkNew<vtkIdList> affectedPoints;
|
||||||
findPointsWithinRadius(distance * radiusScale, tetMesh, point, affectedPoints);
|
kdTree->FindPointsWithinRadius(distance * radiusScale, point, affectedPoints);
|
||||||
// kdTree->FindPointsWithinRadius(distance * radiusScale, point, affectedPoints);
|
|
||||||
|
|
||||||
if(distance > 0) for (vtkIdType j = 0; j < affectedPoints->GetNumberOfIds(); j++) {
|
if(distance > 0) for (vtkIdType j = 0; j < affectedPoints->GetNumberOfIds(); j++) {
|
||||||
vtkIdType affectedPointId = affectedPoints->GetId(j);
|
vtkIdType affectedPointId = affectedPoints->GetId(j);
|
||||||
double affectedPoint[3];
|
double affectedPoint[3];
|
||||||
tetMesh->GetPoint(affectedPointId, affectedPoint);
|
tetMesh->GetPoint(affectedPointId, affectedPoint);
|
||||||
double dist2 = vtkMath::Distance2BetweenPoints(affectedPoint, point);
|
double dist2 = vtkMath::Distance2BetweenPoints(affectedPoint, point);
|
||||||
// if(dist2 > (distance * radiusScale) * (distance * radiusScale)) continue;
|
if(dist2 > (distance * radiusScale) * (distance * radiusScale)) continue;
|
||||||
|
|
||||||
double motion[3] = {direction[0], direction[1], direction[2]};
|
double motion[3] = {direction[0], direction[1], direction[2]};
|
||||||
double factor = 1. - std::sqrt(dist2) / (distance * radiusScale);
|
double factor = 1. - std::sqrt(dist2) / (distance * radiusScale);
|
||||||
@ -126,29 +112,6 @@ static void moveSurfacePoint(vtkUnstructuredGrid *tetMesh,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void applyMotionVectors(vtkUnstructuredGrid *tetMesh,
|
|
||||||
vtkIdTypeArray *surfacePoints,
|
|
||||||
std::vector<double> &motionVectors,
|
|
||||||
const std::vector<unsigned> &numberOfAffectors) {
|
|
||||||
for (vtkIdType i = 0; i < tetMesh->GetNumberOfPoints(); i++) {
|
|
||||||
bool skip = false;
|
|
||||||
for (vtkIdType j = 0; j < surfacePoints->GetNumberOfTuples(); j++) {
|
|
||||||
if (i == surfacePoints->GetValue(j)) skip = true;
|
|
||||||
}
|
|
||||||
if (skip) continue;
|
|
||||||
if(numberOfAffectors[i] == 0) continue;
|
|
||||||
double point[3];
|
|
||||||
tetMesh->GetPoint(i, point);
|
|
||||||
double *motion = motionVectors.data() + (i * 3);
|
|
||||||
|
|
||||||
vtkMath::MultiplyScalar(motion, 1. / numberOfAffectors[i]);
|
|
||||||
vtkMath::Subtract(point, motion, point);
|
|
||||||
tetMesh->GetPoints()->SetPoint(i, point);
|
|
||||||
tetMesh->Modified();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
vtkTypeBool ProjectSurfacePointsOnPoly::RequestData(
|
vtkTypeBool ProjectSurfacePointsOnPoly::RequestData(
|
||||||
vtkInformation *request,
|
vtkInformation *request,
|
||||||
vtkInformationVector **inputVector,
|
vtkInformationVector **inputVector,
|
||||||
@ -181,8 +144,24 @@ vtkTypeBool ProjectSurfacePointsOnPoly::RequestData(
|
|||||||
numberOfAffectors,
|
numberOfAffectors,
|
||||||
kdTree, links);
|
kdTree, links);
|
||||||
}
|
}
|
||||||
applyMotionVectors(tetMesh, surfacePoints,
|
for (vtkIdType i = 0; i < tetMesh->GetNumberOfPoints(); i++) {
|
||||||
motionVectors, numberOfAffectors);
|
bool skip = false;
|
||||||
|
for (vtkIdType j = 0; j < surfacePoints->GetNumberOfTuples(); j++) {
|
||||||
|
if (i == surfacePoints->GetValue(j)) skip = true;
|
||||||
|
}
|
||||||
|
if (skip) continue;
|
||||||
|
|
||||||
|
if(numberOfAffectors[i] != 0) {
|
||||||
|
double point[3];
|
||||||
|
tetMesh->GetPoint(i, point);
|
||||||
|
double *motion = motionVectors.data() + (i * 3);
|
||||||
|
|
||||||
|
vtkMath::MultiplyScalar(motion, 1. / numberOfAffectors[i]);
|
||||||
|
vtkMath::Subtract(point, motion, point);
|
||||||
|
tetMesh->GetPoints()->SetPoint(i, point);
|
||||||
|
tetMesh->Modified();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user