153 double fraction = 0.05;
154 std::string inputfile1, inputSource, inputTarget;
155 opts.
addOpt< std::string >(
"map,m",
"input map ", &inputfile1 );
156 opts.
addOpt< std::string >(
"source,s",
"source mesh", &inputSource );
157 opts.
addOpt< std::string >(
"target,t",
"target mesh", &inputTarget );
158 opts.
addOpt<
int >(
"dimSource,d",
"dimension of source ", &dimSource );
159 opts.
addOpt<
int >(
"dimTarget,g",
"dimension of target ", &dimTarget );
160 opts.
addOpt<
int >(
"typeOutput,o",
" output type vtk(0), h5m(1), view(default = 2) ", &otype );
162 int startSourceID = -1, endSourceID = -1, startTargetID = -1, endTargetID = -1;
163 opts.
addOpt<
int >(
"startSourceID,b",
"start source id ", &startSourceID );
164 opts.
addOpt<
int >(
"endSourceID,e",
"end source id ", &endSourceID );
165 opts.
addOpt<
int >(
"startTargetID,c",
"start target id ", &startTargetID );
166 opts.
addOpt<
int >(
"endTargetID,f",
"end target id ", &endTargetID );
167 opts.
addOpt<
double >(
"raiseFraction,r",
"fraction for raising source points height (default 0.05)", &fraction );
172 std::string extension =
".vtk";
173 if( 1 <= otype ) extension =
".h5m";
176 int fail = nc_open( inputfile1.c_str(), 0, &
ncFile1 );
177 if( NC_NOWRITE !=
fail )
182 std::cout <<
" opened " << inputfile1 <<
" for map 1 \n";
189 std::cout <<
" n_a, n_b, n_s : " << na1 <<
", " << nb1 <<
", " << ns1 <<
" for map 1 \n";
190 std::vector< int > col1( ns1 ), row1( ns1 );
191 std::vector< double > val1( ns1 );
192 int idrow1, idcol1, ids1;
207 std::string name_map = inputfile1;
209 name_map.erase( name_map.begin() + name_map.length() - 3, name_map.end() );
211 size_t pos = name_map.rfind(
'/', name_map.length() );
212 if( pos != std::string::npos ) name_map = name_map.erase( 0, pos + 1 );
224 std::vector< double > xc_a( na1 ), yc_a( na1 );
225 std::vector< double > xc_b( nb1 ), yc_b( nb1 );
226 int idxc_a, idxc_b, idyc_a, idyc_b;
232 std::vector< double > vertex_coords_src( 3 * na1 );
234 for(
int i = 0; i < na1; i++ )
237 sph.
R = 1 + fraction;
238 sph.
lon = xc_a[i] * M_PI / 180;
239 sph.
lat = yc_a[i] * M_PI / 180;
240 CartVect pos = IntxUtils::spherical_to_cart( sph );
241 vertex_coords_src[3 * i] = pos[0];
242 vertex_coords_src[3 * i + 1] = pos[1];
243 vertex_coords_src[3 * i + 2] = pos[2];
251 std::vector< int > vgid( na1 );
252 for(
int i = 0; i < na1; i++ )
256 std::vector< double > vertex_coords_tgt( 3 * nb1 );
258 for(
int i = 0; i < nb1; i++ )
262 sph.
lon = xc_b[i] * M_PI / 180;
263 sph.
lat = yc_b[i] * M_PI / 180;
264 CartVect pos = IntxUtils::spherical_to_cart( sph );
265 vertex_coords_tgt[3 * i] = pos[0];
266 vertex_coords_tgt[3 * i + 1] = pos[1];
267 vertex_coords_tgt[3 * i + 2] = pos[2];
275 for(
int i = 0; i < nb1; i++ )
287 for(
int i = 0; i < ns1; i++ )
289 array[2 * i] = source_verts[col1[i] - 1];
290 array[2 * i + 1] = target_verts[row1[i] - 1];
292 Range edges( actual_start_handle, actual_start_handle + ns1 - 1 );
297 for(
int i = 0; i < ns1; i++ )
301 std::string name_file = name_map + extension;
303 std::cout <<
" wrote view map file " << name_file <<
" with source fraction height: " << fraction <<
"\n";
308 typedef Eigen::Triplet< double >
Triplet;
309 std::vector< Triplet > tripletList;
310 tripletList.reserve( ns1 );
311 for(
int iv = 0; iv < ns1; iv++ )
316 tripletList.push_back(
Triplet( row1[iv] - 1, col1[iv] - 1, val1[iv] ) );
318 Eigen::SparseMatrix< double > weight1( nb1, na1 );
320 weight1.setFromTriplets( tripletList.begin(), tripletList.end() );
321 weight1.makeCompressed();
325 map< int, EntityHandle > sourceHandles;
326 map< int, EntityHandle > targetHandles;
329 const char* readopts =
"";
335 sids.resize( sRange.
size() );
338 for(
size_t i = 0; i < sids.size(); i++ )
342 sourceHandles[gid] = eh;
347 tids.resize( tRange.
size() );
350 for(
size_t i = 0; i < tids.size(); i++ )
354 targetHandles[gid] = eh;
359 for(
int col = startSourceID - 1; col <= endSourceID - 1; col++ )
363 if( col < 0 )
continue;
364 Eigen::SparseVector< double > colVect = weight1.col( col );
366 for( Eigen::SparseVector< double >::InnerIterator it( colVect ); it; ++it )
368 double weight = it.value();
370 int globalIdRow = it.
index() + 1;
380 targetEnts.
merge( adjCells );
385 std::stringstream fff;
386 fff << name_map <<
"_column" << col + 1 << extension;
393 for(
int row = startTargetID - 1; row <= endTargetID - 1; row++ )
397 if( row < 0 )
continue;
398 Eigen::SparseVector< double > rowVect = weight1.row( row );
400 for( Eigen::SparseVector< double >::InnerIterator it( rowVect ); it; ++it )
402 double weight = it.value();
403 int globalIdCol = it.
index() + 1;
412 sourceEnts.
merge( adjCells );
416 std::stringstream fff;
417 fff << name_map <<
"_row" << row + 1 << extension;