MOAB: Mesh Oriented datABase
(version 5.3.1)
|
00001 /** 00002 * MOAB, a Mesh-Oriented datABase, is a software component for creating, 00003 * storing and accessing finite element mesh data. 00004 * 00005 * Copyright 2004 Sandia Corporation. Under the terms of Contract 00006 * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government 00007 * retains certain rights in this software. 00008 * 00009 * This library is free software; you can redistribute it and/or 00010 * modify it under the terms of the GNU Lesser General Public 00011 * License as published by the Free Software Foundation; either 00012 * version 2.1 of the License, or (at your option) any later version. 00013 * 00014 */ 00015 00016 /** TSTT Mesh Interface Unit Test 00017 * 00018 * This program tests TSTT mesh interface functions through the SIDL interface. 00019 * In a nutshell, the test creates (or accesses) an implementation instance, 00020 * tells it to load a file (specified on the command line), then calls a 00021 * number of functions evaluating that mesh. This test also tests mesh, set 00022 * and tag creation and evaluation functions. 00023 * 00024 * Usage: testcxx <mesh_file_name> 00025 * 00026 * Compiling 00027 * --------- 00028 * 1. Build your server (your implementation of the TSTT mesh interface) under 00029 * SIDL/Babel and put it in a library in the Babel-generated server directory, 00030 * ${SERVER_DIR}/libimpl.so. Any include files needed to instantiate this 00031 * server from applications should also be in that directory. See note a) below. 00032 * 2. Change the definition of IMPLEMENTATION_CLASS below to be the 00033 * namespace-qualified name of your implementation class. This definition is 00034 * used in the main to instantiate the server using the SIDL _create function, e.g. 00035 * . TSTTB::Mesh mesh = IMPLEMENTATION_CLASS._create(); 00036 * (we put the definition of IMPLEMENTATION_CLASS at the top of this file so that 00037 * you don't have to understand the rest of the source code to use this test). See 00038 * note b) below. 00039 * 3. Include the file(s) needed which declare the implementation's namespace and 00040 * class 00041 * 4. Compile this test file to an object file: 00042 * g++ -fpic -I. -I${BABEL}/include -I${SERVER_DIR} -c testcxx.cpp 00043 * 5. Link the application: 00044 * g++ -o testcxx testcxx.o -ltest -L${BABEL_LIBS} -lsidl 00045 * 00046 * Notes 00047 * ----- 00048 * a) The files don't absolutely need to be arranged as described above. For 00049 * example, some projects put their custom implementation files somewhere besides 00050 * ${SERVER_DIR}, to keep them separate from Babel-generated files. 00051 * b) This test assumes interface instances are created using a direct call to the 00052 * SIDL _create() function for that class. Another way to do this would be to 00053 * call a factory linked into the test. To change the method used to construct 00054 * the interface instance for this test, see the use of IMPLEMENTATION_CLASS towards 00055 * the end of this file. 00056 */ 00057 00058 #include <cstdio> 00059 #include <cstring> 00060 #include <cstdlib> 00061 #include "iMesh.h" 00062 #include "iMesh_extensions.h" 00063 #include "moab/Types.hpp" 00064 #include "TestUtil.hpp" 00065 using namespace moab; 00066 extern enum iBase_ErrorType iBase_ERROR_MAP[MB_FAILURE + 1]; 00067 00068 #define FALSE 0 00069 #define TRUE 1 00070 00071 #define DEFAULT_TEST_FILE brick.vtk 00072 00073 // clang-format off 00074 00075 #ifdef SRCDIR 00076 #define DEFAULT_INPUT_FILE STRINGIFY( SRCDIR/DEFAULT_TEST_FILE ) 00077 #else 00078 #define DEFAULT_INPUT_FILE STRINGIFY( DEFAULT_TEST_FILE ) 00079 #endif 00080 00081 static bool assert_pass; 00082 #define ASSERT( COND ) \ 00083 assert_pass = true; \ 00084 if( !( COND ) ) \ 00085 { \ 00086 PRINT_ASSERT_FAILURE( #COND, __FILE__, __LINE__ ); \ 00087 assert_pass = false; \ 00088 } 00089 00090 void PRINT_ASSERT_FAILURE( const char* cond, const char* file, int line ) 00091 { 00092 printf( "Condition: %s\n", cond ); 00093 printf( " failed at %s line %d\n", file, line ); 00094 } 00095 00096 #define CHK( err ) \ 00097 if( (err) != iBase_SUCCESS ) do \ 00098 { \ 00099 printf( "%s:%d ITAPS error %d\n", __FILE__, __LINE__, err ); \ 00100 return 0; \ 00101 } while( 0 ) 00102 00103 // clang-format on 00104 00105 static iBase_EntitySetHandle root_set; 00106 00107 /*! 00108 prints out a result string based on the value of error_code 00109 */ 00110 void handle_error_code( const int result, int* number_failed, int* /*number_not_implemented*/, int* number_successful ) 00111 { 00112 if( result ) 00113 { 00114 printf( "Success\n" ); 00115 ( *number_successful )++; 00116 } 00117 else 00118 { 00119 printf( "Failure\n" ); 00120 ( *number_failed )++; 00121 } 00122 } 00123 00124 /*! 00125 @test 00126 Load Mesh 00127 @li Load a mesh file 00128 */ 00129 int load_mesh_test( const char* filename, iMesh_Instance mesh ) 00130 { 00131 /* load a mesh */ 00132 int result; 00133 iMesh_load( mesh, root_set, filename, NULL, &result, strlen( filename ), 0 ); 00134 if( iBase_SUCCESS != result ) 00135 { 00136 printf( "ERROR : can not load a mesh from file %s\n", filename ); 00137 return FALSE; 00138 } 00139 00140 return TRUE; 00141 } 00142 00143 #define TEST_ERROR_CODE( A, B ) \ 00144 if( iBase_ERROR_MAP[( A )] != ( B ) ) \ 00145 { \ 00146 printf( "ERROR: Invalid mapping for MOAB error code %s\n", #A ); \ 00147 printf( " Expected %d, actual is %d\n", (int)iBase_ERROR_MAP[( A )], (int)( B ) ); \ 00148 return FALSE; \ 00149 } 00150 00151 int error_code_test( iMesh_Instance /*mesh*/ ) 00152 { 00153 TEST_ERROR_CODE( MB_SUCCESS, iBase_SUCCESS ) 00154 TEST_ERROR_CODE( MB_TYPE_OUT_OF_RANGE, iBase_INVALID_ENTITY_TYPE ) 00155 TEST_ERROR_CODE( MB_MEMORY_ALLOCATION_FAILED, iBase_MEMORY_ALLOCATION_FAILED ) 00156 TEST_ERROR_CODE( MB_ENTITY_NOT_FOUND, iBase_INVALID_ENTITY_HANDLE ) 00157 TEST_ERROR_CODE( MB_TAG_NOT_FOUND, iBase_TAG_NOT_FOUND ) 00158 TEST_ERROR_CODE( MB_FILE_DOES_NOT_EXIST, iBase_FILE_NOT_FOUND ) 00159 TEST_ERROR_CODE( MB_UNSUPPORTED_OPERATION, iBase_NOT_SUPPORTED ) 00160 TEST_ERROR_CODE( MB_UNHANDLED_OPTION, iBase_INVALID_ARGUMENT ) 00161 TEST_ERROR_CODE( MB_FAILURE, iBase_FAILURE ) 00162 return TRUE; 00163 } 00164 00165 /*! 00166 @test 00167 TSTT topology dimension Test 00168 @li Check 2d topology dimensions 00169 */ 00170 int topology_dimension_test( iMesh_Instance mesh ) 00171 { 00172 iBase_EntityHandle* faces = NULL; 00173 int faces_alloc = 0, faces_size; 00174 int result, i; 00175 int* dimensions = NULL; 00176 int dimensions_alloc = 0, dimensions_size; 00177 00178 /* first get 2D entities */ 00179 iMesh_getEntities( mesh, root_set, iBase_FACE, iMesh_ALL_TOPOLOGIES, &faces, &faces_alloc, &faces_size, &result ); 00180 if( iBase_SUCCESS != result ) 00181 { 00182 printf( "Failed to get faces in entity_sets_test.\n" ); 00183 return FALSE; 00184 } 00185 00186 /* get dimensions of faces */ 00187 iMesh_getEntArrType( mesh, faces, faces_size, &dimensions, &dimensions_alloc, &dimensions_size, &result ); 00188 if( iBase_SUCCESS != result ) 00189 { 00190 printf( "Failed to get dimensions of faces in topology_test.\n" ); 00191 free( faces ); 00192 return FALSE; 00193 } 00194 00195 if( dimensions_size != faces_size ) 00196 { 00197 printf( "Didn't get the right number of types in topology_test.\n" ); 00198 free( faces ); 00199 free( dimensions ); 00200 return FALSE; 00201 } 00202 00203 /* make sure all elements are 2D */ 00204 for( i = 0; i < faces_size; i++ ) 00205 { 00206 if( dimensions[i] != iBase_FACE ) 00207 { 00208 free( faces ); 00209 free( dimensions ); 00210 return FALSE; 00211 } 00212 } 00213 00214 free( faces ); 00215 free( dimensions ); 00216 00217 return TRUE; 00218 } 00219 00220 /*! 00221 @test 00222 TSTT topology adjacency Test 00223 @li Check topology information 00224 @li Check adjacency 00225 @li Get interior and exterior elements 00226 */ 00227 /* make each topological entity vectors, check their topology */ 00228 /* types, get interior and exterior faces of hexes */ 00229 int topology_adjacency_test( iMesh_Instance mesh ) 00230 { 00231 int result, i, j, entities_alloc, entities_size, *topologies; 00232 int topologies_alloc, topologies_size; 00233 iBase_EntityHandle *entities, *entity_vectors[iMesh_ALL_TOPOLOGIES] = { NULL }; 00234 int entity_vectors_sizes[iMesh_ALL_TOPOLOGIES] = { 0 }; 00235 int top_j, num_tops, region_type, num_region; 00236 iBase_EntityHandle* adj_faces = NULL; 00237 int adj_faces_alloc = 0, adj_faces_size; 00238 int* face_offsets = NULL; 00239 int face_offsets_alloc = 0, face_offsets_size, face_loaded; 00240 iBase_EntityHandle* adj_regions = NULL; 00241 int adj_regions_alloc = 0, adj_regions_size; 00242 int* region_offsets = NULL; 00243 int region_offsets_alloc = 0, region_offsets_size; 00244 iBase_EntityHandle *interior, *exterior; 00245 int num_int = 0, num_ext = 0, found, next_offset, iter; 00246 int num_faces_per_region; 00247 ; 00248 00249 /* fill the vectors of each topology entities */ 00250 /* like lines vector, polygon vector, triangle vector, */ 00251 /* quadrilateral, polyhedrron, tet, hex, prism, pyramid, */ 00252 /* septahedron vectors */ 00253 for( i = 0; i < iMesh_ALL_TOPOLOGIES; i++ ) 00254 { 00255 entities = NULL; 00256 entities_alloc = 0; 00257 iMesh_getEntities( mesh, root_set, iBase_ALL_TYPES, i, &entities, &entities_alloc, &entities_size, &result ); 00258 if( iBase_SUCCESS != result ) 00259 { 00260 printf( "Failed to get entities in adjacencies_test.\n" ); 00261 return FALSE; 00262 } 00263 00264 if( entities_alloc > 0 ) 00265 { 00266 topologies = NULL; 00267 topologies_alloc = 0; 00268 iMesh_getEntArrTopo( mesh, entities, entities_alloc, &topologies, &topologies_alloc, &topologies_size, 00269 &result ); 00270 if( iBase_SUCCESS != result ) 00271 { 00272 printf( "Failed to get topologies in adjacencies_test.\n" ); 00273 return FALSE; 00274 } 00275 00276 if( topologies_size != entities_size ) 00277 { 00278 printf( "Didn't get the right number of topologies " 00279 "in topology_adjacency_test.\n" ); 00280 free( topologies ); 00281 free( entities ); 00282 return FALSE; 00283 } 00284 00285 /* put entities into vectors of each topology */ 00286 entity_vectors[i] = (iBase_EntityHandle*)malloc( entities_size * sizeof( iBase_EntityHandle ) ); 00287 00288 for( j = 0; j < entities_size; j++ ) 00289 { 00290 if( topologies[j] < iMesh_POINT || topologies[j] >= iMesh_ALL_TOPOLOGIES ) 00291 printf( "Didn't find entity type for this topology." ); 00292 else 00293 { 00294 entity_vectors[i][entity_vectors_sizes[i]] = entities[j]; 00295 entity_vectors_sizes[i]++; 00296 } 00297 } 00298 00299 free( topologies ); 00300 } 00301 00302 free( entities ); 00303 } 00304 00305 /* check number of entities for each topology */ 00306 for( top_j = 0; top_j < iMesh_ALL_TOPOLOGIES; top_j++ ) 00307 { 00308 num_tops = 0; 00309 iMesh_getNumOfTopo( mesh, root_set, top_j, &num_tops, &result ); 00310 if( iBase_SUCCESS != result ) 00311 { 00312 printf( "Failed to get number of topologies in adjacencies_test.\n" ); 00313 for( i = 0; i < iMesh_ALL_TOPOLOGIES; i++ ) 00314 free( entity_vectors[i] ); 00315 return FALSE; 00316 } 00317 00318 if( entity_vectors_sizes[top_j] != num_tops ) 00319 { 00320 printf( "Topology count mismatch.\n" ); 00321 for( i = 0; i < iMesh_ALL_TOPOLOGIES; i++ ) 00322 free( entity_vectors[i] ); 00323 return FALSE; 00324 } 00325 } 00326 00327 /* change if 3d topology entities are added or removed */ 00328 for( region_type = iMesh_TETRAHEDRON; region_type < iMesh_ALL_TOPOLOGIES; region_type++ ) 00329 { 00330 /* get all adjacent faces of regions */ 00331 iBase_EntityHandle* region_vector = entity_vectors[region_type]; 00332 00333 num_region = entity_vectors_sizes[region_type]; 00334 00335 if( num_region > 0 ) 00336 { 00337 adj_faces = NULL; 00338 adj_faces_alloc = 0; 00339 face_offsets = NULL; 00340 face_offsets_alloc = 0; 00341 00342 iMesh_getEntArrAdj( mesh, region_vector, num_region, iBase_FACE, &adj_faces, &adj_faces_alloc, 00343 &adj_faces_size, &face_offsets, &face_offsets_alloc, &face_offsets_size, &result ); 00344 if( iBase_SUCCESS != result ) 00345 { 00346 printf( "Failed to get adjacent faces of regions in adjacencies_test.\n" ); 00347 for( i = 0; i < iMesh_ALL_TOPOLOGIES; i++ ) 00348 free( entity_vectors[i] ); 00349 return FALSE; 00350 } 00351 00352 if( num_region + 1 != face_offsets_size ) 00353 { 00354 printf( "Number of offsets didn't agree with number of " 00355 "regions in topology_adjacency_test.\n" ); 00356 free( face_offsets ); 00357 free( adj_faces ); 00358 for( i = 0; i < iMesh_ALL_TOPOLOGIES; i++ ) 00359 free( entity_vectors[i] ); 00360 return FALSE; 00361 } 00362 00363 face_loaded = FALSE; 00364 00365 /* check # of faces really loaded */ 00366 if( region_type == iMesh_TETRAHEDRON ) 00367 { 00368 if( adj_faces_size == 4 * num_region ) face_loaded = TRUE; 00369 } 00370 else if( region_type == iMesh_HEXAHEDRON ) 00371 { 00372 if( adj_faces_size == 6 * num_region ) face_loaded = TRUE; 00373 } 00374 else if( region_type == iMesh_PRISM ) 00375 { 00376 if( adj_faces_size == 5 * num_region ) face_loaded = TRUE; 00377 } 00378 else if( region_type == iMesh_PYRAMID ) 00379 { 00380 if( adj_faces_size == 5 * num_region ) face_loaded = TRUE; 00381 } 00382 else if( region_type == iMesh_SEPTAHEDRON ) 00383 { 00384 if( adj_faces_size == 7 * num_region ) face_loaded = TRUE; 00385 } 00386 else 00387 face_loaded = FALSE; 00388 00389 /* get all adjacent regions of adjacent faces */ 00390 adj_regions = NULL; 00391 adj_regions_alloc = 0; 00392 region_offsets = NULL; 00393 region_offsets_alloc = 0; 00394 iMesh_getEntArrAdj( mesh, adj_faces, adj_faces_size, iBase_REGION, &adj_regions, &adj_regions_alloc, 00395 &adj_regions_size, ®ion_offsets, ®ion_offsets_alloc, ®ion_offsets_size, 00396 &result ); 00397 if( iBase_SUCCESS != result ) 00398 { 00399 printf( "Failed to get regions from faces in adjacencies_test.\n" ); 00400 free( face_offsets ); 00401 free( adj_faces ); 00402 for( i = 0; i < iMesh_ALL_TOPOLOGIES; i++ ) 00403 free( entity_vectors[i] ); 00404 return FALSE; 00405 } 00406 00407 if( adj_faces_size + 1 != region_offsets_size ) 00408 { 00409 printf( "Number of offsets didn't agree with number of faces in " 00410 "topology_adjacency_test.\n" ); 00411 free( face_offsets ); 00412 free( region_offsets ); 00413 free( adj_faces ); 00414 free( adj_regions ); 00415 for( i = 0; i < iMesh_ALL_TOPOLOGIES; i++ ) 00416 free( entity_vectors[i] ); 00417 return FALSE; 00418 } 00419 00420 interior = (iBase_EntityHandle*)malloc( adj_faces_size * sizeof( iBase_EntityHandle ) ), 00421 exterior = (iBase_EntityHandle*)malloc( adj_faces_size * sizeof( iBase_EntityHandle ) ); 00422 num_int = 0; 00423 num_ext = 0; 00424 00425 /* find the interior faces having two adjacent regions */ 00426 for( i = 0; i < adj_faces_size; i++ ) 00427 { 00428 next_offset = 0; 00429 if( i == adj_faces_size - 1 ) 00430 next_offset = adj_regions_size; 00431 else 00432 next_offset = region_offsets[i + 1]; 00433 00434 if( next_offset - region_offsets[i] == 2 ) 00435 { 00436 found = FALSE; 00437 for( iter = 0; iter < num_int; iter++ ) 00438 { 00439 if( interior[iter] == adj_faces[i] ) 00440 { 00441 found = TRUE; 00442 break; 00443 } 00444 } 00445 if( !found ) interior[num_int++] = adj_faces[i]; 00446 } 00447 } 00448 00449 /* now remove any interior faces from the previous adjacent faces list */ 00450 /* and we should be left with exterior faces */ 00451 for( i = 0; i < adj_faces_size; i++ ) 00452 { 00453 found = FALSE; 00454 for( iter = 0; iter < num_int; iter++ ) 00455 { 00456 if( interior[iter] == adj_faces[i] ) 00457 { 00458 found = TRUE; 00459 break; 00460 } 00461 } 00462 if( !found ) exterior[num_ext++] = adj_faces[i]; 00463 } 00464 00465 num_faces_per_region = face_offsets[1] - face_offsets[0]; 00466 00467 /* check # of exterior and interior faces */ 00468 /* should be #exterior_faces + 2 * #interior_faces = #faces_per_region */ 00469 /* * #regions */ 00470 if( face_loaded ) 00471 { 00472 if( num_ext + 2 * num_int != num_faces_per_region * num_region ) 00473 { 00474 printf( "exterior/interior failure: %d ext, %d int, %d regions, %d faces per\n", num_ext, num_int, 00475 num_region, num_faces_per_region ); 00476 free( face_offsets ); 00477 free( region_offsets ); 00478 free( adj_faces ); 00479 free( adj_regions ); 00480 free( interior ); 00481 free( exterior ); 00482 for( i = 0; i < iMesh_ALL_TOPOLOGIES; i++ ) 00483 free( entity_vectors[i] ); 00484 return FALSE; 00485 } 00486 } 00487 00488 free( face_offsets ); 00489 free( region_offsets ); 00490 free( adj_faces ); 00491 free( adj_regions ); 00492 free( interior ); 00493 free( exterior ); 00494 } 00495 } 00496 00497 for( i = 0; i < iMesh_ALL_TOPOLOGIES; i++ ) 00498 free( entity_vectors[i] ); 00499 00500 return TRUE; 00501 } 00502 00503 int qsort_comp_handles( const void* h1, const void* h2 ) 00504 { 00505 return *(char**)h1 - *(char**)h2; 00506 } 00507 00508 /*! 00509 @test 00510 TSTT EntityType Connectivity Test 00511 @li Get coordinates for all type enities 00512 */ 00513 00514 int entity_connectivity_test( iMesh_Instance mesh ) 00515 { 00516 int type, result; 00517 int *offsets, offsets_alloc, offsets_size; 00518 int *indices, indices_alloc, indices_size; 00519 iBase_EntityHandle *entities, *adj_ents, *entities2, *sorted; 00520 int entities_alloc, entities_size, adj_ents_alloc, adj_ents_size; 00521 int entities2_alloc, entities2_size; 00522 iBase_EntityHandle adj_ents2[27], *adj_ents2_ptr = adj_ents2; 00523 int adj_ents2_alloc = 27, adj_ents2_size, i, size; 00524 00525 for( type = iBase_EDGE; type < iBase_ALL_TYPES; type++ ) 00526 { 00527 entities = NULL; 00528 entities_alloc = 0; 00529 adj_ents = NULL; 00530 adj_ents_alloc = 0; 00531 indices = NULL; 00532 indices_alloc = 0; 00533 offsets = NULL; 00534 offsets_alloc = 0; 00535 iMesh_getAdjEntIndices( mesh, root_set, type, iMesh_ALL_TOPOLOGIES, iBase_VERTEX, &entities, &entities_alloc, 00536 &entities_size, &adj_ents, &adj_ents_alloc, &adj_ents_size, &indices, &indices_alloc, 00537 &indices_size, &offsets, &offsets_alloc, &offsets_size, &result ); 00538 if( iBase_SUCCESS != result ) 00539 { 00540 printf( "Failed to get indices of vertices in connectivity_test, type=%d.\n", type ); 00541 return FALSE; 00542 } 00543 00544 if( entities_alloc != entities_size ) 00545 { 00546 printf( "Number of entities didn't agree with array size in connectivity_test.\n" ); 00547 free( entities ); 00548 free( adj_ents ); 00549 free( indices ); 00550 free( offsets ); 00551 return FALSE; 00552 } 00553 00554 if( offsets_alloc != offsets_size ) 00555 { 00556 printf( "Number of offsets didn't agree with array size in connectivity_test.\n" ); 00557 free( entities ); 00558 free( adj_ents ); 00559 free( indices ); 00560 free( offsets ); 00561 return FALSE; 00562 } 00563 00564 if( indices_alloc != indices_size ) 00565 { 00566 printf( "Number of indices didn't agree with array size in connectivity_test.\n" ); 00567 free( entities ); 00568 free( adj_ents ); 00569 free( indices ); 00570 free( offsets ); 00571 return FALSE; 00572 } 00573 00574 if( adj_ents_alloc != adj_ents_size ) 00575 { 00576 printf( "Number of adjacent entities didn't agree with array size in " 00577 "connectivity_test.\n" ); 00578 free( entities ); 00579 free( adj_ents ); 00580 free( indices ); 00581 free( offsets ); 00582 return FALSE; 00583 } 00584 00585 if( offsets_size != entities_size + 1 ) 00586 { 00587 printf( "Invalid/inconsistent offset size from iMesh_getAdjEntIndices.\n" ); 00588 free( entities ); 00589 free( adj_ents ); 00590 free( indices ); 00591 free( offsets ); 00592 return FALSE; 00593 } 00594 00595 /* check that results are valid */ 00596 for( i = 0; i < entities_size; ++i ) 00597 { 00598 ASSERT( offsets[i] < offsets[i + 1] && offsets[i] < indices_size ); 00599 if( !assert_pass ) 00600 { 00601 free( entities ); 00602 free( adj_ents ); 00603 free( indices ); 00604 free( offsets ); 00605 return FALSE; 00606 } 00607 } 00608 00609 for( i = 0; i < indices_size; ++i ) 00610 { 00611 ASSERT( indices[i] >= 0 && indices[i] < adj_ents_size ); 00612 if( !assert_pass ) 00613 { 00614 free( entities ); 00615 free( adj_ents ); 00616 free( indices ); 00617 free( offsets ); 00618 return FALSE; 00619 } 00620 } 00621 00622 /* compare initial entity list against result of iMesh_getEntities */ 00623 entities2 = NULL; 00624 entities2_alloc = 0; 00625 iMesh_getEntities( mesh, root_set, type, iMesh_ALL_TOPOLOGIES, &entities2, &entities2_alloc, &entities2_size, 00626 &result ); 00627 ASSERT( iBase_SUCCESS == result ); 00628 if( !assert_pass ) 00629 { 00630 free( entities ); 00631 free( adj_ents ); 00632 free( indices ); 00633 free( offsets ); 00634 return FALSE; 00635 } 00636 00637 size = sizeof( iBase_EntityHandle ) * entities_size; 00638 sorted = (iBase_EntityHandle*)malloc( size ); 00639 memcpy( sorted, entities, size ); 00640 qsort( sorted, entities_size, sizeof( iBase_EntityHandle ), &qsort_comp_handles ); 00641 qsort( entities2, entities2_size, sizeof( iBase_EntityHandle ), &qsort_comp_handles ); 00642 00643 ASSERT( entities_size == entities2_size && !memcmp( sorted, entities2, size ) ); 00644 if( !assert_pass ) 00645 { 00646 free( entities ); 00647 free( adj_ents ); 00648 free( indices ); 00649 free( offsets ); 00650 free( entities2 ); 00651 free( sorted ); 00652 return FALSE; 00653 } 00654 00655 free( entities2 ); 00656 free( sorted ); 00657 00658 /* compare results against output of iMesh_getEntAdj */ 00659 for( i = 0; i < entities_size; ++i ) 00660 { 00661 iMesh_getEntAdj( mesh, entities[i], iBase_VERTEX, &adj_ents2_ptr, &adj_ents2_alloc, &adj_ents2_size, 00662 &result ); 00663 ASSERT( iBase_SUCCESS == result ); 00664 if( !assert_pass ) 00665 { 00666 free( entities ); 00667 free( adj_ents ); 00668 free( indices ); 00669 free( offsets ); 00670 return FALSE; 00671 } 00672 00673 ASSERT( adj_ents2_ptr == adj_ents2 ); /* shouldn't change */ 00674 if( !assert_pass ) 00675 { 00676 free( entities ); 00677 free( adj_ents ); 00678 free( indices ); 00679 free( offsets ); 00680 return FALSE; 00681 } 00682 00683 ASSERT( adj_ents2_alloc == 27 ); /* shouldn't change */ 00684 if( !assert_pass ) 00685 { 00686 free( entities ); 00687 free( adj_ents ); 00688 free( indices ); 00689 free( offsets ); 00690 return FALSE; 00691 } 00692 00693 /* compare results */ 00694 size = offsets[i + 1] - offsets[i]; 00695 ASSERT( size == adj_ents2_size ); 00696 while( --size >= 0 ) 00697 { 00698 ASSERT( adj_ents2[size] == adj_ents[indices[offsets[i] + size]] ); 00699 if( !assert_pass ) 00700 { 00701 free( entities ); 00702 free( adj_ents ); 00703 free( indices ); 00704 free( offsets ); 00705 return FALSE; 00706 } 00707 } 00708 } 00709 00710 free( entities ); 00711 free( adj_ents ); 00712 free( indices ); 00713 free( offsets ); 00714 00715 /* 00716 offsets = NULL; 00717 offsets_alloc = 0; 00718 entities = NULL; 00719 entities_alloc = 0; 00720 00721 iMesh_getAdjEntities(mesh, root_set, type, 00722 iMesh_ALL_TOPOLOGIES, iBase_VERTEX, 00723 &entities, &entities_alloc, &entities_size, 00724 &offsets, &offsets_alloc, &offsets_size, 00725 &result); 00726 if (iBase_SUCCESS != result) { 00727 printf("Failed to get indices of adjacent entity vertices in connectivity_test.\n"); 00728 return FALSE; 00729 } 00730 00731 if (entities_alloc != entities_size || 00732 offsets_alloc != offsets_size) { 00733 printf("Number of elements didn't agree with array size for an array in 00734 connectivity_test.\n"); return FALSE; 00735 } 00736 00737 free(offsets); 00738 free(entities); 00739 */ 00740 } 00741 00742 return TRUE; 00743 } 00744 00745 /*! 00746 @test 00747 TSTT entity sets sub test 00748 @li Check entity sets 00749 */ 00750 00751 /* helper function used to report errors in # sets */ 00752 int check_esets( iMesh_Instance mesh, const int num_sets ); 00753 00754 int entity_sets_subtest( iMesh_Instance mesh, int is_list, int /*num_iter*/ ) 00755 { 00756 int i, num_type = iBase_ALL_TYPES - iBase_VERTEX; 00757 // int num_all_entities_super = 0; 00758 iBase_EntitySetHandle es_array[iBase_ALL_TYPES - iBase_VERTEX]; 00759 int number_array[iBase_ALL_TYPES - iBase_VERTEX]; 00760 int ent_type = iBase_VERTEX; 00761 iBase_EntityHandle* entities = NULL; 00762 int entities_alloc = 0, entities_size; 00763 iBase_EntitySetHandle parent_child, super_set = NULL; 00764 iBase_EntitySetHandle temp_es1, temp_es2, temp_es3; 00765 iBase_EntityHandle *edges = NULL, *faces = NULL, *temp_entities1 = NULL, *temp_entities2 = NULL; 00766 int edges_alloc = 0, faces_alloc = 0, temp_entities1_alloc = 0, temp_entities2_alloc = 0; 00767 int edges_size, faces_size, temp_entities1_size, temp_entities2_size; 00768 int* types = NULL; 00769 int types_alloc = 0, types_size; 00770 int num_rest, num_regions; 00771 iBase_EntityHandle* regions = NULL; 00772 int regions_alloc = 0, regions_size; 00773 iBase_EntitySetHandle* parents = NULL; 00774 int parents_alloc = 0, parents_size, temp_numb, is_child; 00775 iBase_EntitySetHandle* es_array1 = NULL; 00776 int es_array1_alloc = 0, es_array1_size, num_super; 00777 iBase_EntityHandle* all_entities = NULL; 00778 int all_entities_alloc = 0, all_entities_size, k, l; 00779 iBase_EntityHandle* adj_faces = NULL; 00780 int adj_faces_alloc = 0, adj_faces_size; 00781 int* face_offsets = NULL; 00782 int face_offsets_alloc = 0, face_offsets_size; 00783 iBase_EntityHandle* hexes = NULL; 00784 int hexes_alloc = 0, hexes_size; 00785 iBase_EntitySetHandle hex_set; 00786 00787 /* get the number of whole mesh */ 00788 int n_whole_mesh = 0; 00789 int result; 00790 iMesh_getNumEntSets( mesh, root_set, 1, &n_whole_mesh, &result ); 00791 if( iBase_SUCCESS != result ) 00792 { 00793 printf( "Problem to get the number of all entity sets in whole mesh.\n" ); 00794 return FALSE; 00795 } 00796 00797 /* add entities to entitysets by type */ 00798 for( ; ent_type < num_type; ent_type++ ) 00799 { 00800 /* initialize the entityset */ 00801 iMesh_createEntSet( mesh, is_list, &es_array[ent_type], &result ); 00802 if( iBase_SUCCESS != result ) 00803 { 00804 printf( "Problem creating entityset.\n" ); 00805 return FALSE; 00806 } 00807 00808 /* get entities by type in total "mesh" */ 00809 entities = NULL; 00810 entities_alloc = 0; 00811 iMesh_getEntities( mesh, root_set, ent_type, iMesh_ALL_TOPOLOGIES, &entities, &entities_alloc, &entities_size, 00812 &result ); 00813 if( iBase_SUCCESS != result ) 00814 { 00815 printf( "Failed to get entities by type in entity_sets_test.\n" ); 00816 return FALSE; 00817 } 00818 00819 if( entities_alloc != entities_size ) 00820 { 00821 printf( "Number of entities didn't agree with array size in entity_sets_subtest.\n" ); 00822 free( entities ); 00823 return FALSE; 00824 } 00825 00826 /* add entities into entity set */ 00827 if( 0 != entities_size ) 00828 { 00829 iMesh_addEntArrToSet( mesh, entities, entities_size, es_array[ent_type], &result ); 00830 if( iBase_SUCCESS != result ) 00831 { 00832 printf( "Failed to add entities in entity_sets_test.\n" ); 00833 free( entities ); 00834 return FALSE; 00835 } 00836 } 00837 00838 /* Check to make sure entity set really has correct number of entities in it */ 00839 iMesh_getNumOfType( mesh, es_array[ent_type], ent_type, number_array + ent_type, &result ); 00840 00841 if( iBase_SUCCESS != result ) 00842 { 00843 printf( "Failed to get number of entities by type in entity_sets_test.\n" ); 00844 free( entities ); 00845 return FALSE; 00846 } 00847 00848 /* compare the number of entities by type */ 00849 if( number_array[ent_type] != entities_size ) 00850 { 00851 printf( "Number of entities by type is not correct\n" ); 00852 free( entities ); 00853 return FALSE; 00854 } 00855 00856 /* add to number of all entities in super set */ 00857 // num_all_entities_super += entities_size; 00858 00859 free( entities ); 00860 } 00861 00862 if( !check_esets( mesh, n_whole_mesh + num_type ) ) return FALSE; 00863 00864 /* make a super set having all entitysets */ 00865 super_set = NULL; 00866 iMesh_createEntSet( mesh, is_list, &super_set, &result ); 00867 if( iBase_SUCCESS != result ) 00868 { 00869 printf( "Failed to create a super set in entity_sets_test.\n" ); 00870 return FALSE; 00871 } 00872 00873 for( i = 0; i < num_type; i++ ) 00874 { 00875 iMesh_addEntSet( mesh, es_array[i], super_set, &result ); 00876 if( iBase_SUCCESS != result ) 00877 { 00878 printf( "Failed to add a set to a super set in entity_sets_test.\n" ); 00879 return FALSE; 00880 } 00881 } 00882 00883 if( !check_esets( mesh, n_whole_mesh + num_type + 1 ) ) return FALSE; 00884 00885 /*----------TEST intEAN OPERATIONS----------------*/ 00886 00887 iMesh_createEntSet( mesh, is_list, &temp_es1, &result ); 00888 if( iBase_SUCCESS != result ) 00889 { 00890 printf( "Failed to create a super set in entity_sets_test.\n" ); 00891 return FALSE; 00892 } 00893 00894 if( !check_esets( mesh, n_whole_mesh + num_type + 2 ) ) { return FALSE; } 00895 00896 /* Subtract */ 00897 /* add all EDGEs and FACEs to temp_es1 */ 00898 /* get all EDGE entities */ 00899 edges = NULL; 00900 edges_alloc = 0; 00901 iMesh_getEntities( mesh, es_array[iBase_EDGE], iBase_EDGE, iMesh_ALL_TOPOLOGIES, &edges, &edges_alloc, &edges_size, 00902 &result ); 00903 00904 if( iBase_SUCCESS != result ) 00905 { 00906 printf( "Failed to get edge entities in entity_sets_test.\n" ); 00907 return FALSE; 00908 } 00909 00910 /* add EDGEs to es1 */ 00911 iMesh_addEntArrToSet( mesh, edges, edges_size, temp_es1, &result ); 00912 if( iBase_SUCCESS != result ) 00913 { 00914 printf( "Failed to add edge entities in entity_sets_test.\n" ); 00915 free( edges ); 00916 return FALSE; 00917 } 00918 00919 /* get all FACE entities */ 00920 faces = NULL; 00921 faces_alloc = 0; 00922 iMesh_getEntities( mesh, es_array[iBase_FACE], iBase_FACE, iMesh_ALL_TOPOLOGIES, &faces, &faces_alloc, &faces_size, 00923 &result ); 00924 if( iBase_SUCCESS != result ) 00925 { 00926 printf( "Failed to get face entities in entity_sets_test.\n" ); 00927 free( edges ); 00928 return FALSE; 00929 } 00930 00931 /* add FACEs to es1 */ 00932 iMesh_addEntArrToSet( mesh, faces, faces_size, temp_es1, &result ); 00933 if( iBase_SUCCESS != result ) 00934 { 00935 printf( "Failed to add face entities in entity_sets_test.\n" ); 00936 free( edges ); 00937 free( faces ); 00938 return FALSE; 00939 } 00940 00941 /* subtract EDGEs */ 00942 00943 iMesh_subtract( mesh, temp_es1, es_array[iBase_EDGE], &temp_es2, &result ); 00944 if( iBase_SUCCESS != result ) 00945 { 00946 printf( "Failed to subtract entitysets in entity_sets_test.\n" ); 00947 free( edges ); 00948 free( faces ); 00949 return FALSE; 00950 } 00951 00952 temp_entities1 = NULL; 00953 temp_entities1_alloc = 0; 00954 iMesh_getEntities( mesh, temp_es2, iBase_FACE, iMesh_ALL_TOPOLOGIES, &temp_entities1, &temp_entities1_alloc, 00955 &temp_entities1_size, &result ); 00956 if( iBase_SUCCESS != result ) 00957 { 00958 printf( "Failed to get face entities in entity_sets_test.\n" ); 00959 free( edges ); 00960 free( faces ); 00961 return FALSE; 00962 } 00963 00964 if( faces_size != temp_entities1_size ) 00965 { 00966 printf( "not match number of entitysets after subtraction " 00967 "in entity_sets_test.\n" ); 00968 free( edges ); 00969 free( faces ); 00970 free( temp_entities1 ); 00971 return FALSE; 00972 } 00973 00974 /* check there's nothing but faces in face_es */ 00975 types = NULL; 00976 types_alloc = 0; 00977 iMesh_getEntArrType( mesh, temp_entities1, temp_entities1_size, &types, &types_alloc, &types_size, &result ); 00978 if( iBase_SUCCESS != result ) 00979 { 00980 printf( "Failed to get types of entities in entity_sets_test.\n" ); 00981 free( edges ); 00982 free( faces ); 00983 free( temp_entities1 ); 00984 return FALSE; 00985 } 00986 for( i = 0; i < types_size; i++ ) 00987 { 00988 if( types[i] != iBase_FACE ) 00989 { 00990 printf( "wrong entity type for face test in entity_sets_test.\n" ); 00991 free( edges ); 00992 free( faces ); 00993 free( temp_entities1 ); 00994 free( types ); 00995 return FALSE; 00996 } 00997 } 00998 00999 iMesh_destroyEntSet( mesh, temp_es2, &result ); 01000 if( iBase_SUCCESS != result ) 01001 { 01002 printf( "Failed to destroy temp es2.\n" ); 01003 free( edges ); 01004 free( faces ); 01005 free( temp_entities1 ); 01006 free( types ); 01007 return FALSE; 01008 } 01009 01010 if( !check_esets( mesh, n_whole_mesh + num_type + 2 ) ) 01011 { 01012 free( edges ); 01013 free( faces ); 01014 free( temp_entities1 ); 01015 free( types ); 01016 return FALSE; 01017 } 01018 01019 /*------------Intersect------------ */ 01020 01021 /* clean out the temp_ms1 */ 01022 iMesh_rmvEntArrFromSet( mesh, faces, faces_size, temp_es1, &result ); 01023 if( iBase_SUCCESS != result ) 01024 { 01025 printf( "Failed to remove face entities in entity_sets_test.\n" ); 01026 free( edges ); 01027 free( faces ); 01028 free( temp_entities1 ); 01029 free( types ); 01030 return FALSE; 01031 } 01032 01033 /* check if it is really cleaned out */ 01034 iMesh_getNumOfType( mesh, temp_es1, iBase_FACE, &num_rest, &result ); 01035 if( iBase_SUCCESS != result ) 01036 { 01037 printf( "Failed to get number of entities by type in entity_sets_test.\n" ); 01038 free( edges ); 01039 free( faces ); 01040 free( temp_entities1 ); 01041 free( types ); 01042 return FALSE; 01043 } 01044 01045 if( num_rest != 0 ) 01046 { 01047 printf( "failed to remove correctly.\n" ); 01048 free( edges ); 01049 free( faces ); 01050 free( temp_entities1 ); 01051 free( types ); 01052 return FALSE; 01053 } 01054 01055 /* add EDGEs to temp es1 */ 01056 iMesh_addEntArrToSet( mesh, edges, edges_size, temp_es1, &result ); 01057 if( iBase_SUCCESS != result ) 01058 { 01059 printf( "Failed to add edge entities in entity_sets_test.\n" ); 01060 free( edges ); 01061 free( faces ); 01062 free( temp_entities1 ); 01063 free( types ); 01064 return FALSE; 01065 } 01066 01067 /* add FACEs to temp es1 */ 01068 iMesh_addEntArrToSet( mesh, faces, faces_size, temp_es1, &result ); 01069 if( iBase_SUCCESS != result ) 01070 { 01071 printf( "Failed to add edge entities in entity_sets_test.\n" ); 01072 free( edges ); 01073 free( faces ); 01074 free( temp_entities1 ); 01075 free( types ); 01076 return FALSE; 01077 } 01078 01079 /* intersect temp_es1 with edges meshset */ 01080 /* temp_ms1 entityset is altered */ 01081 iMesh_intersect( mesh, temp_es1, es_array[iBase_EDGE], &temp_es2, &result ); 01082 if( iBase_SUCCESS != result ) 01083 { 01084 printf( "Failed to intersect in entity_sets_test.\n" ); 01085 free( edges ); 01086 free( faces ); 01087 free( temp_entities1 ); 01088 free( types ); 01089 return FALSE; 01090 } 01091 01092 temp_entities2 = NULL; 01093 temp_entities2_alloc = 0; 01094 iMesh_getEntities( mesh, temp_es2, iBase_FACE, iMesh_ALL_TOPOLOGIES, &temp_entities2, &temp_entities2_alloc, 01095 &temp_entities2_size, &result ); 01096 if( iBase_SUCCESS != result ) 01097 { 01098 printf( "Failed to get face entities in entity_sets_test.\n" ); 01099 free( edges ); 01100 free( faces ); 01101 free( temp_entities1 ); 01102 free( types ); 01103 return FALSE; 01104 } 01105 01106 if( temp_entities2_size != 0 ) 01107 { 01108 printf( "wrong number of faces.\n" ); 01109 free( edges ); 01110 free( faces ); 01111 free( temp_entities1 ); 01112 free( temp_entities2 ); 01113 free( types ); 01114 return FALSE; 01115 } 01116 01117 iMesh_destroyEntSet( mesh, temp_es2, &result ); 01118 if( iBase_SUCCESS != result ) 01119 { 01120 printf( "Failed to destroy temp es2.\n" ); 01121 free( edges ); 01122 free( faces ); 01123 free( temp_entities1 ); 01124 free( temp_entities2 ); 01125 free( types ); 01126 return FALSE; 01127 } 01128 01129 if( !check_esets( mesh, n_whole_mesh + num_type + 2 ) ) 01130 { 01131 free( edges ); 01132 free( faces ); 01133 free( temp_entities1 ); 01134 free( temp_entities2 ); 01135 free( types ); 01136 return FALSE; 01137 } 01138 01139 /*-------------Unite-------------- */ 01140 01141 iMesh_createEntSet( mesh, is_list, &temp_es2, &result ); 01142 if( iBase_SUCCESS != result ) 01143 { 01144 printf( "Failed to create a temp entityset in entity_sets_test.\n" ); 01145 free( edges ); 01146 free( faces ); 01147 free( temp_entities1 ); 01148 free( temp_entities2 ); 01149 free( types ); 01150 return FALSE; 01151 } 01152 01153 /* get all regions */ 01154 regions = NULL; 01155 regions_alloc = 0; 01156 iMesh_getEntities( mesh, es_array[iBase_REGION], iBase_REGION, iMesh_ALL_TOPOLOGIES, ®ions, ®ions_alloc, 01157 ®ions_size, &result ); 01158 if( iBase_SUCCESS != result ) 01159 { 01160 printf( "Failed to get region entities in entity_sets_test.\n" ); 01161 free( edges ); 01162 free( faces ); 01163 free( temp_entities1 ); 01164 free( temp_entities2 ); 01165 free( types ); 01166 return FALSE; 01167 } 01168 01169 /* add REGIONs to temp es2 */ 01170 iMesh_addEntArrToSet( mesh, regions, regions_size, temp_es2, &result ); 01171 if( iBase_SUCCESS != result ) 01172 { 01173 printf( "Failed to add region entities in entity_sets_test.\n" ); 01174 free( edges ); 01175 free( faces ); 01176 free( temp_entities1 ); 01177 free( temp_entities2 ); 01178 free( types ); 01179 free( regions ); 01180 return FALSE; 01181 } 01182 01183 /* unite temp_es1 and temp_es2 */ 01184 iMesh_unite( mesh, temp_es1, temp_es2, &temp_es3, &result ); 01185 if( iBase_SUCCESS != result ) 01186 { 01187 printf( "Failed to unite in entity_sets_test.\n" ); 01188 free( edges ); 01189 free( faces ); 01190 free( temp_entities1 ); 01191 free( temp_entities2 ); 01192 free( types ); 01193 free( regions ); 01194 return FALSE; 01195 } 01196 01197 /* perform the check */ 01198 iMesh_getNumOfType( mesh, temp_es3, iBase_REGION, &num_regions, &result ); 01199 if( iBase_SUCCESS != result ) 01200 { 01201 printf( "Failed to get number of region entities by type in entity_sets_test.\n" ); 01202 free( edges ); 01203 free( faces ); 01204 free( temp_entities1 ); 01205 free( temp_entities2 ); 01206 free( types ); 01207 free( regions ); 01208 return FALSE; 01209 } 01210 01211 if( num_regions != number_array[iBase_REGION] ) 01212 { 01213 printf( "different number of regions in entity_sets_test.\n" ); 01214 free( edges ); 01215 free( faces ); 01216 free( temp_entities1 ); 01217 free( temp_entities2 ); 01218 free( types ); 01219 free( regions ); 01220 return FALSE; 01221 } 01222 01223 if( !check_esets( mesh, n_whole_mesh + num_type + 4 ) ) 01224 { 01225 free( edges ); 01226 free( faces ); 01227 free( temp_entities1 ); 01228 free( temp_entities2 ); 01229 free( types ); 01230 free( regions ); 01231 return FALSE; 01232 } 01233 01234 /*--------Test parent/child stuff in entiysets----------- */ 01235 01236 /* Add 2 meshsets as children to another */ 01237 iMesh_createEntSet( mesh, is_list, &parent_child, &result ); 01238 if( iBase_SUCCESS != result ) 01239 { 01240 printf( "Problem creating entityset in entity_sets_test.\n" ); 01241 free( edges ); 01242 free( faces ); 01243 free( temp_entities1 ); 01244 free( temp_entities2 ); 01245 free( types ); 01246 free( regions ); 01247 return FALSE; 01248 } 01249 01250 iMesh_addPrntChld( mesh, es_array[iBase_VERTEX], parent_child, &result ); 01251 if( iBase_SUCCESS != result ) 01252 { 01253 printf( "Problem add parent in entity_sets_test.\n" ); 01254 free( edges ); 01255 free( faces ); 01256 free( temp_entities1 ); 01257 free( temp_entities2 ); 01258 free( types ); 01259 free( regions ); 01260 return FALSE; 01261 } 01262 01263 /* check if parent is really added */ 01264 parents = NULL; 01265 parents_alloc = 0; 01266 iMesh_getPrnts( mesh, parent_child, 0, &parents, &parents_alloc, &parents_size, &result ); 01267 if( iBase_SUCCESS != result ) 01268 { 01269 printf( "Problem getting parents in entity_sets_test.\n" ); 01270 free( edges ); 01271 free( faces ); 01272 free( temp_entities1 ); 01273 free( temp_entities2 ); 01274 free( types ); 01275 free( regions ); 01276 return FALSE; 01277 } 01278 01279 if( parents_size != 1 ) 01280 { 01281 printf( "number of parents is not correct in entity_sets_test.\n" ); 01282 free( edges ); 01283 free( faces ); 01284 free( temp_entities1 ); 01285 free( temp_entities2 ); 01286 free( types ); 01287 free( regions ); 01288 free( parents ); 01289 return FALSE; 01290 } 01291 01292 /* get the number of child entitysets */ 01293 iMesh_getNumChld( mesh, es_array[iBase_VERTEX], 0, &temp_numb, &result ); 01294 if( iBase_SUCCESS != result ) 01295 { 01296 printf( "Problem getting number of children in entity_sets_test.\n" ); 01297 free( edges ); 01298 free( faces ); 01299 free( temp_entities1 ); 01300 free( temp_entities2 ); 01301 free( types ); 01302 free( regions ); 01303 free( parents ); 01304 return FALSE; 01305 } 01306 01307 if( temp_numb != 1 ) 01308 { 01309 printf( "number of children is not correct in entity_sets_test.\n" ); 01310 free( edges ); 01311 free( faces ); 01312 free( temp_entities1 ); 01313 free( temp_entities2 ); 01314 free( types ); 01315 free( regions ); 01316 free( parents ); 01317 return FALSE; 01318 } 01319 01320 /* parent_child and es_array[iBase_VERTEX] should be related */ 01321 is_child = 0; 01322 iMesh_isChildOf( mesh, es_array[iBase_VERTEX], parent_child, &is_child, &result ); 01323 if( iBase_SUCCESS != result ) 01324 { 01325 printf( "Problem checking relation in entity_sets_test.\n" ); 01326 free( edges ); 01327 free( faces ); 01328 free( temp_entities1 ); 01329 free( temp_entities2 ); 01330 free( types ); 01331 free( regions ); 01332 free( parents ); 01333 return FALSE; 01334 } 01335 if( !is_child ) 01336 { 01337 printf( "parent_child and es_array[iBase_VERTEX] should be related\n" ); 01338 free( edges ); 01339 free( faces ); 01340 free( temp_entities1 ); 01341 free( temp_entities2 ); 01342 free( types ); 01343 free( regions ); 01344 free( parents ); 01345 return FALSE; 01346 } 01347 01348 /* es_array[iBase_FACE] and es_array[iBase_REGION] are not related */ 01349 is_child = FALSE; 01350 iMesh_isChildOf( mesh, es_array[iBase_FACE], es_array[iBase_REGION], &is_child, &result ); 01351 if( iBase_SUCCESS != result ) 01352 { 01353 printf( "Problem checking relation in entity_sets_test.\n" ); 01354 free( edges ); 01355 free( faces ); 01356 free( temp_entities1 ); 01357 free( temp_entities2 ); 01358 free( types ); 01359 free( regions ); 01360 free( parents ); 01361 return FALSE; 01362 } 01363 if( is_child ) 01364 { 01365 printf( "es_array[iBase_REGION] and es_array[iBase_FACE] should not be related\n" ); 01366 free( edges ); 01367 free( faces ); 01368 free( temp_entities1 ); 01369 free( temp_entities2 ); 01370 free( types ); 01371 free( regions ); 01372 free( parents ); 01373 return FALSE; 01374 } 01375 01376 if( !check_esets( mesh, n_whole_mesh + num_type + 5 ) ) 01377 { 01378 free( edges ); 01379 free( faces ); 01380 free( temp_entities1 ); 01381 free( temp_entities2 ); 01382 free( types ); 01383 free( regions ); 01384 free( parents ); 01385 return FALSE; 01386 } 01387 01388 /*--------test modify and query functions----------------------------- */ 01389 01390 /* get all entity sets in super set */ 01391 es_array1 = NULL; 01392 es_array1_alloc = 0; 01393 iMesh_getEntSets( mesh, super_set, 0, &es_array1, &es_array1_alloc, &es_array1_size, &result ); 01394 if( iBase_SUCCESS != result ) 01395 { 01396 printf( "Problem to get entity sets in super set.\n" ); 01397 free( edges ); 01398 free( faces ); 01399 free( temp_entities1 ); 01400 free( temp_entities2 ); 01401 free( types ); 01402 free( regions ); 01403 free( parents ); 01404 return FALSE; 01405 } 01406 01407 /* get the number of entity sets in super set */ 01408 iMesh_getNumEntSets( mesh, super_set, 0, &num_super, &result ); 01409 if( iBase_SUCCESS != result ) 01410 { 01411 printf( "Problem to get the number of all entity sets in super set.\n" ); 01412 free( edges ); 01413 free( faces ); 01414 free( temp_entities1 ); 01415 free( temp_entities2 ); 01416 free( types ); 01417 free( regions ); 01418 free( parents ); 01419 free( es_array1 ); 01420 return FALSE; 01421 } 01422 01423 /* the number of entity sets in super set should be same */ 01424 if( num_super != es_array1_size ) 01425 { 01426 printf( "the number of entity sets in super set should be same.\n" ); 01427 return FALSE; 01428 } 01429 01430 /* get all entities in super set */ 01431 all_entities = NULL; 01432 all_entities_alloc = 0; 01433 iMesh_getEntities( mesh, super_set, iBase_ALL_TYPES, iMesh_ALL_TOPOLOGIES, &all_entities, &all_entities_alloc, 01434 &all_entities_size, &result ); 01435 if( iBase_SUCCESS != result ) 01436 { 01437 printf( "Problem to get all entities in super set.\n" ); 01438 free( edges ); 01439 free( faces ); 01440 free( temp_entities1 ); 01441 free( temp_entities2 ); 01442 free( types ); 01443 free( regions ); 01444 free( parents ); 01445 free( es_array1 ); 01446 return FALSE; 01447 } 01448 01449 /* compare the number of all entities in super set */ 01450 /* NOTE: TEST COMMENTED OUT UNTIL RESOLUTION OF WHETHER GETENTITIES */ 01451 /* SHOULD GET A NUM_HOPS ARGUMENT */ 01452 /* if (num_all_entities_super != all_entities_size) { */ 01453 /* printf("number of all entities in super set should be same.\n"); */ 01454 /* return FALSE; */ 01455 /* } */ 01456 01457 /* test add, remove and get all entity sets using super set */ 01458 /* check GetAllEntitySets works recursively and dosen't return */ 01459 /* multi sets */ 01460 for( k = 0; k < num_super; k++ ) 01461 { 01462 /* add entity sets of super set to each entity set of super set */ 01463 /* make multiple child super sets */ 01464 iBase_EntitySetHandle es_k = es_array1[k]; 01465 for( l = 0; l < es_array1_size; l++ ) 01466 { 01467 iMesh_addEntSet( mesh, es_array1[l], es_k, &result ); 01468 if( iBase_SUCCESS != result ) 01469 { 01470 printf( "Problem to add entity set to entityset.\n" ); 01471 free( edges ); 01472 free( faces ); 01473 free( temp_entities1 ); 01474 free( temp_entities2 ); 01475 free( types ); 01476 free( regions ); 01477 free( parents ); 01478 free( es_array1 ); 01479 free( all_entities ); 01480 return FALSE; 01481 } 01482 } 01483 01484 /* add super set to each entity set */ 01485 iMesh_addEntSet( mesh, super_set, es_k, &result ); 01486 if( iBase_SUCCESS != result ) 01487 { 01488 printf( "Problem to add super set to entitysets.\n" ); 01489 free( edges ); 01490 free( faces ); 01491 free( temp_entities1 ); 01492 free( temp_entities2 ); 01493 free( types ); 01494 free( regions ); 01495 free( parents ); 01496 free( es_array1 ); 01497 free( all_entities ); 01498 return FALSE; 01499 } 01500 01501 /* add one entity sets multiple times */ 01502 for( l = 0; l < 3; l++ ) 01503 { 01504 iMesh_addEntSet( mesh, temp_es1, es_k, &result ); 01505 if( iBase_SUCCESS != result ) 01506 { 01507 printf( "Problem to add temp set to entitysets.\n" ); 01508 free( edges ); 01509 free( faces ); 01510 free( temp_entities1 ); 01511 free( temp_entities2 ); 01512 free( types ); 01513 free( regions ); 01514 free( parents ); 01515 free( es_array1 ); 01516 free( all_entities ); 01517 return FALSE; 01518 } 01519 } 01520 } 01521 01522 /* get all hexes and get faces of that hexes */ 01523 hexes = NULL; 01524 hexes_alloc = 0; 01525 01526 iMesh_getEntities( mesh, root_set, iBase_ALL_TYPES, iMesh_HEXAHEDRON, &hexes, &hexes_alloc, &hexes_size, &result ); 01527 if( iBase_SUCCESS != result ) 01528 { 01529 printf( "Failed to get hexes in entity_sets_test.\n" ); 01530 free( edges ); 01531 free( faces ); 01532 free( temp_entities1 ); 01533 free( temp_entities2 ); 01534 free( types ); 01535 free( regions ); 01536 free( parents ); 01537 free( es_array1 ); 01538 free( all_entities ); 01539 return FALSE; 01540 } 01541 01542 /* get adjacent face of hexes */ 01543 adj_faces = NULL; 01544 adj_faces_alloc = 0; 01545 face_offsets = NULL; 01546 face_offsets_alloc = 0; 01547 01548 iMesh_getEntArrAdj( mesh, hexes, hexes_size, iBase_FACE, &adj_faces, &adj_faces_alloc, &adj_faces_size, 01549 &face_offsets, &face_offsets_alloc, &face_offsets_size, &result ); 01550 if( iBase_SUCCESS != result ) 01551 { 01552 printf( "Problem to get adjacent entities in entitysets_test.\n" ); 01553 free( edges ); 01554 free( faces ); 01555 free( temp_entities1 ); 01556 free( temp_entities2 ); 01557 free( types ); 01558 free( regions ); 01559 free( parents ); 01560 free( es_array1 ); 01561 free( all_entities ); 01562 free( hexes ); 01563 return FALSE; 01564 } 01565 01566 iMesh_createEntSet( mesh, FALSE, &hex_set, &result ); 01567 if( iBase_SUCCESS != result ) 01568 { 01569 printf( "Problem creating entityset in entity_sets_test.\n" ); 01570 free( edges ); 01571 free( faces ); 01572 free( temp_entities1 ); 01573 free( temp_entities2 ); 01574 free( types ); 01575 free( regions ); 01576 free( parents ); 01577 free( es_array1 ); 01578 free( all_entities ); 01579 free( hexes ); 01580 free( adj_faces ); 01581 free( face_offsets ); 01582 return FALSE; 01583 } 01584 01585 iMesh_addEntArrToSet( mesh, hexes, hexes_size, hex_set, &result ); 01586 if( iBase_SUCCESS != result ) 01587 { 01588 printf( "Failed to add hexes in entity_sets_test.\n" ); 01589 free( edges ); 01590 free( faces ); 01591 free( temp_entities1 ); 01592 free( temp_entities2 ); 01593 free( types ); 01594 free( regions ); 01595 free( parents ); 01596 free( es_array1 ); 01597 free( all_entities ); 01598 free( hexes ); 01599 free( adj_faces ); 01600 free( face_offsets ); 01601 return FALSE; 01602 } 01603 01604 free( edges ); 01605 free( faces ); 01606 free( temp_entities1 ); 01607 free( temp_entities2 ); 01608 free( types ); 01609 free( regions ); 01610 free( parents ); 01611 free( es_array1 ); 01612 free( all_entities ); 01613 free( hexes ); 01614 free( adj_faces ); 01615 free( face_offsets ); 01616 01617 return TRUE; 01618 } 01619 01620 int check_esets( iMesh_Instance mesh, const int num_sets ) 01621 { 01622 int entity_sets_size; 01623 01624 int result; 01625 iMesh_getNumEntSets( mesh, root_set, 1, &entity_sets_size, &result ); 01626 if( iBase_SUCCESS != result ) 01627 { 01628 printf( "Problem to get all entity sets in mesh.\n" ); 01629 return FALSE; 01630 } 01631 if( entity_sets_size != num_sets ) 01632 { 01633 printf( "the number of entity sets in whole mesh should be %d" 01634 ", actual number is %d.\n", 01635 num_sets, entity_sets_size ); 01636 return FALSE; 01637 } 01638 01639 return TRUE; 01640 } 01641 01642 /*! 01643 @test 01644 TSTT entity sets Test 01645 @li Check entity sets 01646 */ 01647 int entity_sets_test( iMesh_Instance mesh ) 01648 { 01649 int iter_num = 0, result; 01650 /* check */ 01651 int i; 01652 for( i = 0; i < 2; i++ ) 01653 { 01654 iter_num++; 01655 01656 result = entity_sets_subtest( mesh, i, iter_num ); 01657 if( !result ) return result; 01658 } 01659 01660 return TRUE; 01661 } 01662 01663 /*! 01664 @test 01665 Vertex Coordinates 01666 @li Get coordinates of vertices by 2 different methods then compare them 01667 */ 01668 int vertex_coordinates_test( iMesh_Instance mesh ) 01669 { 01670 iBase_EntityHandle* verts = NULL; 01671 int verts_alloc = 0, verts_size; 01672 double* vert_coords = NULL; 01673 int vert_coords_alloc = 0, vert_coords_size; 01674 01675 /* check storage order */ 01676 int result; 01677 int this_order; 01678 iMesh_getDfltStorage( mesh, &this_order, &result ); 01679 if( iBase_SUCCESS != result ) 01680 { 01681 printf( "failed to get preferred storage order in vertex_coordinates_test.\n" ); 01682 return FALSE; 01683 } 01684 01685 /* now get the vertex coordinates from a vertex array */ 01686 /* need to get the vertices in the model */ 01687 verts = NULL; 01688 verts_alloc = 0; 01689 iMesh_getEntities( mesh, root_set, iBase_VERTEX, iMesh_POINT, &verts, &verts_alloc, &verts_size, &result ); 01690 if( iBase_SUCCESS != result ) 01691 { 01692 printf( "failed to get entities in vertex_coordinates_test.\n" ); 01693 return FALSE; 01694 } 01695 01696 /* get the coordinates in one array */ 01697 vert_coords = NULL; 01698 vert_coords_alloc = 0; 01699 01700 iMesh_getVtxArrCoords( mesh, verts, verts_size, iBase_INTERLEAVED, &vert_coords, &vert_coords_alloc, 01701 &vert_coords_size, &result ); 01702 if( iBase_SUCCESS != result ) 01703 { 01704 printf( "failed to get vertex cooridinate of entities in vertex_coordinates_test.\n" ); 01705 free( verts ); 01706 return FALSE; 01707 } 01708 01709 free( verts ); 01710 free( vert_coords ); 01711 01712 /* if we get here, this test was successful */ 01713 return TRUE; 01714 } 01715 01716 /*! 01717 @test 01718 TSTT Tag Info test 01719 @li Tests tagCreate, tagDelete, tagGetName, tagGetSize, tagGetHandle 01720 */ 01721 int tag_info_test( iMesh_Instance mesh ) 01722 { 01723 char dum_name[120]; 01724 int dum_name_size = 120; 01725 int dum_size; 01726 int error = FALSE; 01727 iBase_TagHandle dum_handle; 01728 /* Create a tag */ 01729 int result; 01730 iBase_TagHandle tag_handle = NULL; 01731 const char* tag_name = "int_tag"; 01732 int tag_name_size = 8; 01733 iMesh_createTag( mesh, tag_name, 1, iBase_INTEGER, &tag_handle, &result, tag_name_size ); 01734 if( iBase_SUCCESS != result ) 01735 { 01736 printf( "Failed to create tag int_tag in vertex_tag_test." ); 01737 return FALSE; 01738 } 01739 01740 /* check tag info functions */ 01741 iMesh_getTagName( mesh, tag_handle, dum_name, &result, dum_name_size ); 01742 if( iBase_SUCCESS != result ) 01743 { 01744 printf( "Couldn't get name of tag just created.\n" ); 01745 return FALSE; 01746 } 01747 if( strcmp( dum_name, "int_tag" ) != 0 ) 01748 { 01749 printf( "Tag names didn't match.\n" ); 01750 return FALSE; 01751 } 01752 01753 iMesh_getTagSizeBytes( mesh, tag_handle, &dum_size, &result ); 01754 if( iBase_SUCCESS != result ) 01755 { 01756 printf( "Couldn't get size of tag just created.\n" ); 01757 return FALSE; 01758 } 01759 if( dum_size != sizeof( int ) ) 01760 { 01761 printf( "Tag sizes didn't match.\n" ); 01762 return FALSE; 01763 } 01764 01765 iMesh_getTagHandle( mesh, tag_name, &dum_handle, &result, tag_name_size ); 01766 if( iBase_SUCCESS != result ) 01767 { 01768 printf( "Couldn't get handle of tag just created.\n" ); 01769 return FALSE; 01770 } 01771 if( dum_handle != tag_handle ) 01772 { 01773 printf( "Tag handles didn't match.\n" ); 01774 return FALSE; 01775 } 01776 01777 /* test non-forced version of tagDelete; forced version tested later, */ 01778 /* when we have entities around */ 01779 iMesh_destroyTag( mesh, tag_handle, FALSE, &result ); 01780 if( iBase_SUCCESS != result ) 01781 { 01782 printf( "Couldn't delete tag just created.\n" ); 01783 return FALSE; 01784 } 01785 01786 /* look for that tag, to make sure it got deleted */ 01787 iMesh_getTagHandle( mesh, tag_name, &tag_handle, &result, tag_name_size ); 01788 if( iBase_SUCCESS != result ) { error = TRUE; } 01789 if( !error ) 01790 { 01791 printf( "tagGetHandle was able to find handle for deleted tag.\n" ); 01792 return FALSE; 01793 } 01794 01795 return TRUE; 01796 } 01797 01798 int vertex_int_tag_test( iMesh_Instance mesh, iBase_EntityHandle* verts, int /*verts_size*/, iBase_TagHandle* int_tag ) 01799 { 01800 int result; 01801 iBase_EntityHandle dum_vert = verts[0]; 01802 01803 int dum_val = 11, dum_val2; 01804 void* dum_val2_ptr = &dum_val2; 01805 int dum_val2_alloc = sizeof( int ), dum_val2_size; 01806 01807 /* create a tag */ 01808 const char* tag_name = "int_tag"; 01809 int tag_name_size = 8; 01810 iMesh_createTag( mesh, tag_name, 1, iBase_INTEGER, int_tag, &result, tag_name_size ); 01811 if( iBase_SUCCESS != result ) 01812 { 01813 printf( "Failed to create tag int_tag in vertex_int_tag_test.\n" ); 01814 return FALSE; 01815 } 01816 01817 /* put a value in the first vertex and retrieve */ 01818 iMesh_setArrData( mesh, &dum_vert, 1, *int_tag, (const char*)( &dum_val ), sizeof( int ), &result ); 01819 if( iBase_SUCCESS != result ) 01820 { 01821 printf( "Failed to set int tag (val=11) in vertex_int_tag_test.\n" ); 01822 return FALSE; 01823 } 01824 01825 iMesh_getArrData( mesh, &dum_vert, 1, *int_tag, &dum_val2_ptr, &dum_val2_alloc, &dum_val2_size, &result ); 01826 if( iBase_SUCCESS != result || dum_val2 != 11 ) 01827 { 01828 printf( "Failed to get int tag (val=11) in vertex_int_tag_test.\n" ); 01829 return FALSE; 01830 } 01831 01832 if( dum_val2 != 11 ) 01833 { 01834 01835 printf( "Value of vertex tag (val=11) wrong.\n" ); 01836 return FALSE; 01837 } 01838 01839 /* put a value in the last vertex and retrieve */ 01840 dum_val = 12; 01841 01842 iMesh_setArrData( mesh, &dum_vert, 1, *int_tag, (char*)( &dum_val ), sizeof( int ), &result ); 01843 if( iBase_SUCCESS != result ) 01844 { 01845 printf( "Failed to set int tag (val=12) in vertex_int_tag_test.\n" ); 01846 return FALSE; 01847 } 01848 01849 iMesh_getArrData( mesh, &dum_vert, 1, *int_tag, &dum_val2_ptr, &dum_val2_alloc, &dum_val2_size, &result ); 01850 if( iBase_SUCCESS != result ) 01851 { 01852 printf( "Failed to get int tag (val=12) in vertex_int_tag_test.\n" ); 01853 return FALSE; 01854 } 01855 01856 if( dum_val2 != 12 ) 01857 { 01858 01859 printf( "Value of vertex tag (val=12) wrong.\n" ); 01860 return FALSE; 01861 } 01862 01863 /* ok, the int tag test worked */ 01864 return TRUE; 01865 } 01866 01867 int vertex_double_tag_test( iMesh_Instance mesh, iBase_EntityHandle* verts, int /*verts_size*/, 01868 iBase_TagHandle* double_tag ) 01869 { 01870 int result; 01871 01872 iBase_EntityHandle dum_vert = verts[0]; 01873 double dum_val = 1.0e6, dum_val2; 01874 void* dum_val2_ptr = &dum_val2; 01875 int dum_val2_alloc = sizeof( double ), dum_val2_size; 01876 01877 /* create a tag */ 01878 const char* tag_name = "double_tag"; 01879 int tag_name_size = 11; 01880 iMesh_createTag( mesh, tag_name, 1, iBase_DOUBLE, double_tag, &result, tag_name_size ); 01881 if( iBase_SUCCESS != result ) 01882 { 01883 printf( "Failed to create tag double_tag in vertex_double_tag_test.\n" ); 01884 return FALSE; 01885 } 01886 01887 /* put a value in the first vertex and retrieve */ 01888 iMesh_setArrData( mesh, &dum_vert, 1, *double_tag, (char*)( &dum_val ), sizeof( double ), &result ); 01889 if( iBase_SUCCESS != result ) 01890 { 01891 printf( "Failed to set double tag (val=1.0e6) in vertex_double_tag_test.\n" ); 01892 return FALSE; 01893 } 01894 01895 iMesh_getArrData( mesh, &dum_vert, 1, *double_tag, &dum_val2_ptr, &dum_val2_alloc, &dum_val2_size, &result ); 01896 if( iBase_SUCCESS != result ) 01897 { 01898 printf( "Failed to get double tag (val=1.0e6) in vertex_double_tag_test.\n" ); 01899 return FALSE; 01900 } 01901 01902 if( dum_val2 != 1.0e6 ) 01903 { 01904 printf( "Value of vertex tag (val=1.0e6) wrong.\n" ); 01905 return FALSE; 01906 } 01907 01908 /* put a value in the last vertex and retrieve */ 01909 dum_val = 2.0e9; 01910 01911 iMesh_setArrData( mesh, &dum_vert, 1, *double_tag, (char*)( &dum_val ), sizeof( double ), &result ); 01912 if( iBase_SUCCESS != result ) 01913 { 01914 printf( "Failed to set double tag (val=2.0e9) in vertex_double_tag_test.\n" ); 01915 return FALSE; 01916 } 01917 01918 iMesh_getArrData( mesh, &dum_vert, 1, *double_tag, &dum_val2_ptr, &dum_val2_alloc, &dum_val2_size, &result ); 01919 if( iBase_SUCCESS != result ) 01920 { 01921 printf( "Failed to get double tag (val=2.0e9) in vertex_double_tag_test.\n" ); 01922 return FALSE; 01923 } 01924 01925 if( dum_val2 != 2.0e9 ) 01926 { 01927 printf( "Value of vertex tag (val=2.0e9) wrong.\n" ); 01928 return FALSE; 01929 } 01930 01931 /* ok, the double tag test worked */ 01932 return TRUE; 01933 } 01934 01935 /* Add a struct Vertex Tag to the database */ 01936 struct TagStruct 01937 { 01938 double test_double; 01939 int test_int1, test_int2; 01940 }; 01941 01942 int vertex_struct_tag_test( iMesh_Instance mesh, iBase_EntityHandle* verts, int /*verts_size*/, 01943 iBase_TagHandle* struct_tag ) 01944 { 01945 int result; 01946 iBase_EntityHandle dum_vert = verts[0]; 01947 struct TagStruct dum_struct = { 3.0e12, 2, 3 }, dum_struct2; 01948 void* dum_struct2_ptr = &dum_struct2; 01949 int dum_struct_alloc = sizeof( struct TagStruct ), dum_struct_size; 01950 01951 /* create a tag */ 01952 const char* tag_name = "struct_tag"; 01953 int tag_name_size = 11; 01954 iMesh_createTag( mesh, tag_name, sizeof( struct TagStruct ), iBase_BYTES, struct_tag, &result, tag_name_size ); 01955 if( iBase_SUCCESS != result ) 01956 { 01957 printf( "Failed to create tag struct_tag in vertex_struct_tag_test.\n" ); 01958 return FALSE; 01959 } 01960 01961 /* put a value in the first vertex and retrieve */ 01962 01963 /* careful setting the value, since tags are opaque */ 01964 iMesh_setArrData( mesh, &dum_vert, 1, *struct_tag, (const char*)&dum_struct, sizeof( struct TagStruct ), &result ); 01965 if( iBase_SUCCESS != result ) 01966 { 01967 printf( "Failed to set struct tag in vertex_struct_tag_test.\n" ); 01968 return FALSE; 01969 } 01970 01971 iMesh_getArrData( mesh, &dum_vert, 1, *struct_tag, &dum_struct2_ptr, &dum_struct_alloc, &dum_struct_size, &result ); 01972 if( iBase_SUCCESS != result ) 01973 { 01974 printf( "Failed to get struct tag in vertex_struct_tag_test.\n" ); 01975 return FALSE; 01976 } 01977 01978 if( dum_struct_size != sizeof( struct TagStruct ) ) 01979 { 01980 printf( "Size of vertex struct tag wrong.\n" ); 01981 return FALSE; 01982 } 01983 if( dum_struct2.test_int1 != dum_struct.test_int1 || dum_struct2.test_int2 != dum_struct.test_int2 || 01984 dum_struct2.test_double != dum_struct.test_double ) 01985 { 01986 printf( "Value of vertex struct tag wrong.\n" ); 01987 return FALSE; 01988 } 01989 01990 /* ok, the int tag test worked */ 01991 return TRUE; 01992 } 01993 01994 int vertex_tag_delete_test( iMesh_Instance mesh, iBase_EntityHandle* verts, int /*verts_size*/ ) 01995 { 01996 int result; 01997 int delete_err = FALSE; 01998 01999 /* test forced, unforced deletion of tags from entities */ 02000 02001 /* test getAlliBase_TagHandles for first entity */ 02002 iBase_TagHandle* all_tags = NULL; 02003 iBase_EntityHandle dum_entity = verts[0]; 02004 int all_tags_alloc = 0, all_tags_size; 02005 iMesh_getAllTags( mesh, verts[0], &all_tags, &all_tags_alloc, &all_tags_size, &result ); 02006 if( iBase_SUCCESS != result ) 02007 { 02008 printf( "Couldn't get all tag handles from vertex.\n" ); 02009 return FALSE; 02010 } 02011 02012 iMesh_rmvArrTag( mesh, &dum_entity, 1, all_tags[0], &result ); 02013 if( iBase_SUCCESS != result ) 02014 { 02015 printf( "Couldn't remove tag from vertex.\n" ); 02016 free( all_tags ); 02017 return FALSE; 02018 } 02019 02020 iMesh_destroyTag( mesh, all_tags[1], FALSE, &result ); 02021 if( iBase_SUCCESS != result ) { delete_err = TRUE; } 02022 if( !delete_err ) 02023 { 02024 printf( "Error when unforced-deleting tag in use on a vertex.\n" ); 02025 free( all_tags ); 02026 return FALSE; 02027 } 02028 02029 iMesh_destroyTag( mesh, all_tags[1], TRUE, &result ); 02030 if( iBase_SUCCESS != result ) 02031 { 02032 printf( "Couldn't force-delete a tag in use on a vertex.\n" ); 02033 free( all_tags ); 02034 return FALSE; 02035 } 02036 02037 free( all_tags ); 02038 02039 /* ok, we're done */ 02040 return TRUE; 02041 } 02042 02043 int vertex_tag_test( iMesh_Instance mesh ) 02044 { 02045 int result; 02046 02047 iBase_TagHandle int_tag, double_tag, struct_tag; 02048 int int_err, double_err, struct_err, tag_delete_err; 02049 02050 int info_err = tag_info_test( mesh ); 02051 02052 /* get all the vertices */ 02053 iBase_EntityHandle* verts = NULL; 02054 int verts_alloc = 0, verts_size; 02055 iMesh_getEntities( mesh, root_set, iBase_ALL_TYPES, iMesh_POINT, &verts, &verts_alloc, &verts_size, &result ); 02056 if( iBase_SUCCESS != result ) 02057 { 02058 printf( "entitysetGetEntities failed in vertex_tag_test.\n" ); 02059 return FALSE; 02060 } 02061 02062 /* vertex int tag */ 02063 int_err = vertex_int_tag_test( mesh, verts, verts_size, &int_tag ); 02064 02065 /* vertex double tag */ 02066 double_err = vertex_double_tag_test( mesh, verts, verts_size, &double_tag ); 02067 02068 /* vertex struct tag */ 02069 struct_err = vertex_struct_tag_test( mesh, verts, verts_size, &struct_tag ); 02070 02071 tag_delete_err = vertex_tag_delete_test( mesh, verts, verts_size ); 02072 02073 free( verts ); 02074 02075 return ( info_err && int_err && double_err && struct_err && tag_delete_err ); 02076 } 02077 02078 int entityset_int_tag_test( iMesh_Instance mesh, iBase_EntitySetHandle* sets, int sets_size, iBase_TagHandle* int_tag ) 02079 { 02080 int result; 02081 int dum_val = 11, dum_val2; 02082 void* dum_val2_ptr = &dum_val2; 02083 int dum_val2_alloc = sizeof( int ), dum_val2_size; 02084 02085 /* create a tag */ 02086 const char* tag_name = "set_int_tag"; 02087 iMesh_createTag( mesh, tag_name, 1, iBase_INTEGER, int_tag, &result, 12 ); 02088 if( iBase_SUCCESS != result ) 02089 { 02090 printf( "Failed to create tag int_tag in entityset_int_tag_test.\n" ); 02091 return FALSE; 02092 } 02093 02094 /* put a value in the first set and retrieve */ 02095 02096 iMesh_setEntSetData( mesh, sets[0], *int_tag, (char*)( &dum_val ), sizeof( int ), &result ); 02097 if( iBase_SUCCESS != result ) 02098 { 02099 printf( "Failed to set int tag (val=11) in entityset_int_tag_test.\n" ); 02100 return FALSE; 02101 } 02102 02103 dum_val2 = 0; 02104 iMesh_getEntSetData( mesh, sets[0], *int_tag, &dum_val2_ptr, &dum_val2_alloc, &dum_val2_size, &result ); 02105 if( iBase_SUCCESS != result ) 02106 { 02107 printf( "Failed to get int tag (val=11) in entityset_int_tag_test." ); 02108 return FALSE; 02109 } 02110 02111 if( dum_val2 != 11 ) 02112 { 02113 printf( "Value of entityset tag (val=11) wrong.\n" ); 02114 return FALSE; 02115 } 02116 02117 /* put a value in the last faces and retrieve */ 02118 dum_val = 12; 02119 iMesh_setEntSetData( mesh, sets[sets_size - 1], *int_tag, (char*)( &dum_val ), sizeof( int ), &result ); 02120 if( iBase_SUCCESS != result ) 02121 { 02122 printf( "Failed to set int tag (val=12) in entityset_int_tag_test." ); 02123 return FALSE; 02124 } 02125 02126 iMesh_getEntSetData( mesh, sets[sets_size - 1], *int_tag, &dum_val2_ptr, &dum_val2_alloc, &dum_val2_size, &result ); 02127 if( iBase_SUCCESS != result ) 02128 { 02129 printf( "Failed to get int tag (val=12) in entityset_int_tag_test." ); 02130 return FALSE; 02131 } 02132 02133 if( dum_val2 != 12 ) 02134 { 02135 printf( "Value of entityset tag (val=12) wrong.\n" ); 02136 return FALSE; 02137 } 02138 02139 /* ok, the int tag test worked */ 02140 return TRUE; 02141 } 02142 02143 int entityset_double_tag_test( iMesh_Instance mesh, iBase_EntitySetHandle* sets, int sets_size, 02144 iBase_TagHandle* double_tag ) 02145 { 02146 int result; 02147 double dum_val = 1.0e6, dum_val2; 02148 void* dum_val2_ptr = &dum_val2; 02149 int dum_val2_alloc = sizeof( double ), dum_val2_size; 02150 02151 /* create a tag */ 02152 const char* tag_name = "set_double_tag"; 02153 iMesh_createTag( mesh, tag_name, 1, iBase_DOUBLE, double_tag, &result, 15 ); 02154 if( iBase_SUCCESS != result ) 02155 { 02156 printf( "Failed to create tag double_tag in entityset_double_tag_test.\n" ); 02157 return FALSE; 02158 } 02159 02160 /* put a value in the first set and retrieve */ 02161 02162 iMesh_setEntSetData( mesh, sets[0], *double_tag, (char*)( &dum_val ), sizeof( double ), &result ); 02163 if( iBase_SUCCESS != result ) 02164 { 02165 printf( "Failed to set double tag (val=11) in entityset_double_tag_test.\n" ); 02166 return FALSE; 02167 } 02168 02169 dum_val2 = 0; 02170 iMesh_getEntSetData( mesh, sets[0], *double_tag, &dum_val2_ptr, &dum_val2_alloc, &dum_val2_size, &result ); 02171 if( iBase_SUCCESS != result ) 02172 { 02173 printf( "Failed to get double tag (val=1.0e6) in entityset_double_tag_test." ); 02174 return FALSE; 02175 } 02176 02177 if( dum_val2 != 1.0e6 ) 02178 { 02179 printf( "Value of entityset tag (val=11) wrong.\n" ); 02180 return FALSE; 02181 } 02182 02183 /* put a value in the last faces and retrieve */ 02184 dum_val = 2.0e9; 02185 iMesh_setEntSetData( mesh, sets[sets_size - 1], *double_tag, (char*)( &dum_val ), sizeof( double ), &result ); 02186 if( iBase_SUCCESS != result ) 02187 { 02188 printf( "Failed to set double tag (val=2.0e9) in entityset_double_tag_test." ); 02189 return FALSE; 02190 } 02191 02192 iMesh_getEntSetData( mesh, sets[sets_size - 1], *double_tag, &dum_val2_ptr, &dum_val2_alloc, &dum_val2_size, 02193 &result ); 02194 if( iBase_SUCCESS != result ) 02195 { 02196 printf( "Failed to get double tag (val=2.0e9) in entityset_double_tag_test." ); 02197 return FALSE; 02198 } 02199 02200 if( dum_val2 != 2.0e9 ) 02201 { 02202 printf( "Value of entityset tag (val=2.0e9) wrong.\n" ); 02203 return FALSE; 02204 } 02205 02206 /* ok, the double tag test worked */ 02207 return TRUE; 02208 } 02209 02210 int entityset_struct_tag_test( iMesh_Instance mesh, iBase_EntitySetHandle* /*sets*/, int /*sets_size*/, 02211 iBase_TagHandle* struct_tag ) 02212 { 02213 int result; 02214 struct TagStruct dum_struct = { 3.0e12, 2, 3 }, dum_struct2; 02215 void* dum_struct2_ptr = &dum_struct2; 02216 int dum_struct_alloc = sizeof( struct TagStruct ), dum_struct_size; 02217 02218 /* create a tag */ 02219 const char* tag_name = "set_struct_tag"; 02220 iMesh_createTag( mesh, tag_name, sizeof( struct TagStruct ), iBase_BYTES, struct_tag, &result, 11 ); 02221 if( iBase_SUCCESS != result ) 02222 { 02223 printf( "Failed to create tag struct_tag in entityset_struct_tag_test.\n" ); 02224 return FALSE; 02225 } 02226 02227 /* put a value in the first vertex and retrieve */ 02228 02229 /* careful setting the value, since tags are opaque */ 02230 iMesh_setEntSetData( mesh, root_set, *struct_tag, (const char*)&dum_struct, sizeof( struct TagStruct ), &result ); 02231 if( iBase_SUCCESS != result ) 02232 { 02233 printf( "Failed to set struct tag in entityset_struct_tag_test.\n" ); 02234 return FALSE; 02235 } 02236 02237 iMesh_getEntSetData( mesh, root_set, *struct_tag, &dum_struct2_ptr, &dum_struct_alloc, &dum_struct_size, &result ); 02238 if( iBase_SUCCESS != result ) 02239 { 02240 printf( "Failed to get struct tag in entityset_struct_tag_test.\n" ); 02241 return FALSE; 02242 } 02243 02244 if( dum_struct_size != sizeof( struct TagStruct ) ) 02245 { 02246 printf( "Size of entityset struct tag wrong.\n" ); 02247 return FALSE; 02248 } 02249 if( dum_struct2.test_int1 != dum_struct.test_int1 || dum_struct2.test_int2 != dum_struct.test_int2 || 02250 dum_struct2.test_double != dum_struct.test_double ) 02251 { 02252 printf( "Value of entityset struct tag wrong.\n" ); 02253 return FALSE; 02254 } 02255 02256 /* ok, the int tag test worked */ 02257 return TRUE; 02258 } 02259 02260 int entityset_tag_delete_test( iMesh_Instance mesh, iBase_EntitySetHandle* sets, int sets_size ) 02261 { 02262 /* test forced, unforced deletion of tags from entities */ 02263 int result; 02264 int delete_err = FALSE; 02265 02266 /* test getAlliBase_TagHandles for first entity */ 02267 iBase_TagHandle* all_tags = NULL; 02268 if( sets_size < 1 ) 02269 { 02270 printf( "no sets.\n" ); 02271 return FALSE; 02272 } 02273 iBase_EntitySetHandle dum_entity = sets[0]; 02274 int all_tags_alloc = 0, all_tags_size; 02275 iMesh_getAllEntSetTags( mesh, sets[0], &all_tags, &all_tags_alloc, &all_tags_size, &result ); 02276 if( iBase_SUCCESS != result ) 02277 { 02278 printf( "Couldn't get all tag handles from entityset.\n" ); 02279 free( all_tags ); 02280 return FALSE; 02281 } 02282 02283 iMesh_rmvEntSetTag( mesh, dum_entity, all_tags[0], &result ); 02284 if( iBase_SUCCESS != result ) 02285 { 02286 printf( "Couldn't remove tag from entityset.\n" ); 02287 free( all_tags ); 02288 return FALSE; 02289 } 02290 02291 iMesh_destroyTag( mesh, all_tags[1], FALSE, &result ); 02292 if( iBase_SUCCESS != result ) { delete_err = TRUE; } 02293 if( !delete_err ) 02294 { 02295 printf( "Error when unforced-deleting tag in use on a entityset.\n" ); 02296 free( all_tags ); 02297 return FALSE; 02298 } 02299 02300 iMesh_destroyTag( mesh, all_tags[1], TRUE, &result ); 02301 if( iBase_SUCCESS != result ) 02302 { 02303 printf( "Couldn't force-delete a tag in use on a entityset.\n" ); 02304 free( all_tags ); 02305 return FALSE; 02306 } 02307 02308 free( all_tags ); 02309 02310 /* ok, we're done */ 02311 return TRUE; 02312 } 02313 02314 /*! 02315 @test 02316 TSTT entityset tag Test 02317 @li Check entityset tags 02318 */ 02319 int entityset_tag_test( iMesh_Instance mesh ) 02320 { 02321 int result; 02322 iBase_TagHandle int_tag, double_tag, struct_tag; 02323 int int_success, double_success, struct_success, tag_delete_success; 02324 02325 /* get the sets */ 02326 iBase_EntitySetHandle* esets = NULL; 02327 int esets_alloc = 0, esets_size; 02328 iMesh_getEntSets( mesh, root_set, 1, &esets, &esets_alloc, &esets_size, &result ); 02329 if( iBase_SUCCESS != result ) 02330 { 02331 printf( "entitysetGetEntities failed in entityset_tag_test.\n" ); 02332 free( esets ); 02333 return FALSE; 02334 } 02335 02336 /* entityset int tag */ 02337 int_success = entityset_int_tag_test( mesh, esets, esets_size, &int_tag ); 02338 02339 /* entityeset double tag */ 02340 double_success = entityset_double_tag_test( mesh, esets, esets_size, &double_tag ); 02341 02342 /* entityset struct tag */ 02343 struct_success = entityset_struct_tag_test( mesh, esets, esets_size, &struct_tag ); 02344 02345 tag_delete_success = entityset_tag_delete_test( mesh, esets, esets_size ); 02346 02347 free( esets ); 02348 02349 return ( int_success && double_success && struct_success && tag_delete_success ); 02350 } 02351 02352 int mesh_int_tag_test( iMesh_Instance mesh, iBase_TagHandle* int_tag ) 02353 { 02354 int result; 02355 int dum_val = 11, dum_val2; 02356 void* dum_val2_ptr = &dum_val2; 02357 int dum_val2_alloc = sizeof( int ), dum_val2_size; 02358 02359 /* create a tag */ 02360 const char* tag_name = "mesh_int_tag"; 02361 iMesh_createTag( mesh, tag_name, 1, iBase_INTEGER, int_tag, &result, 12 ); 02362 if( iBase_SUCCESS != result ) 02363 { 02364 printf( "Failed to create tag int_tag in mesh_int_tag_test.\n" ); 02365 return FALSE; 02366 } 02367 02368 /* put a value in the first set and retrieve */ 02369 02370 iMesh_setEntSetData( mesh, root_set, *int_tag, (char*)( &dum_val ), sizeof( int ), &result ); 02371 if( iBase_SUCCESS != result ) 02372 { 02373 printf( "Failed to set int tag (val=11) in mesh_int_tag_test.\n" ); 02374 return FALSE; 02375 } 02376 02377 dum_val2 = 0; 02378 iMesh_getEntSetData( mesh, root_set, *int_tag, &dum_val2_ptr, &dum_val2_alloc, &dum_val2_size, &result ); 02379 if( iBase_SUCCESS != result ) 02380 { 02381 printf( "Failed to get int tag (val=11) in mesh_int_tag_test." ); 02382 return FALSE; 02383 } 02384 02385 if( dum_val2 != 11 ) 02386 { 02387 printf( "Value of entityset tag (val=11) wrong.\n" ); 02388 return FALSE; 02389 } 02390 02391 /* put a value in the last faces and retrieve */ 02392 dum_val = 12; 02393 iMesh_setEntSetData( mesh, root_set, *int_tag, (char*)( &dum_val ), sizeof( int ), &result ); 02394 if( iBase_SUCCESS != result ) 02395 { 02396 printf( "Failed to set int tag (val=12) in mesh_int_tag_test." ); 02397 return FALSE; 02398 } 02399 02400 iMesh_getEntSetData( mesh, root_set, *int_tag, &dum_val2_ptr, &dum_val2_alloc, &dum_val2_size, &result ); 02401 if( iBase_SUCCESS != result ) 02402 { 02403 printf( "Failed to get int tag (val=12) in mesh_int_tag_test." ); 02404 return FALSE; 02405 } 02406 02407 if( dum_val2 != 12 ) 02408 { 02409 printf( "Value of entityset tag (val=12) wrong.\n" ); 02410 return FALSE; 02411 } 02412 02413 /* ok, the int tag test worked */ 02414 return TRUE; 02415 } 02416 02417 int mesh_double_tag_test( iMesh_Instance mesh, iBase_TagHandle* double_tag ) 02418 { 02419 int result; 02420 double dum_val = 1.0e6, dum_val2; 02421 void* dum_val2_ptr = &dum_val2; 02422 int dum_val2_alloc = sizeof( double ), dum_val2_size; 02423 02424 /* create a tag */ 02425 const char* tag_name = "mesh_double_tag"; 02426 iMesh_createTag( mesh, tag_name, 1, iBase_DOUBLE, double_tag, &result, 15 ); 02427 if( iBase_SUCCESS != result ) 02428 { 02429 printf( "Failed to create tag double_tag in mesh_double_tag_test.\n" ); 02430 return FALSE; 02431 } 02432 02433 /* put a value in the first set and retrieve */ 02434 02435 iMesh_setEntSetData( mesh, root_set, *double_tag, (char*)( &dum_val ), sizeof( double ), &result ); 02436 if( iBase_SUCCESS != result ) 02437 { 02438 printf( "Failed to set double tag (val=11) in mesh_double_tag_test.\n" ); 02439 return FALSE; 02440 } 02441 02442 dum_val2 = 0; 02443 iMesh_getEntSetData( mesh, root_set, *double_tag, &dum_val2_ptr, &dum_val2_alloc, &dum_val2_size, &result ); 02444 if( iBase_SUCCESS != result ) 02445 { 02446 printf( "Failed to get double tag (val=1.0e6) in mesh_double_tag_test." ); 02447 return FALSE; 02448 } 02449 02450 if( dum_val2 != 1.0e6 ) 02451 { 02452 printf( "Value of entityset tag (val=11) wrong.\n" ); 02453 return FALSE; 02454 } 02455 02456 /* put a value in the last faces and retrieve */ 02457 dum_val = 2.0e9; 02458 iMesh_setEntSetData( mesh, root_set, *double_tag, (char*)( &dum_val ), sizeof( double ), &result ); 02459 if( iBase_SUCCESS != result ) 02460 { 02461 printf( "Failed to set double tag (val=2.0e9) in mesh_double_tag_test." ); 02462 return FALSE; 02463 } 02464 02465 iMesh_getEntSetData( mesh, root_set, *double_tag, &dum_val2_ptr, &dum_val2_alloc, &dum_val2_size, &result ); 02466 if( iBase_SUCCESS != result ) 02467 { 02468 printf( "Failed to get double tag (val=2.0e9) in mesh_double_tag_test." ); 02469 return FALSE; 02470 } 02471 02472 if( dum_val2 != 2.0e9 ) 02473 { 02474 printf( "Value of entityset tag (val=2.0e9) wrong.\n" ); 02475 return FALSE; 02476 } 02477 02478 /* ok, the double tag test worked */ 02479 return TRUE; 02480 } 02481 02482 int mesh_struct_tag_test( iMesh_Instance mesh, iBase_TagHandle* struct_tag ) 02483 { 02484 int result; 02485 struct TagStruct dum_struct = { 3.0e12, 2, 3 }, dum_struct2; 02486 void* dum_struct2_ptr = &dum_struct2; 02487 int dum_struct_alloc = sizeof( struct TagStruct ), dum_struct_size; 02488 02489 /* create a tag */ 02490 const char* tag_name = "mesh_struct_tag"; 02491 iMesh_createTag( mesh, tag_name, sizeof( struct TagStruct ), iBase_BYTES, struct_tag, &result, 11 ); 02492 if( iBase_SUCCESS != result ) 02493 { 02494 printf( "Failed to create tag struct_tag in vertex_struct_tag_test.\n" ); 02495 return FALSE; 02496 } 02497 02498 /* put a value in the first vertex and retrieve */ 02499 02500 /* careful setting the value, since tags are opaque */ 02501 iMesh_setEntSetData( mesh, root_set, *struct_tag, (const char*)&dum_struct, sizeof( struct TagStruct ), &result ); 02502 if( iBase_SUCCESS != result ) 02503 { 02504 printf( "Failed to set struct tag in mesh_struct_tag_test.\n" ); 02505 return FALSE; 02506 } 02507 02508 iMesh_getEntSetData( mesh, root_set, *struct_tag, &dum_struct2_ptr, &dum_struct_alloc, &dum_struct_size, &result ); 02509 if( iBase_SUCCESS != result ) 02510 { 02511 printf( "Failed to get struct tag in mesh_struct_tag_test.\n" ); 02512 return FALSE; 02513 } 02514 02515 if( dum_struct_size != sizeof( struct TagStruct ) ) 02516 { 02517 printf( "Size of entityset struct tag wrong.\n" ); 02518 return FALSE; 02519 } 02520 if( dum_struct2.test_int1 != dum_struct.test_int1 || dum_struct2.test_int2 != dum_struct.test_int2 || 02521 dum_struct2.test_double != dum_struct.test_double ) 02522 { 02523 printf( "Value of entityset struct tag wrong.\n" ); 02524 return FALSE; 02525 } 02526 02527 /* ok, the int tag test worked */ 02528 return TRUE; 02529 } 02530 02531 int mesh_tag_delete_test( iMesh_Instance mesh ) 02532 { 02533 /* test forced, unforced deletion of tags from entities */ 02534 int result; 02535 int delete_err = FALSE; 02536 02537 /* test getAlliBase_TagHandles for first entity */ 02538 iBase_TagHandle* all_tags = NULL; 02539 int all_tags_alloc = 0, all_tags_size; 02540 iMesh_getAllEntSetTags( mesh, root_set, &all_tags, &all_tags_alloc, &all_tags_size, &result ); 02541 if( iBase_SUCCESS != result ) 02542 { 02543 printf( "Couldn't get all tag handles from entityset.\n" ); 02544 return FALSE; 02545 } 02546 02547 iMesh_rmvEntSetTag( mesh, root_set, all_tags[0], &result ); 02548 if( iBase_SUCCESS != result ) 02549 { 02550 printf( "Couldn't remove tag from entityset.\n" ); 02551 free( all_tags ); 02552 return FALSE; 02553 } 02554 02555 iMesh_destroyTag( mesh, all_tags[1], FALSE, &result ); 02556 if( iBase_SUCCESS != result ) { delete_err = TRUE; } 02557 if( !delete_err ) 02558 { 02559 printf( "Error when unforced-deleting tag in use on a entityset.\n" ); 02560 free( all_tags ); 02561 return FALSE; 02562 } 02563 02564 iMesh_destroyTag( mesh, all_tags[1], TRUE, &result ); 02565 if( iBase_SUCCESS != result ) 02566 { 02567 printf( "Couldn't force-delete a tag in use on a entityset.\n" ); 02568 free( all_tags ); 02569 return FALSE; 02570 } 02571 02572 free( all_tags ); 02573 02574 /* ok, we're done */ 02575 return TRUE; 02576 } 02577 02578 /*! 02579 @test 02580 TSTT entityset tag Test 02581 @li Check entityset tags 02582 */ 02583 int mesh_tag_test( iMesh_Instance mesh ) 02584 { 02585 iBase_TagHandle int_tag, double_tag, struct_tag; 02586 02587 /* entityset int tag */ 02588 int int_success = mesh_int_tag_test( mesh, &int_tag ); 02589 02590 /* entityeset double tag */ 02591 int double_success = mesh_double_tag_test( mesh, &double_tag ); 02592 02593 /* entityset struct tag */ 02594 int struct_success = mesh_struct_tag_test( mesh, &struct_tag ); 02595 02596 int tag_delete_success = mesh_tag_delete_test( mesh ); 02597 02598 return ( int_success && double_success && struct_success && tag_delete_success ); 02599 } 02600 02601 int set_remove_contained_regression( iMesh_Instance mesh ) 02602 { 02603 int err, contained; 02604 iBase_EntitySetHandle set, sub; 02605 02606 iMesh_createEntSet( mesh, 0, &set, &err ); 02607 if( iBase_SUCCESS != err ) return 0; 02608 iMesh_createEntSet( mesh, 1, &sub, &err ); 02609 if( iBase_SUCCESS != err ) return 0; 02610 02611 iMesh_addEntSet( mesh, sub, set, &err ); 02612 if( iBase_SUCCESS != err ) return 0; 02613 02614 iMesh_isEntSetContained( mesh, set, sub, &contained, &err ); 02615 if( iBase_SUCCESS != err ) return 0; 02616 if( !contained ) 02617 { 02618 fprintf( stderr, "isEntSetContained returned false for contained set\n" ); 02619 return 0; 02620 } 02621 02622 iMesh_rmvEntSet( mesh, sub, set, &err ); 02623 if( iBase_SUCCESS != err ) return 0; 02624 02625 iMesh_isEntSetContained( mesh, set, sub, &contained, &err ); 02626 if( iBase_SUCCESS != err ) return 0; 02627 if( contained ) 02628 { 02629 fprintf( stderr, "isEntSetContained returned true for removed set\n" ); 02630 return 0; 02631 } 02632 02633 return 1; 02634 } 02635 02636 int all_adjacency_regression( iMesh_Instance mesh ) 02637 { 02638 int err; 02639 02640 double coords[] = { 0, 0, 0, 1, 1, 1 }; 02641 02642 iBase_EntityHandle* verts = NULL; 02643 int verts_alloc = 0, verts_size; 02644 02645 iBase_EntityHandle line; 02646 int status; 02647 02648 iBase_EntityHandle* adj = NULL; 02649 int adj_alloc = 0, adj_size; 02650 02651 iMesh_newMesh( "", &mesh, &err, 0 ); 02652 if( iBase_SUCCESS != err ) return 0; 02653 02654 iMesh_createVtxArr( mesh, 2, iBase_INTERLEAVED, coords, 6, &verts, &verts_alloc, &verts_size, &err ); 02655 if( iBase_SUCCESS != err ) return 0; 02656 02657 iMesh_createEnt( mesh, iMesh_LINE_SEGMENT, verts, 2, &line, &status, &err ); 02658 if( iBase_SUCCESS != err || status != iBase_NEW ) return 0; 02659 02660 iMesh_getEntAdj( mesh, verts[0], iBase_ALL_TYPES, &adj, &adj_alloc, &adj_size, &err ); 02661 if( iBase_SUCCESS != err ) return 0; 02662 if( adj_size != 1 || adj[0] != line ) 02663 { 02664 printf( "Bad: couldn't find adjacency for vertex\n" ); 02665 return 0; 02666 } 02667 free( adj ); 02668 02669 adj_alloc = 0; 02670 adj = NULL; 02671 iMesh_getEntAdj( mesh, line, iBase_ALL_TYPES, &adj, &adj_alloc, &adj_size, &err ); 02672 if( iBase_SUCCESS != err ) return 0; 02673 if( adj_size != 2 || 02674 ( ( adj[0] != verts[0] || adj[1] != verts[1] ) && ( adj[0] != verts[1] || adj[1] != verts[0] ) ) ) 02675 { 02676 printf( "Bad: couldn't find adjacencies for line\n" ); 02677 free( adj ); 02678 free( verts ); 02679 return 0; 02680 } 02681 free( adj ); 02682 free( verts ); 02683 iMesh_dtor( mesh, &err ); 02684 if( iBase_SUCCESS != err ) return 0; 02685 return 1; 02686 } 02687 02688 static int ordered_set_regression( iMesh_Instance mesh ) 02689 { 02690 double coords[] = { 0, 0, 0, 1, 1, 1 }; 02691 iBase_EntityHandle line, *p, verts[2], ents_in[3], ents_out[3]; 02692 iBase_EntitySetHandle set; 02693 int i, err, status, two = 2, three = 3; 02694 02695 iMesh_newMesh( "", &mesh, &err, 0 ); 02696 CHK( err ); 02697 p = verts; 02698 iMesh_createVtxArr( mesh, 2, iBase_INTERLEAVED, coords, 6, &p, &two, &two, &err ); 02699 CHK( err ); 02700 iMesh_createEnt( mesh, iMesh_LINE_SEGMENT, verts, 2, &line, &status, &err ); 02701 CHK( err ); 02702 if( status != iBase_NEW ) return 0; 02703 iMesh_createEntSet( mesh, 1, &set, &err ); 02704 CHK( err ); 02705 ents_in[0] = verts[1]; 02706 ents_in[1] = line; 02707 ents_in[2] = verts[0]; 02708 iMesh_addEntArrToSet( mesh, ents_in, three, set, &err ); 02709 CHK( err ); 02710 p = ents_out; 02711 iMesh_getEntities( mesh, set, iBase_ALL_TYPES, iMesh_ALL_TOPOLOGIES, &p, &three, &three, &err ); 02712 CHK( err ); 02713 for( i = 0; i < three; i++ ) 02714 { 02715 if( ents_in[i] != ents_out[i] ) 02716 { 02717 printf( "Ordered set does not preserve order\n" ); 02718 return 0; 02719 } 02720 } 02721 iMesh_dtor( mesh, &err ); 02722 CHK( err ); 02723 return 1; 02724 } 02725 02726 int array_allocation( iMesh_Instance mesh ) 02727 { 02728 int err; 02729 02730 double coords[] = { 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3 }; 02731 02732 iBase_EntityHandle* verts = NULL; 02733 int verts_alloc = 0, verts_size; 02734 02735 iBase_EntityHandle* ents; 02736 int ents_alloc, ents_size; 02737 02738 iMesh_newMesh( "", &mesh, &err, 0 ); 02739 if( iBase_SUCCESS != err ) return 0; 02740 02741 iMesh_getRootSet( mesh, &root_set, &err ); 02742 if( iBase_SUCCESS != err ) 02743 { 02744 printf( "Failed to return a root set.\n" ); 02745 return 0; 02746 } 02747 02748 iMesh_createVtxArr( mesh, 4, iBase_INTERLEAVED, coords, 12, &verts, &verts_alloc, &verts_size, &err ); 02749 if( iBase_SUCCESS != err ) return 0; 02750 02751 free( verts ); 02752 02753 /* test for proper allocation when array pointer passed in null but alloc'd size not */ 02754 ents_alloc = 3; 02755 ents = NULL; 02756 iMesh_getEntities( mesh, root_set, iBase_ALL_TYPES, iMesh_ALL_TOPOLOGIES, &ents, &ents_alloc, &ents_size, &err ); 02757 CHK( err ); 02758 02759 free( ents ); 02760 02761 /* test for proper allocation when array pointer passed in non-null but alloc'd size 0 */ 02762 ents_alloc = 0; 02763 iMesh_getEntities( mesh, root_set, iBase_ALL_TYPES, iMesh_ALL_TOPOLOGIES, &ents, &ents_alloc, &ents_size, &err ); 02764 CHK( err ); 02765 02766 free( ents ); 02767 02768 /* test for failure when passed in alloc'd size is smaller than it should be */ 02769 ents_alloc -= 1; 02770 iMesh_getEntities( mesh, root_set, iBase_ALL_TYPES, iMesh_ALL_TOPOLOGIES, &ents, &ents_alloc, &ents_size, &err ); 02771 if( iBase_BAD_ARRAY_SIZE != err && iBase_BAD_ARRAY_DIMENSION != err ) 02772 { 02773 err = iBase_FAILURE; 02774 CHK( err ); 02775 } 02776 02777 iMesh_dtor( mesh, &err ); 02778 CHK( err ); 02779 02780 return 1; 02781 } 02782 02783 int compare_single_iter( const char* info, iMesh_Instance mesh, iBase_EntitySetHandle set, iBase_EntityHandle* contents, 02784 int contents_size, enum iBase_EntityType type, enum iMesh_EntityTopology topo ) 02785 { 02786 iBase_EntityIterator iter = 0; 02787 int i, twice, has_data, result = iBase_SUCCESS, result2; 02788 iBase_EntityHandle value; 02789 02790 iMesh_initEntIter( mesh, set, type, topo, 0, &iter, &result ); 02791 if( iBase_SUCCESS != result ) 02792 { 02793 printf( "%s:%d: Error %d initializing %s iterator for type %d/topo %d\n", __FILE__, __LINE__, result, info, 02794 (int)type, (int)topo ); 02795 return result; 02796 } 02797 02798 for( twice = 0; twice < 2; ++twice ) 02799 { 02800 02801 for( i = 0; i < contents_size; ++i ) 02802 { 02803 iMesh_getNextEntIter( mesh, iter, &value, &has_data, &result ); 02804 if( iBase_SUCCESS != result ) 02805 { 02806 printf( "%s:%d: Error %d stepping %s iterator for type %d/topo %d\n", __FILE__, __LINE__, result, info, 02807 (int)type, (int)topo ); 02808 goto end_single_iter; 02809 } 02810 02811 if( !has_data ) 02812 { 02813 printf( "%s:%d: %s iterator for type %d/topo %d ended prematurely at %d of %d\n", __FILE__, __LINE__, 02814 info, (int)type, (int)topo, i, contents_size ); 02815 result = iBase_FAILURE; 02816 goto end_single_iter; 02817 } 02818 02819 if( value != contents[i] ) 02820 { 02821 printf( "%s:%d: %s iterator for type %d/topo %d returned incorrect value at %d of %d\n", __FILE__, 02822 __LINE__, info, (int)type, (int)topo, i, contents_size ); 02823 result = iBase_FAILURE; 02824 goto end_single_iter; 02825 } 02826 } 02827 02828 iMesh_getNextEntIter( mesh, iter, &value, &has_data, &result ); 02829 if( iBase_SUCCESS != result ) 02830 { 02831 printf( "%s:%d: Error %d stepping %s iterator for type %d/topo %d\n", __FILE__, __LINE__, result, info, 02832 (int)type, (int)topo ); 02833 goto end_single_iter; 02834 } 02835 02836 if( has_data ) 02837 { 02838 printf( "%s:%d: %s iterator for type %d/topo %d did not end after %d values\n", __FILE__, __LINE__, info, 02839 (int)type, (int)topo, contents_size ); 02840 result = iBase_FAILURE; 02841 goto end_single_iter; 02842 } 02843 02844 iMesh_resetEntIter( mesh, iter, &result ); 02845 if( iBase_SUCCESS != result ) 02846 { 02847 printf( "%s:%d: Error %d resetting %s iterator for type %d/topo %d\n", __FILE__, __LINE__, result, info, 02848 (int)type, (int)topo ); 02849 result = iBase_FAILURE; 02850 goto end_single_iter; 02851 } 02852 } 02853 02854 end_single_iter: 02855 iMesh_endEntIter( mesh, iter, &result2 ); 02856 if( iBase_SUCCESS != result2 ) 02857 { 02858 printf( "%s:%d: Error %d releasing %s iterator for type %d/topo %d\n", __FILE__, __LINE__, result, info, 02859 (int)type, (int)topo ); 02860 if( iBase_SUCCESS == result ) result = result2; 02861 } 02862 return result; 02863 } 02864 02865 int compare_array_iter( const char* info, iMesh_Instance mesh, iBase_EntitySetHandle set, iBase_EntityHandle* contents, 02866 int contents_size, int array_size, enum iBase_EntityType type, enum iMesh_EntityTopology topo ) 02867 { 02868 iBase_EntityArrIterator iter = 0; 02869 int i, j, twice, has_data, result = iBase_SUCCESS, result2; 02870 iBase_EntityHandle* values; 02871 int values_size, values_alloc = array_size; 02872 values = (iBase_EntityHandle*)malloc( array_size * sizeof( iBase_EntityHandle ) ); 02873 02874 iMesh_initEntArrIter( mesh, set, type, topo, array_size, 0, &iter, &result ); 02875 if( iBase_SUCCESS != result ) 02876 { 02877 printf( "%s:%d: Error %d initializing %s array iterator for type %d/topo %d\n", __FILE__, __LINE__, result, 02878 info, (int)type, (int)topo ); 02879 free( values ); 02880 return result; 02881 } 02882 02883 for( twice = 0; twice < 2; ++twice ) 02884 { 02885 i = 0; 02886 while( i < contents_size ) 02887 { 02888 02889 iMesh_getNextEntArrIter( mesh, iter, &values, &values_alloc, &values_size, &has_data, &result ); 02890 if( iBase_SUCCESS != result ) 02891 { 02892 printf( "%s:%d: Error %d stepping %s array iterator for type %d/topo %d\n", __FILE__, __LINE__, result, 02893 info, (int)type, (int)topo ); 02894 goto end_arr_iter; 02895 } 02896 02897 if( !has_data || !values_size ) 02898 { 02899 printf( "%s:%d: %s array iterator for type %d/topo %d ended prematurely at %d of %d\n", __FILE__, 02900 __LINE__, info, (int)type, (int)topo, i, contents_size ); 02901 result = iBase_FAILURE; 02902 goto end_arr_iter; 02903 } 02904 02905 if( i + values_size > contents_size ) 02906 { 02907 printf( "%s:%d: %s array iterator for type %d/topo %d returned more than %d handles\n", __FILE__, 02908 __LINE__, info, (int)type, (int)topo, contents_size ); 02909 result = iBase_FAILURE; 02910 goto end_arr_iter; 02911 } 02912 02913 if( contents_size - i >= array_size && values_size < array_size ) 02914 { 02915 printf( "%s:%d: %s array iterator for type %d/topo %d returned fewer than %d handles\n", __FILE__, 02916 __LINE__, info, (int)type, (int)topo, array_size ); 02917 result = iBase_FAILURE; 02918 goto end_arr_iter; 02919 } 02920 02921 for( j = 0; j < values_size; ++j, ++i ) 02922 { 02923 if( values[j] != contents[i] ) 02924 { 02925 printf( "%s:%d: %s array iterator for type %d/topo %d returned incorrect value " 02926 "at %d of %d\n", 02927 __FILE__, __LINE__, info, (int)type, (int)topo, i, contents_size ); 02928 result = iBase_FAILURE; 02929 goto end_arr_iter; 02930 } 02931 } 02932 } 02933 02934 iMesh_getNextEntArrIter( mesh, iter, &values, &values_alloc, &values_size, &has_data, &result ); 02935 if( iBase_SUCCESS != result ) 02936 { 02937 printf( "%s:%d: Error %d stepping %s array iterator for type %d/topo %d\n", __FILE__, __LINE__, result, 02938 info, (int)type, (int)topo ); 02939 goto end_arr_iter; 02940 } 02941 02942 if( has_data || values_size ) 02943 { 02944 printf( "%s:%d: %s array iterator for type %d/topo %d did not end after %d values\n", __FILE__, __LINE__, 02945 info, (int)type, (int)topo, contents_size ); 02946 result = iBase_FAILURE; 02947 goto end_arr_iter; 02948 } 02949 02950 iMesh_resetEntArrIter( mesh, iter, &result ); 02951 if( iBase_SUCCESS != result ) 02952 { 02953 printf( "%s:%d: Error %d resetting %s array iterator for type %d/topo %d\n", __FILE__, __LINE__, result, 02954 info, (int)type, (int)topo ); 02955 result = iBase_FAILURE; 02956 goto end_arr_iter; 02957 } 02958 } 02959 02960 end_arr_iter: 02961 free( values ); 02962 iMesh_endEntArrIter( mesh, iter, &result2 ); 02963 if( iBase_SUCCESS != result2 ) 02964 { 02965 printf( "%s:%d: Error %d releasing %s array iterator for type %d/topo %d\n", __FILE__, __LINE__, result, info, 02966 (int)type, (int)topo ); 02967 if( iBase_SUCCESS == result ) result = result2; 02968 } 02969 return result; 02970 } 02971 02972 int test_iterator_common( const char* info, iMesh_Instance mesh, iBase_EntitySetHandle set, int array_size, 02973 enum iBase_EntityType type, enum iMesh_EntityTopology topo ) 02974 { 02975 iBase_EntityHandle* contents = NULL; 02976 int content_size = 0, content_alloc = 0; 02977 int result; 02978 02979 iMesh_getEntities( mesh, set, type, topo, &contents, &content_alloc, &content_size, &result ); 02980 CHK( result ); 02981 if( array_size == 1 ) 02982 result = compare_single_iter( info, mesh, set, contents, content_size, type, topo ); 02983 else 02984 result = compare_array_iter( info, mesh, set, contents, content_size, array_size, type, topo ); 02985 free( contents ); 02986 return result; 02987 } 02988 02989 int test_iterator( iMesh_Instance mesh ) 02990 { 02991 int result, i; 02992 iBase_EntitySetHandle root, list, set, *setptr; 02993 iBase_EntityHandle* array = NULL; 02994 int array_len = 0, array_size = 0; 02995 02996 iMesh_getRootSet( mesh, &root, &result ); 02997 CHK( result ); 02998 02999 /* create some sets containing every other handle */ 03000 iMesh_getEntities( mesh, root, iBase_ALL_TYPES, iMesh_ALL_TOPOLOGIES, &array, &array_size, &array_len, &result ); 03001 CHK( result ); 03002 for( i = 1; i < array_size; i += 2 ) 03003 array[i] = array[i - 1]; 03004 for( i = 0; i < 2; ++i ) 03005 { 03006 setptr = i ? &list : &set; 03007 iMesh_createEntSet( mesh, i, setptr, &result ); 03008 if( iBase_SUCCESS != result ) free( array ); 03009 CHK( result ); 03010 iMesh_addEntArrToSet( mesh, array, array_size, *setptr, &result ); 03011 if( iBase_SUCCESS != result ) free( array ); 03012 CHK( result ); 03013 } 03014 free( array ); 03015 03016 /* test single iterator and array iterator for all types */ 03017 for( i = 0; i < iBase_ALL_TYPES; ++i ) 03018 { 03019 array_size = 2 * i + 2; 03020 result = test_iterator_common( "root", mesh, root, 1, (enum iBase_EntityType)i, iMesh_ALL_TOPOLOGIES ); 03021 CHK( result ); 03022 result = test_iterator_common( "root", mesh, root, array_size, (enum iBase_EntityType)i, iMesh_ALL_TOPOLOGIES ); 03023 CHK( result ); 03024 result = test_iterator_common( "list", mesh, list, 1, (enum iBase_EntityType)i, iMesh_ALL_TOPOLOGIES ); 03025 CHK( result ); 03026 result = test_iterator_common( "list", mesh, list, array_size, (enum iBase_EntityType)i, iMesh_ALL_TOPOLOGIES ); 03027 CHK( result ); 03028 result = test_iterator_common( "set", mesh, set, 1, (enum iBase_EntityType)i, iMesh_ALL_TOPOLOGIES ); 03029 CHK( result ); 03030 result = test_iterator_common( "set", mesh, set, array_size, (enum iBase_EntityType)i, iMesh_ALL_TOPOLOGIES ); 03031 CHK( result ); 03032 } 03033 03034 /* test single iterator and array iterator for all types */ 03035 for( i = 0; i < iMesh_ALL_TOPOLOGIES; ++i ) 03036 { 03037 array_size = 2 * i + 2; 03038 result = test_iterator_common( "root", mesh, root, 1, iBase_ALL_TYPES, (enum iMesh_EntityTopology)i ); 03039 CHK( result ); 03040 result = test_iterator_common( "root", mesh, root, array_size, iBase_ALL_TYPES, (enum iMesh_EntityTopology)i ); 03041 CHK( result ); 03042 result = test_iterator_common( "list", mesh, list, 1, iBase_ALL_TYPES, (enum iMesh_EntityTopology)i ); 03043 CHK( result ); 03044 result = test_iterator_common( "list", mesh, list, array_size, iBase_ALL_TYPES, (enum iMesh_EntityTopology)i ); 03045 CHK( result ); 03046 result = test_iterator_common( "set", mesh, set, 1, iBase_ALL_TYPES, (enum iMesh_EntityTopology)i ); 03047 CHK( result ); 03048 result = test_iterator_common( "set", mesh, set, array_size, iBase_ALL_TYPES, (enum iMesh_EntityTopology)i ); 03049 CHK( result ); 03050 } 03051 03052 return 1; 03053 } 03054 03055 int main( int argc, char* argv[] ) 03056 { 03057 /* Check command line arg */ 03058 const char* filename; 03059 int number_tests = 0; 03060 int number_tests_successful = 0; 03061 int number_tests_not_implemented = 0; 03062 int number_tests_failed = 0; 03063 int result; 03064 iMesh_Instance mesh = NULL; 03065 03066 if( argc == 2 ) { filename = argv[1]; } 03067 else 03068 { 03069 printf( "Usage: %s <mesh_filename>\n", argv[0] ); 03070 if( argc != 1 ) return 1; 03071 printf( " No file specified. Defaulting to: %s\n", DEFAULT_INPUT_FILE ); 03072 filename = DEFAULT_INPUT_FILE; 03073 } 03074 03075 /* initialize the Mesh */ 03076 iMesh_newMesh( NULL, &mesh, &result, 0 ); 03077 if( iBase_SUCCESS != result ) 03078 { 03079 printf( "Failed to create a mesh instance.\n" ); 03080 return 1; 03081 } 03082 iMesh_getRootSet( mesh, &root_set, &result ); 03083 if( iBase_SUCCESS != result ) 03084 { 03085 printf( "Failed to return a root set.\n" ); 03086 return 1; 03087 } 03088 03089 /* Print out Header information */ 03090 printf( "\n\nTSTT TEST PROGRAM:\n\n" ); 03091 03092 /* load_mesh test */ 03093 printf( " load_mesh: " ); 03094 result = load_mesh_test( filename, mesh ); 03095 handle_error_code( result, &number_tests_failed, &number_tests_not_implemented, &number_tests_successful ); 03096 number_tests++; 03097 printf( "\n" ); 03098 03099 /* topology_adjacency_test */ 03100 printf( " topology_adjacency_test: " ); 03101 result = topology_adjacency_test( mesh ); 03102 handle_error_code( result, &number_tests_failed, &number_tests_not_implemented, &number_tests_successful ); 03103 number_tests++; 03104 printf( "\n" ); 03105 03106 /* entity connectivity test */ 03107 printf( " entity_connectivity_test: " ); 03108 result = entity_connectivity_test( mesh ); 03109 handle_error_code( result, &number_tests_failed, &number_tests_not_implemented, &number_tests_successful ); 03110 number_tests++; 03111 printf( "\n" ); 03112 03113 /* vertex_coordinates_test */ 03114 printf( " vertex_coordinates_test: " ); 03115 result = vertex_coordinates_test( mesh ); 03116 handle_error_code( result, &number_tests_failed, &number_tests_not_implemented, &number_tests_successful ); 03117 number_tests++; 03118 printf( "\n" ); 03119 03120 /* topology dimension test */ 03121 printf( " topology_dimension_test: " ); 03122 result = topology_dimension_test( mesh ); 03123 handle_error_code( result, &number_tests_failed, &number_tests_not_implemented, &number_tests_successful ); 03124 number_tests++; 03125 printf( "\n" ); 03126 03127 /* entity sets test */ 03128 printf( " entity_sets_test: " ); 03129 result = entity_sets_test( mesh ); 03130 handle_error_code( result, &number_tests_failed, &number_tests_not_implemented, &number_tests_successful ); 03131 number_tests++; 03132 printf( "\n" ); 03133 03134 /* vertex tag test */ 03135 printf( " vertex_tag_test: " ); 03136 result = vertex_tag_test( mesh ); 03137 handle_error_code( result, &number_tests_failed, &number_tests_not_implemented, &number_tests_successful ); 03138 number_tests++; 03139 printf( "\n" ); 03140 03141 /* entityset tag test */ 03142 printf( " entityset_tag_test: " ); 03143 result = entityset_tag_test( mesh ); 03144 handle_error_code( result, &number_tests_failed, &number_tests_not_implemented, &number_tests_successful ); 03145 number_tests++; 03146 printf( "\n" ); 03147 03148 /* mesh tag test */ 03149 printf( " mesh_tag_test: " ); 03150 result = mesh_tag_test( mesh ); 03151 handle_error_code( result, &number_tests_failed, &number_tests_not_implemented, &number_tests_successful ); 03152 number_tests++; 03153 printf( "\n" ); 03154 03155 /* iterator test */ 03156 printf( " test_iterator: " ); 03157 result = test_iterator( mesh ); 03158 handle_error_code( result, &number_tests_failed, &number_tests_not_implemented, &number_tests_successful ); 03159 number_tests++; 03160 printf( "\n" ); 03161 03162 /* regression test for remove/contained bug */ 03163 printf( " set_remove_contained_regression: " ); 03164 result = set_remove_contained_regression( mesh ); 03165 handle_error_code( result, &number_tests_failed, &number_tests_not_implemented, &number_tests_successful ); 03166 number_tests++; 03167 printf( "\n" ); 03168 03169 /* regression test for adjacencies with iBase_ALL_TYPES bug */ 03170 printf( " all_adjacency_regression: " ); 03171 result = all_adjacency_regression( mesh ); 03172 handle_error_code( result, &number_tests_failed, &number_tests_not_implemented, &number_tests_successful ); 03173 number_tests++; 03174 printf( "\n" ); 03175 03176 /* test for error codes */ 03177 printf( " error_code_test: " ); 03178 result = error_code_test( mesh ); 03179 handle_error_code( result, &number_tests_failed, &number_tests_not_implemented, &number_tests_successful ); 03180 number_tests++; 03181 printf( "\n" ); 03182 03183 /* regression test for ordered sets not preserving order */ 03184 printf( " ordered_set_regression: " ); 03185 result = ordered_set_regression( mesh ); 03186 handle_error_code( result, &number_tests_failed, &number_tests_not_implemented, &number_tests_successful ); 03187 number_tests++; 03188 printf( "\n" ); 03189 03190 /* test for array allocation behavior */ 03191 printf( " array_allocation_regression: " ); 03192 result = array_allocation( mesh ); 03193 handle_error_code( result, &number_tests_failed, &number_tests_not_implemented, &number_tests_successful ); 03194 number_tests++; 03195 printf( "\n" ); 03196 03197 /* summary */ 03198 03199 printf( "\nTSTT TEST SUMMARY: \n" ); 03200 03201 printf( " Number Tests: %d\n", number_tests ); 03202 printf( " Number Successful: %d\n", number_tests_successful ); 03203 printf( " Number Not Implemented: %d\n", number_tests_not_implemented ); 03204 printf( " Number Failed: %d\n", number_tests_failed ); 03205 printf( "\n\n\n" ); 03206 03207 /* delete the mesh */ 03208 iMesh_dtor( mesh, &result ); 03209 if( iBase_SUCCESS != result ) 03210 { 03211 printf( "Failed to destruct the mesh instance.\n" ); 03212 return 1; 03213 } 03214 03215 return number_tests_failed; 03216 }