tmp update
This commit is contained in:
32
demo.cpp
32
demo.cpp
@@ -1,4 +1,4 @@
|
||||
#include "tin.h"
|
||||
#include "tin_backup.h"
|
||||
#include "iostream"
|
||||
#include "fstream"
|
||||
#include "iomanip"
|
||||
@@ -6,10 +6,10 @@
|
||||
int main(int argc, char const *argv[])
|
||||
{
|
||||
// read dem grid
|
||||
std::vector<double> topo(10201);
|
||||
std::vector<double> topo(1002001);
|
||||
|
||||
std::ifstream infile("topo.txt");
|
||||
for (int i = 0; i < 10201; ++i)
|
||||
std::ifstream infile("topo2.txt");
|
||||
for (int i = 0; i < 1002001; ++i)
|
||||
{
|
||||
infile >> topo[i];
|
||||
}
|
||||
@@ -18,10 +18,10 @@ int main(int argc, char const *argv[])
|
||||
std::vector<double> err_records;
|
||||
std::vector<vertex2dc*> tin_vert;
|
||||
std::vector<triangle*> tin_ele;
|
||||
dem2tin(topo, 0, 1000, 0, 1000, 10, 10, tin_vert, tin_ele, 0.5, &err_records);
|
||||
dem2tin(topo, 0, 1000, 0, 1000, 1, 1, tin_vert, tin_ele, 5.0, &err_records);
|
||||
|
||||
// Write a log file
|
||||
std::ofstream logfile("topo_TIN.log");
|
||||
std::ofstream logfile("topo2_TIN.log");
|
||||
logfile << "# Insertion Maxi-Error\n";
|
||||
for (int i = 0; i < err_records.size(); ++i)
|
||||
{
|
||||
@@ -30,7 +30,7 @@ int main(int argc, char const *argv[])
|
||||
logfile.close();
|
||||
|
||||
// Write a Gmsh's .msh file
|
||||
std::ofstream outfile("topo_TIN.msh");
|
||||
std::ofstream outfile("topo2_TIN.msh");
|
||||
outfile << "$MeshFormat" << std::endl << "2.2 0 8" << std::endl << "$EndMeshFormat "<<std::endl;
|
||||
outfile << "$Nodes" << std::endl << tin_vert.size() << std::endl;
|
||||
for (int i = 0; i < tin_vert.size(); i++)
|
||||
@@ -63,6 +63,24 @@ int main(int argc, char const *argv[])
|
||||
outfile << "$EndNodeData" << std::endl;
|
||||
outfile.close();
|
||||
|
||||
// write a neighbor file
|
||||
outfile.open("topo2_TIN.neigh");
|
||||
outfile << tin_ele.size() << std::endl;
|
||||
for (int i = 0; i < tin_ele.size(); i++)
|
||||
{
|
||||
outfile << i + 1;
|
||||
for (int j = 0; j < 3; j++)
|
||||
{
|
||||
if (tin_ele[i]->neigh[j] != nullptr)
|
||||
{
|
||||
outfile << " " << tin_ele[i]->neigh[j]->id + 1;
|
||||
}
|
||||
else outfile << " -1";
|
||||
}
|
||||
outfile << std::endl;
|
||||
}
|
||||
outfile.close();
|
||||
|
||||
// Destroy memories allocated by the dem2tin function
|
||||
for (int i = 0; i < tin_vert.size(); ++i)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user