MeshKit  1.0
mw_fix.cpp
Go to the documentation of this file.
00001 // ********************************************************************
00002 // Patrick Shriwise
00003 // August 2013
00004 /* _curve_to_be_tested_for_watertightness_
00005       vert1 X X vert1
00006             | |
00007       vert2 X |
00008   surf1     | |    surf2
00009             | |
00010       vert3 X X vert2
00011             | |
00012       vert4 X X vert3                   */
00013 
00014 // input:  h5m filename, tolerance
00015 // output: watertight h5m
00016 
00017 // make CXXFLAGS=-g for debug
00018 // make CXXFLAGS=-pg for profiling
00019 
00020 #include <iostream>
00021 #include <sstream>
00022 #include <iomanip> // for setprecision
00023 #include <limits> // for min/max values
00024 #include <assert.h>
00025 #include <math.h>
00026 #include <time.h>
00027 #include <vector>
00028 
00029 #include "moab/Core.hpp"
00030 #include "TagConventions.hpp"
00031 #include "moab/Range.hpp"
00032 #include "moab/Skinner.hpp"
00033 #include "moab/GeomTopoTool.hpp"
00034 
00035 #include "meshkit/gen.hpp"
00036 #include "meshkit/arc.hpp"
00037 #include "meshkit/zip.hpp"
00038 #include "meshkit/cleanup.hpp"
00039 
00040 
00041 
00042 const char GEOM_SENSE_2_TAG_NAME[] = "GEOM_SENSE_2";
00043 const char GEOM_SENSE_N_ENTS_TAG_NAME[] = "GEOM_SENSE_N_ENTS";
00044 const char GEOM_SENSE_N_SENSES_TAG_NAME[] = "GEOM_SENSE_N_SENSES"; 
00045 
00046 
00047 using namespace moab;
00048 Interface *MBI();
00049 
00050 char* sense_printer( int sense){
00051 
00052   if ( sense == 1 ) return "FORWARD (1)";
00053   if ( sense == -1 ) return  "REVERSE (-1)";
00054   if ( sense == 0 ) return "UNKNOWN (0)";
00055 }
00056 
00057 void moab_printer(ErrorCode error_code)
00058 {
00059   if ( error_code == MB_INDEX_OUT_OF_RANGE )
00060     {
00061       std::cerr << "ERROR: MB_INDEX_OUT_OF_RANGE" << std::endl;
00062     }
00063   if ( error_code == MB_MEMORY_ALLOCATION_FAILED )
00064     {
00065       std::cerr << "ERROR: MB_MEMORY_ALLOCATION_FAILED" << std::endl;
00066     }
00067   if ( error_code == MB_ENTITY_NOT_FOUND )
00068     {
00069       std::cerr << "ERROR: MB_ENTITY_NOT_FOUND" << std::endl;
00070     }
00071   if ( error_code == MB_MULTIPLE_ENTITIES_FOUND )
00072     {
00073       std::cerr << "ERROR: MB_MULTIPLE_ENTITIES_FOUND" << std::endl;
00074     }
00075   if ( error_code == MB_TAG_NOT_FOUND )
00076     {
00077       std::cerr << "ERROR: MB_TAG_NOT_FOUND" << std::endl;
00078     }
00079   if ( error_code == MB_FILE_DOES_NOT_EXIST )
00080     {
00081       std::cerr << "ERROR: MB_FILE_DOES_NOT_EXIST" << std::endl;
00082     }    
00083   if ( error_code == MB_FILE_WRITE_ERROR )
00084     {
00085       std::cerr << "ERROR: MB_FILE_WRITE_ERROR" << std::endl;
00086     }    
00087   if ( error_code == MB_ALREADY_ALLOCATED )
00088     {
00089       std::cerr << "ERROR: MB_ALREADY_ALLOCATED" << std::endl;
00090     }    
00091   if ( error_code == MB_VARIABLE_DATA_LENGTH )
00092     {
00093       std::cerr << "ERROR: MB_VARIABLE_DATA_LENGTH" << std::endl;
00094     }  
00095   if ( error_code == MB_INVALID_SIZE )
00096     {
00097       std::cerr << "ERROR: MB_INVALID_SIZE" << std::endl;
00098     }  
00099   if ( error_code == MB_UNSUPPORTED_OPERATION )
00100     {
00101       std::cerr << "ERROR: MB_UNSUPPORTED_OPERATION" << std::endl;
00102     }  
00103   if ( error_code == MB_UNHANDLED_OPTION )
00104     {
00105       std::cerr << "ERROR: MB_UNHANDLED_OPTION" << std::endl;
00106     }  
00107   if ( error_code == MB_FAILURE )
00108     {
00109       std::cerr << "ERROR: MB_FAILURE" << std::endl;
00110     }  
00111   return;
00112 }
00113 
00114 
00115 ErrorCode get_geom_size_before_sealing( const Range geom_sets[],
00116                                           const Tag geom_tag,
00117                                           const Tag size_tag,
00118                                           bool verbose ) {
00119   ErrorCode rval;
00120   for(int dim=1; dim <= 3 ; dim++) {
00121     std::cout << "dim = " << dim << std::endl;
00122     for(Range::iterator i=geom_sets[dim].begin(); i!=geom_sets[dim].end(); i++) {
00123       double size = 0;
00124         //std::cout << "*i =" << *i << std::endl;
00125         //std::cout << "geom_tag =" << geom_tag << std::endl;
00126         //std::cout << "size =" << size << std::endl;
00127 
00128 
00129       rval = gen::measure( *i, geom_tag, size, false, verbose );
00130       if(gen::error(MB_SUCCESS!=rval,"could not measure")) return rval;
00131       rval = MBI()->tag_set_data( size_tag, &(*i), 1, &size );
00132       if(gen::error(MB_SUCCESS!=rval,"could not set size tag")) return rval;
00133 
00134         //std::cout << "*i =" << *i << std::endl;
00135         //std::cout << "geom_tag =" << geom_tag << std::endl;
00136         //std::cout << "size =" << size << std::endl;
00137 
00138     }
00139   }
00140   return MB_SUCCESS;
00141 }
00142 
00143 ErrorCode get_senses(EntityHandle entity,
00144     std::vector<EntityHandle> &wrt_entities, std::vector<int> &senses)
00145 {
00146   //
00147   // the question here is: the wrt_entities is supplied or not?
00148   // I assume not, we will obtain it !!
00149   int edim = 1;
00150 
00151   if (-1 == edim)
00152     return MB_FAILURE;// not geometry entity
00153 
00154   ErrorCode rval;
00155   wrt_entities.clear();
00156   senses.clear();
00157 
00158   if (1 == edim)// edge
00159   {
00160     
00161     const void *dum_ptr;
00162     int num_ents;
00163     unsigned flags = MB_TAG_SPARSE;
00164   
00165     Tag senseNEntsTag;
00166     rval = MBI() -> tag_get_handle(GEOM_SENSE_N_ENTS_TAG_NAME, 0 , MB_TYPE_HANDLE, senseNEntsTag, flags);
00167     if (gen::error(MB_SUCCESS!=rval, "could not get ent sense handles")) return rval;
00168     rval = MBI()->tag_get_by_ptr(senseNEntsTag, &entity, 1, &dum_ptr, &num_ents);
00169     if (gen::error(MB_SUCCESS!=rval, "could not get ent sense data")) return rval;
00170     const EntityHandle *ents_data = static_cast<const EntityHandle*> (dum_ptr);
00171     std::copy(ents_data, ents_data + num_ents, std::back_inserter(wrt_entities));
00172 
00173     Tag senseNSensesTag;
00174     rval = MBI()->tag_get_handle(GEOM_SENSE_N_SENSES_TAG_NAME, 0 , MB_TYPE_INTEGER, senseNSensesTag, flags);
00175     if (gen::error(MB_SUCCESS!=rval, "could not get senses handle")) return rval;
00176     rval = MBI()->tag_get_by_ptr(senseNSensesTag, &entity, 1, &dum_ptr,
00177         &num_ents);
00178     if (gen::error(MB_SUCCESS!=rval, "could not get senses data")) return rval;
00179 
00180     const int *senses_data = static_cast<const int*> (dum_ptr);
00181     std::copy(senses_data, senses_data + num_ents, std::back_inserter(senses));
00182 
00183   }/* else // face in volume, edim == 2
00184   {
00185     
00186     EntityHandle sense_data[2] = { 0, 0 };
00187     rval = MBI()->tag_get_data(GEOM_SENSE_2_TAG_NAME, &entity, 1, sense_data);
00188     if (MB_SUCCESS != rval)
00189       return rval;
00190     if (sense_data[0] != 0 && sense_data[1] == sense_data[0]) {
00191       wrt_entities.push_back(sense_data[0]);
00192       senses.push_back(0);// both
00193     } else {
00194       if (sense_data[0] != 0) {
00195         wrt_entities.push_back(sense_data[0]);
00196         senses.push_back(1);
00197       }
00198       if (sense_data[1] != 0) {
00199         wrt_entities.push_back(sense_data[1]);
00200         senses.push_back(-1);
00201       }
00202 
00203     }
00204 
00205   }
00206   */
00207   // filter the results with the sets that are in the model at this time
00208   // this was introduced because extracting some sets (e.g. neumann set, with mbconvert)
00209   //   from a model would leave some sense tags not defined correctly
00210   // also, the geom ent set really needs to be part of the current model set
00211  /*
00212   unsigned int currentSize =0;
00213 
00214   for (unsigned int index=0; index<wrt_entities.size(); index++)
00215   {
00216     EntityHandle wrt_ent=wrt_entities[index];
00217     if (wrt_ent )
00218     {
00219       if (MBI()->contains_entities(modelSet, &wrt_ent, 1))
00220       {
00221         wrt_entities[currentSize] = wrt_entities[index];
00222         senses[currentSize] = senses[index];
00223         currentSize++;
00224       }
00225     }
00226   }
00227   wrt_entities.resize(currentSize);
00228   senses.resize(currentSize);
00229   //
00230   */
00231   return MB_SUCCESS;
00232 }
00233   int main(int argc, char **argv) {
00234 
00235    // ******************************************************************
00236     // Load the h5m file and create tags.
00237     // ******************************************************************
00238 
00239     clock_t start_time = clock();
00240     const bool debug = false;
00241     const bool check_geom_size = true;
00242     bool verbose = true;
00243 
00244     // check input args
00245     if( 2 > argc || 3 < argc ) 
00246       {
00247         std::cout << "To zip a faceted h5m file:" << std::endl;
00248         std::cout << "$ ./make_watertight <input_file.h5m>" << std::endl;
00249         std::cout << "To facet and zip an ACIS file using the default facet tolerance:" << std::endl;
00250         std::cout << "$ ./make_watertight <input_file.sat>" << std::endl;
00251         std::cout << "To facet and zip an ACIS file using a specified facet tolerance:" << std::endl;
00252         std::cout << "$ ./make_watertight <input_file.sat> <facet_tolerance>" << std::endl;
00253         return MB_FAILURE;
00254       }
00255 
00256     // The root name does not have an extension
00257     std::string input_name = argv[1];
00258     std::string root_name = argv[1];
00259     int len = root_name.length();
00260     root_name.erase(len - 4);
00261     bool is_acis;
00262 
00263     // load the input file
00264     ErrorCode result, rval;
00265     EntityHandle input_set;
00266 
00267     rval = MBI()->create_meshset( MESHSET_SET, input_set );
00268 
00269     if(gen::error(MB_SUCCESS!=rval,"failed to create_meshset"))
00270       {
00271         return rval;
00272       }
00273 
00274     std::cout << "Loading input file..." << std::endl;
00275 
00276     // If reading an h5m file, the facet tolerance has already been determined.
00277     // Read the facet_tol from the file_set. There should only be one input
00278     // argument.
00279 
00280     if(std::string::npos!=input_name.find("h5m") && (2==argc)) 
00281       {
00282         rval = MBI()->load_file( input_name.c_str(), &input_set );
00283         if(gen::error(MB_SUCCESS!=rval,"failed to load_file 0"))
00284           {
00285             return rval;      
00286           }
00287         
00288         is_acis = false;
00289 
00290     // If reading a sat file, the facet toleance will default to 1e-3 if it is
00291     // not specified. If the user does not specify a facet_tol, default to 1e-3.
00292     // This is the same as what ReadCGM uses.
00293       } 
00294 
00295     /*
00296      // recreate to only perform these operations on h5m meshes  
00297     else if(std::string::npos!=input_name.find("sat") && 
00298               ((2==argc) || (3==argc)) ) 
00299       {
00300         double facet_tol;
00301         if(3 == argc) 
00302           {
00303             facet_tol = atof(argv[2]);
00304           }
00305         else 
00306           {
00307             facet_tol = 1e-3;
00308           }
00309 
00310         std::string options;
00311         options += "FACET_DISTANCE_TOLERANCE=";
00312         std::stringstream facet_tol_ss;
00313         facet_tol_ss << facet_tol; 
00314         options += facet_tol_ss.str();
00315         if(debug) std::cout << "  options=" << options << std::endl;
00316         rval = MBI()->load_file( input_name.c_str(), &input_set, options.c_str() );
00317         if(gen::error(MB_SUCCESS!=rval,"failed to load_file 1")) return rval;
00318 
00319       // write an HDF5 file of facets with known tolerance   
00320         std::string facet_tol_filename = root_name + "_" + facet_tol_ss.str() + ".h5m";
00321         rval = MBI()->write_mesh( facet_tol_filename.c_str() );
00322         if(gen::error(MB_SUCCESS!=rval,"failed to write_mesh 0")) return rval;
00323         is_acis = true;
00324       } 
00325     else 
00326       {
00327         std::cout << "incorrect input arguments" << std::endl;
00328         return MB_FAILURE;
00329       }
00330      //not required if  only doing this with h5m files
00331      */
00332 
00333     // create tags
00334     clock_t load_time = clock();    
00335     Tag geom_tag, id_tag, normal_tag, merge_tag, faceting_tol_tag,
00336       geometry_resabs_tag, size_tag, orig_curve_tag;
00337   
00338     result = MBI()->tag_get_handle( GEOM_DIMENSION_TAG_NAME, 1,
00339                                 MB_TYPE_INTEGER, geom_tag, MB_TAG_DENSE|MB_TAG_CREAT );
00340     assert( MB_SUCCESS == result );
00341     if ( result != MB_SUCCESS )
00342       {
00343         moab_printer(result);
00344       }
00345     result = MBI()->tag_get_handle( GLOBAL_ID_TAG_NAME, 1,
00346                                 MB_TYPE_INTEGER, id_tag, MB_TAG_DENSE|MB_TAG_CREAT);
00347     assert( MB_SUCCESS == result );
00348     if ( result != MB_SUCCESS )
00349       {
00350         moab_printer(result);
00351       }
00352     result = MBI()->tag_get_handle( "NORMAL", sizeof(MBCartVect), MB_TYPE_OPAQUE,
00353         normal_tag, MB_TAG_DENSE|MB_TAG_CREAT);
00354     assert( MB_SUCCESS == result );
00355     if ( result != MB_SUCCESS )
00356       {
00357         moab_printer(result);
00358       }
00359     result = MBI()->tag_get_handle( "MERGE", 1, MB_TYPE_HANDLE,
00360         merge_tag, MB_TAG_SPARSE|MB_TAG_CREAT );
00361     assert( MB_SUCCESS == result );
00362     if ( result != MB_SUCCESS )
00363       {
00364         moab_printer(result);
00365       } 
00366     result = MBI()->tag_get_handle( "FACETING_TOL", 1, MB_TYPE_DOUBLE,
00367         faceting_tol_tag , MB_TAG_SPARSE|MB_TAG_CREAT );
00368     assert( MB_SUCCESS == result );
00369     if ( result != MB_SUCCESS )
00370       {
00371         moab_printer(result);
00372       }
00373     result = MBI()->tag_get_handle( "GEOMETRY_RESABS", 1,     MB_TYPE_DOUBLE,
00374                              geometry_resabs_tag, MB_TAG_SPARSE|MB_TAG_CREAT  );
00375     assert( MB_SUCCESS == result );
00376     if ( result != MB_SUCCESS )
00377       {
00378         moab_printer(result);
00379       }
00380     result = MBI()->tag_get_handle( "GEOM_SIZE", 1, MB_TYPE_DOUBLE,
00381                                     size_tag, MB_TAG_DENSE|MB_TAG_CREAT  );
00382     assert( (MB_SUCCESS == result) );
00383     if ( result != MB_SUCCESS )
00384       {
00385         moab_printer(result);
00386       }
00387     int true_int = 1;    
00388     result = MBI()->tag_get_handle( "ORIG_CURVE", 1,
00389                                 MB_TYPE_INTEGER, orig_curve_tag, MB_TAG_DENSE|MB_TAG_CREAT, &true_int );
00390     assert( MB_SUCCESS == result );
00391     if ( result != MB_SUCCESS )
00392       {
00393         moab_printer(result);
00394       }
00395     // PROBLEM: MOAB is not consistent with file_set behavior. The tag may not be
00396     // on the file_set.
00397     Range file_set;
00398     result = MBI()->get_entities_by_type_and_tag( 0, MBENTITYSET, &faceting_tol_tag,
00399                                                   NULL, 1, file_set );
00400 
00401     if(gen::error(MB_SUCCESS!=result,"could not get faceting_tol_tag"))
00402       {
00403         return result;
00404       }
00405 
00406     gen::error(file_set.empty(),"file set not found");
00407 
00408     if(gen::error(1!=file_set.size(),"Refacet with newer version of ReadCGM.")) 
00409       {
00410         return MB_FAILURE;
00411       }
00412 
00413     double facet_tol, sme_resabs_tol=1e-6;
00414     result = MBI()->tag_get_data( faceting_tol_tag, &file_set.front(), 1,  
00415                                   &facet_tol );
00416     assert(MB_SUCCESS == result);
00417     result = MBI()->tag_get_data( geometry_resabs_tag, &file_set.front(), 1,  
00418                                   &sme_resabs_tol );
00419     if(MB_SUCCESS != result)
00420       {
00421         std::cout <<  "absolute tolerance could not be read from file" << std::endl;
00422       }
00423 
00424     // In practice, use 2*facet_tol because we are always comparing 2 faceted
00425     // entities. If instead we were comparing a faceted entity and a geometric
00426     // entitiy, then 1*facet_tol is correct.
00427 
00428     const double SME_RESABS_TOL = sme_resabs_tol; // from ACIS through CGM
00429     const double FACET_TOL = facet_tol; // specified by user when faceting cad
00430     std::cout << "  faceting tolerance=" << facet_tol << " cm" << std::endl;
00431     std::cout << "  absolute tolerance=" << sme_resabs_tol << " cm" << std::endl;
00432     
00433    // get all geometry sets
00434  
00435     
00436     // get all geometry sets
00437     Range geom_sets[4];
00438     for(unsigned dim=0; dim<4; dim++) 
00439       {
00440         void *val[] = {&dim};
00441         result = MBI()->get_entities_by_type_and_tag( 0, MBENTITYSET, &geom_tag,
00442                                                     val, 1, geom_sets[dim] );
00443         std::cout << "Get entities by type and tag" << std::endl;
00444 
00445         assert(MB_SUCCESS == result);
00446 
00447         // make sure that sets TRACK membership and curves are ordered
00448         // MESHSET_TRACK_OWNER=0x1, MESHSET_SET=0x2, MESHSET_ORDERED=0x4
00449         for(Range::iterator i=geom_sets[dim].begin(); i!=geom_sets[dim].end(); i++)
00450           {
00451             unsigned int options;
00452             result = MBI()->get_meshset_options(*i, options );
00453             assert(MB_SUCCESS == result);
00454     
00455             // if options are wrong change them
00456             if(dim==1) 
00457               {
00458                 if( !(MESHSET_TRACK_OWNER&options) || !(MESHSET_ORDERED&options) ) 
00459                   {
00460                     result = MBI()->set_meshset_options(*i, MESHSET_TRACK_OWNER|MESHSET_ORDERED);
00461                     assert(MB_SUCCESS == result);
00462                   }
00463               } 
00464             else 
00465               {
00466                 if( !(MESHSET_TRACK_OWNER&options) ) 
00467                   {        
00468                     result = MBI()->set_meshset_options(*i, MESHSET_TRACK_OWNER);
00469                     assert(MB_SUCCESS == result);
00470                   }
00471               }
00472           }
00473       }
00474 
00475     std::cout << "I am here" << std::endl;
00476 
00477     // this could be related to when there are sat files rather than mesh?
00478     // If desired, find each entity's size before sealing.
00480     if(check_geom_size) 
00481       {
00482         std::cout << "I am checking the geometry size" << std::endl;
00483         result = get_geom_size_before_sealing( geom_sets, geom_tag, size_tag, verbose );
00484         if(gen::error(MB_SUCCESS!=result,"measuring geom size failed"))
00485           {
00486             return result;
00487           }
00488       }
00489     
00490     //*/
00491 
00492     std::cout << "Get entity count before sealing" << std::endl;
00493     // Get entity count before sealing.
00494     int orig_n_tris;
00495     result = MBI()->get_number_entities_by_type( 0, MBTRI, orig_n_tris );
00496     std::cout << result << std::endl;
00497 
00498     assert(MB_SUCCESS == result);
00499 
00500     std::cout << "==================================" << std::endl;
00501     std::cout << "  Input faceted geometry contains: " << std::endl;
00502     std::cout << "==================================" << std::endl;
00503 
00504     std::cout << geom_sets[3].size() << " volumes, " 
00505               << geom_sets[2].size() << " surfaces, " << geom_sets[1].size() 
00506               << " curves, " << orig_n_tris << " triangles, and " 
00507               << geom_sets[0].size() << " vertices" << std::endl;  
00508 
00509     std::cout << "==================================" << std::endl;
00510 
00511 
00512 /*
00513     //Print all geometry entities
00514     std::cout << "Surfaces" << std::endl;
00515     for (unsigned int index=0; index < geom_sets[2].size(); index++)
00516     {
00517       std::cout << "surface handle = " << geom_sets[2][index] << std::endl;
00518       std::cout << "surface id = " << gen::geom_id_by_handle(geom_sets[2][index]) << std::endl;
00519     }
00520     
00521     std::cout << "Curves" << std::endl;
00522     for (unsigned int index=0; index < geom_sets[1].size(); index++)
00523     {
00524       std::cout << "curve handle = " << geom_sets[1][index] << std::endl;
00525       std::cout << "curve id = " << gen::geom_id_by_handle(geom_sets[1][index]) << std::endl;
00526     }
00527     
00528     std::cout << "Volumes" << std::endl;
00529     for (unsigned int index=0; index < geom_sets[3].size(); index++)
00530     {
00531       std::cout << "volume handle = " << geom_sets[3][index] << std::endl;
00532       std::cout << "volume id = " << gen::geom_id_by_handle(geom_sets[3][index]) << std::endl;
00533     }
00534 */
00535     
00536 
00537 // Get all curve senses
00538     std::cout << "=====================================" << std::endl;
00539     std::cout << " CURVE SENSES " << std::endl;
00540     std::cout << "=====================================" << std::endl;
00541 
00542     GeomTopoTool gt(MBI(), false);
00543     
00544     for( unsigned int i=0; i<geom_sets[1].size(); i++)
00545     {
00546     EntityHandle curve = geom_sets[1][i];
00547     std::vector<EntityHandle> surfs;
00548     std::vector<int> senses;
00549     rval = gt.get_senses( curve, surfs, senses);
00550     if(gen::error(MB_SUCCESS!=result,"could not get curve senses")) return result;
00551     std::cout << "Number of senses for curve " << gen::geom_id_by_handle(curve) << " = " << senses.size() << std::endl;
00552     for (unsigned int index=0; index<senses.size() ; index++)
00553     { 
00554      std::cout << "surf = " << gen::geom_id_by_handle(surfs[index]) << std::endl;
00555      std::cout << "sense = " << sense_printer( senses[index] ) << std::endl;
00556     }
00557     std::cout << std::endl;
00558     }
00559 
00560     
00561 
00562 //Get all surface senses
00563 
00564     std::cout << "=====================================" << std::endl;
00565     std::cout << " SURFACE SENSES " << std::endl;
00566     std::cout << "=====================================" << std::endl;
00567 
00568 
00569     for( unsigned int i=0; i<geom_sets[2].size(); i++)
00570     {
00571     EntityHandle surf = geom_sets[2][i];
00572     std::vector<EntityHandle> vols;
00573     std::vector<int> surf_senses;
00574     rval = gt.get_senses( surf, vols, surf_senses);
00575     if(gen::error(MB_SUCCESS!=result,"could not get surface senses")) return result;
00576     std::cout << "Number of senses for surface " << gen::geom_id_by_handle(surf) << " = " << surf_senses.size() << std::endl;
00577     for (unsigned int index=0; index<surf_senses.size() ; index++)
00578     { 
00579      std::cout << "vol = " << gen::geom_id_by_handle(vols[index]) << std::endl;
00580      std::cout << "sense = " << sense_printer( surf_senses[index] ) << std::endl;
00581     }
00582     std::cout << std::endl;
00583     }
00584 
00585 // Print all Vertex Coordinates
00586 
00587     std::cout << "=====================================" << std::endl;
00588     std::cout << " Vertex Coordinates " << std::endl;
00589     std::cout << "=====================================" << std::endl;
00590 
00591     Range verts;
00592     rval = MBI()->get_entities_by_type(0, MBVERTEX, verts);
00593     if(gen::error(MB_SUCCESS!=result,"could not get vertex handles")) return result;
00594     double x[geom_sets[0].size()];
00595     double y[geom_sets[0].size()];
00596     double z[geom_sets[0].size()];
00597 
00598 
00599     rval = MBI()-> get_coords( verts, &x[0], &y[0], &z[0]);
00600     if(gen::error(MB_SUCCESS!=result,"could not get coordinates of the vertices")) return result;
00601 
00602 
00603     int j=0;
00604     for (Range::const_iterator i = verts.begin(); i!=verts.end(); i++)
00605     {
00606         
00607      std::cout << "Vertex ID = " << *i << std::endl;
00608      std::cout << "X = " << x[j] << std::endl;
00609      std::cout << "Y = " << y[j] << std::endl;
00610      std::cout << "Z = " << z[j] << std::endl;
00611 
00612      j++;
00613 
00614    }
00615 }
00616 //==========EOL=============//
00617 
00618 Interface *MBI() {
00619     static Core instance;
00620     return &instance;
00621   }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines