initial upload
This commit is contained in:
97
archive/msh2vtk/sysDefine_msh2vtk.h
Normal file
97
archive/msh2vtk/sysDefine_msh2vtk.h
Normal file
@@ -0,0 +1,97 @@
|
||||
#ifndef _SYSDEFINE_MSH2VTK_H
|
||||
#define _SYSDEFINE_MSH2VTK_H
|
||||
#include "iostream"
|
||||
#include "fstream"
|
||||
#include "string.h"
|
||||
#include "sstream"
|
||||
#include "stdio.h"
|
||||
#include "stdlib.h"
|
||||
#include "iomanip"
|
||||
#include "cmath"
|
||||
#include "vector"
|
||||
#include "map"
|
||||
|
||||
#define BOLDRED "\033[1m\033[31m"
|
||||
#define RESET "\033[0m"
|
||||
|
||||
using namespace std;
|
||||
|
||||
typedef vector<int> _1iArray;
|
||||
typedef vector<double> _1dArray;
|
||||
typedef vector<string> strArray;
|
||||
typedef map<int,int> typesMap;
|
||||
|
||||
struct node
|
||||
{
|
||||
int id;
|
||||
double x, y, z;
|
||||
};
|
||||
typedef vector<node> nodeArray;
|
||||
|
||||
struct element
|
||||
{
|
||||
int id;
|
||||
int msh_type;
|
||||
int vtk_type;
|
||||
int msh_info_num;
|
||||
_1iArray msh_info;
|
||||
_1iArray nodes_index;
|
||||
};
|
||||
typedef vector<element> elementArray;
|
||||
|
||||
struct elementData
|
||||
{
|
||||
_1iArray ids;
|
||||
string name;
|
||||
_1dArray val;
|
||||
};
|
||||
typedef vector<elementData> elementDataArray;
|
||||
|
||||
struct nodeData
|
||||
{
|
||||
_1iArray ids;
|
||||
string name;
|
||||
_1dArray val;
|
||||
};
|
||||
typedef vector<nodeData> nodeDataArray;
|
||||
|
||||
//全局函数
|
||||
int open_infile(ifstream &infile,char* filename)
|
||||
{
|
||||
infile.open(filename);
|
||||
if (!infile)
|
||||
{
|
||||
cout << BOLDRED << "error ==> " << RESET << "file not found: " << filename << endl;
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int open_outfile(ofstream &outfile,char* filename)
|
||||
{
|
||||
outfile.open(filename);
|
||||
if (!outfile)
|
||||
{
|
||||
cout << BOLDRED << "error ==> " << RESET << "fail to create the file: " << filename << endl;
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//替换str中所有lod_value为new_value,返回被替换的old_value的个数
|
||||
string& replace_all(string& str,const string& old_value,const string& new_value,int &num)
|
||||
{
|
||||
int count = 0;
|
||||
for(string::size_type pos(0);pos!=string::npos;pos+=new_value.length())
|
||||
{
|
||||
if((pos=str.find(old_value,pos))!=string::npos)
|
||||
{
|
||||
str.replace(pos,old_value.length(),new_value);
|
||||
count++;
|
||||
}
|
||||
else break;
|
||||
}
|
||||
num = count;
|
||||
return str;
|
||||
}
|
||||
#endif
|
Reference in New Issue
Block a user