Main Lemma Repository
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

RectilinearGridVTKExporter.h 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /* This file is part of Lemma, a geophysical modelling and inversion API.
  2. * More information is available at http://lemmasoftware.org
  3. */
  4. /* This Source Code Form is subject to the terms of the Mozilla Public
  5. * License, v. 2.0. If a copy of the MPL was not distributed with this
  6. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  7. */
  8. /**
  9. * @file
  10. * @date 09/25/2013 08:20:01 AM
  11. * @version $Id$
  12. * @author Trevor Irons (ti)
  13. * @email Trevor.Irons@xri-geo.com
  14. * @copyright Copyright (c) 2013, XRI Geophysics, LLC
  15. * @copyright Copyright (c) 2013, Trevor Irons
  16. */
  17. #ifndef RECTILINEARGRIDVTKEXPORTER_INC
  18. #define RECTILINEARGRIDVTKEXPORTER_INC
  19. #ifdef LEMMAUSEVTK
  20. #include "LemmaObject.h"
  21. #include "RectilinearGrid.h"
  22. #include <vtkSmartPointer.h>
  23. #include "vtkXMLRectilinearGridWriter.h"
  24. #include "vtkRectilinearGrid.h"
  25. #include "vtkDoubleArray.h"
  26. #include "vtkFieldData.h"
  27. #include "vtkCellData.h"
  28. namespace Lemma {
  29. /**
  30. \ingroup LemmaCore
  31. \brief Exports a LemmaRectilinearGrid into a VTKRectilinearGrid.
  32. \details Results can then be dumped to a VTK file or used directly.
  33. */
  34. class RectilinearGridVTKExporter : public LemmaObject {
  35. friend std::ostream &operator<<(std::ostream &stream,
  36. const RectilinearGridVTKExporter &ob);
  37. public:
  38. // ==================== LIFECYCLE =======================
  39. /**
  40. * @copybrief LemmaObject::New()
  41. * @copydetails LemmaObject::New()
  42. */
  43. static RectilinearGridVTKExporter* New();
  44. /**
  45. * Factory method for generating concrete class.
  46. * @return a std::shared_ptr of type RectilinearGridVTKExporter
  47. */
  48. static std::shared_ptr< RectilinearGridVTKExporter > NewSP();
  49. // ==================== OPERATORS =======================
  50. // ==================== OPERATIONS =======================
  51. // ==================== ACCESS =======================
  52. /**
  53. * Sets the Grid to be exported
  54. */
  55. void SetGrid( std::shared_ptr<RectilinearGrid> Grid);
  56. // ==================== INQUIRY =======================
  57. /**
  58. * @return Returns a pointer to a vtkRectilinearGrid containing same information as the Lemma Grid.
  59. */
  60. vtkSmartPointer<vtkRectilinearGrid> GetVTKGrid();
  61. /**
  62. * Writes the exported VTKGrid out to a .vtr XML file
  63. * @param[in] name is the filename to write to. The .vtr extension will be added
  64. */
  65. void WriteVTKGrid( const std::string& name );
  66. /** Returns the name of the underlying class, similiar to Python's type */
  67. virtual inline std::string GetName() const {
  68. return this->CName;
  69. }
  70. protected:
  71. // ==================== LIFECYCLE =======================
  72. /** Default protected constructor, use New */
  73. RectilinearGridVTKExporter ( );
  74. /** Default protected destructor, use Delete */
  75. ~RectilinearGridVTKExporter ();
  76. private:
  77. /** ASCII string representation of the class name */
  78. static constexpr auto CName = "RectilinearGridVTKExporter";
  79. void BuildVTKRectilinearGrid();
  80. // ==================== DATA MEMBERS =========================
  81. /** The Grid to convert from */
  82. std::shared_ptr<RectilinearGrid> Grid;
  83. /** The Grid to convert to */
  84. vtkSmartPointer<vtkRectilinearGrid> VTKGrid;
  85. }; // ----- end of class RectilinearGridVTKExporter -----
  86. } // ----- end of Lemma name -----
  87. #endif // ----- not LEMMAUSEVTK -----
  88. #endif // ----- #ifndef RECTILINEARGRIDVTKEXPORTER_INC -----