Refactor geometry transforms
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.
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::Geometryclass 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.
- 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.
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).
Replaced all the names where vertice is used instead of vertex to mean singular vertex.
- Add RIGID/DEFORMABLE flag in Mesh class.
Geometryclass will store a shallow transform (translation, scaling, rotation), and a flag to check if transform is applied (up to date)
Meshclass will store a set of vertices pre-shallow-transform, and a set of vertices post-shallow-transform
setVerticeswill update pre-shallow-transform vertices, then apply the shallow transform to update post-shallow-transform vertices, and set the flag to shallowTransformApplied = true;
getVerticeswill 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/getVerticesfor analytical geometries :
- 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)
rotateto 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