22 string bd_name = string(
MESH_DIR ) + string(
"/../examples/earth/boundary_points.dat" );
23 string loops = string(
MESH_DIR ) + string(
"/../examples/earth/SaveLoopCounts" );
36 lon = atan2( p[1], p[0] );
40 return 2.0 * M_PI + lon;
51 bool interior_point( vector< double >& coords,
int& startLoop,
int& endLoop,
double lat,
double lon )
55 double totalAngle = 0;
56 for(
int i = startLoop; i <= endLoop; i++ )
58 double x1 = coords[2 * i], y1 = coords[2 * i + 1];
60 if( i == endLoop ) i2 = startLoop;
61 double x2 = coords[2 * i2], y2 = coords[2 * i2 + 1];
62 CartVect P1( x1 - lat, y1 - lon, 0. );
63 CartVect P2( x2 - lat, y2 - lon, 0. );
65 double angle1 =
angle( P1, P2 );
66 if(
cross[2] < 0 ) angle1 = -angle1;
69 if( fabs( totalAngle + 2 * M_PI ) < 0.1 || fabs( totalAngle - 2 * M_PI ) < 0.1 )
return true;
73 int main(
int argc,
char** argv )
77 if( NULL ==
mb )
return 1;
86 std::vector< double > coords;
87 ifstream bdFile(
bd_name.c_str() );
90 cout << endl <<
"Failed to open file " <<
bd_name << endl;
95 while( !bdFile.eof() )
99 coords.push_back( co );
101 cout <<
" number of boundary points:" << coords.size() / 3 <<
"\n";
103 vector< int > loopsindx;
104 ifstream loopFile(
loops.c_str() );
105 while( !loopFile.eof() )
109 loopsindx.push_back( indx );
111 cout <<
"number of loops: " << loopsindx.size() / 2 <<
"\n";
115 vector< double > coords2d;
116 coords2d.resize( coords.size() / 3 * 2 );
117 for(
int i = 0; i < (int)coords.size() / 3; i++ )
119 CartVect p( coords[3 * i], coords[3 * i + 1], coords[3 * i + 2] );
120 coords2d[2 * i] =
getLat( p );
121 coords2d[2 * i + 1] =
getLon( p );
130 cout <<
"number of cells: " << cells.
size() <<
"\n";
137 for(
int loop_index = 0; loop_index < 6; loop_index++ )
140 int startLoop = loopsindx[2 * loop_index];
141 int endLoop = loopsindx[2 * loop_index + 1];
143 vector< EntityHandle > interiorCells;
157 interiorCells.push_back( cell );
162 rval =
mb->
add_entities( islandSets[loop_index], &interiorCells[0], interiorCells.size() );
MB_CHK_SET_ERR( rval,
"Can't add entities to set" );
165 std::stringstream islandFile;
167 islandFile <<
"map.h5m";