[vtkusers] Issue with disconnected polylines rendering

fabrice goizet docteur_kouglof at yahoo.fr
Mon Feb 28 06:20:03 EST 2011


Hi,

I have met issue with disconnected polylines drawn in VTK window (we have same behaviour with Qt window).
I have notice the following behavior :
1 - create one renderer with one actor
2 - associate to actor one polydata witch contain 2 disconnected polylines (like lines1=(Id10,Id1,Id2) and lines2=(Id13,Id4,Id5))
3 - Display it into window (with camera look to XY plane)
4 - Translate camera until bottom polyline go outside of window, then upper polyline disappear too !!!

Other remark, behaviour depend of number of Line.
In my case, if number is less than 325 behaviour is OK (no polyline disspear).
if number is greater than 325 behaviour is KO (polyline disspear).

I dont know if it is bug ou bad using of vtkPolydata ?
I work under Window, I have tried with 5.6.1 (but is is same behaviour with 5.4.2).
Thanks for your help

Fabrice

I join my example :

#include "vtkPolyDataMapper.h"
#include "vtkRenderWindow.h"
#include "vtkCamera.h"
#include "vtkActor.h"
#include "vtkRenderer.h"
#include "vtkCellArray.h"
#include "vtkPoints.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkPolyVertex.h"
#include "vtkPolyLine.h"
#include "vtkProperty.h"
#include "vtkInteractorStyleTrackballCamera.h"
int main()
{
    // create renderer, actor and window
    vtkRenderWindow *pRenWin = vtkRenderWindow::New();
    vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
    vtkActor *pGeomActor = vtkActor::New();
    vtkRenderer *pRen1= vtkRenderer::New();
    pRen1->SetBackground( 0.0, 0.0, 0.0 );
    // Create points and polydata
    vtkPoints* pPoint = vtkPoints::New();
    vtkPolyData* pPolyData = vtkPolyData::New();
    vtkPolyDataMapper* pMapper = vtkPolyDataMapper::New();
    // create geometry
    int NbPtC1 = 325; // change this variable to see issue.
    int NbWire = 2;
    //
    pPoint->SetNumberOfPoints(NbWire*NbPtC1);
    for (int k=0 ; k < NbWire ; k++)
        for (int i = 0 ; i < NbPtC1 ; i++)
            pPoint->InsertPoint(i+(NbPtC1*k), 0.5*i, 1.5*k, 0.0);
    //
    pPolyData->SetPoints(pPoint);
    pPoint->Delete();
    // create first topology ==> all vertices
    vtkPolyVertex* pPolyVertex = vtkPolyVertex::New();
    pPolyVertex->GetPointIds()->SetNumberOfIds(NbWire*NbPtC1);
    for (int i = 0 ; i < NbWire*NbPtC1 ; i++)
        pPolyVertex->GetPointIds()->SetId(i, i);
    // Set the polydata with the vertices topology
    vtkCellArray* pCellArrayVertex = vtkCellArray::New();
    pCellArrayVertex->InsertNextCell(pPolyVertex);
    pPolyVertex->Delete();
    pPolyData->SetVerts(pCellArrayVertex);
    pCellArrayVertex->Delete();
    // create second topology ==> 2 disconnected polylines
    vtkPolyLine* pLine1 = vtkPolyLine::New();
    vtkPolyLine* pLine2 = vtkPolyLine::New();
    //
    pLine1->GetPointIds()->SetNumberOfIds(NbPtC1);
    for (int i = 0 ; i < NbPtC1 ; i++)
        pLine1->GetPointIds()->SetId(i, i);
    //
    pLine2->GetPointIds()->SetNumberOfIds(NbPtC1);
    for (int i = 0 ; i < NbPtC1 ; i++)
        pLine2->GetPointIds()->SetId(i, i+NbPtC1);
    //
    vtkCellArray* pCellArrayLine1 = vtkCellArray::New();
    pCellArrayLine1->InsertNextCell(pLine1);
    pLine1->Delete();
    pCellArrayLine1->InsertNextCell(pLine2);
    pLine2->Delete();
    // Set the polydata
    pPolyData->SetLines(pCellArrayLine1);
    pCellArrayLine1->Delete();
    //
    pMapper->SetInput(pPolyData);
    pPolyData->Delete();
    //
    pGeomActor->SetMapper(pMapper);
    pMapper->Delete();
    pGeomActor->GetProperty()->SetPointSize(5.0);
    pGeomActor->GetProperty()->SetColor(0, 1, 0);
    pGeomActor->GetProperty()->SetLineWidth(3.0);
    pRen1->AddActor( pGeomActor );
    //
    pRenWin->AddRenderer( pRen1 );
    pRenWin->SetSize( 400, 300 );
    vtkInteractorStyleTrackballCamera *style = vtkInteractorStyleTrackballCamera::New();
    iren->SetInteractorStyle(style);
    //
    iren->SetRenderWindow(pRenWin);
    pRenWin->Delete();
    //
    //Create the usual rendering stuff.
    vtkCamera* pCam = pRen1->GetActiveCamera();
    pCam->SetPosition(0.0,0.0,1.0);
    pCam->SetFocalPoint (0.0,0.0,0.0);
    pCam->ComputeViewPlaneNormal();
    pCam->SetViewUp(0.0,1.0,0.0);
    pCam->OrthogonalizeViewUp();
    pCam->SetParallelProjection(1);
    pRen1->ResetCamera();
    //
    iren->Initialize();
    iren->Start();
    //
    pGeomActor->Delete();
    pRen1->Delete();
    iren->Delete();
    //
    return 0;
}


      



More information about the vtkusers mailing list