Hi everyone,
I wanted to share a quick note about the classic “snap” issue when working with real UTM coordinates (X/Y in the millions) in GiD/Iber. As you probably know, the cursor jumps in 1m or 10m steps, making precise geometry creation and picking a real headache. It’s just the OpenGL float32 limitation, while the kernel itself works in double precision.
My current workaround
To get around this, I ended up writing a Tcl plugin (UTM_Tools) that physically translates the imported geometry to the origin (0,0,0). I work locally and only re-apply the offset when exporting or calculating. It works, but moving geometry around is destructive, can mess up the topology, and requires custom plugins for different problem types. For the moment the plugin works only with IBER and with Shapefile and background image import.
The idea
Instead of relying on external plugins and physical moves, would it be feasible to introduce two project-level variables (offset_x, offset_y, default 0.0) directly in the kernel?
The kernel could apply the offset transparently only at the boundaries:
-
Subtracting it before sending data to OpenGL (so the GPU always gets small numbers).
-
Adding it to the
GiD_GetWorldCoordresults. -
Applying it automatically during import/export.
This would keep the kernel in double precision, OpenGL safe, and make the whole user experience completely transparent across any problem type.
I’ve looked into the Tcl interface files to see where the kernel would need to apply this offset.
I cannot upload files so the following is an extract of a report on the problem:
Based on the analysis of the Tcl interface files (gid_gis.tcl, gid_shapefile.tcl, Import.tcl, tclfileP.tcl, GrDataMenus.tcl), the offset must be applied at the following kernel boundaries:
5.1 Rendering pipeline (OpenGL → GPU)
• Before submitting vertices to OpenGL, the kernel subtracts (offset_x, offset_y, offset_z).
• Result: OpenGL receives coordinates near the origin and never suffers from float32 precision loss, regardless of the real model position.
• The internal double-precision database is unchanged: it continues to store real coordinates.
5.2 Picking (mouse → world coordinates)
• When the user clicks, the kernel converts screen (2D) → model (3D) coordinates.
• The result returned to Tcl (via GiD_GetWorldCoord) must be local + offset, so the user always receives real coordinates.
• This single change automatically propagates to all places that use GiD_GetWorldCoord: precision-point tools, geometry creation, the coordinate bar, etc.
5.3 Status bar (bottom-right coordinate readout)
• If §5.2 is applied, the status bar (currently populated by the C++ kernel) automatically shows real coordinates. No additional work is needed.
5.4 User input (command line, Coordinate Window)
• When the user types coordinates (command line or Coordinate Window), the kernel must interpret them as real coordinates and internally use real - offset before storing them.
• If the current input is in local coordinates (e.g. Create Point after an Offset = 0 project), behavior is unchanged.
5.5 File I/O (import / export)
• Import (Shapefile, XYZ, GDAL Raster, DXF, KML, STL, .msh, .2dm, etc.): the kernel receives real coordinates from the file, subtracts the offset, and stores local in the database. The Tcl-level importers that call GiD_Geometry create point will see local coordinates coming out of the kernel.
• Export (IGES, DXF, VTK, .msh, .dat, .bas, STL, etc.): the kernel adds the offset before writing.
• Raster georeferencing: the georeferencing info (.prj, GeoTIFF metadata, etc.) is already read by GDAL and used to compute the raster’s extent. The offset should be applied to the computed extent before sending it to OpenGL.
5.6 Solver input files (calculation)
• When writing .dat/.bas files for the solver, the offset is subtracted so that the solver works in local coordinates.
• This is compatible with the existing Iber behavior where the solver already works in local coordinates (or can be made to).
• Optionally: provide a preference so the user can choose whether the solver receives real or local coordinates.
5.7 Camera and view
• The camera (eye, target, up vector) and view matrix should remain in local coordinates internally, to avoid precision issues in the matrix math.
• The view is then rendered correctly after §5.1.
5.8 Operations that are already double-precision
• Boolean operations, NURBS construction, mesh generation, and the mathematical kernel in general already work in double precision. They see real coordinates internally and are unaffected by the change. Only the rendering and picking views need the offset applied.
I’d love to hear if the developers think this is feasible, or if anyone else has found a better way to handle this!
Cheers
Oscar