cgma
GfxDebug.cpp
Go to the documentation of this file.
00001 
00002 
00003 #include "GfxDebug.hpp"
00004 #include "GMem.hpp"
00005 #include "CubitVector.hpp"
00006 #include "DLIList.hpp"
00007 #include <cassert>
00008 
00009 GfxDebug* GfxDebug::mInstance = 0;
00010 
00011 GfxDebug::GfxDebug()
00012 {
00013   if(mInstance)
00014   {
00015     assert(0);
00016     // if you want a new instance in place of a previous one,
00017     // delete the previous one first
00018   }
00019   mInstance = this;
00020 }
00021 
00022 GfxDebug::~GfxDebug()
00023 {
00024   mInstance = 0;
00025 }
00026 
00027 bool GfxDebug::is_initialized()
00028 {
00029   if (mInstance == 0)
00030     return false;
00031   return true;
00032 }
00033 
00034 // this will clear out all temporary data and any graphics windows created
00035 // with this interface.
00036 /*
00037 void GfxDebug::reset()
00038 {
00039   if(!mInstance) return;
00040   mInstance->p_reset();
00041 }
00042 */
00043 
00044 void GfxDebug::clear()
00045 {
00046   if(!mInstance) return;
00047   mInstance->p_clear();
00048 }
00049 
00050 void GfxDebug::display_all(bool flush_highlight, bool import_mesh_display)
00051 {
00052   if(!mInstance) return;
00053   mInstance->p_display_all(flush_highlight, import_mesh_display);
00054 }
00055 
00056 void GfxDebug::clear_highlight()
00057 {
00058   if(!mInstance) return;
00059   mInstance->p_clear_highlight();
00060 }
00061 
00062 void GfxDebug::drawing_mode(int mode)
00063 {
00064   if(!mInstance) return;
00065   mInstance->p_drawing_mode(mode);
00066 }
00067 /*
00068 void GfxDebug::rebuild_all()
00069 {
00070   if(!mInstance) return;
00071   mInstance->p_rebuild_all();
00072 }
00073 */
00074 
00075 // Window Related Functions
00076 
00077 // creates a graphics window and makes it the current one
00078 // not creating a window will use an existing current window
00079 // all drawing goes only into the current window
00080 int GfxDebug::create_window()
00081 {
00082   if(!mInstance) return -1;
00083   return mInstance->p_create_window();
00084 }
00085 
00086 // deletes a window created by this interface
00087 void GfxDebug::delete_window(int window_id)
00088 {
00089   if(!mInstance) return;
00090   mInstance->p_delete_window(window_id);
00091 }
00092 
00093 // switches a window created by this interface into a 2D drawing mode.
00094 void GfxDebug::set_2D_mode(int window_id)
00095 {
00096   if(!mInstance) return;
00097   mInstance->p_set_2D_mode(window_id);
00098 }
00099 
00100 // causes the current window to be redrawn
00101 void GfxDebug::flush()
00102 {
00103   if(!mInstance) return;
00104   mInstance->p_flush();
00105 }
00106 
00107 // give control to the current window to handle mouse events
00108 void GfxDebug::mouse_xforms()
00109 {
00110   if(!mInstance) return;
00111   mInstance->p_mouse_xforms();
00112 }
00113 
00114 // compute display to world transformation of a length
00115 void GfxDebug::display_to_world_length(double pixels, double& length)
00116 {
00117   if(!mInstance) return;
00118   mInstance->p_display_to_world_length(pixels, length);
00119 }
00120 
00121 // Geometry Drawing Functions
00122     
00123 void GfxDebug::draw_ref_entity(RefEntity* entity, int color, CubitTransformMatrix* mat)
00124 {
00125   if(!mInstance) return;
00126   mInstance->p_draw_ref_entity(entity, color, mat);
00127 }
00128 
00129 void GfxDebug::draw_ref_vertex(RefVertex* entity, int color)
00130 {
00131   if(!mInstance) return;
00132   mInstance->p_draw_ref_vertex(entity, color);
00133 }
00134 
00135 void GfxDebug::draw_ref_edge(RefEdge* entity, int color)
00136 {
00137   if(!mInstance) return;
00138   mInstance->p_draw_ref_edge(entity, color);
00139 }
00140 
00141 void GfxDebug::draw_ref_face(RefFace* entity, int color)
00142 {
00143   if(!mInstance) return;
00144   mInstance->p_draw_ref_face(entity, color);
00145 }
00146 
00147 void GfxDebug::draw_ref_face_edges(RefFace* entity, int color)
00148 {
00149   if(!mInstance) return;
00150   mInstance->p_draw_ref_face_edges(entity, color);
00151 }
00152 
00153 void GfxDebug::draw_ref_volume(RefVolume* entity, int color)
00154 {
00155   if(!mInstance) return;
00156   mInstance->p_draw_ref_volume(entity, color);
00157 }
00158 
00159 void GfxDebug::draw_ref_body(Body* entity, int color)
00160 {
00161   if(!mInstance) return;
00162   mInstance->p_draw_ref_body(entity, color);
00163 }
00164 
00165 
00166 void GfxDebug::draw_mref_entity(MRefEntity* entity, int color, bool draw_geom, bool draw_mesh, CubitTransformMatrix* mat)
00167 {
00168   if(!mInstance) return;
00169   mInstance->p_draw_mref_entity(entity, color, draw_geom, draw_mesh, mat);
00170 }
00171 
00172 void GfxDebug::draw_mref_vertex(MRefVertex* entity, int color)
00173 {
00174   if(!mInstance) return;
00175   mInstance->p_draw_mref_vertex(entity, color);
00176 }
00177 
00178 void GfxDebug::draw_mref_edge(MRefEdge* entity, int color)
00179 {
00180   if(!mInstance) return;
00181   mInstance->p_draw_mref_edge(entity, color);
00182 }
00183 
00184 void GfxDebug::draw_mref_face(MRefFace* entity, int color)
00185 {
00186   if(!mInstance) return;
00187   mInstance->p_draw_mref_face(entity, color);
00188 }
00189 
00190 void GfxDebug::draw_mref_volume(MRefVolume* entity, int color)
00191 {
00192   if(!mInstance) return;
00193   mInstance->p_draw_mref_volume(entity, color);
00194 }
00195 
00196 void GfxDebug::draw_mref_body(MBody* entity, int color)
00197 {
00198   if(!mInstance) return;
00199   mInstance->p_draw_mref_body(entity, color);
00200 }
00201 
00202 void GfxDebug::draw_mref_entity_mesh(MRefEntity* entity, int color)
00203 {
00204   if(!mInstance) return;
00205   mInstance->p_draw_mref_entity_mesh(entity, color);
00206 }
00207 
00208 void GfxDebug::draw_mref_volume_faces(MRefVolume* entity, int color)
00209 {
00210   if(!mInstance) return;
00211   mInstance->p_draw_mref_volume_faces(entity, color);
00212 }
00213 
00214 /*
00215 void GfxDebug::highlight_ref_entity(RefEntity* entity)
00216 {
00217   if(!mInstance) return;
00218   mInstance->p_highlight_ref_entity(entity);
00219 }
00220 */
00221 
00222 void GfxDebug::highlight_ref_vertex(RefVertex* entity)
00223 {
00224   if(!mInstance) return;
00225   mInstance->p_highlight_ref_vertex(entity);
00226 }
00227 
00228 void GfxDebug::highlight_ref_edge(RefEdge* entity)
00229 {
00230   if(!mInstance) return;
00231   mInstance->p_highlight_ref_edge(entity);
00232 }
00233 
00234 void GfxDebug::highlight_ref_face(RefFace* entity)
00235 {
00236   if(!mInstance) return;
00237   mInstance->p_highlight_ref_face(entity);
00238 }
00239 
00240 void GfxDebug::highlight_ref_volume(RefVolume* entity)
00241 {
00242   if(!mInstance) return;
00243   mInstance->p_highlight_ref_volume(entity);
00244 }
00245 
00246 void GfxDebug::highlight_ref_body(Body* entity)
00247 {
00248   if(!mInstance) return;
00249   mInstance->p_highlight_ref_body(entity);
00250 }
00251 
00252 /*
00253 void GfxDebug::highlight_mref_entity(MRefEntity* entity)
00254 {
00255   if(!mInstance) return;
00256   mInstance->p_highlight_mref_entity(entity);
00257 }
00258 */
00259 
00260 void GfxDebug::highlight_mref_vertex(MRefVertex* entity)
00261 {
00262   if(!mInstance) return;
00263   mInstance->p_highlight_mref_vertex(entity);
00264 }
00265 
00266 void GfxDebug::highlight_mref_edge(MRefEdge* entity)
00267 {
00268   if(!mInstance) return;
00269   mInstance->p_highlight_mref_edge(entity);
00270 }
00271 
00272 void GfxDebug::highlight_mref_face(MRefFace* entity)
00273 {
00274   if(!mInstance) return;
00275   mInstance->p_highlight_mref_face(entity);
00276 }
00277 
00278 void GfxDebug::highlight_mref_volume(MRefVolume* entity)
00279 {
00280   if(!mInstance) return;
00281   mInstance->p_highlight_mref_volume(entity);
00282 }
00283 
00284 void GfxDebug::highlight_mref_body(MBody* entity)
00285 {
00286   if(!mInstance) return;
00287   mInstance->p_highlight_mref_body(entity);
00288 }
00289 
00290 
00291 
00292 
00293 // Mesh Drawing Functions
00294 
00295 // draws mesh entities with a color from the cubit color table
00296 // prefer these functions to a loop drawing each entity separately
00297 /*
00298 void GfxDebug::draw_mesh_entities(DLIList<MeshEntity*>* entities, int color)
00299 {
00300   if(!mInstance) return;
00301   mInstance->p_draw_mesh_entities(entities, color);
00302 }
00303 */
00304 
00305 void GfxDebug::draw_nodes(DLIList<CubitNode*>* entities, int color)
00306 {
00307   if(!mInstance) return;
00308   mInstance->p_draw_nodes(entities, color);
00309 }
00310 void GfxDebug::draw_edges(DLIList<CubitEdge*>* entities, int color)
00311 {
00312   if(!mInstance) return;
00313   mInstance->p_draw_edges(entities, color);
00314 }
00315 void GfxDebug::draw_quads(DLIList<CubitFace*>* entities, int color)
00316 {
00317   if(!mInstance) return;
00318   mInstance->p_draw_quads(entities, color);
00319 }
00320 void GfxDebug::draw_tris(DLIList<CubitTri*>* entities, int color)
00321 {
00322   if(!mInstance) return;
00323   mInstance->p_draw_tris(entities, color);
00324 }
00325 void GfxDebug::draw_tets(DLIList<CubitTet*>* entities, int color)
00326 {
00327   if(!mInstance) return;
00328   mInstance->p_draw_tets(entities, color);
00329 }
00330 void GfxDebug::draw_hexes(DLIList<CubitHex*>* entities, int color)
00331 {
00332   if(!mInstance) return;
00333   mInstance->p_draw_hexes(entities, color);
00334 }
00335 /*
00336 void GfxDebug::draw_pyramids(DLIList<CubitPyramid*>* entities, int color)
00337 {
00338   if(!mInstance) return;
00339   mInstance->p_draw_pyramids(entities, color);
00340 }
00341 */
00342 void GfxDebug::draw_wedges(DLIList<CubitWedge*>* entities, int color)
00343 {
00344   if(!mInstance) return;
00345   mInstance->p_draw_wedges(entities, color);
00346 }
00347 
00348 void GfxDebug::draw_mesh_entity(MeshEntity* entity, int color)
00349 {
00350   if(!mInstance) return;
00351   mInstance->p_draw_mesh_entity(entity, color);
00352 }
00353 
00354 void GfxDebug::draw_node(CubitNode* entity, int color)
00355 {
00356   if(!mInstance) return;
00357   mInstance->p_draw_node(entity, color);
00358 }
00359 void GfxDebug::draw_edge(CubitEdge* entity, int color)
00360 {
00361   if(!mInstance) return;
00362   mInstance->p_draw_edge(entity, color);
00363 }
00364 void GfxDebug::draw_quad(CubitFace* entity, int color)
00365 {
00366   if(!mInstance) return;
00367   mInstance->p_draw_quad(entity, color);
00368 }
00369 void GfxDebug::draw_tri(CubitTri* entity, int color)
00370 {
00371   if(!mInstance) return;
00372   mInstance->p_draw_tri(entity, color);
00373 }
00374 void GfxDebug::draw_tet(CubitTet* entity, int color)
00375 {
00376   if(!mInstance) return;
00377   mInstance->p_draw_tet(entity, color);
00378 }
00379 void GfxDebug::draw_hex(CubitHex* entity, int color)
00380 {
00381   if(!mInstance) return;
00382   mInstance->p_draw_hex(entity, color);
00383 }
00384 void GfxDebug::draw_pyramid(CubitPyramid* entity, int color)
00385 {
00386   if(!mInstance) return;
00387   mInstance->p_draw_pyramid(entity, color);
00388 }
00389 
00390 void GfxDebug::draw_wedge(CubitWedge* entity, int color)
00391 {
00392   if(!mInstance) return;
00393   mInstance->p_draw_wedge(entity, color);
00394 }
00395 
00396 void GfxDebug::highlight_node(CubitNode* entity)
00397 {
00398   if(!mInstance) return;
00399   mInstance->p_highlight_node(entity);
00400 }
00401 
00402 void GfxDebug::highlight_edge(CubitEdge* entity)
00403 {
00404   if(!mInstance) return;
00405   mInstance->p_highlight_edge(entity);
00406 }
00407 
00408 void GfxDebug::highlight_quad(CubitFace* entity)
00409 {
00410   if(!mInstance) return;
00411   mInstance->p_highlight_quad(entity);
00412 }
00413 
00414 void GfxDebug::highlight_tri(CubitTri* entity)
00415 {
00416   if(!mInstance) return;
00417   mInstance->p_highlight_tri(entity);
00418 }
00419 
00420 void GfxDebug::highlight_tet(CubitTet* entity)
00421 {
00422   if(!mInstance) return;
00423   mInstance->p_highlight_tet(entity);
00424 }
00425 
00426 void GfxDebug::highlight_hex(CubitHex* entity)
00427 {
00428   if(!mInstance) return;
00429   mInstance->p_highlight_hex(entity);
00430 }
00431 
00432 void GfxDebug::highlight_pyramid(CubitPyramid* entity)
00433 {
00434   if(!mInstance) return;
00435   mInstance->p_highlight_pyramid(entity);
00436 }
00437 
00438 void GfxDebug::highlight_wedge(CubitWedge* entity)
00439 {
00440   if(!mInstance) return;
00441   mInstance->p_highlight_wedge(entity);
00442 }
00443 
00444 
00445 // Facet Drawing Functions
00446 
00447 void GfxDebug::draw_facet(CubitFacet* facet, int color, int draw_uv )
00448 {
00449   if(!mInstance) return;
00450   mInstance->p_draw_facet(facet, color, draw_uv);
00451 }
00452 
00453 void GfxDebug::draw_facet_edge(CubitFacetEdge* facet_edge, int color)
00454 {
00455   if(!mInstance) return;
00456   mInstance->p_draw_facet_edge(facet_edge, color);
00457 }
00458 
00459 void GfxDebug::draw_geotet(GeoTet *tet, int color)
00460 {
00461   if(!mInstance) return;
00462   mInstance->p_draw_geotet(tet, color);
00463 }
00464 
00465 void GfxDebug::draw_geonode(GeoNode *node, int color)
00466 {
00467   if(!mInstance) return;
00468   mInstance->p_draw_geonode(node, color);
00469 }
00470 
00471 // Generic Primitive Drawing Functions
00472 
00473 void GfxDebug::draw_box(CubitBox& box, int color)
00474 {
00475   if(!mInstance) return;
00476   mInstance->p_draw_box(box, color);
00477 }
00478 
00479 // draw point x,y,z of color
00480 void GfxDebug::draw_point(float x, float y, float z, int color)
00481 {
00482   if(!mInstance) return;
00483   mInstance->p_draw_point(x, y, z, color);
00484 }
00485 
00486 void GfxDebug::draw_point(const CubitVector& vector, int color)
00487 {
00488   if(!mInstance) return;
00489   mInstance->p_draw_point(vector, color);
00490 }
00491 
00492 void GfxDebug::draw_point(CubitVector* vector, int color)
00493 {
00494   if(!mInstance) return;
00495   mInstance->p_draw_point(*vector, color);
00496 }
00497 
00498 void GfxDebug::draw_points( DLIList<CubitVector> &points, int color )
00499 {
00500     if (!mInstance) return;
00501     int i;
00502     for ( i = 0; i < points.size(); i++ )
00503     {
00504         mInstance->p_draw_point( points[i], color );
00505     }
00506 }
00507 
00508 // draw line of points {x,y,z}, {x,y,z} of color
00509 void GfxDebug::draw_line(float x1, float y1, float z1, float x2, float y2, float z2, int color)
00510 {
00511   if(!mInstance) return;
00512   mInstance->p_draw_line(x1, y1, z1, x2, y2, z2, color);
00513 }
00514 
00515 void GfxDebug::draw_line(const CubitVector& x, const CubitVector& y, int color)
00516 {
00517   if(!mInstance) return;
00518   mInstance->p_draw_line(x, y, color);
00519 }
00520 
00521 // draw a polyline with a number of points of a color
00522 void GfxDebug::draw_polyline(const GPoint* points, int num_points, int color)
00523 {
00524   if(!mInstance) return;
00525   mInstance->p_draw_polyline(points, num_points, color);
00526 }
00527 
00528 // draw a polyline with a number of points of a color
00529 void GfxDebug::draw_polygon(const GPoint* points, int num_points, int color, int border_color, bool filled)
00530 {
00531   if(!mInstance) return;
00532   mInstance->p_draw_polygon(points, num_points, color, border_color, filled);
00533 }
00534 
00535 // draw a quad of a color
00536 void GfxDebug::draw_quad(const GPoint* points, int color)
00537 {
00538   if(!mInstance) return;
00539   mInstance->p_draw_quad(points, color);
00540 }
00541 
00542 // draw a tri of a color
00543 void GfxDebug::draw_tri(const GPoint* points, int color)
00544 {
00545   if(!mInstance) return;
00546   mInstance->p_draw_tri(points, color);
00547 }
00548 
00549 void GfxDebug::draw_vector(const CubitVector& tail, const CubitVector& head, int color)
00550 {
00551   if(!mInstance) return;
00552   mInstance->p_draw_vector(tail, head, color);
00553 }
00554 
00555 void GfxDebug::draw_vector(const GPoint* tail, const GPoint* head, int color)
00556 {
00557   if(!mInstance) return;
00558   mInstance->p_draw_vector(CubitVector(tail->x, tail->y, tail->z), CubitVector(head->x, head->y, head->z), color);
00559 }
00560 
00561 // draw a shell (num points, point list, num faces, face list) of color
00562 void GfxDebug::draw_shell(int num_pts, const GPoint* points, int num_faces, const int* face_list, int color)
00563 {
00564   if(!mInstance) return;
00565   mInstance->p_draw_shell(num_pts, points, num_faces, face_list, color);
00566 }
00567 
00568 // draw a label at position x,y,z of color
00569 void GfxDebug::draw_label(const char* label, float x, float y, float z, int color)
00570 {
00571   if(!mInstance) return;
00572   mInstance->p_draw_label(label, x, y, z, color);
00573 }
00574 void GfxDebug::draw_label(int label, float x, float y, float z, int color)
00575 {
00576   if(!mInstance) return;
00577   mInstance->p_draw_label(label, x, y, z, color);
00578 }
00579 
00580 // zoom to specfied bounding box
00581 void GfxDebug::zoom(CubitBox &box)
00582 {
00583   if(!mInstance) return;
00584   mInstance->p_zoom(box);
00585 }
00586 
00587 void GfxDebug::highlight_points(int num_points, const double* xyzs)
00588 {
00589   if(!mInstance) return;
00590   mInstance->p_highlight_points(num_points, xyzs);
00591 }
00592 
00593 void GfxDebug::highlight_polylines(int num_points, const double* xyzs, int num_line_points, const int* line_list)
00594 {
00595   if(!mInstance) return;
00596   mInstance->p_highlight_polylines(num_points, xyzs, num_line_points, line_list);
00597 }
00598 
00599 void GfxDebug::highlight_polygons(int num_points, const double* xyzs, int num_face_points, const int* face_list )
00600 {
00601   if(!mInstance) return;
00602   mInstance->p_highlight_polygons(num_points, xyzs, num_face_points, face_list);
00603 }
00604 
00605 // draw surface param lines
00606 void GfxDebug::draw_surface(Surface *surf, int color)
00607 {
00608   if(!mInstance) return;
00609   mInstance->p_draw_surface(surf, color);
00610 }
00611 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines