You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.3 KiB
54 lines
1.3 KiB
#pragma once
|
|
#include <Eigen/Core>
|
|
#include <cstring>
|
|
namespace meshless {
|
|
template <int dim>
|
|
void writePntVTK(const std::string& path, const Eigen::MatrixXd& pnts, const std::vector<double>& attri) {
|
|
std::ofstream out(path);
|
|
out << "# vtk DataFile Version 3.0\n"
|
|
"Volume Mesh\n"
|
|
"ASCII\n"
|
|
"DATASET UNSTRUCTURED_GRID"
|
|
<< std::endl;
|
|
out << "POINTS " << pnts.rows() << " float" << std::endl;
|
|
for(int i = 0; i < pnts.rows(); ++i) {
|
|
for(int j = 0; j < dim; ++j) {
|
|
out << std::setprecision(4) << pnts(i, j) << " ";
|
|
}
|
|
for(int j = dim; j < 3; ++j) {
|
|
out << "0 ";
|
|
}
|
|
out << std::endl;
|
|
}
|
|
int innersize = 0;
|
|
int interSize = 0;
|
|
int bounSize = 0;
|
|
|
|
out << "CELLS " << pnts.rows() << " " << pnts.rows() * (1 + 1) << std::endl;
|
|
for(int i = 0; i < pnts.rows(); ++i) {
|
|
out << "1 " << i << std::endl;
|
|
}
|
|
out << "CELL_TYPES " << pnts.rows() << std::endl;
|
|
for(int i = 0; i < pnts.rows(); ++i) {
|
|
out << 1 << std::endl;
|
|
}
|
|
|
|
if(!attri.empty()) {
|
|
out << "POINT_DATA " << attri.size() << "\n"
|
|
<< "SCALARS point_scalars double 1\n"
|
|
<< "LOOKUP_TABLE default" << std::endl;
|
|
for(auto& d : attri) {
|
|
out << d << std::endl;
|
|
if(d == 1)
|
|
innersize++;
|
|
else
|
|
bounSize++;
|
|
}
|
|
}
|
|
std::cout << "�ڲ��㣺 " << innersize << "\n";
|
|
std::cout << "�߽��㣺 " << bounSize << "\n";
|
|
}
|
|
|
|
|
|
|
|
};
|