Menu

mglPoint on Ball() problem.

Help
2010-11-24
2012-10-16
  • Nobody/Anonymous

    Hi, I was using the 1.10.2 mgl version (installed by the devpack) to plot some
    simple drawings using the Ball and Line methods.
    But, somehow, the Ball(int,int,color) wasn't working as suposed to, so I hade
    to use the Ball(mglPoint(int,int),color) instead.
    Everything worked wonders, until one day I had to deinstall Dev, and when I
    reinstalled everything, mgl had a newer devpack (1.11). And now, whenever I
    try to call the Ball() with an mglPoint inside, the program simply crashes.
    I've tried Ball(mglPoint(0.1,0.1),'rL'), and declaring a "mglPoint POINT"
    before and calling Ball(POINT, 'rL') and both crashed. And calling
    Ball(0.1,0.1,'rL') still doesn't work as it should.

    Also, besides those problems with this program, I'm also having several other
    crash issues in another functions when I upgraded from 1.10.2 to 1.11.

    Thanks for your time.

     
  • Alexey Balakin

    Alexey Balakin - 2010-11-25

    Hi! I have few comments and questions.

    1. I was a bit surprised by request of Ball(int,int,color) function -- there is Ball(float,float,float,color) and Ball(mglPoint,char) for C++ (standard #include <mgl mgl.h=""> for GNU/MinGW compiler) or Ball(float,float,float,char) for C++/Python/... (in #include <mgl mgl_w.h="">). And I think it is enough. So, you can use Ball(x,y,0,color) or Ball(mglPoint(x,y),color) but not Ball(x,y,color).

    2. What kind of crushes you receive? Is this compiler/linker errors, or segmentation fault? Can you send a sample code (because my test don't show any errors)? Which version of compiler you are using (I compiled for MinGW v.3.4.5)? Which header files are use (mgl.h or mgl_w.h)? Which more crashes you have?

     
  • Nobody/Anonymous

    I'm using MinGW v.3.4.2 which came with devcpp. Including the <mgl mgl_zb.h="">.

    I thought that the Z axis had 0 for default, that's why I used
    Ball(int,int,color).
    Anyway, I just tried using the Ball(float,float,float,color) method, and the
    program run-time crashed again, just like when I try to use the
    Ball(mglPoint(x,y),color);

    My program uses some wxWidgets libraries, but I don't know what's happening,
    because in other projects without the wxWidgets all the coding works fine, I
    can mess around with mgl and nothing will go wrong, but on this wxWidgets
    problem I'm getting a lot of crashes.

    My plotting code is fairly simple:

    mglGraph *gr = new mglGraphZB;
    mglGraph *gr2 = new mglGraphZB;
    mglGraph *gr3 = new mglGraphZB;
    mglGraph *gr4 = new mglGraphZB;
    
    mglGraph *gr31 = new mglGraphZB;
    mglGraph *gr32 = new mglGraphZB;
    mglGraph *gr33 = new mglGraphZB;
    
    //My program opens a text file called FIELD.TXT, perform some interpolations with it's data and then set it to a matrix called MAT2
    /* (the file is arranged in a "X tab Y tab Z" fashion)
    FIELD.TXT initial values: 
         0.000   160.000     -16.806
         0.000   180.000     -16.900
         0.000   200.000     -18.262
         0.000   220.000     -20.360
         0.000   240.000     -22.803
         0.000   260.000     -25.376
         0.000   280.000     -27.959
         0.000   300.000     -30.487
         0.000   320.000     -32.925
         0.000   340.000     -35.255
         0.000   360.000     -37.471
         0.000   380.000     -39.572
    */
    // I initialize y with "FIELD.TXT" because I don't know how mglData's constructor parameters work;
    
    mglData y("FIELD.TXT");
    
    //Then I set it to the mglData object with the Set(gsl_matrix) method
    y.Set(MAT2);
    
    //then I apply the plot settings
    gr->SetSize(800,600);
    //these values are predefined in the code as max X, max Y, min Z and max Z in the FIELD.TXT file
    gr->SetRanges(0,maxX,0,maxY,minZ,maxZ); 
    gr->Rotate(30,225);
    gr->Light(true);
    gr->Box();
    gr->SetCut(false);
    gr->Colorbar();
    gr->Surf(y);
    

    Through some debugging, the program seems to crash during the allocations of
    gr3, gr4 or before the allocations of gr31. I've ran it several times, but it
    crashes randomly during those lines. (And I know it´s not a lack of memory
    problem)

    I also use the following link parameters:
    -lmgl -ljpeg -lgsl -lgslcblas -lz -lm

    and the wxWidgets project has included these link parameters too:
    -mwindows -lwx_mswu_core-2.9 -lwx_baseu-2.9 -loleaut32 -lole32 -luuid -lwinspool -lwinmm -lshell32 -lcomctl32 -lcomdlg32 -lctl3d32 -ladvapi32 -lwsock32 -lgdi32
    ../../wxWidgets-2.9.0-msw-static/lib/libwx_mswu_propgrid-2.9.a
    ../../wxWidgets-2.9.0-msw-static/lib/libwx_mswu_adv-2.9.a
    ../../wxWidgets-2.9.0-msw-static/lib/libwx_mswu_core-2.9.a
    ../../wxWidgets-2.9.0-msw-static/lib/libwx_baseu-2.9.a

    (the last 4 lines are libraries that I included on the project options)

    And, at last, wxWidgets also included those command line options:
    -DWXMSW -DNO_GCC_PRAGMA -fno-rtti -fno-exceptions

    Thanks for your help!

     
  • Nobody/Anonymous

    Just found out that the crashes were related to problems regarding the
    instalation of the wxWidgets. I still don't know why MGL was crashing because
    of it, but, after reinstalling every devpak, everything seems to be working
    fine now.

    Anyway, thanks for your help Mr. Abalakin.

     

Log in to post a comment.