Lemma is an Electromagnetics API
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

RectilinearGridVTKExporter.h 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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@LemmaSoftware.org
  14. * @copyright Copyright (c) 2013, XRI Geophysics, LLC
  15. * @copyright Copyright (c) 2013,2017,2018 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. //struct ctor_key {};
  38. public:
  39. // ==================== LIFECYCLE =======================
  40. /**
  41. * Factory method for generating concrete class.
  42. * @return a std::shared_ptr of type RectilinearGridVTKExporter
  43. */
  44. static std::shared_ptr< RectilinearGridVTKExporter > NewSP();
  45. /** Default constructor */
  46. explicit RectilinearGridVTKExporter ( const ctor_key& );
  47. /** Deserializing constructor */
  48. explicit RectilinearGridVTKExporter ( const YAML::Node& node, const ctor_key& );
  49. /** Default protected destructor, use Delete */
  50. virtual ~RectilinearGridVTKExporter ();
  51. /**
  52. * Uses YAML to serialize this object.
  53. * @return a YAML::Node
  54. */
  55. virtual YAML::Node Serialize() const;
  56. /**
  57. * Constructs an object from a YAML::Node.
  58. */
  59. static std::shared_ptr< RectilinearGridVTKExporter > DeSerialize(const YAML::Node& node);
  60. // ==================== OPERATORS =======================
  61. // ==================== OPERATIONS =======================
  62. // ==================== ACCESS =======================
  63. /**
  64. * Sets the Grid to be exported
  65. */
  66. void SetGrid( std::shared_ptr<RectilinearGrid> Grid);
  67. // ==================== INQUIRY =======================
  68. /**
  69. * @return Returns a pointer to a vtkRectilinearGrid containing same information as the Lemma Grid.
  70. */
  71. vtkSmartPointer<vtkRectilinearGrid> GetVTKGrid();
  72. /**
  73. * Writes the exported VTKGrid out to a .vtr XML file
  74. * @param[in] name is the filename to write to. The .vtr extension will be added
  75. */
  76. void WriteVTKGrid( const std::string& name );
  77. /** Returns the name of the underlying class, similiar to Python's type */
  78. virtual std::string GetName() const;
  79. protected:
  80. // ==================== LIFECYCLE =======================
  81. private:
  82. /** ASCII string representation of the class name */
  83. static constexpr auto CName = "RectilinearGridVTKExporter";
  84. void BuildVTKRectilinearGrid();
  85. // ==================== DATA MEMBERS =========================
  86. /** The Grid to convert from */
  87. std::shared_ptr<RectilinearGrid> Grid;
  88. /** The Grid to convert to */
  89. vtkSmartPointer<vtkRectilinearGrid> VTKGrid;
  90. }; // ----- end of class RectilinearGridVTKExporter -----
  91. } // ----- end of Lemma name -----
  92. #endif // ----- not LEMMAUSEVTK -----
  93. #endif // ----- #ifndef RECTILINEARGRIDVTKEXPORTER_INC -----
  94. /* vim: set tabstop=4 expandtab: */
  95. /* vim: set filetype=cpp syntax=cpp.doxygen: */