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::IOXML
|
||||
VTK::FiltersModeling
|
||||
VTK::FiltersPoints
|
||||
VTK::vtksys)
|
||||
set(ENABLE_VIEWER OFF CACHE BOOL "Enable the 3D viewer, depends on Qt.")
|
||||
if(ENABLE_VIEWER)
|
||||
|
@ -15,7 +15,6 @@
|
||||
#include <vtkXMLUnstructuredGridReader.h>
|
||||
#include <vtkXMLUnstructuredGridWriter.h>
|
||||
#include <vtksys/SystemTools.hxx>
|
||||
#include <vtkPointSmoothingFilter.h>
|
||||
|
||||
#ifdef USE_VIEWER
|
||||
#include <vtkCamera.h>
|
||||
@ -83,11 +82,8 @@ int main(int argc, char **argv) {
|
||||
vtkNew<DihedralAnglesFilter> dihedralAnglesFilter;
|
||||
dihedralAnglesFilter->SetInputConnection(project->GetOutputPort());
|
||||
|
||||
vtkNew<vtkPointSmoothingFilter> pointSmoothingFilter;
|
||||
pointSmoothingFilter->SetInputConnection(dihedralAnglesFilter->GetOutputPoort());
|
||||
|
||||
vtkNew<vtkXMLUnstructuredGridWriter> writer;
|
||||
writer->SetInputConnection(pointSmoothingFilter->GetOutputPort());
|
||||
writer->SetInputConnection(dihedralAnglesFilter->GetOutputPort());
|
||||
writer->SetDataModeToAscii();
|
||||
writer->SetFileName("out.vtu");
|
||||
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,
|
||||
vtkPolyData *polyMesh,
|
||||
vtkIdType pointId,
|
||||
@ -100,15 +87,14 @@ static void moveSurfacePoint(vtkUnstructuredGrid *tetMesh,
|
||||
|
||||
closestPolyMeshPoint(polyMesh, point, kdTree, links, direction, &distance);
|
||||
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++) {
|
||||
vtkIdType affectedPointId = affectedPoints->GetId(j);
|
||||
double affectedPoint[3];
|
||||
tetMesh->GetPoint(affectedPointId, affectedPoint);
|
||||
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 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(
|
||||
vtkInformation *request,
|
||||
vtkInformationVector **inputVector,
|
||||
@ -181,8 +144,24 @@ vtkTypeBool ProjectSurfacePointsOnPoly::RequestData(
|
||||
numberOfAffectors,
|
||||
kdTree, links);
|
||||
}
|
||||
applyMotionVectors(tetMesh, surfacePoints,
|
||||
motionVectors, 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) {
|
||||
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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user