1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
#include "GfxDebug.hpp"<--- Skipping configuration 'DBL_MAX' since the value of 'DBL_MAX' is unknown. Use -D if you want to check it. You can use -U to skip it explicitly.<--- Skipping configuration 'DBL_MIN' since the value of 'DBL_MIN' is unknown. Use -D if you want to check it. You can use -U to skip it explicitly.<--- Skipping configuration 'M_PI' since the value of 'M_PI' is unknown. Use -D if you want to check it. You can use -U to skip it explicitly.
#include "GMem.hpp"
#include "CubitVector.hpp"
#include "DLIList.hpp"
#include <cassert>

GfxDebug* GfxDebug::mInstance = 0;

GfxDebug::GfxDebug()
{
  if(mInstance)
  {
    assert(0);
    // if you want a new instance in place of a previous one,
    // delete the previous one first
  }
  mInstance = this;
}

GfxDebug::~GfxDebug()
{
  mInstance = 0;
}

bool GfxDebug::is_initialized()
{
  if (mInstance == 0)<--- The function 'is_initialized' is never used.
    return false;
  return true;
}

// this will clear out all temporary data and any graphics windows created
// with this interface.
/*
void GfxDebug::reset()
{
  if(!mInstance) return;
  mInstance->p_reset();
}
*/

void GfxDebug::clear()
{
  if(!mInstance) return;
  mInstance->p_clear();
}

void GfxDebug::display_all(bool flush_highlight, bool import_mesh_display)
{
  if(!mInstance) return;
  mInstance->p_display_all(flush_highlight, import_mesh_display);
}

void GfxDebug::clear_highlight()
{
  if(!mInstance) return;
  mInstance->p_clear_highlight();
}

void GfxDebug::drawing_mode(int mode)
{
  if(!mInstance) return;<--- The function 'drawing_mode' is never used.
  mInstance->p_drawing_mode(mode);
}
/*
void GfxDebug::rebuild_all()
{
  if(!mInstance) return;
  mInstance->p_rebuild_all();
}
*/

// Window Related Functions

// creates a graphics window and makes it the current one
// not creating a window will use an existing current window
// all drawing goes only into the current window
int GfxDebug::create_window()
{
  if(!mInstance) return -1;<--- The function 'create_window' is never used.
  return mInstance->p_create_window();
}

// deletes a window created by this interface
void GfxDebug::delete_window(int window_id)
{
  if(!mInstance) return;<--- The function 'delete_window' is never used.
  mInstance->p_delete_window(window_id);
}

// switches a window created by this interface into a 2D drawing mode.
void GfxDebug::set_2D_mode(int window_id)
{
  if(!mInstance) return;<--- The function 'set_2D_mode' is never used.
  mInstance->p_set_2D_mode(window_id);
}

// causes the current window to be redrawn
void GfxDebug::flush()
{
  if(!mInstance) return;
  mInstance->p_flush();
}

// give control to the current window to handle mouse events
void GfxDebug::mouse_xforms()
{
  if(!mInstance) return;
  mInstance->p_mouse_xforms();
}

// compute display to world transformation of a length
void GfxDebug::display_to_world_length(double pixels, double& length)
{
  if(!mInstance) return;<--- The function 'display_to_world_length' is never used.
  mInstance->p_display_to_world_length(pixels, length);
}

// Geometry Drawing Functions
    
void GfxDebug::draw_ref_entity(RefEntity* entity, int color, CubitTransformMatrix* mat)
{
  if(!mInstance) return;
  mInstance->p_draw_ref_entity(entity, color, mat);
}

void GfxDebug::draw_ref_vertex(RefVertex* entity, int color)
{
  if(!mInstance) return;
  mInstance->p_draw_ref_vertex(entity, color);
}

void GfxDebug::draw_ref_edge(RefEdge* entity, int color)
{
  if(!mInstance) return;
  mInstance->p_draw_ref_edge(entity, color);
}

void GfxDebug::draw_ref_face(RefFace* entity, int color)
{
  if(!mInstance) return;
  mInstance->p_draw_ref_face(entity, color);
}

void GfxDebug::draw_ref_face_edges(RefFace* entity, int color)
{
  if(!mInstance) return;
  mInstance->p_draw_ref_face_edges(entity, color);
}

void GfxDebug::draw_ref_volume(RefVolume* entity, int color)
{
  if(!mInstance) return;
  mInstance->p_draw_ref_volume(entity, color);
}

void GfxDebug::draw_ref_body(Body* entity, int color)
{
  if(!mInstance) return;
  mInstance->p_draw_ref_body(entity, color);
}


void GfxDebug::draw_mref_entity(MRefEntity* entity, int color, bool draw_geom, bool draw_mesh, CubitTransformMatrix* mat)
{
  if(!mInstance) return;
  mInstance->p_draw_mref_entity(entity, color, draw_geom, draw_mesh, mat);
}

void GfxDebug::draw_mref_vertex(MRefVertex* entity, int color)
{
  if(!mInstance) return;<--- The function 'draw_mref_vertex' is never used.
  mInstance->p_draw_mref_vertex(entity, color);
}

void GfxDebug::draw_mref_edge(MRefEdge* entity, int color)
{
  if(!mInstance) return;<--- The function 'draw_mref_edge' is never used.
  mInstance->p_draw_mref_edge(entity, color);
}

void GfxDebug::draw_mref_face(MRefFace* entity, int color)
{
  if(!mInstance) return;<--- The function 'draw_mref_face' is never used.
  mInstance->p_draw_mref_face(entity, color);
}

void GfxDebug::draw_mref_volume(MRefVolume* entity, int color)
{
  if(!mInstance) return;<--- The function 'draw_mref_volume' is never used.
  mInstance->p_draw_mref_volume(entity, color);
}

void GfxDebug::draw_mref_body(MBody* entity, int color)
{
  if(!mInstance) return;<--- The function 'draw_mref_body' is never used.
  mInstance->p_draw_mref_body(entity, color);
}

void GfxDebug::draw_mref_entity_mesh(MRefEntity* entity, int color)
{
  if(!mInstance) return;<--- The function 'draw_mref_entity_mesh' is never used.
  mInstance->p_draw_mref_entity_mesh(entity, color);
}

void GfxDebug::draw_mref_volume_faces(MRefVolume* entity, int color)
{
  if(!mInstance) return;<--- The function 'draw_mref_volume_faces' is never used.
  mInstance->p_draw_mref_volume_faces(entity, color);
}

/*
void GfxDebug::highlight_ref_entity(RefEntity* entity)
{
  if(!mInstance) return;
  mInstance->p_highlight_ref_entity(entity);
}
*/

void GfxDebug::highlight_ref_vertex(RefVertex* entity)
{
  if(!mInstance) return;<--- The function 'highlight_ref_vertex' is never used.
  mInstance->p_highlight_ref_vertex(entity);
}

void GfxDebug::highlight_ref_edge(RefEdge* entity)
{
  if(!mInstance) return;
  mInstance->p_highlight_ref_edge(entity);
}

void GfxDebug::highlight_ref_face(RefFace* entity)
{
  if(!mInstance) return;
  mInstance->p_highlight_ref_face(entity);
}

void GfxDebug::highlight_ref_volume(RefVolume* entity)
{
  if(!mInstance) return;<--- The function 'highlight_ref_volume' is never used.
  mInstance->p_highlight_ref_volume(entity);
}

void GfxDebug::highlight_ref_body(Body* entity)
{
  if(!mInstance) return;<--- The function 'highlight_ref_body' is never used.
  mInstance->p_highlight_ref_body(entity);
}

/*
void GfxDebug::highlight_mref_entity(MRefEntity* entity)
{
  if(!mInstance) return;
  mInstance->p_highlight_mref_entity(entity);
}
*/

void GfxDebug::highlight_mref_vertex(MRefVertex* entity)
{
  if(!mInstance) return;<--- The function 'highlight_mref_vertex' is never used.
  mInstance->p_highlight_mref_vertex(entity);
}

void GfxDebug::highlight_mref_edge(MRefEdge* entity)
{
  if(!mInstance) return;<--- The function 'highlight_mref_edge' is never used.
  mInstance->p_highlight_mref_edge(entity);
}

void GfxDebug::highlight_mref_face(MRefFace* entity)
{
  if(!mInstance) return;<--- The function 'highlight_mref_face' is never used.
  mInstance->p_highlight_mref_face(entity);
}

void GfxDebug::highlight_mref_volume(MRefVolume* entity)
{
  if(!mInstance) return;<--- The function 'highlight_mref_volume' is never used.
  mInstance->p_highlight_mref_volume(entity);
}

void GfxDebug::highlight_mref_body(MBody* entity)
{
  if(!mInstance) return;<--- The function 'highlight_mref_body' is never used.
  mInstance->p_highlight_mref_body(entity);
}




// Mesh Drawing Functions

// draws mesh entities with a color from the cubit color table
// prefer these functions to a loop drawing each entity separately
/*
void GfxDebug::draw_mesh_entities(DLIList<MeshEntity*>* entities, int color)
{
  if(!mInstance) return;
  mInstance->p_draw_mesh_entities(entities, color);
}
*/

void GfxDebug::draw_nodes(DLIList<CubitNode*>* entities, int color)
{
  if(!mInstance) return;<--- The function 'draw_nodes' is never used.
  mInstance->p_draw_nodes(entities, color);
}
void GfxDebug::draw_edges(DLIList<CubitEdge*>* entities, int color)
{
  if(!mInstance) return;
  mInstance->p_draw_edges(entities, color);
}
void GfxDebug::draw_quads(DLIList<CubitFace*>* entities, int color)
{
  if(!mInstance) return;<--- The function 'draw_quads' is never used.
  mInstance->p_draw_quads(entities, color);
}
void GfxDebug::draw_tris(DLIList<CubitTri*>* entities, int color)
{
  if(!mInstance) return;<--- The function 'draw_tris' is never used.
  mInstance->p_draw_tris(entities, color);
}
void GfxDebug::draw_tets(DLIList<CubitTet*>* entities, int color)
{
  if(!mInstance) return;<--- The function 'draw_tets' is never used.
  mInstance->p_draw_tets(entities, color);
}
void GfxDebug::draw_hexes(DLIList<CubitHex*>* entities, int color)
{
  if(!mInstance) return;<--- The function 'draw_hexes' is never used.
  mInstance->p_draw_hexes(entities, color);
}
/*
void GfxDebug::draw_pyramids(DLIList<CubitPyramid*>* entities, int color)
{
  if(!mInstance) return;
  mInstance->p_draw_pyramids(entities, color);
}
*/
void GfxDebug::draw_wedges(DLIList<CubitWedge*>* entities, int color)
{
  if(!mInstance) return;<--- The function 'draw_wedges' is never used.
  mInstance->p_draw_wedges(entities, color);
}

void GfxDebug::draw_mesh_entity(MeshEntity* entity, int color)
{
  if(!mInstance) return;<--- The function 'draw_mesh_entity' is never used.
  mInstance->p_draw_mesh_entity(entity, color);
}

void GfxDebug::draw_node(CubitNode* entity, int color)
{
  if(!mInstance) return;<--- The function 'draw_node' is never used.
  mInstance->p_draw_node(entity, color);
}
void GfxDebug::draw_edge(CubitEdge* entity, int color)
{
  if(!mInstance) return;
  mInstance->p_draw_edge(entity, color);
}
void GfxDebug::draw_quad(CubitFace* entity, int color)
{
  if(!mInstance) return;
  mInstance->p_draw_quad(entity, color);
}
void GfxDebug::draw_tri(CubitTri* entity, int color)
{
  if(!mInstance) return;
  mInstance->p_draw_tri(entity, color);
}
void GfxDebug::draw_tet(CubitTet* entity, int color)
{
  if(!mInstance) return;<--- The function 'draw_tet' is never used.
  mInstance->p_draw_tet(entity, color);
}
void GfxDebug::draw_hex(CubitHex* entity, int color)
{
  if(!mInstance) return;<--- The function 'draw_hex' is never used.
  mInstance->p_draw_hex(entity, color);
}
void GfxDebug::draw_pyramid(CubitPyramid* entity, int color)
{
  if(!mInstance) return;<--- The function 'draw_pyramid' is never used.
  mInstance->p_draw_pyramid(entity, color);
}

void GfxDebug::draw_wedge(CubitWedge* entity, int color)
{
  if(!mInstance) return;<--- The function 'draw_wedge' is never used.
  mInstance->p_draw_wedge(entity, color);
}

void GfxDebug::highlight_node(CubitNode* entity)
{
  if(!mInstance) return;<--- The function 'highlight_node' is never used.
  mInstance->p_highlight_node(entity);
}

void GfxDebug::highlight_edge(CubitEdge* entity)
{
  if(!mInstance) return;<--- The function 'highlight_edge' is never used.
  mInstance->p_highlight_edge(entity);
}

void GfxDebug::highlight_quad(CubitFace* entity)
{
  if(!mInstance) return;<--- The function 'highlight_quad' is never used.
  mInstance->p_highlight_quad(entity);
}

void GfxDebug::highlight_tri(CubitTri* entity)
{
  if(!mInstance) return;<--- The function 'highlight_tri' is never used.
  mInstance->p_highlight_tri(entity);
}

void GfxDebug::highlight_tet(CubitTet* entity)
{
  if(!mInstance) return;<--- The function 'highlight_tet' is never used.
  mInstance->p_highlight_tet(entity);
}

void GfxDebug::highlight_hex(CubitHex* entity)
{
  if(!mInstance) return;<--- The function 'highlight_hex' is never used.
  mInstance->p_highlight_hex(entity);
}

void GfxDebug::highlight_pyramid(CubitPyramid* entity)
{
  if(!mInstance) return;<--- The function 'highlight_pyramid' is never used.
  mInstance->p_highlight_pyramid(entity);
}

void GfxDebug::highlight_wedge(CubitWedge* entity)
{
  if(!mInstance) return;<--- The function 'highlight_wedge' is never used.
  mInstance->p_highlight_wedge(entity);
}


// Facet Drawing Functions

void GfxDebug::draw_facet(CubitFacet* facet, int color, int draw_uv )
{
  if(!mInstance) return;
  mInstance->p_draw_facet(facet, color, draw_uv);
}

void GfxDebug::draw_facet_edge(CubitFacetEdge* facet_edge, int color)
{
  if(!mInstance) return;
  mInstance->p_draw_facet_edge(facet_edge, color);
}

void GfxDebug::draw_geotet(GeoTet *tet, int color)
{
  if(!mInstance) return;
  mInstance->p_draw_geotet(tet, color);
}

void GfxDebug::draw_geonode(GeoNode *node, int color)
{
  if(!mInstance) return;
  mInstance->p_draw_geonode(node, color);
}

// Generic Primitive Drawing Functions

void GfxDebug::draw_box(CubitBox& box, int color)
{
  if(!mInstance) return;
  mInstance->p_draw_box(box, color);
}

// draw point x,y,z of color
void GfxDebug::draw_point(float x, float y, float z, int color)
{
  if(!mInstance) return;
  mInstance->p_draw_point(x, y, z, color);
}

void GfxDebug::draw_point(const CubitVector& vector, int color)
{
  if(!mInstance) return;
  mInstance->p_draw_point(vector, color);
}

void GfxDebug::draw_point(CubitVector* vector, int color)
{
  if(!mInstance) return;
  mInstance->p_draw_point(*vector, color);
}

void GfxDebug::draw_points( DLIList<CubitVector> &points, int color )
{
    if (!mInstance) return;
    int i;
    for ( i = 0; i < points.size(); i++ )
    {
        mInstance->p_draw_point( points[i], color );
    }
}

// draw line of points {x,y,z}, {x,y,z} of color
void GfxDebug::draw_line(float x1, float y1, float z1, float x2, float y2, float z2, int color)
{
  if(!mInstance) return;
  mInstance->p_draw_line(x1, y1, z1, x2, y2, z2, color);
}

void GfxDebug::draw_line(const CubitVector& x, const CubitVector& y, int color)
{
  if(!mInstance) return;
  mInstance->p_draw_line(x, y, color);
}

// draw a polyline with a number of points of a color
void GfxDebug::draw_polyline(const GPoint* points, int num_points, int color)
{
  if(!mInstance) return;
  mInstance->p_draw_polyline(points, num_points, color);
}

// draw a polyline with a number of points of a color
void GfxDebug::draw_polygon(const GPoint* points, int num_points, int color, int border_color, bool filled)
{
  if(!mInstance) return;
  mInstance->p_draw_polygon(points, num_points, color, border_color, filled);
}

// draw a quad of a color
void GfxDebug::draw_quad(const GPoint* points, int color)
{
  if(!mInstance) return;
  mInstance->p_draw_quad(points, color);
}

// draw a tri of a color
void GfxDebug::draw_tri(const GPoint* points, int color)
{
  if(!mInstance) return;
  mInstance->p_draw_tri(points, color);
}

void GfxDebug::draw_vector(const CubitVector& tail, const CubitVector& head, int color)
{
  if(!mInstance) return;
  mInstance->p_draw_vector(tail, head, color);
}

void GfxDebug::draw_vector(const GPoint* tail, const GPoint* head, int color)
{
  if(!mInstance) return;
  mInstance->p_draw_vector(CubitVector(tail->x, tail->y, tail->z), CubitVector(head->x, head->y, head->z), color);
}

// draw a shell (num points, point list, num faces, face list) of color
void GfxDebug::draw_shell(int num_pts, const GPoint* points, int num_faces, const int* face_list, int color)
{
  if(!mInstance) return;<--- The function 'draw_shell' is never used.
  mInstance->p_draw_shell(num_pts, points, num_faces, face_list, color);
}

// draw a label at position x,y,z of color
void GfxDebug::draw_label(const char* label, float x, float y, float z, int color)
{
  if(!mInstance) return;
  mInstance->p_draw_label(label, x, y, z, color);
}
void GfxDebug::draw_label(int label, float x, float y, float z, int color)
{
  if(!mInstance) return;
  mInstance->p_draw_label(label, x, y, z, color);
}

// zoom to specfied bounding box
void GfxDebug::zoom(CubitBox &box)
{
  if(!mInstance) return;
  mInstance->p_zoom(box);
}

void GfxDebug::highlight_points(int num_points, const double* xyzs)
{
  if(!mInstance) return;<--- The function 'highlight_points' is never used.
  mInstance->p_highlight_points(num_points, xyzs);
}

void GfxDebug::highlight_polylines(int num_points, const double* xyzs, int num_line_points, const int* line_list)
{
  if(!mInstance) return;<--- The function 'highlight_polylines' is never used.
  mInstance->p_highlight_polylines(num_points, xyzs, num_line_points, line_list);
}

void GfxDebug::highlight_polygons(int num_points, const double* xyzs, int num_face_points, const int* face_list )
{
  if(!mInstance) return;<--- The function 'highlight_polygons' is never used.
  mInstance->p_highlight_polygons(num_points, xyzs, num_face_points, face_list);
}

// draw surface param lines
void GfxDebug::draw_surface(Surface *surf, int color)
{
  if(!mInstance) return;
  mInstance->p_draw_surface(surf, color);
}