Code_TYMPAN  4.4.0
Industrial site acoustic simulation
altimetry_file_reader_impl.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) <2012-2024> <EDF-DTG> <FRANCE>
3  * This file is part of Code_TYMPAN (R).
4  * Code_TYMPAN (R) is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  * Code_TYMPAN (R) is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11  * See the GNU General Public License for more details.
12  * You should have received a copy of the GNU General Public License along
13  * with Code_TYMPAN (R). If not, see <https://www.gnu.org/licenses/>.
14  */
15 
25 #ifndef TYMPAN__ALTIMETRYREADERIMPL_H__INCLUDED
26 #define TYMPAN__ALTIMETRYREADERIMPL_H__INCLUDED
27 
28 typedef struct t_ply_* p_ply; // Avoid including rply.h here
29 
30 #include "altimetry_file_reader.h"
31 #include "qstring.h"
32 
33 namespace tympan
34 {
35 
40 {
41 public:
42  typedef enum
43  {
44  X,
45  Y,
46  Z,
49  typedef enum
50  {
55  typedef enum
56  {
60 
61  AltimetryPLYReader(FILE* fp);
62  virtual ~AltimetryPLYReader();
63 
66  virtual const points_array_t& points() const
67  {
68  return _points;
69  };
70  virtual const faces_array_t& faces() const
71  {
72  return _faces;
73  };
74  virtual const materials_array_t& materials() const
75  {
76  return _material_by_face;
77  };
78  virtual void read();
80 
83  void setup_callbacks();
84  void init_data();
85  void read_data();
88 
91  long nvertices() const
92  {
93  return _nvertices;
94  }
95  long nfaces() const
96  {
97  return _nfaces;
98  }
100 
103  bool vertex_cb(vertex_properties property, unsigned vertex_index, double value);
104  bool face_cb(face_properties property, unsigned face_index, unsigned nproperties, int property_index,
105  double value);
106  bool material_cb(material_properties property, unsigned material_index, unsigned nproperties,
107  int property_index, double value);
108  void error_cb(p_ply ply, const char* message);
110 
113 public:
114  FILE* _fp;
115  inline static FILE* openFileForReading(const QString& filename)
116  {
117 #ifdef _WIN32
118  return _wfopen(reinterpret_cast<const wchar_t*>(filename.utf16()), L"rb");
119 #else
120  return fopen(filename.toUtf8().constData(), "rb");
121 #endif
122  }
123 
124 protected:
127  std::vector<unsigned> _material_indices;
130 
133  long _nfaces;
136 
137 }; // AltimetryPLYReader
138 }; // namespace tympan
139 
140 #endif // TYMPAN__ALTIMETRYREADERIMPL_H__INCLUDED
Provides for reading back an altimetry written in a file.
struct t_ply_ * p_ply
read an Altimetry from a PLY file.
virtual const points_array_t & points() const
std::vector< unsigned > _material_indices
bool vertex_cb(vertex_properties property, unsigned vertex_index, double value)
virtual void read()
read the file whose name was given at reader's construction time
bool face_cb(face_properties property, unsigned face_index, unsigned nproperties, int property_index, double value)
virtual const materials_array_t & materials() const
Getter for the faces read.
void error_cb(p_ply ply, const char *message)
virtual const faces_array_t & faces() const
Getter for the faces read.
static FILE * openFileForReading(const QString &filename)
bool material_cb(material_properties property, unsigned material_index, unsigned nproperties, int property_index, double value)
std::deque< std::string > materials_array_t
Type of the material array returned.
std::deque< OPoint3D > points_array_t
Type of the points array returned.
std::deque< OTriangle > faces_array_t
Type of the faces array returned.