@@ -62,33 +62,12 @@ bool useCache = true;
6262std::shared_ptr<Discregrid::CubicLagrangeDiscreteGrid> distanceField;
6363
6464
65- std::istream& operator >> (std::istream& istream, SamplingBase::Region& r)
66- {
67- return istream >> std::skipws >> r.m_min [0 ] >> r.m_min [1 ] >> r.m_min [2 ] >> r.m_max [0 ] >> r.m_max [1 ] >> r.m_max [2 ];
68- }
69-
70- std::ostream& operator << (std::ostream& out, const SamplingBase::Region& r)
71- {
72- out << r.m_min [0 ] << " , " << r.m_min [1 ] << " , " << r.m_min [2 ] << " , " << r.m_max [0 ] << " , " << r.m_max [1 ] << " , " << r.m_max [2 ];
73- return out;
74- }
75-
76- std::istream& operator >> (std::istream& istream, Eigen::Matrix<unsigned int , 3 , 1 >& r)
77- {
78- return istream >> std::skipws >> r[0 ] >> r[1 ] >> r[2 ];
79- }
80-
8165std::ostream& operator << (std::ostream& out, const Eigen::Matrix<unsigned int , 3 , 1 >& r)
8266{
8367 out << r[0 ] << " , " << r[1 ] << " , " << r[2 ];
8468 return out;
8569}
8670
87- std::istream& operator >> (std::istream& istream, Vector3r& r)
88- {
89- return istream >> std::skipws >> r[0 ] >> r[1 ] >> r[2 ];
90- }
91-
9271std::ostream& operator << (std::ostream& out, const Vector3r& r)
9372{
9473 out << r[0 ] << " , " << r[1 ] << " , " << r[2 ];
@@ -113,17 +92,17 @@ int main(int argc, char **argv)
11392 (" i,input" , " Input file (obj)" , cxxopts::value<std::string>())
11493 (" o,output" , " Output file (bgeo or vtk)" , cxxopts::value<std::string>())
11594 (" r,radius" , " Particle radius" , cxxopts::value<Real>()->default_value (" 0.025" ))
116- (" s,scale" , " Scaling of input geometry (e.g. --scale \" 2 1 2 \" )" , cxxopts::value<Vector3r> ()->default_value (" 1 1 1" ))
95+ (" s,scale" , " Scaling of input geometry (e.g. --scale 2,1,2 )" , cxxopts::value<std::vector<Real>> ()->default_value (" 1,1, 1" ))
11796 (" m,mode" , " Mode (regular=0, almost dense=1, dense=2, Jiang et al. 2015=3, Kugelstadt et al. 2021=4)" , cxxopts::value<int >()->default_value (" 4" ))
118- (" region" , " Region to fill with particles (e.g. --region \" 0 0 0 1 1 1 \" )" , cxxopts::value<SamplingBase::Region >())
97+ (" region" , " Region to fill with particles (e.g. --region 0,0,0,1,1,1 )" , cxxopts::value<std::vector<Real> >())
11998 (" steps" , " SPH time steps" , cxxopts::value<unsigned int >()->default_value (" 100" ))
12099 (" cflFactor" , " CFL factor" , cxxopts::value<Real>()->default_value (" 0.25" ))
121100 (" viscosity" , " Viscosity coefficient (XSPH)" , cxxopts::value<Real>()->default_value (" 0.25" ))
122101 (" cohesion" , " Cohesion coefficient" , cxxopts::value<Real>())
123102 (" adhesion" , " Adhesion coefficient" , cxxopts::value<Real>())
124103 (" stiffness" , " Stiffness coefficient (only mode 3)" , cxxopts::value<Real>()->default_value (" 10000.0" ))
125104 (" dt" , " Time step size (only mode 3)" , cxxopts::value<Real>()->default_value (" 0.0005" ))
126- (" res" , " Resolution of the Signed Distance Field (e.g. --res \" 30 30 30 \" )" , cxxopts::value<Eigen::Matrix <unsigned int , 3 , 1 >>())
105+ (" res" , " Resolution of the Signed Distance Field (e.g. --res 30,30,30 )" , cxxopts::value<std::vector <unsigned int >>())
127106 (" invert" , " Invert the SDF to sample the outside of the object in the bounding box/region" )
128107 (" no-cache" , " Disable caching of SDF." )
129108 ;
@@ -182,7 +161,7 @@ int main(int argc, char **argv)
182161 LOG_INFO << " Radius: " << radius;
183162
184163 if (result.count (" scale" ))
185- scale = result[" scale" ].as <Vector3r>();
164+ scale = Vector3r ( result[" scale" ].as <std::vector<Real>>(). data ());
186165 LOG_INFO << " Scale: " << scale;
187166
188167 if (result.count (" steps" ))
@@ -213,7 +192,7 @@ int main(int argc, char **argv)
213192
214193 if (result.count (" res" ))
215194 {
216- resolutionSDF = result[" res" ].as <Eigen::Matrix <unsigned int , 3 , 1 >>();
195+ resolutionSDF = Eigen::Matrix< unsigned int , 3 , 1 >( result[" res" ].as <std::vector <unsigned int >>(). data () );
217196 LOG_INFO << " SDF resolution: " << resolutionSDF;
218197 }
219198
@@ -227,9 +206,14 @@ int main(int argc, char **argv)
227206
228207 if (result.count (" region" ))
229208 {
230- region = result[" region" ].as <SamplingBase::Region>();
209+ const std::vector<Real> &v = result[" region" ].as <std::vector<Real>>();
210+ if (v.size () == 6 )
211+ region = SamplingBase::Region (v[0 ], v[1 ], v[2 ], v[3 ], v[4 ], v[5 ]);
212+ else
213+ LOG_WARN << " Region parameter has wrong number of elements." ;
231214 useRegion = true ;
232- LOG_INFO << " Region: " << region;
215+ LOG_INFO << " Region - min: " << region.m_min .transpose ();
216+ LOG_INFO << " Region - max: " << region.m_max .transpose ();
233217 }
234218 }
235219 catch (const cxxopts::exceptions::exception& e)
0 commit comments