Skip to content

Refactor geometry transforms

Previous

Geometry transforms (scale, translate, rotate) were stored separately and a compound transform is computed at the beginning of each render frame and handed over to VTKs render pipeline. VTK internally takes the geometry and applies the transform before rendering. The actual geometry information remain unchanged. There was no support for deep/real transforms.

Changes

Geometry transforms

  • Deep Transforms: Any affine transform applied with a deep transform flag will overwrite the geometric information. For geometries of mesh type, the nodal co-ordinates are overwritten with the transformed data. For analytical objects, certain properties (e.g.: width) could be overwritten. This transform is not persistent across frames and is reset to Identity once applied at the end of the frame. At a given frame only a record of the compound transform is kept.

  • Shallow Transforms: Any affine transform applied with a shallow transform flag will record the transform in the imstk::Geometry class and compute the compound transform at the beginning of the render frame. Individual offsets (translation, rotation, scale) can be accessed. These stored transforms are persistent across render frames and can be overwritten at any time. The compound transform computed is used to offset the geometry during rendering just like before by the VTK’s pipeline.

Optimizations

  • The compound shallow transform is not computed unless changed between frames.
  • A data modification flag is added for the geometry class to do the same for deformation. The Modified() method for m_mappedVertexArray in mesh related render delegates is called only if this flag is true.

Usage

geometryObj->scale(5); // Apply deep scale for geometry object
geometryObj->translate(5., 2., 0., GeometryTransformType::Shallow); // Apply shallow translation for geometry object

Accessing geometric data

The default behavior of the get/set methods (e.g.: sphereGeom->getRadius()) will return only pre-shallow transforms. For the case of mesh types api is provided to compute and access post-shallow transforms. If the offset geometry data is required for analytical objects they will have to be computed on-demand by the caller (see changes in CD classes).

Misc. changes

Replaced all the names where vertice is used instead of vertex to mean singular vertex.

Prev. discussion

TODO:

  • Add RIGID/DEFORMABLE flag in Mesh class.
  • Geometry class will store a shallow transform (translation, scaling, rotation), and a flag to check if transform is applied (up to date)
  • Mesh class will store a set of vertices pre-shallow-transform, and a set of vertices post-shallow-transform
  • setVertices will update pre-shallow-transform vertices, then apply the shallow transform to update post-shallow-transform vertices, and set the flag to shallowTransformApplied = true;
  • getVertices will always return post-shallow-transform vertices. If shallow transform flag shows it is not up to date, apply transform on pre-shallow-transform vertices before returning the post-shallow-transform ones.
  • Do similar behavior that set/getVertices for analytical geometries : normal, width, position for plane; position, radius for sphere; orientation, width, position for cube...
  • In collision detection, physics etc... use post-shallow-transform data
  • For rendering in vtk, use pre-shallow-transform data for the source, and the shallow transform for actor transform (PS: need to apply that rigid transform on GPU)
  • Replace scale, translate, rotate to have that signature:
translate(Vec3d t, TransformType type = TransformType::DEEP)
  • DEEP: apply change on pre-shallow-transform data (vertices, position, normals, rotation,width, radius) -> default behavior
  • SHALLOW: apply change on the shallow transform data (translation, scaling, rotation) and set the flag to show transform is not applied and need update

Merge request reports