Geometry information while raytracing

Developers
2009-11-13
2013-04-22
  • Wim Bokkers
    Wim Bokkers
    2009-11-13

    Hi all,

    While raytracing, I can get information about the regions/intersections like:
    - region name
    - name of solids (entry and exit)
    - normals (entry and exit)
    - curvature (don't know how to interpret this yet)
    and so on…

    Now I need to obtain more information about the geometry of a region that was hit. Is it possitble to get the triangulated geometry of a region? What's the best way to approach these kind of use cases in code?

    Kind regards,
    Wim Bokkers

     
  • Sean Morrison
    Sean Morrison
    2009-11-14

    It is certainly possible, but there's yet not a clean API call for doing this and there are several decisions that have to be made on how to triangulate and how to recover from errors.  That said, there are several examples that do what you suggest in the src/conv directory.  The src/conv/g-xxx_facets.c file is the core approach most of the converters take.

    The core of the approach, from the perspective of our API is to call `nmg_booltree_leaf_tess()` on each primitive to get a polygonal representation of that primitive.  Then recursively for each combination above it, calling `nmg_booltree_evaluate()` to perform the corresponding CSG boolean evaluation.  Using `db_walk_tree()` in LIBRT, you can specify how you want it to traverse, for example whether to stop at a given region, what to do with multiple regions, what to do if the geometry is invalid, what to do if an object fails to tessellate, etc.

    One of the goals I've had for the Geometry Engine is to provide an API for returning geometric representations of objects in various forms, as well as the corresponding LIBRT changes that need to be made to support them.  This includes providing a better tessellation API but is generalized for getting any one of a number of representation forms that one might want.  There is the implicit unevaluated CSG form that you get now as well as a NURBS representation, point clouds, polygonal form, and triangulated form, all in either evaluated or unevaluated boolean form.

    All the logic and code to do that already exists in various places within BRL-CAD, it's just not neatly provided via a library API.

    Cheers!
    Sean