| 
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -25,7 +25,10 @@ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					#include "BoundaryConditions.hpp" | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					#include "Config.hpp" | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					#include "Utils.hpp" | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					#include <igl/read_triangle_mesh.h> | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					#include <igl/write_triangle_mesh.h> | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					namespace ssim { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    class StaticSimGUI; | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -85,19 +88,24 @@ namespace ssim { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        /// \param v_is_extract if (v_is_extract[i]){ extract the target i; }
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        /// \param extract_coord_flg
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        void ExtractTarget(std::string save_dir,std::vector<bool> v_is_extract,bool extract_coord_flg){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            if(extract_coord_flg){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                // TODO: add coordinate cols
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                spdlog::info("extract {}","coordinate"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            if(extract_coord_flg) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                Eigen::MatrixXd V_surf(SVI.size(), 3); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                for (int svI = 0; svI < SVI.size(); ++svI) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    int vI = SVI[svI]; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    Eigen::Vector3d u = U.segment<3>(vI * 3); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    V_surf.row(svI) = TV.row(vI) + u.transpose(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                igl::write_triangle_mesh(save_dir + "/deformed-surf.obj", V_surf, F_surf); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                spdlog::info("save deformed surface mesh to 'deformed-surf.obj'"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            for(int i=0;i<v_is_extract.size();++i){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                assert(i<SimTargetOption::Target::ENUM_SIZE); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                if(v_is_extract[i]){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    // TODO: add #target col
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    spdlog::info("extract {}",i); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    Utils::writeMatrix(save_dir + "/" + std::to_string(i) + ".txt", map_target_to_evaluated_[i]); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    spdlog::info("extract target {}",i); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            // TODO: extract the file
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        Eigen::MatrixXd EvaluateTarget(SimTargetOption::Target target) { | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -165,26 +173,6 @@ namespace ssim { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        // Return: 1 x 1
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        Eigen::MatrixXd EvaluateCompliance() const; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        void writePntVTK(const std::string &path, const Eigen::MatrixXd &V) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            std::ofstream out(path); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            out << "# vtk DataFile Version 3.0\n" | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                   "Volume Mesh\n" | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                   "ASCII\n" | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                   "DATASET UNSTRUCTURED_GRID" << std::endl; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            out << "POINTS " << V.rows() << " float" << std::endl; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            for (int i = 0; i < V.rows(); ++i) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                out << std::setprecision(4) << V.row(i).x() << " " << V.row(i).y() << " " << V.row(i).z() << std::endl; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            out << "CELLS " << V.rows() << " " << V.rows() * (1 + 1) << std::endl; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            for (int i = 0; i < V.rows(); ++i) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                out << "1 " << i << std::endl; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            out << "CELL_TYPES " << V.rows() << std::endl; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            for (int i = 0; i < V.rows(); ++i) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                out << 1 << std::endl; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    private: | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        MeshModel mesh_; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        MaterialProperty material_property_; | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
				 | 
				
					
  |