[vtkusers] Exception throw with vtkPolygonalSurfaceContourLineInterpolator
Nicolas Sarrasin
nsarrasin at phenix-systems.com
Fri Jan 14 02:49:29 EST 2011
Hi karthik,
Unfortunately, I can't know StartVertex and EndVertex because my vtk
source are compiled in release.
But here I post a light example which reproduce the problem. Every
second selection will throw the exception.
I also add the polydata (selectedges.vtp)
//
#include <vtkSmartPointer.h>
#include <vtkProperty.h>
#include <vtkContourWidget.h>
#include <vtkPolyDataMapper.h>
#include <vtkActor.h>
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkPolygonalSurfacePointPlacer.h>
#include <vtkOrientedGlyphContourRepresentation.h>
#include <vtkXMLPolyDataReader.h>
#include <vtkPolygonalSurfaceContourLineInterpolator.h>
int main(int, char *[])
{
vtkSmartPointer<vtkXMLPolyDataReader> reader =
vtkSmartPointer<vtkXMLPolyDataReader>::New();
reader->SetFileName("./selectedges.vtp");
reader->Update();
vtkSmartPointer<vtkPolyData> polydata =
vtkSmartPointer<vtkPolyData>::New();
polydata = reader->GetOutput();
vtkSmartPointer<vtkPolyDataMapper> mapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInput(polydata);
vtkSmartPointer<vtkActor> actor =
vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper);
actor->GetProperty()->SetInterpolationToFlat();
vtkSmartPointer<vtkRenderer> renderer =
vtkSmartPointer<vtkRenderer>::New();
renderer->AddActor(actor);
vtkSmartPointer<vtkRenderWindow> renderWindow =
vtkSmartPointer<vtkRenderWindow>::New();
renderWindow->AddRenderer(renderer);
vtkSmartPointer<vtkRenderWindowInteractor> interactor =
vtkSmartPointer<vtkRenderWindowInteractor>::New();
interactor->SetRenderWindow(renderWindow);
vtkSmartPointer<vtkContourWidget> contourWidget =
vtkSmartPointer<vtkContourWidget>::New();
contourWidget->SetInteractor(interactor);
vtkOrientedGlyphContourRepresentation* rep =
vtkOrientedGlyphContourRepresentation::SafeDownCast(contourWidget->GetRepresentation());
vtkSmartPointer<vtkPolygonalSurfacePointPlacer> pointPlacer =
vtkSmartPointer<vtkPolygonalSurfacePointPlacer>::New();
pointPlacer->AddProp(actor);
pointPlacer->GetPolys()->AddItem(polydata);
vtkSmartPointer<vtkPolygonalSurfaceContourLineInterpolator>
interpolator =
vtkSmartPointer<vtkPolygonalSurfaceContourLineInterpolator>::New();
interpolator->GetPolys()->AddItem(polydata);
rep->GetLinesProperty()->SetColor(1, 0, 0);
rep->GetLinesProperty()->SetLineWidth(3.0);
rep->SetPointPlacer(pointPlacer);
//setting this will throw an exception
rep->SetLineInterpolator(interpolator);
contourWidget->EnabledOn();
renderer->ResetCamera();
renderWindow->Render();
interactor->Initialize();
interactor->Start();
return EXIT_SUCCESS;
}
//
Thanks again
Le 13/01/2011 19:44, Karthik Krishnan a écrit :
> Can you post the polygonal dataset, along with the StartVertex and
> EndVertex Id's that were passed onto vtkDijkstraGraphGeodesicPath
>
> thx
> --
> karthik
>
> On Thu, Jan 13, 2011 at 11:36 PM, Nicolas Sarrasin
> <nsarrasin at phenix-systems.com <mailto:nsarrasin at phenix-systems.com>>
> wrote:
>
> Hi all,
>
> I'm coding an application to select edges on a vtkPolyData.
>
> For my needs, I first have to build a wireframe vtkPolyData of the
> input (vtkPolyline->GetPointIds(...);
> vtkCellArray->InsertNextCell(vtkPolyLine);
> vtkPolyData->SetPoints(..); vtkPolyData->SetLines(vtkCellArray);...)
>
> This part is ok. Then I use vtkContourWidget with
> vtkPolygonalSurfacePointPlacer and
> vtkPolygonalSurfaceContourLineInterpolator :
>
>
> vtkSmartPointer<vtkContourWidget> contourWidget =
> vtkSmartPointer<vtkContourWidget>::New();
> contourWidget->SetInteractor(interactor);
>
> vtkSmartPointer<vtkOrientedGlyphContourRepresentation> rep =
>
> vtkOrientedGlyphContourRepresentation::SafeDownCast(contourWidget->GetRepresentation());
> rep->GetLinesProperty()->SetColor(1, 0.2, 0);
> rep->GetLinesProperty()->SetLineWidth(3.0);
>
> vtkSmartPointer<vtkPolygonalSurfacePointPlacer> pointPlacer =
> vtkSmartPointer<vtkPolygonalSurfacePointPlacer>::New();
> pointPlacer->AddProp(actor);
> pointPlacer->GetPolys()->AddItem( my_polydata );
>
> vtkSmartPointer<vtkPolygonalSurfaceContourLineInterpolator>
> interpolator =
>
> vtkSmartPointer<vtkPolygonalSurfaceContourLineInterpolator>::New();
> interpolator->GetPolys()->AddItem( my_polydata );
>
> rep->SetPointPlacer(pointPlacer);
> rep->SetLineInterpolator(interpolator);
>
> contourWidget->EnabledOn();
>
> When I pick one point it's ok but after the second picking I get
> an exception : "vector subscript out of range" thrown in the
> function vtkDijkstraGraphGeodesicPath::TraceShortestPath().
>
> It appears only if I the LineInterPolator is
> vtkPolygonalSurfaceContourLineInterpolator. It seems that Dijkstra
> can't find the path allong the lines.
>
> So I'm asking where does this comes from ?
>
> When I compute a vtkpolyDataConnectivityFilter, it says me I have
> only one region, so my data is right connected (i means I have no
> holes on my polylines).
>
> Is there a filter I can pass to my polydata to make it works ??
>
> Thanks by advance for helping me.
>
> Nicolas
>
> _______________________________________________
> Powered by www.kitware.com <http://www.kitware.com>
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110114/89db60b5/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: selectedges.vtp
Type: text/xml
Size: 2449 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110114/89db60b5/attachment.bin>
More information about the vtkusers
mailing list