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.
 
 
 
 
 
 

36 lines
1.4 KiB

#include <spdlog/spdlog.h>
#include "Util.h"
int main() {
using namespace da::sha::top;
std::string ex_name = "Lshape";
std::filesystem::path out_dir(OUTPUT_DIR);
std::filesystem::path assets_dir(ASSETS_DIR);
std::filesystem::path rho_path =
out_dir / "txt" / ex_name / (ex_name + "_MeTop_rho.txt");
spdlog::info("Algo read density(0~1) model from '{}'", rho_path.string());
Tensor3d tr_rho = ReadTensor3d(rho_path);
// USER DEFINED THRESHOLD HERE
double threshold = 0.35;
std::string str_thresh =
"_thresh" + std::to_string((int) (threshold * 100));
for (int k = 0; k < tr_rho.dimension(2); ++k) {
for (int j = 0; j < tr_rho.dimension(1); ++j) {
for (int i = 0; i < tr_rho.dimension(0); ++i) {
tr_rho(i, j, k) = tr_rho(i, j, k) >= threshold ? 1 : 0;
}
}
}
std::filesystem::path txt_path =
assets_dir / "voxel_model" /
("Clamped_" + ex_name + "_model" + str_thresh +
".txt");
WriteTensor3d(txt_path, tr_rho);
spdlog::info("Write user defined grid to file: {}", txt_path.string());
std::filesystem::path vtk_path =
assets_dir / "voxel_model" /
("Clamped_" + ex_name + "_model" + str_thresh +
".vtk");
WriteTensorToVtk(vtk_path, tr_rho);
spdlog::info("visualize user defined grid to file: {}", vtk_path.string());
}