MOAB: Mesh Oriented datABase  (version 5.4.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 <cassert>
00025 #include <cstring>
00026 #include <cmath>
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 + "unittest/PB.h5m";
00072     polygon_file_name = TestDir + "unittest/polyPB.txt";
00073     filename_out      = "PB_facet.h5m";
00074     quads_file        = TestDir + "unittest/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 )
00174     {
00175         remove( filename_out.c_str() );
00176     }
00177     return number_tests_failed;
00178 }
00179 
00180 ErrorCode root_set_test( FBEngine* pFacet )
00181 {
00182     EntityHandle root_set;
00183     ErrorCode rval = pFacet->getRootSet( &root_set );MB_CHK_SET_ERR( rval, "ERROR : getRootSet failed!" );
00184 
00185     return MB_SUCCESS;
00186 }
00187 
00188 ErrorCode gentityset_test( FBEngine* pFacet )
00189 {
00190     int num_type = 4;
00191     EntityHandle ges_array[4];
00192     int number_array[4];
00193     // int num_all_gentities_super = 0;
00194     int ent_type = 0;  // iBase_VERTEX;
00195 
00196     EntityHandle root_set;
00197     ErrorCode rval = pFacet->getRootSet( &root_set );MB_CHK_SET_ERR( rval, "ERROR : getRootSet failed!" );
00198 
00199     // get the number of sets in the whole model
00200     int all_sets = 0;
00201     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
00202                                                                                                // count all sets
00203 
00204     // add gentities to entitysets by type
00205     for( ; ent_type < num_type; ent_type++ )
00206     {
00207         // initialize the entityset
00208         rval = pFacet->createEntSet( 1, &ges_array[ent_type] );  // 1 means isList, ordered
00209         MB_CHK_SET_ERR( rval, "Problem creating entityset." );
00210 
00211         // get entities by type in total "mesh"
00212         Range gentities;
00213         rval = pFacet->getEntities( root_set, ent_type, gentities );MB_CHK_SET_ERR( rval, "Failed to get gentities by type in gentityset_test." );
00214 
00215         // add gentities into gentity set
00216         rval = pFacet->addEntArrToSet( gentities, ges_array[ent_type] );MB_CHK_SET_ERR( rval, "Failed to add gentities in entityset_test." );
00217 
00218         // Check to make sure entity set really has correct number of entities in it
00219         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." );
00220 
00221         // compare the number of entities by type
00222         int num_type_gentity = gentities.size();
00223 
00224         if( number_array[ent_type] != num_type_gentity )
00225         {
00226             std::cerr << "Number of gentities by type is not correct" << std::endl;
00227             return MB_FAILURE;
00228         }
00229 
00230         // add to number of all entities in super set
00231         // num_all_gentities_super += num_type_gentity;
00232     }
00233 
00234     // make a super set having all entitysets
00235     EntityHandle super_set;
00236     rval = pFacet->createEntSet( 1, &super_set );  // 1 is list
00237     MB_CHK_SET_ERR( rval, "Failed to create a super set in gentityset_test." );
00238 
00239     for( int i = 0; i < num_type; i++ )
00240     {
00241         rval = pFacet->addEntSet( ges_array[i], super_set );MB_CHK_SET_ERR( rval, "Failed to create a super set in gentityset_test." );
00242     }
00243 
00244     //----------TEST BOOLEAN OPERATIONS----------------//
00245 
00246     EntityHandle temp_ges1;
00247     rval = pFacet->createEntSet( 1, &temp_ges1 );MB_CHK_SET_ERR( rval, "Failed to create a super set in gentityset_test." );
00248 
00249     // Subtract
00250     // add all EDGEs and FACEs to temp_es1
00251     // get all EDGE entities
00252     Range gedges, gfaces, temp_gentities1;
00253     rval = pFacet->getEntities( ges_array[1], /* iBase_EDGE*/ 1, gedges );MB_CHK_SET_ERR( rval, "Failed to get gedge gentities in gentityset_test." );
00254 
00255     // add EDGEs to ges1
00256     rval = pFacet->addEntArrToSet( gedges, temp_ges1 );MB_CHK_SET_ERR( rval, "Failed to add gedge gentities in gentityset_test." );
00257 
00258     // get all FACE gentities
00259     rval = pFacet->getEntities( ges_array[2], /*iBase_FACE*/ 2, gfaces );MB_CHK_SET_ERR( rval, "Failed to get gface gentities in gentityset_test." );
00260 
00261     // add FACEs to es1
00262     rval = pFacet->addEntArrToSet( gfaces, temp_ges1 );MB_CHK_SET_ERR( rval, "Failed to add gface gentities in gentityset_test." );
00263 
00264     // subtract EDGEs
00265     rval = pFacet->gsubtract( temp_ges1, ges_array[1], temp_ges1 );MB_CHK_SET_ERR( rval, "Failed to subtract gentitysets in gentityset_test." );
00266 
00267     rval = pFacet->getEntities( temp_ges1, 2, temp_gentities1 );MB_CHK_SET_ERR( rval, "Failed to get gface gentities in gentityset_test." );
00268 
00269     if( gfaces.size() != temp_gentities1.size() )
00270     {
00271         std::cerr << "Number of entitysets after subtraction not correct \
00272              in gentityset_test."
00273                   << std::endl;
00274         return MB_FAILURE;
00275     }
00276 
00277     // check there's nothing but gfaces in temp_ges1
00278     int num_gents;
00279     rval = pFacet->getNumOfType( temp_ges1, 1, &num_gents );MB_CHK_SET_ERR( rval, "Failed to get dimensions of gentities in gentityset_test." );
00280     if( 0 != num_gents )
00281     {
00282         std::cerr << "Subtraction failed to remove all edges" << std::endl;
00283         return MB_FAILURE;
00284     }
00285 
00286     return MB_SUCCESS;
00287 }
00288 
00289 ErrorCode geometry_evaluation_test( FBEngine* pFacet )
00290 {
00291     int i;
00292     EntityHandle root_set;
00293     ErrorCode rval = pFacet->getRootSet( &root_set );MB_CHK_SET_ERR( rval, "ERROR : getRootSet failed!" );
00294 
00295     int top          = 0;  // iBase_VERTEX;
00296     int num_test_top = 4;  // iBase_ALL_TYPES;
00297     std::vector< std::vector< EntityHandle > > gentity_vectors( num_test_top );
00298 
00299     // fill the vectors of each topology entities
00300     //
00301     for( i = top; i < num_test_top; i++ )
00302     {
00303         Range gentities;
00304         rval = pFacet->getEntities( root_set, i, gentities );MB_CHK_SET_ERR( rval, "Failed to get gentities in eval tests." );
00305 
00306         gentity_vectors[i].resize( gentities.size() );
00307         std::copy( gentities.begin(), gentities.end(), gentity_vectors[i].begin() );
00308     }
00309 
00310     // check geometries in both directions
00311     double min[3], max[3], on[3];
00312     double near[3] = { .0, .0, .0 };
00313     std::vector< EntityHandle >::iterator vit;
00314     /*for (i = iBase_REGION; i >= iBase_VERTEX; i--) {
00315      if (i != iBase_EDGE) {*/
00316     for( i = 3; i >= 0; i-- )
00317     {
00318         if( i != 1 )
00319         {
00320             for( vit = gentity_vectors[i].begin(); vit != gentity_vectors[i].end(); ++vit )
00321             {
00322                 EntityHandle this_gent = *vit;
00323 
00324                 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." );
00325 
00326                 for( int j = 0; j < 3; j++ )
00327                     near[j] = ( min[j] + max[j] ) / 2.;
00328                 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." );
00329             }
00330         }
00331         else
00332         {
00333             // for edges, provide a little better help
00334             for( vit = gentity_vectors[i].begin(); vit != gentity_vectors[i].end(); ++vit )
00335             {
00336                 EntityHandle this_gent = *vit;
00337 
00338                 // we know that the edge is parametric, with par between 0 and 1
00339                 // some random parameter
00340                 rval = pFacet->getEntUtoXYZ( this_gent, 0.33, near[0], near[1], near[2] );MB_CHK_SET_ERR( rval, "Failed to get a new point" );
00341 
00342                 std::cout << " entity of type " << i << " position:\n  " << near[0] << " " << near[1] << " " << near[2]
00343                           << "\n";
00344                 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." );
00345 
00346                 std::cout << "   close by:  " << on[0] << " " << on[1] << " " << on[2] << "\n";
00347             }
00348         }
00349     }
00350 
00351     return MB_SUCCESS;
00352 }
00353 
00354 //  test normals evaluations on the surface only
00355 ErrorCode normals_test( FBEngine* pFacet )
00356 {
00357     int i;
00358     EntityHandle root_set;
00359     ErrorCode rval = pFacet->getRootSet( &root_set );MB_CHK_SET_ERR( rval, "ERROR : getRootSet failed!" );
00360 
00361     int top          = 0;  // iBase_VERTEX;
00362     int num_test_top = 4;  // iBase_ALL_TYPES;
00363     std::vector< std::vector< EntityHandle > > gentity_vectors( num_test_top );
00364 
00365     // fill the vectors of each topology entities
00366     //
00367     for( i = top; i < num_test_top; i++ )
00368     {
00369         Range gentities;
00370         rval = pFacet->getEntities( root_set, i, gentities );MB_CHK_SET_ERR( rval, "Failed to get gentities in eval tests." );
00371 
00372         gentity_vectors[i].resize( gentities.size() );
00373         std::copy( gentities.begin(), gentities.end(), gentity_vectors[i].begin() );
00374     }
00375 
00376     // check adjacencies in both directions
00377     double min[3], max[3];
00378     double normal[3] = { .0, .0, .0 };
00379     std::vector< EntityHandle >::iterator vit;
00380     for( i = 3 /*iBase_REGION*/; i > 1 /*iBase_EDGE*/; i-- )
00381     {
00382         for( vit = gentity_vectors[i].begin(); vit != gentity_vectors[i].end(); ++vit )
00383         {
00384             EntityHandle this_gent = *vit;
00385             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." );
00386 
00387             rval = pFacet->getEntNrmlXYZ( this_gent, ( max[0] + min[0] ) / 2, ( max[1] + min[1] ) / 2,
00388                                           ( max[2] + min[2] ) / 2, &normal[0], &normal[1], &normal[2] );MB_CHK_SET_ERR( rval, "Failed to get normal to the closest point." );
00389 
00390             std::cout << " entity of type " << i << " closest normal to center:\n  " << normal[0] << " " << normal[1]
00391                       << " " << normal[2] << "\n";
00392         }
00393     }
00394 
00395     return MB_SUCCESS;
00396 }
00397 
00398 //  ray test
00399 ErrorCode ray_test( FBEngine* pFacet )
00400 {
00401 
00402     EntityHandle root_set;
00403     ErrorCode rval = pFacet->getRootSet( &root_set );MB_CHK_SET_ERR( rval, "ERROR : getRootSet failed!" );
00404 
00405     int top = 2;  //  iBase_FACE;
00406 
00407     Range faces;
00408     rval = pFacet->getEntities( root_set, top, faces );MB_CHK_SET_ERR( rval, "Failed to get faces in ray_test." );
00409 
00410     // check only the first face
00411 
00412     // check adjacencies in both directions
00413     double min[3], max[3];
00414 
00415     EntityHandle first_face = faces[0];
00416 
00417     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." );
00418 
00419     // assume that the ray shot from the bottom of the box (middle) is a pretty good candidate
00420     // in z direction
00421     double x = ( min[0] + max[0] ) / 2, y = ( min[1] + max[1] ) / 2, z = min[2];
00422     std::vector< EntityHandle > intersect_entity_handles;
00423     std::vector< double > intersect_coords;
00424     std::vector< double > param_coords;
00425 
00426     rval = pFacet->getPntRayIntsct( x, y, z,     // shot from
00427                                     0., 0., 1.,  // direction
00428                                     intersect_entity_handles,
00429                                     /*iBase_INTERLEAVED,*/
00430                                     intersect_coords, param_coords );MB_CHK_SET_ERR( rval, "Failed to find ray intersections points " );
00431 
00432     for( unsigned int i = 0; i < intersect_entity_handles.size(); i++ )
00433     {
00434 
00435         std::cout << " entity of type " << pFacet->moab_instance()->type_from_handle( intersect_entity_handles[i] )
00436                   << " id from handle: " << pFacet->moab_instance()->id_from_handle( intersect_entity_handles[i] )
00437                   << "\n"
00438                   << intersect_coords[3 * i] << " " << intersect_coords[3 * i + 1] << " " << intersect_coords[3 * i + 2]
00439                   << "\n"
00440                   << " distance: " << param_coords[i] << "\n";
00441     }
00442 
00443     return MB_SUCCESS;
00444 }
00445 
00446 // this test is for creating 2 surfaces given a polyline and a direction for piercing.
00447 // this test is for cropping a surface with a closed loop, no intersection
00448 // with initial boundary
00449 ErrorCode split_test( Interface* mb, FBEngine* pFacet )
00450 {
00451 
00452     EntityHandle root_set;
00453     ErrorCode rval = pFacet->getRootSet( &root_set );MB_CHK_SET_ERR( rval, "ERROR : getRootSet failed!" );
00454 
00455     int top = 2;  //  iBase_FACE;
00456 
00457     Range faces;
00458     rval = pFacet->getEntities( root_set, top, faces );MB_CHK_SET_ERR( rval, "Failed to get faces in split_test." );
00459 
00460     // check only the first face
00461 
00462     EntityHandle first_face = faces[0];
00463     // use the polyPB.txt file to get the trimming polygon
00464     ;
00465     // read the file with the polygon user data
00466 
00467     std::ifstream datafile( polygon_file_name.c_str(), std::ifstream::in );
00468     if( !datafile )
00469     {
00470         std::cout << "can't read file\n";
00471         return MB_FAILURE;
00472     }
00473     //
00474     char temp[100];
00475     double direction[3];  // normalized
00476     double gridSize;
00477     datafile.getline( temp, 100 );  // first line
00478 
00479     // get direction and mesh size along polygon segments, from file
00480     sscanf( temp, " %lf %lf %lf %lf ", direction, direction + 1, direction + 2, &gridSize );
00481     // NORMALIZE(direction);// just to be sure
00482 
00483     std::vector< double > xyz;
00484     while( !datafile.eof() )
00485     {
00486         datafile.getline( temp, 100 );
00487         // int id = 0;
00488         double x, y, z;
00489         int nr = sscanf( temp, "%lf %lf %lf", &x, &y, &z );
00490         if( nr == 3 )
00491         {
00492             xyz.push_back( x );
00493             xyz.push_back( y );
00494             xyz.push_back( z );
00495         }
00496     }
00497     int sizePolygon = (int)xyz.size() / 3;
00498     if( sizePolygon < 3 )
00499     {
00500         std::cerr << " Not enough points in the polygon" << std::endl;
00501         return MB_FAILURE;
00502     }
00503 
00504     EntityHandle newFace;  // first test is with closed surface
00505     rval = pFacet->split_surface_with_direction( first_face, xyz, direction, /*closed*/ 1, min_dot, newFace );MB_CHK_SET_ERR( rval, "ERROR : splitting surface failed!" );
00506 
00507     // save a new database
00508     pFacet->delete_smooth_tags();
00509     // get a new gtt tool
00510 
00511     // duplicate -- extract a new geom topo tool
00512     GeomTopoTool* gtt       = pFacet->get_gtt();
00513     GeomTopoTool* duplicate = NULL;
00514     std::vector< EntityHandle > gents;
00515     gents.push_back( newFace );
00516     rval = gtt->duplicate_model( duplicate, &gents );MB_CHK_SET_ERR( rval, "Failed to extract surface." );
00517 
00518     EntityHandle newRootSet = duplicate->get_root_model_set();
00519     delete pFacet;
00520     pFacet = NULL;  // try not to write the obb tree
00521     rval   = mb->write_file( filename_out.c_str(), NULL, NULL, &newRootSet, 1 );MB_CHK_SET_ERR( rval, "ERROR : writing mesh failed!" );
00522 
00523     delete duplicate;
00524     return rval;
00525 }
00526 
00527 ErrorCode check_split( Interface* mb )
00528 {
00529     // check loading the file in an empty db
00530     // delete pFacet;// should clean up the FBEngine
00531     ErrorCode rval = mb->delete_mesh();MB_CHK_SET_ERR( rval, "ERROR : delete mesh failed!" );
00532 
00533     rval = mb->load_file( filename_out.c_str() );MB_CHK_SET_ERR( rval, "ERROR : can't load modified file!" );
00534 
00535     FBEngine* pFacet = new FBEngine( mb, NULL, true );  // smooth facetting, no OBB tree passed
00536 
00537     // repeat tests on modified file
00538 
00539     // should the init be part of constructor or not?
00540     // this is where the obb tree is constructed, and smooth faceting initialized, too.
00541     rval = pFacet->Init();MB_CHK_SET_ERR( rval, "failed to initialize smoothing" );
00542 
00543     std::cout << "root set test: ";
00544     rval = root_set_test( pFacet );
00545     handle_error_code( rval, number_tests_failed, number_tests_successful );
00546     std::cout << "\n";
00547 
00548     std::cout << "gentity set test: ";
00549     rval = gentityset_test( pFacet );
00550     handle_error_code( rval, number_tests_failed, number_tests_successful );
00551     std::cout << "\n";
00552 
00553     std::cout << "geometry evals test: ";
00554     rval = geometry_evaluation_test( pFacet );
00555     handle_error_code( rval, number_tests_failed, number_tests_successful );
00556     std::cout << "\n";
00557 
00558     std::cout << "normal evals test: ";
00559     rval = normals_test( pFacet );
00560     handle_error_code( rval, number_tests_failed, number_tests_successful );
00561     std::cout << "\n";
00562 
00563     std::cout << "ray test: ";
00564     rval = ray_test( pFacet );
00565     handle_error_code( rval, number_tests_failed, number_tests_successful );
00566     std::cout << "\n";
00567 
00568     delete pFacet;
00569     pFacet = NULL;
00570     if( number_tests_failed > 0 ) return MB_FAILURE;
00571 
00572     return MB_SUCCESS;
00573 }
00574 
00575 ErrorCode split_quads_test()
00576 {
00577     Core mbcore;
00578     Interface* mb = &mbcore;
00579 
00580     ErrorCode rval = mb->load_file( quads_file.c_str() );MB_CHK_SET_ERR( rval, "failed to load quads file" );
00581 
00582     FBEngine* pFacet = new FBEngine( mb, NULL, true );
00583 
00584     rval = pFacet->Init();MB_CHK_SET_ERR( rval, "failed to initialize smoothing" );
00585 
00586     EntityHandle root_set;
00587     rval = pFacet->getRootSet( &root_set );MB_CHK_SET_ERR( rval, "ERROR : getRootSet failed!" );
00588     int top = 2;  //  iBase_FACE;
00589 
00590     Range faces;
00591     rval = pFacet->getEntities( root_set, top, faces );MB_CHK_SET_ERR( rval, "Failed to get faces in split_test." );
00592 
00593     if( faces.size() != 2 )
00594     {
00595         std::cout << "num faces after loading quads model:" << faces.size() << "\n";
00596         return MB_FAILURE;  //
00597     }
00598 
00599     // multiple tests
00600     std::cout << "gentity set test: ";
00601     rval = gentityset_test( pFacet );
00602     handle_error_code( rval, number_tests_failed, number_tests_successful );
00603     std::cout << "\n";
00604 
00605     std::cout << "geometry evals test: ";
00606     rval = geometry_evaluation_test( pFacet );
00607     handle_error_code( rval, number_tests_failed, number_tests_successful );
00608     std::cout << "\n";
00609 
00610     std::cout << "normal evals test: ";
00611     rval = normals_test( pFacet );
00612     handle_error_code( rval, number_tests_failed, number_tests_successful );
00613     std::cout << "\n";
00614 
00615     std::cout << "ray test: ";
00616     rval = ray_test( pFacet );
00617     handle_error_code( rval, number_tests_failed, number_tests_successful );
00618     std::cout << "\n";
00619 
00620     // export split triangles model, after deleting the smooth tags
00621     pFacet->delete_smooth_tags();
00622 
00623     delete pFacet;
00624     pFacet               = NULL;
00625     std::string spl_file = "q.split.h5m";
00626     rval                 = mb->write_file( spl_file.c_str(), 0, 0, &root_set, 1 );MB_CHK_SET_ERR( rval, "can't write result file" );
00627 
00628     if( !keep_output )
00629     {
00630         remove( spl_file.c_str() );
00631     }
00632 
00633     if( number_tests_failed > 0 ) return MB_FAILURE;
00634 
00635     return MB_SUCCESS;
00636 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines