View Issue Details

IDProjectCategoryView StatusLast Update
0004157Slicer4Module Modelspublic2016-10-13 02:00
Reporterfepegar Assigned Topieper  
PriorityhighSeveritymajorReproducibilityalways
Status closedResolutionfixed 
PlatformLinuxOSUbuntuOS Version14.04
Product VersionSlicer 4.5.0-1 
Target VersionFixed in VersionSlicer 4.6.0 
Summary0004157: Models turn black when applying a transform
Description

Models darken when applying some transforms.

I've observed that it happens when one or three scale parameters in the matrix are negative, for example:
-1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1

Steps To Reproduce

I've written some code to reproduce this:

Create a yellow sphere and add it to the scene

scene = slicer.mrmlScene
sphere = vtk.vtkSphereSource()
sphere.SetRadius(10)
sphere.Update()
polyData = sphere.GetOutput()
modelDisplay = slicer.vtkMRMLModelDisplayNode()
modelDisplay.SetColor((1,1,0))
modelDisplay.SetScene(scene)
scene.AddNode(modelDisplay)
model = slicer.vtkMRMLModelNode()
model.SetScene(scene)
model.SetAndObservePolyData(polyData)
scene.AddNode(model)
modelDisplay.SetInputPolyDataConnection(model.GetPolyDataConnection())
model.SetAndObserveDisplayNodeID(modelDisplay.GetID())

Create the transform and apply it to the model

t = slicer.vtkMRMLTransformNode()
slicer.mrmlScene.AddNode(t)
m = vtk.vtkMatrix4x4()
m.SetElement(0, 0, -1)
t.SetMatrixTransformFromParent(m)
model.SetAndObserveTransformNodeID(t.GetID())

Tagsmodels

Activities

fepegar

fepegar

2016-02-24 07:58

reporter  

Screenshot.png (50,944 bytes)
Screenshot.png (50,944 bytes)
pieper

pieper

2016-03-18 16:58

administrator   ~0013842

Yes, that's what happens when you turn the model inside out.

You can harden the transform in the context menu of the Data module and you can flip the normals in Surface Toolbox module.

https://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Modules/SurfaceToolbox

fepegar

fepegar

2016-03-23 12:49

reporter   ~0013843

Shouldn't it be enough to just apply my transformation to the model?

Anyway, if I do harden the transform and then I flip the normals with the Surface Toolbox, I can see the interior of the model (backface culling enabled).

So this didn't help me. Do you have any other ideas?

pieper

pieper

2016-03-23 13:17

administrator   ~0013844

Did you try just selecting the Normals option of the SurfaceToolbox without the Flip option? That should recalculate them for you.

fepegar

fepegar

2016-03-23 13:22

reporter   ~0013845

Last edited: 2016-03-23 13:23

View 2 revisions

That did solve the visualization trouble.

However I still don't understand why just applying the transform should not be enough. I'm not sure that hardening a transform and recalculating the model's normals is the best solution here.

pieper

pieper

2016-03-23 13:34

administrator   ~0013846

It's a pretty common thing in computer graphics - when you turn the object inside out the normals need to be recalculated.

fepegar

fepegar

2016-03-23 13:45

reporter   ~0013847

Ok thanks Steve.

Issue History

Date Modified Username Field Change
2016-02-24 07:58 fepegar New Issue
2016-02-24 07:58 fepegar File Added: Screenshot.png
2016-03-04 10:42 fepegar Tag Attached: models
2016-03-04 10:42 fepegar Priority normal => high
2016-03-04 10:42 fepegar Severity minor => major
2016-03-18 16:58 pieper Note Added: 0013842
2016-03-18 16:58 pieper Assigned To => pieper
2016-03-18 16:58 pieper Status new => feedback
2016-03-23 12:49 fepegar Note Added: 0013843
2016-03-23 12:49 fepegar Status feedback => assigned
2016-03-23 13:17 pieper Note Added: 0013844
2016-03-23 13:22 fepegar Note Added: 0013845
2016-03-23 13:23 fepegar Note Edited: 0013845 View Revisions
2016-03-23 13:34 pieper Note Added: 0013846
2016-03-23 13:34 pieper Status assigned => closed
2016-03-23 13:34 pieper Resolution open => fixed
2016-03-23 13:34 pieper Fixed in Version => Slicer 4.5.1
2016-03-23 13:45 fepegar Note Added: 0013847
2016-10-13 02:00 jcfr Fixed in Version Slicer 4.5.1 => Slicer 4.6.0