Results 1 to 20 of 22

Thread: QVectos to multidimensional array

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2007
    Posts
    95
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QVectos to multidimensional array

    Yes, but i need a multidimensional array because opengl functions to evaluate surfaces (glMap2f, GlEvalMesh2,...) needs points in that way, like multidimensional array, and glut functions for NURBS surfaces need it too. Thats the reason why i need multidimensional array.
    If you know other way to do this (paint in opengl a surface with n points), please tell me how?

    Thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QVectos to multidimensional array

    Yes, but you are mixing and confusing things.
    You have QVector.size() points.
    So the index of the x,y and z vectors is not their location in the 3D world, but their joint values are, yet you are using the vector index as a position:
    points[ix][iy][0]=x[cont];
    what (maybe) you are looking for is:
    Qt Code:
    1. for(int i=0: i<x.size(); i++)
    2. points[x[i]][y[i]][z[i]] = somevalue;
    To copy to clipboard, switch view to plain text mode 
    but what 'somevalue' is, I don't know, its not visible in your code, maybe reflectance[i]?

  3. #3
    Join Date
    Jan 2007
    Posts
    95
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QVectos to multidimensional array

    So the index of the x,y and z vectors is not their location in the 3D world, but their joint values are, yet you are using the vector index as a position:
    Yes, you are right about confusing.

    but what 'somevalue' is, I don't know, its not visible in your code, maybe reflectance[i]?
    No, in qvector x, y and z are the coordinates in a real 3D space of the points of the surface.

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QVectos to multidimensional array

    No, in qvector x, y and z are the coordinates in a real 3D space of the points of the surface.
    Which is exactly what my last suggestion does.
    The 3D array should hold some point values, right?
    The vectors hold the x,y,z position and.... where is the value?

  5. #5
    Join Date
    Jan 2007
    Posts
    95
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QVectos to multidimensional array

    With a fortran programm i generate a grid of points who contents x,y,z,value then i select wich points has a value between l1 and l2 ( l1=value-delta, l2=value+delta), this made me a points collection with the same value of the function (this is a contour). I want to print in open gl this contour (points(x,y,z) with the same value of the function) and construct a surface with theese points. Im trying this (x,y,z) be my control points to construct the surface. I know i can joint this points with lines, triangles,... but this is not a smooth surface, so im trying to use opengl evaluators or glutnurbs where my points are the control points of the evaluator or nurbs.

    I hope you understand me.

  6. #6
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QVectos to multidimensional array

    I hope you understand me.
    Well, yes and no...

    Ok, so you have the values for each point calculated by some external function.
    Good.
    So where is the problem?
    You can use the code I suggested (with your original 3D array initialization)
    Qt Code:
    1. for(int i=0: i<x.size(); i++)
    2. points[x[i]][y[i]][z[i]] = somevalue;
    To copy to clipboard, switch view to plain text mode 

    Where 'somevalue' is the value you calculated with your fortran program.
    And you can feed this 3D array then to opengl.

  7. #7
    Join Date
    Jan 2007
    Posts
    95
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QVectos to multidimensional array

    After all, thanks a lot for your patient and for your suggestions.

    I cant see why this code works because x[i], y[i] and z[i] are floating values. And I dont know why theese points are the control points of my surface in opengl.

    Nevertheless, im going to try this....

    As I thought, compiler says me that x[i]... are not integral values. And no compile the program.
    Last edited by zorro68; 16th March 2007 at 11:31.

  8. #8
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QVectos to multidimensional array

    I cant see why this code works because x[i], y[i] and z[i] are floating values.
    You are right, I forgot these are floats.
    But then something does not add up with the information you are giving.
    What kind of a multi dimenssional array does openGL expects?
    What kind of infomation the array should have?
    The only way I see is to map the vector values to ints - otherwise you can't use them as indexes in an array.

  9. #9
    Join Date
    Feb 2007
    Posts
    49
    Thanks
    4
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QVectos to multidimensional array

    To help this discussion...

    This is what OpenGL expects. gluNurbsSurface.

  10. #10
    Join Date
    Jan 2007
    Posts
    95
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QVectos to multidimensional array

    Im trying to do something like this with my points:

    http://pgrafica.webideas4all.com/evaluators.html

    but in this way i need n*m control points, and i have not this n*m control points. I have lots of points in a 3Dspace, and i need a surface that contains all theese points.
    Im thinking of generate the n*m points with my points and interpolate (splines,bsplines,....or any suggestion) the other points. If i have the n*m control points i can construct the surface with evaluators.

  11. #11
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QVectos to multidimensional array

    I have no idea what nurbs are, since my opengl skills are limited.
    I was trying to help you sort the problem with the multidimensional array.
    I can't help you about specific openGL issues, nor is this the place for that.
    If the problem is opengl specific, you might want to try to post it on an opengl forum.

  12. #12
    Join Date
    Jan 2007
    Posts
    95
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QVectos to multidimensional array

    Thanks for all high_flyer

Similar Threads

  1. How to create QPixmap from unsigned character array?
    By rashidbutt in forum Qt Programming
    Replies: 4
    Last Post: 16th May 2006, 18:25
  2. Creating a global array in my code???
    By therealjag in forum General Programming
    Replies: 5
    Last Post: 13th March 2006, 11:13
  3. QSettings again ... how to remove array elements
    By Mike in forum Qt Programming
    Replies: 4
    Last Post: 11th January 2006, 08:58
  4. loading array values directly
    By jamadagni in forum General Programming
    Replies: 5
    Last Post: 8th January 2006, 17:50

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.