Esempio n. 1
0
inline iMesh::~iMesh()
{
  if (iMeshInstanceOwner) {
    int err;
    iMesh_dtor( mInstance, &err );
  }
}
Esempio n. 2
0
void test_tags_retrieval()
{
  iMesh_Instance mesh;
  int err;
  iMesh_newMesh("", &mesh, &err, 0);
  CHECK_EQUAL( iBase_SUCCESS, err );

  iBase_EntitySetHandle root_set;
  iMesh_getRootSet(mesh, &root_set, &err);
  CHECK_EQUAL( iBase_SUCCESS, err );

  // open a file with var len tags (sense tags)
  // they should be filtered out
  std::string filename = STRINGIFY(MESHDIR) "/PB.h5m";

  iMesh_load(mesh, root_set, filename.c_str(), NULL, &err, filename.length(), 0);
  CHECK_EQUAL( iBase_SUCCESS, err );

  iBase_EntitySetHandle* contained_set_handles = NULL;
  int contained_set_handles_allocated = 0;
  int contained_set_handles_size;
  // get all entity sets
  iMesh_getEntSets(mesh, root_set, 1,
      &contained_set_handles,
      &contained_set_handles_allocated,
      &contained_set_handles_size,
      &err  );
  CHECK_EQUAL( iBase_SUCCESS, err );
  // get tags for all sets
  for (int i=0; i< contained_set_handles_size; i++)
  {
    iBase_TagHandle* tag_handles = NULL;
    int tag_handles_allocated=0;
    int tag_handles_size;
    iMesh_getAllEntSetTags (mesh,
        contained_set_handles[i],
        &tag_handles,
        &tag_handles_allocated,
        &tag_handles_size, &err);
    CHECK_EQUAL( iBase_SUCCESS, err );

    for (int j=0; j<tag_handles_size; j++)
    {
      int tagSize;
      iMesh_getTagSizeValues(mesh, tag_handles[j], &tagSize, &err);
      CHECK_EQUAL( iBase_SUCCESS, err );

    }
    free(tag_handles);
  }
  free (contained_set_handles);

  // Delete the iMesh instance
  iMesh_dtor(mesh, &err);
  CHECK_EQUAL(iBase_SUCCESS, err);

  return;
}
Esempio n. 3
0
void test_step_iter()
{
  iMesh_Instance mesh;
  int err;
  iMesh_newMesh("", &mesh, &err, 0);
  CHECK_EQUAL( iBase_SUCCESS, err );

  iBase_EntitySetHandle root_set;
  iMesh_getRootSet(mesh, &root_set, &err);
  CHECK_EQUAL( iBase_SUCCESS, err );

  iBase_EntityHandle *verts = 0;
  int verts_alloc = 0, verts_size = 0;
  double coords[] = { 0,0,0, 1,1,1, 2,2,2, 3,3,3, 4,4,4, 5,5,5 };
  iMesh_createVtxArr(mesh,6,iBase_INTERLEAVED,coords,18,&verts,&verts_alloc,
                     &verts_size,&err);
  CHECK_EQUAL( iBase_SUCCESS, err );

  /* make a non-array iterator and test stepping over it */
  iBase_EntityIterator iter;
  int atend;
  iMesh_initEntIter( mesh, root_set, iBase_ALL_TYPES, iMesh_ALL_TOPOLOGIES,
                     0, &iter, &err );
  CHECK_EQUAL( iBase_SUCCESS, err );
  iMesh_stepEntIter(mesh, iter, 2, &atend, &err);
  CHECK_EQUAL( iBase_SUCCESS, err );
    /* shouldn't be at end yet */
  if (atend) CHECK_EQUAL( iBase_SUCCESS, iBase_FAILURE );
  
  iMesh_stepEntIter(mesh, iter, 4, &atend, &err);
  CHECK_EQUAL( iBase_SUCCESS, err );
    /* should be at end now */
  if (!atend) CHECK_EQUAL( iBase_SUCCESS, iBase_FAILURE );
  iMesh_endEntIter(mesh, iter, &err);
  CHECK_EQUAL( iBase_SUCCESS, err );

  /* make an array iterator and test stepping over it */
  iBase_EntityArrIterator arr_iter;
  iMesh_initEntArrIter( mesh, root_set, iBase_ALL_TYPES, iMesh_ALL_TOPOLOGIES,
                        6, 0, &arr_iter, &err );
  CHECK_EQUAL( iBase_SUCCESS, err );
  iMesh_stepEntArrIter(mesh, arr_iter, 2, &atend, &err);
  CHECK_EQUAL( iBase_SUCCESS, err );
    /* shouldn't be at end yet */
  if (atend) CHECK_EQUAL( iBase_SUCCESS, iBase_FAILURE );
  
  iMesh_stepEntArrIter(mesh, arr_iter, 4, &atend, &err);
  CHECK_EQUAL( iBase_SUCCESS, err );
    /* should be at end now */
  if (!atend) CHECK_EQUAL( iBase_SUCCESS, iBase_FAILURE );
  iMesh_endEntArrIter(mesh, arr_iter, &err);
  CHECK_EQUAL( iBase_SUCCESS, err );

  iMesh_dtor(mesh,&err);
  CHECK_EQUAL( iBase_SUCCESS, err );

  free(verts);
}
Esempio n. 4
0
void test_existinterface()
{
    // test construction of an imesh instance from a core instance
  moab::Core *core = new moab::Core();
  MBiMesh *mesh = new MBiMesh(core);
  iMesh_Instance imesh = reinterpret_cast<iMesh_Instance>(mesh);
  
    // make sure we can call imesh functions
  int dim, err;
  iMesh_getGeometricDimension(imesh, &dim, &err);
  CHECK_EQUAL( iBase_SUCCESS, err );

    // now make sure we can delete the instance without it deleting the MOAB instance
  iMesh_dtor(imesh, &err);
  CHECK_EQUAL(err, iBase_SUCCESS);
  
  ErrorCode rval = core->get_number_entities_by_dimension(0, 0, dim);
  CHECK_EQUAL(moab::MB_SUCCESS, rval);

    // finally, delete the MOAB instance
  delete core;
}
Esempio n. 5
0
int main( int argc, char* argv[] )
{
  REGISTER_TEST( test_getEntArrAdj_conn );
  REGISTER_TEST( test_getEntArrAdj_vertex );
  REGISTER_TEST( test_getEntArrAdj_up );
  REGISTER_TEST( test_getEntArrAdj_down );
  REGISTER_TEST( test_getEntArrAdj_invalid_size );
  REGISTER_TEST( test_getEntArrAdj_none );
  REGISTER_TEST( test_existinterface );
#ifdef  MOAB_HAVE_HDF5
  REGISTER_TEST( test_tags_retrieval );
#endif
  int result = RUN_TESTS( argc, argv );

  // Delete the static iMesh instance defined in create_mesh()
  iMesh_Instance mesh = create_mesh();
  int err;
  iMesh_dtor(mesh, &err);
  CHECK_EQUAL(iBase_SUCCESS, err);

  return result;
}
Esempio n. 6
0
void test_tag_iterate()
{
  iMesh_Instance mesh;
  int err;
  iMesh_newMesh("", &mesh, &err, 0);
  CHECK_EQUAL( iBase_SUCCESS, err );

  iBase_EntitySetHandle root_set, entset;
  iMesh_getRootSet(mesh, &root_set, &err);
  CHECK_EQUAL( iBase_SUCCESS, err );

  iBase_EntityHandle *verts = 0;
  int verts_alloc = 0, verts_size = 0;
  double coords[] = { 0,0,0, 1,1,1, 2,2,2, 3,3,3, 4,4,4, 5,5,5 };
  iMesh_createVtxArr(mesh,6,iBase_INTERLEAVED,coords,18,&verts,&verts_alloc,
                     &verts_size,&err);
  CHECK_EQUAL( iBase_SUCCESS, err );

    /* create an entity set with two subranges */
  iMesh_createEntSet( mesh, 0, &entset, &err );
  CHECK_EQUAL( iBase_SUCCESS, err );
  iMesh_addEntArrToSet( mesh, verts, 2, entset, &err );
  CHECK_EQUAL( iBase_SUCCESS, err );
  iMesh_addEntArrToSet( mesh, &verts[3], 3, entset, &err );
  CHECK_EQUAL( iBase_SUCCESS, err );
    
    /* create a dbl tag and set vertices */
  iBase_TagHandle tagh;
  iMesh_createTagWithOptions(mesh, "dum", "moab:TAG_STORAGE_TYPE=DENSE", 1, iBase_DOUBLE, &tagh, &err, 3, 27);
  CHECK_EQUAL( iBase_SUCCESS, err );
  iMesh_setDblArrData(mesh, verts, 6, tagh, coords+3, 6, &err);
  CHECK_EQUAL( iBase_SUCCESS, err );

    /* get an iterator over the root set, and check tag iterator for that */
  iBase_EntityArrIterator iter;
  int count, atend;
  double *data;
  iMesh_initEntArrIter( mesh, root_set, iBase_ALL_TYPES, iMesh_ALL_TOPOLOGIES,
                        6, 0, &iter, &err );
  CHECK_EQUAL( iBase_SUCCESS, err );
  iMesh_tagIterate(mesh, tagh, iter, &data, &count, &err);
  CHECK_EQUAL( iBase_SUCCESS, err );
  if (count != 6) CHECK_EQUAL( iBase_SUCCESS, iBase_FAILURE );
  
  for (int i = 0; i < 6; i++) {
    if (data[i] != coords[i+3]) CHECK_EQUAL( iBase_SUCCESS, iBase_FAILURE );
  }
  iMesh_endEntArrIter(mesh, iter, &err);
  CHECK_EQUAL( iBase_SUCCESS, err );
  
    /* get an iterator over the set with two subranges, and check tag iterator for that */
  iMesh_initEntArrIter( mesh, entset, iBase_ALL_TYPES, iMesh_ALL_TOPOLOGIES, 6,
                        0, &iter, &err );
  CHECK_EQUAL( iBase_SUCCESS, err );
  iMesh_tagIterate(mesh, tagh, iter, &data, &count, &err);
  CHECK_EQUAL( iBase_SUCCESS, err );
  if (count != 2 || data[0] != coords[3] || data[1] != coords[4]) CHECK_EQUAL( iBase_SUCCESS, iBase_FAILURE );
  iMesh_stepEntArrIter(mesh, iter, 2, &atend, &err);
  CHECK_EQUAL( iBase_SUCCESS, err );
    /* shouldn't be at end yet */
  if (atend) CHECK_EQUAL( iBase_SUCCESS, iBase_FAILURE );
  
  iMesh_tagIterate(mesh, tagh, iter, &data, &count, &err);
  CHECK_EQUAL( iBase_SUCCESS, err );
  if (count != 3 || data[0] != coords[6] || data[1] != coords[7]) CHECK_EQUAL( iBase_SUCCESS, iBase_FAILURE );
  iMesh_stepEntArrIter(mesh, iter, 3, &atend, &err);
  CHECK_EQUAL( iBase_SUCCESS, err );
    /* should be at end now */
  if (!atend) CHECK_EQUAL( iBase_SUCCESS, iBase_FAILURE );
  iMesh_endEntArrIter(mesh, iter, &err);
  CHECK_EQUAL( iBase_SUCCESS, err );

  iMesh_dtor(mesh,&err);
  CHECK_EQUAL( iBase_SUCCESS, err );

  free(verts);
}