[vtkusers] How to transfer

xx_zx xuanaux at gmail.com
Tue Nov 18 14:27:23 EST 2008


I am sorry I don't know how to perform rigid transformation.
I have used vtkReverseSense. Is this make sure that normals are all outward
oriented?
I think it is the not perfectly constructed surface leads to the wrong
volume. Because when I render structures they looks strange.
Here is my code:
	vtkSurfaceReconstructionFilter *surf =
vtkSurfaceReconstructionFilter::New();
	surf->SetInput(grid);

	vtkContourFilter *contours = vtkContourFilter::New();
	contours->SetInputConnection(surf->GetOutputPort());
	contours->SetValue(0,0.0);

	//	# Extract boundary edges
	vtkFeatureEdges *boundary = vtkFeatureEdges::New();
	boundary->BoundaryEdgesOn();
	boundary->FeatureEdgesOff();
	boundary->ManifoldEdgesOff();
	boundary->NonManifoldEdgesOff();
	boundary->SetInputConnection(contours->GetOutputPort());
	//	# Build a polyline from boundary edges
	vtkStripper *stripper = vtkStripper::New();
	stripper->SetInputConnection(boundary->GetOutputPort());
	stripper->Update();
	vtkPolyData *holePoly = vtkPolyData::New();
	holePoly->SetPoints(stripper->GetOutput()->GetPoints());
	holePoly->SetPolys(stripper->GetOutput()->GetLines());
	//	# Triangulate hole
	vtkTriangleFilter *filler = vtkTriangleFilter::New();
	filler->SetInput(holePoly);

	//	# Combine into a single polydata
	vtkAppendPolyData *apd = vtkAppendPolyData::New();
	apd->AddInputConnection(contours->GetOutputPort());
	apd->AddInputConnection(filler->GetOutputPort());

	//	# Merge duplicate points
	vtkCleanPolyData *cleaner = vtkCleanPolyData::New();
	cleaner->AddInputConnection(apd->GetOutputPort());

	//	# Add normals
	vtkPolyDataNormals *apdNormals = vtkPolyDataNormals::New();
	apdNormals->SetInputConnection(cleaner->GetOutputPort());

	vtkReverseSense *reverse = vtkReverseSense::New();
	reverse->SetInputConnection(apdNormals->GetOutputPort());
	reverse->ReverseCellsOn();
	reverse->ReverseNormalsOn();


	vtkTriangleFilter *triangle = vtkTriangleFilter::New();
	triangle->SetInputConnection(reverse->GetOutputPort());
	
	vtkMassProperties *massProperty = vtkMassProperties::New();
	massProperty->SetInputConnection(triangle->GetOutputPort());
	cout<<"Volume:"<<massProperty->GetVolume()<<endl;



Denis Barbier-5 wrote:
> 
> On 2008/11/18 xx_zx wrote:
>>
>> Thank you very much for your time!
>> Structures are indeed closed after I applied the method you shown me in
>> the
>> example. However, the calculated volumes seem not right. They are
>> extremely
>> larger than the volume calculated before. I think it is because the
>> discrete
>> points are not perfect and have some noise points which degenerate the
>> performance of the vtkSurfaceReconstructionFilter.
> [...]
> 
> Did you perform rigid transformations to check that the new result
> does not change?
> And are you sure that normals are all outward oriented?
> 
> Denis
> _______________________________________________
> 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
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-transfer-vtkUnstructuredGrid-to-vtkPolydata-tp20521283p20566479.html
Sent from the VTK - Users mailing list archive at Nabble.com.




More information about the vtkusers mailing list