It looks like one of the end faces is wound the wrong way. That would cause vtkPolyDataNormals to produce “inward” normals instead of “outward” normals.
I suspect that vtkTransformPolyDataFilter is not the problem. Instead, I think you might have discovered a bug in vtkTubeFilter: it winds one end cap correctly, but winds the other end cap inside-out.
If you remove vtkTransformPolyDataFilter, but keep vtkPolyDataNormals, do you get the same result? Try the following pipeline:
If I remove vtkTransformPolyDataFilter, everything looks correct. And If I only remove the Concatenation, it also works. I also tried some combinations of rotation matrix. And some work but some don’t.
Also, I tried to use vtkCylinderSource as well. It works the same as tube. They both have issues.
This is very strange, because rotating the polydata should have absolutely no impact on this setting. This indicates either a bug in vtkTransformPolyDataFilter (which I doubt), or a bug in the AutoOrientNormals code in vtkPolyDataNormals (which seems more likely).
I tried that too.
If it is turned off, the whole object is pointing inwards. If I turn it on, there is this one face pointing inwards.
Is there a good solution for me to make them all pointing outwards? I can simply flip it but not sure if it is always the case
In any case, you can probably fix the issue by using AutoOrientNormalsOff() and by adding the following to your pipeline (it doesn’t matter where, any place after vtkTriangleFilter will work).
// check if the matrix turns the data inside-out
bool flipped = (C->Determinant() < 0.0);
vtkNew<vtkReverseSense> reverse;
reverse->SetInputData(xxx->GetOutput());
reverse->SetReverseNormals(flipped);
reverse->SetReverseCells(flipped);
reverse->Update();
Hi David, just some follow ups. I used an OBB Tree for an object, and then use (max, mid, min) as the new axes for the new coordinates. And I found out that (max, mid, min) do not make a right-handed coordinates. This is the issue causing the negative Determinant