[vtkusers] How to enable capping for Cone ?

Girish Lande girish.lande at agiliad.com
Fri Jun 23 06:24:29 EDT 2017


Hi Experts,

I am trying to draw Cone with its base closed.
For that I am calling CappingOn() function provided for same.
But it doesn't seem to work. I can't think of what can be missing here.

Following is my code.


#include "stdafx.h"

#include <vtkAutoInit.h>
VTK_MODULE_INIT(vtkRenderingOpenGL2)
VTK_MODULE_INIT(vtkRenderingFreeType);

#include <vtkConeSource.h>
#include <vtkPolyData.h>
#include <vtkSmartPointer.h>
#include <vtkPolyDataMapper.h>
#include <vtkActor.h>
#include <vtkRenderWindow.h>
#include <vtkRenderer.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkInteractorStyleTrackballCamera.h>
#include <vtkProperty.h>

int main(int, char *[])
{
//Create a cone
vtkSmartPointer<vtkConeSource> coneSource =
vtkSmartPointer<vtkConeSource>::New();
coneSource->SetResolution(100);
coneSource->SetCapping(true);
coneSource->Update();

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

vtkSmartPointer<vtkActor> actor =
vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper);
actor->GetProperty()->SetOpacity(0.5);

//Create a renderer, render window, and interactor
vtkSmartPointer<vtkRenderer> renderer =
vtkSmartPointer<vtkRenderer>::New();
vtkSmartPointer<vtkRenderWindow> renderWindow =
vtkSmartPointer<vtkRenderWindow>::New();
renderWindow->AddRenderer(renderer);
vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
vtkSmartPointer<vtkRenderWindowInteractor>::New();
renderWindowInteractor->SetRenderWindow(renderWindow);

//Add the actors to the scene
renderer->AddActor(actor);

vtkSmartPointer<vtkInteractorStyleTrackballCamera> style =
vtkSmartPointer<vtkInteractorStyleTrackballCamera>::New();
renderWindowInteractor->SetInteractorStyle(style);


//Render and interact
renderWindow->SetSize(800, 800);
renderWindow->Render();
renderWindowInteractor->Start();

return EXIT_SUCCESS;
}




-- 
thanks & regards,
Girish

-- 
------------------------------------------------------------
-------------------------------------------------------------
*Disclaimer:* This email message including any attachments is confidential, 
and may be privileged and proprietary to Agiliad. If you are not the 
intended recipient, please notify us immediately by replying to this 
message and destroy all copies of this message including any attachments. 
You are NOT authorized to read, print, retain, copy, disseminate, 
distribute, or use this message or any part thereof. Thank you.
------------------------------------------------------------
------------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20170623/702411c9/attachment.html>


More information about the vtkusers mailing list