[vtkusers] Getting the scalar value from vtkCell

Dominik Szczerba domi at vision.ee.ethz.ch
Wed Aug 15 07:12:52 EDT 2007


Hi Mark,
What I would do first is break the whole scene in sub-meshes before any
rendering, and store the corresponding vtkSmartPointers in a
std::vector, with the order as they appear on the scene (e.g. submesh[3]
would reference the part with domain ID 3 etc.). Then run ExtractEdges
on each of those, storing the corresponding stkSmartPointers in a vector
again. Then again make a vector of actors associated with the extracted
edges. Then, when you pick, you turn on the visibility of the relevant
edge actor, while switching the other off. That should perform pretty
fast. You may want to enable the PolygonOffset to avoid the race
conditions when rendering the edges and the faces at the same time.
- Dominik

Mark Kobine wrote:
> Hi Dominik,
> 
> I have managed to add a vtkThreshold filter and can now control which
> parts of my geometry are displayed based on the scalar value.
> 
> Currently I click on a sub-part of the geometry and filter using its
> scalar value. The renderer then displays only the sub-part that was
> clicked on and hides the rest of the geometry.
> 
> What I need to do is keep the rest of the geometry visible and change
> the display of the clicked sub-part using vtkExtractEdges. I think that
> I will now need 2 actors, both with threshold filters, one to display
> the clicked part and the other to display the rest of the geometry.
> 
> Does this strategy sound sensible or would you recommend an alternative
> approach?
> 
> Many thanks,
> Mark
> 
> Dominik Szczerba wrote:
>> OK so your scene is a set of triangular surfaces and you want to
>> highlight one whole surface and not the picked cell alone. That is very
>> easily done with the vtkThresholdFilter. Do you have your surfaces
>> pre-marked with some (integer) ID? If not, you can run
>> vtkConnectivityFilter to mark the disconnected regions with different
>> integers. Else, you have to prepare some ID field beforehand yourself.
>> Then when you click you pick a cell, then you retrieve its domain ID,
>> then you threshold the whole scene using this scalar to extract only
>> this particular surface, then you run vtkExtractEdges to render
>> (red/thick) edges. It might be slow for big datasets though. First thing
>> to speed up would be to pre-compute the edges at the beginning.
>> - Dominik
>>
>> Mark Kobine wrote:
>>> Hi Dominik,
>>>
>>> My geometry is arranged into a number of STL "solid" sections each of
>>> which is comprised of many triangles. When the user clicks on the
>>> geometry I want to "highlight" the whole "solid" section, not just the
>>> individual triangle. The one thing that all the triangles in the same
>>> section have in common is their scalar value. So I thought that I
>>> may be able to use that.
>>>
>>> Hope that helps to explain my thinking.
>>>
>>> Many thanks,
>>> Mark
>>>
>>> Dominik Szczerba wrote:
>>>> Hi Mark,
>>>> I am not sure what you are after. Why do you need to have cells with
>>>> the
>>>> same scalar? I thought you just wanted to highlight a picked cell (or
>>>> cells). In any case, you can get the scalar value by
>>>> dataset->GetCellData()-> ... and getting you array by name for example.
>>>> But I dont see why you would want that. You can extract the selected
>>>> cell's edges and color their actor to your liking.
>>>> - Dominik
>>>>
>>>> Mark Kobine wrote:
>>>>> Hi Dominik,
>>>>>
>>>>> Thanks for that - vtkExtractEdges looks like the way to go.
>>>>>
>>>>> What I think I need to do next is to get the set of cells that
>>>>> share the
>>>>> same scalar value (as allocated by vtkSTLReader with ScalarTagsOn())
>>>>> when the STL file was read in. I can get the cell the user clicked
>>>>> easily with vtkCellPicker but I haven't been able to find anything
>>>>> that
>>>>> will give me that cell's scalar value or the rest of the cells with
>>>>> the
>>>>> same scalar.
>>>>>
>>>>> Or am I approaching this the wrong way?
>>>>>
>>>>> Many thanks,
>>>>> Mark
>>>>>
>>>>> Dominik Szczerba wrote:
>>>>>> Hi Mark,
>>>>>> Please make cc's to the mailing list.
>>>>>> The easiest thing to set up (not necessarily the fastest to perform)
>>>>>> would be to extract the picked selection and use the vtkExtractEdges
>>>>>> filter on it. Then set linewidth to 2 or 3 and color to red in a
>>>>>> corresponding actor.
>>>>>> bye, Dominik
>>>>>>
>>>>>> Mark Kobine wrote:
>>>>>>> Hi Dominik,
>>>>>>>
>>>>>>> Many thanks for the advice.
>>>>>>>
>>>>>>> If I were to go about plotting the edges of the selected
>>>>>>> geometry, as
>>>>>>> you suggest, how would I go about this?
>>>>>>>
>>>>>>> Many thanks,
>>>>>>> Mark
>>>>>>>
>>>>>>> Dominik Szczerba wrote:
>>>>>>>> This has been frequently asked here. There is no way to change a
>>>>>>>> cell
>>>>>>>> color other than to change its scalar value. This is not elegant
>>>>>>>> as you
>>>>>>>> have to write to your original dataset, supposedly writing down the
>>>>>>>> overwritten value temporarily and taking care it is written back
>>>>>>>> when
>>>>>>>> you un-pick. Then, you have to remember that the modified scalar
>>>>>>>> has
>>>>>>>> still go through a color lookup table to be seen and having it
>>>>>>>> always
>>>>>>>> e.g. red may not always be that trivial and robust.
>>>>>>>> I would recommend a different way without modifying the actual
>>>>>>>> data,
>>>>>>>> like shrinking the element, plotting it edges, or annotating it's
>>>>>>>> nodes etc.
>>>>>>>> - Dominik
>>>>>>>>
>>>>>>>> Mark Kobine wrote:
>>>>>>>>> Hi,
>>>>>>>>>
>>>>>>>>> I have some geometry read in from an STL file that contains
>>>>>>>>> several
>>>>>>>>> "solid" sections. These sections are currently coloured
>>>>>>>>> automatically
>>>>>>>>> by vtk based on the scalar value assigned to each section as it is
>>>>>>>>> read in. I want to change the appearance of one of these
>>>>>>>>> sections if
>>>>>>>>> the user clicks on it in the renderer window.
>>>>>>>>>
>>>>>>>>> I'm using vtkCellPicker and from that I can get the selected
>>>>>>>>> vtkCell.
>>>>>>>>> From there is there a way to get the scalar value for that cell?
>>>>>>>>>
>>>>>>>>> My approach is to use that scalar to somehow change the
>>>>>>>>> appearance of
>>>>>>>>> all cells with the same scalar value.
>>>>>>>>>
>>>>>>>>> Can any one help? Is this a sensible approach?
>>>>>>>>>
>>>>>>>>> Many thanks,
>>>>>>>>> Mark
>>>>>>>>> _______________________________________________
>>>>>>>>> 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

-- 
Dominik Szczerba, Ph.D.
Computer Vision Lab CH-8092 Zurich
http://www.vision.ee.ethz.ch/~domi



More information about the vtkusers mailing list