Class documentation of Concepts

Loading...
Searching...
No Matches
meshImport.hh
Go to the documentation of this file.
1
6#ifndef meshImport_hh
7#define meshImport_hh
8
9#include <vector>
10#include "mesh.hh"
11#include "toolbox/array.hh"
12#include "toolbox/multiArray.hh"
14#include "basics/debug.hh"
15
16#define ImportMeshReadInts_D 0
17#define ImportMeshReadLine_D 0
18
19namespace concepts {
20
21 // ************************************************************ ImportMesh **
22
32 class ImportMesh {
33 public:
38 : idxStart_(idxStart), Edg_(true), twoAttr_(true), threeAttr_(true),
39 fourAttr_(true), sixAttr_(true), eightAttr_(true) {}
40 virtual ~ImportMesh();
41 protected:
44
46 std::vector<Vertex*> vtx_;
47 std::vector<Connector1*> edg_;
49 MultiArray<1, Vertex*> Vtx_; // map from vertex index in the file to Vertex
50 MultiArray<2, Edge*> Edg_; // map from vertex indices in the file to Edge
51
55 MultiArray<3, Attribute> threeAttr_;
58 MultiArray<8, Attribute> eightAttr_;
59
61 virtual void createEntity_(const MultiIndex<1>& idx);
62 virtual void createEntity_(const MultiIndex<2>& idx);
67 virtual void createEntity_(const MultiIndex<3>& idx);
68 virtual void createEntity_(const MultiIndex<4>& idx);
69 virtual void createEntity_(const MultiIndex<6>& idx);
70 virtual void createEntity_(const MultiIndex<8>& idx);
71
76 virtual void createCell_(const MultiIndex<2>& idx);
77 virtual void createCell_(const MultiIndex<3>& idx);
78 virtual void createCell_(const MultiIndex<4>& idx);
79 virtual void createCell_(const MultiIndex<6>& idx);
80 virtual void createCell_(const MultiIndex<8>& idx);
81
85 uint readInts_(const std::string& i, std::vector<int>& v) const;
92 template<class F>
93 uint readLine_(const std::string& i, Array<F>& a,
94 bool first = false) const;
95
99 void readCells_(const std::string& elms, const Array<bool>& dimensions,
100 const std::vector<Real3d>& vertices);
102 template<uint dim>
104
105 void readAttributes_(const std::string& bound,
106 const Array<bool>& dimensions);
107
109 template<class T>
110 void clear_(std::vector<T*>& field);
111 };
112
113 template<class F>
114 uint ImportMesh::readLine_(const std::string& i, Array<F>& a,
115 bool first) const {
116 std::istringstream input(i.c_str());
117 F number = 0;
118 DEBUGL(ImportMeshReadLine_D, number);
119 std::vector<F> v;
120 if (!first) input >> number;
121 while (input >> number) {
122 v.push_back(number);
123 DEBUGL(ImportMeshReadLine_D, "inserted " << v.back());
124 }
125 a.resize(v.size());
126 for(uint i = 0; i < a.size(); ++i) a[i] = v[i];
127 DEBUGL(ImportMeshReadLine_D, "array = " << a);
128 return a.size();
129 }
130
131 template<class T>
132 void ImportMesh::clear_(std::vector<T*>& field) {
133 for (typename std::vector<T*>::iterator i = field.begin();
134 i != field.end(); ++i) {
135 delete *i; *i = 0;
136 }
137 }
138
139 template<class T>
140 std::ostream& operator<<(std::ostream& os, const std::vector<T*>& field) {
141 uint j=0;
142 for (typename std::vector<T*>::const_iterator i = field.begin();
143 i != field.end(); ++j) {
144 if (i != field.begin()) os << ", ";
145 T* val = *i++;
146 os << '(' << j << ',';
147 if (val) os << *val; else os << '0';
148 os << ')';
149 }
150 return os;
151 }
152
153} // namespace concepts
154
155#endif // meshImport_hh
uint size() const
Returns the requested size of the array.
Definition array.hh:259
void resize(const uint sz)
Definition array.hh:281
const uint idxStart_
Starting point of indices in the files (1 or 0)
Definition meshImport.hh:43
ImportMesh(const uint idxStart=1)
Definition meshImport.hh:37
uint readInts_(const std::string &i, std::vector< int > &v) const
uint readLine_(const std::string &i, Array< F > &a, bool first=false) const
void readCells_(const std::string &elms, const Array< bool > &dimensions, const std::vector< Real3d > &vertices)
virtual void createEntity_(const MultiIndex< 3 > &idx)
MultiArray< 1, Vertex * > Vtx_
Array of the entities.
Definition meshImport.hh:49
void clear_(std::vector< T * > &field)
Deletes the content of field of pointers.
virtual void createCell_(const MultiIndex< 2 > &idx)
MultiArray< 1, Attribute > oneAttr_
Attributes of entities.
Definition meshImport.hh:53
virtual void createEntity_(const MultiIndex< 1 > &idx)
Creation of topological entities Vertex and Edge.
void newCell_(MultiIndex< dim > i)
Creates topological entities and a geometrical cell.
std::vector< Vertex * > vtx_
List of entities.
Definition meshImport.hh:46
#define DEBUGL(doit, msg)
Definition debug.hh:40
Set< F > makeSet(uint n, const F &first,...)
Definition set.hh:320