Add Volumetric mesh support
Created by: agirault
See: https://www.na-mic.org/Wiki/index.php/2017_Winter_Project_Week/Support_for_volumetric_meshes
With the help of @lassoan @jcfr @cpinter @curtislisle @vovythevov @pieper (Thank you!)
Features & Results
ENH : Add volumetric mesh support in vtkMRMLModelNod
Update vtkMRMLModelNode to store a vtkPointSet instead of a vtkPolyData. vtkPointSet can be a base class for vtkPolyData (surface mesh) as well as vtkUnstructuredGrid (volumetric mesh).
The safest way to know if the mesh is unstructuredGrid is to
check if vtkMRMLModelNode::GetUnstructuredGrid()
is not NULL,
but since it requires to update the pipeline, vtkMRMLModelNode
also has a member variable called MeshTypeHint
.
For backward compatibility, keep the public polydata-based API and wrap around the mesh-based API.
Update vtkMRMLModelDisplayNode, vtkMRMLModelDisplayableManager, vtkMRMLModelSliceDisplayableManager, and qMRMLModelDisplayNodeWidget to use the mesh-based API.
ENH: Add support for vtkUnstructuredGrid IO
Update vtkMRMLModelStorageNode and qSlicerModelsReader to be able to read and write unstructured grid based models using the vtkUnstructuredGrid readers and writers (.vtk and .vtu).
Implement GetAssociatedDataNode()
similar to the one in
vtkMRMLSegmentationStorageNode to offer the correct supported
write file types.
BUG: Read all data for model of .vtk extension
STYLE: Use actorProperties in Model displayable manager
ENH: Implement vtkMRMLProceduralColorNode::GetLookupTable
Migrate conversion of ColorTransferFunction to LookupTable from ModelDisplayableManager to ProceduralColorNode, to simplify code in the displayable manager, and to be able to reuse that conversion code for ModelSliceDisplayableManager.
ENH: Consolidate AutoScalarRange & ScalarRangeFlag
AutoScalarRange - in vtkMRMLDisplayNode - would define if the ModelDisplayNode would reset its ScalarRange to map the range of the mesh active scalar or not (manually set by the user).
ScalarRangeFlag - in vtkMRMLDisplayNode - would define if the ModelDisplayableManager would map scalar range based on the active scalar if UseDataScalarRange (same that AutoScalarOn), would use the DataType range if UseDataTypeScalarRange, would use the color node lookup table range if UseColorNodeScalarRange, or would use the display node scalar range (aka its OWN range defined by AutoScalarRange value) if UseDisplayNodeScalarRange.
To consolidate those two class members which show redundancies, they are replaced by a unique ScalarRangeFlag which can take the following values:
- UseManualScalarRange (new, equivalent to AutoScalarRangeOff)
- UseDataScalarRange (as previously, equivalent to AutoScalarRangeOn)
- UseColorNodeScalarRange (as previously)
- UseDataTypeScalarRange (as previously)
Note the removal of
UseDisplayNodeScalarRange
.
For backward compatibility, the AutoScalarRange API is conserved and wraps Set/GetScalarRangeFlag.
The range update based on this ScalarRangeFlag is then made in
vtkMRMLModelDisplayNode::UpdateMeshPipeline instead of
vtkMRMLModelDisplayableManager::SetModelDisplayProperty, which
simplifies greatly the code in the displayable manager by only
calling mapper->SetScalarRange(modelDisplayNode->GetScalarRange())
,
and allows that call in vtkMRMLModelSliceDisplayableManager to
now return the correct range based on that option.
vtkMRMLModelSliceDisplayableManager is also updated to instantiate the vtkMapper in a similar way than it is made in the 3D displayable manager for visualization consistency (deep copy of the lut, etc...)
ENH: Add Thresholding for vtkMRMLModelDisplayNode
ENH: Add model mesh type in qMRMLModelInfoWidget
Needed tests
- Work made on vtkMRMLDisplayNode and vtkMRMLModelDisplayNode could impact a lot of classes. Should probably test with fiber bundles (@ihnorton ?).
Future work
- Clean up and consolidate qSlicerModelsModuleWidget (display properties, representations, wireframe, clipping... just move options around to make it more usable)
- Add clipping option to smoothen the cut (using vtkClipDataSet vs vtkExtractGeometry). Not urgent since the Slicer view can display a smooth cut.
- Update extensions like CleaverExtension or BodyCentricCubicMesh module, import edition/creation work from IA_FEMesh.