[vtkusers] How to color cylinder with different colors
Divya
divya at triassicsolutions.com
Tue May 7 01:03:02 EDT 2013
Dear All,
I want to color a cylinder like the image attached. I have tried
combining 2 different cylinder source with different colors but I am
getting the following result
Any help will be greatly appreciated.
My source code is as follows:
vtkCylinderSource catheter = vtkCylinderSource.New();
catheter.SetRadius(1);
catheter.SetHeight(15.0);
catheter.Update();
//catheter.CappingOn();
vtkFloatArray cylColor1 = vtkFloatArray.New();
cylColor1.SetNumberOfComponents(3);
cylColor1.SetName("Color1");
for (int i = 0; i <
catheter.GetOutput().GetNumberOfPoints(); i++)
{
cylColor1.InsertTuple3(i, 255, 0, 0);
}
catheter.GetOutput().GetPointData().SetScalars(cylColor1);
vtkCylinderSource catheter2 = vtkCylinderSource.New();
catheter2.SetRadius(1);
catheter2.SetHeight(10.0);
catheter2.Update();
//catheter2.CappingOn();
vtkFloatArray cylColor = vtkFloatArray.New();
cylColor.SetNumberOfComponents(3);
cylColor.SetName("Color2");
for (int i = 0; i <
catheter2.GetOutput().GetNumberOfPoints(); i++)
{
cylColor.InsertTuple3(i, 0, 0, 255);
}
catheter2.GetOutput().GetPointData().SetScalars(cylColor);
// append both polydata sets
vtkAppendPolyData apd = new vtkAppendPolyData();
apd.AddInput(catheter.GetOutput());
apd.AddInput(catheter2.GetOutput());
apd.Update();
////vtkCleanPolyData cleanFilter = vtkCleanPolyData.New();
////cleanFilter.SetInput(apd.GetOutput());
////cleanFilter.Update();
vtkPolyDataMapper catheterMapper = vtkPolyDataMapper.New();
catheterMapper.SetInputConnection(apd.GetOutputPort());
catheterActor.SetMapper(catheterMapper);
--
Regards,
*DIVYA SADANANDAN
Software Engineer*
Triassic Solutions Pvt. Ltd.
(+91) 471 2700050 (Office)
7736382699 (Mobile)
<http://www.triassicsolutions.com>
Disclaimer: This e-mail contains confidential information intended
solely for the intended recipient. If you are not the intended
recipient, please notify the sender by e-mail and delete this email
permanently from your records. Do not copy or distribute this e-mail and
any such actions are unlawful. Except where this email is sent in the
usual course of business, the views expressed in this email are those of
the sender. Triassic Solutions Pvt. Ltd. accepts no responsibility for
any indirect damage or loss suffered by reason of inaccuracy or
incorrectness of the information in this email.
+ Please consider our environment before printing this e-mail.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130507/7943868e/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ebgfhjjf.png
Type: image/png
Size: 14361 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130507/7943868e/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: aecfiefh.
Type: image/jpg
Size: 6447 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130507/7943868e/attachment.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: DesiredResult.png
Type: image/png
Size: 2147 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130507/7943868e/attachment-0001.png>
More information about the vtkusers
mailing list