@@ -62,33 +62,12 @@ bool useCache = true;
62
62
std::shared_ptr<Discregrid::CubicLagrangeDiscreteGrid> distanceField;
63
63
64
64
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
-
81
65
std::ostream& operator << (std::ostream& out, const Eigen::Matrix<unsigned int , 3 , 1 >& r)
82
66
{
83
67
out << r[0 ] << " , " << r[1 ] << " , " << r[2 ];
84
68
return out;
85
69
}
86
70
87
- std::istream& operator >> (std::istream& istream, Vector3r& r)
88
- {
89
- return istream >> std::skipws >> r[0 ] >> r[1 ] >> r[2 ];
90
- }
91
-
92
71
std::ostream& operator << (std::ostream& out, const Vector3r& r)
93
72
{
94
73
out << r[0 ] << " , " << r[1 ] << " , " << r[2 ];
@@ -113,17 +92,17 @@ int main(int argc, char **argv)
113
92
(" i,input" , " Input file (obj)" , cxxopts::value<std::string>())
114
93
(" o,output" , " Output file (bgeo or vtk)" , cxxopts::value<std::string>())
115
94
(" 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" ))
117
96
(" 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> >())
119
98
(" steps" , " SPH time steps" , cxxopts::value<unsigned int >()->default_value (" 100" ))
120
99
(" cflFactor" , " CFL factor" , cxxopts::value<Real>()->default_value (" 0.25" ))
121
100
(" viscosity" , " Viscosity coefficient (XSPH)" , cxxopts::value<Real>()->default_value (" 0.25" ))
122
101
(" cohesion" , " Cohesion coefficient" , cxxopts::value<Real>())
123
102
(" adhesion" , " Adhesion coefficient" , cxxopts::value<Real>())
124
103
(" stiffness" , " Stiffness coefficient (only mode 3)" , cxxopts::value<Real>()->default_value (" 10000.0" ))
125
104
(" 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 >>())
127
106
(" invert" , " Invert the SDF to sample the outside of the object in the bounding box/region" )
128
107
(" no-cache" , " Disable caching of SDF." )
129
108
;
@@ -182,7 +161,7 @@ int main(int argc, char **argv)
182
161
LOG_INFO << " Radius: " << radius;
183
162
184
163
if (result.count (" scale" ))
185
- scale = result[" scale" ].as <Vector3r>();
164
+ scale = Vector3r ( result[" scale" ].as <std::vector<Real>>(). data ());
186
165
LOG_INFO << " Scale: " << scale;
187
166
188
167
if (result.count (" steps" ))
@@ -213,7 +192,7 @@ int main(int argc, char **argv)
213
192
214
193
if (result.count (" res" ))
215
194
{
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 () );
217
196
LOG_INFO << " SDF resolution: " << resolutionSDF;
218
197
}
219
198
@@ -227,9 +206,14 @@ int main(int argc, char **argv)
227
206
228
207
if (result.count (" region" ))
229
208
{
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." ;
231
214
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 ();
233
217
}
234
218
}
235
219
catch (const cxxopts::exceptions::exception& e)
0 commit comments