Commit c74ae574 authored by Stenger, Florian's avatar Stenger, Florian
Browse files

meshconv v3.20

parent 737cad9a
No preview for this file type
......@@ -1297,7 +1297,7 @@ void read_wsxm_file(string file, Mesh &m, bool mirror, double bottom){
int i, p, x, y, v[3], line_length=-1, line_count, matrix_count;
double x0, y0, x1, y1, line_value=-999999.0;
//first run through input file just to estimate the number of needed vertices (begin §firstrun)
//first run through input file just to estimate the number of needed vertices (begin $firstrun)
ifstream in(file.c_str(), ios_base::in | ios_base::binary);
if(!in) error("Could not read file \"" + file + "\".");
......@@ -1317,7 +1317,7 @@ void read_wsxm_file(string file, Mesh &m, bool mirror, double bottom){
if(mirror) i*=4;
m.numvertices = 2*i;
//(end §firstrun)
//(end $firstrun)
//open input .wsxm-file
in.open(file.c_str());
......@@ -1346,7 +1346,7 @@ void read_wsxm_file(string file, Mesh &m, bool mirror, double bottom){
if(p < 3){
for(x=p; x<3; ++x) m.vertices[i][x] = 0.0;
}
m.vertices[i][2] = m.vertices[i][2]/1000.0; //conversion from nm to µm
m.vertices[i][2] = m.vertices[i][2]/1000.0; //conversion from nanometers to micrometers
if(line_value == -999999.0) line_value = m.vertices[i][1];
if(m.vertices[i][1] != line_value){
if(line_length == -1) line_length = i;
......@@ -1834,14 +1834,21 @@ void read_msh_file(string file, Mesh &m, int dim_of_world, bool store_boundary_f
//open input .msh-file
ifstream in(file.c_str(), ios_base::in | ios_base::binary);
if(!in) error("Could not read file \"" + file + "\".");
if(!in.good()) error("Could not read file \"" + file + "\".");
//prepare mesh structure
m.dim_of_elements = 1;
m.dim_of_world = dim_of_world;
while(missing_vertices or missing_elements){
in >> buf;
if(buf == "$Nodes"){ //iterate through vertices
if(buf == "$MeshFormat"){ //test support for format
string ascii_or_binary, size_of_double;
in >> buf >> ascii_or_binary >> size_of_double;
if(buf.size() == 0 || buf[0] != '2' || ascii_or_binary != "0" || size_of_double != "8"){
in.close();
error("Only msh-format 2.2 ASCII supported at the moment.");
}
}else if(buf == "$Nodes"){ //iterate through vertices
missing_vertices = false;
in >> buf;
m.numvertices = ival(buf);
......
......@@ -44,7 +44,7 @@
namespace meshconv{
using namespace std;
#define MESHCONV_VERSION "v3.19"
#define MESHCONV_VERSION "v3.20"
#define DEBUG_COUNT_AMBIGUOUS_RAYS 0
#define DEBUG_REFINE_BACKGRID 0
......@@ -476,8 +476,9 @@ template<typename T> struct VertexMap{
vector<pair<Vertex, T>*> find(const Vertex &v_begin, const Vertex &v_end); // find in cubic range
#ifdef DEBUG_MODE
void debug_output_statistics();
void debug_statistics(size_t &node_count, size_t &leaf_count, size_t &crowded_leaf_count,
size_t &entry_count, size_t &max_leaf_entries);
void debug_statistics_first_run(size_t &node_count, size_t &leaf_count,
size_t &crowded_leaf_count, size_t &entry_count, size_t &max_leaf_entries);
void debug_statistics_second_run(double avg, size_t entry_count, double &std_dev_sum);
void debug_output(int indentation=0);
#endif
......@@ -929,7 +930,12 @@ struct BackGrid{
vector<int> current_operation_index;
uchar operation_index_mode;
BackGrid():n(NULL), current_operation_index(0), operation_index_mode(oim_create){}
BackGrid():distance_threshold(0), min_seg_size(0), n(NULL), lamp_count(0),
operation_index_mode(oim_create){
segments[0] = 1;
segments[1] = 1;
segments[2] = 1;
}
~BackGrid(){clear();}
void debug_output_dimensions();
void init(Mesh *m, Mesh *n=NULL, uchar operation_index_mode=oim_create, bool no_scaling=false);
......@@ -1612,7 +1618,14 @@ template<typename T> void VertexMap<T>::debug_output_statistics(){
cout << "\nVertexMap statistics:" << endl;
size_t node_count = 0, leaf_count = 0, crowded_leaf_count = 0, entry_count = 0,
max_leaf_entries = 0;
debug_statistics(node_count, leaf_count, crowded_leaf_count, entry_count, max_leaf_entries);
debug_statistics_first_run(node_count, leaf_count, crowded_leaf_count,
entry_count, max_leaf_entries);
double avg = (double)entry_count / leaf_count;
double std_dev = 0.0;
if(entry_count > 0){
debug_statistics_second_run(avg, entry_count, std_dev);
std_dev = sqrt(std_dev);
}
cout << " node-count: " << node_count << endl;
cout << " leaf-count: " << leaf_count
<< " (" << (double)leaf_count / node_count * 100.0 << "%)" << endl;
......@@ -1620,14 +1633,15 @@ template<typename T> void VertexMap<T>::debug_output_statistics(){
<< " (" << (double)crowded_leaf_count / leaf_count * 100.0 << "%)" << endl;
cout << " entry-count: " << entry_count << endl;
cout << " max. leaf-entries: " << max_leaf_entries << endl;
cout << " avg. leaf-entries: " << (double)entry_count / leaf_count << endl;
cout << " avg. leaf-entries: " << avg << endl;
cout << " std. deviation: " << std_dev << endl;
}
#endif
//--------------------< debug_statistics >
//--------------------< debug_statistics_first_run >
#ifdef DEBUG_MODE
template<typename T> void VertexMap<T>::debug_statistics(size_t &node_count, size_t &leaf_count,
size_t &crowded_leaf_count, size_t &entry_count, size_t &max_leaf_entries){
template<typename T> void VertexMap<T>::debug_statistics_first_run(size_t &node_count,
size_t &leaf_count, size_t &crowded_leaf_count, size_t &entry_count, size_t &max_leaf_entries){
++node_count;
if(p0 == NULL){
++leaf_count;
......@@ -1635,16 +1649,48 @@ template<typename T> void VertexMap<T>::debug_statistics(size_t &node_count, siz
max_leaf_entries = max(max_leaf_entries, entries.size());
if(entries.size() > partition_threshold) ++crowded_leaf_count;
}else{
p0->debug_statistics(node_count,leaf_count,crowded_leaf_count,entry_count,max_leaf_entries);
p1->debug_statistics(node_count,leaf_count,crowded_leaf_count,entry_count,max_leaf_entries);
p0->debug_statistics_first_run(node_count, leaf_count,
crowded_leaf_count, entry_count, max_leaf_entries);
p1->debug_statistics_first_run(node_count, leaf_count,
crowded_leaf_count, entry_count, max_leaf_entries);
if(dim_of_world >= 2){
p2->debug_statistics_first_run(node_count, leaf_count,
crowded_leaf_count, entry_count, max_leaf_entries);
p3->debug_statistics_first_run(node_count, leaf_count,
crowded_leaf_count, entry_count, max_leaf_entries);
if(dim_of_world == 3){
p4->debug_statistics_first_run(node_count, leaf_count,
crowded_leaf_count, entry_count, max_leaf_entries);
p5->debug_statistics_first_run(node_count, leaf_count,
crowded_leaf_count, entry_count, max_leaf_entries);
p6->debug_statistics_first_run(node_count, leaf_count,
crowded_leaf_count, entry_count, max_leaf_entries);
p7->debug_statistics_first_run(node_count, leaf_count,
crowded_leaf_count, entry_count, max_leaf_entries);
}
}
}
}
#endif
//--------------------< debug_statistics_second_run >
#if DEBUG_MODE != 0
template<typename T> void VertexMap<T>::debug_statistics_second_run(double avg,
size_t entry_count, double &std_dev_sum){
if(p0 == NULL){
double deviation = (double)entries.size() - avg;
std_dev_sum += (deviation * deviation) / entry_count;
}else{
p0->debug_statistics_second_run(avg, entry_count, std_dev_sum);
p1->debug_statistics_second_run(avg, entry_count, std_dev_sum);
if(dim_of_world >= 2){
p2->debug_statistics(node_count,leaf_count,crowded_leaf_count,entry_count,max_leaf_entries);
p3->debug_statistics(node_count,leaf_count,crowded_leaf_count,entry_count,max_leaf_entries);
p2->debug_statistics_second_run(avg, entry_count, std_dev_sum);
p3->debug_statistics_second_run(avg, entry_count, std_dev_sum);
if(dim_of_world == 3){
p4->debug_statistics(node_count,leaf_count,crowded_leaf_count,entry_count,max_leaf_entries);
p5->debug_statistics(node_count,leaf_count,crowded_leaf_count,entry_count,max_leaf_entries);
p6->debug_statistics(node_count,leaf_count,crowded_leaf_count,entry_count,max_leaf_entries);
p7->debug_statistics(node_count,leaf_count,crowded_leaf_count,entry_count,max_leaf_entries);
p4->debug_statistics_second_run(avg, entry_count, std_dev_sum);
p5->debug_statistics_second_run(avg, entry_count, std_dev_sum);
p6->debug_statistics_second_run(avg, entry_count, std_dev_sum);
p7->debug_statistics_second_run(avg, entry_count, std_dev_sum);
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment