Changeset 1305


Ignore:
Timestamp:
Mar 10, 2009 2:05:11 PM (15 years ago)
Author:
vrinside
Message:

resized the input data less than 512

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/vizservers/nanovis/data/flowvis_dx_files/convpro/main.cpp

    r1304 r1305  
    1010{
    1111        FILE* file = fopen(filename, "wb");
    12        
    13 #if 0
    14         width = width >> 1;
    15         height = height >> 1;
    16 #endif
     12
     13        int ori_width = width;
     14        int ori_height = height;
     15        if (ori_width > 512) width = 512;
     16        if (ori_height > 512) height = 512;
     17
    1718        int count = width * height;
    1819        int total_count = width * height * depth;
    19         fprintf(file, "object 1 class gridposition counts %d %d %d\n", width, height, depth);
     20        fprintf(file, "object 1 class gridpositions counts %d %d %d\n", width, height, depth);
    2021        fprintf(file, "origin 0 0 0\n");
    2122        fprintf(file, "delta 50 0 0\n");
     
    2627       
    2728
    28         for (int z = 0; z < depth; ++z)
     29        if (ori_width <= 512 && ori_height <= 512)
    2930        {
    30                 for (int index = 0; index < count; ++index)
     31                int dataindex = 0;
     32                Vector2* ptr;
     33                for (int z = 0; z < depth; ++z)
    3134                {
    32                         fprintf(file, "%f %f 0.0\n", vector[index].x, vector[index].y);
     35                        for (int y = 0; y < height; ++y)
     36                        {
     37                                for (int x = 0; x < width; ++x)
     38                                {
     39                                        ptr = vector + (y * ori_width +  x);
     40                                        fprintf(file, "%f %f 0.0\n", ptr->x, ptr->y);
     41                                }
     42                        }
    3343                }
    3444        }
     45        else
     46        {
     47                int offsetx = 0, offsety = 0;
     48                if (ori_width > 512) { width = 512; offsetx = (ori_width - width) / 2;}
     49                if (ori_height > 512) { height = 512; offsety = (ori_height - height) / 2;}
     50
     51                int dataindex = 0;
     52                Vector2* ptr;
     53                for (int z = 0; z < depth; ++z)
     54                {
     55                        for (int y = 0; y < height; ++y)
     56                        {
     57                                for (int x = 0; x < width; ++x)
     58                                {
     59                                        ptr = vector + ((y + offsety) * ori_width +  x + offsetx);
     60                                        fprintf(file, "%f %f 0.0\n", ptr->x, ptr->y);
     61                                }
     62                        }
     63                }
     64        }
     65
    3566
    3667        fclose(file);
     
    3970int main(int argc, char* argv[])
    4071{
    41 #if 1
    42         if (argc < 7)
     72#if 0
     73        if (argc < 6)
    4374        {
    44                 printf("usage: mat2dx <Ix ascii filename> <Iy ascii filename> <width> <height> <depth> <outputfilename>\n");
    45                 return 0;
     75                printf("usage: mat2dx <Ix ascii filename> <Iy ascii filename> <width> <height> <depth>\n");
    4676        }
    4777        FILE* xComp = fopen(argv[1], "rb");
    4878        FILE* yComp = fopen(argv[2], "rb");
    49         int width, height, depth;
     79        int width = 610, height = 218;
    5080        width = atoi(argv[3]);
    5181        height = atoi(argv[4]);
    5282        depth = atoi(argv[5]);
    5383#else
    54         int width = 610, height = 218;
     84        //int width =218, height = 610;(?)
     85        int width =610, height = 218;
    5586        int depth = 50;
    5687        FILE* xComp = fopen("Ix_data.txt", "rb");
     
    94125        fclose(yComp);
    95126
    96         storeInOpenDX(argv[6], data, width, height, depth);
     127        storeInOpenDX("flow2d.dx", data, width, height, depth);
    97128}
Note: See TracChangeset for help on using the changeset viewer.