Glyph3D problems with orientation

Hello I am new to VTK and have the problem that my glyphs are not oriented and i don’t understand why
This is the orientation i get:
vtkGlyph
and this should be their orientation:

This is my Code:
void performGlyph(const vtkSmartPointer& glyph,
const vtkSmartPointer& glyphMask,
const vtkSmartPointer& glyphArrow,
const vtkSmartPointer& glyphMapper,
const vtkSmartPointer& glyphActor,
const vtkSmartPointer& renderer,
const vtkSmartPointer& renWin) {
if (!glyphInit) {

	glyphMask->SetInputData(getLastUsedObject());
			
	glyphMask->SetOnRatio(100);
	glyphMask->RandomModeOn();
	
	glyph->SetInputConnection(glyphMask->GetOutputPort());
	glyph->SetSourceConnection(glyphArrow->GetOutputPort());
	
	glyph->ScalingOn();
	glyph->SetVectorModeToUseVector();
	glyph->SetScaleModeToScaleByVector();
	glyph->SetScaleFactor(0.2);
	glyph->OrientOn();
	
	// Mapper, Actor und Renderer befüllen
	glyphMapper->SetInputConnection(glyph->GetOutputPort());
    glyphActor->SetMapper(glyphMapper);
    renderer->AddActor(glyphActor);
	
	
    // Token setzen das Glyph Funktion initialisiert wurde
    glyphInit = true;

    // blende den vorherigen Actor aus und blende den Iso Actor ein
    setActorVisibility(renderer, renWin);
    glyphActor->SetVisibility(1);

    // Speichern welche Filter zuletzt benutzt wurde
    filterList.push_back("glyphFilter");
	
}
if (bGlyphGenerateValues) {
	printf("Glyph generate \n");
	// Daten für spätere Benutzung außerhalb der Methode speichern
    glyphObject = glyph->GetOutputDataObject(0);
    // rendern
    glyph->Update();
    renWin->Render();
renderer->ResetCamera();
}

}

I have no Idea what i am missing here and would be very grateful for help.

Did you check that your orientations are set as the active vectors in your data? ie: glyphMask->GetOutput()->GetPointData()->SetVectors(…)

Thanks a lot for your answer! I think that I don’t really understand your suggestion. Do you mean that when the data is loaded?

This would happen here:

/ Lade Dateien mit dem VTK Format
void loadFileVtk(const vtkSmartPointer& genericReader,
const vtkSmartPointer& geometryFilter,
const vtkSmartPointer& mapper,
const vtkSmartPointer& actor,
const vtkSmartPointer& renderer,
const vtkSmartPointer& renWin) {

// renderwindow größe festlegen
renWin->SetSize(renderWindowSizeX, renderWindowSizeY);
//Zeitmessung für Zeitserien, wird später beim Senden benötigt
timestampStart = time(0);
// Dateinamen übergeben an den Reader
genericReader->SetFileName(sFilename.c_str());
genericReader->Update();

// geometry Filter um aus den VTK Daten PolyData zu machen
geometryFilter->SetInputConnection(genericReader->GetOutputPort());
geometryFilter->Update();

// Daten für spätere Benutzung außerhalb der Methode speichern
setLastUsedObject(geometryFilter->GetOutputDataObject(0), "fileReader");

// Mapper, Actor und Renderer befüllen
mapper->SetInputConnection(geometryFilter->GetOutputPort());
actor->SetMapper(mapper);
renderer->AddActor(actor);
renWin->Render();

// Da Azimuth und Elevation verwendet wird um die Kamera zu drehen muss sichergestellt werden das
// der ViewUp Vektor senkrecht zum focalpoint der Kamera ist
renderer->GetActiveCamera()->OrthogonalizeViewUp();

// Zeitmessung für Zeitserien
timestampEnd = time(0);
timeDifferenze = timestampEnd - timestampStart;

// Speichern welche Filter/Reader zuletzt benutzt wurde
filterList.push_back("fileReader");

}

Do I have to set the vector data active there? Or can I do it in my function performGlyph? Hopefully the Geometry Filter has the Vector Information.

In the examples provided in VTK it is working with polydata which I also have with the help of the vtkGeometryFilter. I use the glyphMask to subsample the Data and then I try to scale and orient my glyphs provided with the functions of the Glyph3D Class. I tried different filters and also changed my code without any results, they are never orientated the right way. I could really need some help, thanks in advance!

In a vtkPolyData’s PointData (vtkPolyData::GetPointData), there are a set of vertex attributes. Arrays per vertex. These may be referred to by string names, but may not have a name.

You may set/denote only one as the active vectors for the points. This carries contextual information on how it is used. Similarly you can set active scalars, normals, tex coords, etc.

A particular algorithm in VTK may then ask for the set of active vectors.

Where this can create common issues is if you read in a file with a 3 component vertex attribute array, or later added it but they were not the set of active vectors. The algorithm will then fail to see which array it should be using. The vtkGlyph3D, vtkGylph3DMapper, and vtkOpenGLGlyph3DMapper all have some slight minuet differences and should probably see consolidation. Often the algorithm will have a setter that can be used to denote which attribute array to use. For example, vtkGlyph3D only orients by whatever is set as active vectors. vtkGlyph3DMapper allows users to SetOrientationArray. The differences are well documented though. See:

https://vtk.org/doc/nightly/html/classvtkGlyph3D.html#details

https://vtk.org/doc/nightly/html/classvtkGlyph3DMapper.html#details

https://vtk.org/doc/nightly/html/classvtkOpenGLGlyph3DMapper.html#details

Lastly, a vtkPolyData under the .vtk format may denote that an array is the active vectors so when they are read in you don’t need to do anything. Passing data through a geometry filter should preserve the attributes but not every vtk filter is so kind.

Also it’s worth mentioning the glyph mappers can render many more glyphs faster as they use GPU, hardware instancing. Instead of copying a massive buffer of geometry to the GPU, there is only one arrow. The downside is you can’t directly get vtkPolyData output from it.

Thank you for your answer!
So I understood what part i am missing. I only have one Vector field Array in the loaded dataset, is it not weird that this array is not the default array?
What I did now is save the Point Data in a float array which I named and set as the active Vectors:
{
vector_3->SetName(“Vectors”);
vector_3->SetNumberOfComponents(3);
vector_3->SetNumberOfTuples(glyphMask->GetOutput()->GetNumberOfPoints());
//printf("%d\n",vector_3->GetNumberOfTuples());
double *values;
for(int i = 0; i < vector_3->GetNumberOfTuples(); i++)
{
values = glyphMask->GetOutput()->GetPoint(i);
vector_3->SetTuple3( i, values[0], values[1], values[2]);
//printf("%f, %f, %f, ", values[0], values[1], values[2]);

	}
	glyphMask->GetOutput()->GetPointData()->AddArray(vector_3);
	glyphMask->GetOutput()->GetPointData()->SetActiveVectors("Vectors");

}
This led to the following presentation:
glyphColorOrient
There seems to be something wrong with the Orientation at the top as they are reversed (but at least most of them are orinented). Is there some easier way to set the Vectors as active?
Something like the following, which gave me no error message, but sadly did not work:

//glyphMask->GetOutput()->GetPointData()->GetVectors()->SetName(“glyphVectors”);
//glyphMask->GetOutput()->GetPointData()->SetActiveVectors(“glyphVectors”);