Fetch grid projection info

LotfiMira
LotfiMira Posts: 9 Calcite Rank Badge
edited May 2023 in Oasis montaj
Greetings,

Is there an example showing how to fetch projection info (GXIPJ) given a grid object (GXIMG) and a context (GXContext)?

I tried the following but it crashes when calling get_3d_view()

C++ code

GXContextPtr ctx …
GXIMGPtr grid …



GXIPJPtr proj_info = GXIPJ::create(ctx);
if(proj_info)
{
grid->get_ipj(proj_info);

double x, y, z, x_rot, y_rot, z_rot, x_scale, y_scale, z_scale;
proj_info->get_3d_view(x, y, z,
x_rot, y_rot, z_rot,
x_scale, y_scale, z_scale);
}

Thank you.

Lotfi Mira

Comments

  • Hello,

    Are you able to successfully run the c++ samples? You can try modifying the gridcopy sample to get and print out the projection information using the get_3d_view function.

    Joseph

  • LotfiMira
    LotfiMira Posts: 9 Calcite Rank Badge
    edited November 2016
    Hi,

    Unfortunatly no.
    I added include path and library path to GX Developer, glib and boost.
    It builds successfully in Visual Studio.
    When I try to run it I get an error message "The application was unable to start correctly (0x000007b)

    I build with VS2012. Target set to x64.

    I had to add the following lines for it to compile
    include gxcpp_dbus.h in gridcopy.cpp
    include windows.h in gxcpp_dbus.h

    Did i forget anything?

    Thanks.

    Lotfi
  • Hi Lotfi,

    To compile and build the gridcopy example, add the inc and lib folder to the include and library paths. Once it has compiled, you can copy this executable to the bin folder of your Oasis montaj and run it. If you are still having issues, send me a direct message and I can try and assist you.

    Joseph
  • LotfiMira
    LotfiMira Posts: 9 Calcite Rank Badge
    edited November 2016
    Hi Joseph,

    I did manage to run the grid copy example. I added code to get the orientation info from the .gi file but I am still getting default values.

    Here is the modified CopyGrid() function. Am I using this wrong?

    Thanks.

    Lotfi

    void CopyGrid(gx_string_type &gridName)
    {
    // name of output grid
    gx_string_type outGridName = gridName + L" (exact copy).grd";

    // get (create) a GX Object handle
    GXContextPtr ctx = GXContext::create(std::wstring(L"GridCopy"), std::wstring(L"Geosoft Inc."));

    // load an existing grid and create new ones
    GXIMGPtr grid = GXIMG::create_file(ctx, GS_TYPES::GS_TYPE_DEFAULT, gridName, IMG_FILE::IMG_FILE_READONLY);


    // fetch orientation info from .gi file
    GXIPJPtr proj_info_ptr = GXIPJ::create(ctx);
    grid->get_ipj(proj_info_ptr);

    double x_origin, y_origin, z_origin;
    double x_rot, y_rot, z_rot;
    double x_scale, y_scale, z_scale;

    proj_info_ptr->get_3d_view(x_origin, y_origin, z_origin,
    x_rot, y_rot, z_rot,
    x_scale, y_scale, z_scale);




    GXIMGPtr outGrid = GXIMG::create_out_file(ctx, GS_TYPES::GS_TYPE_DEFAULT, outGridName, grid);

    //copy grid
    grid->copy(outGrid);
    }
  • Hi Lotfi,

    There are other get functions that may help you out. What information are you looking to gather from the GXIPJ?

    Joseph
  • Hi,

    I am looking for rotation angles of the grid.
    If I understand correctly, those are located in the .gi file next to the grid, right?
    I thought I could get it by fetching the IPJ then get_3d_view().
    Is there another way?

    Thanks

    Lotfi
  • Hi Lotfi,

    Try get_orientation_info. Values from this function is displayed on the status bar of a grid window.

    Joseph
  • Hi Joseph,

    Unfortunatly it does not seem to work either.

    On a grid that should have an orientation of 35 degrees,
    get_orientation_info() returns:
    azimuth = 0
    swing = 0

  • It works Joseph.
    I used the wrong grid.
    Now I get 35 degrees with get_orientation_info()

    Thanks for the help.
This discussion has been closed.