MOAB: Mesh Oriented datABase  (version 5.2.1)
mbfacet_test.cpp
Go to the documentation of this file.
00001 /**
00002  * This library is free software; you can redistribute it and/or
00003  * modify it under the terms of the GNU Lesser General Public
00004  * License as published by the Free Software Foundation; either
00005  * version 2.1 of the License, or (at your option) any later version.
00006  *
00007  */
00008 /**
00009  * \file mbfacet_test.cpp
00010  *
00011  * \brief test mbfacet, a unit test for the FBEngine class, which is providing iGeom like methods to
00012  * a MOAB db
00013  *
00014  */
00015 #include "moab/Core.hpp"
00016 #include <iostream>
00017 #include <fstream>
00018 #include <set>
00019 #include <algorithm>
00020 #include <vector>
00021 #include <iterator>
00022 #include <algorithm>
00023 #include <iomanip>
00024 #include <assert.h>
00025 #include <string.h>
00026 #include <math.h>
00027 #include "moab/FBEngine.hpp"
00028 #include "moab/GeomTopoTool.hpp"
00029 #include "TestUtil.hpp"
00030 
00031 std::string filename;
00032 std::string filename_out;
00033 std::string polygon_file_name;
00034 
00035 std::string quads_file;
00036 
00037 double min_dot = 0.8;  // default
00038 
00039 bool keep_output;
00040 int number_tests_successful = 0;
00041 int number_tests_failed     = 0;
00042 
00043 using namespace moab;
00044 
00045 ErrorCode root_set_test( FBEngine* pFacet );
00046 ErrorCode gentityset_test( FBEngine* pFacet );
00047 ErrorCode geometry_evaluation_test( FBEngine* pFacet );
00048 ErrorCode normals_test( FBEngine* pFacet );
00049 ErrorCode ray_test( FBEngine* pFacet );
00050 ErrorCode split_test( Interface* mb, FBEngine* pFacet );
00051 ErrorCode check_split( Interface* mb );
00052 
00053 ErrorCode split_quads_test();
00054 
00055 void handle_error_code( ErrorCode rv, int& number_failed, int& number_successful )
00056 {
00057     if( rv == MB_SUCCESS )
00058     {
00059         std::cout << "Success";
00060         number_successful++;
00061     }
00062     else
00063     {
00064         std::cout << "Failure";
00065         number_failed++;
00066     }
00067 }
00068 
00069 int main( int argc, char* argv[] )
00070 {
00071     filename          = TestDir + "/PB.h5m";
00072     polygon_file_name = TestDir + "/polyPB.txt";
00073     filename_out      = "PB_facet.h5m";
00074     quads_file        = TestDir + "/quads.h5m";
00075 
00076     min_dot = 0.8;
00077 
00078     keep_output        = false;
00079     bool only_cropping = false;
00080     if( argc == 1 )
00081     {
00082         std::cout << "Using default input files: " << filename << " " << polygon_file_name << " " << filename_out << " "
00083                   << min_dot << " " << quads_file << std::endl;
00084         std::cout << "    default output file: " << filename_out << " will be deleted \n";
00085     }
00086     else if( argc == 5 )
00087     {
00088         only_cropping     = true;
00089         filename          = argv[1];
00090         polygon_file_name = argv[2];
00091         filename_out      = argv[3];
00092         min_dot           = atof( argv[4] );
00093     }
00094     else if( argc >= 6 )
00095     {
00096         filename          = argv[1];
00097         polygon_file_name = argv[2];
00098         filename_out      = argv[3];
00099         min_dot           = atof( argv[4] );
00100         quads_file        = argv[5];
00101         keep_output       = true;
00102         std::cout << "Using input files: " << filename << " " << polygon_file_name << " " << std::endl;
00103         std::cout << "    default output file: " << filename_out << " will be saved \n";
00104         std::cout << " min_dot: " << min_dot << " quads file:" << quads_file << "\n";
00105     }
00106     else
00107     {
00108         std::cerr << "Usage: " << argv[0] << " [geom_filename] [polygon_file] [output_file] [min_dot] [quads_file]"
00109                   << std::endl;
00110         return 1;
00111     }
00112 
00113     Core mbcore;
00114     Interface* mb = &mbcore;
00115 
00116     ErrorCode rval = mb->load_file( filename.c_str() );MB_CHK_SET_ERR( rval, "failed to load input file" );
00117 
00118     FBEngine* pFacet = new FBEngine( mb, NULL, true );  // smooth facetting, no OBB tree passed
00119 
00120     if( !pFacet ) return 1;  // error
00121 
00122     // should the init be part of constructor or not?
00123     // this is where the obb tree is constructed, and smooth faceting initialized, too.
00124     rval = pFacet->Init();MB_CHK_SET_ERR( rval, "failed to initialize smoothing" );
00125 
00126     std::cout << "root set test: ";
00127     rval = root_set_test( pFacet );
00128     handle_error_code( rval, number_tests_failed, number_tests_successful );
00129     std::cout << "\n";
00130 
00131     std::cout << "gentity set test: ";
00132     rval = gentityset_test( pFacet );
00133     handle_error_code( rval, number_tests_failed, number_tests_successful );
00134     std::cout << "\n";
00135 
00136     std::cout << "geometry evals test: ";
00137     rval = geometry_evaluation_test( pFacet );
00138     handle_error_code( rval, number_tests_failed, number_tests_successful );
00139     std::cout << "\n";
00140 
00141     std::cout << "normal evals test: ";
00142     rval = normals_test( pFacet );
00143     handle_error_code( rval, number_tests_failed, number_tests_successful );
00144     std::cout << "\n";
00145 
00146     std::cout << "ray test: ";
00147     rval = ray_test( pFacet );
00148     handle_error_code( rval, number_tests_failed, number_tests_successful );
00149     std::cout << "\n";
00150 
00151     std::cout << "split with loop test ";
00152     rval = split_test( mb, pFacet );
00153     handle_error_code( rval, number_tests_failed, number_tests_successful );
00154     std::cout << "\n";
00155 
00156     // pFacet has been deleted in split_test(), so we should mark it as NULL
00157     // Setting pFacet (value parameter) to NULL in split_test() does not work
00158     pFacet = NULL;
00159 
00160     std::cout << " check split: ";
00161     rval = check_split( mb );
00162     handle_error_code( rval, number_tests_failed, number_tests_successful );
00163     std::cout << "\n";
00164 
00165     if( only_cropping ) return number_tests_failed;  // we do not remove the output file, either
00166 
00167     std::cout << " split quads test: ";
00168     rval = split_quads_test();
00169     handle_error_code( rval, number_tests_failed, number_tests_successful );
00170     std::cout << "\n";
00171 
00172     // when we are done, remove modified file if we want to
00173     if( !keep_output ) { remove( filename_out.c_str() ); }
00174     return number_tests_failed;
00175 }
00176 
00177 ErrorCode root_set_test( FBEngine* pFacet )
00178 {
00179     EntityHandle root_set;
00180     ErrorCode rval = pFacet->getRootSet( &root_set );MB_CHK_SET_ERR( rval, "ERROR : getRootSet failed!" );
00181 
00182     return MB_SUCCESS;
00183 }
00184 
00185 ErrorCode gentityset_test( FBEngine* pFacet )
00186 {
00187     int num_type = 4;
00188     EntityHandle ges_array[4];
00189     int number_array[4];
00190     // int num_all_gentities_super = 0;
00191     int ent_type = 0;  // iBase_VERTEX;
00192 
00193     EntityHandle root_set;
00194     ErrorCode rval = pFacet->getRootSet( &root_set );MB_CHK_SET_ERR( rval, "ERROR : getRootSet failed!" );
00195 
00196     // get the number of sets in the whole model
00197     int all_sets = 0;
00198     rval         = pFacet->getNumEntSets( root_set, 0, &all_sets );MB_CHK_SET_ERR( rval, "Problem getting the number of all gentity sets in whole model." );  // why do we
00199                                                                                                // count all sets
00200 
00201     // add gentities to entitysets by type
00202     for( ; ent_type < num_type; ent_type++ )
00203     {
00204         // initialize the entityset
00205         rval = pFacet->createEntSet( 1, &ges_array[ent_type] );  // 1 means isList, ordered
00206         MB_CHK_SET_ERR( rval, "Problem creating entityset." );
00207 
00208         // get entities by type in total "mesh"
00209         Range gentities;
00210         rval = pFacet->getEntities( root_set, ent_type, gentities );MB_CHK_SET_ERR( rval, "Failed to get gentities by type in gentityset_test." );
00211 
00212         // add gentities into gentity set
00213         rval = pFacet->addEntArrToSet( gentities, ges_array[ent_type] );MB_CHK_SET_ERR( rval, "Failed to add gentities in entityset_test." );
00214 
00215         // Check to make sure entity set really has correct number of entities in it
00216         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." );
00217 
00218         // compare the number of entities by type
00219         int num_type_gentity = gentities.size();
00220 
00221         if( number_array[ent_type] != num_type_gentity )
00222         {
00223             std::cerr << "Number of gentities by type is not correct" << std::endl;
00224             return MB_FAILURE;
00225         }
00226 
00227         // add to number of all entities in super set
00228         // num_all_gentities_super += num_type_gentity;
00229     }
00230 
00231     // make a super set having all entitysets
00232     EntityHandle super_set;
00233     rval = pFacet->createEntSet( 1, &super_set );  // 1 is list
00234     MB_CHK_SET_ERR( rval, "Failed to create a super set in gentityset_test." );
00235 
00236     for( int i = 0; i < num_type; i++ )
00237     {
00238         rval = pFacet->addEntSet( ges_array[i], super_set );MB_CHK_SET_ERR( rval, "Failed to create a super set in gentityset_test." );
00239     }
00240 
00241     //----------TEST BOOLEAN OPERATIONS----------------//
00242 
00243     EntityHandle temp_ges1;
00244     rval = pFacet->createEntSet( 1, &temp_ges1 );MB_CHK_SET_ERR( rval, "Failed to create a super set in gentityset_test." );
00245 
00246     // Subtract
00247     // add all EDGEs and FACEs to temp_es1
00248     // get all EDGE entities
00249     Range gedges, gfaces, temp_gentities1;
00250     rval = pFacet->getEntities( ges_array[1], /* iBase_EDGE*/ 1, gedges );MB_CHK_SET_ERR( rval, "Failed to get gedge gentities in gentityset_test." );
00251 
00252     // add EDGEs to ges1
00253     rval = pFacet->addEntArrToSet( gedges, temp_ges1 );MB_CHK_SET_ERR( rval, "Failed to add gedge gentities in gentityset_test." );
00254 
00255     // get all FACE gentities
00256     rval = pFacet->getEntities( ges_array[2], /*iBase_FACE*/ 2, gfaces );MB_CHK_SET_ERR( rval, "Failed to get gface gentities in gentityset_test." );
00257 
00258     // add FACEs to es1
00259     rval = pFacet->addEntArrToSet( gfaces, temp_ges1 );MB_CHK_SET_ERR( rval, "Failed to add gface gentities in gentityset_test." );
00260 
00261     // subtract EDGEs
00262     rval = pFacet->gsubtract( temp_ges1, ges_array[1], temp_ges1 );MB_CHK_SET_ERR( rval, "Failed to subtract gentitysets in gentityset_test." );
00263 
00264     rval = pFacet->getEntities( temp_ges1, 2, temp_gentities1 );MB_CHK_SET_ERR( rval, "Failed to get gface gentities in gentityset_test." );
00265 
00266     if( gfaces.size() != temp_gentities1.size() )
00267     {
00268         std::cerr << "Number of entitysets after subtraction not correct \
00269              in gentityset_test."
00270                   << std::endl;
00271         return MB_FAILURE;
00272     }
00273 
00274     // check there's nothing but gfaces in temp_ges1
00275     int num_gents;
00276     rval = pFacet->getNumOfType( temp_ges1, 1, &num_gents );MB_CHK_SET_ERR( rval, "Failed to get dimensions of gentities in gentityset_test." );
00277     if( 0 != num_gents )
00278     {
00279         std::cerr << "Subtraction failed to remove all edges" << std::endl;
00280         return MB_FAILURE;
00281     }
00282 
00283     return MB_SUCCESS;
00284 }
00285 
00286 ErrorCode geometry_evaluation_test( FBEngine* pFacet )
00287 {
00288     int i;
00289     EntityHandle root_set;
00290     ErrorCode rval = pFacet->getRootSet( &root_set );MB_CHK_SET_ERR( rval, "ERROR : getRootSet failed!" );
00291 
00292     int top          = 0;  // iBase_VERTEX;
00293     int num_test_top = 4;  // iBase_ALL_TYPES;
00294     std::vector< std::vector< EntityHandle > > gentity_vectors( num_test_top );
00295 
00296     // fill the vectors of each topology entities
00297     //
00298     for( i = top; i < num_test_top; i++ )
00299     {
00300         Range gentities;
00301         rval = pFacet->getEntities( root_set, i, gentities );MB_CHK_SET_ERR( rval, "Failed to get gentities in eval tests." );
00302 
00303         gentity_vectors[i].resize( gentities.size() );
00304         std::copy( gentities.begin(), gentities.end(), gentity_vectors[i].begin() );
00305     }
00306 
00307     // check geometries in both directions
00308     double min[3], max[3], on[3];
00309     double near[3] = { .0, .0, .0 };
00310     std::vector< EntityHandle >::iterator vit;
00311     /*for (i = iBase_REGION; i >= iBase_VERTEX; i--) {
00312      if (i != iBase_EDGE) {*/
00313     for( i = 3; i >= 0; i-- )
00314     {
00315         if( i != 1 )
00316         {
00317             for( vit = gentity_vectors[i].begin(); vit != gentity_vectors[i].end(); ++vit )
00318             {
00319                 EntityHandle this_gent = *vit;
00320 
00321                 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." );
00322 
00323                 for( int j = 0; j < 3; j++ )
00324                     near[j] = ( min[j] + max[j] ) / 2.;
00325                 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." );
00326             }
00327         }
00328         else
00329         {
00330             // for edges, provide a little better help
00331             for( vit = gentity_vectors[i].begin(); vit != gentity_vectors[i].end(); ++vit )
00332             {
00333                 EntityHandle this_gent = *vit;
00334 
00335                 // we know that the edge is parametric, with par between 0 and 1
00336                 // some random parameter
00337                 rval = pFacet->getEntUtoXYZ( this_gent, 0.33, near[0], near[1], near[2] );MB_CHK_SET_ERR( rval, "Failed to get a new point" );
00338 
00339                 std::cout << " entity of type " << i << " position:\n  " << near[0] << " " << near[1] << " " << near[2]
00340                           << "\n";
00341                 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." );
00342 
00343                 std::cout << "   close by:  " << on[0] << " " << on[1] << " " << on[2] << "\n";
00344             }
00345         }
00346     }
00347 
00348     return MB_SUCCESS;
00349 }
00350 
00351 //  test normals evaluations on the surface only
00352 ErrorCode normals_test( FBEngine* pFacet )
00353 {
00354     int i;
00355     EntityHandle root_set;
00356     ErrorCode rval = pFacet->getRootSet( &root_set );MB_CHK_SET_ERR( rval, "ERROR : getRootSet failed!" );
00357 
00358     int top          = 0;  // iBase_VERTEX;
00359     int num_test_top = 4;  // iBase_ALL_TYPES;
00360     std::vector< std::vector< EntityHandle > > gentity_vectors( num_test_top );
00361 
00362     // fill the vectors of each topology entities
00363     //
00364     for( i = top; i < num_test_top; i++ )
00365     {
00366         Range gentities;
00367         rval = pFacet->getEntities( root_set, i, gentities );MB_CHK_SET_ERR( rval, "Failed to get gentities in eval tests." );
00368 
00369         gentity_vectors[i].resize( gentities.size() );
00370         std::copy( gentities.begin(), gentities.end(), gentity_vectors[i].begin() );
00371     }
00372 
00373     // check adjacencies in both directions
00374     double min[3], max[3];
00375     double normal[3] = { .0, .0, .0 };
00376     std::vector< EntityHandle >::iterator vit;
00377     for( i = 3 /*iBase_REGION*/; i > 1 /*iBase_EDGE*/; i-- )
00378     {
00379         for( vit = gentity_vectors[i].begin(); vit != gentity_vectors[i].end(); ++vit )
00380         {
00381             EntityHandle this_gent = *vit;
00382             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." );
00383 
00384             rval = pFacet->getEntNrmlXYZ( this_gent, ( max[0] + min[0] ) / 2, ( max[1] + min[1] ) / 2,
00385                                           ( max[2] + min[2] ) / 2, &normal[0], &normal[1], &normal[2] );MB_CHK_SET_ERR( rval, "Failed to get normal to the closest point." );
00386 
00387             std::cout << " entity of type " << i << " closest normal to center:\n  " << normal[0] << " " << normal[1]
00388                       << " " << normal[2] << "\n";
00389         }
00390     }
00391 
00392     return MB_SUCCESS;
00393 }
00394 
00395 //  ray test
00396 ErrorCode ray_test( FBEngine* pFacet )
00397 {
00398 
00399     EntityHandle root_set;
00400     ErrorCode rval = pFacet->getRootSet( &root_set );MB_CHK_SET_ERR( rval, "ERROR : getRootSet failed!" );
00401 
00402     int top = 2;  //  iBase_FACE;
00403 
00404     Range faces;
00405     rval = pFacet->getEntities( root_set, top, faces );MB_CHK_SET_ERR( rval, "Failed to get faces in ray_test." );
00406 
00407     // check only the first face
00408 
00409     // check adjacencies in both directions
00410     double min[3], max[3];
00411 
00412     EntityHandle first_face = faces[0];
00413 
00414     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." );
00415 
00416     // assume that the ray shot from the bottom of the box (middle) is a pretty good candidate
00417     // in z direction
00418     double x = ( min[0] + max[0] ) / 2, y = ( min[1] + max[1] ) / 2, z = min[2];
00419     std::vector< EntityHandle > intersect_entity_handles;
00420     std::vector< double > intersect_coords;
00421     std::vector< double > param_coords;
00422 
00423     rval = pFacet->getPntRayIntsct( x, y, z,     // shot from
00424                                     0., 0., 1.,  // direction
00425                                     intersect_entity_handles,
00426                                     /*iBase_INTERLEAVED,*/
00427                                     intersect_coords, param_coords );MB_CHK_SET_ERR( rval, "Failed to find ray intersections points " );
00428 
00429     for( unsigned int i = 0; i < intersect_entity_handles.size(); i++ )
00430     {
00431 
00432         std::cout << " entity of type " << pFacet->moab_instance()->type_from_handle( intersect_entity_handles[i] )
00433                   << " id from handle: " << pFacet->moab_instance()->id_from_handle( intersect_entity_handles[i] )
00434                   << "\n"
00435                   << intersect_coords[3 * i] << " " << intersect_coords[3 * i + 1] << " " << intersect_coords[3 * i + 2]
00436                   << "\n"
00437                   << " distance: " << param_coords[i] << "\n";
00438     }
00439 
00440     return MB_SUCCESS;
00441 }
00442 
00443 // this test is for creating 2 surfaces given a polyline and a direction for piercing.
00444 // this test is for cropping a surface with a closed loop, no intersection
00445 // with initial boundary
00446 ErrorCode split_test( Interface* mb, FBEngine* pFacet )
00447 {
00448 
00449     EntityHandle root_set;
00450     ErrorCode rval = pFacet->getRootSet( &root_set );MB_CHK_SET_ERR( rval, "ERROR : getRootSet failed!" );
00451 
00452     int top = 2;  //  iBase_FACE;
00453 
00454     Range faces;
00455     rval = pFacet->getEntities( root_set, top, faces );MB_CHK_SET_ERR( rval, "Failed to get faces in split_test." );
00456 
00457     // check only the first face
00458 
00459     EntityHandle first_face = faces[0];
00460     // use the polyPB.txt file to get the trimming polygon
00461     ;
00462     // read the file with the polygon user data
00463 
00464     std::ifstream datafile( polygon_file_name.c_str(), std::ifstream::in );
00465     if( !datafile )
00466     {
00467         std::cout << "can't read file\n";
00468         return MB_FAILURE;
00469     }
00470     //
00471     char temp[100];
00472     double direction[3];  // normalized
00473     double gridSize;
00474     datafile.getline( temp, 100 );  // first line
00475 
00476     // get direction and mesh size along polygon segments, from file
00477     sscanf( temp, " %lf %lf %lf %lf ", direction, direction + 1, direction + 2, &gridSize );
00478     // NORMALIZE(direction);// just to be sure
00479 
00480     std::vector< double > xyz;
00481     while( !datafile.eof() )
00482     {
00483         datafile.getline( temp, 100 );
00484         // int id = 0;
00485         double x, y, z;
00486         int nr = sscanf( temp, "%lf %lf %lf", &x, &y, &z );
00487         if( nr == 3 )
00488         {
00489             xyz.push_back( x );
00490             xyz.push_back( y );
00491             xyz.push_back( z );
00492         }
00493     }
00494     int sizePolygon = (int)xyz.size() / 3;
00495     if( sizePolygon < 3 )
00496     {
00497         std::cerr << " Not enough points in the polygon" << std::endl;
00498         return MB_FAILURE;
00499     }
00500 
00501     EntityHandle newFace;  // first test is with closed surface
00502     rval = pFacet->split_surface_with_direction( first_face, xyz, direction, /*closed*/ 1, min_dot, newFace );MB_CHK_SET_ERR( rval, "ERROR : splitting surface failed!" );
00503 
00504     // save a new database
00505     pFacet->delete_smooth_tags();
00506     // get a new gtt tool
00507 
00508     // duplicate -- extract a new geom topo tool
00509     GeomTopoTool* gtt       = pFacet->get_gtt();
00510     GeomTopoTool* duplicate = NULL;
00511     std::vector< EntityHandle > gents;
00512     gents.push_back( newFace );
00513     rval = gtt->duplicate_model( duplicate, &gents );MB_CHK_SET_ERR( rval, "Failed to extract surface." );
00514 
00515     EntityHandle newRootSet = duplicate->get_root_model_set();
00516     delete pFacet;
00517     pFacet = NULL;  // try not to write the obb tree
00518     rval   = mb->write_file( filename_out.c_str(), NULL, NULL, &newRootSet, 1 );MB_CHK_SET_ERR( rval, "ERROR : writing mesh failed!" );
00519 
00520     delete duplicate;
00521     return rval;
00522 }
00523 
00524 ErrorCode check_split( Interface* mb )
00525 {
00526     // check loading the file in an empty db
00527     // delete pFacet;// should clean up the FBEngine
00528     ErrorCode rval = mb->delete_mesh();MB_CHK_SET_ERR( rval, "ERROR : delete mesh failed!" );
00529 
00530     rval = mb->load_file( filename_out.c_str() );MB_CHK_SET_ERR( rval, "ERROR : can't load modified file!" );
00531 
00532     FBEngine* pFacet = new FBEngine( mb, NULL, true );  // smooth facetting, no OBB tree passed
00533 
00534     // repeat tests on modified file
00535 
00536     // should the init be part of constructor or not?
00537     // this is where the obb tree is constructed, and smooth faceting initialized, too.
00538     rval = pFacet->Init();MB_CHK_SET_ERR( rval, "failed to initialize smoothing" );
00539 
00540     std::cout << "root set test: ";
00541     rval = root_set_test( pFacet );
00542     handle_error_code( rval, number_tests_failed, number_tests_successful );
00543     std::cout << "\n";
00544 
00545     std::cout << "gentity set test: ";
00546     rval = gentityset_test( pFacet );
00547     handle_error_code( rval, number_tests_failed, number_tests_successful );
00548     std::cout << "\n";
00549 
00550     std::cout << "geometry evals test: ";
00551     rval = geometry_evaluation_test( pFacet );
00552     handle_error_code( rval, number_tests_failed, number_tests_successful );
00553     std::cout << "\n";
00554 
00555     std::cout << "normal evals test: ";
00556     rval = normals_test( pFacet );
00557     handle_error_code( rval, number_tests_failed, number_tests_successful );
00558     std::cout << "\n";
00559 
00560     std::cout << "ray test: ";
00561     rval = ray_test( pFacet );
00562     handle_error_code( rval, number_tests_failed, number_tests_successful );
00563     std::cout << "\n";
00564 
00565     delete pFacet;
00566     pFacet = NULL;
00567     if( number_tests_failed > 0 ) return MB_FAILURE;
00568 
00569     return MB_SUCCESS;
00570 }
00571 
00572 ErrorCode split_quads_test()
00573 {
00574     Core mbcore;
00575     Interface* mb = &mbcore;
00576 
00577     ErrorCode rval = mb->load_file( quads_file.c_str() );MB_CHK_SET_ERR( rval, "failed to load quads file" );
00578 
00579     FBEngine* pFacet = new FBEngine( mb, NULL, true );
00580 
00581     rval = pFacet->Init();MB_CHK_SET_ERR( rval, "failed to initialize smoothing" );
00582 
00583     EntityHandle root_set;
00584     rval = pFacet->getRootSet( &root_set );MB_CHK_SET_ERR( rval, "ERROR : getRootSet failed!" );
00585     int top = 2;  //  iBase_FACE;
00586 
00587     Range faces;
00588     rval = pFacet->getEntities( root_set, top, faces );MB_CHK_SET_ERR( rval, "Failed to get faces in split_test." );
00589 
00590     if( faces.size() != 2 )
00591     {
00592         std::cout << "num faces after loading quads model:" << faces.size() << "\n";
00593         return MB_FAILURE;  //
00594     }
00595 
00596     // multiple tests
00597     std::cout << "gentity set test: ";
00598     rval = gentityset_test( pFacet );
00599     handle_error_code( rval, number_tests_failed, number_tests_successful );
00600     std::cout << "\n";
00601 
00602     std::cout << "geometry evals test: ";
00603     rval = geometry_evaluation_test( pFacet );
00604     handle_error_code( rval, number_tests_failed, number_tests_successful );
00605     std::cout << "\n";
00606 
00607     std::cout << "normal evals test: ";
00608     rval = normals_test( pFacet );
00609     handle_error_code( rval, number_tests_failed, number_tests_successful );
00610     std::cout << "\n";
00611 
00612     std::cout << "ray test: ";
00613     rval = ray_test( pFacet );
00614     handle_error_code( rval, number_tests_failed, number_tests_successful );
00615     std::cout << "\n";
00616 
00617     // export split triangles model, after deleting the smooth tags
00618     pFacet->delete_smooth_tags();
00619 
00620     delete pFacet;
00621     pFacet               = NULL;
00622     std::string spl_file = "q.split.h5m";
00623     rval                 = mb->write_file( spl_file.c_str(), 0, 0, &root_set, 1 );MB_CHK_SET_ERR( rval, "can't write result file" );
00624 
00625     if( !keep_output ) { remove( spl_file.c_str() ); }
00626 
00627     if( number_tests_failed > 0 ) return MB_FAILURE;
00628 
00629     return MB_SUCCESS;
00630 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines