Skip to content

Commit

Permalink
Merge pull request firemodels#2091 from gforney/patch
Browse files Browse the repository at this point in the history
add debug blockage drawing routine, fix to new (faster) blockage drawing routine
  • Loading branch information
gforney authored Nov 9, 2024
2 parents 3605b3f + c2dfcd2 commit 2a69826
Show file tree
Hide file tree
Showing 14 changed files with 997 additions and 42 deletions.
150 changes: 143 additions & 7 deletions Source/smokeview/IOgeometry.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,145 @@ int HaveNonTextures(tridata **tris, int ntris){
return 0;
}

/* ------------------ DrawBox ------------------------ */
/* ------------------ DrawBoxShaded ------------------------ */

void DrawBox(float *bb, float *box_color){
void DrawBoxShaded(float *bb, int flag, int *hidden6, float *box_color){
float x0, x1, y0, y1, z0, z1;

x0 = bb[0];
x1 = bb[1];
y0 = bb[2];
y1 = bb[3];
z0 = bb[4];
z1 = bb[5];
glColor3fv(box_color);
glBegin(GL_TRIANGLES);

if(flag==2||(flag==3&&hidden6[0]==0)){
glNormal3f(-1.0, 0.0, 0.0);
glVertex3f(x0, y0, z0);
glVertex3f(x0, y1, z1);
glVertex3f(x0, y1, z0);
glVertex3f(x0, y0, z0);
glVertex3f(x0, y0, z1);
glVertex3f(x0, y1, z1);

if(flag == 3 && hidden6[0] == 0){
glNormal3f(1.0, 0.0, 0.0);
glVertex3f(x0, y0, z0);
glVertex3f(x0, y1, z0);
glVertex3f(x0, y1, z1);
glVertex3f(x0, y0, z0);
glVertex3f(x0, y1, z1);
glVertex3f(x0, y0, z1);
}
}

if(flag==2||(flag==3&&hidden6[1]==0)){
glNormal3f(1.0, 0.0, 0.0);
glVertex3f(x1, y0, z0);
glVertex3f(x1, y1, z0);
glVertex3f(x1, y1, z1);
glVertex3f(x1, y0, z0);
glVertex3f(x1, y1, z1);
glVertex3f(x1, y0, z1);

if(flag == 3 && hidden6[1] == 0){
glNormal3f(-1.0, 0.0, 0.0);
glVertex3f(x1, y0, z0);
glVertex3f(x1, y1, z1);
glVertex3f(x1, y1, z0);
glVertex3f(x1, y0, z0);
glVertex3f(x1, y0, z1);
glVertex3f(x1, y1, z1);
}
}

if(flag==2||(flag==3&&hidden6[2]==0)){
glNormal3f(0.0, -1.0, 0.0);
glVertex3f(x0, y0, z0);
glVertex3f(x1, y0, z0);
glVertex3f(x1, y0, z1);
glVertex3f(x0, y0, z0);
glVertex3f(x1, y0, z1);
glVertex3f(x0, y0, z1);

if(flag == 3 && hidden6[2] == 0){
glNormal3f(0.0, 1.0, 0.0);
glVertex3f(x0, y0, z0);
glVertex3f(x1, y0, z1);
glVertex3f(x1, y0, z0);
glVertex3f(x0, y0, z0);
glVertex3f(x0, y0, z1);
glVertex3f(x1, y0, z1);
}
}

if(flag==2||(flag==3&&hidden6[3]==0)){
glNormal3f(0.0, 1.0, 0.0);
glVertex3f(x0, y1, z0);
glVertex3f(x1, y1, z1);
glVertex3f(x1, y1, z0);
glVertex3f(x0, y1, z0);
glVertex3f(x0, y1, z1);
glVertex3f(x1, y1, z1);

if(flag == 3 && hidden6[3] == 0){
glNormal3f(0.0, -1.0, 0.0);
glVertex3f(x0, y1, z0);
glVertex3f(x1, y1, z0);
glVertex3f(x1, y1, z1);
glVertex3f(x0, y1, z0);
glVertex3f(x1, y1, z1);
glVertex3f(x0, y1, z1);
}
}

if(flag==2||(flag==3&&hidden6[4]==0)){
glNormal3f(0.0, 0.0, -1.0);
glVertex3f(x1, y0, z0);
glVertex3f(x0, y0, z0);
glVertex3f(x1, y1, z0);
glVertex3f(x0, y0, z0);
glVertex3f(x0, y1, z0);
glVertex3f(x1, y1, z0);

if(flag == 3 && hidden6[4] == 0){
glNormal3f(0.0, 0.0, 1.0);
glVertex3f(x1, y0, z0);
glVertex3f(x1, y1, z0);
glVertex3f(x0, y0, z0);
glVertex3f(x0, y0, z0);
glVertex3f(x1, y1, z0);
glVertex3f(x0, y1, z0);
}
}

if(flag==2||(flag==3&&hidden6[5]==0)){
glNormal3f(0.0, 0.0, 1.0);
glVertex3f(x0, y0, z1);
glVertex3f(x1, y0, z1);
glVertex3f(x1, y1, z1);
glVertex3f(x0, y0, z1);
glVertex3f(x1, y1, z1);
glVertex3f(x0, y1, z1);

if(flag == 3 && hidden6[5] == 0){
glNormal3f(0.0, 0.0, -1.0);
glVertex3f(x0, y0, z1);
glVertex3f(x1, y1, z1);
glVertex3f(x1, y0, z1);
glVertex3f(x0, y0, z1);
glVertex3f(x0, y1, z1);
glVertex3f(x1, y1, z1);
}
}
glEnd();
}

/* ------------------ DrawBoxOutline ------------------------ */

void DrawBoxOutline(float *bb, float *box_color){
glColor3fv(box_color);
glLineWidth(geom_linewidth);
glBegin(GL_LINES);
Expand Down Expand Up @@ -377,7 +513,7 @@ void DrawBox(float *bb, float *box_color){
glEnd();
}

/* ------------------ DrawBox ------------------------ */
/* ------------------ DrawBoxMinMax ------------------------ */

void DrawBoxMinMax(float *bbmin, float *bbmax, float *box_color){
float bb[6];
Expand All @@ -388,7 +524,7 @@ void DrawBoxMinMax(float *bbmin, float *bbmax, float *box_color){
bb[1] = bbmax[0];
bb[3] = bbmax[1];
bb[5] = bbmax[2];
DrawBox(bb, box_color);
DrawBoxOutline(bb, box_color);
}

/* ------------------ DrawObstBoundingBox ------------------------ */
Expand All @@ -400,7 +536,7 @@ void DrawObstBoundingBox(void){
glPushMatrix();
glScalef(SCALE2SMV(1.0), SCALE2SMV(1.0), SCALE2SMV(1.0));
glTranslatef(-xbar0, -ybar0, -zbar0);
DrawBox(obst_bounding_box, foregroundcolor);
DrawBoxOutline(obst_bounding_box, foregroundcolor);
glPopMatrix();
}

Expand Down Expand Up @@ -429,12 +565,12 @@ void DrawGeomBoundingBox(float *boundingbox_color){
box_color = foregroundcolor;
if(geomobjj->color!=NULL)box_color = geomobjj->color;
if(boundingbox_color!=NULL)box_color = boundingbox_color;
DrawBox(geomobjj->bounding_box, box_color);
DrawBoxOutline(geomobjj->bounding_box, box_color);
have_box = 1;
}
}
if(have_box==0){
DrawBox(geomi->bounding_box, foregroundcolor);
DrawBoxOutline(geomi->bounding_box, foregroundcolor);
}
}
glPopMatrix();
Expand Down
2 changes: 1 addition & 1 deletion Source/smokeview/c_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -2468,7 +2468,7 @@ int SetTicklinewidth(float v) {
} // TICKLINEWIDTH

int SetUsenewdrawface(int v) {
use_new_drawface = v;
blockage_draw_option = v;
return 0;
} // USENEWDRAWFACE

Expand Down
15 changes: 12 additions & 3 deletions Source/smokeview/callbacks.c
Original file line number Diff line number Diff line change
Expand Up @@ -2584,11 +2584,20 @@ void Keyboard(unsigned char key, int flag){
}
break;
case 'U':
use_new_drawface = 1 - use_new_drawface;
blockage_draw_option++;
#ifdef pp_OBST_DEBUG
if(blockage_draw_option > 3)blockage_draw_option = 0;
#else
if(blockage_draw_option > 1)blockage_draw_option = 0;
#endif
updatefacelists = 1;
GLUIUpdateFastBlockageDraw();
if(use_new_drawface == 1)printf("fast blockage drawing\n");
if(use_new_drawface == 0)printf("original blockage drawing\n");
if(blockage_draw_option == 0)printf("original blockage drawing\n");
if(blockage_draw_option == 1)printf("fast blockage drawing\n");
#ifdef pp_OBST_DEBUG
if(blockage_draw_option == 2)printf("debug blockage drawing\n");
if(blockage_draw_option == 3)printf("debug blockage drawing, draw only hidden faces\n");
#endif
break;
case '|':
projection_type = 1-projection_type;
Expand Down
90 changes: 80 additions & 10 deletions Source/smokeview/drawGeometry.c
Original file line number Diff line number Diff line change
Expand Up @@ -2853,7 +2853,7 @@ void UpdateFaceListsWorker(void){
nface_transparent_double += n_transparent_double;
nface_outlines += n_outlines;

if(use_new_drawface==0)continue;
if(blockage_draw_option!=1)continue;

meshi->nface_normals_single_DOWN_X=0;
meshi->nface_normals_single_UP_X=0;
Expand All @@ -2879,12 +2879,17 @@ void UpdateFaceListsWorker(void){
facei->dup=0;
faceim1 = meshi->face_normals_single[iface-1];
if(
facei->imax-facei->imin<=1&&facei->jmax-facei->jmin<=1&&facei->kmax-facei->kmin<=1&& // only hide duplicate one cell faces
faceim1->imin==facei->imin&&faceim1->imax==facei->imax&&
faceim1->jmin==facei->jmin&&faceim1->jmax==facei->jmax&&
faceim1->kmin==facei->kmin&&faceim1->kmax==facei->kmax&&faceim1->dir!=facei->dir
facei->imax-facei->imin<=1&&
facei->jmax-facei->jmin<=1&&
facei->kmax-facei->kmin<=1&& // only hide duplicate one cell faces
faceim1->imin==facei->imin&&
faceim1->imax==facei->imax&&
faceim1->jmin==facei->jmin&&
faceim1->jmax==facei->jmax&&
faceim1->kmin==facei->kmin&&
faceim1->kmax==facei->kmax&&
faceim1->dir!=facei->dir
){
if(*(faceim1->showtimelist_handle)==NULL)faceim1->dup=1;
if(*(facei->showtimelist_handle)==NULL){
facei->dup=1;
nhidden++;
Expand Down Expand Up @@ -3060,6 +3065,60 @@ void DrawSelectFaces(){
glVertex3fv(vertices+6);\
glVertex3fv(vertices+9);


#ifdef pp_OBST_DEBUG
/* ------------------ DrawObstsDebug ------------------------ */

void DrawObstsDebug(void){
int i;

glPushMatrix();
glScalef(SCALE2SMV(1.0),SCALE2SMV(1.0),SCALE2SMV(1.0));
glTranslatef(-xbar0,-ybar0,-zbar0);
if(light_faces == 1){
ENABLE_LIGHTING;
glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, &block_shininess);
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, block_ambient2);
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, block_specular2);
glEnable(GL_COLOR_MATERIAL);
}
for(i = 0; i < nmeshes; i++){
meshdata *meshi;
int j;
int jmin, jmax;

meshi = meshinfo + i;
jmin = 0;
jmax = meshi->nbptrs-1;
if(mesh_index_debug >= 0 && mesh_index_debug < nmeshes){
int max_blockage_index_debug;
if(mesh_index_debug!=i)continue;
max_blockage_index_debug = min_blockage_index_debug + n_blockages_debug - 1;
if(min_blockage_index_debug >= 0 && min_blockage_index_debug < meshi->nbptrs){
if(max_blockage_index_debug >= 0 && max_blockage_index_debug < meshi->nbptrs){
if(min_blockage_index_debug <= max_blockage_index_debug){
jmin = min_blockage_index_debug;
jmax = max_blockage_index_debug;
}
}
}
}
for(j = jmin; j<=jmax; j++){
blockagedata *bc;

bc = meshi->blockageinfoptrs[j];
void DrawBoxShaded(float *bb, int flag, int *hidden6, float *box_color);
DrawBoxShaded(bc->xyz, blockage_draw_option, bc->hidden6, bc->color);
}
}
if(light_faces == 1){
glDisable(GL_COLOR_MATERIAL);
DISABLE_LIGHTING;
}
glPopMatrix();
}
#endif

/* ------------------ DrawFacesOLD ------------------------ */
// add option to turn off lighting when verifying smoke
void DrawFacesOLD(){
Expand Down Expand Up @@ -4973,11 +5032,22 @@ void DrawBlockages(int mode, int trans_flag){
}
}
else{
if(use_new_drawface==1){
DrawFaces();
}
else{
switch(blockage_draw_option){
case 0:
DrawFacesOLD();
break;
case 1:
DrawFaces();
break;
#ifdef pp_OBST_DEBUG
case 2:
case 3:
DrawObstsDebug();
break;
#endif
default:
assert(0);
break;
}
}
}
Expand Down
18 changes: 15 additions & 3 deletions Source/smokeview/glui_display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ GLUI_Checkbox *CHECKBOX_user_ticks_show_x=NULL;
GLUI_Checkbox *CHECKBOX_user_ticks_show_y=NULL;
GLUI_Checkbox *CHECKBOX_user_ticks_show_z=NULL;
GLUI_Checkbox *CHECKBOX_tick_auto=NULL;
GLUI_Checkbox *CHECKBOX_label_1=NULL;
GLUI_Checkbox *CHECKBOX_label_2=NULL;
GLUI_Checkbox *CHECKBOX_label_3=NULL;
GLUI_Checkbox *CHECKBOX_labels_flip=NULL;
Expand All @@ -141,6 +140,7 @@ GLUI_Rollout *ROLLOUT_general=NULL;
GLUI_Rollout *ROLLOUT_north = NULL;
GLUI_Rollout *ROLLOUT_light2 = NULL;

GLUI_Panel *PANEL_blockage_drawing = NULL;
GLUI_Panel *PANEL_boundingbox = NULL;
GLUI_Panel *PANEL_titles=NULL;
GLUI_Panel *PANEL_screen = NULL;
Expand Down Expand Up @@ -175,6 +175,7 @@ GLUI_Panel *PANEL_texture_display = NULL;
GLUI_RadioGroup *RADIO_show_geom_boundingbox = NULL;
GLUI_RadioGroup *RADIO_timebar_overlap = NULL;
GLUI_RadioGroup *RADIO_fontsize = NULL;
GLUI_RadioGroup *RADIOBUTTON_label_1 = NULL;
GLUI_RadioButton *RADIOBUTTON_label_1a=NULL;
GLUI_RadioButton *RADIOBUTTON_label_1b=NULL;
GLUI_RadioButton *RADIOBUTTON_label_1c=NULL;
Expand Down Expand Up @@ -305,7 +306,7 @@ extern "C" void GLUIUpdateTimebarOverlap(void){
/* ------------------ GLUIUpdateTimebarOverlap ------------------------ */

extern "C" void GLUIUpdateFastBlockageDraw(void){
if(CHECKBOX_label_1 != NULL)CHECKBOX_label_1->set_int_val(use_new_drawface);
if(RADIOBUTTON_label_1 != NULL)RADIOBUTTON_label_1->set_int_val(blockage_draw_option);
}

/* ------------------ DisplayRolloutCB ------------------------ */
Expand Down Expand Up @@ -880,7 +881,18 @@ extern "C" void GLUIDisplaySetup(int main_window){
glui_labels->add_radiobutton_to_group(RADIO_timebar_overlap,_("Never"));
glui_labels->add_radiobutton_to_group(RADIO_timebar_overlap,_("Only if timebar hidden"));

CHECKBOX_label_1=glui_labels->add_checkbox_to_panel(PANEL_gen3,_("Fast blockage drawing"),&use_new_drawface,LABELS_drawface,GLUILabelsCB);
PANEL_blockage_drawing = glui_labels->add_panel_to_panel(PANEL_gen3,_("Blockage drawing"));
RADIOBUTTON_label_1 = glui_labels->add_radiogroup_to_panel(PANEL_blockage_drawing, &blockage_draw_option, LABELS_drawface, GLUILabelsCB);
glui_labels->add_radiobutton_to_group(RADIOBUTTON_label_1, _("original"));
glui_labels->add_radiobutton_to_group(RADIOBUTTON_label_1, _("new"));
#ifdef pp_OBST_DEBUG
glui_labels->add_radiobutton_to_group(RADIOBUTTON_label_1, _("debug"));
glui_labels->add_radiobutton_to_group(RADIOBUTTON_label_1, _("debug - draw only hidden faces"));
glui_labels->add_spinner_to_panel(PANEL_blockage_drawing, "mesh:", GLUI_SPINNER_INT, &mesh_index_debug);
glui_labels->add_spinner_to_panel(PANEL_blockage_drawing, "min blockage index:", GLUI_SPINNER_INT, &min_blockage_index_debug);
glui_labels->add_spinner_to_panel(PANEL_blockage_drawing, "number of blockages:", GLUI_SPINNER_INT, &n_blockages_debug);
#endif

CHECKBOX_label_2=glui_labels->add_checkbox_to_panel(PANEL_gen3,_("Sort transparent faces"),&sort_transparent_faces,LABELS_drawface,GLUILabelsCB);
CHECKBOX_label_3=glui_labels->add_checkbox_to_panel(PANEL_gen3,_("Hide overlaps"),&hide_overlaps,LABELS_hide_overlaps,GLUILabelsCB);

Expand Down
Loading

0 comments on commit 2a69826

Please sign in to comment.