/* This file is part of Lemma, a geophysical modelling and inversion API. * More information is available at http://lemmasoftware.org */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ /** * @file * @date 01/27/2016 01:24:24 PM * @version $Id$ * @author Trevor Irons (ti) * @email tirons@egi.utah.edu * @copyright Copyright (c) 2016, University of Utah * @copyright Copyright (c) 2016, Trevor Irons & Lemma Software, LLC */ #include #include #include #include #include #include #include #include #include #include #include #include int main(int argc, char**argv) { std::cout << "Mesh boundary assigment routine\n"; if (argc<4) { std::cout << "usage:\n" << "./ResampleWithDataset inMesh.vtu boundaries.stl outG.vtu" << std::endl; exit(EXIT_SUCCESS); } vtkUnstructuredGrid* uGrid;// = vtkUnstructuredGrid::New(); std::string fn = argv[1]; if(fn.substr(fn.find_last_of(".") + 1) == "vtk") { vtkGenericDataObjectReader* Reader = vtkGenericDataObjectReader::New(); Reader->SetFileName(argv[1]); Reader->Update(); if(Reader->IsFileUnstructuredGrid()) { std::cout << "Found Unstructured grid legacy file" << std::endl; uGrid = Reader->GetUnstructuredGridOutput(); } else { std::cerr << "Unknown legacy format"; exit(EXIT_FAILURE); } } else { vtkXMLUnstructuredGridReader* Reader = vtkXMLUnstructuredGridReader::New(); std::cout << "Reading" << argv[1] << std::endl; Reader->SetFileName(argv[1]); Reader->Update(); uGrid = Reader->GetOutput(); } int nc = uGrid->GetNumberOfCells() ; int nn = uGrid->GetNumberOfPoints() ; std::cout << "Processing grid with nodes=" << nn << "\t cells=" << nc << "\n"; vtkSTLReader* Stencil = vtkSTLReader::New(); Stencil->SetFileName(argv[2]); Stencil->Update(); vtkProbeFilter* Resample = vtkProbeFilter::New(); //Resample->SetSourceData( uGrid ); //Resample->SetInputData( Stencil->GetOutput() ); Resample->SetInputData( uGrid ); Resample->SetSourceData( Stencil->GetOutput() ); Resample->SpatialMatchOn(); Resample->SetValidPointMaskArrayName("HomogeneousDirichlet"); Resample->Update(); //std::cout << *Resample << std::endl;. std::cout << "Resampled grid, ncells=" << Resample->GetOutput()->GetNumberOfCells() << " npoints=" << Resample->GetOutput()->GetNumberOfPoints() << std::endl; vtkXMLUnstructuredGridWriter* Writer = vtkXMLUnstructuredGridWriter::New(); Writer->SetInputData( Resample->GetOutput() ); Writer->SetFileName( argv[3] ); Writer->Write(); Writer->Delete(); Resample->Delete(); //Reader->Delete(); Stencil->Delete(); //std::cout << *Stencil << std::endl; }