cgma
|
00001 00010 #undef NDEBUG 00011 #include <cassert> 00012 00013 #include "stdio.h" 00014 00015 #include "GMem.hpp" 00016 #include "GeometryQueryTool.hpp" 00017 #include "GeometryModifyTool.hpp" 00018 #include "RefEdge.hpp" 00019 #include "RefFace.hpp" 00020 #include "CubitDefines.h" 00021 #include "CubitBox.hpp" 00022 #include "InitCGMA.hpp" 00023 #include "TestUtilities.hpp" 00024 00025 #ifndef SRCDIR 00026 # define SRCDIR . 00027 #endif 00028 00029 #if defined (TEST_OCC) 00030 # define ENGINE "OCC" 00031 #else 00032 # error "Which engine to test?" 00033 #endif 00034 00035 #define STRINGIFY_(X) #X 00036 #define STRINGIFY(X) STRINGIFY_(X) 00037 #define SRCPATH STRINGIFY(SRCDIR) "/" 00038 00039 // forward declare some functions used and defined later 00040 int GraphicsData(); 00041 00042 // macro for printing a separator line 00043 #define PRINT_SEPARATOR PRINT_INFO("=======================================\n"); 00044 00045 00046 // main program - initialize, then send to proper function 00047 int main (int argc, char **argv) 00048 { 00049 CubitStatus s = InitCGMA::initialize_cgma( ENGINE ); 00050 if (CUBIT_SUCCESS != s) return 1; 00051 00052 //Do tests. 00053 int rsl = GraphicsData(); 00054 if (rsl == 1) 00055 PRINT_INFO("Operation Failed"); 00056 00057 int ret_val = ( CubitMessage::instance()->error_count() ); 00058 if ( ret_val != 0 ) 00059 { 00060 PRINT_ERROR("Errors found during Mergechk session.\n"); 00061 } 00062 else 00063 ret_val = 0; 00064 00065 return ret_val; 00066 00067 } 00068 00069 int GraphicsData() 00070 { 00071 GeometryModifyTool::instance()->brick(10,10,10); 00072 00073 GeometryQueryEngine* engine = GeometryQueryTool::instance()->get_gqe(); 00074 00075 if(!engine) 00076 { 00077 printf("no engine\n"); 00078 return 1; 00079 } 00080 00081 CubitBox uninit_box; 00082 00083 CubitBox model_bbox( 00084 CubitVector(-5, -5, -5), 00085 CubitVector(5, 5, 5) 00086 ); 00087 00088 00089 DLIList<RefEdge*> edges; 00090 GeometryQueryTool::instance()->ref_edges(edges); 00091 00092 // expect 24 edges 00093 if(edges.size() != 12) 00094 { 00095 printf("wrong edge count\n"); 00096 return 1; 00097 } 00098 00099 // get graphics data for the curves 00100 00101 CubitBox g_curves = uninit_box; 00102 GMem gmem; 00103 for(int i=0; i<edges.size(); i++) 00104 { 00105 RefEdge* edge = edges.get_and_step(); 00106 if(engine->get_graphics(edge->get_curve_ptr(), &gmem) != CUBIT_SUCCESS || 00107 gmem.pointListCount == 0) 00108 { 00109 printf("got no edge facet data for edge %i\n", edge->id()); 00110 } 00111 else 00112 { 00113 for(int j=0; j<gmem.pointListCount; j++) 00114 { 00115 const GPoint& pt = gmem.point_list()[j]; 00116 g_curves |= CubitVector(pt.x, pt.y, pt.z); 00117 } 00118 } 00119 } 00120 00121 printf("curve bbox range = %f %f %f\n", 00122 g_curves.x_range(), g_curves.y_range(), g_curves.z_range()); 00123 00124 if(!cubit_box_identical(g_curves, model_bbox, GEOMETRY_RESABS)) 00125 { 00126 printf("didn't get accurate facet data for curves\n"); 00127 return 1; 00128 } 00129 00130 00131 CubitBox g_surfaces = uninit_box; 00132 DLIList<RefFace*> faces; 00133 GeometryQueryTool::instance()->ref_faces(faces); 00134 00135 // expect 6 edges 00136 if(faces.size() != 6) 00137 { 00138 printf("wrong face count\n"); 00139 return 1; 00140 } 00141 00142 // get graphics data for the surfaces 00143 for(int i=0; i<faces.size(); i++) 00144 { 00145 RefFace* face = faces.get_and_step(); 00146 if(engine->get_graphics(face->get_surface_ptr(), &gmem) != CUBIT_SUCCESS || 00147 gmem.pointListCount == 0 || gmem.fListCount == 0) 00148 { 00149 printf("got no face facet data for face %i\n", face->id()); 00150 } 00151 else 00152 { 00153 const GPoint* pts = gmem.point_list(); 00154 const int* facets = gmem.facet_list(); 00155 int facet_size = gmem.fListCount; 00156 for(int j=0; j<facet_size;) 00157 { 00158 int num = facets[j++]; 00159 for(int k=0; k<num; k++) 00160 { 00161 const GPoint& pt = pts[facets[j++]]; 00162 g_surfaces |= CubitVector(pt.x, pt.y, pt.z); 00163 } 00164 } 00165 } 00166 } 00167 00168 printf("surface bbox range = %f %f %f\n", 00169 g_surfaces.x_range(), g_surfaces.y_range(), g_surfaces.z_range()); 00170 00171 if(!cubit_box_identical(g_surfaces, model_bbox, GEOMETRY_RESABS)) 00172 { 00173 printf("didn't get accurate facet data for surfaces\n"); 00174 return 1; 00175 } 00176 00177 00178 return 0; 00179 } 00180