[vtkusers] Color a vtkcell
awabi
aw.ndaw at gmail.com
Wed Jan 13 08:59:23 EST 2010
Thank you François.
With the code given before, the faces of my cube are colored with the same
color. Iµ wants to color faces with differents colors.
Thank you,
Awa.
Francois Bertel wrote:
>
> Just include vtkCellData.h:
>
> http://www.vtk.org/Wiki/VTK_FAQ#The_C.2B.2B_compiler_cannot_convert_some_pointer_type_to_another_pointer_type_in_my_little_program
>
> On Tue, Jan 12, 2010 at 7:21 PM, awabi <aw.ndaw at gmail.com> wrote:
>>
>> I try to use your solution but,
>> 4) PolyData->GetCellData()->SetScalars(colors) is not accepted I have
>> this
>> error:
>>
>> error: invalid use of incomplete type ‘struct vtkCellData’
>> /usr/sbin/../include/vtk-5.0/vtkDataSet.h:43: error: forward declaration
>> of
>> ‘struct vtkCellData’
>>
>> However when I replace the dtkCellData with a vtkPointData i haven't any
>> error.
>>
>> Thanks,
>>
>> Awa,
>>
>>
>> David Gobbi-3 wrote:
>>>
>>> No, the CellArray is for something else. The best way is with RGB
>>> scalars:
>>>
>>> vtkUnsignedCharArray *faceColors = vtkUnsignedCharArray::New();
>>> faceColors->SetNumberOfComponents(3);
>>> faceColors->InsertNextTuple(r1, b1, g1);
>>> faceColors->InsertNextTuple(r2, b2, g2);
>>>
>>> Etcetera, until you have six colors. Use values between 0 and 255 for
>>> r,
>>> g, b.
>>>
>>> Next is the tricky part. I don't think that VTK has a pipeline filter
>>> that allows you to add these scalars (except for the programmable
>>> filters) so the easiest way to add the colors is like this:
>>>
>>> 1) make a vtkCubeSource
>>> 2) make a vtkPolyData
>>> 3) DeepCopy the output of the CubeSource into the PolyData
>>> 4) do PolyData->GetCellData()->SetScalars(colors) as Darshan said
>>>
>>> Does anyone know if there is a VTK filter that can add field data or
>>> attribute data to a dataset, so that these sorts of DeepCopy tricks
>>> aren't necessary?
>>>
>>> David
>>>
>>>
>>> On Tue, Jan 12, 2010 at 3:27 PM, awabi <aw.ndaw at gmail.com> wrote:
>>>>
>>>> Thank you.
>>>>
>>>> Is it possible via a vtkcellarray?
>>>>
>>>> awa.
>>>>
>>>> dpai wrote:
>>>>>
>>>>> Yes you can
>>>>>
>>>>> Add Attributes as follows PolyData->GetCellData()->SetScalars()
>>>>> and put a lookupTable with the required colors
>>>>>
>>>>> On Tue, Jan 12, 2010 at 5:03 PM, awabi <aw.ndaw at gmail.com> wrote:
>>>>>
>>>>>>
>>>>>> Hello,
>>>>>>
>>>>>> I'd like to know if it is possible with vtk to color the faces of a
>>>>>> vtkpolydata as I want. For example I have a cube and I'd like to
>>>>>> color
>>>>>> the
>>>>>> faces differently.
>>>>>>
>>>>>> Thank you,
>>>>>>
>>>>>> Awa
>>>>>> --
>>>>>> View this message in context:
>>>>>> http://old.nabble.com/Color-a-vtkcell-tp27135594p27135594.html
>>>>>> Sent from the VTK - Users mailing list archive at Nabble.com.
>>>>>>
>>>>>> _______________________________________________
>>>>>> Powered by www.kitware.com
>>>>>>
>>>>>> Visit other Kitware open-source projects at
>>>>>> http://www.kitware.com/opensource/opensource.html
>>>>>>
>>>>>> Please keep messages on-topic and check the VTK FAQ at:
>>>>>> http://www.vtk.org/Wiki/VTK_FAQ
>>>>>>
>>>>>> Follow this link to subscribe/unsubscribe:
>>>>>> http://www.vtk.org/mailman/listinfo/vtkusers
>>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> Powered by www.kitware.com
>>>>>
>>>>> Visit other Kitware open-source projects at
>>>>> http://www.kitware.com/opensource/opensource.html
>>>>>
>>>>> Please keep messages on-topic and check the VTK 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://old.nabble.com/Color-a-vtkcell-tp27135594p27135949.html
>>>> Sent from the VTK - Users mailing list archive at Nabble.com.
>>>>
>>>> _______________________________________________
>>>> Powered by www.kitware.com
>>>>
>>>> Visit other Kitware open-source projects at
>>>> http://www.kitware.com/opensource/opensource.html
>>>>
>>>> Please keep messages on-topic and check the VTK FAQ at:
>>>> http://www.vtk.org/Wiki/VTK_FAQ
>>>>
>>>> Follow this link to subscribe/unsubscribe:
>>>> http://www.vtk.org/mailman/listinfo/vtkusers
>>>>
>>> _______________________________________________
>>> Powered by www.kitware.com
>>>
>>> Visit other Kitware open-source projects at
>>> http://www.kitware.com/opensource/opensource.html
>>>
>>> Please keep messages on-topic and check the VTK 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://old.nabble.com/Color-a-vtkcell-tp27135594p27137548.html
>> Sent from the VTK - Users mailing list archive at Nabble.com.
>>
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the VTK FAQ at:
>> http://www.vtk.org/Wiki/VTK_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.vtk.org/mailman/listinfo/vtkusers
>>
>
>
>
> --
> François Bertel, PhD | Kitware Inc. Suite 204
> 1 (518) 371 3971 x113 | 28 Corporate Drive
> | Clifton Park NY 12065, USA
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK 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://old.nabble.com/Color-a-vtkcell-tp27135594p27145338.html
Sent from the VTK - Users mailing list archive at Nabble.com.
More information about the vtkusers
mailing list