Changeset 2754 for ddriv

Show
Ignore:
Timestamp:
03/25/09 19:16:24 (12 months ago)
Author:
tautges
Message:

Changes to update to C-based interfaces. All files compile
now except for SmoothUtils?, which needs updates for Mesquite changes.

Location:
ddriv/trunk
Files:
21 modified

Legend:

Unmodified
Added
Removed
  • ddriv/trunk/DdrivDerivs.cpp

    r2696 r2754  
    1515#include "MsqError.hpp" 
    1616#include "LaplacianIQ.hpp" 
    17 #include "iBase_SNL_SIDL_defs.h" 
    1817 
    1918#include <iostream> 
     
    3433#define CV_S_INDEX(cv, s) (s*(handle_index_vecs[0].size()+handle_index_vecs[1].size())+cv) 
    3534 
    36 #define CE catch (iBase::Error err) \ 
    37    {std::cerr << "Error msg: " << err.getDescription() << "." << std::endl; return false;} 
     35#define CE(e) if (ierr != iBase_SUCCESS) {                              \ 
     36      std::cerr << "Error msg: " << e << "." << std::endl; return false;} 
    3837 
    3938#define RS if (!success) return success; 
     
    4241// and the list of parameter names 
    4342DdrivDerivs::DdrivDerivs(OptUtils &ou, SmoothUtils &su, GeomGenerator *gg)  
    44   : myOu(ou), mySu(su), myGeomGenerator(gg), adj_cv_s(NULL), infl_scl_p(NULL),  
    45     infl_cv_p(NULL) 
     43        : myOu(ou), mySu(su), myGeomGenerator(gg), adj_cv_s(NULL), infl_scl_p(NULL),  
     44          infl_cv_p(NULL) 
    4645 
    4746{ 
     
    8988    // (STEPS 4, 6) GENERATE MODIFIED MODELS 
    9089 
    91   // su->smoother_driver("T"); 
     90    // su->smoother_driver("T"); 
    9291    // 1. build the overall topology graph 
    9392  success = build_topology_graph(adj_cv_s, handle_index_vecs); RS; 
     
    139138{ 
    140139  bool success; 
     140  int ierr; 
    141141 
    142142  if (myDParams.empty()) { 
     
    153153  mySu.my_algorithm(SmoothUtils::DEFORMING); 
    154154 
    155   // allocate a set for meshsets for use later in restoring vertex coords 
    156   std::set<iBase_EntityHandle> saved_msets; 
     155    // allocate a set for meshsets for use later in restoring vertex coords 
     156  std::set<iBase_EntitySetHandle> saved_msets; 
    157157 
    158158  int pmax = myGeomGenerator->num_params(); 
     
    165165       
    166166        // a. reset classification data and model 
    167       myOu.myRelate.removeRelations(&myOu.myGeom, &myOu.myMesh); 
     167      myOu.reset_relation(true); 
    168168      myGeomGenerator->reset_model(); 
    169169     
     
    192192                                    
    193193        // c. Relate mesh for those entities 
    194       try { 
    195         for (int i = 0; i < 3; i++) 
    196           myOu.myRelate.relateGeomEntities(&myOu.myGeom, &myOu.myMesh, gents[i], gents_size[i]); 
    197 //        myOu.myRelate.relateAllEntities(&myOu.myGeom, &myOu.myMesh); 
     194      for (int i = 0; i < 3; i++) { 
     195        iRel_inferEntArrAssociations(myOu.myRel, myOu.myRelH, &gents[i][0], gents_size[i], 
     196                                     0, &ierr); 
     197        CE("Trouble inferring relations for entities."); 
    198198      } 
    199       catch (iBase::Error) { 
    200         return false; 
    201       } 
    202199     
    203200        // f. smooth 2d geom entities dependent on p 
    204       success = mySu.smooth(gents[1], gents_size[1]);RS; 
    205       success = myOu.project_to_geom(gents[0], gents_size[0]);RS; 
     201      success = mySu.smooth(gents[1]);RS; 
     202      success = myOu.project_to_geom(&gents[0][0], gents[0].size());RS; 
    206203 
    207204      if (debug_output_models) { 
     
    211208 
    212209        char* options; 
    213         iMesh_save( myOu.myMesh, mfilename, options, &result, strlen(mfilename), 0); 
    214  
    215         success = mySu.smooth(gents[2], gents_size[2]);RS; 
     210        iBase_EntitySetHandle root_set; 
     211        iMesh_getRootSet(myOu.myMesh, &root_set, &ierr); 
     212        CE("Couldn't get root set."); 
     213         
     214        iMesh_save( myOu.myMesh, root_set, mfilename.c_str(), options, &ierr, mfilename.length(), 0); 
     215 
     216        success = mySu.smooth(gents[2]);RS; 
    216217        mfilename = "tmp_mesh_p"; 
    217218        mfilename += myOu.itoa(p); 
    218219        mfilename += "_after.vtk"; 
    219         try {myOu.myMesh.save(0, mfilename);} catch (iBase::Error) {return false;} 
     220        iMesh_save( myOu.myMesh, root_set, mfilename.c_str(), options, &ierr, mfilename.length(), 0); 
    220221      } 
    221222       
    222223      else 
    223         success = mySu.smooth(gents[2], gents_size[2]);RS; 
     224        success = mySu.smooth(gents[2]);RS; 
    224225    } 
    225226 
    226227      // g. Compute d(xyz)/dp & store in tag on vertices 
    227     // h. Compute d(n)/dp for all surf vertices & store in tag on them 
     228      // h. Compute d(n)/dp for all surf vertices & store in tag on them 
    228229    success = store_coords_normals(bogus_derivs, 
    229230                                   gents[2], gents_size[2], 2, 
     
    231232                                   myOu.origCoords_tag(), myOu.normal_tag(), myDParams[p]); RS; 
    232233 
    233     // i. Compute d(n)/dp for all surfs containing curve & vertex mesh vertices &  
    234     //    store in tag on them 
     234      // i. Compute d(n)/dp for all surfs containing curve & vertex mesh vertices &  
     235      //    store in tag on them 
    235236    success = store_coords_normals(bogus_derivs, 
    236237                                   gents[1], gents_size[1], 1, 
     
    246247    for (int i = 0; i < 3; i++) { 
    247248      if (0 == gents_size[i]) continue; 
    248       std::vector<iBase_EntityHandle> tmp_msets; 
    249       int tmp_msets_size; 
    250       try { 
    251         myOu.myRelate.getGeomRelatedEntities(&myOu.myGeom, &myOu.myMesh, 
    252                                              gents[i], gents_size[i], 
    253                                              tmp_msets, tmp_msets_size); 
    254       } CE; 
    255       iBase_EntityHandle *msets_ptr = ARRAY_PTR(tmp_msets, iBase_EntityHandle); 
    256       saved_msets.insert(msets_ptr, msets_ptr+tmp_msets_size); 
     249      iBase_EntitySetHandle *tmp_msets = NULL; 
     250      int tmp_msets_size, tmp_msets_alloc = 0; 
     251      iRel_getEntArrSetArrAssociation(myOu.myRel, myOu.myRelH, 
     252                                      &gents[i][0], gents_size[i], 0, 
     253                                      &tmp_msets, &tmp_msets_alloc, &tmp_msets_size, 
     254                                      &ierr); 
     255      CE("Couldn't get relation."); 
     256      std::copy(tmp_msets, tmp_msets+tmp_msets_size,  
     257                std::inserter(saved_msets, saved_msets.begin())); 
    257258    } 
    258259  } // for p = ... 
    259260   
    260261    // ok, success; reset model, removing classifications too 
    261   myOu.myRelate.removeRelations(&myOu.myGeom, &myOu.myMesh); 
     262  myOu.reset_relation(true); 
    262263  myGeomGenerator->reset_model(); 
    263264 
    264   // finally, reset coords for the msets whose vertices were moved 
     265    // finally, reset coords for the msets whose vertices were moved 
    265266  if (debug)  
    266267    std::cout << "Resetting coords on " << saved_msets.size() << " msets." << std::endl; 
     
    272273  myGeomGenerator->get_params(new_params); 
    273274  success = myGeomGenerator->generate_model(&new_params[0], new_params.size()); RS; 
    274   myOu.myRelate.relateAllEntities(&myOu.myGeom, &myOu.myMesh); 
     275  iRel_inferAllAssociations(myOu.myRel, myOu.myRelH, &ierr); 
     276  CE("Unable to infer all relations."); 
    275277 
    276278  if (debug) 
     
    302304                                iBase_EntitySetHandle& new_set) 
    303305{ 
    304   int err; 
    305  
    306     // make a new set 
    307   CAST_iBase_INTERFACE(myOu.myMesh, mesh_eset, EntSet); 
    308  
    309   iMesh_createEntSet( mesh_eset, 1, new_set, &ierr );  
    310   CHKERR; 
     306  int ierr; 
     307 
     308    // make a new mesh entity set 
     309  iMesh_createEntSet(myOu.myMesh, 1, &new_set, &ierr);  
     310  CE("Couldn't make a new set."); 
    311311 
    312312    // get all the dim-dimensional entities 
     
    314314  for (std::vector<iBase_EntityHandle>::iterator vit = gents.begin(); 
    315315       vit != gents.end(); vit++) { 
    316     std::vector<iBase_EntityHandle> tmp_ments; 
    317     int tmp_ments_size; 
    318     myOu.myRelate.getGeomOwnedMesh(&myOu.myGeom, &myOu.myMesh, *vit, 2, 
    319                                   tmp_ments, tmp_ments_size); 
    320     append_from_sidl(tmp_ments, tmp_ments_size, set_ments); 
     316    iBase_EntityHandle *tmp_ments = NULL; 
     317    int tmp_ments_alloc = 0, tmp_ments_size; 
     318    iRel_getEntEntArrAssociation(myOu.myRel, myOu.myRelH, *vit, 0, 
     319                                 &tmp_ments, &tmp_ments_alloc, &tmp_ments_size, 
     320                                 &ierr); 
     321    CE("Couldn't get related mesh entities."); 
     322    std::copy(tmp_ments, tmp_ments+tmp_ments_size, std::back_inserter(set_ments)); 
     323    free(tmp_ments); 
    321324  } 
    322325   
    323326    // now put them all in the set 
    324     iMesh_addEntArrToSet( mesh_eset, &set_ments[0], set_ments.size(),  
    325                           new_set, &ierr ); 
    326     CHKERR; 
    327    
    328   return true; 
    329 } 
    330  
    331 //! for surfaces, get mesh vertex coordinates and normals at those vertices,  
    332 //! compute derivatives if old_xxx_tag is non-zero, then store results in xxx_tag 
    333 //! variant that works on all entities of given dimension 
    334 bool DdrivDerivs::store_coords_normals(const bool bogus_derivs, 
    335                                        std::vector<iBase_EntityHandle> *handle_index_vecs,  
    336                                        const int gent_dim, 
    337                                        TagHandle coord_tag, TagHandle normal_tag, 
    338                                        TagHandle old_coord_tag, TagHandle old_normal_tag, 
    339                                        const double dp)  
    340 { 
    341     // do coords & normals on surfaces 
    342   int gents_size = handle_index_vecs[gent_dim].size(); 
    343   std::vector<iBase_EntityHandle> gents(convert_to_sidl_vector(&handle_index_vecs[gent_dim][0], 
    344                                                           gents_size)); 
    345  
    346   return store_coords_normals(bogus_derivs, gents, gents_size, gent_dim,  
    347                               coord_tag, normal_tag, old_coord_tag, old_normal_tag, 
    348                               dp); 
     327  iMesh_addEntArrToSet(myOu.myMesh, &set_ments[0], set_ments.size(), new_set,  
     328                       &ierr ); 
     329  CE("Couldn't add to set."); 
     330   
     331  return true; 
    349332} 
    350333 
     
    356339                                       const int gents_size, 
    357340                                       const int gent_dim, 
    358                                        TagHandle coord_tag, TagHandle normal_tag, 
    359                                        TagHandle old_coord_tag, TagHandle old_normal_tag, 
     341                                       iBase_TagHandle coord_tag, iBase_TagHandle normal_tag, 
     342                                       iBase_TagHandle old_coord_tag, iBase_TagHandle old_normal_tag, 
    360343                                       const double dp)  
    361344{ 
    362345 
    363   int err; 
    364  
    365   std::vector<MentitySetHandle> msets; 
    366   int msets_size; 
    367   try { 
    368     myOu.myRelate.getGeomRelatedEntities(&myOu.myGeom, &myOu.myMesh,  
    369                                         gents, gents_size, msets, msets_size); 
    370   } catch (iBase::Error) {return false;} 
     346  int ierr; 
     347 
     348  iBase_EntitySetHandle *msets = NULL; 
     349  int msets_alloc = 0, msets_size; 
     350  iRel_getEntArrSetArrAssociation(myOu.myRel, myOu.myRelH, 
     351                                  &gents[0], gents.size(), 0, &msets, &msets_alloc, &msets_size, 
     352                                  &ierr); 
     353  CE("Couldn't get related mesh entity sets."); 
    371354   
    372355  for (int g = 0; g < msets_size; g++) { 
     
    383366 
    384367      // grab the geom and mesh entity handles and index right away 
    385     iBase_EntityHandle this_gent = gents.get(g); 
    386     iBase_EntityHandle this_ment = msets.get(g); 
     368    iBase_EntityHandle this_gent = gents[g]; 
     369    iBase_EntitySetHandle this_ment = msets[g]; 
    387370    assert(0 != this_gent && 0 != this_ment); 
    388371     
    389     // get the mesh vertices and their coordinates for this gent 
    390  
    391     // get mesh vertices in this_mset 
     372      // get the mesh vertices and their coordinates for this gent 
     373 
     374      // get mesh vertices in this_mset 
    392375    iBase_EntityHandle *mverts = NULL; 
    393376    int mverts_alloc = 0, mverts_size; 
    394377    int result; 
    395378    iMesh_getEntities(myOu.myMesh, this_ment, 
    396                       iMesh::EntityType_VERTEX,  
    397                       iMesh::EntityTopology_ALL_TOPOLOGIES, 
     379                      iBase_VERTEX,  
     380                      iMesh_ALL_TOPOLOGIES, 
    398381                      &mverts, &mverts_alloc, &mverts_size, &result); 
    399382 
    400383    if (iBase_SUCCESS != result) { 
    401384      char dum_str[256]; 
    402       iMesh_getDescription(myMesh, dum_str, &result, 256); 
     385      iMesh_getDescription(myOu.myMesh, dum_str, &result, 256); 
    403386      std::cerr << "Couldn't get entities in set in reset_coords." 
    404387                << std::endl 
     
    415398    int coords_size, avg_normals_size; 
    416399    bool success = myOu.get_coords(mverts, mverts_size, 
    417                                    coords, coords_size); RS; 
     400                                   coords); RS; 
    418401 
    419402      // allocate space for the avg normals, same size as coords array 
    420     avg_normals = avg_normals.create1d(coords_size); 
    421     avg_normals_size = coords_size; 
     403    avg_normals.resize(coords.size()); 
    422404     
    423405      // get the connected surfaces 
    424406    std::vector<iBase_EntityHandle> all_gsurfs; 
    425     int all_gsurfs_size; 
    426     success = myOu.get_connected_surfs(this_gent, gent_dim, all_gsurfs, all_gsurfs_size); 
     407    success = myOu.get_connected_surfs(this_gent, gent_dim, all_gsurfs); 
    427408    if (!success) return success; 
    428409 
     
    452433      if (0 != old_coord_tag) 
    453434        compute_vector_difference(mverts, mverts_size, 
    454                                   coords, coords_size, old_coord_tag, dp); 
    455  
     435                                  coords, old_coord_tag, dp); 
    456436    } 
    457437     
    458438      // now set the coords and normal tags on those vertices 
    459       iMesh_setDblArrData ( mesh_atag, mverts, mverts_size, coord_tag, 
    460                             coords, coords_size, &err); 
    461       CE; 
     439    iMesh_setDblArrData (myOu.myMesh, mverts, mverts_size, coord_tag, 
     440                         &coords[0], coords_size, &ierr); 
     441    CE("Couldn't set coords/normals tag."); 
     442 
     443    free(mverts); 
    462444  } 
    463445   
     
    469451//! derivatives and surface normal derivatives 
    470452bool DdrivDerivs::compute_vector_difference(std::vector<iBase_EntityHandle> &mverts,  
     453                                            std::vector<double> &new_vec,  
     454                                            iBase_TagHandle old_vec_tag, 
     455                                            const double dp)  
     456{ 
     457  return compute_vector_difference(&mverts[0], mverts.size(), new_vec, old_vec_tag, dp); 
     458} 
     459 
     460bool DdrivDerivs::compute_vector_difference(iBase_EntityHandle *mverts,  
    471461                                            const int mverts_size,  
    472462                                            std::vector<double> &new_vec,  
    473                                             const int new_vec_size,  
    474                                             TagHandle old_vec_tag, 
     463                                            iBase_TagHandle old_vec_tag, 
    475464                                            const double dp)  
    476465{ 
    477   int err; 
     466  int ierr; 
    478467 
    479468    // given new values and a tag which holds old values, compute the differences and 
     
    483472   
    484473    // get the old values 
    485   std::vector<char> old_vec; 
    486   int old_vec_size; 
    487   CAST_iBase_INTERFACE(myOu.myMesh, mesh_atag, ArrTag); 
    488   try { 
    489     mesh_atag.getArrData(mverts, mverts_size, old_vec_tag, 
    490                          old_vec, old_vec_size); 
    491   } CE; 
    492    
    493   double *old_vec_ptr = reinterpret_cast<double*>(old_vec._get_ior()->d_firstElement); 
    494   double *new_vec_ptr = reinterpret_cast<double*>(new_vec._get_ior()->d_firstElement); 
     474  char *old_vec = NULL; 
     475  int old_vec_alloc = 0, old_vec_size; 
     476  iMesh_getArrData(myOu.myMesh, mverts, mverts_size, old_vec_tag, 
     477                   &old_vec, &old_vec_alloc, &old_vec_size, &ierr); 
     478  CE("Couldn't get old tag values."); 
     479   
     480  double *old_vec_ptr = reinterpret_cast<double*>(old_vec); 
     481  double *new_vec_ptr = reinterpret_cast<double*>(&new_vec[0]); 
    495482   
    496483  double denom = 1.0 / dp; 
     
    517504  } 
    518505  else { 
    519     for (int i = 0; i < 3*mverts_size; i++) { 
    520       double deriv = (new_vec.get(i) - old_vec_ptr[i])*denom; 
    521       new_vec.set(i, deriv); 
    522     } 
    523   } 
     506    for (int i = 0; i < 3*mverts_size; i++) 
     507      new_vec[i] = (new_vec[i] - old_vec_ptr[i])*denom; 
     508  } 
     509 
     510  free(old_vec); 
    524511   
    525512  return true; 
     
    533520{ 
    534521  std::vector<iBase_EntityHandle>::iterator handle_index =  
    535     std::find(handle_index_vecs[dim].begin(),  
    536               handle_index_vecs[dim].end(), this_gent); 
     522      std::find(handle_index_vecs[dim].begin(),  
     523                handle_index_vecs[dim].end(), this_gent); 
    537524   
    538525  return (handle_index == handle_index_vecs[dim].end()) ? -1 : 
    539     (handle_index - handle_index_vecs[dim].begin()); 
     526      (handle_index - handle_index_vecs[dim].begin()); 
    540527} 
    541528 
     
    550537                                       std::vector<iBase_EntityHandle> *handle_index_vecs, 
    551538                                       std::vector<iBase_EntityHandle> &surf_gents,  
    552                                        int &surf_gents_size, 
    553                                        std::vector<iBase_EntityHandle> &c_gents, 
    554                                        int &c_gents_size, 
    555                                        std::vector<iBase_EntityHandle> &v_gents, 
    556                                        int &v_gents_size, 
    557                                        const bool cv_too) 
    558 { 
    559     // get the surfaces 
    560   std::vector<iBase_EntityHandle> tmp_surfs; 
    561   std::set<iBase_EntityHandle> tmp_cs, tmp_vs; 
    562   std::set<iBase_EntityHandle> *tmp_cs_ptr, *tmp_vs_ptr; 
    563   if (cv_too) { 
    564     tmp_vs_ptr = &tmp_vs; 
    565     tmp_cs_ptr = &tmp_cs; 
    566   } 
    567   else { 
    568     tmp_vs_ptr = NULL; 
    569     tmp_cs_ptr = NULL; 
    570   } 
    571    
    572   iBase_EntityHandle this_surf; 
    573  
    574   bool result = get_influenced_gents(infl_scl_p, handle_index_vecs, 
    575                                      tmp_surfs, tmp_cs_ptr, tmp_vs_ptr); 
    576   if (!result) return result; 
    577  
    578     // now put them into the surface and curve/vertex sidl arrays 
    579   surf_gents_size = tmp_surfs.size(); 
    580   surf_gents = surf_gents.create1d(surf_gents_size); 
    581   for (unsigned int s = 0; s < tmp_surfs.size(); s++) 
    582     surf_gents.set(s, tmp_surfs[s]); 
    583  
    584   if (cv_too) { 
    585     c_gents_size = tmp_cs.size(); 
    586     c_gents = c_gents.create1d(c_gents_size); 
    587     v_gents_size = tmp_vs.size(); 
    588     v_gents = v_gents.create1d(v_gents_size); 
    589    
    590     unsigned int v, c; 
    591     std::set<iBase_EntityHandle>::iterator sit; 
    592     for (c = 0, sit = tmp_cs.begin(); c < c_gents_size; c++, sit++) 
    593       c_gents.set(c, *sit); 
    594     for (v = 0, sit = tmp_vs.begin(); v < v_gents_size; v++, sit++) 
    595       v_gents.set(v, *sit); 
    596   } 
    597    
    598   return true; 
    599 } 
    600  
    601 //! same as other version of this function, but taking STL vectors as args instead 
    602 //! of sidl arrays 
    603 bool DdrivDerivs::get_influenced_gents(const unsigned int *infl_scl_p, 
    604                                        std::vector<iBase_EntityHandle> *handle_index_vecs, 
    605                                        std::vector<iBase_EntityHandle> &surf_gents,  
    606539                                       std::set<iBase_EntityHandle> *cs, 
    607540                                       std::set<iBase_EntityHandle> *vs) 
    608541{ 
     542  int ierr; 
     543   
     544  std::set<iBase_EntityHandle> *cv_sets[2] = {vs, cs}; 
    609545   
    610546  for (int s = 0; s < handle_index_vecs[2].size(); s++) { 
     
    616552    if (NULL == cs || NULL == vs) continue; 
    617553     
    618     // now get adjacent curves/vertices and put them in the set 
    619     int adj_vs_size, adj_cs_size; 
    620  
    621     iBase_EntityHandle *adj_vs = NULL; 
    622     int adj_vs_alloc = 0; 
    623     iGeom_getEntAdj(myOu.myGeom, this_surf, ::iBase_VERTEX, 
    624                     &adj_vs, &adj_vs_alloc, &adj_vs_size, &result); 
    625  
    626  
    627     iBase_EntityHandle *adj_cs = NULL; 
    628     int adj_cs_alloc = 0; 
    629     iGeom_getEntAdj(myOu.myGeom, this_surf, ::iBase_VERTEX, 
    630                     &adj_cs, &adj_cs_alloc, &adj_cs_size, &result); 
    631  
    632      
    633     for (int nv = 0; nv < adj_vs_size; nv++) vs->insert(adj_vs.get(nv)); 
    634     for (int nc = 0; nc < adj_cs_size; nc++) cs->insert(adj_cs.get(nc)); 
    635   } 
    636  
     554      // now get adjacent curves/vertices and put them in the set 
     555    for (int dim = 0; dim < 2; dim++) { 
     556      int adj_alloc = 0, adj_size; 
     557      iBase_EntityHandle *adj = NULL; 
     558      iGeom_getEntAdj(myOu.myGeom, this_surf, dim, 
     559                      &adj, &adj_alloc, &adj_size, &ierr); 
     560      CE("Couldn't get adjacent geometry."); 
     561 
     562      std::copy(adj, adj+adj_size,  
     563                std::inserter(*cv_sets[dim], cv_sets[dim]->begin())); 
     564      free(adj); 
     565    } 
     566  } 
     567   
    637568  return true; 
    638569} 
     
    669600      for (int s = 0; s < handle_index_vecs[2].size(); s++) { 
    670601        infl_cv_p[CV_P_INDEX(cv, p)] += 
    671           adj_cv_s[CV_S_INDEX(cv, s)] * myGeomGenerator->paramSurfInfls[S_P_INDEX(s, p)]; 
     602            adj_cv_s[CV_S_INDEX(cv, s)] * myGeomGenerator->paramSurfInfls[S_P_INDEX(s, p)]; 
    672603      } 
    673604    } 
     
    680611      for (int cv = 0; cv < ncv; cv++) { 
    681612        infl_scl_p[S_P_INDEX(s, p)] +=  
    682           adj_cv_s[CV_S_INDEX(cv, s)] * infl_cv_p[CV_P_INDEX(cv, p)]; 
     613            adj_cv_s[CV_S_INDEX(cv, s)] * infl_cv_p[CV_P_INDEX(cv, p)]; 
    683614      } 
    684615    } 
     
    734665//! the overall surface-curve/vertex adjacency matrix (stored as unsigned ints) 
    735666bool 
    736  DdrivDerivs::build_topology_graph(unsigned int *&adj_cv_s, 
    737                                  std::vector<iBase_EntityHandle> *handle_index_vecs)  
    738 { 
     667DdrivDerivs::build_topology_graph(unsigned int *&adj_cv_s, 
     668                                  std::vector<iBase_EntityHandle> *handle_index_vecs)  
     669{ 
     670  int ierr; 
    739671    // get the handle_index_vecs 
    740672  bool success = populate_index_vecs(handle_index_vecs);  
     
    743675  if (NULL != adj_cv_s) delete [] adj_cv_s; 
    744676  int adj_cv_s_size = handle_index_vecs[2].size() * (handle_index_vecs[0].size() +  
    745                                             handle_index_vecs[1].size()); 
     677                                                     handle_index_vecs[1].size()); 
    746678  adj_cv_s = new unsigned int [adj_cv_s_size]; 
    747679  for (int i = 0; i < adj_cv_s_size; i++) adj_cv_s[i] = 0; 
     
    751683  for (int s = 0; s < handle_index_vecs[2].size(); s++) { 
    752684     
    753     //   - get handle & adjacent entities 
     685      //   - get handle & adjacent entities 
    754686    iBase_EntityHandle this_surf = handle_index_vecs[2][s]; 
    755687 
     
    757689    int rowstart = 0; 
    758690    for (int dim = 0; dim < 2; dim++) { 
    759          int adj_gents_size; 
    760  
    761  
    762          iBase_EntityHandle *adj_gents = NULL; 
    763          int adj_vs_alloc = 0; 
    764          iGeom_getEntAdj(myOu.myGeom, this_surf, (::int)dim, 
    765                          &adj_gents, &adj_gents_alloc,  
    766                          &adj_gents_size, &result); 
    767  
     691      iBase_EntityHandle *adj_gents = NULL; 
     692      int adj_gents_alloc = 0, adj_gents_size; 
     693      iGeom_getEntAdj(myOu.myGeom, this_surf, dim, 
     694                      &adj_gents, &adj_gents_alloc, &adj_gents_size,  
     695                      &ierr); 
     696      CE("Couldn't get adj geometry entities."); 
    768697 
    769698      for (int ag = 0; ag < adj_gents_size; ag++) { 
    770            const int adj_index 
    771              = get_gent_index(adj_gents[ag], handle_index_vecs, dim); 
    772            assert(adj_index < handle_index_vecs[dim].size()); 
    773            adj_cv_s[CV_S_INDEX(rowstart+adj_index, s)] = 1; 
     699        const int adj_index 
     700            = get_gent_index(adj_gents[ag], handle_index_vecs, dim); 
     701        assert(adj_index < handle_index_vecs[dim].size()); 
     702        adj_cv_s[CV_S_INDEX(rowstart+adj_index, s)] = 1; 
    774703      } 
    775704 
    776705      rowstart += handle_index_vecs[0].size(); 
     706 
     707      free(adj_gents); 
    777708    } 
    778709  } 
     
    787718 
    788719bool 
    789  DdrivDerivs::assign_indices(std::map<int, gent_data*> *id_gentdata_map,  
    790                            std::vector<iBase_EntityHandle> *handle_index_vecs,  
    791                            std::vector<int> *id_index_vecs, 
    792                            int *num_indices)  
     720DdrivDerivs::assign_indices(std::map<int, gent_data*> *id_gentdata_map,  
     721                            std::vector<iBase_EntityHandle> *handle_index_vecs,  
     722                            std::vector<int> *id_index_vecs, 
     723                            int *num_indices)  
    793724{ 
    794725 
    795726    // loop over dimension/id map, assigning indexes 
    796727    // also generate two vectors, for handle[index] and global_id[index] 
    797     for (int dim = 0; dim < 3; dim++) { 
    798  
    799          int tot_indices = 0; 
    800          std::map<int, gent_data*>::iterator mit = (id_gentdata_map[dim]).begin();  
    801          for ( ; mit != (id_gentdata_map[dim]).end(); mit++) { 
    802               gent_data *ged = (*mit).second; 
    803               ged->index = tot_indices; 
    804               handle_index_vecs[dim].push_back(ged->gent); 
    805               id_index_vecs[dim].push_back(ged->gid); 
    806               tot_indices++; 
    807          } 
    808          num_indices[dim] = tot_indices; 
    809     } 
    810  
    811     return true; 
     728  for (int dim = 0; dim < 3; dim++) { 
     729 
     730    int tot_indices = 0; 
     731    std::map<int, gent_data*>::iterator mit = (id_gentdata_map[dim]).begin();  
     732    for ( ; mit != (id_gentdata_map[dim]).end(); mit++) { 
     733      gent_data *ged = (*mit).second; 
     734      ged->index = tot_indices; 
     735      handle_index_vecs[dim].push_back(ged->gent); 
     736      id_index_vecs[dim].push_back(ged->gid); 
     737      tot_indices++; 
     738    } 
     739    num_indices[dim] = tot_indices; 
     740  } 
     741 
     742  return true; 
    812743} 
    813744 
     
    817748bool DdrivDerivs::init_tags()  
    818749{ 
    819   CAST_iBase_INTERFACE(myOu.myMesh, mesh_tag_iface, Tag); 
    820  
    821750  dcoordsdpTag.clear(); 
    822751  dnormaldpTag.clear(); 
    823752  for (int i = 0; i < myGeomGenerator->num_params(); i++) { 
    824753    std::string tmp_name = std::string("DCOORDS_DP_") +  
    825       std::string(myGeomGenerator->get_param_name(i)); 
    826     dcoordsdpTag.push_back(get_tag_handle(mesh_tag_iface,  
     754        std::string(myGeomGenerator->get_param_name(i)); 
     755    dcoordsdpTag.push_back(get_tag_handle(myOu.myMesh, 
    827756                                          tmp_name.c_str(), 3, 
    828                                           ::iBase_DOUBLE)); 
     757                                          iBase_DOUBLE)); 
    829758     
    830759    tmp_name = std::string("DNORMAL_DP_") + 
    831                std::string(myGeomGenerator->get_param_name(i)); 
    832     dnormaldpTag.push_back(get_tag_handle(mesh_tag_iface,  
     760        std::string(myGeomGenerator->get_param_name(i)); 
     761    dnormaldpTag.push_back(get_tag_handle(myOu.myMesh, 
    833762                                          tmp_name.c_str(), 3, 
    834                                           ::iBase_DOUBLE)); 
     763                                          iBase_DOUBLE)); 
    835764  } 
    836765   
     
    839768 
    840769//! retrieves or creates a tag handle given the tag's description 
     770iBase_TagHandle DdrivDerivs::get_tag_handle(iMesh_Instance &iface,  
     771                                            const char *tag_name,  
     772                                            const int tag_size,  
     773                                            const iBase_TagValueType tag_type)  
     774{ 
     775  iBase_TagHandle return_tag = 0; 
     776 
     777  int ierr; 
     778  iMesh_createTag(iface,  
     779                  tag_name, tag_size, tag_type,  
     780                  &return_tag, &ierr, 
     781                  strlen(tag_name)); 
     782  if (iBase_SUCCESS != ierr && iBase_TAG_ALREADY_EXISTS) { 
     783    CE("Trouble creating tag."); 
     784  } 
     785   
     786  return return_tag; 
     787} 
     788 
    841789void 
    842  *DdrivDerivs::get_tag_handle(::iBase::Tag &iface,  
    843                               const char *tag_name,  
    844                               const int tag_size,  
    845                               const ::iBase::TagValueType tag_type)  
    846 { 
    847      void *return_tag = 0; 
    848  
    849      iBase_TagHandle th; 
    850      iMesh_createTag(iface,  
    851                      tag_name,  
    852                      tag_size,  
    853                      tag_type,  
    854                      &th,  
    855                      &result, 
    856                      strlen(tag_name)); 
    857     } 
    858  
    859     if (iBase_SUCCESS != result) { 
    860       std::cerr << "Error creating/accessing tag: " << tag_name << std::endl; 
    861       return 0; 
    862     } 
    863  
    864     return return_tag; 
    865 } 
    866  
    867 void 
    868  DdrivDerivs::print_adj_graph(const unsigned int *adj_cv_s,  
    869                             std::vector<iBase_EntityHandle> *handle_index_vecs)  
     790DdrivDerivs::print_adj_graph(const unsigned int *adj_cv_s,  
     791                             std::vector<iBase_EntityHandle> *handle_index_vecs)  
    870792{ 
    871793  std::cout << std::endl; 
     
    893815{ 
    894816 
    895   iBase::ArrTag tag_iface = (iBase::ArrTag)(myOu.myMesh); 
    896  
    897817  std::vector<iBase_EntityHandle> handle_index_vecs[4]; 
    898818 
     819  int ierr; 
     820 
    899821  bool success = populate_index_vecs(handle_index_vecs); RS; 
    900822     
    901         // Get all surfaces which depend on p and all children  
    902         //    of those surfaces 
     823    // Get all surfaces which depend on p and all children  
     824    //    of those surfaces 
    903825  std::vector<iBase_EntityHandle> surf_gents; 
    904826  std::set<iBase_EntityHandle> v_gents, c_gents; 
    905827  success = get_influenced_gents(&infl_scl_p[S_P_INDEX(0, param_index)],  
    906                                 handle_index_vecs, surf_gents,  
    907                                 &c_gents, &v_gents); RS; 
    908  
    909   // put all the curves/verts onto the end of the surf list 
     828                                handle_index_vecs, surf_gents,  
     829                                &c_gents, &v_gents); RS; 
     830 
     831    // put all the curves/verts onto the end of the surf list 
    910832  std::copy(c_gents.begin(), c_gents.end(), std::back_inserter(surf_gents)); 
    911833  std::copy(v_gents.begin(), v_gents.end(), std::back_inserter(surf_gents)); 
    912834 
    913   // for each gent 
     835    // for each gent 
    914836  for (int s = 0; s < surf_gents.size(); s++) { 
    915837     
    916   // - get all vertices on entity 
    917     std::vector<iBase_EntityHandle> mverts; 
     838      // - get all vertices on entity 
     839    iBase_EntityHandle *mverts = NULL; 
    918840    int mverts_size; 
    919841    success = myOu.get_gentity_mvertices(surf_gents[s], mverts, mverts_size); 
     
    923845    } 
    924846 
    925   // - append vertices to list 
    926     std::copy(ARRAY_PTR(mverts, iBase_EntityHandle), 
    927               ARRAY_PTR(mverts, iBase_EntityHandle)+mverts_size,  
    928               std::back_inserter(vertices)); 
    929  
    930   // - get tag for that parameter 
    931     TagHandle param_tag = dcoordsdpTag[param_index]; 
    932  
    933  
    934  
    935     iBase_EntityHandle *mverts = NULL; 
    936     int mverts_alloc = 0, mverts_size; 
    937     double *params = NULL; 
    938     int params_alloc = 0, params_size; 
    939  
    940     iMesh_getDblArrData(myOu.myMesh, mverts, mverts_size,  
    941                         param_tag, &params, &params_alloc,  
    942                         &params_size, &result); 
    943  
    944     if (iBase_SUCCESS != result) { 
    945         char dum_str[256]; 
    946         iMesh_getDescription(myMesh, dum_str, &result, 256); 
    947         std::cerr << "Couldn't get coordinates tag on mvertices  
    948                       in store_cv_coords_normals." 
    949                   << std::endl 
    950                   << dum_str << std::endl; 
    951         return false; 
    952     } 
    953  
    954  
    955      
    956   // - append to list 
    957     std::copy(ARRAY_PTR(params, double), ARRAY_PTR(params, double)+params_size, 
    958               std::back_inserter(vertex_DV)); 
    959   } 
     847      // - append vertices to list 
     848    std::copy(mverts, mverts+mverts_size, std::back_inserter(vertices)); 
     849 
     850    free(mverts); 
     851  } 
     852   
     853    // - get tag for that parameter 
     854  iBase_TagHandle param_tag = dcoordsdpTag[param_index]; 
     855 
     856  double *params = NULL; 
     857  int params_alloc = 0, params_size; 
     858 
     859  iMesh_getDblArrData(myOu.myMesh, &vertices[0], vertices.size(), 
     860                      param_tag, &params, &params_alloc, &params_size,  
     861                      &ierr); 
     862  if (iBase_SUCCESS != ierr) { 
     863    char dum_str[256]; 
     864    iMesh_getDescription(myOu.myMesh, dum_str, &ierr, 256); 
     865    std::cerr << "Couldn't get coordinates tag on mvertices" 
     866              << " in store_cv_coords_normals." 
     867              << std::endl 
     868              << dum_str << std::endl; 
     869    return false; 
     870  } 
     871     
     872    // - append to list 
     873  std::copy(params, params+params_size, std::back_inserter(vertex_DV)); 
     874  free(params); 
    960875 
    961876  return true; 
     
    965880                                double &integrated_dv)  
    966881{ 
    967   iBase::ArrTag tag_iface = (iBase::ArrTag)(myOu.myMesh); 
    968   CAST_iMesh_INTERFACE(myOu.myMesh, mesh_ent, Entity); 
    969    
    970882  std::vector<iBase_EntityHandle> handle_index_vecs[4]; 
    971883  bool success = populate_index_vecs(handle_index_vecs); RS; 
    972884     
    973         // Get all surfaces which depend on p and all children  
    974         //    of those surfaces 
     885    // Get all surfaces which depend on p and all children  
     886    //    of those surfaces 
    975887  std::vector<iBase_EntityHandle> surf_gents; 
    976888  std::set<iBase_EntityHandle> v_gents, c_gents; 
    977889  success = get_influenced_gents(&infl_scl_p[S_P_INDEX(0, param_index)],  
    978                                 handle_index_vecs, surf_gents,  
    979                                 NULL, NULL); RS; 
     890                                handle_index_vecs, surf_gents,  
     891                                NULL, NULL); RS; 
    980892 
    981893    // get the entity sets corresponding to those 
    982   std::vector<MentitySetHandle> msets; 
    983   int msets_size; 
    984   std::vector<iBase_EntityHandle> surf_gents_sidl  
    985         = convert_to_sidl_vector(surf_gents); 
    986   try { 
    987     myOu.myRelate.getGeomRelatedEntities(&myOu.myGeom, &myOu.myMesh,  
    988                                          surf_gents_sidl, surf_gents.size(),  
    989                                          msets, msets_size); 
    990   } catch (iBase::Error) {return false;} 
     894  iBase_EntitySetHandle *msets = NULL; 
     895  int msets_alloc = 0, msets_size; 
     896  int ierr; 
     897  iRel_getEntArrSetArrAssociation(myOu.myRel, myOu.myRelH, 
     898                                  &surf_gents[0], surf_gents.size(), 0, 
     899                                  &msets, &msets_alloc, &msets_size,  
     900                                  &ierr); 
     901  CE("Couldn't get related mesh sets."); 
    991902   
    992903    // - get tag for that parameter 
    993   TagHandle param_tag = dcoordsdpTag[param_index]; 
     904  iBase_TagHandle param_tag = dcoordsdpTag[param_index]; 
    994905 
    995906  integrated_dv = 0.0; 
    996907   
    997   // for each surface 
     908    // for each surface 
    998909  for (int s = 0; s < surf_gents.size(); s++) { 
    999910     
    1000     // - get all triangles on entity 
    1001     myOu.myMesh.getEntities(msets[s], iMesh::EntityType_FACE, 
    1002                             iMesh::EntityTopology_ALL_TOPOLOGIES, 
    1003                             faces, faces_size); 
    1004  
    1005  
     911      // - get all triangles on entity 
    1006912    iBase_EntityHandle *faces = NULL; 
    1007913    int faces_alloc = 0, faces_size; 
    1008     iMesh_getEntities(myOu.myMesh, msets[s], 
    1009                       iMesh::EntityType_FACE, 
    1010                       iMesh::EntityTopology_ALL_TOPOLOGIES, 
    1011                       &faces, &faces_alloc, &faces_size, &result); 
    1012  
    1013     if (iBase_SUCCESS != result) { 
     914    iMesh_getEntities(myOu.myMesh, msets[s],  
     915                      iBase_FACE, iMesh_ALL_TOPOLOGIES, 
     916                      &faces, &faces_alloc, &faces_size, &ierr); 
     917 
     918    if (iBase_SUCCESS != ierr) { 
    1014919      char dum_str[256]; 
    1015       iMesh_getDescription(myMesh, dum_str, &result, 256); 
     920      iMesh_getDescription(myOu.myMesh, dum_str, &ierr, 256); 
    1016921      std::cerr << "Couldn't get entities in set in reset_coords." 
    1017922                << std::endl 
     
    1022927 
    1023928    double surf_area = 0.0, surf_integrated_dv = 0.0; 
    1024      
    1025929    for (int t = 0; t < faces_size; t++) { 
    1026930       
    1027931        // get vertices for those triangles and coordinates for vertices 
    1028       std::vector<iBase_EntityHandle> mverts; 
    1029       int mverts_size; 
    1030       try { 
    1031         mesh_ent.getEntAdj(faces[t], iMesh::EntityType_VERTEX,  
    1032                            mverts, mverts_size); 
    1033       } 
    1034       catch (iBase::Error err) { 
    1035         std::cerr << "Trouble getting vertices for a face." << std::endl; 
     932      iBase_EntityHandle *mverts = NULL; 
     933      int mverts_alloc = 0, mverts_size; 
     934      iMesh_getEntAdj(myOu.myMesh, faces[t], iBase_VERTEX,  
     935                      &mverts, &mverts_alloc, &mverts_size, &ierr); 
     936      CE("Trouble getting vertices for a face."); 
     937 
     938      double *coords = NULL; 
     939      int coords_alloc = 0, coords_size; 
     940      iMesh_getVtxArrCoords(myOu.myMesh, mverts, mverts_size,  
     941                            iBase_INTERLEAVED,  
     942                            &coords, &coords_alloc, &coords_size, &ierr); 
     943      CE("Trouble getting vertex coordinates."); 
     944      assert(coords_size == mverts_size*3); 
     945 
     946 
     947        // get design v's and normals for those verts 
     948      double *params = NULL; 
     949      int params_alloc = 0, params_size; 
     950      iMesh_getDblArrData(myOu.myMesh, mverts, mverts_size, 
     951                          param_tag, &params, &params_alloc, 
     952                          &params_size, &ierr); 
     953 
     954      if (iBase_SUCCESS != ierr) { 
     955        char dum_str[256]; 
     956        iMesh_getDescription(myOu.myMesh, dum_str, &ierr, 256); 
     957        std::cerr << "Couldn't get coordinates tag on mvertices" 
     958                  << " in store_cv_coords_normals." 
     959                  << std::endl 
     960                  << dum_str << std::endl; 
    1036961        return false; 
    1037962      } 
    1038963 
    1039       std::vector<double> coords; 
    1040       int coords_size; 
    1041       iMesh::StorageOrder so = iMesh::StorageOrder_INTERLEAVED; 
    1042       try { 
    1043         myOu.myMesh.getVtxArrCoords(mverts, mverts_size,  
    1044                                     so, coords, coords_size); 
    1045       } 
    1046       catch (iBase::Error err) { 
    1047         std::cerr << "Trouble getting vertex coordinates." << std::endl; 
     964      double *normals = NULL; 
     965      int normals_alloc = 0, normals_size; 
     966 
     967      iMesh_getDblArrData(myOu.myMesh, mverts, mverts_size, 
     968                          myOu.normal_tag(), &normals,  
     969                          &normals_alloc, &normals_size, &ierr); 
     970      if (iBase_SUCCESS != ierr) { 
     971        char dum_str[256]; 
     972        iMesh_getDescription(myOu.myMesh, dum_str, &ierr, 256); 
     973        std::cerr << "Couldn't get coordinates tag on mvertices" 
     974                  << " in store_cv_coords_normals." 
     975                  << std::endl 
     976                  << dum_str << std::endl; 
    1048977        return false; 
    1049978      } 
    1050       assert(coords_size == mverts_size*3); 
    1051  
    1052  
    1053       // get design v's and normals for those verts 
    1054  
    1055       Base_EntityHandle *mverts = NULL; 
    1056       int mverts_alloc = 0, mverts_size; 
    1057       double *params = NULL; 
    1058       int params_alloc = 0, params_size; 
    1059  
    1060       iMesh_getDblArrData(myOu.myMesh, mverts, mverts_size, 
    1061                           param_tag, &params, &params_alloc, 
    1062                           &params_size, &result); 
    1063  
    1064       if (iBase_SUCCESS != result) { 
    1065           char dum_str[256]; 
    1066           iMesh_getDescription(myMesh, dum_str, &result, 256); 
    1067           std::cerr << "Couldn't get coordinates tag on mvertices 
    1068                         in store_cv_coords_normals." 
    1069                     << std::endl 
    1070                     << dum_str << std::endl; 
    1071           return false; 
    1072       } 
    1073  
    1074  
    1075       int normals_alloc = 0; 
    1076  
    1077       iMesh_getDblArrData(myOu.myMesh, mverts, mverts_size, 
    1078                           myOu.normal_tag(), &normals,  
    1079                           &normals_alloc, &normals_size, &result); 
    1080  
    1081       if (iBase_SUCCESS != result) { 
    1082           char dum_str[256]; 
    1083           iMesh_getDescription(myMesh, dum_str, &result, 256); 
    1084           std::cerr << "Couldn't get coordinates tag on mvertices 
    1085                         in store_cv_coords_normals." 
    1086                     << std::endl 
    1087                     << dum_str << std::endl; 
    1088           return false; 
    1089       } 
    1090  
    1091  
    1092979 
    1093980        // put the edge vectors in for the coords of 2 pts 
     
    11271014        term += params[i]*normals[i]; 
    11281015      surf_integrated_dv += (term/(double)mverts_size) * area; 
     1016       
     1017      free(mverts); free(coords); free(params); free(normals); 
    11291018    } 
    11301019 
    11311020    std::cout << "Surface " << myOu.get_gentity_id(surf_gents[s])  
    11321021              << " area = " << surf_area <<  
    1133       ", integrated dv contribution = " << surf_integrated_dv << std::endl; 
     1022        ", integrated dv contribution = " << surf_integrated_dv << std::endl; 
    11341023     
    11351024    integrated_dv += surf_integrated_dv; 
     1025 
     1026    free(faces);  
    11361027  } 
    11371028 
  • ddriv/trunk/DdrivDerivs.hpp

    r2696 r2754  
    2020 
    2121 
    22 #include "MeshTSTT.hpp" 
    23 #include "GeomTSTT.hpp" 
    24  
    2522#include "OptUtils.hpp" 
    2623#include "SmoothUtils.hpp" 
     
    3027#include <vector> 
    3128 
    32 typedef void* MentitySetHandle; 
    33 typedef void* TagHandle; 
    3429 
    3530class GeomGenerator; 
     
    9186  unsigned int *adj_cv_s, *infl_scl_p, *infl_cv_p; 
    9287 
    93   std::vector<TagHandle> dcoordsdpTag, dnormaldpTag, dnormaldpSTag; 
     88  std::vector<iBase_TagHandle> dcoordsdpTag, dnormaldpTag, dnormaldpSTag; 
    9489   
    9590    // params vector and requested difference step size (initialize to ???) 
     
    108103  bool make_mesh_set(std::vector<iBase_EntityHandle> &gents, 
    109104                     const int dimension, 
    110                      MentitySetHandle &new_set); 
     105                     iBase_EntitySetHandle &new_set); 
    111106   
    112107    //! for surfaces, get mesh vertex coordinates and normals at those vertices,  
     
    117112                            const int gents_size, 
    118113                            const int gent_dim, 
    119                             TagHandle coord_tag, TagHandle normal_tag, 
    120                             TagHandle old_coord_tag, TagHandle old_normal_tag, 
    121                             const double dp); 
    122    
    123     //! for surfaces, get mesh vertex coordinates and normals at those vertices,  
    124     //! compute derivatives if old_xxx_tag is non-zero, then store results in xxx_tag 
    125   bool store_coords_normals(const bool bogus_derivs, 
    126                             std::vector<iBase_EntityHandle> *handle_index_vecs,  
    127                             const int gent_dim, 
    128                             TagHandle coord_tag, TagHandle normal_tag, 
    129                             TagHandle old_coord_tag, TagHandle old_normal_tag, 
     114                            iBase_TagHandle coord_tag, iBase_TagHandle normal_tag, 
     115                            iBase_TagHandle old_coord_tag, iBase_TagHandle old_normal_tag, 
    130116                            const double dp); 
    131117   
     
    134120    //! derivatives and surface normal derivatives 
    135121  bool compute_vector_difference(std::vector<iBase_EntityHandle> &mverts,  
    136                                  const int mverts_size,  
    137122                                 std::vector<double> &new_vec,  
    138                                  const int new_vec_size,  
    139                                  TagHandle old_vec_tag, 
     123                                 iBase_TagHandle old_vec_tag, 
     124                                 const double dp); 
     125   
     126  bool compute_vector_difference(iBase_EntityHandle *mverts,  
     127                                 int mverts_size, 
     128                                 std::vector<double> &new_vec,  
     129                                 iBase_TagHandle old_vec_tag, 
    140130                                 const double dp); 
    141131   
     
    148138                                    const int mverts_size,  
    149139                                    std::vector<double> &new_vec,  
    150                                     TagHandle old_vec_tag, 
     140                                    iBase_TagHandle old_vec_tag, 
    151141                                    const int surf_indices_size, 
    152142                                    const double dp, 
     
    158148    //! that space on the input tag 
    159149  bool allocate_cv_normal_tags(std::vector<iBase_EntityHandle> &mverts,  
    160                                const int mverts_size, TagHandle normal_tag,  
     150                               const int mverts_size, iBase_TagHandle normal_tag,  
    161151                               const int surf_indices_size, 
    162152                               std::vector<double> &mvert_normals); 
     
    248238   
    249239    //! retrieves or creates a tag handle given the tag's description 
    250   void *get_tag_handle(iBase_Instance &iface, const char *tag_name,  
    251                        const int tag_size, const iBase_TagValueType tag_type); 
     240  iBase_TagHandle get_tag_handle(iMesh_Instance &iface, const char *tag_name,  
     241                                 const int tag_size, const iBase_TagValueType tag_type); 
    252242 
    253243    //! print the adjacency graph, with header row containing vertex/curve indices 
  • ddriv/trunk/GeomGenerator.cpp

    r2696 r2754  
    340340 
    341341    iGeom_save(myOu.myGeom, myOutputGeomFile.c_str(), NULL, &result,   
    342                myOutputGeomFile.length(), &result); 
     342               myOutputGeomFile.length(), 0); 
    343343 
    344344    if (iBase_SUCCESS != result) { 
  • ddriv/trunk/Makefile

    r2696 r2754  
    1515#include ${IREL_DIR}/lib/iRel-Defs.inc 
    1616 
    17 include /home/malusare/bin/lib/iRel-Defs.inc 
    18 include /home/malusare/bin/lib/iGeom-Defs.inc 
    19 include /home/malusare/bin/lib/iMesh-Defs.inc 
     17include ${IREL_DIR}/lib/iRel-Defs.inc 
     18include ${IGEOM_DIR}/lib/iGeom-Defs.inc 
     19include ${IMESH_DIR}/lib/iMesh-Defs.inc 
    2020 
    2121 
     
    6060 
    6161ddriv: ${DDRIV_OBJS}  libddriv.a ${MESQUITE_LIBS}  
    62         $(IREL_CXX)  $(CXXFLAGS) -o $@ ${DDRIV_OBJS} -L. -lddriv ${MESQUITE_LIBS_LINK} ${IREL_LIBS} 
     62        $(IREL_CXX)  $(CXXFLAGS) -o $@ ${DDRIV_OBJS} -L. -lddriv ${MESQUITE_LIBS_LINK} ${IREL_LIBS} ${IMESH_LIBS} ${IGEOM_LIBS} 
    6363 
    6464libddriv.a: $(DDRIV_LIB_OBJS) 
     
    119119        ${CXX} -DMSQ_TSTT_USE_MOAB -c ${CXXFLAGS} ${IGEOM_INCLUDES} $< 
    120120.cpp.o: 
    121         ${CXX} -DMSQ_TSTT_USE_MOAB -c ${CXXFLAGS} ${iRel_INCLUDES} ${IGEOM_INCLUDES} ${MESQUITE_INCLUDES} $< 
     121        ${CXX} -DMSQ_TSTT_USE_MOAB -c ${CXXFLAGS} ${IREL_INCLUDES} ${IMESH_INCLUDES} ${IGEOM_INCLUDES} ${MESQUITE_INCLUDES} $< 
    122122 
    123123 
  • ddriv/trunk/MkCone.cpp

    r2696 r2754  
    3737#include <vector> 
    3838#include <cmath> 
    39 using namespace std; 
    4039 
    4140#include "iGeom.h" 
    42 #include "iBase_SNL_SIDL_defs.h" 
    4341#include "CubitVector.hpp" 
    44 #include "AcisModifyEngine.hpp" 
    4542#include "GeometryModifyTool.hpp" 
    4643#include "GeometryQueryTool.hpp" 
     
    5249#include "ConeParamInfls.hpp" 
    5350 
     51#define CE(s) if (iBase_SUCCESS != ierr) {std::cerr << s << std::endl; return false;} 
     52     
    5453/* 
    5554 * Interpolation functions: interpolateY and interpolateZ 
     
    6867 
    6968/* ================================================== */ 
    70 vector<double> 
    71  interpolateY(vector<double> y, double angle, double beta) 
     69std::vector<double> 
     70interpolateY(std::vector<double> y, double angle, double beta) 
    7271{ 
    73   vector<double> result; 
     72  std::vector<double> result; 
    7473  size_t len = y.size(); 
    7574  for(size_t i = 0; i < len; ++i) { 
     
    8180 
    8281/* ================================================== */ 
    83 vector<double>  
    84  interpolateZ(vector<double> z, double angle, double gamma) 
     82std::vector<double>  
     83 interpolateZ(std::vector<double> z, double angle, double gamma) 
    8584{ 
    86   vector<double> result; 
     85  std::vector<double> result; 
    8786  size_t len = z.size(); 
    8887  for(size_t i = 0; i < len; ++i) { 
     
    140139  } 
    141140   
    142   vector<double> frac, x, y, z, other; 
     141  std::vector<double> frac, x, y, z, other; 
    143142 
    144143  // create the fraction vector 
     
    175174  for(int v = 0; v < NUM_V-2; v++) { 
    176175      // vertices at angle (v+1)*angle 
    177       vector<double> new_y = interpolateY(y, angle, beta); 
    178       vector<double> new_z = interpolateZ(z, angle, gamma); 
     176      std::vector<double> new_y = interpolateY(y, angle, beta); 
     177      std::vector<double> new_z = interpolateZ(z, angle, gamma); 
    179178      for(int u = 0; u < NUM_U; ++u) { 
    180179          points[u][v+1]->set(x[u], new_y[u], new_z[u]); 
     
    267266    // assign to RefEntity* so cast to void* works correctly 
    268267  RefEntity *this_body_refent = this_body; 
    269   typedef void* iBase_EntityHandle; 
    270   iBase_EntityHandle this_gent = this_body_refent, cone_body; 
     268  iBase_EntityHandle this_gent = (iBase_EntityHandle) this_body_refent, cone_body; 
    271269 
    272270  // get the other parts by copy/reflect/uniting 
    273271 
    274272  iBase_EntityHandle q2, q3, q4; 
    275  
    276   iGeom_copyEnt( geom_iface, this_gent, q2, &result); 
    277  
    278   if (iBase_SUCCESS != result) { 
     273  int ierr; 
     274  iGeom_copyEnt( geom_iface, this_gent, &q2, &ierr); 
     275 
     276  if (iBase_SUCCESS != ierr) { 
    279277      std::cerr << "Failed Copy." << std::endl; 
    280278      return false; 
     
    282280 
    283281 
    284   iGeom_reflectEnt(geom_iface, q2, 0.0, 0.0, 1.0, &result); 
    285  
    286   if (iBase_SUCCESS != result) { 
     282  iGeom_reflectEnt(geom_iface, &q2, 0.0, 0.0, 1.0, &ierr); 
     283 
     284  if (iBase_SUCCESS != ierr) { 
    287285      std::cerr << "Failed Reflect." << std::endl; 
    288286      return false; 
     
    291289 
    292290 
    293   iGeom_copyEnt( geom_iface, q2, q3, &result); 
    294  
    295   if (iBase_SUCCESS != result) { 
     291  iGeom_copyEnt( geom_iface, q2, &q3, &ierr); 
     292 
     293  if (iBase_SUCCESS != ierr) { 
    296294      std::cerr << "Failed Copy." << std::endl; 
    297295      return false; 
     
    299297 
    300298 
    301   iGeom_copyEnt( geom_iface, this_gent, q4, &result); 
    302  
    303   if (iBase_SUCCESS != result) { 
     299  iGeom_copyEnt( geom_iface, this_gent, &q4, &ierr); 
     300 
     301  if (iBase_SUCCESS != ierr) { 
    304302      std::cerr << "Failed Copy." << std::endl; 
    305303      return false; 
     
    308306 
    309307 
    310   iGeom_reflectEnt(geom_iface, q3, 0.0, 1.0, 0.0, &result); 
    311  
    312   if (iBase_SUCCESS != result) { 
     308  iGeom_reflectEnt(geom_iface, &q3, 0.0, 1.0, 0.0, &ierr); 
     309 
     310  if (iBase_SUCCESS != ierr) { 
    313311      std::cerr << "Failed Reflect." << std::endl; 
    314312      return false; 
     
    316314 
    317315 
    318   iGeom_reflectEnt(geom_iface, q4, 0.0, 1.0, 0.0, &result); 
     316  iGeom_reflectEnt(geom_iface, &q4, 0.0, 1.0, 0.0, &ierr); 
    319317     
    320   if (iBase_SUCCESS != result) { 
     318  if (iBase_SUCCESS != ierr) { 
    321319      std::cerr << "Failed Reflect." << std::endl; 
    322320      return false; 
     
    324322 
    325323 
    326   std::vector<iBase_EntityHandle> pieces = pieces.create1d(4); 
    327   pieces.set(0, this_gent); 
    328   pieces.set(1, q2); 
    329   pieces.set(2, q3); 
    330   pieces.set(3, q4); 
    331  
    332  
    333   iGeom_uniteEnts( geom_iface, &pieces, 4, &cone_body, &result);  
    334  
    335   if (iBase_SUCCESS != result) { 
    336       std::cerr << "Failed Unite." << std::endl; 
    337       return false; 
    338   } 
    339  
    340  
    341  
    342   iBase_EntityHandle q2, q3, q4; 
    343  
    344   iGeom_copyEnt( geom_iface, this_gent, q2, &result); 
    345  
    346   if (iBase_SUCCESS != result) { 
    347       std::cerr << "Failed Copy." << std::endl; 
    348       return false; 
    349   } 
    350  
    351  
    352   iGeom_reflectEnt( geom_iface, q2, 0.0, 0.0, 1.0, &result);  
    353  
    354   if (iBase_SUCCESS != result) { 
    355       std::cerr << "Failed Subtract." << std::endl; 
    356       return false; 
    357   } 
    358  
    359  
    360   iGeom_copyEnt( geom_iface, q2, q3, &result); 
    361      
    362   if (iBase_SUCCESS != result) { 
    363       std::cerr << "Failed Copy." << std::endl; 
    364       return false; 
    365   } 
    366  
    367  
    368   iGeom_copyEnt( geom_iface, this_gent, q4, &result); 
    369  
    370   if (iBase_SUCCESS != result) { 
    371       std::cerr << "Failed Copy." << std::endl; 
    372       return false; 
    373   } 
    374  
    375  
    376   iGeom_reflectEnt( geom_iface, q3, 0.0, 1.0, 0.0, &result); 
    377  
    378   if (iBase_SUCCESS != result) { 
    379       std::cerr << "Failed Reflect." << std::endl; 
    380       return false; 
    381   } 
    382  
    383  
    384   iGeom_reflectEnt( geom_iface, q4, 0.0, 1.0, 0.0, &result); 
    385  
    386   if (iBase_SUCCESS != result) { 
    387       std::cerr << "Failed Reflect." << std::endl; 
    388       return false; 
    389   } 
    390  
    391  
    392   std::vector<iBase_EntityHandle> pieces = pieces.create1d(4); 
    393   pieces.set(0, this_gent); 
    394   pieces.set(1, q2); 
    395   pieces.set(2, q3); 
    396   pieces.set(3, q4); 
    397  
    398   iGeom_uniteEnts( geom_face, &pieces, 4, &cone_body, &result); 
    399  
    400   if (iBase_SUCCESS != result) { 
    401       std::cerr << "Failed Unite." << std::endl; 
    402       return false; 
    403   } 
    404    
     324  iBase_EntityHandle pieces[4] = {this_gent, q2, q3, q4}; 
     325  iGeom_uniteEnts(geom_iface, pieces, 4, &cone_body, &ierr);  
     326  CE("Failed Unite."); 
     327 
     328  iGeom_copyEnt( geom_iface, this_gent, &q2, &ierr); 
     329  CE("Failed Copy."); 
     330 
     331  iGeom_reflectEnt( geom_iface, &q2, 0.0, 0.0, 1.0, &ierr);  
     332  CE("Failed Subtract."); 
     333   
     334 
     335 
     336  iGeom_copyEnt( geom_iface, q2, &q3, &ierr); 
     337  CE("Failed Copy."); 
     338 
     339  iGeom_copyEnt( geom_iface, this_gent, &q4, &ierr); 
     340  CE("Failed Copy."); 
     341 
     342  iGeom_reflectEnt( geom_iface, &q3, 0.0, 1.0, 0.0, &ierr); 
     343  CE("Failed Reflect."); 
     344 
     345  iGeom_reflectEnt( geom_iface, &q4, 0.0, 1.0, 0.0, &ierr); 
     346  CE("Failed Reflect."); 
     347 
     348  iBase_EntityHandle pieces2[] = {this_gent, q2, q3, q4}; 
     349  iGeom_uniteEnts(geom_iface, pieces2, 4, &cone_body, &ierr); 
     350  CE("Failed Unite."); 
    405351  
    406352  // if we got here, and it's requested, pass back the param-surf influence matrix 
    407353  if (NULL != param_surf_infls) { 
    408  
    409354      int num_param_surf_infls = paramInflsNumSurfs*paramInflsNumParams; 
    410355 
    411356      if (NULL == *param_surf_infls)  
    412  
    413357          *param_surf_infls = new unsigned int [num_param_surf_infls]; 
    414  
    415358           memcpy(*param_surf_infls, paramSurfInfls,  
    416359                   num_param_surf_infls*sizeof(unsigned int)); 
  • ddriv/trunk/MkCyl.cpp

    r2696 r2754  
    2121#include <iostream> 
    2222#include "iGeom.h" 
    23 #include "iBase_SNL_SIDL_defs.h" 
    2423#include "cylParamInfls.hpp" 
     24#include <cstring> 
    2525 
    26 typedef void* iBase_EntityHandle; 
    2726int result; 
    2827 
     
    5049 
    5150 
    52   iGeom_sectionEnt( geom_iface, cyl_tmp, 1.0, 0.0, 0.0, 0.0,  
     51  iGeom_sectionEnt( geom_iface, &cyl_tmp, 1.0, 0.0, 0.0, 0.0,  
    5352                    false, &cyl, &result); 
    5453 
  • ddriv/trunk/MkDDSCell.cpp

    r2696 r2754  
    2020#include <iostream> 
    2121#include "iGeom.h" 
    22 #include "iBase_SNL_SIDL_defs.h" 
    2322#include "ddsdefines.h" 
    2423#include "DDSParamInfls.hpp" 
    25  
    26  
     24#include <cstring> 
     25#include <vector> 
     26#include <math.h> 
    2727 
    2828/* ============== typedefs section =============== */ 
    2929int result; 
    30  
    31 typedef void* iBase_EntityHandle; 
    3230 
    3331const double fixed_params[15] = { 
     
    5654bool cleanup_other_geom(iGeom_Instance &geom, 
    5755                        iBase_EntityHandle &dds_cell, 
    58                         std::vector<iBase_EntityHandle> &initial_gents, 
     56                        iBase_EntityHandle *initial_gents, 
    5957                        int initial_gents_size); 
    6058 
     
    6260const double RADTODEG = 180.0/(4.0*atan(1.0)); 
    6361 
    64  
     62#define CE(s) if (iBase_SUCCESS != ierr) {        \ 
     63      std::cerr << s << std::endl; return false; } 
     64     
    6565 
    6666 
     
    8989 
    9090  if (iBase_SUCCESS != result) { 
    91       std::cerr << "Trouble getting gentities of dimension" << dim << std::endl; 
     91      std::cerr << "Trouble getting gentities of dimension" << iBase_REGION << std::endl; 
    9292      return false; 
    9393  } 
     
    201201 
    202202 
    203   iGeom_moveEnt( iGeom_transforms, temp2, -.5*brround,  
     203  iGeom_moveEnt(geom, &temp2, -.5*brround,  
    204204                .5*b_n0_fillet_pos+.5*brround, 0.0, &result); 
    205205 
     
    210210 
    211211 
    212   iGeom_subtract(geom, temp1, temp2, &temp3, &result); 
     212  iGeom_subtractEnts(geom, temp1, temp2, &temp3, &result); 
    213213 
    214214  if (iBase_SUCCESS != result) { 
     
    218218 
    219219 
    220   iGeom_moveEnt( iGeom_Instance, temp3, .5*brround,  
     220  iGeom_moveEnt(geom, &temp3, .5*brround,  
    221221                .5*b_n0_fillet_pos+.5*brround, 0.0, &result ); 
    222222  
     
    230230  double angb00 = asin(brrbc/(b_n0_fillet_pos+brround))*RADTODEG; 
    231231 
    232   iGeom_rotateEnt( geom, temp3, angb00, 0.0, 0.0, 1.0, &result); 
     232  iGeom_rotateEnt( geom, &temp3, angb00, 0.0, 0.0, 1.0, &result); 
    233233 
    234234  if (iBase_SUCCESS != result) { 
     
    242242 
    243243 
    244   iGeom_sectionEnt( geom, temp3, 0.0, 1.0, 0.0,  
     244  iGeom_sectionEnt( geom, &temp3, 0.0, 1.0, 0.0,  
    245245                    offset, true, &angled, &result); 
    246246 
     
    249249      return false; 
    250250  } 
    251  
    252   
    253   std::vector<iBase_EntityHandle> tempa =  
    254       std::vector<iBase_EntityHandle>::create1d(2); 
    255  
    256251 
    257252  double sinang00_pos  
     
    272267 
    273268 
    274    iGeom_moveEnt( geom, temp1, wnarrow_pos-rround, 
     269   iGeom_moveEnt( geom, &temp1, wnarrow_pos-rround, 
    275270                  .5*b_n0_fillet_pos+.5*s_b_manif_pos+.5*rmanif, 
    276271                  0.0, &result);   
     
    282277 
    283278 
    284    tempa.set(0, angled); 
    285    tempa.set(1, temp1); 
     279   iBase_EntityHandle tempa[2] = {angled, temp1}; 
    286280   rounded_disk_top = NULL; 
    287281    
    288282 
    289    iGeom_uniteEnts( geom, &tempa, 2, &rounded_disk_top, &result); 
     283   iGeom_uniteEnts( geom, tempa, 2, &rounded_disk_top, &result); 
    290284 
    291285   if (iBase_SUCCESS != result) { 
     
    295289 
    296290 
    297    iGeom_moveEnt( geom, rounded_disk_top, 0.0, 0.0,  
     291   iGeom_moveEnt( geom, &rounded_disk_top, 0.0, 0.0,  
    298292                  0.25*(t_neg-t_pos), &result); 
    299293 
     
    336330 
    337331 
    338   iGeom_moveEnt( geom, temp1, wnarrow_pos - .5*rround,  
     332  iGeom_moveEnt( geom, &temp1, wnarrow_pos - .5*rround,  
    339333                .5*slen_pos + dmove_pos,  
    340334                .5*rround + .25*t_neg - .25*t_pos, &result); 
     
    355349 
    356350 
    357   iGeom_rotateEnt( geom, temp2, 90.0, 1.0, 0.0, 0.0, &result); 
     351  iGeom_rotateEnt( geom, &temp2, 90.0, 1.0, 0.0, 0.0, &result); 
    358352 
    359353  if (iBase_SUCCESS != result) { 
     
    363357 
    364358 
    365   iGeom_moveEnt( geom, temp2, -rround, dmove_pos + .5*slen_pos,    
     359  iGeom_moveEnt( geom, &temp2, -rround, dmove_pos + .5*slen_pos,    
    366360                 .5*cell_height - .5*t_pos + rround, &result); 
    367361 
     
    373367 
    374368  lower_brick = NULL; 
    375   iGeom_subtract(geom, temp1, temp2, &lower_brick, &result); 
     369  iGeom_subtractEnts(geom, temp1, temp2, &lower_brick, &result); 
    376370 
    377371  if (iBase_SUCCESS != result) { 
     
    392386 
    393387 
    394   iGeom_moveEnt( geom, upper_brick, wnarrow_pos,  
     388  iGeom_moveEnt( geom, &upper_brick, wnarrow_pos,  
    395389                 .5*slen_pos + dmove_pos, .25*t_neg, &result); 
    396390 
     
    411405 
    412406 
    413   iGeom_moveEnt( geom, cyl_sm, rslot, dmove_pos,  
     407  iGeom_moveEnt( geom, &cyl_sm, rslot, dmove_pos,  
    414408                 .25*t_neg, &result); 
    415409   
     
    432426 
    433427 
    434    iGeom_moveEnt( geom, temp1, rslot, dmove_pos, 
     428   iGeom_moveEnt( geom, &temp1, rslot, dmove_pos, 
    435429                    .25*(t_neg-t_pos)+.5*rround, &result); 
    436430 
     
    454448 
    455449 
    456    iGeom_moveEnt( geom, temp2, rslot, dmove_pos,  
     450   iGeom_moveEnt( geom, &temp2, rslot, dmove_pos,  
    457451                  .5*cell_height-.5*t_pos+rround, &result); 
    458452 
     
    466460    cyl_lrg = NULL; 
    467461 
    468    iGeom_subtract(geom, temp1, temp2, &cyl_lrg, &result); 
     462   iGeom_subtractEnts(geom, temp1, temp2, &cyl_lrg, &result); 
    469463 
    470464   if (iBase_SUCCESS != result) { 
     
    474468 
    475469 
    476    std::vector<iBase_EntityHandle> tempa =  
    477       std::vector<iBase_EntityHandle>::create1d(4); 
    478  
    479    tempa.set(0, lower_brick); 
    480    tempa.set(1, upper_brick); 
    481    tempa.set(2, cyl_sm); 
    482    tempa.set(3, cyl_lrg); 
     470   iBase_EntityHandle tempa[4] = {lower_brick, upper_brick, cyl_sm, cyl_lrg}; 
    483471   rounded_disk_side_pos = NULL; 
    484  
    485  
    486    iGeom_uniteEnts( geom, &tempa, 4, &rounded_disk_side_pos, &result); 
     472   iGeom_uniteEnts( geom, tempa, 4, &rounded_disk_side_pos, &result); 
    487473 
    488474   if (iBase_SUCCESS != result) { 
     
    526512 
    527513 
    528    iGeom_moveEnt( geom, temp1, wnarrow_neg - .5*rround,  
     514   iGeom_moveEnt( geom, &temp1, wnarrow_neg - .5*rround,  
    529515                  0.0, -.5*rround, &result); 
    530516 
     
    543529   } 
    544530 
    545   iGeom_rotateEnt( geom, temp2, 90.0, 1.0, 0.0, 0.0, &result); 
     531  iGeom_rotateEnt( geom, &temp2, 90.0, 1.0, 0.0, 0.0, &result); 
    546532 
    547533  if (iBase_SUCCESS != result) { 
     
    551537 
    552538 
    553   iGeom_moveEnt( geom, temp2, -rround, 0.0, -rround, &result); 
     539  iGeom_moveEnt( geom, &temp2, -rround, 0.0, -rround, &result); 
    554540 
    555541  if (iBase_SUCCESS != result) { 
     
    560546 
    561547  upper_brick = NULL; 
    562   iGeom_subtract(geom, temp1, temp2, &upper_brick, &result); 
     548  iGeom_subtractEnts(geom, temp1, temp2, &upper_brick, &result); 
    563549 
    564550  if (iBase_SUCCESS != result) { 
     
    568554 
    569555 
    570   iGeom_moveEnt( geom, upper_brick, 0.0, .5*slen_neg, 0.0, &result);  
     556  iGeom_moveEnt( geom, &upper_brick, 0.0, .5*slen_neg, 0.0, &result);  
    571557 
    572558  if (iBase_SUCCESS != result) { 
     
    589575 
    590576 
    591   iGeom_moveEnt( geom, lower_brick, wnarrow_neg, .5*slen_neg,  
     577  iGeom_moveEnt( geom, &lower_brick, wnarrow_neg, .5*slen_neg,  
    592578                 -.25*t_neg-.5*rround, &result); 
    593579 
     
    612598 
    613599 
    614   iGeom_moveEnt( geom, temp1, rslot, 0.0, -.5*rround, &result); 
     600  iGeom_moveEnt( geom, &temp1, rslot, 0.0, -.5*rround, &result); 
    615601 
    616602  if (iBase_SUCCESS != result) { 
     
    632618 
    633619 
    634   iGeom_moveEnt( iGeom_transforms, temp2, rslot, 0.0, -rround, &result);   
     620  iGeom_moveEnt( geom, &temp2, rslot, 0.0, -rround, &result);   
    635621 
    636622  if (iBase_SUCCESS != result) { 
     
    643629  cyl_lrg = NULL; 
    644630 
    645   iGeom_subtract(geom, temp1, temp2, &cyl_lrg, &result); 
     631  iGeom_subtractEnts(geom, temp1, temp2, &cyl_lrg, &result); 
    646632 
    647633  if (iBase_SUCCESS != result) { 
     
    661647  } 
    662648 
    663   iGeom_moveEnt(geom,cyl_sm,rslot,0.0,-.25*t_neg-.5*rround,&result); 
     649  iGeom_moveEnt(geom, &cyl_sm,rslot,0.0,-.25*t_neg-.5*rround,&result); 
    664650 
    665651  if (iBase_SUCCESS != result) { 
     
    671657  // unite to get rounded_disk_side_neg 
    672658 
    673   std::vector<iBase_EntityHandle> tempa =  
    674     std::vector<iBase_EntityHandle>::create1d(4); 
    675  
    676   tempa.set(0, lower_brick); 
    677   tempa.set(1, upper_brick); 
    678   tempa.set(2, cyl_sm); 
    679   tempa.set(3, cyl_lrg); 
    680  
     659  iBase_EntityHandle tempa[4] = {lower_brick, upper_brick, cyl_sm, cyl_lrg}; 
    681660  rounded_disk_side_neg = NULL; 
    682661 
    683   iGeom_uniteEnts( geom, &tempa, 4, &rounded_disk_side_neg, &result); 
     662  iGeom_uniteEnts( geom, tempa, 4, &rounded_disk_side_neg, &result); 
    684663 
    685664  if (iBase_SUCCESS != result) { 
     
    688667  } 
    689668 
    690   iGeom_moveEnt( geom, rounded_disk_side_neg, 0.0, dmove_neg,  
     669  iGeom_moveEnt( geom, &rounded_disk_side_neg, 0.0, dmove_neg,  
    691670                 -.5*(cell_height-t_neg), &result);  
    692671 
     
    721700  double ang01_neg = asin(sinang00_neg)*RADTODEG; 
    722701   
    723   iGeom_rotateEnt( geom, rounded_disk_side_pos,  
     702  iGeom_rotateEnt( geom, &rounded_disk_side_pos,  
    724703                   ang01_pos, 0.0, 0.0, 1.0 , &result); 
    725704 
     
    730709 
    731710 
    732   iGeom_rotateEnt( geom, rounded_disk_side_neg,  
     711  iGeom_rotateEnt( geom, &rounded_disk_side_neg,  
    733712                   ang01_neg, 0.0, 0.0, 1.0, &result);  
    734713 
     
    739718 
    740719 
    741   iGeom_rotateEnt( geom, rounded_disk_top, ang01_pos,  
    742                      0.0, 0.0, 1.0, &result); 
     720  iGeom_rotateEnt( geom, &rounded_disk_top, ang01_pos,  
     721                   0.0, 0.0, 1.0, &result); 
    743722 
    744723  if (iBase_SUCCESS != result) { 
     
    748727 
    749728 
    750   std::vector<iBase_EntityHandle> tempa =  
    751       std::vector<iBase_EntityHandle>::create1d(3); 
    752  
    753   tempa.set(0, rounded_disk_side_pos); 
    754   tempa.set(1, rounded_disk_side_neg); 
    755   tempa.set(2, rounded_disk_top); 
    756  
    757  
     729  iBase_EntityHandle tempa[] = {rounded_disk_side_pos, rounded_disk_side_neg, 
     730                                rounded_disk_top}; 
     731   
    758732  temp1 = NULL; 
    759   iGeom_uniteEnts( geom, &tempa, 3, &temp1, &result); 
     733  iGeom_uniteEnts( geom, tempa, 3, &temp1, &result); 
    760734 
    761735  if (iBase_SUCCESS != result) { 
     
    766740 
    767741  temp2 = NULL; 
    768   void iGeom_sectionEnt( geom, temp1, 1.0, 0.0, 0.0,  
    769                          0.0, true, &temp2, &result);  
     742  iGeom_sectionEnt( geom, &temp1, 1.0, 0.0, 0.0,  
     743                    0.0, true, &temp2, &result);  
    770744 
    771745  if (iBase_SUCCESS != result) { 
     
    776750 
    777751  temp3 = NULL; 
    778   iGeom_copyEnt( geom, temp2, temp3, &result); 
     752  iGeom_copyEnt( geom, temp2, &temp3, &result); 
    779753 
    780754  if (iBase_SUCCESS != result) { 
     
    784758 
    785759 
    786   iGeom_reflectEnt( geom, temp3, 1.0, 0.0, 0.0, &result); 
     760  iGeom_reflectEnt( geom, &temp3, 1.0, 0.0, 0.0, &result); 
    787761 
    788762  if (iBase_SUCCESS != result) { 
     
    792766 
    793767 
    794   std::vector<iBase_EntityHandle> tempb =  
    795       std::vector<iBase_EntityHandle>::create1d(2); 
    796  
    797   tempb.set(0, temp2); 
    798   tempb.set(1, temp3); 
     768  iBase_EntityHandle tempb[] = {temp2, temp3}; 
    799769 
    800770  temp4 = NULL; 
    801   iGeom_uniteEnts( geom, &tempb, 2, &temp4, &result); 
     771  iGeom_uniteEnts(geom, tempb, 2, &temp4, &result); 
    802772 
    803773  if (iBase_SUCCESS != result) { 
     
    825795 
    826796 
    827   iGeom_rotateEnt( geom, temp1, taa, 1.0, 0.0, 0.0, &result); 
     797  iGeom_rotateEnt( geom, &temp1, taa, 1.0, 0.0, 0.0, &result); 
    828798  
    829799  if (iBase_SUCCESS != result) { 
     
    833803 
    834804 
    835   iGeom_moveEnt( geom, temp1, 0.0, dymanif_ave, 0.0, &result); 
    836  
    837   if (iBase_SUCCESS != result) { 
    838        std::cerr << "Failed Move." << std::endl; 
    839        return false; 
    840   } 
    841  
    842  
    843   std::vector<iBase_EntityHandle> tempc =  
    844       std::vector<iBase_EntityHandle>::create1d(2); 
    845  
    846   tempc.set(0, temp4); 
    847   tempc.set(1, temp1); 
     805  iGeom_moveEnt( geom, &temp1, 0.0, dymanif_ave, 0.0, &result); 
     806 
     807  if (iBase_SUCCESS != result) { 
     808       std::cerr << "Failed Move." << std::endl; 
     809       return false; 
     810  } 
     811 
     812 
     813  iBase_EntityHandle tempc[] = {temp4, temp1}; 
    848814  temp2 = NULL; 
    849815 
    850816 
    851   iGeom_uniteEnts( geom, &tempc, 2, &temp2, &result); 
     817  iGeom_uniteEnts( geom, tempc, 2, &temp2, &result); 
    852818 
    853819  if (iBase_SUCCESS != result) { 
     
    858824 
    859825  temp3 = NULL; 
    860   iGeom_sectionEnt( geom, temp2, 0.0, 0.0, 1.0, 
     826  iGeom_sectionEnt( geom, &temp2, 0.0, 0.0, 1.0, 
    861827                   .5*cell_height, true, &temp3, &result);  
    862828 
     
    868834 
    869835  rounded_slot_manif = NULL; 
    870   iGeom_sectionEnt( geom, temp3, 0.0, 0.0, 1.0, -.5*cell_height,  
     836  iGeom_sectionEnt( geom, &temp3, 0.0, 0.0, 1.0, -.5*cell_height,  
    871837                    false, &rounded_slot_manif, &result);  
    872838 
     
    917883 
    918884 
    919      iGeom_moveEnt( geom, temp2, 0.0, 0.0,  
     885     iGeom_moveEnt( geom, &temp2, 0.0, 0.0,  
    920886                    .25*cell_height+.125*tdiff, &result); 
    921887 
     
    936902 
    937903 
    938      iGeom_moveEnt( geom, temp3, 0.0, 0.0,  
     904     iGeom_moveEnt( geom, &temp3, 0.0, 0.0,  
    939905                    -.25*cell_height+.125*tdiff, &result);  
    940906 
     
    945911 
    946912 
    947     std::vector<iBase_EntityHandle> tempa =  
    948       std::vector<iBase_EntityHandle>::create1d(3); 
    949  
    950     tempa.set(0, temp1); 
    951     tempa.set(1, temp2); 
    952     tempa.set(2, temp3); 
     913     iBase_EntityHandle tempa2[] = {temp1, temp2, temp3}; 
    953914    cyls = NULL; 
    954915 
    955916 
    956     iGeom_uniteEnts( geom, &tempa, 3, &cyls, &result); 
     917    iGeom_uniteEnts( geom, tempa2, 3, &cyls, &result); 
    957918 
    958919    if (iBase_SUCCESS != result) { 
     
    973934 
    974935 
    975     iGeom_rotateEnt( geom, temp1, 90.0, 1.0, 0.0, 0.0, &result); 
     936    iGeom_rotateEnt( geom, &temp1, 90.0, 1.0, 0.0, 0.0, &result); 
    976937  
    977938    if (iBase_SUCCESS != result) { 
     
    981942 
    982943 
    983      iGeom_moveEnt( geom, temp1, -(a_pos+anose_pos),  
     944     iGeom_moveEnt( geom, &temp1, -(a_pos+anose_pos),  
    984945                    0.5, .5*cell_height+.25*tdiff, &result);  
    985946 
     
    991952     
    992953      // find surface of previous volume with max y coord 
    993     std::vector<double> minc, maxc; 
    994     int num_adj_surfs, num_minc, num_maxc; 
    995  
    996954    iBase_EntityHandle *adj_surfs = NULL; 
    997     int adj_surfs_alloc = 0; 
    998     iGeom_getEntAdj(geom, temp1, ::iBase_FACE, adj_surfs, 
    999                     &adj_surfs_alloc, &adj_surfs_size, &result); 
    1000  
    1001  
    1002     ::iBase::StorageOrder order = ::iBase::StorageOrder_INTERLEAVED; 
    1003  
    1004  
    1005     iGeom_getArrBoundBox(geom, &adj_surfs, num_adj_surfs, &order,  
    1006                          &minc, &num_minc, &maxc, &num_maxc, &result); 
     955    int adj_surfs_alloc = 0, adj_surfs_size; 
     956    iGeom_getEntAdj(geom, temp1, iBase_FACE,  
     957                    &adj_surfs, &adj_surfs_alloc, &adj_surfs_size,  
     958                    &result); 
     959 
     960    int order = iBase_INTERLEAVED; 
     961    int mc_size = 3*adj_surfs_size; 
     962    std::vector<double> minc(mc_size), maxc(mc_size); 
     963    double *minc_ptr = &minc[0], *maxc_ptr = &maxc[0]; 
     964    iGeom_getArrBoundBox(geom, adj_surfs, adj_surfs_size, &order,  
     965                         &minc_ptr, &mc_size, &mc_size, 
     966                         &maxc_ptr, &mc_size, &mc_size, &result); 
    1007967 
    1008968 
     
    1014974 
    1015975    iBase_EntityHandle this_surf = 0; 
    1016     for (int i = 0; i < num_adj_surfs; i++) { 
    1017       if (minc.get(3*i+1) >= -1.0e-6 && maxc.get(3*i+1) <= 1.0e-6) { 
    1018         this_surf = adj_surfs.get(i); 
     976    for (int i = 0; i < adj_surfs_size; i++) { 
     977      if (minc[3*i+1] >= -1.0e-6 && maxc[3*i+1] <= 1.0e-6) { 
     978        this_surf = adj_surfs[i]; 
    1019979        break; 
    1020980      } 
     
    1022982 
    1023983    if (0 == this_surf) { 
    1024       iBase::Error err = iBase::Error::_create(); 
    1025       err.set(iBase::ErrorType_FAILURE, "Didn't create surface for rotate."); 
    1026       err.setNote("Didn't create surface for rotate."); 
    1027       throw err; 
     984      int ierr = iBase_FAILURE; 
     985      CE("Didn't create surface for rotate."); 
    1028986    } 
    1029987 
    1030988     
    1031989    temp2 = NULL; 
    1032     iGeom_copyEnt( geom, this_surf, temp2, &result); 
     990    iGeom_copyEnt( geom, this_surf, &temp2, &result); 
    1033991 
    1034992    if (iBase_SUCCESS != result) { 
     
    10591017 
    10601018 
    1061     iGeom_rotateEnt( geom, temp1, 90.0, 1.0, 0.0, 0.0, &result); 
     1019    iGeom_rotateEnt( geom, &temp1, 90.0, 1.0, 0.0, 0.0, &result); 
    10621020 
    10631021    if (iBase_SUCCESS != result) { 
     
    10671025 
    10681026 
    1069      iGeom_moveEnt( geom, temp1, -(a_neg+anose_neg),  
     1027     iGeom_moveEnt( geom, &temp1, -(a_neg+anose_neg),  
    10701028                    0.5, -.5*cell_height+.25*tdiff, &result); 
    10711029  
     
    10771035     
    10781036      // find surface of previous volume with max y coord 
    1079     std::vector<iBase_EntityHandle> adj_surfs; 
    1080     std::vector<double> minc, maxc; 
    1081     int num_adj_surfs, num_minc, num_maxc; 
    1082  
    1083     iBase_EntityHandle *adj_surfs = NULL; 
    1084     int adj_surfs_alloc = 0; 
    1085     iGeom_getEntAdj(geom, temp1, ::iBase_FACE, adj_surfs, 
     1037    adj_surfs = NULL; 
     1038    adj_surfs_alloc = 0; 
     1039    iGeom_getEntAdj(geom, temp1, ::iBase_FACE, &adj_surfs, 
    10861040                    &adj_surfs_alloc, &adj_surfs_size, &result); 
    10871041 
    1088  
    1089     ::iBase::StorageOrder order = ::iBase::StorageOrder_INTERLEAVED; 
    1090  
    1091  
    1092     iGeom_getArrBoundBox(geom, &adj_surfs, num_adj_surfs, &order,  
    1093                          &minc, &num_minc, &maxc, &num_maxc, &result); 
     1042    mc_size = 3*adj_surfs_size; 
     1043    minc.resize(mc_size); maxc.resize(mc_size); 
     1044    minc_ptr = &minc[0]; maxc_ptr = &maxc[0]; 
     1045    iGeom_getArrBoundBox(geom, adj_surfs, adj_surfs_size, &order,  
     1046                         &minc_ptr, &mc_size, &mc_size,  
     1047                         &maxc_ptr, &mc_size, &mc_size, &result); 
    10941048 
    10951049 
     
    11011055 
    11021056 
    1103     iBase_EntityHandle this_surf = 0; 
    1104     for (int i = 0; i < num_adj_surfs; i++) { 
    1105       if (minc.get(3*i+1) >= -1.0e-6 && maxc.get(3*i+1) <= 1.0e-6) { 
    1106         this_surf = adj_surfs.get(i); 
     1057    this_surf = 0; 
     1058    for (int i = 0; i < adj_surfs_size; i++) { 
     1059      if (minc[3*i+1] >= -1.0e-6 && maxc[3*i+1] <= 1.0e-6) { 
     1060        this_surf = adj_surfs[i]; 
    11071061        break; 
    11081062      } 
     
    11111065 
    11121066    if (0 == this_surf) { 
    1113       iBase::Error err = iBase::Error::_create(); 
    1114       err.set(iBase::ErrorType_FAILURE, "Didn't create surface for rotate."); 
    1115       err.setNote("Didn't create surface for rotate."); 
    1116       throw err; 
     1067      int ierr = iBase_FAILURE; 
     1068      CE("Didn't create surface for rotate."); 
    11171069    } 
    11181070 
    11191071     
    11201072    temp2 = NULL; 
    1121     iGeom_copyEnt( geom, this_surf, temp2, &result); 
     1073    iGeom_copyEnt( geom, this_surf, &temp2, &result); 
    11221074     
    11231075    if (iBase_SUCCESS != result) { 
     
    11421094 
    11431095    temp1 = NULL; 
    1144     iGeom_subtract(geom, cyls, ell_pos, &temp1, &result); 
     1096    iGeom_subtractEnts(geom, cyls, ell_pos, &temp1, &result); 
    11451097 
    11461098    if (iBase_SUCCESS != result) { 
     
    11521104 
    11531105    temp2 = NULL; 
    1154     iGeom_subtract(geom, temp1, ell_neg, &temp2, &result); 
     1106    iGeom_subtractEnts(geom, temp1, ell_neg, &temp2, &result); 
    11551107 
    11561108    if (iBase_SUCCESS != result) { 
     
    11611113 
    11621114 
    1163      iGeom_moveEnt( geom, temp2, 0.0, 0.0, -.25*tdiff, &result); 
     1115     iGeom_moveEnt( geom, &temp2, 0.0, 0.0, -.25*tdiff, &result); 
    11641116 
    11651117     if (iBase_SUCCESS != result) { 
     
    11721124 
    11731125    temp3 = NULL; 
    1174     iGeom_copyEnt( geom, rounded_slot_manif, temp3, &result); 
     1126    iGeom_copyEnt( geom, rounded_slot_manif, &temp3, &result); 
    11751127     
    11761128    if (iBase_SUCCESS != result) { 
     
    11801132 
    11811133 
    1182     iGeom_rotateEnt( geom, temp3, 90.0, 0.0, 0.0, 1.0, &result); 
     1134    iGeom_rotateEnt( geom, &temp3, 90.0, 0.0, 0.0, 1.0, &result); 
    11831135 
    11841136    if (iBase_SUCCESS != result) { 
     
    11881140 
    11891141 
    1190     std::vector<iBase_EntityHandle> tempa =  
    1191       std::vector<iBase_EntityHandle>::create1d(3); 
    1192  
    1193     tempa.set(0, temp2); 
    1194     tempa.set(1, rounded_slot_manif); 
    1195     tempa.set(2, temp3); 
     1142    iBase_EntityHandle tempa[] = {temp2, rounded_slot_manif, temp3}; 
    11961143    temp4 = NULL; 
    11971144 
    11981145 
    1199     iGeom_uniteEnts( geom, &tempa, 3, &temp4, &result); 
     1146    iGeom_uniteEnts( geom, tempa, 3, &temp4, &result); 
    12001147 
    12011148    if (iBase_SUCCESS != result) { 
     
    12061153 
    12071154    temp1 = NULL; 
    1208     void iGeom_sectionEnt( geom, temp4, 0.0, 1.0, 0.0,  
    1209                            0.0, false, &temp1, &result); 
     1155    iGeom_sectionEnt( geom, &temp4, 0.0, 1.0, 0.0,  
     1156                      0.0, false, &temp1, &result); 
    12101157 
    12111158    if (iBase_SUCCESS != result) { 
     
    12161163 
    12171164    dds_cell = NULL; 
    1218     void iGeom_sectionEnt( geom, temp1, 1.0, 0.0,  
    1219                            0.0, 0.0, true, &dds_cell, &result);  
     1165    iGeom_sectionEnt( geom, &temp1, 1.0, 0.0,  
     1166                      0.0, 0.0, true, &dds_cell, &result);  
    12201167 
    12211168    if (iBase_SUCCESS != result) { 
     
    12331180bool cleanup_other_geom(iGeom_Instance &geom, 
    12341181                        iBase_EntityHandle &dds_cell, 
    1235                         std::vector<iBase_EntityHandle> &initial_gents, 
     1182                        iBase_EntityHandle *initial_gents, 
    12361183                        int initial_gents_size)  
    12371184{ 
    12381185    // get all the 3-dimensional entities, and all 3d entities adj to dds_cell 
    1239   std::vector<iBase_EntityHandle> adj_gents, deletable_gents; 
    1240   int all_gents_size, adj_gents_size, deletable_gents_size; 
     1186  std::vector<iBase_EntityHandle> deletable_gents; 
     1187  int deletable_gents_size; 
    12411188 
    12421189 
     
    12501197 
    12511198  if (iBase_SUCCESS != result) { 
    1252       std::cerr << "Trouble getting gentities of dimension" << dim << std::endl; 
    1253       return false; 
    1254   } 
    1255  
    1256  
     1199      std::cerr << "Trouble getting gentities of dimension" << iBase_REGION  
     1200                << std::endl; 
     1201      return false; 
     1202  } 
    12571203 
    12581204  iBase_EntityHandle *adj_gents = NULL; 
    12591205  int adj_gents_size, adj_gents_alloc; 
    12601206  // get all entities of this dimension 
    1261   iGeom_getEntities(geom, dds_cell, iBase_REGION, &adj_gents, 
     1207  iGeom_getEntAdj(geom, dds_cell, iBase_REGION, &adj_gents, 
    12621208                    &adj_gents_alloc, 
    12631209                    &adj_gents_size, &result); 
    12641210 
    12651211   if (iBase_SUCCESS != result) { 
    1266        std::cerr << "Trouble getting gentities of dimension" << dim << std::endl; 
    1267        return false; 
    1268    } 
    1269  
    1270  
    1271   deletable_gents = deletable_gents.create1d(all_gents_size-1); 
    1272   deletable_gents_size = 0; 
    1273    
     1212       std::cerr << "Trouble getting gentities of dimension" << iBase_REGION  
     1213                 << std::endl; 
     1214       return false; 
     1215   } 
     1216 
     1217 
    12741218  for (int i = 0; i < all_gents_size; i++) { 
    1275  
    1276        if (all_gents.get(i) == adj_gents.get(0)) { 
    1277            continue; 
    1278        } 
     1219    if (all_gents[i] == adj_gents[0]) continue; 
    12791220 
    12801221       bool insert_this = true; 
    12811222       for (int j = 0; j < initial_gents_size; j++) { 
    12821223 
    1283             if (all_gents.get(i) == initial_gents.get(j)) { 
     1224            if (all_gents[i] == initial_gents[j]) { 
    12841225                insert_this = false; 
    12851226                break; 
     
    12871228       } 
    12881229 
    1289        if (insert_this) { 
    1290            deletable_gents.set(deletable_gents_size++, all_gents.get(i)); 
    1291        } 
     1230       if (insert_this)  
     1231           deletable_gents.push_back(all_gents[i]); 
    12921232  } 
    12931233   
    12941234     
    1295   for (int i = 0; i < deletable_gents_size; i++) { 
    1296  
    1297        iGeom_deleteEnt( geom, deletable_gents.get(i), &result); 
     1235  for (std::vector<iBase_EntityHandle>::iterator vit = 
     1236           deletable_gents.begin(); vit != deletable_gents.end(); vit++) { 
     1237       iGeom_deleteEnt( geom, *vit, &result); 
    12981238 
    12991239       if (iBase_SUCCESS != result) { 
     
    13051245  return true; 
    13061246} 
    1307  
    1308      
    1309      
  • ddriv/trunk/MkEllCyl.cpp

    r2696 r2754  
    1919#include <iostream> 
    2020#include "iGeom.h" 
    21 #include "iBase_SNL_SIDL_defs.h" 
    2221#include "ellcylParamInfls.hpp" 
    23  
    24  
    25 /* ================= Typedef,Global section =============== */ 
    26  
    27 typedef void* iBase_EntityHandle; 
    28  
     22#include <cstring> 
    2923 
    3024 
     
    3832     
    3933  iBase_EntityHandle cyl_tmp, cyl; 
    40  
    41   iGeom_createCylinder( geom, params[0], params[1], 
     34  int result; 
     35  iGeom_createCylinder(geom_iface, params[0], params[1], 
    4236                        params[2], &cyl_tmp, &result); 
    4337  
     
    4842 
    4943 
    50   iGeom_sectionEnt( geom, cyl_tmp, 1.0, 0.0, 0.0, 0.0, false,  
     44  iGeom_sectionEnt( geom_iface, &cyl_tmp, 1.0, 0.0, 0.0, 0.0, false,  
    5145                    &cyl, &result); 
    5246 
  • ddriv/trunk/MkILCCell.cpp

    r2696 r2754  
    1717 
    1818#include "iGeom.h" 
    19 #include "iBase_SNL_SIDL_defs.h" 
    2019#include "ILCParamInfls.hpp" 
    2120#include <iostream> 
     21#include <vector> 
     22#include <cstring> 
     23#include "math.h" 
    2224#include "ilcdefines.h" 
    2325 
     26#define CE(a) if (iBase_SUCCESS != result) {      \ 
     27      std::cerr << a << std::endl; return false;} 
     28 
     29 
     30#define HDECL(a) iBase_EntityHandle *a = NULL; \ 
     31    int a ## _alloc = 0, a ## _size; 
     32     
    2433/* ================= TypeDef/Global Section ================== */ 
    2534int result; 
    2635 
    27 typedef void* iBase_EntityHandle; 
    28  
    2936extern void  
    30    GetTangPoint(const double& xic, const double& yic, const double& ai, 
    31                 const double& bi,const double xtc, const double& ytc,  
    32                 const double& at, const double& bt, double& xi,  
    33                 double& yi, double& xt, double& yt); 
     37GetTangPoint(const double& xic, const double& yic, const double& ai, 
     38             const double& bi,const double xtc, const double& ytc,  
     39             const double& at, const double& bt, double& xi,  
     40             double& yi, double& xt, double& yt); 
    3441 
    3542const bool debug = false; 
     
    3744 
    3845double fixed_params[] = { 
    39   7.59, 
    40   10.0, 
    41   50.0, 
    42   34.4, 
    43   50.0, 
    44   7.6, 
    45   10.0, 
    46   98.89, 
    47   41.0, 
    48   30.0, 
    49   115.4, 
    50   57.7, 
    51   347, 
    52   71.6, 
    53   150.0, 
    54   4.0, 
    55   4.0, 
    56   4.0, 
    57   4.0, 
    58   30.0 
     46    7.59, 
     47    10.0, 
     48    50.0, 
     49    34.4, 
     50    50.0, 
     51    7.6, 
     52    10.0, 
     53    98.89, 
     54    41.0, 
     55    30.0, 
     56    115.4, 
     57    57.7, 
     58    347, 
     59    71.6, 
     60    150.0, 
     61    4.0, 
     62    4.0, 
     63    4.0, 
     64    4.0, 
     65    30.0 
    5966}; 
    6067 
     
    6269#define ABS(a) (a > 0 ? a : -a) 
    6370 
    64 EntityHandle  
    65   construct_end_cell(iGeom_Instance &geom_mod, 
    66                      const double local_a1, const double local_a2,  
    67                      const double local_b1,  
    68                      const double local_al, const double local_bl,  
    69                      const double local_ar, const double local_br,  
    70                      const double local_ra1, const double local_ra2,  
    71                      const double local_zcr, const double local_zcl,  
    72                      const double local_b, 
    73                      const double local_zcb, const double local_zcll,  
    74                      const double local_zcc,  
    75                      const double local_all, const double local_bll,  
    76                      const double local_a1l, const double local_b1l,  
    77                      const double local_ra0,  
    78                      const bool reflect_it, 
    79                      const double x_offset); 
    80  
    81 EntityHandle 
    82   construct_half_cell(iGeom_Instance &geom_mod, 
    83                       const double local_a1, const double local_b1,  
    84                       const double local_al, const double local_bl,  
    85                       const double local_ra1, const double local_zcl,  
    86                       const double local_b, 
    87                       const bool reflect_it); 
    88  
    89  
    90 EntityHandle get_surface(iGeom_Instance &geom_mod, 
    91                           iBase_EntityHandle from_gent, 
    92                           const double xyz_location, 
    93                           const int xyorz, 
    94                           const double tol); 
     71iBase_EntityHandle  
     72construct_end_cell(iGeom_Instance &geom_mod, 
     73                   const double local_a1, const double local_a2,  
     74                   const double local_b1,  
     75                   const double local_al, const double local_bl,  
     76                   const double local_ar, const double local_br,  
     77                   const double local_ra1, const double local_ra2,  
     78                   const double local_zcr, const double local_zcl,  
     79                   const double local_b, 
     80                   const double local_zcb, const double local_zcll,  
     81                   const double local_zcc,  
     82                   const double local_all, const double local_bll,  
     83                   const double local_a1l, const double local_b1l,  
     84                   const double local_ra0,  
     85                   const bool reflect_it, 
     86                   const double x_offset); 
     87 
     88iBase_EntityHandle 
     89construct_half_cell(iGeom_Instance &geom_mod, 
     90                    const double local_a1, const double local_b1,  
     91                    const double local_al, const double local_bl,  
     92                    const double local_ra1, const double local_zcl,  
     93                    const double local_b, 
     94                    const bool reflect_it); 
     95 
     96 
     97iBase_EntityHandle get_surface(iGeom_Instance &geom_mod, 
     98                               iBase_EntityHandle from_gent, 
     99                               const double xyz_location, 
     100                               const int xyorz, 
     101                               const double tol); 
    95102 
    96103const double RAD_TO_DEG = 180.0 / acos(-1.0); 
     
    108115{ 
    109116 
    110     if (NULL == params || 0 == num_params) { 
    111         params = fixed_params; 
    112     } 
    113  
    114     double local_params[20]; 
    115     for (int i = 0; i < 20; i++) { 
    116          local_params[i] = 1000.0*params[i]; 
    117     } 
     117  if (NULL == params || 0 == num_params) { 
     118    params = fixed_params; 
     119  } 
     120 
     121  double local_params[20]; 
     122  for (int i = 0; i < 20; i++) { 
     123    local_params[i] = 1000.0*params[i]; 
     124  } 
    118125   
    119126    // read in center seven cells 
    120     if (debug) { 
    121         std::cout << "Reading in mid_7cells.sat." << std::endl;   
    122     } 
    123  
    124     std::vector<std::string> options; 
    125     std::string tmp_string = "mid_7cells.sat"; 
    126  
    127     iGeom_load(geom_iface, tmp_string, options, &result, tmp_string.length(), 0); 
    128  
    129     if (iBase_SUCCESS != result) { 
    130       std::cerr << "Failed Load." << std::endl; 
    131       return false; 
    132     } 
     127  if (debug) { 
     128    std::cout << "Reading in mid_7cells.sat." << std::endl;   
     129  } 
     130 
     131  iGeom_load(geom_iface, "mid_7cells.sat", NULL, &result,  
     132             strlen("mid_7cells.sat"), 0); 
     133 
     134  if (iBase_SUCCESS != result) { 
     135    std::cerr << "Failed Load." << std::endl; 
     136    return false; 
     137  } 
    133138 
    134139 
    135140    // get the unchanged bodies in an array before we create the changing ones 
    136     iBase_EntityHandle *all_bods = NULL; 
    137     int all_bods_size=0, all_bods_alloc; 
     141  iBase_EntityHandle all_bods[11], *all_bods_ptr = &all_bods[0]; 
     142  int all_bods_alloc = 11, all_bods_size; 
    138143    // get all entities of this dimension 
    139     iGeom_getEntities(geom_iface, 0, iBase_REGION, &all_bods, 
    140                       &all_bods_alloc, &all_bods_size, &result); 
    141  
    142     if (iBase_SUCCESS != result) { 
    143         std::cerr << "Trouble getting gentities of dimension"  
    144                   << dim << std::endl; 
    145         return false; 
    146     } 
    147  
    148     if (7 != all_bods_size) {  
    149         throw iBase::Error(); 
    150     } 
    151  
    152  
    153 /* ====================== PLM => Unknown Catch Condition =================== */ 
    154   } 
    155   catch (iBase::Error err) { 
    156     std::cerr << "Failed to get right number of bodies after reading unchanged ones."  
    157               << std::endl; 
    158     return false; 
    159   } 
    160    
     144  iGeom_getEntities(geom_iface, 0, iBase_REGION,  
     145                    &all_bods_ptr, &all_bods_alloc, &all_bods_size, &result); 
     146 
     147  if (iBase_SUCCESS != result) { 
     148    std::cerr << "Trouble getting gentities of dimension"  
     149              << iBase_REGION << std::endl; 
     150    return false; 
     151  } 
     152 
     153  if (7 != all_bods_size) {  
     154    std::cerr << "wrong number of bodies produced." << std::endl; 
     155    return false; 
     156  } 
     157 
    161158/* ========================================================================= */ 
    162159 
    163160 
    164161 
    165   // construct left end cell 
    166   if (debug) { 
    167       std::cout << "Constructing left end cell." << std::endl; 
     162    // construct left end cell 
     163  if (debug) { 
     164    std::cout << "Constructing left end cell." << std::endl; 
    168165  } 
    169166 
     
    172169 
    173170  iBase_EntityHandle left_end_cell =  
    174     construct_end_cell(geom_iface, 
    175                        a1, a2, b1, al, bl, ar, br, ra1, ra2, 
    176                        zcr, zcl, b, zcb, zcll, zcc, all, bll, a1l, b1l, ra0, 
    177                        false, left_offset); 
     171      construct_end_cell(geom_iface, 
     172                         a1, a2, b1, al, bl, ar, br, ra1, ra2, 
     173                         zcr, zcl, b, zcb, zcll, zcc, all, bll, a1l, b1l, ra0, 
     174                         false, left_offset); 
    178175 
    179176  if (0 == left_end_cell) { 
     
    182179  } 
    183180 
    184   all_bods.set(9, left_end_cell); 
     181  all_bods[9] = left_end_cell; 
    185182  all_bods_size++; 
    186183 
    187   std::vector<std::string> options; 
    188   int result; 
    189   std::string str = std::string("ilc_leftbod.sat");  
    190  
    191   iGeom_save( geom_iface, str, options, &result, str.length(), 0); 
    192  
    193   if (iBase_SUCCESS != result) { 
    194       std::cerr << "ERROR : can not save a geometry to " << std::endl; 
    195       return false; 
    196   } 
    197  
    198    
    199   // construct right end cell 
    200   if (debug) { 
    201       std::cout << "Constructing right end cell." << std::endl; 
     184  iGeom_save( geom_iface, "ilc_leftbod.sat", "", &result,  
     185              strlen("ilc_leftbod.sat"), 0); 
     186 
     187  if (iBase_SUCCESS != result) { 
     188    std::cerr << "ERROR : can not save a geometry to " << std::endl; 
     189    return false; 
     190  } 
     191 
     192   
     193    // construct right end cell 
     194  if (debug) { 
     195    std::cout << "Constructing right end cell." << std::endl; 
    202196  } 
    203197 
     
    205199  end_suffix = "right"; 
    206200  iBase_EntityHandle right_end_cell =  
    207     construct_end_cell(geom_iface, a1, a2, b1, al, bl, ar, br,  
    208                        ra1, ra2, 
    209                        zcr, zcl, b, zcb, zcll, zcc, all, bll, a1l, b1l, ra0, 
    210                        true, right_offset); 
     201      construct_end_cell(geom_iface, a1, a2, b1, al, bl, ar, br,  
     202                         ra1, ra2, 
     203                         zcr, zcl, b, zcb, zcll, zcc, all, bll, a1l, b1l, ra0, 
     204                         true, right_offset); 
    211205 
    212206  if (0 == right_end_cell) { 
     
    215209  } 
    216210 
    217   all_bods.set(10, right_end_cell); 
     211  all_bods[10] = right_end_cell; 
    218212  all_bods_size++; 
    219213 
    220214 
    221   int result; 
    222   std::string str1 = std::string("ilc_rightbod.sat");  
    223  
    224   iGeom_save(geom_iface, str1, options, &result, str1.length(), 0); 
    225  
    226   if (iBase_SUCCESS != result) { 
    227       std::cerr << "ERROR : can not save a geometry to " << std::endl; 
     215  std::string str1 = std::string();  
     216 
     217  iGeom_save(geom_iface, "ilc_rightbod.sat", NULL, &result,  
     218             strlen("ilc_rightbod.sat"), 0); 
     219 
     220  if (iBase_SUCCESS != result) { 
     221    std::cerr << "ERROR : can not save a geometry to " << std::endl; 
     222    return false; 
     223  } 
     224 
     225 
     226 
     227    // get all the bodies for imprint/merge 
     228  if (debug) { 
     229    std::cout << "Gathering bodies for imprint/merge." << std::endl; 
     230  } 
     231 
     232  HDECL(im_bods); 
     233  iBase_EntitySetHandle root_set; 
     234  iGeom_getRootSet(geom_iface, &root_set, &result); 
     235   
     236  iGeom_getEntities(geom_iface, root_set, iBase_REGION,  
     237                    &im_bods, &im_bods_alloc, &im_bods_size, &result); 
     238  CE("Failed to get regions in preparation for imprint."); 
     239 
     240    // now scale & change params 
     241 
     242  for (int i = 0; i < im_bods_size; i++) { 
     243 
     244    iBase_EntityHandle this_bod = im_bods[i]; 
     245 
     246    iGeom_scaleEnt( geom_iface, &this_bod, .001, .001, .001, &result); 
     247 
     248    if (iBase_SUCCESS != result) { 
     249 
     250      std::cerr << "Failed Scale." << std::endl; 
    228251      return false; 
    229   } 
    230  
    231  
    232  
    233   // get all the bodies for imprint/merge 
    234   if (debug) { 
    235       std::cout << "Gathering bodies for imprint/merge." << std::endl; 
    236   } 
    237  
    238   std::vector<iBase_EntityHandle> im_bods; 
    239   int im_bods_size = 0; 
    240  
    241 /* ================ PLM => Did not find porting for getEntitites ====== */ 
    242  
    243   try { 
    244        geom_topo.getEntities(0, iBase_REGION, im_bods, im_bods_size);