#include #include "Util.h" int main() { using namespace da::sha::top; std::string rho_path = OUTPUT_DIR "/txt/Lshape/Lshape_MeTop_rho.txt"; spdlog::info("Algo read density(0~1) model from '{}'", rho_path); 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::string txt_path = ASSETS_DIR "/voxel_model/Clamped_Lshape_model" + str_thresh + ".txt"; WriteTensor3d(txt_path, tr_rho); spdlog::info("Write user defined grid to file: {}", txt_path); std::string vtk_path = ASSETS_DIR "/voxel_model/Clamped_Lshape_model" + str_thresh + ".vtk"; WriteTensorToVtk(vtk_path, tr_rho); spdlog::info("visualize user defined grid to file: {}", vtk_path); }