lasso
AssocPair.cpp
Go to the documentation of this file.
00001 #include "AssocPair.hpp"
00002 
00003 #include <cstdlib>
00004 
00005 #include "Lasso.hpp"
00006 
00007 #ifdef ENABLE_IGEOM
00008 #include "GeomAssocPairSide.hpp"
00009 #endif
00010 #ifdef ENABLE_FBIGEOM
00011 #include "FBGeomAssocPairSide.hpp"
00012 #endif
00013 #ifdef ENABLE_IMESH
00014 #include "MeshAssocPairSide.hpp"
00015 #endif
00016 
00017 int AssocPair::currId = 0;
00018 
00019 AssocPair::AssocPair(iRel_Instance instance,
00020                      iBase_Instance iface0,
00021                      iRel_RelationType ent_or_set0,
00022                      iRel_IfaceType type0,
00023                      iRel_RelationStatus status0,
00024                      iBase_Instance iface1,
00025                      iRel_RelationType ent_or_set1,
00026                      iRel_IfaceType type1,
00027                      iRel_RelationStatus status1)
00028   : instance(instance)
00029 {
00030   pairId = currId++;
00031 
00032   iBase_Instance ifaces[] = {iface0, iface1};
00033   iRel_IfaceType types[] = {type0, type1};
00034   for (int i = 0; i < 2; i++) {
00035     switch (types[i]) {
00036 #ifdef ENABLE_IGEOM
00037     case iRel_IGEOM_IFACE:
00038       relSides[i] = new GeomAssocPairSide(instance, ifaces[i], pairId);
00039       break;
00040 #endif
00041 #ifdef ENABLE_FBIGEOM
00042     case iRel_FBIGEOM_IFACE:
00043       relSides[i] = new FBGeomAssocPairSide(instance, ifaces[i], pairId);
00044       break;
00045 #endif
00046 #ifdef ENABLE_IMESH
00047     case iRel_IMESH_IFACE:
00048       relSides[i] = new MeshAssocPairSide(instance, ifaces[i], pairId);
00049       break;
00050 #endif
00051     default:
00052       relSides[i] = NULL;
00053     }
00054   }
00055 
00056   entOrSet[0] = ent_or_set0;
00057   entOrSet[1] = ent_or_set1;
00058   relStatus[0] = status0;
00059   relStatus[1] = status1;
00060 }
00061 
00062 AssocPair::~AssocPair()
00063 {
00064   for (int i = 0; i < 2; i++)
00065     delete relSides[i];
00066 }
00067 
00068 int AssocPair::get_all_entities(int iface_no, int dimension,
00069                                 iBase_EntityHandle **entities,
00070                                 int *entities_alloc, int *entities_size)
00071 {
00072   return relSides[iface_no]->get_all_entities(dimension, entities,
00073                                               entities_alloc, entities_size);
00074 }
00075 
00076 int AssocPair::get_all_sets(int iface_no, iBase_EntitySetHandle **sets,
00077                             int *sets_alloc, int *sets_size)
00078 {
00079   return relSides[iface_no]->get_all_sets(sets, sets_alloc, sets_size);
00080 }
00081 
00082 int AssocPair::get_entities(int iface_no, int dimension,
00083                             iBase_EntitySetHandle set_handle,
00084                             iBase_EntityHandle **entities, int *entities_alloc,
00085                             int *entities_size)
00086 {
00087   return relSides[iface_no]->get_entities(dimension, set_handle, entities,
00088                                           entities_alloc, entities_size);
00089 }
00090 
00091 int AssocPair::get_ents_dims(int iface_no, iBase_EntityHandle *entities,
00092                              int entities_size, int **ent_types,
00093                              int *ent_types_alloc, int *ent_types_size)
00094 {
00095   return relSides[iface_no]->get_ents_dims(entities, entities_size, ent_types,
00096                                            ent_types_alloc, ent_types_size);
00097 }
00098 
00099 int AssocPair::set_relation(iBase_EntityHandle ent1, iBase_EntityHandle ent2)
00100 {
00101   if (entOrSet[0] == iRel_SET || entOrSet[1] == iRel_SET)
00102     ERRORR(iBase_FAILURE, "Invalid relation type");
00103 
00104   // check that if we're passing in an ent for a 'both'-type
00105   // assoc, there's already a set associated to the other ent
00106   iBase_EntityHandle tmp_ent;
00107   if (entOrSet[0] == iRel_BOTH &&
00108       relSides[1]->get_relation_side(&ent2, 1, &tmp_ent) != iBase_SUCCESS)
00109     ERRORR(iBase_FAILURE, "Couldn't find associated set on left side");
00110   if (entOrSet[1] == iRel_BOTH &&
00111       relSides[0]->get_relation_side(&ent1, 1, &tmp_ent) != iBase_SUCCESS)
00112     ERRORR(iBase_FAILURE, "Couldn't find associated set on right side");
00113 
00114   // set ent1 => ent2
00115   if (relStatus[0] == iRel_ACTIVE)
00116     CHK_ERRORR( relSides[0]->set_relation_side(&ent1, 1, &ent2) );
00117 
00118   // set ent1 <= ent2
00119   if (relStatus[1] == iRel_ACTIVE)
00120     CHK_ERRORR( relSides[1]->set_relation_side(&ent2, 1, &ent1) );
00121 
00122   RETURNR(iBase_SUCCESS);
00123 }
00124 
00125 int AssocPair::set_relation(iBase_EntityHandle ent1, iBase_EntitySetHandle set2)
00126 {
00127   if (entOrSet[0] == iRel_SET || entOrSet[1] == iRel_ENTITY)
00128     ERRORR(iBase_FAILURE, "Invalid relation type");
00129 
00130   // check that if we're passing in an ent for a 'both'-type
00131   // assoc, there's already a set associated to the other ent
00132   iBase_EntityHandle tmp_ent;
00133   if (entOrSet[0] == iRel_BOTH &&
00134       relSides[1]->get_relation_side(&set2, 1, &tmp_ent) != iBase_SUCCESS)
00135     ERRORR(iBase_FAILURE, "Couldn't find associated set on left side");
00136 
00137   // set ent1 => set2
00138   if (relStatus[0] == iRel_ACTIVE)
00139     CHK_ERRORR( relSides[0]->set_relation_side(&ent1, 1, &set2) );
00140 
00141   // set ent1 <= set2
00142   if (relStatus[1] == iRel_ACTIVE)
00143     CHK_ERRORR( relSides[1]->set_relation_side(&set2, 1, &ent1) );
00144 
00145   // if the right side is a 'both'-type association, set the contents of set2
00146   // to point to ent1 as well
00147   if (entOrSet[1] == iRel_BOTH)
00148     CHK_ERRORR( populate_recursive(1, set2, ent1) );
00149 
00150   RETURNR(iBase_SUCCESS);
00151 }
00152 
00153 int AssocPair::set_relation(iBase_EntitySetHandle set1, iBase_EntityHandle ent2)
00154 {
00155   if (entOrSet[0] == iRel_ENTITY || entOrSet[1] == iRel_SET)
00156     ERRORR(iBase_FAILURE, "Invalid relation type");
00157 
00158   // check that if we're passing in an ent for a 'both'-type
00159   // assoc, there's already a set associated to the other ent
00160   iBase_EntityHandle tmp_ent;
00161   if (entOrSet[1] == iRel_BOTH &&
00162       relSides[0]->get_relation_side(&set1, 1, &tmp_ent) != iBase_SUCCESS)
00163     ERRORR(iBase_FAILURE, "Couldn't find associated set on right side");
00164 
00165   // set set1 => ent2
00166   if (relStatus[0] == iRel_ACTIVE)
00167     CHK_ERRORR( relSides[0]->set_relation_side(&set1, 1, &ent2) );
00168 
00169   // set ent1 <= set2
00170   if (relStatus[1] == iRel_ACTIVE)
00171     CHK_ERRORR( relSides[1]->set_relation_side(&ent2, 1, &set1) );
00172 
00173   // if the left side is a 'both'-type association, set the contents of set1
00174   // to point to ent2 as well
00175   if (entOrSet[0] == iRel_BOTH)
00176     CHK_ERRORR( populate_recursive(0, set1, ent2) );
00177 
00178   RETURNR(iBase_SUCCESS);
00179 }
00180 
00181 int AssocPair::set_relation(iBase_EntitySetHandle set1,
00182                             iBase_EntitySetHandle set2)
00183 {
00184   if (entOrSet[0] == iRel_ENTITY || entOrSet[1] == iRel_ENTITY)
00185     ERRORR(iBase_FAILURE, "Invalid relation type");
00186 
00187   // set set1 => set2
00188   if (relStatus[0] == iRel_ACTIVE)
00189     CHK_ERRORR( relSides[0]->set_relation_side(&set1, 1, &set2) );
00190 
00191   // set set1 <= set2
00192   if (relStatus[1] == iRel_ACTIVE)
00193     CHK_ERRORR( relSides[1]->set_relation_side(&set2, 1, &set1) );
00194 
00195   // if either side is a 'both'-type association, set the contents of set1
00196   // to point to set2 as well (and/or vice-versa)
00197   if (entOrSet[0] == iRel_BOTH)
00198     CHK_ERRORR( populate_recursive(0, set1, set2) );
00199   if (entOrSet[1] == iRel_BOTH)
00200     CHK_ERRORR( populate_recursive(1, set2, set1) );
00201 
00202   RETURNR(iBase_SUCCESS);
00203 }
00204 
00205 int AssocPair::get_relation(int iface_no, iBase_EntityHandle *entities,
00206                             int num_entities, iBase_EntityHandle *tag_values)
00207 {
00208   if (relStatus[iface_no] == iRel_NOTEXIST)
00209     ERRORR(iBase_FAILURE, "Relation does not exist on this side");
00210   if (entOrSet[!iface_no] != iRel_ENTITY) // other iface is sets
00211     ERRORR(iBase_INVALID_ENTITY_HANDLE, "Expected EntitySet, got Entity");
00212 
00213   return relSides[iface_no]->get_relation_side(entities, num_entities,
00214                                                tag_values);
00215 }
00216 
00217 int AssocPair::get_relation(int iface_no, iBase_EntitySetHandle *sets,
00218                             int num_sets, iBase_EntityHandle *tag_values)
00219 {
00220   if (relStatus[iface_no] == iRel_NOTEXIST)
00221     ERRORR(iBase_FAILURE, "Relation does not exist on this side");
00222   if (entOrSet[!iface_no] != iRel_ENTITY) // other iface is sets
00223     ERRORR(iBase_INVALID_ENTITY_HANDLE, "Expected EntitySet, got Entity");
00224 
00225   return relSides[iface_no]->get_relation_side(sets, num_sets, tag_values);
00226 }
00227 
00228 int AssocPair::get_relation(int iface_no, iBase_EntityHandle *entities,
00229                             int num_entities, iBase_EntitySetHandle *tag_values)
00230 {
00231   if (relStatus[iface_no] == iRel_NOTEXIST)
00232     ERRORR(iBase_FAILURE, "Relation does not exist on this side");
00233   if (entOrSet[!iface_no] == iRel_ENTITY) // other iface is not sets
00234     ERRORR(iBase_INVALID_ENTITY_HANDLE, "Expected Entity, got EntitySet");
00235 
00236   return relSides[iface_no]->get_relation_side(entities, num_entities,
00237                                                tag_values);
00238 }
00239 
00240 int AssocPair::get_relation(int iface_no, iBase_EntitySetHandle *sets,
00241                             int num_sets, iBase_EntitySetHandle *tag_values)
00242 {
00243   if (relStatus[iface_no] == iRel_NOTEXIST)
00244     ERRORR(iBase_FAILURE, "Relation does not exist on this side");
00245   if (entOrSet[!iface_no] == iRel_ENTITY) // other iface is not sets
00246     ERRORR(iBase_INVALID_ENTITY_HANDLE, "Expected Entity, got EntitySet");
00247 
00248   return relSides[iface_no]->get_relation_side(sets, num_sets, tag_values);
00249 }
00250 
00251 int AssocPair::get_relation(int iface_no, iBase_EntityHandle *entities,
00252                             int num_entities, iBase_EntityIterator *tag_values)
00253 {
00254   std::vector<iBase_EntitySetHandle> sets(num_entities);
00255   CHK_ERRORR( get_relation(iface_no, entities, num_entities, &sets[0]) );
00256 
00257   for(int i=0; i<num_entities; i++)
00258     CHK_ERRORR( relSides[i]->get_iterator(sets[i], &tag_values[i]) );
00259 
00260   RETURNR(iBase_SUCCESS);
00261 }
00262 
00263 int AssocPair::get_relation(int iface_no, iBase_EntitySetHandle *sets,
00264                             int num_sets, iBase_EntityIterator *tag_values)
00265 {
00266   std::vector<iBase_EntitySetHandle> sets2(num_sets);
00267   CHK_ERRORR( get_relation(iface_no, sets, num_sets, &sets2[0]) );
00268 
00269   for(int i=0; i<num_sets; i++)
00270     CHK_ERRORR( relSides[iface_no]->get_iterator(sets2[i], &tag_values[i]) );
00271 
00272   RETURNR(iBase_SUCCESS);
00273 }
00274 
00275 int AssocPair::rmv_relation(int iface_no, iBase_EntityHandle *entities,
00276                             int num_entities)
00277 {
00278   if (relStatus[iface_no] == iRel_NOTEXIST)
00279     ERRORR(iBase_FAILURE, "Relation does not exist on this side");
00280 
00281   // TODO: handle "both" case
00282 
00283   // Remove the opposite side first
00284   if (relStatus[!iface_no] == iRel_ACTIVE) {
00285     if (entOrSet[!iface_no] == iRel_ENTITY) {
00286       std::vector<iBase_EntityHandle> other_entities(num_entities);
00287       CHK_ERRORR( get_relation(iface_no, entities, num_entities,
00288                                &other_entities[0]) );
00289       CHK_ERRORR( relSides[!iface_no]->rmv_relation_side(&other_entities[0],
00290                                                          num_entities) );
00291     }
00292     else {
00293       std::vector<iBase_EntitySetHandle> other_sets(num_entities);
00294       CHK_ERRORR( get_relation(iface_no, entities, num_entities,
00295                                &other_sets[0]) );
00296       CHK_ERRORR( relSides[!iface_no]->rmv_relation_side(&other_sets[0],
00297                                                          num_entities) );
00298     }
00299   }
00300 
00301   return relSides[iface_no]->rmv_relation_side(entities, num_entities);
00302 }
00303 
00304 int AssocPair::rmv_relation(int iface_no, iBase_EntitySetHandle *sets,
00305                             int num_sets)
00306 {
00307   if (relStatus[iface_no] == iRel_NOTEXIST)
00308     ERRORR(iBase_FAILURE, "Relation does not exist on this side");
00309 
00310   // TODO: handle "both" case
00311 
00312   // Remove the opposite side first
00313   if (relStatus[!iface_no] == iRel_ACTIVE) {
00314     if (entOrSet[!iface_no] == iRel_ENTITY) {
00315       std::vector<iBase_EntityHandle> other_entities(num_sets);
00316       CHK_ERRORR( get_relation(iface_no, sets, num_sets, &other_entities[0]) );
00317       CHK_ERRORR( relSides[!iface_no]->rmv_relation_side(&other_entities[0],
00318                                                          num_sets) );
00319     }
00320     else {
00321       std::vector<iBase_EntitySetHandle> other_sets(num_sets);
00322       CHK_ERRORR( get_relation(iface_no, sets, num_sets, &other_sets[0]) );
00323       CHK_ERRORR( relSides[!iface_no]->rmv_relation_side(&other_sets[0],
00324                                                          num_sets) );
00325     }
00326   }
00327 
00328   return relSides[iface_no]->rmv_relation_side(sets, num_sets);
00329 }
00330 
00331 int AssocPair::get_gids(int iface_no, iBase_EntityHandle *entities,
00332                         int num_entities, int *tag_values)
00333 {
00334   return relSides[iface_no]->get_gids(entities, num_entities, tag_values);
00335 }
00336 
00337 int AssocPair::get_gids(int iface_no, iBase_EntitySetHandle *sets,
00338                         int num_sets, int *tag_values)
00339 {
00340   return relSides[iface_no]->get_gids(sets, num_sets, tag_values);
00341 }
00342 
00343 int AssocPair::get_dims(int iface_no, iBase_EntityHandle *entities,
00344                         int num_entities, int *tag_values)
00345 {
00346   return relSides[iface_no]->get_dims(entities, num_entities, tag_values);
00347 }
00348 
00349 int AssocPair::get_dims(int iface_no, iBase_EntitySetHandle *sets,
00350                         int num_sets, int *tag_values)
00351 {
00352   return relSides[iface_no]->get_dims(sets, num_sets, tag_values);
00353 }
00354 
00355 int AssocPair::change_type(int iface_no, iRel_RelationType type)
00356 {
00357   if (entOrSet[iface_no] == type)
00358     RETURNR(iBase_SUCCESS);
00359   if (entOrSet[iface_no] == iRel_ENTITY || type == iRel_ENTITY)
00360     ERRORR(iBase_FAILURE, "Can only change type from \"set\" to \"both\", or "
00361            "vice-versa");
00362 
00363   entOrSet[iface_no] = type;
00364   if (relStatus[iface_no] != iRel_ACTIVE)
00365     RETURNR(iBase_SUCCESS);
00366 
00367   iBase_EntitySetHandle *sets = NULL;
00368   int set_alloc = 0, set_size;
00369   CHK_ERRORR( relSides[iface_no]->get_related_sets(&sets, &set_alloc,
00370                                                    &set_size) );
00371   if (type == iRel_BOTH) {
00372     if (entOrSet[!iface_no] == iRel_ENTITY) {
00373       std::vector<iBase_EntityHandle> related_ents(set_size);
00374       CHK_ERRORR( relSides[iface_no]->get_relation_side(sets, set_size,
00375                                                         &related_ents[0]) );
00376 
00377       for (int i = 0; i < set_size; i++)
00378         CHK_ERRORR( populate_recursive(iface_no, sets[i], related_ents[i]) );
00379     }
00380     else {
00381       std::vector<iBase_EntitySetHandle> related_sets(set_size);
00382       CHK_ERRORR( relSides[iface_no]->get_relation_side(sets, set_size,
00383                                                         &related_sets[0]) );
00384 
00385       for (int i = 0; i < set_size; i++)
00386         CHK_ERRORR( populate_recursive(iface_no, sets[i], related_sets[i]) );
00387     }
00388   }
00389   else if (type == iRel_SET) {
00390     for (int i = 0; i < set_size; i++)
00391       CHK_ERRORR( unpopulate_recursive(iface_no, sets[i]) );
00392   }
00393 
00394   free(sets);
00395   RETURNR(iBase_SUCCESS);
00396 }
00397 
00398 int AssocPair::change_status(int iface_no, iRel_RelationStatus status)
00399 {
00400   if (relStatus[iface_no] == status)
00401     RETURNR(iBase_SUCCESS);
00402 
00403   relStatus[iface_no] = status;
00404 
00405   if (status == iRel_NOTEXIST) {
00406     // Destroy the assoc tag
00407     CHK_ERRORR( relSides[iface_no]->destroy_relation_side() );
00408   }
00409   else if (status == iRel_INACTIVE) {
00410     // Create the assoc tag
00411     CHK_ERRORR( relSides[iface_no]->create_relation_side() );
00412   }
00413   // Update the assoc tag
00414   else if (status == iRel_ACTIVE) {
00415     CHK_ERRORR( relSides[iface_no]->destroy_relation_side() );
00416     CHK_ERRORR( relSides[iface_no]->create_relation_side() );
00417 
00418     if (entOrSet[!iface_no] == iRel_ENTITY) {
00419       iBase_EntityHandle *entities = NULL;
00420       int ent_alloc = 0, ent_size;
00421 
00422       CHK_ERRORR( relSides[!iface_no]->get_related_ents(&entities, &ent_alloc,
00423                                                         &ent_size) );
00424       if (entOrSet[iface_no] == iRel_ENTITY) {
00425         std::vector<iBase_EntityHandle> related_ents(ent_size);
00426         int result = relSides[!iface_no]->get_relation_side(
00427           entities, ent_size, &related_ents[0]);
00428 
00429         if (result == iBase_SUCCESS) {
00430           if (iface_no == 0)
00431             for (int i = 0; i < ent_size; i++)
00432               CHK_ERRORR( set_relation(related_ents[i], entities[i]) );
00433           else
00434             for (int i = 0; i < ent_size; i++)
00435               CHK_ERRORR( set_relation(entities[i], related_ents[i]) );
00436         }
00437       }
00438       else {
00439         std::vector<iBase_EntitySetHandle> related_sets(ent_size);
00440         int result = relSides[!iface_no]->get_relation_side(
00441           entities, ent_size, &related_sets[0]);
00442 
00443         if (result == iBase_SUCCESS) {
00444           if (iface_no == 0)
00445             for (int i = 0; i < ent_size; i++)
00446               CHK_ERRORR( set_relation(related_sets[i], entities[i]) );
00447           else
00448             for (int i = 0; i < ent_size; i++)
00449               CHK_ERRORR( set_relation(entities[i], related_sets[i]) );
00450         }
00451       }
00452     
00453       free(entities);
00454     }
00455     else {
00456       iBase_EntitySetHandle *sets = NULL;
00457       int set_alloc = 0, set_size;
00458 
00459       CHK_ERRORR( relSides[!iface_no]->get_related_sets(&sets, &set_alloc,
00460                                                         &set_size) );
00461       if (entOrSet[iface_no] == iRel_ENTITY) {
00462         std::vector<iBase_EntityHandle> related_ents(set_size);
00463         int result = relSides[!iface_no]->get_relation_side(
00464           sets, set_size, &related_ents[0]);
00465 
00466         if (result == iBase_SUCCESS) {
00467           if (iface_no == 0)
00468             for (int i = 0; i < set_size; i++)
00469               CHK_ERRORR( set_relation(related_ents[i], sets[i]) );
00470           else
00471             for (int i = 0; i < set_size; i++)
00472               CHK_ERRORR( set_relation(sets[i], related_ents[i]) );
00473         }
00474       }
00475       else {
00476         std::vector<iBase_EntitySetHandle> related_sets(set_size);
00477         int result = relSides[!iface_no]->get_relation_side(
00478           sets, set_size, &related_sets[0]);
00479 
00480         if (result == iBase_SUCCESS) {
00481           if (iface_no == 0)
00482             for (int i = 0; i < set_size; i++)
00483               CHK_ERRORR( set_relation(related_sets[i], sets[i]) );
00484           else
00485             for (int i = 0; i < set_size; i++)
00486               CHK_ERRORR( set_relation(sets[i], related_sets[i]) );
00487         }
00488       }
00489     
00490       free(sets);
00491     }
00492   }
00493   else {
00494     ERRORR(iBase_INVALID_ARGUMENT, "Invalid argument for relation status");
00495   }
00496 
00497   RETURNR(iBase_SUCCESS);
00498 }
00499 
00500 bool AssocPair::equivalent(iBase_Instance iface0, iBase_Instance iface1,
00501                            bool *order_switched)
00502 {
00503   if (iface0 == relSides[0]->instance() &&
00504       iface1 == relSides[1]->instance()) {
00505     if (order_switched) *order_switched = false;
00506     return true;
00507   }
00508   else if (iface0 == relSides[1]->instance() &&
00509            iface1 == relSides[0]->instance()) {
00510     if (order_switched) *order_switched = true;
00511     return true;
00512   }
00513   else
00514     return false;
00515 }
00516 
00517 bool AssocPair::equivalent(iRel_IfaceType type0, iRel_IfaceType type1,
00518                            bool *order_switched)
00519 {
00520   if (type0 == relSides[0]->type() &&
00521       type1 == relSides[1]->type()) {
00522     if (order_switched) *order_switched = false;
00523     return true;
00524   }
00525   else if (type0 == relSides[1]->type() &&
00526            type1 == relSides[0]->type()) {
00527     if (order_switched) *order_switched = true;
00528     return true;
00529   }
00530   else
00531     return false;
00532 }
00533 
00534 bool AssocPair::contains(iBase_Instance iface)
00535 {
00536   return (iface == relSides[0]->instance() ||
00537           iface == relSides[1]->instance());
00538 }
00539 
00540 int AssocPair::populate_recursive(int iface_no, iBase_EntitySetHandle set,
00541                                   iBase_EntityHandle related_ent)
00542 {
00543   iBase_EntityHandle *entities = NULL;
00544   int entities_alloc = 0, entities_size;
00545 
00546   CHK_ERRORR( relSides[iface_no]->get_entities(-1, set, &entities,
00547                                                &entities_alloc,
00548                                                &entities_size) );
00549 
00550   for (int i = 0; i < entities_size; i++)
00551     CHK_ERRORR( relSides[iface_no]->set_relation_side(entities+i, 1,
00552                                                       &related_ent) );
00553 
00554   free(entities);
00555   RETURNR(iBase_SUCCESS);
00556 }
00557 
00558 int AssocPair::populate_recursive(int iface_no, iBase_EntitySetHandle set,
00559                                   iBase_EntitySetHandle related_set)
00560 {
00561   iBase_EntityHandle *entities = NULL;
00562   int entities_alloc, entities_size;
00563 
00564   CHK_ERRORR( relSides[iface_no]->get_entities(-1, set, &entities,
00565                                                &entities_alloc,
00566                                                &entities_size) );
00567 
00568   for (int i = 0; i < entities_size; i++)
00569     CHK_ERRORR( relSides[iface_no]->set_relation_side(entities+i, 1,
00570                                                       &related_set) );
00571 
00572   free(entities);
00573   RETURNR(iBase_SUCCESS);
00574 }
00575 
00576 int AssocPair::unpopulate_recursive(int iface_no, iBase_EntitySetHandle set)
00577 {
00578   iBase_EntityHandle *entities = NULL;
00579   int entities_alloc = 0, entities_size;
00580 
00581   CHK_ERRORR( relSides[iface_no]->get_entities(-1, set, &entities,
00582                                                &entities_alloc,
00583                                                &entities_size) );
00584   CHK_ERRORR( relSides[iface_no]->rmv_relation_side(entities, entities_size) );
00585 
00586   free(entities);
00587   RETURNR(iBase_SUCCESS);
00588 }
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines