[vtkusers] Displaying entities as wire frame

M.Hardikar at asu.edu M.Hardikar at asu.edu
Sun Apr 21 17:49:42 EDT 2002


Dear users,

I am new to VTK and I am trying to display STL CAD data in wire frame
format. I am using the following code:

The code is repetitive as I am trying to open 3 CAD files in STL format and
then trying to display them in wire frame.
---------------------------------------
	CKneeLoadingDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);

	pDoc->GetProps()->RemoveAllItems();

	vtkSTLReader *pSTL = vtkSTLReader::New();
	vtkSTLReader *pSTL1 = vtkSTLReader::New();
	vtkSTLReader* pSTL2 = vtkSTLReader::New();

	vtkPolyDataMapper *pMapper = vtkPolyDataMapper::New();
	vtkPolyDataMapper *pMapper1 = vtkPolyDataMapper::New();
	vtkPolyDataMapper *pMapper2 = vtkPolyDataMapper::New();

	pSTL->SetFileName(pDoc->get_char_femoral_file_name());
	pSTL1->SetFileName(pDoc->get_char_tibial_file_name());
	pSTL2->SetFileName(pDoc->get_char_poly_file_name());
	
	
	pMapper->SetInput(pSTL->GetOutput());
	pMapper1->SetInput(pSTL1->GetOutput());
	pMapper2->SetInput(pSTL2->GetOutput());

	
	vtkPolyData *pPolyData = vtkPolyData::New();
	vtkPolyData *pPolyData1 = vtkPolyData::New();
	vtkPolyData *pPolyData2 = vtkPolyData::New();

	pPolyData = pMapper->GetInput();
	pPolyData1 = pMapper1->GetInput();
	pPolyData2 = pMapper2->GetInput();

	vtkExtractEdges* pEdges = vtkExtractEdges::New();
	vtkExtractEdges* pEdges1 = vtkExtractEdges::New();
	vtkExtractEdges* pEdges2 = vtkExtractEdges::New();

	pEdges->SetInput( pPolyData );
	pEdges1->SetInput( pPolyData1 );
	pEdges2->SetInput( pPolyData2 );

	vtkTubeFilter* pTubes = vtkTubeFilter::New();
	pTubes->SetInput( pEdges->GetOutput() );
	pTubes->SetRadius( 0.01 );  // or some similarly smallish number
	pTubes->SetNumberOfSides(3);

	vtkTubeFilter* pTubes1 = vtkTubeFilter::New();
	pTubes1->SetInput( pEdges1->GetOutput() );
	pTubes1->SetRadius( 0.01 );  // or some similarly smallish number
	pTubes1->SetNumberOfSides(3);

	vtkTubeFilter* pTubes2 = vtkTubeFilter::New();
	pTubes->SetInput( pEdges2->GetOutput() );
	pTubes2->SetRadius( 0.01 );  // or some similarly smallish number
	pTubes2->SetNumberOfSides(3);

	vtkPolyDataMapper* pEdgeMapper = vtkPolyDataMapper::New();
	pEdgeMapper->SetInput( pTubes->GetOutput() );

	vtkPolyDataMapper* pEdgeMapper1 = vtkPolyDataMapper::New();
	pEdgeMapper1->SetInput( pTubes1->GetOutput() );

	vtkPolyDataMapper* pEdgeMapper2 = vtkPolyDataMapper::New();
	pEdgeMapper2->SetInput( pTubes2->GetOutput() );


	vtkActor* pEdgeActor = vtkActor::New();
	pEdgeActor->SetMapper( pEdgeMapper );
	pEdgeActor->GetProperty()->SetColor( 5,0,0 );
	pEdgeActor->SetMapper(pEdgeMapper);
	pDoc->Props->AddItem(pEdgeActor);

	vtkActor* pEdgeActor1 = vtkActor::New();
	pEdgeActor1->SetMapper( pEdgeMapper1 );
	pEdgeActor1->GetProperty()->SetColor( 0,5,0 );
	pEdgeActor1->SetMapper(pEdgeMapper1);
	pDoc->Props->AddItem(pEdgeActor1);

	vtkActor* pEdgeActor2 = vtkActor::New();
	pEdgeActor2->SetMapper( pEdgeMapper2 );
	pEdgeActor2->GetProperty()->SetColor( 0,0,5 );
	pEdgeActor2->SetMapper(pEdgeMapper2);
	pDoc->Props->AddItem(pEdgeActor2);

	pDoc->UpdateAllViews(NULL);

---------------------------------
Again ,the code is repetitive as I am trying to read in 3 CAD files which are
in STL format and then trying to display them. 
Two of the files are displayed correctly, but for the third one I get the
following error message after I try to call UpdateAllViews():
---------------
ERROR: In C:\martink\vtk40\VTK\Common\vtkSource.cxx, line 414
vtkTubeFilter (0x00E497A0): At least 1 inputs are required but only 0 are
specified
-----------------------

Any help on this issue will be valuable.

Regards,

Mahesh Hardikar
Arizona State Univ.






More information about the vtkusers mailing list