MOAB: Mesh Oriented datABase  (version 5.5.0)
testc_cbind.cpp File Reference
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include "iMesh.h"
#include "iMesh_extensions.h"
#include "moab/Types.hpp"
#include "TestUtil.hpp"
+ Include dependency graph for testc_cbind.cpp:

Go to the source code of this file.

Classes

struct  TagStruct
 

Macros

#define FALSE   0
 
#define TRUE   1
 
#define DEFAULT_TEST_FILE   brick.vtk
 
#define DEFAULT_INPUT_FILE   STRINGIFY( DEFAULT_TEST_FILE )
 
#define ASSERT(COND)
 
#define CHK(err)
 
#define TEST_ERROR_CODE(A, B)
 

Functions

void PRINT_ASSERT_FAILURE (const char *cond, const char *file, int line)
 
void handle_error_code (const int result, int *number_failed, int *, int *number_successful)
 
int load_mesh_test (const char *filename, iMesh_Instance mesh)
 
int error_code_test (iMesh_Instance)
 
int topology_dimension_test (iMesh_Instance mesh)
 
int topology_adjacency_test (iMesh_Instance mesh)
 
int qsort_comp_handles (const void *h1, const void *h2)
 
int entity_connectivity_test (iMesh_Instance mesh)
 
int check_esets (iMesh_Instance mesh, const int num_sets)
 
int entity_sets_subtest (iMesh_Instance mesh, int is_list, int)
 
int entity_sets_test (iMesh_Instance mesh)
 
int vertex_coordinates_test (iMesh_Instance mesh)
 
int tag_info_test (iMesh_Instance mesh)
 
int vertex_int_tag_test (iMesh_Instance mesh, iBase_EntityHandle *verts, int, iBase_TagHandle *int_tag)
 
int vertex_double_tag_test (iMesh_Instance mesh, iBase_EntityHandle *verts, int, iBase_TagHandle *double_tag)
 
int vertex_struct_tag_test (iMesh_Instance mesh, iBase_EntityHandle *verts, int, iBase_TagHandle *struct_tag)
 
int vertex_tag_delete_test (iMesh_Instance mesh, iBase_EntityHandle *verts, int)
 
int vertex_tag_test (iMesh_Instance mesh)
 
int entityset_int_tag_test (iMesh_Instance mesh, iBase_EntitySetHandle *sets, int sets_size, iBase_TagHandle *int_tag)
 
int entityset_double_tag_test (iMesh_Instance mesh, iBase_EntitySetHandle *sets, int sets_size, iBase_TagHandle *double_tag)
 
int entityset_struct_tag_test (iMesh_Instance mesh, iBase_EntitySetHandle *, int, iBase_TagHandle *struct_tag)
 
int entityset_tag_delete_test (iMesh_Instance mesh, iBase_EntitySetHandle *sets, int sets_size)
 
int entityset_tag_test (iMesh_Instance mesh)
 
int mesh_int_tag_test (iMesh_Instance mesh, iBase_TagHandle *int_tag)
 
int mesh_double_tag_test (iMesh_Instance mesh, iBase_TagHandle *double_tag)
 
int mesh_struct_tag_test (iMesh_Instance mesh, iBase_TagHandle *struct_tag)
 
int mesh_tag_delete_test (iMesh_Instance mesh)
 
int mesh_tag_test (iMesh_Instance mesh)
 
int set_remove_contained_regression (iMesh_Instance mesh)
 
int all_adjacency_regression (iMesh_Instance mesh)
 
static int ordered_set_regression (iMesh_Instance mesh)
 
int array_allocation (iMesh_Instance mesh)
 
int compare_single_iter (const char *info, iMesh_Instance mesh, iBase_EntitySetHandle set, iBase_EntityHandle *contents, int contents_size, enum iBase_EntityType type, enum iMesh_EntityTopology topo)
 
int compare_array_iter (const char *info, iMesh_Instance mesh, iBase_EntitySetHandle set, iBase_EntityHandle *contents, int contents_size, int array_size, enum iBase_EntityType type, enum iMesh_EntityTopology topo)
 
int test_iterator_common (const char *info, iMesh_Instance mesh, iBase_EntitySetHandle set, int array_size, enum iBase_EntityType type, enum iMesh_EntityTopology topo)
 
int test_iterator (iMesh_Instance mesh)
 
int main (int argc, char *argv[])
 

Variables

enum iBase_ErrorType iBase_ERROR_MAP [MB_FAILURE+1]
 
static bool assert_pass
 
static iBase_EntitySetHandle root_set
 

Macro Definition Documentation

◆ ASSERT

#define ASSERT (   COND)
Value:
assert_pass = true; \
if( !( COND ) ) \
{ \
PRINT_ASSERT_FAILURE( #COND, __FILE__, __LINE__ ); \
assert_pass = false; \
}

Definition at line 82 of file testc_cbind.cpp.

◆ CHK

#define CHK (   err)
Value:
if( (err) != iBase_SUCCESS ) do \
{ \
printf( "%s:%d ITAPS error %d\n", __FILE__, __LINE__, err ); \
return 0; \
} while( 0 )

Definition at line 96 of file testc_cbind.cpp.

◆ DEFAULT_INPUT_FILE

#define DEFAULT_INPUT_FILE   STRINGIFY( DEFAULT_TEST_FILE )

Definition at line 78 of file testc_cbind.cpp.

◆ DEFAULT_TEST_FILE

#define DEFAULT_TEST_FILE   brick.vtk

Definition at line 71 of file testc_cbind.cpp.

◆ FALSE

#define FALSE   0

Definition at line 68 of file testc_cbind.cpp.

◆ TEST_ERROR_CODE

#define TEST_ERROR_CODE (   A,
 
)
Value:
if( iBase_ERROR_MAP[( A )] != ( B ) ) \
{ \
printf( "ERROR: Invalid mapping for MOAB error code %s\n", #A ); \
printf( " Expected %d, actual is %d\n", (int)iBase_ERROR_MAP[( A )], (int)( B ) ); \
return FALSE; \
}

Definition at line 143 of file testc_cbind.cpp.

◆ TRUE

#define TRUE   1

Definition at line 69 of file testc_cbind.cpp.

Function Documentation

◆ all_adjacency_regression()

int all_adjacency_regression ( iMesh_Instance  mesh)

Definition at line 2659 of file testc_cbind.cpp.

2660 {
2661  int err;
2662 
2663  double coords[] = { 0, 0, 0, 1, 1, 1 };
2664 
2665  iBase_EntityHandle* verts = NULL;
2666  int verts_alloc = 0, verts_size;
2667 
2668  iBase_EntityHandle line;
2669  int status;
2670 
2671  iBase_EntityHandle* adj = NULL;
2672  int adj_alloc = 0, adj_size;
2673 
2674  iMesh_newMesh( "", &mesh, &err, 0 );
2675  if( iBase_SUCCESS != err ) return 0;
2676 
2677  iMesh_createVtxArr( mesh, 2, iBase_INTERLEAVED, coords, 6, &verts, &verts_alloc, &verts_size, &err );
2678  if( iBase_SUCCESS != err ) return 0;
2679 
2680  iMesh_createEnt( mesh, iMesh_LINE_SEGMENT, verts, 2, &line, &status, &err );
2681  if( iBase_SUCCESS != err || status != iBase_NEW ) return 0;
2682 
2683  iMesh_getEntAdj( mesh, verts[0], iBase_ALL_TYPES, &adj, &adj_alloc, &adj_size, &err );
2684  if( iBase_SUCCESS != err ) return 0;
2685  if( adj_size != 1 || adj[0] != line )
2686  {
2687  printf( "Bad: couldn't find adjacency for vertex\n" );
2688  return 0;
2689  }
2690  free( adj );
2691 
2692  adj_alloc = 0;
2693  adj = NULL;
2694  iMesh_getEntAdj( mesh, line, iBase_ALL_TYPES, &adj, &adj_alloc, &adj_size, &err );
2695  if( iBase_SUCCESS != err ) return 0;
2696  if( adj_size != 2 ||
2697  ( ( adj[0] != verts[0] || adj[1] != verts[1] ) && ( adj[0] != verts[1] || adj[1] != verts[0] ) ) )
2698  {
2699  printf( "Bad: couldn't find adjacencies for line\n" );
2700  free( adj );
2701  free( verts );
2702  return 0;
2703  }
2704  free( adj );
2705  free( verts );
2706  iMesh_dtor( mesh, &err );
2707  if( iBase_SUCCESS != err ) return 0;
2708  return 1;
2709 }

References iBase_ALL_TYPES, iBase_INTERLEAVED, iBase_NEW, iBase_SUCCESS, iMesh_createEnt, iMesh_createVtxArr, iMesh_dtor, iMesh_getEntAdj, iMesh_LINE_SEGMENT, iMesh_newMesh, and mesh.

Referenced by main().

◆ array_allocation()

int array_allocation ( iMesh_Instance  mesh)

Definition at line 2749 of file testc_cbind.cpp.

2750 {
2751  int err;
2752 
2753  double coords[] = { 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3 };
2754 
2755  iBase_EntityHandle* verts = NULL;
2756  int verts_alloc = 0, verts_size;
2757 
2758  iBase_EntityHandle* ents;
2759  int ents_alloc, ents_size;
2760 
2761  iMesh_newMesh( "", &mesh, &err, 0 );
2762  if( iBase_SUCCESS != err ) return 0;
2763 
2764  iMesh_getRootSet( mesh, &root_set, &err );
2765  if( iBase_SUCCESS != err )
2766  {
2767  printf( "Failed to return a root set.\n" );
2768  return 0;
2769  }
2770 
2771  iMesh_createVtxArr( mesh, 4, iBase_INTERLEAVED, coords, 12, &verts, &verts_alloc, &verts_size, &err );
2772  if( iBase_SUCCESS != err ) return 0;
2773 
2774  free( verts );
2775 
2776  /* test for proper allocation when array pointer passed in null but alloc'd size not */
2777  ents_alloc = 3;
2778  ents = NULL;
2779  iMesh_getEntities( mesh, root_set, iBase_ALL_TYPES, iMesh_ALL_TOPOLOGIES, &ents, &ents_alloc, &ents_size, &err );
2780  CHK( err );
2781 
2782  free( ents );
2783 
2784  /* test for proper allocation when array pointer passed in non-null but alloc'd size 0 */
2785  ents_alloc = 0;
2786  iMesh_getEntities( mesh, root_set, iBase_ALL_TYPES, iMesh_ALL_TOPOLOGIES, &ents, &ents_alloc, &ents_size, &err );
2787  CHK( err );
2788 
2789  free( ents );
2790 
2791  /* test for failure when passed in alloc'd size is smaller than it should be */
2792  ents_alloc -= 1;
2793  iMesh_getEntities( mesh, root_set, iBase_ALL_TYPES, iMesh_ALL_TOPOLOGIES, &ents, &ents_alloc, &ents_size, &err );
2794  if( iBase_BAD_ARRAY_SIZE != err && iBase_BAD_ARRAY_DIMENSION != err )
2795  {
2796  err = iBase_FAILURE;
2797  CHK( err );
2798  }
2799 
2800  iMesh_dtor( mesh, &err );
2801  CHK( err );
2802 
2803  return 1;
2804 }

References CHK, iBase_ALL_TYPES, iBase_BAD_ARRAY_DIMENSION, iBase_BAD_ARRAY_SIZE, iBase_FAILURE, iBase_INTERLEAVED, iBase_SUCCESS, iMesh_ALL_TOPOLOGIES, iMesh_createVtxArr, iMesh_dtor, iMesh_getEntities, iMesh_getRootSet, iMesh_newMesh, mesh, and root_set.

Referenced by main().

◆ check_esets()

int check_esets ( iMesh_Instance  mesh,
const int  num_sets 
)
Test:
TSTT entity sets sub test
  • Check entity sets

Definition at line 1623 of file testc_cbind.cpp.

1624 {
1625  int entity_sets_size;
1626 
1627  int result;
1628  iMesh_getNumEntSets( mesh, root_set, 1, &entity_sets_size, &result );
1629  if( iBase_SUCCESS != result )
1630  {
1631  printf( "Problem to get all entity sets in mesh.\n" );
1632  return FALSE;
1633  }
1634  if( entity_sets_size != num_sets )
1635  {
1636  printf( "the number of entity sets in whole mesh should be %d"
1637  ", actual number is %d.\n",
1638  num_sets, entity_sets_size );
1639  return FALSE;
1640  }
1641 
1642  return TRUE;
1643 }

References FALSE, iBase_SUCCESS, iMesh_getNumEntSets, mesh, root_set, and TRUE.

Referenced by entity_sets_subtest().

◆ compare_array_iter()

int compare_array_iter ( const char *  info,
iMesh_Instance  mesh,
iBase_EntitySetHandle  set,
iBase_EntityHandle contents,
int  contents_size,
int  array_size,
enum iBase_EntityType  type,
enum iMesh_EntityTopology  topo 
)

Definition at line 2893 of file testc_cbind.cpp.

2901 {
2902  iBase_EntityArrIterator iter = 0;
2903  int i, j, twice, has_data, result = iBase_SUCCESS, result2;
2904  iBase_EntityHandle* values;
2905  int values_size, values_alloc = array_size;
2906  values = (iBase_EntityHandle*)malloc( array_size * sizeof( iBase_EntityHandle ) );
2907 
2908  iMesh_initEntArrIter( mesh, set, type, topo, array_size, 0, &iter, &result );
2909  if( iBase_SUCCESS != result )
2910  {
2911  printf( "%s:%d: Error %d initializing %s array iterator for type %d/topo %d\n", __FILE__, __LINE__, result,
2912  info, (int)type, (int)topo );
2913  free( values );
2914  return result;
2915  }
2916 
2917  for( twice = 0; twice < 2; ++twice )
2918  {
2919  i = 0;
2920  while( i < contents_size )
2921  {
2922 
2923  iMesh_getNextEntArrIter( mesh, iter, &values, &values_alloc, &values_size, &has_data, &result );
2924  if( iBase_SUCCESS != result )
2925  {
2926  printf( "%s:%d: Error %d stepping %s array iterator for type %d/topo %d\n", __FILE__, __LINE__, result,
2927  info, (int)type, (int)topo );
2928  goto end_arr_iter;
2929  }
2930 
2931  if( !has_data || !values_size )
2932  {
2933  printf( "%s:%d: %s array iterator for type %d/topo %d ended prematurely at %d of %d\n", __FILE__,
2934  __LINE__, info, (int)type, (int)topo, i, contents_size );
2935  result = iBase_FAILURE;
2936  goto end_arr_iter;
2937  }
2938 
2939  if( i + values_size > contents_size )
2940  {
2941  printf( "%s:%d: %s array iterator for type %d/topo %d returned more than %d handles\n", __FILE__,
2942  __LINE__, info, (int)type, (int)topo, contents_size );
2943  result = iBase_FAILURE;
2944  goto end_arr_iter;
2945  }
2946 
2947  if( contents_size - i >= array_size && values_size < array_size )
2948  {
2949  printf( "%s:%d: %s array iterator for type %d/topo %d returned fewer than %d handles\n", __FILE__,
2950  __LINE__, info, (int)type, (int)topo, array_size );
2951  result = iBase_FAILURE;
2952  goto end_arr_iter;
2953  }
2954 
2955  for( j = 0; j < values_size; ++j, ++i )
2956  {
2957  if( values[j] != contents[i] )
2958  {
2959  printf( "%s:%d: %s array iterator for type %d/topo %d returned incorrect value "
2960  "at %d of %d\n",
2961  __FILE__, __LINE__, info, (int)type, (int)topo, i, contents_size );
2962  result = iBase_FAILURE;
2963  goto end_arr_iter;
2964  }
2965  }
2966  }
2967 
2968  iMesh_getNextEntArrIter( mesh, iter, &values, &values_alloc, &values_size, &has_data, &result );
2969  if( iBase_SUCCESS != result )
2970  {
2971  printf( "%s:%d: Error %d stepping %s array iterator for type %d/topo %d\n", __FILE__, __LINE__, result,
2972  info, (int)type, (int)topo );
2973  goto end_arr_iter;
2974  }
2975 
2976  if( has_data || values_size )
2977  {
2978  printf( "%s:%d: %s array iterator for type %d/topo %d did not end after %d values\n", __FILE__, __LINE__,
2979  info, (int)type, (int)topo, contents_size );
2980  result = iBase_FAILURE;
2981  goto end_arr_iter;
2982  }
2983 
2984  iMesh_resetEntArrIter( mesh, iter, &result );
2985  if( iBase_SUCCESS != result )
2986  {
2987  printf( "%s:%d: Error %d resetting %s array iterator for type %d/topo %d\n", __FILE__, __LINE__, result,
2988  info, (int)type, (int)topo );
2989  result = iBase_FAILURE;
2990  goto end_arr_iter;
2991  }
2992  }
2993 
2994 end_arr_iter:
2995  free( values );
2996  iMesh_endEntArrIter( mesh, iter, &result2 );
2997  if( iBase_SUCCESS != result2 )
2998  {
2999  printf( "%s:%d: Error %d releasing %s array iterator for type %d/topo %d\n", __FILE__, __LINE__, result, info,
3000  (int)type, (int)topo );
3001  if( iBase_SUCCESS == result ) result = result2;
3002  }
3003  return result;
3004 }

References iBase_FAILURE, iBase_SUCCESS, iMesh_endEntArrIter, iMesh_getNextEntArrIter, iMesh_initEntArrIter, iMesh_resetEntArrIter, and mesh.

Referenced by test_iterator_common().

◆ compare_single_iter()

int compare_single_iter ( const char *  info,
iMesh_Instance  mesh,
iBase_EntitySetHandle  set,
iBase_EntityHandle contents,
int  contents_size,
enum iBase_EntityType  type,
enum iMesh_EntityTopology  topo 
)

Definition at line 2806 of file testc_cbind.cpp.

2813 {
2814  iBase_EntityIterator iter = 0;
2815  int i, twice, has_data, result = iBase_SUCCESS, result2;
2816  iBase_EntityHandle value;
2817 
2818  iMesh_initEntIter( mesh, set, type, topo, 0, &iter, &result );
2819  if( iBase_SUCCESS != result )
2820  {
2821  printf( "%s:%d: Error %d initializing %s iterator for type %d/topo %d\n", __FILE__, __LINE__, result, info,
2822  (int)type, (int)topo );
2823  return result;
2824  }
2825 
2826  for( twice = 0; twice < 2; ++twice )
2827  {
2828 
2829  for( i = 0; i < contents_size; ++i )
2830  {
2831  iMesh_getNextEntIter( mesh, iter, &value, &has_data, &result );
2832  if( iBase_SUCCESS != result )
2833  {
2834  printf( "%s:%d: Error %d stepping %s iterator for type %d/topo %d\n", __FILE__, __LINE__, result, info,
2835  (int)type, (int)topo );
2836  goto end_single_iter;
2837  }
2838 
2839  if( !has_data )
2840  {
2841  printf( "%s:%d: %s iterator for type %d/topo %d ended prematurely at %d of %d\n", __FILE__, __LINE__,
2842  info, (int)type, (int)topo, i, contents_size );
2843  result = iBase_FAILURE;
2844  goto end_single_iter;
2845  }
2846 
2847  if( value != contents[i] )
2848  {
2849  printf( "%s:%d: %s iterator for type %d/topo %d returned incorrect value at %d of %d\n", __FILE__,
2850  __LINE__, info, (int)type, (int)topo, i, contents_size );
2851  result = iBase_FAILURE;
2852  goto end_single_iter;
2853  }
2854  }
2855 
2856  iMesh_getNextEntIter( mesh, iter, &value, &has_data, &result );
2857  if( iBase_SUCCESS != result )
2858  {
2859  printf( "%s:%d: Error %d stepping %s iterator for type %d/topo %d\n", __FILE__, __LINE__, result, info,
2860  (int)type, (int)topo );
2861  goto end_single_iter;
2862  }
2863 
2864  if( has_data )
2865  {
2866  printf( "%s:%d: %s iterator for type %d/topo %d did not end after %d values\n", __FILE__, __LINE__, info,
2867  (int)type, (int)topo, contents_size );
2868  result = iBase_FAILURE;
2869  goto end_single_iter;
2870  }
2871 
2872  iMesh_resetEntIter( mesh, iter, &result );
2873  if( iBase_SUCCESS != result )
2874  {
2875  printf( "%s:%d: Error %d resetting %s iterator for type %d/topo %d\n", __FILE__, __LINE__, result, info,
2876  (int)type, (int)topo );
2877  result = iBase_FAILURE;
2878  goto end_single_iter;
2879  }
2880  }
2881 
2882 end_single_iter:
2883  iMesh_endEntIter( mesh, iter, &result2 );
2884  if( iBase_SUCCESS != result2 )
2885  {
2886  printf( "%s:%d: Error %d releasing %s iterator for type %d/topo %d\n", __FILE__, __LINE__, result, info,
2887  (int)type, (int)topo );
2888  if( iBase_SUCCESS == result ) result = result2;
2889  }
2890  return result;
2891 }

References iBase_FAILURE, iBase_SUCCESS, iMesh_endEntIter, iMesh_getNextEntIter, iMesh_initEntIter, iMesh_resetEntIter, and mesh.

Referenced by test_iterator_common().

◆ entity_connectivity_test()

int entity_connectivity_test ( iMesh_Instance  mesh)
Test:
TSTT EntityType Connectivity Test
  • Get coordinates for all type enities

Definition at line 514 of file testc_cbind.cpp.

515 {
516  int type, result;
517  int *offsets, offsets_alloc, offsets_size;
518  int *indices, indices_alloc, indices_size;
519  iBase_EntityHandle *entities, *adj_ents, *entities2, *sorted;
520  int entities_alloc, entities_size, adj_ents_alloc, adj_ents_size;
521  int entities2_alloc, entities2_size;
522  iBase_EntityHandle adj_ents2[27], *adj_ents2_ptr = adj_ents2;
523  int adj_ents2_alloc = 27, adj_ents2_size, i, size;
524 
525  for( type = iBase_EDGE; type < iBase_ALL_TYPES; type++ )
526  {
527  entities = NULL;
528  entities_alloc = 0;
529  adj_ents = NULL;
530  adj_ents_alloc = 0;
531  indices = NULL;
532  indices_alloc = 0;
533  offsets = NULL;
534  offsets_alloc = 0;
536  &entities_size, &adj_ents, &adj_ents_alloc, &adj_ents_size, &indices, &indices_alloc,
537  &indices_size, &offsets, &offsets_alloc, &offsets_size, &result );
538  if( iBase_SUCCESS != result )
539  {
540  printf( "Failed to get indices of vertices in connectivity_test, type=%d.\n", type );
541  return FALSE;
542  }
543 
544  if( entities_alloc != entities_size )
545  {
546  printf( "Number of entities didn't agree with array size in connectivity_test.\n" );
547  free( entities );
548  free( adj_ents );
549  free( indices );
550  free( offsets );
551  return FALSE;
552  }
553 
554  if( offsets_alloc != offsets_size )
555  {
556  printf( "Number of offsets didn't agree with array size in connectivity_test.\n" );
557  free( entities );
558  free( adj_ents );
559  free( indices );
560  free( offsets );
561  return FALSE;
562  }
563 
564  if( indices_alloc != indices_size )
565  {
566  printf( "Number of indices didn't agree with array size in connectivity_test.\n" );
567  free( entities );
568  free( adj_ents );
569  free( indices );
570  free( offsets );
571  return FALSE;
572  }
573 
574  if( adj_ents_alloc != adj_ents_size )
575  {
576  printf( "Number of adjacent entities didn't agree with array size in "
577  "connectivity_test.\n" );
578  free( entities );
579  free( adj_ents );
580  free( indices );
581  free( offsets );
582  return FALSE;
583  }
584 
585  if( offsets_size != entities_size + 1 )
586  {
587  printf( "Invalid/inconsistent offset size from iMesh_getAdjEntIndices.\n" );
588  free( entities );
589  free( adj_ents );
590  free( indices );
591  free( offsets );
592  return FALSE;
593  }
594 
595  /* check that results are valid */
596  for( i = 0; i < entities_size; ++i )
597  {
598  ASSERT( offsets[i] < offsets[i + 1] && offsets[i] < indices_size );
599  if( !assert_pass )
600  {
601  free( entities );
602  free( adj_ents );
603  free( indices );
604  free( offsets );
605  return FALSE;
606  }
607  }
608 
609  for( i = 0; i < indices_size; ++i )
610  {
611  ASSERT( indices[i] >= 0 && indices[i] < adj_ents_size );
612  if( !assert_pass )
613  {
614  free( entities );
615  free( adj_ents );
616  free( indices );
617  free( offsets );
618  return FALSE;
619  }
620  }
621 
622  /* compare initial entity list against result of iMesh_getEntities */
623  entities2 = NULL;
624  entities2_alloc = 0;
625  iMesh_getEntities( mesh, root_set, type, iMesh_ALL_TOPOLOGIES, &entities2, &entities2_alloc, &entities2_size,
626  &result );
627  ASSERT( iBase_SUCCESS == result );
628  if( !assert_pass )
629  {
630  free( entities );
631  free( adj_ents );
632  free( indices );
633  free( offsets );
634  return FALSE;
635  }
636 
637  size = sizeof( iBase_EntityHandle ) * entities_size;
638  sorted = (iBase_EntityHandle*)malloc( size );
639  memcpy( sorted, entities, size );
640  qsort( sorted, entities_size, sizeof( iBase_EntityHandle ), &qsort_comp_handles );
641  qsort( entities2, entities2_size, sizeof( iBase_EntityHandle ), &qsort_comp_handles );
642 
643  ASSERT( entities_size == entities2_size && !memcmp( sorted, entities2, size ) );
644  if( !assert_pass )
645  {
646  free( entities );
647  free( adj_ents );
648  free( indices );
649  free( offsets );
650  free( entities2 );
651  free( sorted );
652  return FALSE;
653  }
654 
655  free( entities2 );
656  free( sorted );
657 
658  /* compare results against output of iMesh_getEntAdj */
659  for( i = 0; i < entities_size; ++i )
660  {
661  iMesh_getEntAdj( mesh, entities[i], iBase_VERTEX, &adj_ents2_ptr, &adj_ents2_alloc, &adj_ents2_size,
662  &result );
663  ASSERT( iBase_SUCCESS == result );
664  if( !assert_pass )
665  {
666  free( entities );
667  free( adj_ents );
668  free( indices );
669  free( offsets );
670  return FALSE;
671  }
672 
673  ASSERT( adj_ents2_ptr == adj_ents2 ); /* shouldn't change */
674  if( !assert_pass )
675  {
676  free( entities );
677  free( adj_ents );
678  free( indices );
679  free( offsets );
680  return FALSE;
681  }
682 
683  ASSERT( adj_ents2_alloc == 27 ); /* shouldn't change */
684  if( !assert_pass )
685  {
686  free( entities );
687  free( adj_ents );
688  free( indices );
689  free( offsets );
690  return FALSE;
691  }
692 
693  /* compare results */
694  size = offsets[i + 1] - offsets[i];
695  ASSERT( size == adj_ents2_size );
696  while( --size >= 0 )
697  {
698  ASSERT( adj_ents2[size] == adj_ents[indices[offsets[i] + size]] );
699  if( !assert_pass )
700  {
701  free( entities );
702  free( adj_ents );
703  free( indices );
704  free( offsets );
705  return FALSE;
706  }
707  }
708  }
709 
710  free( entities );
711  free( adj_ents );
712  free( indices );
713  free( offsets );
714 
715  /*
716  offsets = NULL;
717  offsets_alloc = 0;
718  entities = NULL;
719  entities_alloc = 0;
720 
721  iMesh_getAdjEntities(mesh, root_set, type,
722  iMesh_ALL_TOPOLOGIES, iBase_VERTEX,
723  &entities, &entities_alloc, &entities_size,
724  &offsets, &offsets_alloc, &offsets_size,
725  &result);
726  if (iBase_SUCCESS != result) {
727  printf("Failed to get indices of adjacent entity vertices in connectivity_test.\n");
728  return FALSE;
729  }
730 
731  if (entities_alloc != entities_size ||
732  offsets_alloc != offsets_size) {
733  printf("Number of elements didn't agree with array size for an array in
734  connectivity_test.\n"); return FALSE;
735  }
736 
737  free(offsets);
738  free(entities);
739  */
740  }
741 
742  return TRUE;
743 }

References ASSERT, assert_pass, entities, FALSE, iBase_ALL_TYPES, iBase_EDGE, iBase_SUCCESS, iBase_VERTEX, iMesh_ALL_TOPOLOGIES, iMesh_getAdjEntIndices, iMesh_getEntAdj, iMesh_getEntities, mesh, qsort_comp_handles(), root_set, size, and TRUE.

Referenced by main().

◆ entity_sets_subtest()

int entity_sets_subtest ( iMesh_Instance  mesh,
int  is_list,
int   
)

Definition at line 754 of file testc_cbind.cpp.

755 {
756  int i, num_type = iBase_ALL_TYPES - iBase_VERTEX;
757  // int num_all_entities_super = 0;
759  int number_array[iBase_ALL_TYPES - iBase_VERTEX];
760  int ent_type = iBase_VERTEX;
762  int entities_alloc = 0, entities_size;
763  iBase_EntitySetHandle parent_child, super_set = NULL;
764  iBase_EntitySetHandle temp_es1, temp_es2, temp_es3;
765  iBase_EntityHandle *edges = NULL, *faces = NULL, *temp_entities1 = NULL, *temp_entities2 = NULL;
766  int edges_alloc = 0, faces_alloc = 0, temp_entities1_alloc = 0, temp_entities2_alloc = 0;
767  int edges_size, faces_size, temp_entities1_size, temp_entities2_size;
768  int* types = NULL;
769  int types_alloc = 0, types_size;
770  int num_rest, num_regions;
771  iBase_EntityHandle* regions = NULL;
772  int regions_alloc = 0, regions_size;
773  iBase_EntitySetHandle* parents = NULL;
774  int parents_alloc = 0, parents_size, temp_numb, is_child;
775  iBase_EntitySetHandle* es_array1 = NULL;
776  int es_array1_alloc = 0, es_array1_size, num_super;
777  iBase_EntityHandle* all_entities = NULL;
778  int all_entities_alloc = 0, all_entities_size, k, l;
779  iBase_EntityHandle* adj_faces = NULL;
780  int adj_faces_alloc = 0, adj_faces_size;
781  int* face_offsets = NULL;
782  int face_offsets_alloc = 0, face_offsets_size;
783  iBase_EntityHandle* hexes = NULL;
784  int hexes_alloc = 0, hexes_size;
785  iBase_EntitySetHandle hex_set;
786 
787  /* get the number of whole mesh */
788  int n_whole_mesh = 0;
789  int result;
790  iMesh_getNumEntSets( mesh, root_set, 1, &n_whole_mesh, &result );
791  if( iBase_SUCCESS != result )
792  {
793  printf( "Problem to get the number of all entity sets in whole mesh.\n" );
794  return FALSE;
795  }
796 
797  /* add entities to entitysets by type */
798  for( ; ent_type < num_type; ent_type++ )
799  {
800  /* initialize the entityset */
801  iMesh_createEntSet( mesh, is_list, &es_array[ent_type], &result );
802  if( iBase_SUCCESS != result )
803  {
804  printf( "Problem creating entityset.\n" );
805  return FALSE;
806  }
807 
808  /* get entities by type in total "mesh" */
809  entities = NULL;
810  entities_alloc = 0;
811  iMesh_getEntities( mesh, root_set, ent_type, iMesh_ALL_TOPOLOGIES, &entities, &entities_alloc, &entities_size,
812  &result );
813  if( iBase_SUCCESS != result )
814  {
815  printf( "Failed to get entities by type in entity_sets_test.\n" );
816  return FALSE;
817  }
818 
819  if( entities_alloc != entities_size )
820  {
821  printf( "Number of entities didn't agree with array size in entity_sets_subtest.\n" );
822  free( entities );
823  return FALSE;
824  }
825 
826  /* add entities into entity set */
827  if( 0 != entities_size )
828  {
829  iMesh_addEntArrToSet( mesh, entities, entities_size, es_array[ent_type], &result );
830  if( iBase_SUCCESS != result )
831  {
832  printf( "Failed to add entities in entity_sets_test.\n" );
833  free( entities );
834  return FALSE;
835  }
836  }
837 
838  /* Check to make sure entity set really has correct number of entities in it */
839  iMesh_getNumOfType( mesh, es_array[ent_type], ent_type, number_array + ent_type, &result );
840 
841  if( iBase_SUCCESS != result )
842  {
843  printf( "Failed to get number of entities by type in entity_sets_test.\n" );
844  free( entities );
845  return FALSE;
846  }
847 
848  /* compare the number of entities by type */
849  if( number_array[ent_type] != entities_size )
850  {
851  printf( "Number of entities by type is not correct\n" );
852  free( entities );
853  return FALSE;
854  }
855 
856  /* add to number of all entities in super set */
857  // num_all_entities_super += entities_size;
858 
859  free( entities );
860  }
861 
862  if( !check_esets( mesh, n_whole_mesh + num_type ) ) return FALSE;
863 
864  /* make a super set having all entitysets */
865  super_set = NULL;
866  iMesh_createEntSet( mesh, is_list, &super_set, &result );
867  if( iBase_SUCCESS != result )
868  {
869  printf( "Failed to create a super set in entity_sets_test.\n" );
870  return FALSE;
871  }
872 
873  for( i = 0; i < num_type; i++ )
874  {
875  iMesh_addEntSet( mesh, es_array[i], super_set, &result );
876  if( iBase_SUCCESS != result )
877  {
878  printf( "Failed to add a set to a super set in entity_sets_test.\n" );
879  return FALSE;
880  }
881  }
882 
883  if( !check_esets( mesh, n_whole_mesh + num_type + 1 ) ) return FALSE;
884 
885  /*----------TEST intEAN OPERATIONS----------------*/
886 
887  iMesh_createEntSet( mesh, is_list, &temp_es1, &result );
888  if( iBase_SUCCESS != result )
889  {
890  printf( "Failed to create a super set in entity_sets_test.\n" );
891  return FALSE;
892  }
893 
894  if( !check_esets( mesh, n_whole_mesh + num_type + 2 ) )
895  {
896  return FALSE;
897  }
898 
899  /* Subtract */
900  /* add all EDGEs and FACEs to temp_es1 */
901  /* get all EDGE entities */
902  edges = NULL;
903  edges_alloc = 0;
904  iMesh_getEntities( mesh, es_array[iBase_EDGE], iBase_EDGE, iMesh_ALL_TOPOLOGIES, &edges, &edges_alloc, &edges_size,
905  &result );
906 
907  if( iBase_SUCCESS != result )
908  {
909  printf( "Failed to get edge entities in entity_sets_test.\n" );
910  return FALSE;
911  }
912 
913  /* add EDGEs to es1 */
914  iMesh_addEntArrToSet( mesh, edges, edges_size, temp_es1, &result );
915  if( iBase_SUCCESS != result )
916  {
917  printf( "Failed to add edge entities in entity_sets_test.\n" );
918  free( edges );
919  return FALSE;
920  }
921 
922  /* get all FACE entities */
923  faces = NULL;
924  faces_alloc = 0;
925  iMesh_getEntities( mesh, es_array[iBase_FACE], iBase_FACE, iMesh_ALL_TOPOLOGIES, &faces, &faces_alloc, &faces_size,
926  &result );
927  if( iBase_SUCCESS != result )
928  {
929  printf( "Failed to get face entities in entity_sets_test.\n" );
930  free( edges );
931  return FALSE;
932  }
933 
934  /* add FACEs to es1 */
935  iMesh_addEntArrToSet( mesh, faces, faces_size, temp_es1, &result );
936  if( iBase_SUCCESS != result )
937  {
938  printf( "Failed to add face entities in entity_sets_test.\n" );
939  free( edges );
940  free( faces );
941  return FALSE;
942  }
943 
944  /* subtract EDGEs */
945 
946  iMesh_subtract( mesh, temp_es1, es_array[iBase_EDGE], &temp_es2, &result );
947  if( iBase_SUCCESS != result )
948  {
949  printf( "Failed to subtract entitysets in entity_sets_test.\n" );
950  free( edges );
951  free( faces );
952  return FALSE;
953  }
954 
955  temp_entities1 = NULL;
956  temp_entities1_alloc = 0;
957  iMesh_getEntities( mesh, temp_es2, iBase_FACE, iMesh_ALL_TOPOLOGIES, &temp_entities1, &temp_entities1_alloc,
958  &temp_entities1_size, &result );
959  if( iBase_SUCCESS != result )
960  {
961  printf( "Failed to get face entities in entity_sets_test.\n" );
962  free( edges );
963  free( faces );
964  return FALSE;
965  }
966 
967  if( faces_size != temp_entities1_size )
968  {
969  printf( "not match number of entitysets after subtraction "
970  "in entity_sets_test.\n" );
971  free( edges );
972  free( faces );
973  free( temp_entities1 );
974  return FALSE;
975  }
976 
977  /* check there's nothing but faces in face_es */
978  types = NULL;
979  types_alloc = 0;
980  iMesh_getEntArrType( mesh, temp_entities1, temp_entities1_size, &types, &types_alloc, &types_size, &result );
981  if( iBase_SUCCESS != result )
982  {
983  printf( "Failed to get types of entities in entity_sets_test.\n" );
984  free( edges );
985  free( faces );
986  free( temp_entities1 );
987  return FALSE;
988  }
989  for( i = 0; i < types_size; i++ )
990  {
991  if( types[i] != iBase_FACE )
992  {
993  printf( "wrong entity type for face test in entity_sets_test.\n" );
994  free( edges );
995  free( faces );
996  free( temp_entities1 );
997  free( types );
998  return FALSE;
999  }
1000  }
1001 
1002  iMesh_destroyEntSet( mesh, temp_es2, &result );
1003  if( iBase_SUCCESS != result )
1004  {
1005  printf( "Failed to destroy temp es2.\n" );
1006  free( edges );
1007  free( faces );
1008  free( temp_entities1 );
1009  free( types );
1010  return FALSE;
1011  }
1012 
1013  if( !check_esets( mesh, n_whole_mesh + num_type + 2 ) )
1014  {
1015  free( edges );
1016  free( faces );
1017  free( temp_entities1 );
1018  free( types );
1019  return FALSE;
1020  }
1021 
1022  /*------------Intersect------------ */
1023 
1024  /* clean out the temp_ms1 */
1025  iMesh_rmvEntArrFromSet( mesh, faces, faces_size, temp_es1, &result );
1026  if( iBase_SUCCESS != result )
1027  {
1028  printf( "Failed to remove face entities in entity_sets_test.\n" );
1029  free( edges );
1030  free( faces );
1031  free( temp_entities1 );
1032  free( types );
1033  return FALSE;
1034  }
1035 
1036  /* check if it is really cleaned out */
1037  iMesh_getNumOfType( mesh, temp_es1, iBase_FACE, &num_rest, &result );
1038  if( iBase_SUCCESS != result )
1039  {
1040  printf( "Failed to get number of entities by type in entity_sets_test.\n" );
1041  free( edges );
1042  free( faces );
1043  free( temp_entities1 );
1044  free( types );
1045  return FALSE;
1046  }
1047 
1048  if( num_rest != 0 )
1049  {
1050  printf( "failed to remove correctly.\n" );
1051  free( edges );
1052  free( faces );
1053  free( temp_entities1 );
1054  free( types );
1055  return FALSE;
1056  }
1057 
1058  /* add EDGEs to temp es1 */
1059  iMesh_addEntArrToSet( mesh, edges, edges_size, temp_es1, &result );
1060  if( iBase_SUCCESS != result )
1061  {
1062  printf( "Failed to add edge entities in entity_sets_test.\n" );
1063  free( edges );
1064  free( faces );
1065  free( temp_entities1 );
1066  free( types );
1067  return FALSE;
1068  }
1069 
1070  /* add FACEs to temp es1 */
1071  iMesh_addEntArrToSet( mesh, faces, faces_size, temp_es1, &result );
1072  if( iBase_SUCCESS != result )
1073  {
1074  printf( "Failed to add edge entities in entity_sets_test.\n" );
1075  free( edges );
1076  free( faces );
1077  free( temp_entities1 );
1078  free( types );
1079  return FALSE;
1080  }
1081 
1082  /* intersect temp_es1 with edges meshset */
1083  /* temp_ms1 entityset is altered */
1084  iMesh_intersect( mesh, temp_es1, es_array[iBase_EDGE], &temp_es2, &result );
1085  if( iBase_SUCCESS != result )
1086  {
1087  printf( "Failed to intersect in entity_sets_test.\n" );
1088  free( edges );
1089  free( faces );
1090  free( temp_entities1 );
1091  free( types );
1092  return FALSE;
1093  }
1094 
1095  temp_entities2 = NULL;
1096  temp_entities2_alloc = 0;
1097  iMesh_getEntities( mesh, temp_es2, iBase_FACE, iMesh_ALL_TOPOLOGIES, &temp_entities2, &temp_entities2_alloc,
1098  &temp_entities2_size, &result );
1099  if( iBase_SUCCESS != result )
1100  {
1101  printf( "Failed to get face entities in entity_sets_test.\n" );
1102  free( edges );
1103  free( faces );
1104  free( temp_entities1 );
1105  free( types );
1106  return FALSE;
1107  }
1108 
1109  if( temp_entities2_size != 0 )
1110  {
1111  printf( "wrong number of faces.\n" );
1112  free( edges );
1113  free( faces );
1114  free( temp_entities1 );
1115  free( temp_entities2 );
1116  free( types );
1117  return FALSE;
1118  }
1119 
1120  iMesh_destroyEntSet( mesh, temp_es2, &result );
1121  if( iBase_SUCCESS != result )
1122  {
1123  printf( "Failed to destroy temp es2.\n" );
1124  free( edges );
1125  free( faces );
1126  free( temp_entities1 );
1127  free( temp_entities2 );
1128  free( types );
1129  return FALSE;
1130  }
1131 
1132  if( !check_esets( mesh, n_whole_mesh + num_type + 2 ) )
1133  {
1134  free( edges );
1135  free( faces );
1136  free( temp_entities1 );
1137  free( temp_entities2 );
1138  free( types );
1139  return FALSE;
1140  }
1141 
1142  /*-------------Unite-------------- */
1143 
1144  iMesh_createEntSet( mesh, is_list, &temp_es2, &result );
1145  if( iBase_SUCCESS != result )
1146  {
1147  printf( "Failed to create a temp entityset in entity_sets_test.\n" );
1148  free( edges );
1149  free( faces );
1150  free( temp_entities1 );
1151  free( temp_entities2 );
1152  free( types );
1153  return FALSE;
1154  }
1155 
1156  /* get all regions */
1157  regions = NULL;
1158  regions_alloc = 0;
1159  iMesh_getEntities( mesh, es_array[iBase_REGION], iBase_REGION, iMesh_ALL_TOPOLOGIES, &regions, &regions_alloc,
1160  &regions_size, &result );
1161  if( iBase_SUCCESS != result )
1162  {
1163  printf( "Failed to get region entities in entity_sets_test.\n" );
1164  free( edges );
1165  free( faces );
1166  free( temp_entities1 );
1167  free( temp_entities2 );
1168  free( types );
1169  return FALSE;
1170  }
1171 
1172  /* add REGIONs to temp es2 */
1173  iMesh_addEntArrToSet( mesh, regions, regions_size, temp_es2, &result );
1174  if( iBase_SUCCESS != result )
1175  {
1176  printf( "Failed to add region entities in entity_sets_test.\n" );
1177  free( edges );
1178  free( faces );
1179  free( temp_entities1 );
1180  free( temp_entities2 );
1181  free( types );
1182  free( regions );
1183  return FALSE;
1184  }
1185 
1186  /* unite temp_es1 and temp_es2 */
1187  iMesh_unite( mesh, temp_es1, temp_es2, &temp_es3, &result );
1188  if( iBase_SUCCESS != result )
1189  {
1190  printf( "Failed to unite in entity_sets_test.\n" );
1191  free( edges );
1192  free( faces );
1193  free( temp_entities1 );
1194  free( temp_entities2 );
1195  free( types );
1196  free( regions );
1197  return FALSE;
1198  }
1199 
1200  /* perform the check */
1201  iMesh_getNumOfType( mesh, temp_es3, iBase_REGION, &num_regions, &result );
1202  if( iBase_SUCCESS != result )
1203  {
1204  printf( "Failed to get number of region entities by type in entity_sets_test.\n" );
1205  free( edges );
1206  free( faces );
1207  free( temp_entities1 );
1208  free( temp_entities2 );
1209  free( types );
1210  free( regions );
1211  return FALSE;
1212  }
1213 
1214  if( num_regions != number_array[iBase_REGION] )
1215  {
1216  printf( "different number of regions in entity_sets_test.\n" );
1217  free( edges );
1218  free( faces );
1219  free( temp_entities1 );
1220  free( temp_entities2 );
1221  free( types );
1222  free( regions );
1223  return FALSE;
1224  }
1225 
1226  if( !check_esets( mesh, n_whole_mesh + num_type + 4 ) )
1227  {
1228  free( edges );
1229  free( faces );
1230  free( temp_entities1 );
1231  free( temp_entities2 );
1232  free( types );
1233  free( regions );
1234  return FALSE;
1235  }
1236 
1237  /*--------Test parent/child stuff in entiysets----------- */
1238 
1239  /* Add 2 meshsets as children to another */
1240  iMesh_createEntSet( mesh, is_list, &parent_child, &result );
1241  if( iBase_SUCCESS != result )
1242  {
1243  printf( "Problem creating entityset in entity_sets_test.\n" );
1244  free( edges );
1245  free( faces );
1246  free( temp_entities1 );
1247  free( temp_entities2 );
1248  free( types );
1249  free( regions );
1250  return FALSE;
1251  }
1252 
1253  iMesh_addPrntChld( mesh, es_array[iBase_VERTEX], parent_child, &result );
1254  if( iBase_SUCCESS != result )
1255  {
1256  printf( "Problem add parent in entity_sets_test.\n" );
1257  free( edges );
1258  free( faces );
1259  free( temp_entities1 );
1260  free( temp_entities2 );
1261  free( types );
1262  free( regions );
1263  return FALSE;
1264  }
1265 
1266  /* check if parent is really added */
1267  parents = NULL;
1268  parents_alloc = 0;
1269  iMesh_getPrnts( mesh, parent_child, 0, &parents, &parents_alloc, &parents_size, &result );
1270  if( iBase_SUCCESS != result )
1271  {
1272  printf( "Problem getting parents in entity_sets_test.\n" );
1273  free( edges );
1274  free( faces );
1275  free( temp_entities1 );
1276  free( temp_entities2 );
1277  free( types );
1278  free( regions );
1279  return FALSE;
1280  }
1281 
1282  if( parents_size != 1 )
1283  {
1284  printf( "number of parents is not correct in entity_sets_test.\n" );
1285  free( edges );
1286  free( faces );
1287  free( temp_entities1 );
1288  free( temp_entities2 );
1289  free( types );
1290  free( regions );
1291  free( parents );
1292  return FALSE;
1293  }
1294 
1295  /* get the number of child entitysets */
1296  iMesh_getNumChld( mesh, es_array[iBase_VERTEX], 0, &temp_numb, &result );
1297  if( iBase_SUCCESS != result )
1298  {
1299  printf( "Problem getting number of children in entity_sets_test.\n" );
1300  free( edges );
1301  free( faces );
1302  free( temp_entities1 );
1303  free( temp_entities2 );
1304  free( types );
1305  free( regions );
1306  free( parents );
1307  return FALSE;
1308  }
1309 
1310  if( temp_numb != 1 )
1311  {
1312  printf( "number of children is not correct in entity_sets_test.\n" );
1313  free( edges );
1314  free( faces );
1315  free( temp_entities1 );
1316  free( temp_entities2 );
1317  free( types );
1318  free( regions );
1319  free( parents );
1320  return FALSE;
1321  }
1322 
1323  /* parent_child and es_array[iBase_VERTEX] should be related */
1324  is_child = 0;
1325  iMesh_isChildOf( mesh, es_array[iBase_VERTEX], parent_child, &is_child, &result );
1326  if( iBase_SUCCESS != result )
1327  {
1328  printf( "Problem checking relation in entity_sets_test.\n" );
1329  free( edges );
1330  free( faces );
1331  free( temp_entities1 );
1332  free( temp_entities2 );
1333  free( types );
1334  free( regions );
1335  free( parents );
1336  return FALSE;
1337  }
1338  if( !is_child )
1339  {
1340  printf( "parent_child and es_array[iBase_VERTEX] should be related\n" );
1341  free( edges );
1342  free( faces );
1343  free( temp_entities1 );
1344  free( temp_entities2 );
1345  free( types );
1346  free( regions );
1347  free( parents );
1348  return FALSE;
1349  }
1350 
1351  /* es_array[iBase_FACE] and es_array[iBase_REGION] are not related */
1352  is_child = FALSE;
1353  iMesh_isChildOf( mesh, es_array[iBase_FACE], es_array[iBase_REGION], &is_child, &result );
1354  if( iBase_SUCCESS != result )
1355  {
1356  printf( "Problem checking relation in entity_sets_test.\n" );
1357  free( edges );
1358  free( faces );
1359  free( temp_entities1 );
1360  free( temp_entities2 );
1361  free( types );
1362  free( regions );
1363  free( parents );
1364  return FALSE;
1365  }
1366  if( is_child )
1367  {
1368  printf( "es_array[iBase_REGION] and es_array[iBase_FACE] should not be related\n" );
1369  free( edges );
1370  free( faces );
1371  free( temp_entities1 );
1372  free( temp_entities2 );
1373  free( types );
1374  free( regions );
1375  free( parents );
1376  return FALSE;
1377  }
1378 
1379  if( !check_esets( mesh, n_whole_mesh + num_type + 5 ) )
1380  {
1381  free( edges );
1382  free( faces );
1383  free( temp_entities1 );
1384  free( temp_entities2 );
1385  free( types );
1386  free( regions );
1387  free( parents );
1388  return FALSE;
1389  }
1390 
1391  /*--------test modify and query functions----------------------------- */
1392 
1393  /* get all entity sets in super set */
1394  es_array1 = NULL;
1395  es_array1_alloc = 0;
1396  iMesh_getEntSets( mesh, super_set, 0, &es_array1, &es_array1_alloc, &es_array1_size, &result );
1397  if( iBase_SUCCESS != result )
1398  {
1399  printf( "Problem to get entity sets in super set.\n" );
1400  free( edges );
1401  free( faces );
1402  free( temp_entities1 );
1403  free( temp_entities2 );
1404  free( types );
1405  free( regions );
1406  free( parents );
1407  return FALSE;
1408  }
1409 
1410  /* get the number of entity sets in super set */
1411  iMesh_getNumEntSets( mesh, super_set, 0, &num_super, &result );
1412  if( iBase_SUCCESS != result )
1413  {
1414  printf( "Problem to get the number of all entity sets in super set.\n" );
1415  free( edges );
1416  free( faces );
1417  free( temp_entities1 );
1418  free( temp_entities2 );
1419  free( types );
1420  free( regions );
1421  free( parents );
1422  free( es_array1 );
1423  return FALSE;
1424  }
1425 
1426  /* the number of entity sets in super set should be same */
1427  if( num_super != es_array1_size )
1428  {
1429  printf( "the number of entity sets in super set should be same.\n" );
1430  return FALSE;
1431  }
1432 
1433  /* get all entities in super set */
1434  all_entities = NULL;
1435  all_entities_alloc = 0;
1436  iMesh_getEntities( mesh, super_set, iBase_ALL_TYPES, iMesh_ALL_TOPOLOGIES, &all_entities, &all_entities_alloc,
1437  &all_entities_size, &result );
1438  if( iBase_SUCCESS != result )
1439  {
1440  printf( "Problem to get all entities in super set.\n" );
1441  free( edges );
1442  free( faces );
1443  free( temp_entities1 );
1444  free( temp_entities2 );
1445  free( types );
1446  free( regions );
1447  free( parents );
1448  free( es_array1 );
1449  return FALSE;
1450  }
1451 
1452  /* compare the number of all entities in super set */
1453  /* NOTE: TEST COMMENTED OUT UNTIL RESOLUTION OF WHETHER GETENTITIES */
1454  /* SHOULD GET A NUM_HOPS ARGUMENT */
1455  /* if (num_all_entities_super != all_entities_size) { */
1456  /* printf("number of all entities in super set should be same.\n"); */
1457  /* return FALSE; */
1458  /* } */
1459 
1460  /* test add, remove and get all entity sets using super set */
1461  /* check GetAllEntitySets works recursively and dosen't return */
1462  /* multi sets */
1463  for( k = 0; k < num_super; k++ )
1464  {
1465  /* add entity sets of super set to each entity set of super set */
1466  /* make multiple child super sets */
1467  iBase_EntitySetHandle es_k = es_array1[k];
1468  for( l = 0; l < es_array1_size; l++ )
1469  {
1470  iMesh_addEntSet( mesh, es_array1[l], es_k, &result );
1471  if( iBase_SUCCESS != result )
1472  {
1473  printf( "Problem to add entity set to entityset.\n" );
1474  free( edges );
1475  free( faces );
1476  free( temp_entities1 );
1477  free( temp_entities2 );
1478  free( types );
1479  free( regions );
1480  free( parents );
1481  free( es_array1 );
1482  free( all_entities );
1483  return FALSE;
1484  }
1485  }
1486 
1487  /* add super set to each entity set */
1488  iMesh_addEntSet( mesh, super_set, es_k, &result );
1489  if( iBase_SUCCESS != result )
1490  {
1491  printf( "Problem to add super set to entitysets.\n" );
1492  free( edges );
1493  free( faces );
1494  free( temp_entities1 );
1495  free( temp_entities2 );
1496  free( types );
1497  free( regions );
1498  free( parents );
1499  free( es_array1 );
1500  free( all_entities );
1501  return FALSE;
1502  }
1503 
1504  /* add one entity sets multiple times */
1505  for( l = 0; l < 3; l++ )
1506  {
1507  iMesh_addEntSet( mesh, temp_es1, es_k, &result );
1508  if( iBase_SUCCESS != result )
1509  {
1510  printf( "Problem to add temp set to entitysets.\n" );
1511  free( edges );
1512  free( faces );
1513  free( temp_entities1 );
1514  free( temp_entities2 );
1515  free( types );
1516  free( regions );
1517  free( parents );
1518  free( es_array1 );
1519  free( all_entities );
1520  return FALSE;
1521  }
1522  }
1523  }
1524 
1525  /* get all hexes and get faces of that hexes */
1526  hexes = NULL;
1527  hexes_alloc = 0;
1528 
1529  iMesh_getEntities( mesh, root_set, iBase_ALL_TYPES, iMesh_HEXAHEDRON, &hexes, &hexes_alloc, &hexes_size, &result );
1530  if( iBase_SUCCESS != result )
1531  {
1532  printf( "Failed to get hexes in entity_sets_test.\n" );
1533  free( edges );
1534  free( faces );
1535  free( temp_entities1 );
1536  free( temp_entities2 );
1537  free( types );
1538  free( regions );
1539  free( parents );
1540  free( es_array1 );
1541  free( all_entities );
1542  return FALSE;
1543  }
1544 
1545  /* get adjacent face of hexes */
1546  adj_faces = NULL;
1547  adj_faces_alloc = 0;
1548  face_offsets = NULL;
1549  face_offsets_alloc = 0;
1550 
1551  iMesh_getEntArrAdj( mesh, hexes, hexes_size, iBase_FACE, &adj_faces, &adj_faces_alloc, &adj_faces_size,
1552  &face_offsets, &face_offsets_alloc, &face_offsets_size, &result );
1553  if( iBase_SUCCESS != result )
1554  {
1555  printf( "Problem to get adjacent entities in entitysets_test.\n" );
1556  free( edges );
1557  free( faces );
1558  free( temp_entities1 );
1559  free( temp_entities2 );
1560  free( types );
1561  free( regions );
1562  free( parents );
1563  free( es_array1 );
1564  free( all_entities );
1565  free( hexes );
1566  return FALSE;
1567  }
1568 
1569  iMesh_createEntSet( mesh, FALSE, &hex_set, &result );
1570  if( iBase_SUCCESS != result )
1571  {
1572  printf( "Problem creating entityset in entity_sets_test.\n" );
1573  free( edges );
1574  free( faces );
1575  free( temp_entities1 );
1576  free( temp_entities2 );
1577  free( types );
1578  free( regions );
1579  free( parents );
1580  free( es_array1 );
1581  free( all_entities );
1582  free( hexes );
1583  free( adj_faces );
1584  free( face_offsets );
1585  return FALSE;
1586  }
1587 
1588  iMesh_addEntArrToSet( mesh, hexes, hexes_size, hex_set, &result );
1589  if( iBase_SUCCESS != result )
1590  {
1591  printf( "Failed to add hexes in entity_sets_test.\n" );
1592  free( edges );
1593  free( faces );
1594  free( temp_entities1 );
1595  free( temp_entities2 );
1596  free( types );
1597  free( regions );
1598  free( parents );
1599  free( es_array1 );
1600  free( all_entities );
1601  free( hexes );
1602  free( adj_faces );
1603  free( face_offsets );
1604  return FALSE;
1605  }
1606 
1607  free( edges );
1608  free( faces );
1609  free( temp_entities1 );
1610  free( temp_entities2 );
1611  free( types );
1612  free( regions );
1613  free( parents );
1614  free( es_array1 );
1615  free( all_entities );
1616  free( hexes );
1617  free( adj_faces );
1618  free( face_offsets );
1619 
1620  return TRUE;
1621 }

References check_esets(), entities, FALSE, iBase_ALL_TYPES, iBase_EDGE, iBase_FACE, iBase_REGION, iBase_SUCCESS, iBase_VERTEX, iMesh_addEntArrToSet, iMesh_addEntSet, iMesh_addPrntChld, iMesh_ALL_TOPOLOGIES, iMesh_createEntSet, iMesh_destroyEntSet, iMesh_getEntArrAdj, iMesh_getEntArrType, iMesh_getEntities, iMesh_getEntSets, iMesh_getNumChld, iMesh_getNumEntSets, iMesh_getNumOfType, iMesh_getPrnts, iMesh_HEXAHEDRON, iMesh_intersect, iMesh_isChildOf, iMesh_rmvEntArrFromSet, iMesh_subtract, iMesh_unite, mesh, root_set, and TRUE.

Referenced by entity_sets_test().

◆ entity_sets_test()

int entity_sets_test ( iMesh_Instance  mesh)
Test:
TSTT entity sets Test
  • Check entity sets

Definition at line 1650 of file testc_cbind.cpp.

1651 {
1652  int iter_num = 0, result;
1653  /* check */
1654  int i;
1655  for( i = 0; i < 2; i++ )
1656  {
1657  iter_num++;
1658 
1659  result = entity_sets_subtest( mesh, i, iter_num );
1660  if( !result ) return result;
1661  }
1662 
1663  return TRUE;
1664 }

References entity_sets_subtest(), mesh, and TRUE.

Referenced by main().

◆ entityset_double_tag_test()

int entityset_double_tag_test ( iMesh_Instance  mesh,
iBase_EntitySetHandle sets,
int  sets_size,
iBase_TagHandle double_tag 
)

Definition at line 2156 of file testc_cbind.cpp.

2160 {
2161  int result;
2162  double dum_val = 1.0e6, dum_val2;
2163  void* dum_val2_ptr = &dum_val2;
2164  int dum_val2_alloc = sizeof( double ), dum_val2_size;
2165 
2166  /* create a tag */
2167  const char* tag_name = "set_double_tag";
2168  iMesh_createTag( mesh, tag_name, 1, iBase_DOUBLE, double_tag, &result, 15 );
2169  if( iBase_SUCCESS != result )
2170  {
2171  printf( "Failed to create tag double_tag in entityset_double_tag_test.\n" );
2172  return FALSE;
2173  }
2174 
2175  /* put a value in the first set and retrieve */
2176 
2177  iMesh_setEntSetData( mesh, sets[0], *double_tag, (char*)( &dum_val ), sizeof( double ), &result );
2178  if( iBase_SUCCESS != result )
2179  {
2180  printf( "Failed to set double tag (val=11) in entityset_double_tag_test.\n" );
2181  return FALSE;
2182  }
2183 
2184  dum_val2 = 0;
2185  iMesh_getEntSetData( mesh, sets[0], *double_tag, &dum_val2_ptr, &dum_val2_alloc, &dum_val2_size, &result );
2186  if( iBase_SUCCESS != result )
2187  {
2188  printf( "Failed to get double tag (val=1.0e6) in entityset_double_tag_test." );
2189  return FALSE;
2190  }
2191 
2192  if( dum_val2 != 1.0e6 )
2193  {
2194  printf( "Value of entityset tag (val=11) wrong.\n" );
2195  return FALSE;
2196  }
2197 
2198  /* put a value in the last faces and retrieve */
2199  dum_val = 2.0e9;
2200  iMesh_setEntSetData( mesh, sets[sets_size - 1], *double_tag, (char*)( &dum_val ), sizeof( double ), &result );
2201  if( iBase_SUCCESS != result )
2202  {
2203  printf( "Failed to set double tag (val=2.0e9) in entityset_double_tag_test." );
2204  return FALSE;
2205  }
2206 
2207  iMesh_getEntSetData( mesh, sets[sets_size - 1], *double_tag, &dum_val2_ptr, &dum_val2_alloc, &dum_val2_size,
2208  &result );
2209  if( iBase_SUCCESS != result )
2210  {
2211  printf( "Failed to get double tag (val=2.0e9) in entityset_double_tag_test." );
2212  return FALSE;
2213  }
2214 
2215  if( dum_val2 != 2.0e9 )
2216  {
2217  printf( "Value of entityset tag (val=2.0e9) wrong.\n" );
2218  return FALSE;
2219  }
2220 
2221  /* ok, the double tag test worked */
2222  return TRUE;
2223 }

References FALSE, iBase_DOUBLE, iBase_SUCCESS, iMesh_createTag, iMesh_getEntSetData, iMesh_setEntSetData, mesh, and TRUE.

Referenced by entityset_tag_test().

◆ entityset_int_tag_test()

int entityset_int_tag_test ( iMesh_Instance  mesh,
iBase_EntitySetHandle sets,
int  sets_size,
iBase_TagHandle int_tag 
)

Definition at line 2091 of file testc_cbind.cpp.

2092 {
2093  int result;
2094  int dum_val = 11, dum_val2;
2095  void* dum_val2_ptr = &dum_val2;
2096  int dum_val2_alloc = sizeof( int ), dum_val2_size;
2097 
2098  /* create a tag */
2099  const char* tag_name = "set_int_tag";
2100  iMesh_createTag( mesh, tag_name, 1, iBase_INTEGER, int_tag, &result, 12 );
2101  if( iBase_SUCCESS != result )
2102  {
2103  printf( "Failed to create tag int_tag in entityset_int_tag_test.\n" );
2104  return FALSE;
2105  }
2106 
2107  /* put a value in the first set and retrieve */
2108 
2109  iMesh_setEntSetData( mesh, sets[0], *int_tag, (char*)( &dum_val ), sizeof( int ), &result );
2110  if( iBase_SUCCESS != result )
2111  {
2112  printf( "Failed to set int tag (val=11) in entityset_int_tag_test.\n" );
2113  return FALSE;
2114  }
2115 
2116  dum_val2 = 0;
2117  iMesh_getEntSetData( mesh, sets[0], *int_tag, &dum_val2_ptr, &dum_val2_alloc, &dum_val2_size, &result );
2118  if( iBase_SUCCESS != result )
2119  {
2120  printf( "Failed to get int tag (val=11) in entityset_int_tag_test." );
2121  return FALSE;
2122  }
2123 
2124  if( dum_val2 != 11 )
2125  {
2126  printf( "Value of entityset tag (val=11) wrong.\n" );
2127  return FALSE;
2128  }
2129 
2130  /* put a value in the last faces and retrieve */
2131  dum_val = 12;
2132  iMesh_setEntSetData( mesh, sets[sets_size - 1], *int_tag, (char*)( &dum_val ), sizeof( int ), &result );
2133  if( iBase_SUCCESS != result )
2134  {
2135  printf( "Failed to set int tag (val=12) in entityset_int_tag_test." );
2136  return FALSE;
2137  }
2138 
2139  iMesh_getEntSetData( mesh, sets[sets_size - 1], *int_tag, &dum_val2_ptr, &dum_val2_alloc, &dum_val2_size, &result );
2140  if( iBase_SUCCESS != result )
2141  {
2142  printf( "Failed to get int tag (val=12) in entityset_int_tag_test." );
2143  return FALSE;
2144  }
2145 
2146  if( dum_val2 != 12 )
2147  {
2148  printf( "Value of entityset tag (val=12) wrong.\n" );
2149  return FALSE;
2150  }
2151 
2152  /* ok, the int tag test worked */
2153  return TRUE;
2154 }

References FALSE, iBase_INTEGER, iBase_SUCCESS, iMesh_createTag, iMesh_getEntSetData, iMesh_setEntSetData, mesh, and TRUE.

Referenced by entityset_tag_test().

◆ entityset_struct_tag_test()

int entityset_struct_tag_test ( iMesh_Instance  mesh,
iBase_EntitySetHandle ,
int  ,
iBase_TagHandle struct_tag 
)

Definition at line 2225 of file testc_cbind.cpp.

2229 {
2230  int result;
2231  struct TagStruct dum_struct = { 3.0e12, 2, 3 }, dum_struct2;
2232  void* dum_struct2_ptr = &dum_struct2;
2233  int dum_struct_alloc = sizeof( struct TagStruct ), dum_struct_size;
2234 
2235  /* create a tag */
2236  const char* tag_name = "set_struct_tag";
2237  iMesh_createTag( mesh, tag_name, sizeof( struct TagStruct ), iBase_BYTES, struct_tag, &result, 11 );
2238  if( iBase_SUCCESS != result )
2239  {
2240  printf( "Failed to create tag struct_tag in entityset_struct_tag_test.\n" );
2241  return FALSE;
2242  }
2243 
2244  /* put a value in the first vertex and retrieve */
2245 
2246  /* careful setting the value, since tags are opaque */
2247  iMesh_setEntSetData( mesh, root_set, *struct_tag, (const char*)&dum_struct, sizeof( struct TagStruct ), &result );
2248  if( iBase_SUCCESS != result )
2249  {
2250  printf( "Failed to set struct tag in entityset_struct_tag_test.\n" );
2251  return FALSE;
2252  }
2253 
2254  iMesh_getEntSetData( mesh, root_set, *struct_tag, &dum_struct2_ptr, &dum_struct_alloc, &dum_struct_size, &result );
2255  if( iBase_SUCCESS != result )
2256  {
2257  printf( "Failed to get struct tag in entityset_struct_tag_test.\n" );
2258  return FALSE;
2259  }
2260 
2261  if( dum_struct_size != sizeof( struct TagStruct ) )
2262  {
2263  printf( "Size of entityset struct tag wrong.\n" );
2264  return FALSE;
2265  }
2266  if( dum_struct2.test_int1 != dum_struct.test_int1 || dum_struct2.test_int2 != dum_struct.test_int2 ||
2267  dum_struct2.test_double != dum_struct.test_double )
2268  {
2269  printf( "Value of entityset struct tag wrong.\n" );
2270  return FALSE;
2271  }
2272 
2273  /* ok, the int tag test worked */
2274  return TRUE;
2275 }

References FALSE, iBase_BYTES, iBase_SUCCESS, iMesh_createTag, iMesh_getEntSetData, iMesh_setEntSetData, mesh, root_set, TagStruct::test_double, TagStruct::test_int1, TagStruct::test_int2, and TRUE.

Referenced by entityset_tag_test().

◆ entityset_tag_delete_test()

int entityset_tag_delete_test ( iMesh_Instance  mesh,
iBase_EntitySetHandle sets,
int  sets_size 
)

Definition at line 2277 of file testc_cbind.cpp.

2278 {
2279  /* test forced, unforced deletion of tags from entities */
2280  int result;
2281  int delete_err = FALSE;
2282 
2283  /* test getAlliBase_TagHandles for first entity */
2284  iBase_TagHandle* all_tags = NULL;
2285  if( sets_size < 1 )
2286  {
2287  printf( "no sets.\n" );
2288  return FALSE;
2289  }
2290  iBase_EntitySetHandle dum_entity = sets[0];
2291  int all_tags_alloc = 0, all_tags_size;
2292  iMesh_getAllEntSetTags( mesh, sets[0], &all_tags, &all_tags_alloc, &all_tags_size, &result );
2293  if( iBase_SUCCESS != result )
2294  {
2295  printf( "Couldn't get all tag handles from entityset.\n" );
2296  free( all_tags );
2297  return FALSE;
2298  }
2299 
2300  iMesh_rmvEntSetTag( mesh, dum_entity, all_tags[0], &result );
2301  if( iBase_SUCCESS != result )
2302  {
2303  printf( "Couldn't remove tag from entityset.\n" );
2304  free( all_tags );
2305  return FALSE;
2306  }
2307 
2308  iMesh_destroyTag( mesh, all_tags[1], FALSE, &result );
2309  if( iBase_SUCCESS != result )
2310  {
2311  delete_err = TRUE;
2312  }
2313  if( !delete_err )
2314  {
2315  printf( "Error when unforced-deleting tag in use on a entityset.\n" );
2316  free( all_tags );
2317  return FALSE;
2318  }
2319 
2320  iMesh_destroyTag( mesh, all_tags[1], TRUE, &result );
2321  if( iBase_SUCCESS != result )
2322  {
2323  printf( "Couldn't force-delete a tag in use on a entityset.\n" );
2324  free( all_tags );
2325  return FALSE;
2326  }
2327 
2328  free( all_tags );
2329 
2330  /* ok, we're done */
2331  return TRUE;
2332 }

References FALSE, iBase_SUCCESS, iMesh_destroyTag, iMesh_getAllEntSetTags, iMesh_rmvEntSetTag, mesh, and TRUE.

Referenced by entityset_tag_test().

◆ entityset_tag_test()

int entityset_tag_test ( iMesh_Instance  mesh)
Test:
TSTT entityset tag Test
  • Check entityset tags

Definition at line 2339 of file testc_cbind.cpp.

2340 {
2341  int result;
2342  iBase_TagHandle int_tag, double_tag, struct_tag;
2343  int int_success, double_success, struct_success, tag_delete_success;
2344 
2345  /* get the sets */
2346  iBase_EntitySetHandle* esets = NULL;
2347  int esets_alloc = 0, esets_size;
2348  iMesh_getEntSets( mesh, root_set, 1, &esets, &esets_alloc, &esets_size, &result );
2349  if( iBase_SUCCESS != result )
2350  {
2351  printf( "entitysetGetEntities failed in entityset_tag_test.\n" );
2352  free( esets );
2353  return FALSE;
2354  }
2355 
2356  /* entityset int tag */
2357  int_success = entityset_int_tag_test( mesh, esets, esets_size, &int_tag );
2358 
2359  /* entityeset double tag */
2360  double_success = entityset_double_tag_test( mesh, esets, esets_size, &double_tag );
2361 
2362  /* entityset struct tag */
2363  struct_success = entityset_struct_tag_test( mesh, esets, esets_size, &struct_tag );
2364 
2365  tag_delete_success = entityset_tag_delete_test( mesh, esets, esets_size );
2366 
2367  free( esets );
2368 
2369  return ( int_success && double_success && struct_success && tag_delete_success );
2370 }

References entityset_double_tag_test(), entityset_int_tag_test(), entityset_struct_tag_test(), entityset_tag_delete_test(), FALSE, iBase_SUCCESS, iMesh_getEntSets, mesh, and root_set.

Referenced by main().

◆ error_code_test()

◆ handle_error_code()

void handle_error_code ( const int  result,
int *  number_failed,
int *  ,
int *  number_successful 
)

prints out a result string based on the value of error_code

Definition at line 110 of file testc_cbind.cpp.

111 {
112  if( result )
113  {
114  printf( "Success\n" );
115  ( *number_successful )++;
116  }
117  else
118  {
119  printf( "Failure\n" );
120  ( *number_failed )++;
121  }
122 }

Referenced by main().

◆ load_mesh_test()

int load_mesh_test ( const char *  filename,
iMesh_Instance  mesh 
)
Test:
Load Mesh
  • Load a mesh file

Definition at line 129 of file testc_cbind.cpp.

130 {
131  /* load a mesh */
132  int result;
133  iMesh_load( mesh, root_set, filename, NULL, &result, strlen( filename ), 0 );
134  if( iBase_SUCCESS != result )
135  {
136  printf( "ERROR : can not load a mesh from file %s\n", filename );
137  return FALSE;
138  }
139 
140  return TRUE;
141 }

References FALSE, filename, iBase_SUCCESS, iMesh_load, mesh, root_set, and TRUE.

Referenced by main().

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 3093 of file testc_cbind.cpp.

3094 {
3095  /* Check command line arg */
3096  const char* filename;
3097  int number_tests = 0;
3098  int number_tests_successful = 0;
3099  int number_tests_not_implemented = 0;
3100  int number_tests_failed = 0;
3101  int result;
3102  iMesh_Instance mesh = NULL;
3103 
3104  if( argc == 2 )
3105  {
3106  filename = argv[1];
3107  }
3108  else
3109  {
3110  printf( "Usage: %s <mesh_filename>\n", argv[0] );
3111  if( argc != 1 ) return 1;
3112  printf( " No file specified. Defaulting to: %s\n", DEFAULT_INPUT_FILE );
3114  }
3115 
3116  /* initialize the Mesh */
3117  iMesh_newMesh( NULL, &mesh, &result, 0 );
3118  if( iBase_SUCCESS != result )
3119  {
3120  printf( "Failed to create a mesh instance.\n" );
3121  return 1;
3122  }
3123  iMesh_getRootSet( mesh, &root_set, &result );
3124  if( iBase_SUCCESS != result )
3125  {
3126  printf( "Failed to return a root set.\n" );
3127  return 1;
3128  }
3129 
3130  /* Print out Header information */
3131  printf( "\n\nTSTT TEST PROGRAM:\n\n" );
3132 
3133  /* load_mesh test */
3134  printf( " load_mesh: " );
3135  result = load_mesh_test( filename, mesh );
3136  handle_error_code( result, &number_tests_failed, &number_tests_not_implemented, &number_tests_successful );
3137  number_tests++;
3138  printf( "\n" );
3139 
3140  /* topology_adjacency_test */
3141  printf( " topology_adjacency_test: " );
3142  result = topology_adjacency_test( mesh );
3143  handle_error_code( result, &number_tests_failed, &number_tests_not_implemented, &number_tests_successful );
3144  number_tests++;
3145  printf( "\n" );
3146 
3147  /* entity connectivity test */
3148  printf( " entity_connectivity_test: " );
3149  result = entity_connectivity_test( mesh );
3150  handle_error_code( result, &number_tests_failed, &number_tests_not_implemented, &number_tests_successful );
3151  number_tests++;
3152  printf( "\n" );
3153 
3154  /* vertex_coordinates_test */
3155  printf( " vertex_coordinates_test: " );
3156  result = vertex_coordinates_test( mesh );
3157  handle_error_code( result, &number_tests_failed, &number_tests_not_implemented, &number_tests_successful );
3158  number_tests++;
3159  printf( "\n" );
3160 
3161  /* topology dimension test */
3162  printf( " topology_dimension_test: " );
3163  result = topology_dimension_test( mesh );
3164  handle_error_code( result, &number_tests_failed, &number_tests_not_implemented, &number_tests_successful );
3165  number_tests++;
3166  printf( "\n" );
3167 
3168  /* entity sets test */
3169  printf( " entity_sets_test: " );
3170  result = entity_sets_test( mesh );
3171  handle_error_code( result, &number_tests_failed, &number_tests_not_implemented, &number_tests_successful );
3172  number_tests++;
3173  printf( "\n" );
3174 
3175  /* vertex tag test */
3176  printf( " vertex_tag_test: " );
3177  result = vertex_tag_test( mesh );
3178  handle_error_code( result, &number_tests_failed, &number_tests_not_implemented, &number_tests_successful );
3179  number_tests++;
3180  printf( "\n" );
3181 
3182  /* entityset tag test */
3183  printf( " entityset_tag_test: " );
3184  result = entityset_tag_test( mesh );
3185  handle_error_code( result, &number_tests_failed, &number_tests_not_implemented, &number_tests_successful );
3186  number_tests++;
3187  printf( "\n" );
3188 
3189  /* mesh tag test */
3190  printf( " mesh_tag_test: " );
3191  result = mesh_tag_test( mesh );
3192  handle_error_code( result, &number_tests_failed, &number_tests_not_implemented, &number_tests_successful );
3193  number_tests++;
3194  printf( "\n" );
3195 
3196  /* iterator test */
3197  printf( " test_iterator: " );
3198  result = test_iterator( mesh );
3199  handle_error_code( result, &number_tests_failed, &number_tests_not_implemented, &number_tests_successful );
3200  number_tests++;
3201  printf( "\n" );
3202 
3203  /* regression test for remove/contained bug */
3204  printf( " set_remove_contained_regression: " );
3206  handle_error_code( result, &number_tests_failed, &number_tests_not_implemented, &number_tests_successful );
3207  number_tests++;
3208  printf( "\n" );
3209 
3210  /* regression test for adjacencies with iBase_ALL_TYPES bug */
3211  printf( " all_adjacency_regression: " );
3212  result = all_adjacency_regression( mesh );
3213  handle_error_code( result, &number_tests_failed, &number_tests_not_implemented, &number_tests_successful );
3214  number_tests++;
3215  printf( "\n" );
3216 
3217  /* test for error codes */
3218  printf( " error_code_test: " );
3219  result = error_code_test( mesh );
3220  handle_error_code( result, &number_tests_failed, &number_tests_not_implemented, &number_tests_successful );
3221  number_tests++;
3222  printf( "\n" );
3223 
3224  /* regression test for ordered sets not preserving order */
3225  printf( " ordered_set_regression: " );
3226  result = ordered_set_regression( mesh );
3227  handle_error_code( result, &number_tests_failed, &number_tests_not_implemented, &number_tests_successful );
3228  number_tests++;
3229  printf( "\n" );
3230 
3231  /* test for array allocation behavior */
3232  printf( " array_allocation_regression: " );
3233  result = array_allocation( mesh );
3234  handle_error_code( result, &number_tests_failed, &number_tests_not_implemented, &number_tests_successful );
3235  number_tests++;
3236  printf( "\n" );
3237 
3238  /* summary */
3239 
3240  printf( "\nTSTT TEST SUMMARY: \n" );
3241 
3242  printf( " Number Tests: %d\n", number_tests );
3243  printf( " Number Successful: %d\n", number_tests_successful );
3244  printf( " Number Not Implemented: %d\n", number_tests_not_implemented );
3245  printf( " Number Failed: %d\n", number_tests_failed );
3246  printf( "\n\n\n" );
3247 
3248  /* delete the mesh */
3249  iMesh_dtor( mesh, &result );
3250  if( iBase_SUCCESS != result )
3251  {
3252  printf( "Failed to destruct the mesh instance.\n" );
3253  return 1;
3254  }
3255 
3256  return number_tests_failed;
3257 }

References all_adjacency_regression(), array_allocation(), DEFAULT_INPUT_FILE, entity_connectivity_test(), entity_sets_test(), entityset_tag_test(), error_code_test(), filename, handle_error_code(), iBase_SUCCESS, iMesh_dtor, iMesh_getRootSet, iMesh_newMesh, load_mesh_test(), mesh, mesh_tag_test(), number_tests, number_tests_failed, number_tests_successful, ordered_set_regression(), root_set, set_remove_contained_regression(), test_iterator(), topology_adjacency_test(), topology_dimension_test(), vertex_coordinates_test(), and vertex_tag_test().

◆ mesh_double_tag_test()

int mesh_double_tag_test ( iMesh_Instance  mesh,
iBase_TagHandle double_tag 
)

Definition at line 2437 of file testc_cbind.cpp.

2438 {
2439  int result;
2440  double dum_val = 1.0e6, dum_val2;
2441  void* dum_val2_ptr = &dum_val2;
2442  int dum_val2_alloc = sizeof( double ), dum_val2_size;
2443 
2444  /* create a tag */
2445  const char* tag_name = "mesh_double_tag";
2446  iMesh_createTag( mesh, tag_name, 1, iBase_DOUBLE, double_tag, &result, 15 );
2447  if( iBase_SUCCESS != result )
2448  {
2449  printf( "Failed to create tag double_tag in mesh_double_tag_test.\n" );
2450  return FALSE;
2451  }
2452 
2453  /* put a value in the first set and retrieve */
2454 
2455  iMesh_setEntSetData( mesh, root_set, *double_tag, (char*)( &dum_val ), sizeof( double ), &result );
2456  if( iBase_SUCCESS != result )
2457  {
2458  printf( "Failed to set double tag (val=11) in mesh_double_tag_test.\n" );
2459  return FALSE;
2460  }
2461 
2462  dum_val2 = 0;
2463  iMesh_getEntSetData( mesh, root_set, *double_tag, &dum_val2_ptr, &dum_val2_alloc, &dum_val2_size, &result );
2464  if( iBase_SUCCESS != result )
2465  {
2466  printf( "Failed to get double tag (val=1.0e6) in mesh_double_tag_test." );
2467  return FALSE;
2468  }
2469 
2470  if( dum_val2 != 1.0e6 )
2471  {
2472  printf( "Value of entityset tag (val=11) wrong.\n" );
2473  return FALSE;
2474  }
2475 
2476  /* put a value in the last faces and retrieve */
2477  dum_val = 2.0e9;
2478  iMesh_setEntSetData( mesh, root_set, *double_tag, (char*)( &dum_val ), sizeof( double ), &result );
2479  if( iBase_SUCCESS != result )
2480  {
2481  printf( "Failed to set double tag (val=2.0e9) in mesh_double_tag_test." );
2482  return FALSE;
2483  }
2484 
2485  iMesh_getEntSetData( mesh, root_set, *double_tag, &dum_val2_ptr, &dum_val2_alloc, &dum_val2_size, &result );
2486  if( iBase_SUCCESS != result )
2487  {
2488  printf( "Failed to get double tag (val=2.0e9) in mesh_double_tag_test." );
2489  return FALSE;
2490  }
2491 
2492  if( dum_val2 != 2.0e9 )
2493  {
2494  printf( "Value of entityset tag (val=2.0e9) wrong.\n" );
2495  return FALSE;
2496  }
2497 
2498  /* ok, the double tag test worked */
2499  return TRUE;
2500 }

References FALSE, iBase_DOUBLE, iBase_SUCCESS, iMesh_createTag, iMesh_getEntSetData, iMesh_setEntSetData, mesh, root_set, and TRUE.

Referenced by mesh_tag_test().

◆ mesh_int_tag_test()

int mesh_int_tag_test ( iMesh_Instance  mesh,
iBase_TagHandle int_tag 
)

Definition at line 2372 of file testc_cbind.cpp.

2373 {
2374  int result;
2375  int dum_val = 11, dum_val2;
2376  void* dum_val2_ptr = &dum_val2;
2377  int dum_val2_alloc = sizeof( int ), dum_val2_size;
2378 
2379  /* create a tag */
2380  const char* tag_name = "mesh_int_tag";
2381  iMesh_createTag( mesh, tag_name, 1, iBase_INTEGER, int_tag, &result, 12 );
2382  if( iBase_SUCCESS != result )
2383  {
2384  printf( "Failed to create tag int_tag in mesh_int_tag_test.\n" );
2385  return FALSE;
2386  }
2387 
2388  /* put a value in the first set and retrieve */
2389 
2390  iMesh_setEntSetData( mesh, root_set, *int_tag, (char*)( &dum_val ), sizeof( int ), &result );
2391  if( iBase_SUCCESS != result )
2392  {
2393  printf( "Failed to set int tag (val=11) in mesh_int_tag_test.\n" );
2394  return FALSE;
2395  }
2396 
2397  dum_val2 = 0;
2398  iMesh_getEntSetData( mesh, root_set, *int_tag, &dum_val2_ptr, &dum_val2_alloc, &dum_val2_size, &result );
2399  if( iBase_SUCCESS != result )
2400  {
2401  printf( "Failed to get int tag (val=11) in mesh_int_tag_test." );
2402  return FALSE;
2403  }
2404 
2405  if( dum_val2 != 11 )
2406  {
2407  printf( "Value of entityset tag (val=11) wrong.\n" );
2408  return FALSE;
2409  }
2410 
2411  /* put a value in the last faces and retrieve */
2412  dum_val = 12;
2413  iMesh_setEntSetData( mesh, root_set, *int_tag, (char*)( &dum_val ), sizeof( int ), &result );
2414  if( iBase_SUCCESS != result )
2415  {
2416  printf( "Failed to set int tag (val=12) in mesh_int_tag_test." );
2417  return FALSE;
2418  }
2419 
2420  iMesh_getEntSetData( mesh, root_set, *int_tag, &dum_val2_ptr, &dum_val2_alloc, &dum_val2_size, &result );
2421  if( iBase_SUCCESS != result )
2422  {
2423  printf( "Failed to get int tag (val=12) in mesh_int_tag_test." );
2424  return FALSE;
2425  }
2426 
2427  if( dum_val2 != 12 )
2428  {
2429  printf( "Value of entityset tag (val=12) wrong.\n" );
2430  return FALSE;
2431  }
2432 
2433  /* ok, the int tag test worked */
2434  return TRUE;
2435 }

References FALSE, iBase_INTEGER, iBase_SUCCESS, iMesh_createTag, iMesh_getEntSetData, iMesh_setEntSetData, mesh, root_set, and TRUE.

Referenced by mesh_tag_test().

◆ mesh_struct_tag_test()

int mesh_struct_tag_test ( iMesh_Instance  mesh,
iBase_TagHandle struct_tag 
)

Definition at line 2502 of file testc_cbind.cpp.

2503 {
2504  int result;
2505  struct TagStruct dum_struct = { 3.0e12, 2, 3 }, dum_struct2;
2506  void* dum_struct2_ptr = &dum_struct2;
2507  int dum_struct_alloc = sizeof( struct TagStruct ), dum_struct_size;
2508 
2509  /* create a tag */
2510  const char* tag_name = "mesh_struct_tag";
2511  iMesh_createTag( mesh, tag_name, sizeof( struct TagStruct ), iBase_BYTES, struct_tag, &result, 11 );
2512  if( iBase_SUCCESS != result )
2513  {
2514  printf( "Failed to create tag struct_tag in vertex_struct_tag_test.\n" );
2515  return FALSE;
2516  }
2517 
2518  /* put a value in the first vertex and retrieve */
2519 
2520  /* careful setting the value, since tags are opaque */
2521  iMesh_setEntSetData( mesh, root_set, *struct_tag, (const char*)&dum_struct, sizeof( struct TagStruct ), &result );
2522  if( iBase_SUCCESS != result )
2523  {
2524  printf( "Failed to set struct tag in mesh_struct_tag_test.\n" );
2525  return FALSE;
2526  }
2527 
2528  iMesh_getEntSetData( mesh, root_set, *struct_tag, &dum_struct2_ptr, &dum_struct_alloc, &dum_struct_size, &result );
2529  if( iBase_SUCCESS != result )
2530  {
2531  printf( "Failed to get struct tag in mesh_struct_tag_test.\n" );
2532  return FALSE;
2533  }
2534 
2535  if( dum_struct_size != sizeof( struct TagStruct ) )
2536  {
2537  printf( "Size of entityset struct tag wrong.\n" );
2538  return FALSE;
2539  }
2540  if( dum_struct2.test_int1 != dum_struct.test_int1 || dum_struct2.test_int2 != dum_struct.test_int2 ||
2541  dum_struct2.test_double != dum_struct.test_double )
2542  {
2543  printf( "Value of entityset struct tag wrong.\n" );
2544  return FALSE;
2545  }
2546 
2547  /* ok, the int tag test worked */
2548  return TRUE;
2549 }

References FALSE, iBase_BYTES, iBase_SUCCESS, iMesh_createTag, iMesh_getEntSetData, iMesh_setEntSetData, mesh, root_set, TagStruct::test_double, TagStruct::test_int1, TagStruct::test_int2, and TRUE.

Referenced by mesh_tag_test().

◆ mesh_tag_delete_test()

int mesh_tag_delete_test ( iMesh_Instance  mesh)

Definition at line 2551 of file testc_cbind.cpp.

2552 {
2553  /* test forced, unforced deletion of tags from entities */
2554  int result;
2555  int delete_err = FALSE;
2556 
2557  /* test getAlliBase_TagHandles for first entity */
2558  iBase_TagHandle* all_tags = NULL;
2559  int all_tags_alloc = 0, all_tags_size;
2560  iMesh_getAllEntSetTags( mesh, root_set, &all_tags, &all_tags_alloc, &all_tags_size, &result );
2561  if( iBase_SUCCESS != result )
2562  {
2563  printf( "Couldn't get all tag handles from entityset.\n" );
2564  return FALSE;
2565  }
2566 
2567  iMesh_rmvEntSetTag( mesh, root_set, all_tags[0], &result );
2568  if( iBase_SUCCESS != result )
2569  {
2570  printf( "Couldn't remove tag from entityset.\n" );
2571  free( all_tags );
2572  return FALSE;
2573  }
2574 
2575  iMesh_destroyTag( mesh, all_tags[1], FALSE, &result );
2576  if( iBase_SUCCESS != result )
2577  {
2578  delete_err = TRUE;
2579  }
2580  if( !delete_err )
2581  {
2582  printf( "Error when unforced-deleting tag in use on a entityset.\n" );
2583  free( all_tags );
2584  return FALSE;
2585  }
2586 
2587  iMesh_destroyTag( mesh, all_tags[1], TRUE, &result );
2588  if( iBase_SUCCESS != result )
2589  {
2590  printf( "Couldn't force-delete a tag in use on a entityset.\n" );
2591  free( all_tags );
2592  return FALSE;
2593  }
2594 
2595  free( all_tags );
2596 
2597  /* ok, we're done */
2598  return TRUE;
2599 }

References FALSE, iBase_SUCCESS, iMesh_destroyTag, iMesh_getAllEntSetTags, iMesh_rmvEntSetTag, mesh, root_set, and TRUE.

Referenced by mesh_tag_test().

◆ mesh_tag_test()

int mesh_tag_test ( iMesh_Instance  mesh)
Test:
TSTT entityset tag Test
  • Check entityset tags

Definition at line 2606 of file testc_cbind.cpp.

2607 {
2608  iBase_TagHandle int_tag, double_tag, struct_tag;
2609 
2610  /* entityset int tag */
2611  int int_success = mesh_int_tag_test( mesh, &int_tag );
2612 
2613  /* entityeset double tag */
2614  int double_success = mesh_double_tag_test( mesh, &double_tag );
2615 
2616  /* entityset struct tag */
2617  int struct_success = mesh_struct_tag_test( mesh, &struct_tag );
2618 
2619  int tag_delete_success = mesh_tag_delete_test( mesh );
2620 
2621  return ( int_success && double_success && struct_success && tag_delete_success );
2622 }

References mesh, mesh_double_tag_test(), mesh_int_tag_test(), mesh_struct_tag_test(), and mesh_tag_delete_test().

Referenced by main().

◆ ordered_set_regression()

static int ordered_set_regression ( iMesh_Instance  mesh)
static

Definition at line 2711 of file testc_cbind.cpp.

2712 {
2713  double coords[] = { 0, 0, 0, 1, 1, 1 };
2714  iBase_EntityHandle line, *p, verts[2], ents_in[3], ents_out[3];
2716  int i, err, status, two = 2, three = 3;
2717 
2718  iMesh_newMesh( "", &mesh, &err, 0 );
2719  CHK( err );
2720  p = verts;
2721  iMesh_createVtxArr( mesh, 2, iBase_INTERLEAVED, coords, 6, &p, &two, &two, &err );
2722  CHK( err );
2723  iMesh_createEnt( mesh, iMesh_LINE_SEGMENT, verts, 2, &line, &status, &err );
2724  CHK( err );
2725  if( status != iBase_NEW ) return 0;
2726  iMesh_createEntSet( mesh, 1, &set, &err );
2727  CHK( err );
2728  ents_in[0] = verts[1];
2729  ents_in[1] = line;
2730  ents_in[2] = verts[0];
2731  iMesh_addEntArrToSet( mesh, ents_in, three, set, &err );
2732  CHK( err );
2733  p = ents_out;
2734  iMesh_getEntities( mesh, set, iBase_ALL_TYPES, iMesh_ALL_TOPOLOGIES, &p, &three, &three, &err );
2735  CHK( err );
2736  for( i = 0; i < three; i++ )
2737  {
2738  if( ents_in[i] != ents_out[i] )
2739  {
2740  printf( "Ordered set does not preserve order\n" );
2741  return 0;
2742  }
2743  }
2744  iMesh_dtor( mesh, &err );
2745  CHK( err );
2746  return 1;
2747 }

References CHK, iBase_ALL_TYPES, iBase_INTERLEAVED, iBase_NEW, iMesh_addEntArrToSet, iMesh_ALL_TOPOLOGIES, iMesh_createEnt, iMesh_createEntSet, iMesh_createVtxArr, iMesh_dtor, iMesh_getEntities, iMesh_LINE_SEGMENT, iMesh_newMesh, and mesh.

Referenced by main().

◆ PRINT_ASSERT_FAILURE()

void PRINT_ASSERT_FAILURE ( const char *  cond,
const char *  file,
int  line 
)

Definition at line 90 of file testc_cbind.cpp.

91 {
92  printf( "Condition: %s\n", cond );
93  printf( " failed at %s line %d\n", file, line );
94 }

◆ qsort_comp_handles()

int qsort_comp_handles ( const void *  h1,
const void *  h2 
)

Definition at line 503 of file testc_cbind.cpp.

504 {
505  return *(char**)h1 - *(char**)h2;
506 }

References h1.

Referenced by entity_connectivity_test().

◆ set_remove_contained_regression()

int set_remove_contained_regression ( iMesh_Instance  mesh)

Definition at line 2624 of file testc_cbind.cpp.

2625 {
2626  int err, contained;
2627  iBase_EntitySetHandle set, sub;
2628 
2629  iMesh_createEntSet( mesh, 0, &set, &err );
2630  if( iBase_SUCCESS != err ) return 0;
2631  iMesh_createEntSet( mesh, 1, &sub, &err );
2632  if( iBase_SUCCESS != err ) return 0;
2633 
2634  iMesh_addEntSet( mesh, sub, set, &err );
2635  if( iBase_SUCCESS != err ) return 0;
2636 
2637  iMesh_isEntSetContained( mesh, set, sub, &contained, &err );
2638  if( iBase_SUCCESS != err ) return 0;
2639  if( !contained )
2640  {
2641  fprintf( stderr, "isEntSetContained returned false for contained set\n" );
2642  return 0;
2643  }
2644 
2645  iMesh_rmvEntSet( mesh, sub, set, &err );
2646  if( iBase_SUCCESS != err ) return 0;
2647 
2648  iMesh_isEntSetContained( mesh, set, sub, &contained, &err );
2649  if( iBase_SUCCESS != err ) return 0;
2650  if( contained )
2651  {
2652  fprintf( stderr, "isEntSetContained returned true for removed set\n" );
2653  return 0;
2654  }
2655 
2656  return 1;
2657 }

References contained(), iBase_SUCCESS, iMesh_addEntSet, iMesh_createEntSet, iMesh_isEntSetContained, iMesh_rmvEntSet, and mesh.

Referenced by main().

◆ tag_info_test()

int tag_info_test ( iMesh_Instance  mesh)
Test:
TSTT Tag Info test
  • Tests tagCreate, tagDelete, tagGetName, tagGetSize, tagGetHandle

Definition at line 1724 of file testc_cbind.cpp.

1725 {
1726  char dum_name[120];
1727  int dum_name_size = 120;
1728  int dum_size;
1729  int error = FALSE;
1730  iBase_TagHandle dum_handle;
1731  /* Create a tag */
1732  int result;
1733  iBase_TagHandle tag_handle = NULL;
1734  const char* tag_name = "int_tag";
1735  int tag_name_size = 8;
1736  iMesh_createTag( mesh, tag_name, 1, iBase_INTEGER, &tag_handle, &result, tag_name_size );
1737  if( iBase_SUCCESS != result )
1738  {
1739  printf( "Failed to create tag int_tag in vertex_tag_test." );
1740  return FALSE;
1741  }
1742 
1743  /* check tag info functions */
1744  iMesh_getTagName( mesh, tag_handle, dum_name, &result, dum_name_size );
1745  if( iBase_SUCCESS != result )
1746  {
1747  printf( "Couldn't get name of tag just created.\n" );
1748  return FALSE;
1749  }
1750  if( strcmp( dum_name, "int_tag" ) != 0 )
1751  {
1752  printf( "Tag names didn't match.\n" );
1753  return FALSE;
1754  }
1755 
1756  iMesh_getTagSizeBytes( mesh, tag_handle, &dum_size, &result );
1757  if( iBase_SUCCESS != result )
1758  {
1759  printf( "Couldn't get size of tag just created.\n" );
1760  return FALSE;
1761  }
1762  if( dum_size != sizeof( int ) )
1763  {
1764  printf( "Tag sizes didn't match.\n" );
1765  return FALSE;
1766  }
1767 
1768  iMesh_getTagHandle( mesh, tag_name, &dum_handle, &result, tag_name_size );
1769  if( iBase_SUCCESS != result )
1770  {
1771  printf( "Couldn't get handle of tag just created.\n" );
1772  return FALSE;
1773  }
1774  if( dum_handle != tag_handle )
1775  {
1776  printf( "Tag handles didn't match.\n" );
1777  return FALSE;
1778  }
1779 
1780  /* test non-forced version of tagDelete; forced version tested later, */
1781  /* when we have entities around */
1782  iMesh_destroyTag( mesh, tag_handle, FALSE, &result );
1783  if( iBase_SUCCESS != result )
1784  {
1785  printf( "Couldn't delete tag just created.\n" );
1786  return FALSE;
1787  }
1788 
1789  /* look for that tag, to make sure it got deleted */
1790  iMesh_getTagHandle( mesh, tag_name, &tag_handle, &result, tag_name_size );
1791  if( iBase_SUCCESS != result )
1792  {
1793  error = TRUE;
1794  }
1795  if( !error )
1796  {
1797  printf( "tagGetHandle was able to find handle for deleted tag.\n" );
1798  return FALSE;
1799  }
1800 
1801  return TRUE;
1802 }

References moab::error(), FALSE, iBase_INTEGER, iBase_SUCCESS, iMesh_createTag, iMesh_destroyTag, iMesh_getTagHandle, iMesh_getTagName, iMesh_getTagSizeBytes, mesh, and TRUE.

Referenced by vertex_tag_test().

◆ test_iterator()

int test_iterator ( iMesh_Instance  mesh)

Definition at line 3027 of file testc_cbind.cpp.

3028 {
3029  int result, i;
3030  iBase_EntitySetHandle root, list, set, *setptr;
3031  iBase_EntityHandle* array = NULL;
3032  int array_len = 0, array_size = 0;
3033 
3034  iMesh_getRootSet( mesh, &root, &result );
3035  CHK( result );
3036 
3037  /* create some sets containing every other handle */
3038  iMesh_getEntities( mesh, root, iBase_ALL_TYPES, iMesh_ALL_TOPOLOGIES, &array, &array_size, &array_len, &result );
3039  CHK( result );
3040  for( i = 1; i < array_size; i += 2 )
3041  array[i] = array[i - 1];
3042  for( i = 0; i < 2; ++i )
3043  {
3044  setptr = i ? &list : &set;
3045  iMesh_createEntSet( mesh, i, setptr, &result );
3046  if( iBase_SUCCESS != result ) free( array );
3047  CHK( result );
3048  iMesh_addEntArrToSet( mesh, array, array_size, *setptr, &result );
3049  if( iBase_SUCCESS != result ) free( array );
3050  CHK( result );
3051  }
3052  free( array );
3053 
3054  /* test single iterator and array iterator for all types */
3055  for( i = 0; i < iBase_ALL_TYPES; ++i )
3056  {
3057  array_size = 2 * i + 2;
3058  result = test_iterator_common( "root", mesh, root, 1, (enum iBase_EntityType)i, iMesh_ALL_TOPOLOGIES );
3059  CHK( result );
3060  result = test_iterator_common( "root", mesh, root, array_size, (enum iBase_EntityType)i, iMesh_ALL_TOPOLOGIES );
3061  CHK( result );
3062  result = test_iterator_common( "list", mesh, list, 1, (enum iBase_EntityType)i, iMesh_ALL_TOPOLOGIES );
3063  CHK( result );
3064  result = test_iterator_common( "list", mesh, list, array_size, (enum iBase_EntityType)i, iMesh_ALL_TOPOLOGIES );
3065  CHK( result );
3066  result = test_iterator_common( "set", mesh, set, 1, (enum iBase_EntityType)i, iMesh_ALL_TOPOLOGIES );
3067  CHK( result );
3068  result = test_iterator_common( "set", mesh, set, array_size, (enum iBase_EntityType)i, iMesh_ALL_TOPOLOGIES );
3069  CHK( result );
3070  }
3071 
3072  /* test single iterator and array iterator for all types */
3073  for( i = 0; i < iMesh_ALL_TOPOLOGIES; ++i )
3074  {
3075  array_size = 2 * i + 2;
3076  result = test_iterator_common( "root", mesh, root, 1, iBase_ALL_TYPES, (enum iMesh_EntityTopology)i );
3077  CHK( result );
3078  result = test_iterator_common( "root", mesh, root, array_size, iBase_ALL_TYPES, (enum iMesh_EntityTopology)i );
3079  CHK( result );
3080  result = test_iterator_common( "list", mesh, list, 1, iBase_ALL_TYPES, (enum iMesh_EntityTopology)i );
3081  CHK( result );
3082  result = test_iterator_common( "list", mesh, list, array_size, iBase_ALL_TYPES, (enum iMesh_EntityTopology)i );
3083  CHK( result );
3084  result = test_iterator_common( "set", mesh, set, 1, iBase_ALL_TYPES, (enum iMesh_EntityTopology)i );
3085  CHK( result );
3086  result = test_iterator_common( "set", mesh, set, array_size, iBase_ALL_TYPES, (enum iMesh_EntityTopology)i );
3087  CHK( result );
3088  }
3089 
3090  return 1;
3091 }

References CHK, iBase_ALL_TYPES, iBase_SUCCESS, iMesh_addEntArrToSet, iMesh_ALL_TOPOLOGIES, iMesh_createEntSet, iMesh_getEntities, iMesh_getRootSet, mesh, and test_iterator_common().

Referenced by main().

◆ test_iterator_common()

int test_iterator_common ( const char *  info,
iMesh_Instance  mesh,
iBase_EntitySetHandle  set,
int  array_size,
enum iBase_EntityType  type,
enum iMesh_EntityTopology  topo 
)

Definition at line 3006 of file testc_cbind.cpp.

3012 {
3013  iBase_EntityHandle* contents = NULL;
3014  int content_size = 0, content_alloc = 0;
3015  int result;
3016 
3017  iMesh_getEntities( mesh, set, type, topo, &contents, &content_alloc, &content_size, &result );
3018  CHK( result );
3019  if( array_size == 1 )
3020  result = compare_single_iter( info, mesh, set, contents, content_size, type, topo );
3021  else
3022  result = compare_array_iter( info, mesh, set, contents, content_size, array_size, type, topo );
3023  free( contents );
3024  return result;
3025 }

References CHK, compare_array_iter(), compare_single_iter(), iMesh_getEntities, and mesh.

Referenced by test_iterator().

◆ topology_adjacency_test()

int topology_adjacency_test ( iMesh_Instance  mesh)
Test:
TSTT topology adjacency Test
  • Check topology information
  • Check adjacency
  • Get interior and exterior elements

Definition at line 229 of file testc_cbind.cpp.

230 {
231  int result, i, j, entities_alloc, entities_size, *topologies;
232  int topologies_alloc, topologies_size;
233  iBase_EntityHandle *entities, *entity_vectors[iMesh_ALL_TOPOLOGIES] = { NULL };
234  int entity_vectors_sizes[iMesh_ALL_TOPOLOGIES] = { 0 };
235  int top_j, num_tops, region_type, num_region;
236  iBase_EntityHandle* adj_faces = NULL;
237  int adj_faces_alloc = 0, adj_faces_size;
238  int* face_offsets = NULL;
239  int face_offsets_alloc = 0, face_offsets_size, face_loaded;
240  iBase_EntityHandle* adj_regions = NULL;
241  int adj_regions_alloc = 0, adj_regions_size;
242  int* region_offsets = NULL;
243  int region_offsets_alloc = 0, region_offsets_size;
244  iBase_EntityHandle *interior, *exterior;
245  int num_int = 0, num_ext = 0, found, next_offset, iter;
246  int num_faces_per_region;
247  ;
248 
249  /* fill the vectors of each topology entities */
250  /* like lines vector, polygon vector, triangle vector, */
251  /* quadrilateral, polyhedrron, tet, hex, prism, pyramid, */
252  /* septahedron vectors */
253  for( i = 0; i < iMesh_ALL_TOPOLOGIES; i++ )
254  {
255  entities = NULL;
256  entities_alloc = 0;
257  iMesh_getEntities( mesh, root_set, iBase_ALL_TYPES, i, &entities, &entities_alloc, &entities_size, &result );
258  if( iBase_SUCCESS != result )
259  {
260  printf( "Failed to get entities in adjacencies_test.\n" );
261  return FALSE;
262  }
263 
264  if( entities_alloc > 0 )
265  {
266  topologies = NULL;
267  topologies_alloc = 0;
268  iMesh_getEntArrTopo( mesh, entities, entities_alloc, &topologies, &topologies_alloc, &topologies_size,
269  &result );
270  if( iBase_SUCCESS != result )
271  {
272  printf( "Failed to get topologies in adjacencies_test.\n" );
273  return FALSE;
274  }
275 
276  if( topologies_size != entities_size )
277  {
278  printf( "Didn't get the right number of topologies "
279  "in topology_adjacency_test.\n" );
280  free( topologies );
281  free( entities );
282  return FALSE;
283  }
284 
285  /* put entities into vectors of each topology */
286  entity_vectors[i] = (iBase_EntityHandle*)malloc( entities_size * sizeof( iBase_EntityHandle ) );
287 
288  for( j = 0; j < entities_size; j++ )
289  {
290  if( topologies[j] < iMesh_POINT || topologies[j] >= iMesh_ALL_TOPOLOGIES )
291  printf( "Didn't find entity type for this topology." );
292  else
293  {
294  entity_vectors[i][entity_vectors_sizes[i]] = entities[j];
295  entity_vectors_sizes[i]++;
296  }
297  }
298 
299  free( topologies );
300  }
301 
302  free( entities );
303  }
304 
305  /* check number of entities for each topology */
306  for( top_j = 0; top_j < iMesh_ALL_TOPOLOGIES; top_j++ )
307  {
308  num_tops = 0;
309  iMesh_getNumOfTopo( mesh, root_set, top_j, &num_tops, &result );
310  if( iBase_SUCCESS != result )
311  {
312  printf( "Failed to get number of topologies in adjacencies_test.\n" );
313  for( i = 0; i < iMesh_ALL_TOPOLOGIES; i++ )
314  free( entity_vectors[i] );
315  return FALSE;
316  }
317 
318  if( entity_vectors_sizes[top_j] != num_tops )
319  {
320  printf( "Topology count mismatch.\n" );
321  for( i = 0; i < iMesh_ALL_TOPOLOGIES; i++ )
322  free( entity_vectors[i] );
323  return FALSE;
324  }
325  }
326 
327  /* change if 3d topology entities are added or removed */
328  for( region_type = iMesh_TETRAHEDRON; region_type < iMesh_ALL_TOPOLOGIES; region_type++ )
329  {
330  /* get all adjacent faces of regions */
331  iBase_EntityHandle* region_vector = entity_vectors[region_type];
332 
333  num_region = entity_vectors_sizes[region_type];
334 
335  if( num_region > 0 )
336  {
337  adj_faces = NULL;
338  adj_faces_alloc = 0;
339  face_offsets = NULL;
340  face_offsets_alloc = 0;
341 
342  iMesh_getEntArrAdj( mesh, region_vector, num_region, iBase_FACE, &adj_faces, &adj_faces_alloc,
343  &adj_faces_size, &face_offsets, &face_offsets_alloc, &face_offsets_size, &result );
344  if( iBase_SUCCESS != result )
345  {
346  printf( "Failed to get adjacent faces of regions in adjacencies_test.\n" );
347  for( i = 0; i < iMesh_ALL_TOPOLOGIES; i++ )
348  free( entity_vectors[i] );
349  return FALSE;
350  }
351 
352  if( num_region + 1 != face_offsets_size )
353  {
354  printf( "Number of offsets didn't agree with number of "
355  "regions in topology_adjacency_test.\n" );
356  free( face_offsets );
357  free( adj_faces );
358  for( i = 0; i < iMesh_ALL_TOPOLOGIES; i++ )
359  free( entity_vectors[i] );
360  return FALSE;
361  }
362 
363  face_loaded = FALSE;
364 
365  /* check # of faces really loaded */
366  if( region_type == iMesh_TETRAHEDRON )
367  {
368  if( adj_faces_size == 4 * num_region ) face_loaded = TRUE;
369  }
370  else if( region_type == iMesh_HEXAHEDRON )
371  {
372  if( adj_faces_size == 6 * num_region ) face_loaded = TRUE;
373  }
374  else if( region_type == iMesh_PRISM )
375  {
376  if( adj_faces_size == 5 * num_region ) face_loaded = TRUE;
377  }
378  else if( region_type == iMesh_PYRAMID )
379  {
380  if( adj_faces_size == 5 * num_region ) face_loaded = TRUE;
381  }
382  else if( region_type == iMesh_SEPTAHEDRON )
383  {
384  if( adj_faces_size == 7 * num_region ) face_loaded = TRUE;
385  }
386  else
387  face_loaded = FALSE;
388 
389  /* get all adjacent regions of adjacent faces */
390  adj_regions = NULL;
391  adj_regions_alloc = 0;
392  region_offsets = NULL;
393  region_offsets_alloc = 0;
394  iMesh_getEntArrAdj( mesh, adj_faces, adj_faces_size, iBase_REGION, &adj_regions, &adj_regions_alloc,
395  &adj_regions_size, &region_offsets, &region_offsets_alloc, &region_offsets_size,
396  &result );
397  if( iBase_SUCCESS != result )
398  {
399  printf( "Failed to get regions from faces in adjacencies_test.\n" );
400  free( face_offsets );
401  free( adj_faces );
402  for( i = 0; i < iMesh_ALL_TOPOLOGIES; i++ )
403  free( entity_vectors[i] );
404  return FALSE;
405  }
406 
407  if( adj_faces_size + 1 != region_offsets_size )
408  {
409  printf( "Number of offsets didn't agree with number of faces in "
410  "topology_adjacency_test.\n" );
411  free( face_offsets );
412  free( region_offsets );
413  free( adj_faces );
414  free( adj_regions );
415  for( i = 0; i < iMesh_ALL_TOPOLOGIES; i++ )
416  free( entity_vectors[i] );
417  return FALSE;
418  }
419 
420  interior = (iBase_EntityHandle*)malloc( adj_faces_size * sizeof( iBase_EntityHandle ) ),
421  exterior = (iBase_EntityHandle*)malloc( adj_faces_size * sizeof( iBase_EntityHandle ) );
422  num_int = 0;
423  num_ext = 0;
424 
425  /* find the interior faces having two adjacent regions */
426  for( i = 0; i < adj_faces_size; i++ )
427  {
428  next_offset = 0;
429  if( i == adj_faces_size - 1 )
430  next_offset = adj_regions_size;
431  else
432  next_offset = region_offsets[i + 1];
433 
434  if( next_offset - region_offsets[i] == 2 )
435  {
436  found = FALSE;
437  for( iter = 0; iter < num_int; iter++ )
438  {
439  if( interior[iter] == adj_faces[i] )
440  {
441  found = TRUE;
442  break;
443  }
444  }
445  if( !found ) interior[num_int++] = adj_faces[i];
446  }
447  }
448 
449  /* now remove any interior faces from the previous adjacent faces list */
450  /* and we should be left with exterior faces */
451  for( i = 0; i < adj_faces_size; i++ )
452  {
453  found = FALSE;
454  for( iter = 0; iter < num_int; iter++ )
455  {
456  if( interior[iter] == adj_faces[i] )
457  {
458  found = TRUE;
459  break;
460  }
461  }
462  if( !found ) exterior[num_ext++] = adj_faces[i];
463  }
464 
465  num_faces_per_region = face_offsets[1] - face_offsets[0];
466 
467  /* check # of exterior and interior faces */
468  /* should be #exterior_faces + 2 * #interior_faces = #faces_per_region */
469  /* * #regions */
470  if( face_loaded )
471  {
472  if( num_ext + 2 * num_int != num_faces_per_region * num_region )
473  {
474  printf( "exterior/interior failure: %d ext, %d int, %d regions, %d faces per\n", num_ext, num_int,
475  num_region, num_faces_per_region );
476  free( face_offsets );
477  free( region_offsets );
478  free( adj_faces );
479  free( adj_regions );
480  free( interior );
481  free( exterior );
482  for( i = 0; i < iMesh_ALL_TOPOLOGIES; i++ )
483  free( entity_vectors[i] );
484  return FALSE;
485  }
486  }
487 
488  free( face_offsets );
489  free( region_offsets );
490  free( adj_faces );
491  free( adj_regions );
492  free( interior );
493  free( exterior );
494  }
495  }
496 
497  for( i = 0; i < iMesh_ALL_TOPOLOGIES; i++ )
498  free( entity_vectors[i] );
499 
500  return TRUE;
501 }

References entities, FALSE, iBase_ALL_TYPES, iBase_FACE, iBase_REGION, iBase_SUCCESS, iMesh_ALL_TOPOLOGIES, iMesh_getEntArrAdj, iMesh_getEntArrTopo, iMesh_getEntities, iMesh_getNumOfTopo, iMesh_HEXAHEDRON, iMesh_POINT, iMesh_PRISM, iMesh_PYRAMID, iMesh_SEPTAHEDRON, iMesh_TETRAHEDRON, mesh, root_set, and TRUE.

Referenced by main().

◆ topology_dimension_test()

int topology_dimension_test ( iMesh_Instance  mesh)
Test:
TSTT topology dimension Test
  • Check 2d topology dimensions

Definition at line 170 of file testc_cbind.cpp.

171 {
172  iBase_EntityHandle* faces = NULL;
173  int faces_alloc = 0, faces_size;
174  int result, i;
175  int* dimensions = NULL;
176  int dimensions_alloc = 0, dimensions_size;
177 
178  /* first get 2D entities */
179  iMesh_getEntities( mesh, root_set, iBase_FACE, iMesh_ALL_TOPOLOGIES, &faces, &faces_alloc, &faces_size, &result );
180  if( iBase_SUCCESS != result )
181  {
182  printf( "Failed to get faces in entity_sets_test.\n" );
183  return FALSE;
184  }
185 
186  /* get dimensions of faces */
187  iMesh_getEntArrType( mesh, faces, faces_size, &dimensions, &dimensions_alloc, &dimensions_size, &result );
188  if( iBase_SUCCESS != result )
189  {
190  printf( "Failed to get dimensions of faces in topology_test.\n" );
191  free( faces );
192  return FALSE;
193  }
194 
195  if( dimensions_size != faces_size )
196  {
197  printf( "Didn't get the right number of types in topology_test.\n" );
198  free( faces );
199  free( dimensions );
200  return FALSE;
201  }
202 
203  /* make sure all elements are 2D */
204  for( i = 0; i < faces_size; i++ )
205  {
206  if( dimensions[i] != iBase_FACE )
207  {
208  free( faces );
209  free( dimensions );
210  return FALSE;
211  }
212  }
213 
214  free( faces );
215  free( dimensions );
216 
217  return TRUE;
218 }

References FALSE, iBase_FACE, iBase_SUCCESS, iMesh_ALL_TOPOLOGIES, iMesh_getEntArrType, iMesh_getEntities, mesh, root_set, and TRUE.

Referenced by main().

◆ vertex_coordinates_test()

int vertex_coordinates_test ( iMesh_Instance  mesh)
Test:
Vertex Coordinates
  • Get coordinates of vertices by 2 different methods then compare them

Definition at line 1671 of file testc_cbind.cpp.

1672 {
1673  iBase_EntityHandle* verts = NULL;
1674  int verts_alloc = 0, verts_size;
1675  double* vert_coords = NULL;
1676  int vert_coords_alloc = 0, vert_coords_size;
1677 
1678  /* check storage order */
1679  int result;
1680  int this_order;
1681  iMesh_getDfltStorage( mesh, &this_order, &result );
1682  if( iBase_SUCCESS != result )
1683  {
1684  printf( "failed to get preferred storage order in vertex_coordinates_test.\n" );
1685  return FALSE;
1686  }
1687 
1688  /* now get the vertex coordinates from a vertex array */
1689  /* need to get the vertices in the model */
1690  verts = NULL;
1691  verts_alloc = 0;
1692  iMesh_getEntities( mesh, root_set, iBase_VERTEX, iMesh_POINT, &verts, &verts_alloc, &verts_size, &result );
1693  if( iBase_SUCCESS != result )
1694  {
1695  printf( "failed to get entities in vertex_coordinates_test.\n" );
1696  return FALSE;
1697  }
1698 
1699  /* get the coordinates in one array */
1700  vert_coords = NULL;
1701  vert_coords_alloc = 0;
1702 
1703  iMesh_getVtxArrCoords( mesh, verts, verts_size, iBase_INTERLEAVED, &vert_coords, &vert_coords_alloc,
1704  &vert_coords_size, &result );
1705  if( iBase_SUCCESS != result )
1706  {
1707  printf( "failed to get vertex cooridinate of entities in vertex_coordinates_test.\n" );
1708  free( verts );
1709  return FALSE;
1710  }
1711 
1712  free( verts );
1713  free( vert_coords );
1714 
1715  /* if we get here, this test was successful */
1716  return TRUE;
1717 }

References FALSE, iBase_INTERLEAVED, iBase_SUCCESS, iBase_VERTEX, iMesh_getDfltStorage, iMesh_getEntities, iMesh_getVtxArrCoords, iMesh_POINT, mesh, root_set, and TRUE.

Referenced by main().

◆ vertex_double_tag_test()

int vertex_double_tag_test ( iMesh_Instance  mesh,
iBase_EntityHandle verts,
int  ,
iBase_TagHandle double_tag 
)

Definition at line 1873 of file testc_cbind.cpp.

1877 {
1878  int result;
1879 
1880  iBase_EntityHandle dum_vert = verts[0];
1881  double dum_val = 1.0e6, dum_val2;
1882  void* dum_val2_ptr = &dum_val2;
1883  int dum_val2_alloc = sizeof( double ), dum_val2_size;
1884 
1885  /* create a tag */
1886  const char* tag_name = "double_tag";
1887  int tag_name_size = 11;
1888  iMesh_createTag( mesh, tag_name, 1, iBase_DOUBLE, double_tag, &result, tag_name_size );
1889  if( iBase_SUCCESS != result )
1890  {
1891  printf( "Failed to create tag double_tag in vertex_double_tag_test.\n" );
1892  return FALSE;
1893  }
1894 
1895  /* put a value in the first vertex and retrieve */
1896  iMesh_setArrData( mesh, &dum_vert, 1, *double_tag, (char*)( &dum_val ), sizeof( double ), &result );
1897  if( iBase_SUCCESS != result )
1898  {
1899  printf( "Failed to set double tag (val=1.0e6) in vertex_double_tag_test.\n" );
1900  return FALSE;
1901  }
1902 
1903  iMesh_getArrData( mesh, &dum_vert, 1, *double_tag, &dum_val2_ptr, &dum_val2_alloc, &dum_val2_size, &result );
1904  if( iBase_SUCCESS != result )
1905  {
1906  printf( "Failed to get double tag (val=1.0e6) in vertex_double_tag_test.\n" );
1907  return FALSE;
1908  }
1909 
1910  if( dum_val2 != 1.0e6 )
1911  {
1912  printf( "Value of vertex tag (val=1.0e6) wrong.\n" );
1913  return FALSE;
1914  }
1915 
1916  /* put a value in the last vertex and retrieve */
1917  dum_val = 2.0e9;
1918 
1919  iMesh_setArrData( mesh, &dum_vert, 1, *double_tag, (char*)( &dum_val ), sizeof( double ), &result );
1920  if( iBase_SUCCESS != result )
1921  {
1922  printf( "Failed to set double tag (val=2.0e9) in vertex_double_tag_test.\n" );
1923  return FALSE;
1924  }
1925 
1926  iMesh_getArrData( mesh, &dum_vert, 1, *double_tag, &dum_val2_ptr, &dum_val2_alloc, &dum_val2_size, &result );
1927  if( iBase_SUCCESS != result )
1928  {
1929  printf( "Failed to get double tag (val=2.0e9) in vertex_double_tag_test.\n" );
1930  return FALSE;
1931  }
1932 
1933  if( dum_val2 != 2.0e9 )
1934  {
1935  printf( "Value of vertex tag (val=2.0e9) wrong.\n" );
1936  return FALSE;
1937  }
1938 
1939  /* ok, the double tag test worked */
1940  return TRUE;
1941 }

References FALSE, iBase_DOUBLE, iBase_SUCCESS, iMesh_createTag, iMesh_getArrData, iMesh_setArrData, mesh, and TRUE.

Referenced by vertex_tag_test().

◆ vertex_int_tag_test()

int vertex_int_tag_test ( iMesh_Instance  mesh,
iBase_EntityHandle verts,
int  ,
iBase_TagHandle int_tag 
)

Definition at line 1804 of file testc_cbind.cpp.

1805 {
1806  int result;
1807  iBase_EntityHandle dum_vert = verts[0];
1808 
1809  int dum_val = 11, dum_val2;
1810  void* dum_val2_ptr = &dum_val2;
1811  int dum_val2_alloc = sizeof( int ), dum_val2_size;
1812 
1813  /* create a tag */
1814  const char* tag_name = "int_tag";
1815  int tag_name_size = 8;
1816  iMesh_createTag( mesh, tag_name, 1, iBase_INTEGER, int_tag, &result, tag_name_size );
1817  if( iBase_SUCCESS != result )
1818  {
1819  printf( "Failed to create tag int_tag in vertex_int_tag_test.\n" );
1820  return FALSE;
1821  }
1822 
1823  /* put a value in the first vertex and retrieve */
1824  iMesh_setArrData( mesh, &dum_vert, 1, *int_tag, (const char*)( &dum_val ), sizeof( int ), &result );
1825  if( iBase_SUCCESS != result )
1826  {
1827  printf( "Failed to set int tag (val=11) in vertex_int_tag_test.\n" );
1828  return FALSE;
1829  }
1830 
1831  iMesh_getArrData( mesh, &dum_vert, 1, *int_tag, &dum_val2_ptr, &dum_val2_alloc, &dum_val2_size, &result );
1832  if( iBase_SUCCESS != result || dum_val2 != 11 )
1833  {
1834  printf( "Failed to get int tag (val=11) in vertex_int_tag_test.\n" );
1835  return FALSE;
1836  }
1837 
1838  if( dum_val2 != 11 )
1839  {
1840 
1841  printf( "Value of vertex tag (val=11) wrong.\n" );
1842  return FALSE;
1843  }
1844 
1845  /* put a value in the last vertex and retrieve */
1846  dum_val = 12;
1847 
1848  iMesh_setArrData( mesh, &dum_vert, 1, *int_tag, (char*)( &dum_val ), sizeof( int ), &result );
1849  if( iBase_SUCCESS != result )
1850  {
1851  printf( "Failed to set int tag (val=12) in vertex_int_tag_test.\n" );
1852  return FALSE;
1853  }
1854 
1855  iMesh_getArrData( mesh, &dum_vert, 1, *int_tag, &dum_val2_ptr, &dum_val2_alloc, &dum_val2_size, &result );
1856  if( iBase_SUCCESS != result )
1857  {
1858  printf( "Failed to get int tag (val=12) in vertex_int_tag_test.\n" );
1859  return FALSE;
1860  }
1861 
1862  if( dum_val2 != 12 )
1863  {
1864 
1865  printf( "Value of vertex tag (val=12) wrong.\n" );
1866  return FALSE;
1867  }
1868 
1869  /* ok, the int tag test worked */
1870  return TRUE;
1871 }

References FALSE, iBase_INTEGER, iBase_SUCCESS, iMesh_createTag, iMesh_getArrData, iMesh_setArrData, mesh, and TRUE.

Referenced by vertex_tag_test().

◆ vertex_struct_tag_test()

int vertex_struct_tag_test ( iMesh_Instance  mesh,
iBase_EntityHandle verts,
int  ,
iBase_TagHandle struct_tag 
)

Definition at line 1950 of file testc_cbind.cpp.

1954 {
1955  int result;
1956  iBase_EntityHandle dum_vert = verts[0];
1957  struct TagStruct dum_struct = { 3.0e12, 2, 3 }, dum_struct2;
1958  void* dum_struct2_ptr = &dum_struct2;
1959  int dum_struct_alloc = sizeof( struct TagStruct ), dum_struct_size;
1960 
1961  /* create a tag */
1962  const char* tag_name = "struct_tag";
1963  int tag_name_size = 11;
1964  iMesh_createTag( mesh, tag_name, sizeof( struct TagStruct ), iBase_BYTES, struct_tag, &result, tag_name_size );
1965  if( iBase_SUCCESS != result )
1966  {
1967  printf( "Failed to create tag struct_tag in vertex_struct_tag_test.\n" );
1968  return FALSE;
1969  }
1970 
1971  /* put a value in the first vertex and retrieve */
1972 
1973  /* careful setting the value, since tags are opaque */
1974  iMesh_setArrData( mesh, &dum_vert, 1, *struct_tag, (const char*)&dum_struct, sizeof( struct TagStruct ), &result );
1975  if( iBase_SUCCESS != result )
1976  {
1977  printf( "Failed to set struct tag in vertex_struct_tag_test.\n" );
1978  return FALSE;
1979  }
1980 
1981  iMesh_getArrData( mesh, &dum_vert, 1, *struct_tag, &dum_struct2_ptr, &dum_struct_alloc, &dum_struct_size, &result );
1982  if( iBase_SUCCESS != result )
1983  {
1984  printf( "Failed to get struct tag in vertex_struct_tag_test.\n" );
1985  return FALSE;
1986  }
1987 
1988  if( dum_struct_size != sizeof( struct TagStruct ) )
1989  {
1990  printf( "Size of vertex struct tag wrong.\n" );
1991  return FALSE;
1992  }
1993  if( dum_struct2.test_int1 != dum_struct.test_int1 || dum_struct2.test_int2 != dum_struct.test_int2 ||
1994  dum_struct2.test_double != dum_struct.test_double )
1995  {
1996  printf( "Value of vertex struct tag wrong.\n" );
1997  return FALSE;
1998  }
1999 
2000  /* ok, the int tag test worked */
2001  return TRUE;
2002 }

References FALSE, iBase_BYTES, iBase_SUCCESS, iMesh_createTag, iMesh_getArrData, iMesh_setArrData, mesh, TagStruct::test_double, TagStruct::test_int1, TagStruct::test_int2, and TRUE.

Referenced by vertex_tag_test().

◆ vertex_tag_delete_test()

int vertex_tag_delete_test ( iMesh_Instance  mesh,
iBase_EntityHandle verts,
int   
)

Definition at line 2004 of file testc_cbind.cpp.

2005 {
2006  int result;
2007  int delete_err = FALSE;
2008 
2009  /* test forced, unforced deletion of tags from entities */
2010 
2011  /* test getAlliBase_TagHandles for first entity */
2012  iBase_TagHandle* all_tags = NULL;
2013  iBase_EntityHandle dum_entity = verts[0];
2014  int all_tags_alloc = 0, all_tags_size;
2015  iMesh_getAllTags( mesh, verts[0], &all_tags, &all_tags_alloc, &all_tags_size, &result );
2016  if( iBase_SUCCESS != result )
2017  {
2018  printf( "Couldn't get all tag handles from vertex.\n" );
2019  return FALSE;
2020  }
2021 
2022  iMesh_rmvArrTag( mesh, &dum_entity, 1, all_tags[0], &result );
2023  if( iBase_SUCCESS != result )
2024  {
2025  printf( "Couldn't remove tag from vertex.\n" );
2026  free( all_tags );
2027  return FALSE;
2028  }
2029 
2030  iMesh_destroyTag( mesh, all_tags[1], FALSE, &result );
2031  if( iBase_SUCCESS != result )
2032  {
2033  delete_err = TRUE;
2034  }
2035  if( !delete_err )
2036  {
2037  printf( "Error when unforced-deleting tag in use on a vertex.\n" );
2038  free( all_tags );
2039  return FALSE;
2040  }
2041 
2042  iMesh_destroyTag( mesh, all_tags[1], TRUE, &result );
2043  if( iBase_SUCCESS != result )
2044  {
2045  printf( "Couldn't force-delete a tag in use on a vertex.\n" );
2046  free( all_tags );
2047  return FALSE;
2048  }
2049 
2050  free( all_tags );
2051 
2052  /* ok, we're done */
2053  return TRUE;
2054 }

References FALSE, iBase_SUCCESS, iMesh_destroyTag, iMesh_getAllTags, iMesh_rmvArrTag, mesh, and TRUE.

Referenced by vertex_tag_test().

◆ vertex_tag_test()

int vertex_tag_test ( iMesh_Instance  mesh)

Definition at line 2056 of file testc_cbind.cpp.

2057 {
2058  int result;
2059 
2060  iBase_TagHandle int_tag, double_tag, struct_tag;
2061  int int_err, double_err, struct_err, tag_delete_err;
2062 
2063  int info_err = tag_info_test( mesh );
2064 
2065  /* get all the vertices */
2066  iBase_EntityHandle* verts = NULL;
2067  int verts_alloc = 0, verts_size;
2068  iMesh_getEntities( mesh, root_set, iBase_ALL_TYPES, iMesh_POINT, &verts, &verts_alloc, &verts_size, &result );
2069  if( iBase_SUCCESS != result )
2070  {
2071  printf( "entitysetGetEntities failed in vertex_tag_test.\n" );
2072  return FALSE;
2073  }
2074 
2075  /* vertex int tag */
2076  int_err = vertex_int_tag_test( mesh, verts, verts_size, &int_tag );
2077 
2078  /* vertex double tag */
2079  double_err = vertex_double_tag_test( mesh, verts, verts_size, &double_tag );
2080 
2081  /* vertex struct tag */
2082  struct_err = vertex_struct_tag_test( mesh, verts, verts_size, &struct_tag );
2083 
2084  tag_delete_err = vertex_tag_delete_test( mesh, verts, verts_size );
2085 
2086  free( verts );
2087 
2088  return ( info_err && int_err && double_err && struct_err && tag_delete_err );
2089 }

References FALSE, iBase_ALL_TYPES, iBase_SUCCESS, iMesh_getEntities, iMesh_POINT, mesh, root_set, tag_info_test(), vertex_double_tag_test(), vertex_int_tag_test(), vertex_struct_tag_test(), and vertex_tag_delete_test().

Referenced by main().

Variable Documentation

◆ assert_pass

bool assert_pass
static

Definition at line 81 of file testc_cbind.cpp.

Referenced by entity_connectivity_test().

◆ iBase_ERROR_MAP

◆ root_set