59 std::cout <<
"Success";
64 std::cout <<
"Failure";
69 int main(
int argc,
char* argv[] )
71 filename = TestDir +
"unittest/PB.h5m";
79 bool only_cropping =
false;
84 std::cout <<
" default output file: " <<
filename_out <<
" will be deleted \n";
103 std::cout <<
" default output file: " <<
filename_out <<
" will be saved \n";
108 std::cerr <<
"Usage: " << argv[0] <<
" [geom_filename] [polygon_file] [output_file] [min_dot] [quads_file]"
120 if( !pFacet )
return 1;
126 std::cout <<
"root set test: ";
131 std::cout <<
"gentity set test: ";
136 std::cout <<
"geometry evals test: ";
141 std::cout <<
"normal evals test: ";
146 std::cout <<
"ray test: ";
151 std::cout <<
"split with loop test ";
160 std::cout <<
" check split: ";
167 std::cout <<
" split quads test: ";
205 for( ; ent_type < num_type; ent_type++ )
219 rval = pFacet->
getNumOfType( ges_array[ent_type], ent_type, &number_array[ent_type] );
MB_CHK_SET_ERR( rval,
"Failed to get number of gentities by type in entityset_test." );
222 int num_type_gentity = gentities.
size();
224 if( number_array[ent_type] != num_type_gentity )
226 std::cerr <<
"Number of gentities by type is not correct" << std::endl;
237 MB_CHK_SET_ERR( rval,
"Failed to create a super set in gentityset_test." );
239 for(
int i = 0; i < num_type; i++ )
241 rval = pFacet->
addEntSet( ges_array[i], super_set );
MB_CHK_SET_ERR( rval,
"Failed to create a super set in gentityset_test." );
252 Range gedges, gfaces, temp_gentities1;
253 rval = pFacet->
getEntities( ges_array[1], 1, gedges );
MB_CHK_SET_ERR( rval,
"Failed to get gedge gentities in gentityset_test." );
259 rval = pFacet->
getEntities( ges_array[2], 2, gfaces );
MB_CHK_SET_ERR( rval,
"Failed to get gface gentities in gentityset_test." );
265 rval = pFacet->
gsubtract( temp_ges1, ges_array[1], temp_ges1 );
MB_CHK_SET_ERR( rval,
"Failed to subtract gentitysets in gentityset_test." );
267 rval = pFacet->
getEntities( temp_ges1, 2, temp_gentities1 );
MB_CHK_SET_ERR( rval,
"Failed to get gface gentities in gentityset_test." );
269 if( gfaces.
size() != temp_gentities1.
size() )
271 std::cerr <<
"Number of entitysets after subtraction not correct \
279 rval = pFacet->
getNumOfType( temp_ges1, 1, &num_gents );
MB_CHK_SET_ERR( rval,
"Failed to get dimensions of gentities in gentityset_test." );
282 std::cerr <<
"Subtraction failed to remove all edges" << std::endl;
296 int num_test_top = 4;
297 std::vector< std::vector< EntityHandle > > gentity_vectors( num_test_top );
301 for( i = top; i < num_test_top; i++ )
306 gentity_vectors[i].resize( gentities.
size() );
307 std::copy( gentities.
begin(), gentities.
end(), gentity_vectors[i].begin() );
311 double min[3], max[3], on[3];
312 double near[3] = { .0, .0, .0 };
313 std::vector< EntityHandle >::iterator vit;
316 for( i = 3; i >= 0; i-- )
320 for( vit = gentity_vectors[i].begin(); vit != gentity_vectors[i].end(); ++vit )
324 rval = pFacet->
getEntBoundBox( this_gent, &min[0], &min[1], &min[2], &max[0], &max[1], &max[2] );
MB_CHK_SET_ERR( rval,
"Failed to get bounding box of entity." );
326 for(
int j = 0; j < 3; j++ )
327 near[j] = ( min[j] + max[j] ) / 2.;
328 rval = pFacet->
getEntClosestPt( this_gent, near[0], near[1], near[2], &on[0], &on[1], &on[2] );
MB_CHK_SET_ERR( rval,
"Failed to get closest point on entity." );
334 for( vit = gentity_vectors[i].begin(); vit != gentity_vectors[i].end(); ++vit )
340 rval = pFacet->
getEntUtoXYZ( this_gent, 0.33, near[0], near[1], near[2] );
MB_CHK_SET_ERR( rval,
"Failed to get a new point" );
342 std::cout <<
" entity of type " << i <<
" position:\n " << near[0] <<
" " << near[1] <<
" " << near[2]
344 rval = pFacet->
getEntClosestPt( this_gent, near[0], near[1], near[2], &on[0], &on[1], &on[2] );
MB_CHK_SET_ERR( rval,
"Failed to get closest point on entity." );
346 std::cout <<
" close by: " << on[0] <<
" " << on[1] <<
" " << on[2] <<
"\n";
362 int num_test_top = 4;
363 std::vector< std::vector< EntityHandle > > gentity_vectors( num_test_top );
367 for( i = top; i < num_test_top; i++ )
372 gentity_vectors[i].resize( gentities.
size() );
373 std::copy( gentities.
begin(), gentities.
end(), gentity_vectors[i].begin() );
377 double min[3], max[3];
378 double normal[3] = { .0, .0, .0 };
379 std::vector< EntityHandle >::iterator vit;
380 for( i = 3 ; i > 1 ; i-- )
382 for( vit = gentity_vectors[i].begin(); vit != gentity_vectors[i].end(); ++vit )
385 rval = pFacet->
getEntBoundBox( this_gent, &min[0], &min[1], &min[2], &max[0], &max[1], &max[2] );
MB_CHK_SET_ERR( rval,
"Failed to get bounding box of entity." );
387 rval = pFacet->
getEntNrmlXYZ( this_gent, ( max[0] + min[0] ) / 2, ( max[1] + min[1] ) / 2,
388 ( max[2] + min[2] ) / 2, &normal[0], &normal[1], &normal[2] );
MB_CHK_SET_ERR( rval,
"Failed to get normal to the closest point." );
390 std::cout <<
" entity of type " << i <<
" closest normal to center:\n " << normal[0] <<
" " << normal[1]
391 <<
" " << normal[2] <<
"\n";
413 double min[3], max[3];
417 rval = pFacet->
getEntBoundBox( first_face, &min[0], &min[1], &min[2], &max[0], &max[1], &max[2] );
MB_CHK_SET_ERR( rval,
"Failed to get bounding box of entity." );
421 double x = ( min[0] + max[0] ) / 2, y = ( min[1] + max[1] ) / 2, z = min[2];
422 std::vector< EntityHandle > intersect_entity_handles;
423 std::vector< double > intersect_coords;
424 std::vector< double > param_coords;
428 intersect_entity_handles,
430 intersect_coords, param_coords );
MB_CHK_SET_ERR( rval,
"Failed to find ray intersections points " );
432 for(
unsigned int i = 0; i < intersect_entity_handles.size(); i++ )
438 << intersect_coords[3 * i] <<
" " << intersect_coords[3 * i + 1] <<
" " << intersect_coords[3 * i + 2]
440 <<
" distance: " << param_coords[i] <<
"\n";
470 std::cout <<
"can't read file\n";
477 datafile.getline( temp, 100 );
480 sscanf( temp,
" %lf %lf %lf %lf ", direction, direction + 1, direction + 2, &gridSize );
483 std::vector< double > xyz;
484 while( !datafile.eof() )
486 datafile.getline( temp, 100 );
489 int nr = sscanf( temp,
"%lf %lf %lf", &x, &y, &z );
497 int sizePolygon = (int)xyz.size() / 3;
498 if( sizePolygon < 3 )
500 std::cerr <<
" Not enough points in the polygon" << std::endl;
514 std::vector< EntityHandle > gents;
515 gents.push_back( newFace );
543 std::cout <<
"root set test: ";
548 std::cout <<
"gentity set test: ";
553 std::cout <<
"geometry evals test: ";
558 std::cout <<
"normal evals test: ";
563 std::cout <<
"ray test: ";
593 if( faces.
size() != 2 )
595 std::cout <<
"num faces after loading quads model:" << faces.
size() <<
"\n";
600 std::cout <<
"gentity set test: ";
605 std::cout <<
"geometry evals test: ";
610 std::cout <<
"normal evals test: ";
615 std::cout <<
"ray test: ";
625 std::string spl_file =
"q.split.h5m";
630 remove( spl_file.c_str() );