[vtkusers] Delaunay3d help

Amy Squillacote amy.squillacote at kitware.com
Tue Aug 30 08:32:10 EDT 2005


What line does it crash on?  Please post a stack trace.

- Amy

At 10:27 PM 8/29/2005, Lichun Andrew Li wrote:

>in VC++, the following code crashes:
>(unhandled exception (vtkRendering.dll), access violation).
>I was just trying to triangulate points on a hemisphere.
>
>#include "vtkMath.h"
>#include "vtkRenderer.h"
>#include "vtkRenderWindow.h"
>#include "vtkRenderWindowInteractor.h"
>#include "vtkPolyData.h"
>#include "vtkPoints.h"
>#include "vtkCellArray.h"
>#include "vtkIntArray.h"
>#include "vtkDoubleArray.h"
>#include "vtkPolyDataMapper.h"
>#include "vtkActor.h"
>#include "vtkCamera.h"
>#include "vtkPointData.h"
>#include "vtkDelaunay3D.h"
>#include "vtkUnstructuredGridToPolyDataFilter.h"
>#include "vtkUnstructuredGrid.h"
>
>
>
>
>void main( int argc, char *argv[] )
>{
>   int i = 0;
>   int delta_deg = 60;  //angle increment
>   int azimuth=0;
>   int elevation = 0;
>   float azimuth_rad, elevation_rad;
>   float R = 100;
>
>   static float coor[3];
>
>   vtkPolyData *hemisphere = vtkPolyData::New();
>   vtkPoints *points = vtkPoints::New();
>
>   for (elevation = 90; elevation >= 0; elevation = elevation - delta_deg)
>           for ( azimuth = 0; azimuth < 360; azimuth = azimuth + delta_deg)
>           {
>                   azimuth_rad = azimuth*vtkMath::DegreesToRadians();
>                   elevation_rad = elevation*vtkMath::DegreesToRadians();
>                   coor[0] = R*cos(elevation_rad)*cos(azimuth_rad);
>                   coor[1] = R*cos(elevation_rad)*sin(azimuth_rad);
>                   coor[2] = R*sin(elevation_rad);
>                   i++;
>                   points->InsertPoint(i, coor);
>           }
>
>   hemisphere->SetPoints(points);
>   points->Delete();
>
>   vtkDelaunay3D * mesh = vtkDelaunay3D::New();
>   mesh->SetInput(hemisphere);
>   mesh->SetTolerance (0.01);
>   mesh->SetAlpha(0.2);
>
>   vtkPolyDataMapper *hemisphereMapper = vtkPolyDataMapper::New();
>       hemisphereMapper->SetInput((vtkPolyData*) mesh->GetOutput());
>
>   vtkActor *hemisphereActor = vtkActor::New();
>         hemisphereActor->SetMapper(hemisphereMapper);
>
>   vtkRenderer *renderer = vtkRenderer::New();
>   renderer->AddActor(hemisphereActor);
>
>
>   vtkRenderWindow *renWin = vtkRenderWindow::New();
>     renWin->AddRenderer(renderer);
>         renWin->SetSize(300,300);
>     renWin->Render();
>
>   vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
>     iren->SetRenderWindow(renWin);
>
>   iren->Start();
>
>   renderer->Delete();
>   renWin->Delete();
>   iren->Delete();
>   hemisphere->Delete();
>   points->Delete();
>   hemisphereMapper->Delete();
>   hemisphereActor->Delete();
>
>}
>
>_______________________________________________
>This is the private VTK discussion list. Please keep messages 
>on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>Follow this link to subscribe/unsubscribe:
>http://www.vtk.org/mailman/listinfo/vtkusers




More information about the vtkusers mailing list