LCOV - code coverage report
Current view: top level - ugbase/lib_grid/file_io - file_io_ugx.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 10 0
Test Date: 2025-09-21 23:31:46 Functions: - 0 0

            Line data    Source code
       1              : /*
       2              :  * Copyright (c) 2010-2015:  G-CSC, Goethe University Frankfurt
       3              :  * Author: Sebastian Reiter
       4              :  * 
       5              :  * This file is part of UG4.
       6              :  * 
       7              :  * UG4 is free software: you can redistribute it and/or modify it under the
       8              :  * terms of the GNU Lesser General Public License version 3 (as published by the
       9              :  * Free Software Foundation) with the following additional attribution
      10              :  * requirements (according to LGPL/GPL v3 §7):
      11              :  * 
      12              :  * (1) The following notice must be displayed in the Appropriate Legal Notices
      13              :  * of covered and combined works: "Based on UG4 (www.ug4.org/license)".
      14              :  * 
      15              :  * (2) The following notice must be displayed at a prominent place in the
      16              :  * terminal output of covered works: "Based on UG4 (www.ug4.org/license)".
      17              :  * 
      18              :  * (3) The following bibliography is recommended for citation and must be
      19              :  * preserved in all covered files:
      20              :  * "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively
      21              :  *   parallel geometric multigrid solver on hierarchically distributed grids.
      22              :  *   Computing and visualization in science 16, 4 (2013), 151-164"
      23              :  * "Vogel, A., Reiter, S., Rupp, M., Nägel, A., and Wittum, G. UG4 -- a novel
      24              :  *   flexible software system for simulating pde based models on high performance
      25              :  *   computers. Computing and visualization in science 16, 4 (2013), 165-179"
      26              :  * 
      27              :  * This program is distributed in the hope that it will be useful,
      28              :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      29              :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
      30              :  * GNU Lesser General Public License for more details.
      31              :  */
      32              : 
      33              : #ifndef __H__LIB_GRID__FILE_IO_UGX__
      34              : #define __H__LIB_GRID__FILE_IO_UGX__
      35              : 
      36              : 
      37              : #include <errno.h>
      38              : #include <cstdlib>
      39              : #include <iostream>
      40              : #include <vector>
      41              : #include <utility>
      42              : #include "common/parser/rapidxml/rapidxml.hpp"
      43              : #include "lib_grid/grid/grid.h"
      44              : #include "lib_grid/multi_grid.h"
      45              : #include "lib_grid/tools/subset_handler_interface.h"
      46              : #include "lib_grid/tools/selector_interface.h"
      47              : #include "lib_grid/common_attachments.h"
      48              : #include "lib_grid/grid_objects/grid_objects.h"
      49              : #include "lib_grid/refinement/projectors/refinement_projector.h"
      50              : #include "common/math/misc/shapes.h"  // AABox
      51              : 
      52              : namespace ug
      53              : {
      54              : 
      55              : class ProjectionHandler;
      56              : 
      57              : ////////////////////////////////////////////////////////////////////////
      58              : ///     Writes a grid to an ugx file. internally uses GridWriterUGX.
      59              : /**     The position attachment can be specified. Since the type of the
      60              :  *      position attachment is a template parameter, MathVector attachments
      61              :  *      of any dimension are supported. Especially ug::aPosition, ug::aPostion2
      62              :  *      and ug::aPosition1.
      63              :  */
      64              : template <class TAPosition>
      65              : bool SaveGridToUGX(Grid& grid, ISubsetHandler& sh,
      66              :                                    const char* filename, TAPosition& aPos);
      67              : 
      68              : ///     Writes a grid to a ugx file.
      69              : /**     Before writing a grid to file, this method searches for the
      70              :  *      attached standard position attachment with the highest dimension.
      71              :  *      This will be used as position-attachment in a call to the overloaded
      72              :  *      version of SaveGridToUGX.
      73              :  */
      74              : bool SaveGridToUGX(Grid& grid, ISubsetHandler& sh,
      75              :                                    const char* filename);
      76              : 
      77              : ////////////////////////////////////////////////////////////////////////
      78              : ///     Reads a grid to an ugx file. internally uses GridReaderUGX.
      79              : /**     The position attachment can be specified. Since the type of the
      80              :  *      position attachment is a template parameter, MathVector attachments
      81              :  *      of any dimension are supported. Especially ug::aPosition, ug::aPostion2
      82              :  *      and ug::aPosition1.
      83              :  */
      84              : template <class TAPosition>
      85              : bool LoadGridFromUGX(Grid& grid, ISubsetHandler& sh,
      86              :                                         const char* filename, APosition& aPos);
      87              : 
      88              : ///     Reads a grid to an ugx file.
      89              : /**     Before reading a grid from file, this method searches for the
      90              :  *      attached standard position attachment with the highest dimension.
      91              :  *      This will be used as position-attachment in a call to the overloaded
      92              :  *      version of LoadGridFromUGX.
      93              :  *
      94              :  *      If no standard attachment is found, aPosition will be attached and used.
      95              :  */
      96              : bool LoadGridFromUGX(Grid& grid, ISubsetHandler& sh,
      97              :                                         const char* filename);
      98              :                                         
      99              :                                         
     100              : 
     101              : ////////////////////////////////////////////////////////////////////////                                        
     102              : ////////////////////////////////////////////////////////////////////////
     103              : ///     Grants write access to ugx files.
     104              : /**     Make sure that all elements added via one of the add_* methods
     105              :  *      exist until the FileAccessor is destroyed.
     106              :  */
     107              : class GridWriterUGX
     108              : {
     109              :         public:
     110              :                 GridWriterUGX();
     111              :                 virtual ~GridWriterUGX();
     112              : 
     113              :         /**     TPositionAttachments value type has to be compatible with MathVector.
     114              :          *      Make sure that aPos is attached to the vertices of the grid.*/
     115              :                 template <class TPositionAttachment>
     116              :                 bool add_grid(Grid& grid, const char* name,
     117              :                                           TPositionAttachment& aPos);
     118              : 
     119              : //              template <class TPositionAttachment>
     120              : //              void add_grid(MultiGrid& mg, const char* name,
     121              : //                                        TPositionAttachment& aPos);
     122              : 
     123              :                 void add_subset_handler(ISubsetHandler& sh, const char* name,
     124              :                                                                 size_t refGridIndex);
     125              : 
     126              :                 void add_selector(ISelector& sel, const char* name,
     127              :                                                   size_t refGridIndex);
     128              : 
     129              :                 void add_projection_handler(ProjectionHandler& ph, const char* name,
     130              :                                                                         size_t refGridIndex);
     131              : 
     132              :                 template <class TElem, class TAttachment>
     133              :                 void add_attachment(TAttachment attachment,
     134              :                                                         const char* name,
     135              :                                                         size_t refGridIndex);
     136              : 
     137              :                 virtual bool write_to_stream(std::ostream& out);
     138              : 
     139              :                 bool write_to_file(const char* filename);
     140              : 
     141              :         protected:
     142              :                 typedef Grid::VertexAttachmentAccessor<AInt> AAVrtIndex;
     143              :                 typedef Grid::EdgeAttachmentAccessor<AInt> AAEdgeIndex;
     144              :                 typedef Grid::FaceAttachmentAccessor<AInt> AAFaceIndex;
     145              :                 typedef Grid::VolumeAttachmentAccessor<AInt> AAVolIndex;
     146              : 
     147              :         protected:
     148              :                 void init_grid_attachments(Grid& grid);
     149              :                 
     150              :         //      VERTICES
     151              :                 template <class TAAPos>
     152              :                 rapidxml::xml_node<>*
     153              :                 create_vertex_node(RegularVertexIterator vrtsBegin,
     154              :                                                   RegularVertexIterator vrtsEnd,
     155              :                                                   TAAPos& aaPos);
     156              : 
     157              :                 template <class TAAPos>
     158              :                 rapidxml::xml_node<>*
     159              :                 create_constrained_vertex_node(ConstrainedVertexIterator vrtsBegin,
     160              :                                                                                 ConstrainedVertexIterator vrtsEnd,
     161              :                                                                                 TAAPos& aaPos,
     162              :                                                                                 AAEdgeIndex aaIndEDGE,
     163              :                                                                                 AAFaceIndex aaIndFACE);
     164              :                                                 
     165              :                                                                                                                 
     166              :         ///     adds grid elements (edges, faces, volumes) to the given node.
     167              :                 void add_elements_to_node(rapidxml::xml_node<>* node,
     168              :                                                                   Grid& grid);
     169              : 
     170              :         //      EDGES
     171              :                 rapidxml::xml_node<>*
     172              :                 create_edge_node(RegularEdgeIterator edgesBegin,
     173              :                                                  RegularEdgeIterator edgesEnd,
     174              :                                                  AAVrtIndex aaIndVRT);
     175              : 
     176              :                 rapidxml::xml_node<>*
     177              :                 create_constraining_edge_node(ConstrainingEdgeIterator edgesBegin,
     178              :                                                                           ConstrainingEdgeIterator edgesEnd,
     179              :                                                                           AAVrtIndex aaIndVRT);
     180              :                                                           
     181              :                 rapidxml::xml_node<>*
     182              :                 create_constrained_edge_node(ConstrainedEdgeIterator edgesBegin,
     183              :                                                                          ConstrainedEdgeIterator edgesEnd,
     184              :                                                                          AAVrtIndex aaIndVRT,
     185              :                                                                          AAEdgeIndex aaIndEDGE,
     186              :                                                                          AAFaceIndex aaIndFACE);
     187              :                                                                          
     188              :         //      FACES
     189              :                 rapidxml::xml_node<>*
     190              :                 create_triangle_node(TriangleIterator trisBegin,
     191              :                                                          TriangleIterator trisEnd,
     192              :                                                          AAVrtIndex aaIndVRT);
     193              : 
     194              :                 rapidxml::xml_node<>*
     195              :                 create_constraining_triangle_node(ConstrainingTriangleIterator trisBegin,
     196              :                                                                                   ConstrainingTriangleIterator trisEnd,
     197              :                                                                                   AAVrtIndex aaIndVRT);
     198              : 
     199              :                 rapidxml::xml_node<>*
     200              :                 create_constrained_triangle_node(ConstrainedTriangleIterator trisBegin,
     201              :                                                                                  ConstrainedTriangleIterator trisEnd,
     202              :                                                                                  AAVrtIndex aaIndVRT,
     203              :                                                                                  AAFaceIndex aaIndFACE);
     204              :                                                          
     205              :                 rapidxml::xml_node<>*
     206              :                 create_quadrilateral_node(QuadrilateralIterator quadsBegin,
     207              :                                                                   QuadrilateralIterator quadsEnd,
     208              :                                                                   AAVrtIndex aaIndVRT);
     209              : 
     210              :                 rapidxml::xml_node<>*
     211              :                 create_constraining_quadrilateral_node(ConstrainingQuadrilateralIterator quadsBegin,
     212              :                                                                                            ConstrainingQuadrilateralIterator quadsEnd,
     213              :                                                                                            AAVrtIndex aaIndVRT);
     214              : 
     215              :                 rapidxml::xml_node<>*
     216              :                 create_constrained_quadrilateral_node(ConstrainedQuadrilateralIterator quadsBegin,
     217              :                                                                                           ConstrainedQuadrilateralIterator quadsEnd,
     218              :                                                                                           AAVrtIndex aaIndVRT,
     219              :                                                                                           AAFaceIndex aaIndFACE);
     220              :         //      VOLUMES
     221              :                 rapidxml::xml_node<>*
     222              :                 create_tetrahedron_node(TetrahedronIterator tetsBegin,
     223              :                                                                   TetrahedronIterator tetsEnd,
     224              :                                                                   AAVrtIndex aaIndVRT);
     225              : 
     226              :                 rapidxml::xml_node<>*
     227              :                 create_hexahedron_node(HexahedronIterator hexasBegin,
     228              :                                                                   HexahedronIterator hexasEnd,
     229              :                                                                   AAVrtIndex aaIndVRT);
     230              : 
     231              :                 rapidxml::xml_node<>*
     232              :                 create_prism_node(PrismIterator prismsBegin,
     233              :                                                         PrismIterator prismsEnd,
     234              :                                                         AAVrtIndex aaIndVRT);
     235              : 
     236              :                 rapidxml::xml_node<>*
     237              :                 create_pyramid_node(PyramidIterator pyrasBegin,
     238              :                                                         PyramidIterator pyrasEnd,
     239              :                                                         AAVrtIndex aaIndVRT);
     240              : 
     241              :                 rapidxml::xml_node<>*
     242              :                 create_octahedron_node(OctahedronIterator octsBegin,
     243              :                                                                 OctahedronIterator octsEnd,
     244              :                                                                 AAVrtIndex aaIndVRT);
     245              : 
     246              :                 void add_subset_attributes(rapidxml::xml_node<>* targetNode,
     247              :                                                                    ISubsetHandler& sh, size_t subsetIndex);
     248              : 
     249              :                 template <class TGeomObj>
     250              :                 rapidxml::xml_node<>*
     251              :                 create_subset_element_node(const char* name,
     252              :                                                                    const ISubsetHandler& sh,
     253              :                                                                    size_t si);
     254              : 
     255              :                 template <class TGeomObj>
     256              :                 rapidxml::xml_node<>*
     257              :                 create_selector_element_node(const char* name, const ISelector& sel);
     258              : 
     259              : 
     260              :                 rapidxml::xml_node<>*
     261              :                 create_projector_node(RefinementProjector& proj, const char* nodeName);
     262              : 
     263              :                 template <class TElem>
     264              :                 void process_global_attachments(Grid& grid, rapidxml::xml_node<>* gridNode);
     265              : 
     266              :                 template <class TElem>
     267              :                 const char* attachment_node_name();
     268              : 
     269              :         protected:
     270              :         ///     entries are stored for each grid.
     271              :         /**     an entry holds a pointer to a grid together with its xml_node.*/
     272            0 :                 struct Entry{
     273              :                         Entry() {}
     274            0 :                         Entry(Grid* g, rapidxml::xml_node<>* n) :
     275            0 :                                 grid(g), node(n)        {}
     276              : 
     277              :                         Grid* grid;
     278              :                         std::vector<const ISubsetHandler*> subsetHandlers;
     279              :                         rapidxml::xml_node<>* node;
     280              :                 };
     281              : 
     282              :         ///     the xml_document which stores the data
     283              :                 rapidxml::xml_document<> m_doc;
     284              : 
     285              :         ///     List of accessible grids
     286              :                 std::vector<Entry> m_vEntries;
     287              : 
     288              :         ///     attached to vertices of each grid during add_grid.
     289              :                 AInt    m_aInt;
     290              : };
     291              : 
     292              : 
     293              : ////////////////////////////////////////////////////////////////////////
     294              : ///     Grants read access to ugx files.
     295              : /**     Before any data can be retrieved using the get_* methods, a file
     296              :  *      has to be successfully loaded using load_file.
     297              :  *
     298              :  *      \todo: Improve performance by using in-situ stringstreams during element creation.
     299              :  */
     300              : class GridReaderUGX
     301              : {
     302              :         public:
     303              :                 GridReaderUGX();
     304              :                 virtual ~GridReaderUGX();
     305              : 
     306              :         ///     parses an xml file
     307              :                 bool parse_file(const char* filename);
     308              : 
     309              :         ///     returns the number of grids
     310              :                 inline size_t num_grids() const {return m_entries.size();}
     311              : 
     312              :         ///     returns the i-th grid.
     313              :         /**     TPositionAttachments value type has to be compatible with MathVector.
     314              :          *      Make sure that a file has already been loaded.*/
     315              :                 template <class TPositionAttachment>
     316              :                 bool grid(Grid& gridOut, size_t index,
     317              :                                           TPositionAttachment& aPos);
     318              : 
     319              :         ///     returns the name of the i-th grid
     320              :                 const char* get_grid_name(size_t index) const;
     321              : 
     322              :         ///     returns the number of subset handlers for the given grid
     323              :                 size_t num_subset_handlers(size_t refGridIndex) const;
     324              : 
     325              :         ///     returns the name of the given subset handler
     326              :                 const char* get_subset_handler_name(size_t refGridIndex,
     327              :                                                                                         size_t subsetHandlerIndex) const;
     328              : 
     329              :         ///     fills the given subset-handler
     330              :                 bool subset_handler(ISubsetHandler& shOut,
     331              :                                                                 size_t subsetHandlerIndex,
     332              :                                                                 size_t refGridIndex);
     333              : 
     334              :         ///     returns the number of selectors for the given grid
     335              :                 size_t num_selectors(size_t refGridIndex) const;
     336              : 
     337              :         ///     returns the name of the given selector
     338              :                 const char* get_selector_name(size_t refGridIndex, size_t selectorIndex) const;
     339              : 
     340              :         ///     fills the given selector
     341              :                 bool selector(ISelector& selOut, size_t selectorIndex, size_t refGridIndex);
     342              : 
     343              :         ///     returns the number of projection-handlers for the given grid
     344              :                 size_t num_projection_handlers(size_t refGridIndex) const;
     345              : 
     346              :         ///     returns the name of the given projection-handler
     347              :                 const char* get_projection_handler_name(size_t refGridIndex, size_t phIndex) const;
     348              : 
     349              :         ///     returns the subset handler index for a projection handler
     350              :                 size_t get_projection_handler_subset_handler_index(size_t phIndex, size_t refGridIndex);
     351              : 
     352              :         ///     fills the given projection-handler
     353              :                 bool projection_handler(ProjectionHandler& phOut, size_t phIndex, size_t refGridIndex);
     354              :                 
     355              :         protected:
     356              :                 struct SubsetHandlerEntry
     357              :                 {
     358            0 :                         SubsetHandlerEntry(rapidxml::xml_node<>* n) : node(n), sh(NULL) {}
     359              : 
     360              :                         rapidxml::xml_node<>*     node;
     361              :                         ISubsetHandler*                 sh;
     362              :                 };
     363              : 
     364              :                 struct SelectorEntry
     365              :                 {
     366            0 :                         SelectorEntry(rapidxml::xml_node<>* n) : node(n), sel(NULL) {}
     367              : 
     368              :                         rapidxml::xml_node<>*     node;
     369              :                         ISelector*                              sel;
     370              :                 };
     371              : 
     372              :                 struct GridEntry
     373              :                 {
     374            0 :                         GridEntry(rapidxml::xml_node<>* n) : node(n), grid(NULL), mg(NULL)        {}
     375              : 
     376              :                         rapidxml::xml_node<>* node;
     377              :                         Grid*           grid;
     378              :                         MultiGrid*      mg;
     379              :                         std::vector<SubsetHandlerEntry>   subsetHandlerEntries;
     380              :                         std::vector<SelectorEntry>                selectorEntries;
     381              :                         std::vector<rapidxml::xml_node<>*>  projectionHandlerEntries;
     382              :                         std::vector<Vertex*>              vertices;
     383              :                         std::vector<Edge*>                        edges;
     384              :                         std::vector<Face*>                                faces;
     385              :                         std::vector<Volume*>                      volumes;
     386              :                 };
     387              : 
     388              :         protected:
     389              :         ///     initializes internal arrays
     390              :         /**     searches for all grid-nodes and stores, resizes m_entries and stores
     391              :          *      the node for each entry.
     392              :          *
     393              :          *      If you create your own version of this method, don't forget to call the
     394              :          *      base-class implementation!*/
     395              :                 virtual bool new_document_parsed();
     396              : 
     397              :         ///     creates vertices from a vertex-node.
     398              :         /**     if aaPos has more coordinates per vertex than the vrtNode,
     399              :          *      0's will be appended. If it has less, unused coordinates will
     400              :          *      be ignored.*/
     401              :                 template <class TAAPos>
     402              :                 bool create_vertices(std::vector<Vertex*>& vrtsOut, Grid& grid,
     403              :                                                         rapidxml::xml_node<>* vrtNode, TAAPos aaPos);
     404              : 
     405              :                 template <class TAAPos>
     406              :                 bool create_constrained_vertices(std::vector<Vertex*>& vrtsOut,
     407              :                                                         std::vector<std::pair<int, int> >& constrainingObjsOut,
     408              :                                                         Grid& grid, rapidxml::xml_node<>* vrtNode, TAAPos aaPos);
     409              :                                                         
     410              :                 bool create_edges(std::vector<Edge*>& edgesOut,
     411              :                                                   Grid& grid, rapidxml::xml_node<>* node,
     412              :                                                   std::vector<Vertex*>& vrts);
     413              : 
     414              :                 bool create_constraining_edges(std::vector<Edge*>& edgesOut,
     415              :                                                   Grid& grid, rapidxml::xml_node<>* node,
     416              :                                                   std::vector<Vertex*>& vrts);
     417              : 
     418              :                 bool create_constrained_edges(std::vector<Edge*>& edgesOut,
     419              :                                                   std::vector<std::pair<int, int> >& constrainingObjsOut,
     420              :                                                   Grid& grid, rapidxml::xml_node<>* node,
     421              :                                                   std::vector<Vertex*>& vrts);
     422              : 
     423              :                 bool create_triangles(std::vector<Face*>& facesOut,
     424              :                                                           Grid& grid, rapidxml::xml_node<>* node,
     425              :                                                           std::vector<Vertex*>& vrts);
     426              : 
     427              :                 bool create_constraining_triangles(std::vector<Face*>& facesOut,
     428              :                                                           Grid& grid, rapidxml::xml_node<>* node,
     429              :                                                           std::vector<Vertex*>& vrts);
     430              : 
     431              :                 bool create_constrained_triangles(std::vector<Face*>& facesOut,
     432              :                                                           std::vector<std::pair<int, int> >& constrainingObjsOut,
     433              :                                                           Grid& grid, rapidxml::xml_node<>* node,
     434              :                                                           std::vector<Vertex*>& vrts);
     435              :                                                           
     436              :                 bool create_quadrilaterals(std::vector<Face*>& facesOut,
     437              :                                                                    Grid& grid, rapidxml::xml_node<>* node,
     438              :                                                                    std::vector<Vertex*>& vrts);
     439              : 
     440              :                 bool create_constraining_quadrilaterals(std::vector<Face*>& facesOut,
     441              :                                                           Grid& grid, rapidxml::xml_node<>* node,
     442              :                                                           std::vector<Vertex*>& vrts);
     443              : 
     444              :                 bool create_constrained_quadrilaterals(std::vector<Face*>& facesOut,
     445              :                                                           std::vector<std::pair<int, int> >& constrainingObjsOut,
     446              :                                                           Grid& grid, rapidxml::xml_node<>* node,
     447              :                                                           std::vector<Vertex*>& vrts);
     448              :                                                           
     449              :                 bool create_tetrahedrons(std::vector<Volume*>& volsOut,
     450              :                                                                  Grid& grid, rapidxml::xml_node<>* node,
     451              :                                                                  std::vector<Vertex*>& vrts);
     452              : 
     453              :                 bool create_hexahedrons(std::vector<Volume*>& volsOut,
     454              :                                                                 Grid& grid, rapidxml::xml_node<>* node,
     455              :                                                                 std::vector<Vertex*>& vrts);
     456              : 
     457              :                 bool create_prisms(std::vector<Volume*>& volsOut,
     458              :                                                         Grid& grid, rapidxml::xml_node<>* node,
     459              :                                                         std::vector<Vertex*>& vrts);
     460              : 
     461              :                 bool create_pyramids(std::vector<Volume*>& volsOut,
     462              :                                                         Grid& grid, rapidxml::xml_node<>* node,
     463              :                                                         std::vector<Vertex*>& vrts);
     464              : 
     465              :                 bool create_octahedrons(std::vector<Volume*>& volsOut,
     466              :                                                                 Grid& grid, rapidxml::xml_node<>* node,
     467              :                                                                 std::vector<Vertex*>& vrts);
     468              : 
     469              :                 template <class TGeomObj>
     470              :                 bool read_subset_handler_elements(ISubsetHandler& shOut,
     471              :                                                                                  const char* elemNodeName,
     472              :                                                                                  rapidxml::xml_node<>* subsetNode,
     473              :                                                                                  int subsetIndex,
     474              :                                                                                  std::vector<TGeomObj*>& vElems);
     475              : 
     476              :                 template <class TGeomObj>
     477              :                 bool read_selector_elements(ISelector& selOut,
     478              :                                                                          const char* elemNodeName,
     479              :                                                                          rapidxml::xml_node<>* selNode,
     480              :                                                                          std::vector<TGeomObj*>& vElems);
     481              : 
     482              :                 template <class TElem>
     483              :                 bool read_attachment(Grid& grid, rapidxml::xml_node<>* node);
     484              : 
     485              :                 SPRefinementProjector
     486              :                 read_projector(rapidxml::xml_node<>* projNode);
     487              : 
     488              :         protected:
     489              :         ///     the xml_document which stores the data
     490              :                 rapidxml::xml_document<> m_doc;
     491              : 
     492              :         ///     holds grids which already have been created
     493              :                 std::vector<GridEntry>    m_entries;
     494              : };
     495              : 
     496              : 
     497            0 : class UGXFileInfo{
     498              :         public:
     499              :                 UGXFileInfo();
     500              : 
     501              :                 bool parse_file(const char* filename);
     502              : 
     503              :                 size_t num_grids() const;
     504              :                 size_t num_subset_handlers(size_t gridInd) const;
     505              :                 size_t num_subsets(size_t gridInd, size_t shInd) const;
     506              : 
     507              :                 std::string grid_name(size_t gridInd) const;
     508              :                 std::string subset_handler_name(size_t gridInd, size_t shInd) const;
     509              :                 std::string subset_name(size_t gridInd, size_t shInd, size_t subsetInd) const;
     510              : 
     511              :                 bool grid_has_vertices(size_t gridInd) const;
     512              :                 bool grid_has_edges(size_t gridInd) const;
     513              :                 bool grid_has_faces(size_t gridInd) const;
     514              :                 bool grid_has_volumes(size_t gridInd) const;
     515              : 
     516              :         ///     Returns the physical dimension of the given grid.
     517              :         /** We define the 'maximal range' as the maximum of the ranges of the
     518              :          *      the particular coordinates. Then the result is
     519              :          *      3 - if the z-coordinate are in a range that is larger than
     520              :          *              SMALL times the maximal range;
     521              :          *      2 - if it is not 3 and the y-coordinate are in a range that is
     522              :          *              larger than SMALL times the maximal range;
     523              :          *      1 - if it is not 0 or 1 and the x-coordinate are in a range that is
     524              :          *              larger than SMALL times the maximal range;
     525              :          *      0 - if it is not 3 or 2 or 1 (i.e. if the geometry resides in one point).
     526              :          */
     527              :                 size_t physical_grid_dimension(size_t gridInd) const;
     528              : 
     529              :         ///     Returns the topological dimension of the given grid.
     530              :         /** That is the dimension of the element of highest dimension in the given grid.
     531              :          */
     532              :                 size_t topological_grid_dimension(size_t gridInd) const;
     533              : 
     534              :         ///     Returns the dimension of the world-coordinates required for the given grid.
     535              :         /** We define the 'maximal range' as the maximum of the ranges of the
     536              :          *      the particular coordinates. Then the result is
     537              :          *      3 - if the z-coordinate are in a range that is larger than
     538              :          *              SMALL times the maximal range;
     539              :          *      2 - if it is not 3 and the y-coordinate are in a range that is
     540              :          *              larger than SMALL times the maximal range;
     541              :          *      1 - if it is not 0 or 1 and the x-coordinate are in a range that is
     542              :          *              larger than SMALL times the maximal range;
     543              :          *      0 - if it is not 3 or 2 or 1 (i.e. if the geometry resides in one point).
     544              :          *
     545              :          *      @note           The functionality of this method has been changed slightly as of
     546              :          *                              2015-03-13 and is the same as in physical_grid_dimension(size_t gridInd);
     547              :          *                              the previous functionality is still available in
     548              :          *                              topological_grid_dimension(size_t gridInd).
     549              :          *      @deprecated     This method is marked deprecated and might be removed
     550              :          *                              in a future update.
     551              :          *                              Please use physical_grid_dimension(size_t gridInd) and
     552              :          *                              topological_grid_dimension(size_t gridInd) instead.
     553              :          */
     554              :                 size_t grid_world_dimension(size_t gridInd) const;
     555              : 
     556              : 
     557              :         private:
     558            0 :                 struct SubsetInfo{
     559              :                         std::string     m_name;
     560              :                 };
     561              : 
     562            0 :                 struct SubsetHandlerInfo{
     563              :                         std::string     m_name;
     564              :                         std::vector<SubsetInfo>   m_subsets;
     565              :                 };
     566              : 
     567            0 :                 struct GridInfo{
     568              :                         std::string     m_name;
     569              :                         bool    m_hasVertices;
     570              :                         bool    m_hasEdges;
     571              :                         bool    m_hasFaces;
     572              :                         bool    m_hasVolumes;
     573              :                         std::vector<SubsetHandlerInfo>    m_subsetHandlers;
     574              :                         vector3 m_extension;
     575              :                 };
     576              : 
     577              :                 std::vector<GridInfo>     m_grids;
     578              :                 bool                                    m_fileParsed;
     579              : 
     580              : 
     581              :         private:
     582              :         ///     returns the name-attribute of the node or "" if none exists
     583              :                 std::string node_name(rapidxml::xml_node<>* n) const;
     584              : 
     585              :         ///     throws an error if no file has been parsed yet
     586              :                 void check_file_parsed() const;
     587              : 
     588              :         ///     return the queried grid info and throws an error if the grid index is out of range
     589              :         /**     Also calls check_file_parsed().*/
     590              :                 const GridInfo& grid_info(size_t index) const;
     591              : 
     592              :         ///     throws an error if the subset handler index is out of range
     593              :         /**     Also calls check_grid_index.*/
     594              :                 const SubsetHandlerInfo& subset_handler_info(size_t gridInd, size_t shInd) const;
     595              : 
     596              :         ///     throws an error if the subset index is out of range.
     597              :         /**     Also calls check_subset_handler_index.*/
     598              :                 const SubsetInfo& subset_info(size_t gridInd, size_t shInd, size_t subsetInd) const;
     599              : 
     600              :         /// calculates the bounding box of a group of vertices
     601              :         /**
     602              :          *
     603              :          * @param[in] vrtNode   node in the xml file (containing vertex information)
     604              :          * @param[out] bb               output bounding box
     605              :          *
     606              :          * @return true if at least one valid (coordinate dimension in {0,1,2,3}) vertex is contained
     607              :          */
     608              :                 bool calculate_vertex_node_bbox(rapidxml::xml_node<>* vrtNode, AABox<vector3>& bb) const;
     609              : };
     610              : 
     611              : }//     end of namespace
     612              : 
     613              : ////////////////////////////////
     614              : //      include implementation
     615              : #include "file_io_ugx_impl.hpp"
     616              : 
     617              : #endif
        

Generated by: LCOV version 2.0-1