static int test_oriented_brick() { CubitVector center(1, 2, 4); CubitVector axes[3] = { CubitVector(0.707, 0.707, 0), CubitVector(-0.707, 0.707, 0), CubitVector(0, 0, 1) }; CubitVector extension(3, 5, 7); Body* brick = GeometryModifyTool::instance()->brick(center, axes, extension); if(!brick) { printf("failed to make brick\n"); return 1; } CubitBox comp_box(CubitVector(-4.656854, -3.656854, -3.), CubitVector(6.656854, 7.656854, 11.)); CubitBox bnd_box = brick->bounding_box(); bool identical = cubit_box_identical(bnd_box, comp_box, GEOMETRY_RESABS*2.0, true); if (identical) return 0; if( bnd_box < comp_box || bnd_box > comp_box*1.09) { printf("boxes not identical\n"); return 1; } return 0; }
static int test_planar_sheet() { CubitVector axes[2] = { CubitVector(1,0,0), CubitVector(.1,.9,0) }; Body* body = GeometryModifyTool::instance()->planar_sheet(CubitVector(1,1,1), axes, 2, 3); if(!body) { printf("failed to make planar sheet\n"); return 1; } CubitBox comp_box(CubitVector(-0.165647,-0.490826,1.0), CubitVector(2.165647,2.490826,1.0)); CubitBox bnd_box = body->bounding_box(); bool identical = cubit_box_identical(bnd_box, comp_box, GEOMETRY_RESABS*2.0, true); if (identical) return 0; if( bnd_box < comp_box || bnd_box > comp_box*1.09) { printf("boxes not identical\n"); return 1; } body = GeometryModifyTool::instance()->planar_sheet( CubitVector(0,0,0), CubitVector(1,0,0), CubitVector(1,1,0), CubitVector(0,1,.2) ); if(body) { printf("should have failed to make planar sheet out of non-planar points\n"); return 1; } body = GeometryModifyTool::instance()->planar_sheet( CubitVector(0,0,0), CubitVector(0,0,0), CubitVector(1,1,0), CubitVector(0,1,0) ); if(body) { printf("should have failed to make planar sheet with coincident input points\n"); return 1; } return 0; }
static int test_brick() { Body* brick = GeometryModifyTool::instance()->brick(1,2,4); if(!brick) { printf("failed to make brick\n"); return 1; } if(!cubit_box_identical(brick->bounding_box(), CubitBox(CubitVector(-0.5,-1,-2), CubitVector(0.5,1,2)), GEOMETRY_RESABS*2.0, true)) { printf("boxes not identical\n"); return 1; } return 0; }
static int test_sphere() { Body* sphere = GeometryModifyTool::instance()->sphere(1); if(!sphere) { printf("failed to make sphere\n"); return 1; } CubitBox comp_box( CubitVector(-1,-1,-1), CubitVector(1,1,1)); CubitBox bnd_box = sphere->bounding_box(); bool identical = cubit_box_identical(bnd_box, comp_box, GEOMETRY_RESABS*2.0, true); if (identical) return 0; if( bnd_box < comp_box || bnd_box > comp_box*1.09) { printf("boxes not identical\n"); return 1; } return 0; }
static int test_torus() { printf("making torus\n"); Body* torus = GeometryModifyTool::instance()->torus(1, .2); if(!torus) { printf("failed to make torus\n"); return 1; } CubitBox comp_box(CubitVector(-1.2,-1.2,-0.2), CubitVector(1.2,1.2,0.2)); CubitBox bnd_box = torus->bounding_box(); bool identical = cubit_box_identical(bnd_box, comp_box, GEOMETRY_RESABS*2.0, true); if (identical) return 0; if( bnd_box < comp_box || bnd_box > comp_box*1.09) { printf("boxes not identical\n"); return 1; } return 0; }