1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- /* 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->Update();
-
- std::cout << *Resample << 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;
-
- }
|