-
Notifications
You must be signed in to change notification settings - Fork 0
/
meshutil.h
150 lines (135 loc) · 3.88 KB
/
meshutil.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/* $Id: meshutil.h,v 1.3 2008/01/28 07:41:13 canacar Exp $ */
/*
* This file is part of the EMSI Tools Package developed at the
* Brain Research Laboratory, Middle East Technical University
* Department of Electrical and Electronics Engineering.
*
* Copyright (C) 2008 Zeynep Akalin Acar
* Copyright (C) 2008 Can Erkin Acar
* Copyright (C) 2008 Nevzat G. Gencer
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
//---------------------------------------------------------------------------
/*! \file meshutil.h
\brief Mesh Utility class header file.
Contains Mesh utility class decleration.
*/
#ifndef meshUtilH
#define meshUtilH
//---------------------------------------------------------------------------
#include <stdio.h>
#include "define.h"
#define MMGR_BUFSIZE 1024
class Node {
public:
Node(){}
virtual ~Node();
virtual int &node(int i) = 0 ;
};
class Node8:public Node {
public:
Node8():Node() {}
virtual ~Node8();
virtual int &node(int i){
assert (i>=0 && i<8);
return _node[i];
}
private:
int _node[8];
};
class Node20:public Node {
public:
Node20():Node() {}
virtual ~Node20();
virtual int &node(int i){
assert (i>=0 && i<20);
return _node[i];
}
private:
int _node[20];
};
class NodeArray {
public:
NodeArray(int sz):_size(sz) {}
virtual ~NodeArray();
inline int size(void) {return _size;}
virtual Node &operator[](int i) = 0;
private:
int _size;
};
class Node8Array:public NodeArray {
public:
Node8Array(int sz):NodeArray(sz){
assert(sz>0);
_nodes=new Node8[sz];
}
virtual ~Node8Array();
virtual Node &operator[](int i){
assert(i>=0 && i<size());
return _nodes[i];
}
private:
Node8 *_nodes;
};
class Node20Array:public NodeArray {
public:
Node20Array(int sz):NodeArray(sz){
assert(sz>0);
_nodes=new Node20[sz];
}
virtual ~Node20Array();
virtual Node &operator[](int i){
assert(i>=0 && i<size());
return _nodes[i];
}
private:
Node20 *_nodes;
};
enum SourceModelID { SM_J, SM_YAN };
struct DInfo {
point J; // dipole strength
point D; // local coords
SourceModelID smodel; // source model
int elem; // element
int dgroup; // dipole group
};
struct Shell {
double radius;
double sig;
};
class MeshUtil {
public:
static int readListHdr(FILE *f, int *size);
static int readElemListHdr(FILE *f, int *size, int *nen);
static int readIntList(FILE *f, int *lst, int start, int size);
static int readDoubleList(FILE *f, double *lst, int start, int size);
static int readPointList(FILE *f, point *pts, int start, int size);
static int readElemList(FILE *f, NodeArray &nds, int start,
int size, int nn, int en);
static int *loadIntList(FILE *f, int *size);
static int skipLineItems(FILE *f, int start, int size);
static int skipNodeItems(FILE *f, int start, int size, int en);
static int checkHeader(FILE *f, const char *sign);
static int readDipoleList(FILE *f, DInfo *dip, int start,
int size, int ne);
static int readShellList(FILE *f, Shell *sh, int start, int size);
static int *readSensors(char *fn, int &num, int nn);
static DInfo *readDipoles(char *fn, int &num, int ne);
static Shell *readShells(char *fn, int &num);
private:
static char m_buf[MMGR_BUFSIZE];
};
#endif