Flipped normals during linear transform of model

transforms
3d-model

(Dominic White) #1

I’m importing a 3d model created in another program and trying to align it with the same model created in Slicer, and I’m running into a problem with the normals of the model.

Here’s the model after import:

And here’s the same model after a reflection using the Transforms module:

This appears to be a problem with the normals - I can reverse it with Surface Toolbox’s flipped normals.

However, is there a way to do a reflection which doesn’t flip the normals?

Here are my Linear Transform settings to reproduce this effect:


(Andras Lasso) #2

If you turn the model inside out (apply a linear transform with a matrix that has negative determinant) then the surface normals will be reversed, too. Using Surface Toolbox module is a good solution. Is there any specific reason you would only want to turn the surface inside out but not flip the normals?


(Dominic White) #3

Andras

My linear algebra is pretty rusty, so I may be missing something here, but I’m not trying to turn the model inside out.

What I want to do is flip the model around one of the axes (i.e. map every x coordinate to -x, while keeping y & z coordinates the same).

I was following the instructions in the Wiki FAQ for this question: https://www.slicer.org/wiki/Documentation/4.10/FAQ#How_do_I_fix_incorrect_axis_directions.3F_Can_I_flip_an_image_.28left.2Fright.2C_anterior.2Fposterior_etc.29_.3F

It just seems counter-intuitive to me that reflecting the model through a plane would also flip the normals (but see above re: math & rusty). Hence my original question, is there a Transform matrix to do a reflection without also flipping the normals?


(Andras Lasso) #4

There is not. Inverting direction of axis turns the model inside out (the inside surface of the non-transformed model becomes outside surface in the transformed model).


(Steffen O) #5

You could do the flipping in Meshlab (it’s also free) before you import it into Slicer.
There you can flip the axis (Filters->Normals Curvature Orientation ->Transform, flip swap axis) and invert the faces orientation (Filters->Normals Curvature Orientation -> Invert faces orientation).


(Dominic White) #6

Thanks, @steffen-o . I’m trying to build a script to import files from another program into Slicer, so I’d prefer to do it all “in-house”.

In case anyone has the same problem in future, I was eventually able to flip surface models without inverting normals using the “Surface Toolbox” module’s Mirror operation.


(Andras Lasso) #7

Surface toolbox is a Python scripted module, which exposes a few VTK filters on the GUI. Of course you can use those VTK filters directly in your script.