Compare commits

..

No commits in common. "dcc99754b62274d9b0cc743476846218752e0d74" and "61d1f67b06d86e4fb442b2cceed8e6c2d42ee361" have entirely different histories.

4 changed files with 23 additions and 27 deletions

View File

@ -44,10 +44,10 @@ int main(int argc, char **argv) {
vtkNew<DihedralAnglesFilter> dihedralAnglesFilter;
dihedralAnglesFilter->SetInputConnection(tetMeshReader->GetOutputPort());
// vtkNew<vtkXMLPolyDataReader> polyMeshReader;
// polyMeshReader->SetFileName(argv[2]);
vtkNew<vtkOBJReader> polyMeshReader;
vtkNew<vtkXMLPolyDataReader> polyMeshReader;
polyMeshReader->SetFileName(argv[2]);
// vtkNew<vtkOBJReader> polyMeshReader;
// polyMeshReader->SetFileName(argv[2]);
vtkNew<RemoveExternalCellsFilter> removeExternalCellsFilter;
removeExternalCellsFilter->SetInputConnection(0,
@ -55,16 +55,12 @@ int main(int argc, char **argv) {
removeExternalCellsFilter->SetInputConnection(1,
polyMeshReader->GetOutputPort());
vtkNew<SurfacePointsFilter> surfacePointsFilter;
surfacePointsFilter->SetInputConnection(
removeExternalCellsFilter->GetOutputPort());
vtkNew<ProjectSurfacePointsOnPoly> project;
project->SetInputConnection(0, surfacePointsFilter->GetOutputPort());
project->SetInputConnection(1, polyMeshReader->GetOutputPort());
// vtkNew<ProjectSurfacePointsOnPoly> project;
// project->SetInputConnection(0, removeExternalCellsFilter->GetOutputPort());
// project->SetInputConnection(1, pdReader->GetOutputPort());
vtkNew<vtkXMLUnstructuredGridWriter> writer;
writer->SetInputConnection(project->GetOutputPort());
writer->SetInputConnection(removeExternalCellsFilter->GetOutputPort());
writer->SetDataModeToAscii();
writer->SetFileName("out.vtu");
writer->Write();

View File

@ -41,27 +41,27 @@ vtkTypeBool ProjectSurfacePointsOnPoly::RequestData(
vtkInformationVector **inputVector,
vtkInformationVector *outputVector) {
(void) request;
vtkUnstructuredGrid* tetMesh = vtkUnstructuredGrid::GetData(inputVector[0]);
vtkPolyData* polyMesh = vtkPolyData::GetData(inputVector[1]);
vtkUnstructuredGrid* us = vtkUnstructuredGrid::GetData(inputVector[0]);
vtkPolyData* pd = vtkPolyData::GetData(inputVector[1]);
vtkUnstructuredGrid* output =
vtkUnstructuredGrid::GetData(outputVector);
output->CopyStructure(tetMesh);
output->GetPointData()->PassData(tetMesh->GetPointData());
output->GetCellData()->PassData(tetMesh->GetCellData());
output->CopyStructure(us);
output->GetPointData()->PassData(us->GetPointData());
output->GetCellData()->PassData(us->GetCellData());
/* Generate cell links, these tell us which cell a point belongs to. */
vtkNew<vtkStaticCellLinks> links;
links->BuildLinks(polyMesh);
links->BuildLinks(pd);
vtkNew<vtkKdTree> kdTree;
kdTree->BuildLocatorFromPoints(polyMesh->GetPoints());
kdTree->BuildLocatorFromPoints(pd->GetPoints());
vtkIdTypeArray *surfacePoints =
vtkIdTypeArray::SafeDownCast(tetMesh->GetFieldData()->GetArray("surface_points"));
for (vtkIdType i = 0; i < surfacePoints->GetNumberOfTuples(); i++) {
vtkIdTypeArray *externalPoints =
vtkIdTypeArray::SafeDownCast(us->GetFieldData()->GetArray("external_points"));
for (vtkIdType i = 0; i < externalPoints->GetNumberOfTuples(); i++) {
double p[3];
tetMesh->GetPoint(surfacePoints->GetTuple1(i), p);
us->GetPoint(externalPoints->GetTuple1(i), p);
double dist2;
vtkIdType closest = kdTree->FindClosestPoint(p, dist2);
vtkIdType *cellIds = links->GetCells(closest);
@ -73,7 +73,7 @@ vtkTypeBool ProjectSurfacePointsOnPoly::RequestData(
for (vtkIdType j = 0; j < nCells; j++) {
vtkIdType cellId = cellIds[j];
double direction[3];
double dist = pointTriangleDistance(p, polyMesh->GetCell(cellId), direction);
double dist = pointTriangleDistance(p, pd->GetCell(cellId), direction);
/* Find the closest one. */
if (dist < min_dist) {
min_dist = dist;
@ -85,8 +85,8 @@ vtkTypeBool ProjectSurfacePointsOnPoly::RequestData(
vtkMath::MultiplyScalar(min_direction, min_dist);
vtkMath::Subtract(p, min_direction, p);
tetMesh->GetPoints()->SetPoint(surfacePoints->GetTuple1(i), p);
tetMesh->Modified();
us->GetPoints()->SetPoint(externalPoints->GetTuple1(i), p);
us->Modified();
}
return true;

View File

@ -52,7 +52,7 @@ vtkTypeBool SurfacePointsFilter::RequestData(
/* Create an array to store the IDs of external points. */
vtkNew<vtkIdTypeArray> externalPoints;
externalPoints->SetName("surface_points");
externalPoints->SetName("external_points");
externalPoints->SetNumberOfComponents(1);
vtkNew<vtkIntArray> isExternal;
isExternal->SetName("bl");