[vtkusers] Regarding area calculation of clipped surface

QtITK VTKHelp qt.itk.vtk.help at gmail.com
Wed Oct 19 07:36:20 EDT 2016


Hi friends,


                  I want to calculate the area of the clipped surface.As
shown in image below, I want  to calculate the area of red region / read
only read region. How can we do that ?

[image: Inline image 1]


Code:

vtkSmartPointer<vtkSuperquadricSource> superquadricSource =
		vtkSmartPointer<vtkSuperquadricSource>::New();
	superquadricSource->SetPhiRoundness(3.1);
	superquadricSource->SetThetaRoundness(2.2);

	// Define a clipping plane
	vtkSmartPointer<vtkPlane> clipPlane =
		vtkSmartPointer<vtkPlane>::New();
	clipPlane->SetNormal(1.0, -1.0, -1.0);
	clipPlane->SetOrigin(0.0, 0.0, 0.0);

	// Clip the source with the plane
	vtkSmartPointer<vtkClipPolyData> clipper =
		vtkSmartPointer<vtkClipPolyData>::New();
	clipper->SetInputConnection(superquadricSource->GetOutputPort());
	clipper->SetClipFunction(clipPlane);


	//Create a mapper and actor
	vtkSmartPointer<vtkPolyDataMapper> superquadricMapper =
		vtkSmartPointer<vtkPolyDataMapper>::New();
	superquadricMapper->SetInputConnection(clipper->GetOutputPort());

	


	vtkSmartPointer<vtkActor> superquadricActor =
		vtkSmartPointer<vtkActor>::New();
	superquadricActor->SetMapper(superquadricMapper);

	// Create a property to be used for the back faces. Turn off all
	// shading by specifying 0 weights for specular and diffuse. Max the
	// ambient.
	vtkSmartPointer<vtkProperty> backFaces =
		vtkSmartPointer<vtkProperty>::New();
	backFaces->SetSpecular(0.0);
	backFaces->SetDiffuse(0.0);
	backFaces->SetAmbient(1.0);
	backFaces->SetAmbientColor(1.0000, 0.3882, 0.2784);
	//backFaces->SetAmbientColor(1.0000, 0, 0.0);
	//backFaces->SetOpacity(0.7);

	superquadricActor->SetBackfaceProperty(backFaces);
	

	// Create a renderer
	vtkSmartPointer<vtkRenderer> renderer =
		vtkSmartPointer<vtkRenderer>::New();

	vtkSmartPointer<vtkRenderWindow> renderWindow =
		vtkSmartPointer<vtkRenderWindow>::New();
	renderWindow->SetWindowName("SolidClip");

	renderWindow->AddRenderer(renderer);

	vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
		vtkSmartPointer<vtkRenderWindowInteractor>::New();
	renderWindowInteractor->SetRenderWindow(renderWindow);

	//Add actors to the renderers
	renderer->AddActor(superquadricActor);
	renderWindow->Render();

	//Interact with the window
	renderWindowInteractor->Start();
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20161019/d3b4148f/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 24062 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20161019/d3b4148f/attachment.png>


More information about the vtkusers mailing list