123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- /* 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 <vtkProbeFilter.h>
- #include <vtkSTLReader.h>
- #include <vtkUnstructuredGrid.h>
- #include <vtkUnstructuredGridReader.h>
- #include <vtkUnstructuredGridWriter.h>
- #include <vtkGenericDataObjectReader.h>
- #include <vtkXMLUnstructuredGridReader.h>
- #include <vtkXMLUnstructuredGridWriter.h>
- #include <vtkDoubleArray.h>
- #include <vtkPointData.h>
- #include <cmath>
- #include <Eigen/Core>
-
-
- 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;
-
- }
|