Changeset 1258


Ignore:
Timestamp:
Dec 10, 2008 12:48:52 PM (15 years ago)
Author:
gah
Message:

removed debugging from pymolproxy, field object (dumping dx file)

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/gui/scripts/editor.tcl

    r440 r1258  
    285285    if {$h+$_loc(y) >= [winfo screenheight $e]} {
    286286        set h [expr {[winfo screenheight $e]-$_loc(y)}]
    287     }
    288 
    289     wm geometry $itk_component(hull) "${w}x${h}+$_loc(x)+$_loc(y)"
     287    }                                   
     288    # Temporary fix to prevent Opps. Don't deal with negative dimensions.
     289    if { $w <= 0 || $h <= 0 } {
     290        wm geometry $itk_component(hull) "+$_loc(x)+$_loc(y)"
     291    } else {
     292        wm geometry $itk_component(hull) "${w}x${h}+$_loc(x)+$_loc(y)"
     293    }
    290294}
    291295
  • trunk/gui/scripts/field.tcl

    r1220 r1258  
    693693            set _comp2style($cname) [$_field get $cname.style]
    694694            incr _counter
     695
    695696        } elseif {$type == "opendx"} {
    696697            #
     
    702703            set data [$_field get -decode yes $cname.opendx]
    703704            set data [Rappture::encoding::decode -as zb64 $data]
    704 
    705             global fcount
    706             if { ![info exists fcount] } {
    707                 set fcount 0
    708             }
    709             incr fcount
    710             set f [open "opendx-$fcount.dx" "w"]
    711             puts $f $data
    712             close $f
    713705
    714706            set data "<ODX>$data"
  • trunk/packages/vizservers/nanovis/VolumeRenderer.cpp

    r1177 r1258  
    109109}
    110110
    111 struct SortElement{
    112   float z;
    113   int volume_id;
    114   int slice_id;
    115   SortElement(float _z, int _v, int _s):
    116           z(_z), volume_id(_v), slice_id(_s){}
     111struct SortElement {
     112    float z;
     113    int volume_id;
     114    int slice_id;
     115    SortElement(float _z, int _v, int _s):
     116        z(_z), volume_id(_v), slice_id(_s){}
    117117};
    118118
     
    154154}
    155155
    156 void VolumeRenderer::render_all()
     156void
     157VolumeRenderer::render_all()
    157158{
    158159    Volume* cur_vol = 0;
     
    163164    int num_volumes = n_volumes;
    164165
    165     if (_volumeInterpolator->is_started())
    166     {
    167         ++ num_volumes;
     166    if (_volumeInterpolator->is_started()) {
     167        ++num_volumes;
    168168        ani_tf = tf[_volumeInterpolator->getReferenceVolumeID()];
    169169        ani_vol = _volumeInterpolator->getVolume();
    170170    }
    171171
    172     ConvexPolygon*** polys = new ConvexPolygon**[num_volumes];  //two dimension pointer array
    173     int* actual_slices = new int[num_volumes]; //number of actual slices for each volume
    174 
    175     for(int vol_index = 0; vol_index< num_volumes; vol_index++)
    176     {
    177         if (vol_index != n_volumes)
    178         {
     172    //two dimension pointer array
     173    ConvexPolygon*** polys = new ConvexPolygon**[num_volumes]; 
     174    //number of actual slices for each volume
     175    int* actual_slices = new int[num_volumes];
     176
     177    for(int vol_index = 0; vol_index< num_volumes; vol_index++) {
     178        if (vol_index != n_volumes) {
    179179            cur_vol = volume[vol_index];
    180180            cur_tf = tf[vol_index];
    181         }
    182         else
    183         {
     181        } else {
    184182            cur_vol = ani_vol;
    185183            cur_tf = ani_tf;
     
    193191
    194192        int n_slices = cur_vol->get_n_slice();
    195         if (cur_vol->get_isosurface())
    196         {
    197                     // double the number of slices
     193        if (cur_vol->get_isosurface()) {
     194            // double the number of slices
    198195            n_slices <<= 1;
    199             }
    200 
     196        }
     197       
    201198        //volume start location
    202199        Vector3* location = cur_vol->get_location();
    203200        Vector4 shift_4d(location->x, location->y, location->z, 0);
    204 
     201       
    205202        double x0 = 0;
    206203        double y0 = 0;
    207204        double z0 = 0;
    208 
     205       
    209206        Mat4x4 model_view_no_trans, model_view_trans;
    210207        Mat4x4 model_view_no_trans_inverse, model_view_trans_inverse;
    211 
     208       
    212209        double zNear, zFar;
    213 
    214     //initialize volume plane with world coordinates
     210       
     211        //initialize volume plane with world coordinates
    215212        Plane volume_planes[6];
    216         volume_planes[0].set_coeffs(1, 0, 0, -x0);
    217         volume_planes[1].set_coeffs(-1, 0, 0, x0+1);
    218         volume_planes[2].set_coeffs(0, 1, 0, -y0);
    219         volume_planes[3].set_coeffs(0, -1, 0, y0+1);
    220         volume_planes[4].set_coeffs(0, 0, 1, -z0);
    221         volume_planes[5].set_coeffs(0, 0, -1, z0+1);
    222  
    223     //get modelview matrix with no translation
     213        volume_planes[0].set_coeffs( 1,  0, 0, -x0);
     214        volume_planes[1].set_coeffs(-1,  0,  0, x0+1);
     215        volume_planes[2].set_coeffs( 0,  1, 0, -y0);
     216        volume_planes[3].set_coeffs( 0, -1,  0, y0+1);
     217        volume_planes[4].set_coeffs( 0,  0, 1, -z0);
     218        volume_planes[5].set_coeffs( 0,  0, -1, z0+1);
     219       
     220        //get modelview matrix with no translation
    224221        glPushMatrix();
    225222        glScalef(cur_vol->aspect_ratio_width,
    226                 cur_vol->aspect_ratio_height,
    227                 cur_vol->aspect_ratio_depth);
    228 
     223                cur_vol->aspect_ratio_height,
     224                cur_vol->aspect_ratio_depth);
     225       
    229226        glEnable(GL_DEPTH_TEST);
    230 
     227       
    231228        GLfloat mv_no_trans[16];
    232229        glGetFloatv(GL_MODELVIEW_MATRIX, mv_no_trans);
    233 
     230       
    234231        model_view_no_trans = Mat4x4(mv_no_trans);
    235232        model_view_no_trans_inverse = model_view_no_trans.inverse();
    236 
     233       
    237234        glPopMatrix();
    238 
    239     //get modelview matrix with translation
     235       
     236        //get modelview matrix with translation
    240237        glPushMatrix();
    241238        glTranslatef(shift_4d.x, shift_4d.y, shift_4d.z);
    242239        glScalef(cur_vol->aspect_ratio_width,
    243                 cur_vol->aspect_ratio_height,
    244                 cur_vol->aspect_ratio_depth);
     240                cur_vol->aspect_ratio_height,
     241                cur_vol->aspect_ratio_depth);
    245242        GLfloat mv_trans[16];
    246243        glGetFloatv(GL_MODELVIEW_MATRIX, mv_trans);
    247 
     244       
    248245        model_view_trans = Mat4x4(mv_trans);
    249246        model_view_trans_inverse = model_view_trans.inverse();
    250 
     247       
    251248        //draw volume bounding box with translation (the correct location in
    252249        //space)
     
    255252            cur_vol->get_outline_color(olcolor);
    256253            draw_bounding_box(x0, y0, z0, x0+1, y0+1, z0+1,
    257                 (double)olcolor[0], (double)olcolor[1], (double)olcolor[2],
    258             1.5);
     254                (double)olcolor[0], (double)olcolor[1], (double)olcolor[2],
     255                1.5);
    259256        }
    260257        glPopMatrix();
    261 
     258       
    262259        //draw labels
    263260        glPushMatrix();
    264261        glTranslatef(shift_4d.x, shift_4d.y, shift_4d.z);
    265262        if(cur_vol->outline_is_enabled()) {
    266         //draw_label(i);
     263            //draw_label(i);
    267264        }
    268265        glPopMatrix();
    269 
    270     //transform volume_planes to eye coordinates.
     266       
     267        //transform volume_planes to eye coordinates.
    271268        for(int i=0; i<6; i++)
    272269            volume_planes[i].transform(model_view_no_trans);
    273 
     270       
    274271        get_near_far_z(mv_no_trans, zNear, zFar);
    275 
    276     //compute actual rendering slices
     272       
     273        //compute actual rendering slices
    277274        float z_step = fabs(zNear-zFar)/n_slices;               
    278275        int n_actual_slices;
    279 
     276       
    280277        if (cur_vol->data_is_enabled()) {
    281278            n_actual_slices = (int)(fabs(zNear-zFar)/z_step + 1);
     
    286283        }
    287284        actual_slices[vol_index] = n_actual_slices;
    288 
     285       
    289286        Vector4 vert1 = (Vector4(-10, -10, -0.5, 1));
    290287        Vector4 vert2 = (Vector4(-10, +10, -0.5, 1));
    291288        Vector4 vert3 = (Vector4(+10, +10, -0.5, 1));
    292289        Vector4 vert4 = (Vector4(+10, -10, -0.5, 1));
    293 
    294    
    295     //Render cutplanes first with depth test enabled.
    296     //They will mark the image with their depth values. Then we render other volume slices.
    297     //These volume slices will be occluded correctly by the cutplanes and vice versa.
    298 
    299     ConvexPolygon static_poly;
    300     for(int i=0; i<cur_vol->get_cutplane_count(); i++)
    301     {
    302       if(!cur_vol->cutplane_is_enabled(i))
    303         continue;
    304 
    305       float offset = cur_vol->get_cutplane(i)->offset;
    306       int axis = cur_vol->get_cutplane(i)->orient;
    307 
    308       if(axis==3){
    309         vert1 = Vector4(-10, -10, offset, 1);
    310         vert2 = Vector4(-10, +10, offset, 1);
    311         vert3 = Vector4(+10, +10, offset, 1);
    312         vert4 = Vector4(+10, -10, offset, 1);
    313         //continue;
    314       }
    315       else if(axis==1){
    316         vert1 = Vector4(offset, -10, -10, 1);
    317         vert2 = Vector4(offset, +10, -10, 1);
    318         vert3 = Vector4(offset, +10, +10, 1);
    319         vert4 = Vector4(offset, -10, +10, 1);
    320         //continue;
    321       }
    322       else if(axis==2){
    323         vert1 = Vector4(-10, offset, -10, 1);
    324         vert2 = Vector4(+10, offset, -10, 1);
    325         vert3 = Vector4(+10, offset, +10, 1);
    326         vert4 = Vector4(-10, offset, +10, 1);
    327         //continue;
    328       }
    329 
    330       vert1 = model_view_no_trans.transform(vert1);
    331       vert2 = model_view_no_trans.transform(vert2);
    332       vert3 = model_view_no_trans.transform(vert3);
    333       vert4 = model_view_no_trans.transform(vert4);
    334 
    335       ConvexPolygon* p = &static_poly;
    336       p->vertices.clear();
    337 
    338       p->append_vertex(vert1);
    339       p->append_vertex(vert2);
    340       p->append_vertex(vert3);
    341       p->append_vertex(vert4);
    342 
    343       for(int k=0; k<6; k++){
    344         p->clip(volume_planes[k], true);
    345       }
    346 
    347       p->transform(model_view_no_trans_inverse);
    348       p->transform(model_view_trans);
    349 
    350       glPushMatrix();
    351       glScalef(cur_vol->aspect_ratio_width, cur_vol->aspect_ratio_height, cur_vol->aspect_ratio_depth);
    352 
    353       activate_volume_shader(cur_vol, cur_tf, true);
    354       glPopMatrix();
    355 
    356       glEnable(GL_DEPTH_TEST);
    357       glDisable(GL_BLEND);
    358 
    359       glBegin(GL_POLYGON);
    360         p->Emit(true);
    361       glEnd();
    362       glDisable(GL_DEPTH_TEST);
    363 
    364       deactivate_volume_shader();
    365     } //done cutplanes
    366 
    367    
    368     //Now do volume rendering
    369 
     290       
     291       
     292        // Render cutplanes first with depth test enabled.  They will mark the
     293        // image with their depth values.  Then we render other volume slices.
     294        // These volume slices will be occluded correctly by the cutplanes and
     295        // vice versa.
     296       
     297        ConvexPolygon static_poly;
     298        for(int i=0; i<cur_vol->get_cutplane_count(); i++) {
     299            if(!cur_vol->cutplane_is_enabled(i))
     300                continue;
     301           
     302            float offset = cur_vol->get_cutplane(i)->offset;
     303            int axis = cur_vol->get_cutplane(i)->orient;
     304           
     305            if(axis==3){
     306                vert1 = Vector4(-10, -10, offset, 1);
     307                vert2 = Vector4(-10, +10, offset, 1);
     308                vert3 = Vector4(+10, +10, offset, 1);
     309                vert4 = Vector4(+10, -10, offset, 1);
     310                //continue;
     311            } else if(axis==1){
     312                vert1 = Vector4(offset, -10, -10, 1);
     313                vert2 = Vector4(offset, +10, -10, 1);
     314                vert3 = Vector4(offset, +10, +10, 1);
     315                vert4 = Vector4(offset, -10, +10, 1);
     316                //continue;
     317            } else if(axis==2){
     318                vert1 = Vector4(-10, offset, -10, 1);
     319                vert2 = Vector4(+10, offset, -10, 1);
     320                vert3 = Vector4(+10, offset, +10, 1);
     321                vert4 = Vector4(-10, offset, +10, 1);
     322                //continue;
     323            }
     324           
     325            vert1 = model_view_no_trans.transform(vert1);
     326            vert2 = model_view_no_trans.transform(vert2);
     327            vert3 = model_view_no_trans.transform(vert3);
     328            vert4 = model_view_no_trans.transform(vert4);
     329           
     330            ConvexPolygon* p = &static_poly;
     331            p->vertices.clear();
     332           
     333            p->append_vertex(vert1);
     334            p->append_vertex(vert2);
     335            p->append_vertex(vert3);
     336            p->append_vertex(vert4);
     337           
     338            for(int k=0; k<6; k++){
     339                p->clip(volume_planes[k], true);
     340            }
     341           
     342            p->transform(model_view_no_trans_inverse);
     343            p->transform(model_view_trans);
     344           
     345            glPushMatrix();
     346            glScalef(cur_vol->aspect_ratio_width, cur_vol->aspect_ratio_height,
     347                     cur_vol->aspect_ratio_depth);
     348           
     349            activate_volume_shader(cur_vol, cur_tf, true);
     350            glPopMatrix();
     351           
     352            glEnable(GL_DEPTH_TEST);
     353            glDisable(GL_BLEND);
     354           
     355            glBegin(GL_POLYGON);
     356            p->Emit(true);
     357            glEnd();
     358            glDisable(GL_DEPTH_TEST);
     359           
     360            deactivate_volume_shader();
     361        } //done cutplanes
     362       
     363       
     364        //Now do volume rendering
     365       
    370366        vert1 = (Vector4(-10, -10, -0.5, 1));
    371367        vert2 = (Vector4(-10, +10, -0.5, 1));
    372368        vert3 = (Vector4(+10, +10, -0.5, 1));
    373369        vert4 = (Vector4(+10, -10, -0.5, 1));
    374 
     370       
    375371        int counter = 0;
    376    
    377     //transform slices and store them
     372       
     373        //transform slices and store them
    378374        float slice_z;
    379         for (int i=0; i<n_actual_slices; i++)
    380         {
    381             slice_z = zFar + i * z_step;        //back to front
    382 
     375        for (int i=0; i<n_actual_slices; i++) {
     376            slice_z = zFar + i * z_step;        //back to front
     377           
    383378            ConvexPolygon *poly = new ConvexPolygon();
    384379            polys[vol_index][counter] = poly;
    385380            counter++;
    386 
     381           
    387382            poly->vertices.clear();
    388383            poly->set_id(vol_index);
    389 
     384           
    390385            //Setting Z-coordinate
    391386            vert1.z = slice_z;
     
    393388            vert3.z = slice_z;
    394389            vert4.z = slice_z;
    395                
     390           
    396391            poly->append_vertex(vert1);
    397392            poly->append_vertex(vert2);
    398393            poly->append_vertex(vert3);
    399394            poly->append_vertex(vert4);
    400        
    401             for(int k=0; k<6; k++)
    402             {
    403                 poly->clip(volume_planes[k], true);
    404             }
    405 
     395           
     396            for(int k=0; k<6; k++) {
     397                poly->clip(volume_planes[k], true);
     398            }
     399           
    406400            poly->transform(model_view_no_trans_inverse);
    407401            poly->transform(model_view_trans);
    408 
     402           
    409403            if(poly->vertices.size()>=3)
    410                     total_rendered_slices++;
     404                total_rendered_slices++;
    411405        }
    412    
    413   } //iterate all volumes
    414   //fprintf(stderr, "total slices: %d\n", total_rendered_slices);
    415 
    416   //We sort all the polygons according to their eye-space depth, from farthest to the closest.
    417   //This step is critical for correct blending
    418 
    419     SortElement* slices = (SortElement*) malloc(sizeof(SortElement)*total_rendered_slices);
    420 
     406       
     407    } //iterate all volumes
     408    //fprintf(stderr, "total slices: %d\n", total_rendered_slices);
     409   
     410    //We sort all the polygons according to their eye-space depth, from farthest to the closest.
     411    //This step is critical for correct blending
     412   
     413    SortElement* slices = (SortElement*)malloc(sizeof(SortElement)*total_rendered_slices);
     414   
    421415    int counter = 0;
    422416    for(int i=0; i<num_volumes; i++){
     
    428422        }
    429423    }
    430 
    431   //sort them
     424   
     425    //sort them
    432426    qsort(slices, total_rendered_slices, sizeof(SortElement), slice_sort);
    433 
    434   //Now we are ready to render all the slices from back to front
     427   
     428    //Now we are ready to render all the slices from back to front
    435429    glEnable(GL_DEPTH_TEST);
    436430    glEnable(GL_BLEND);
    437 
     431   
    438432    for(int i=0; i<total_rendered_slices; i++){
    439433        int volume_index = slices[i].volume_id;
    440434        int slice_index = slices[i].slice_id;
    441435        ConvexPolygon* cur = polys[volume_index][slice_index];
    442 
    443         if (volume_index == n_volumes)
    444         {
    445             cur_vol = ani_vol;
    446             cur_tf = ani_tf;
    447         }
    448         else
    449         {
     436       
     437        if (volume_index == n_volumes) {
     438            cur_vol = ani_vol;
     439            cur_tf = ani_tf;
     440        } else {
    450441            cur_vol = volume[volume_index];
    451442            cur_tf = tf[volume_index];
    452443        }
    453 
    454 
     444       
     445       
    455446        glPushMatrix();
    456447        glScalef(cur_vol->aspect_ratio_width, cur_vol->aspect_ratio_height, cur_vol->aspect_ratio_depth);
    457    
     448       
    458449        activate_volume_shader(cur_vol, cur_tf, false);
    459450        glPopMatrix();
    460 
     451       
    461452        glBegin(GL_POLYGON);
    462453        cur->Emit(true);
     
    465456        deactivate_volume_shader();
    466457    }
    467 
    468 
     458   
     459   
    469460    glDisable(GL_DEPTH_TEST);
    470461    glDisable(GL_BLEND);
    471 
     462   
    472463    //Deallocate all the memory used
    473464    for(int i=0; i<num_volumes; i++){
     
    475466            delete polys[i][j];
    476467        }
    477 
    478         if (polys[i])
    479         {
     468       
     469        if (polys[i]) {
    480470            delete[] polys[i];
    481471        }
    482472    }
    483 
     473   
    484474    delete[] polys;
    485475    delete[] actual_slices;
  • trunk/packages/vizservers/nanovis/nanovis.cpp

    r1249 r1258  
    461461
    462462/* Load a 3D volume
    463  * index: the index into the volume array, which stores pointers to 3D volume instances
    464  * data: pointer to an array of floats.
    465  * n_component: the number of scalars for each space point.
    466  *              All component scalars for a point are placed consequtively in data array
    467  * width, height and depth: number of points in each dimension
     463 * index:       the index into the volume array, which stores pointers
     464 *              to 3D volume instances
     465 * data:        pointer to an array of floats.
     466 * n_component: the number of scalars for each space point. All component
     467 *              scalars for a point are placed consequtively in data array
     468 *              width, height and depth: number of points in each dimension
    468469 */
    469470Volume *
  • trunk/packages/vizservers/pymolproxy/pymolproxy.c

    r1219 r1258  
    6868
    6969static FILE *flog;
    70 static int debug = TRUE;
     70static int debug = 0;
    7171
    7272typedef struct {
Note: See TracChangeset for help on using the changeset viewer.