Selected cells not visible

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Selected cells not visible

-Daniel-
Hello vtk-users,

I use vtkExtractVisibleCells to select cells from a polydata.
My selection found more than one node, but it isn't visible.


Java-Code:
vtkPolyData poly = (vtkPolyData) getObjects().get(0).getPolydata();
poly.Update();

vtkHardwareSelector selector = new vtkHardwareSelector();
selector.SetRenderer(getView_volume().GetRenderer());
                       
int[] temp = rect4PolySelection; // int[4]

selector.SetArea(temp[0], temp[2], temp[1], temp[3]);
                                       
vtkSelection selection = selector.Select();
System.out.println("nodes: "+selection.GetNumberOfNodes() );
                                       
vtkExtractSelection extractSelection = new vtkExtractSelection();
extractSelection.SetInput(0, poly);
extractSelection.SetInput(1, selection);
extractSelection.Update();
                               
vtkDataSetMapper mapper = new vtkDataSetMapper();
mapper.SetInputConnection(extractSelection.GetOutputPort());
                                       
vtkActor actor = new vtkActor();
actor.SetMapper(mapper);
actor.GetProperty().SetColor(0.1, 0, 0.8);
                                       
getView_volume().GetRenderer().AddActor(actor);



What's wrong? Can someone help me?
Reply | Threaded
Open this post in threaded view
|

Re: Selected cells not visible

Alex Malyushytskyy
I can't help you with Java,
but it looks like you missing a few operations and doing it different than
http://www.cmake.org/Wiki/VTK/Examples/Cxx/Filtering/ExtractVisibleCells example

For example
selector.SetArea(temp[0], temp[2], temp[1], temp[3]);
isn't it supposed to be
selector.SetArea(temp[2], temp[3], temp[0], temp[1]);
according to the example?

what is rect4PolySelection?

and I have not found equivalent of the following line iun your code
      selector->SetFieldAssociation(vtkDataObject::FIELD_ASSOCIATION_CELLS);

Hope it helps,
    Alex

On Mon, Feb 11, 2013 at 9:14 AM, -Daniel- <[hidden email]> wrote:

> Hello vtk-users,
>
> I use vtkExtractVisibleCells to select cells from a polydata.
> My selection found more than one node, but it isn't visible.
>
>
> *Java-Code:*/
> vtkPolyData poly = (vtkPolyData) getObjects().get(0).getPolydata();
> poly.Update();
>
> vtkHardwareSelector selector = new vtkHardwareSelector();
> selector.SetRenderer(getView_volume().GetRenderer());
>
> int[] temp = rect4PolySelection;        // int[4]
>
> selector.SetArea(temp[0], temp[2], temp[1], temp[3]);
>
> vtkSelection selection = selector.Select();
> System.out.println("nodes: "+selection.GetNumberOfNodes() );
>
> vtkExtractSelection extractSelection = new vtkExtractSelection();
> extractSelection.SetInput(0, poly);
> extractSelection.SetInput(1, selection);
> extractSelection.Update();
>
> vtkDataSetMapper mapper = new vtkDataSetMapper();
> mapper.SetInputConnection(extractSelection.GetOutputPort());
>
> vtkActor actor = new vtkActor();
> actor.SetMapper(mapper);
> actor.GetProperty().SetColor(0.1, 0, 0.8);
>
> getView_volume().GetRenderer().AddActor(actor);/
>
>
> What's wrong? Can someone help me?
>
>
>
>
> --
> View this message in context: http://vtk.1045678.n5.nabble.com/Selected-cells-not-visible-tp5718419.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
Reply | Threaded
Open this post in threaded view
|

Re: Selected cells not visible

-Daniel-
Thanks for your hint.
What is the int-value of "vtkDataObject::FIELD_ASSOCIATION_CELLS" ?
I don't use (found) it with Java.

"rect4PolySelection" is an int-Array of a rectangle with (xmin, xmax, ymin, ymax).
Reply | Threaded
Open this post in threaded view
|

Re: Selected cells not visible

Alex Malyushytskyy
It is defined in enum below (as 1) in my  VTK version.
It is unlikely but might be changed in other versions.

//BTX
  // Description:
  // Possible values for the FIELD_ASSOCIATION information entry.
  enum FieldAssociations
  {
    FIELD_ASSOCIATION_POINTS,
    FIELD_ASSOCIATION_CELLS,
    FIELD_ASSOCIATION_NONE,
    FIELD_ASSOCIATION_POINTS_THEN_CELLS,
    FIELD_ASSOCIATION_VERTICES,
    FIELD_ASSOCIATION_EDGES,
    FIELD_ASSOCIATION_ROWS,
    NUMBER_OF_ASSOCIATIONS
  };
  //ETX

Alex

On Tue, Feb 12, 2013 at 9:48 AM, -Daniel- <[hidden email]> wrote:

> Thanks for your hint.
> What is the int-value of "vtkDataObject::FIELD_ASSOCIATION_CELLS" ?
> I don't use (found) it with Java.
>
> "rect4PolySelection" is an int-Array of a rectangle with (xmin, xmax, ymin,
> ymax).
>
>
>
> --
> View this message in context: http://vtk.1045678.n5.nabble.com/Selected-cells-not-visible-tp5718419p5718464.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
Reply | Threaded
Open this post in threaded view
|

Re: Selected cells not visible

-Daniel-
I included the following line
  selector.SetFieldAssociation(1);

But this solved not the problem. My selected cells are still invisible. (but nodes founded..)
Reply | Threaded
Open this post in threaded view
|

Re: Selected cells not visible

Alex Malyushytskyy
Check that you window does not have anti-aliasing

In C++ and mentioned above example it is set with line :
  renderWindow->SetMultiSamples(0);

I am not sure that
http://www.cmake.org/Wiki/VTK/Examples/Cxx/Filtering/ExtractVisibleCells
works as expected at least at my vtk version.

Initiating selection over sphere and over bacjground always prints
"Selection has 2 nodes",
Even though if it were supposed to select cells I would expect it to
be 3 nodes cause sphere is built from triangles.


Alex

On Wed, Feb 13, 2013 at 12:26 PM, -Daniel- <[hidden email]> wrote:

> I included the following line
>   selector.SetFieldAssociation(1);
>
> But this solved not the problem. My selected cells are still invisible. (but
> nodes founded..)
>
>
>
> --
> View this message in context: http://vtk.1045678.n5.nabble.com/Selected-cells-not-visible-tp5718419p5718506.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
Reply | Threaded
Open this post in threaded view
|

Re: Selected cells not visible

Alex Malyushytskyy
I phrased it incorrectly.

Selection ( visible triangles ) should have at least 3 nodes and in
reality more , depending on the on the point of view.
unless I misunderstand something which is fairly possible.

Alex

On Wed, Feb 13, 2013 at 3:13 PM, Alex Malyushytskyy
<[hidden email]> wrote:

> Check that you window does not have anti-aliasing
>
> In C++ and mentioned above example it is set with line :
>   renderWindow->SetMultiSamples(0);
>
> I am not sure that
> http://www.cmake.org/Wiki/VTK/Examples/Cxx/Filtering/ExtractVisibleCells
> works as expected at least at my vtk version.
>
> Initiating selection over sphere and over bacjground always prints
> "Selection has 2 nodes",
> Even though if it were supposed to select cells I would expect it to
> be 3 nodes cause sphere is built from triangles.
>
>
> Alex
>
> On Wed, Feb 13, 2013 at 12:26 PM, -Daniel- <[hidden email]> wrote:
>> I included the following line
>>   selector.SetFieldAssociation(1);
>>
>> But this solved not the problem. My selected cells are still invisible. (but
>> nodes founded..)
>>
>>
>>
>> --
>> View this message in context: http://vtk.1045678.n5.nabble.com/Selected-cells-not-visible-tp5718419p5718506.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
Reply | Threaded
Open this post in threaded view
|

Re: Selected cells not visible

Alex Malyushytskyy
It looks like I was mistaken and it prints number of vtkSelectionNode
s which may be a valid number in this case,
but as I understand example was supposed to color selection (assign
red color ) and I do not see this happen.


On Wed, Feb 13, 2013 at 3:21 PM, Alex Malyushytskyy
<[hidden email]> wrote:

> I phrased it incorrectly.
>
> Selection ( visible triangles ) should have at least 3 nodes and in
> reality more , depending on the on the point of view.
> unless I misunderstand something which is fairly possible.
>
> Alex
>
> On Wed, Feb 13, 2013 at 3:13 PM, Alex Malyushytskyy
> <[hidden email]> wrote:
>> Check that you window does not have anti-aliasing
>>
>> In C++ and mentioned above example it is set with line :
>>   renderWindow->SetMultiSamples(0);
>>
>> I am not sure that
>> http://www.cmake.org/Wiki/VTK/Examples/Cxx/Filtering/ExtractVisibleCells
>> works as expected at least at my vtk version.
>>
>> Initiating selection over sphere and over bacjground always prints
>> "Selection has 2 nodes",
>> Even though if it were supposed to select cells I would expect it to
>> be 3 nodes cause sphere is built from triangles.
>>
>>
>> Alex
>>
>> On Wed, Feb 13, 2013 at 12:26 PM, -Daniel- <[hidden email]> wrote:
>>> I included the following line
>>>   selector.SetFieldAssociation(1);
>>>
>>> But this solved not the problem. My selected cells are still invisible. (but
>>> nodes founded..)
>>>
>>>
>>>
>>> --
>>> View this message in context: http://vtk.1045678.n5.nabble.com/Selected-cells-not-visible-tp5718419p5718506.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
Reply | Threaded
Open this post in threaded view
|

Re: Selected cells not visible

Alex Malyushytskyy
I printed information on selection modifying example:

                vtkIdType numNodes = selection->GetNumberOfNodes();
                for(int iNode=0; iNode < numNodes; iNode++)
                {

                        std::cout << "Node: " << iNode << endl;
                        vtkIdType listSize =
selection->GetNode(iNode)->GetSelectionList()->GetNumberOfTuples();
                        for(int iVal=0; iVal < listSize; iVal++)
                        {
                                std::cout << "\t" << iVal << "\t" <<
selection->GetNode(iNode)->GetSelectionList()->GetVariantValue(iVal)
<< endl;
                        }
                }

And even though example does not  change the color it looks like it
does  pick up the correct (visible only)  cells .
So check that you do not have anti-aliasing set otherwise you might
get cells which are not visible partially visible.

Alex


On Wed, Feb 13, 2013 at 3:38 PM, Alex Malyushytskyy
<[hidden email]> wrote:

> It looks like I was mistaken and it prints number of vtkSelectionNode
> s which may be a valid number in this case,
> but as I understand example was supposed to color selection (assign
> red color ) and I do not see this happen.
>
>
> On Wed, Feb 13, 2013 at 3:21 PM, Alex Malyushytskyy
> <[hidden email]> wrote:
>> I phrased it incorrectly.
>>
>> Selection ( visible triangles ) should have at least 3 nodes and in
>> reality more , depending on the on the point of view.
>> unless I misunderstand something which is fairly possible.
>>
>> Alex
>>
>> On Wed, Feb 13, 2013 at 3:13 PM, Alex Malyushytskyy
>> <[hidden email]> wrote:
>>> Check that you window does not have anti-aliasing
>>>
>>> In C++ and mentioned above example it is set with line :
>>>   renderWindow->SetMultiSamples(0);
>>>
>>> I am not sure that
>>> http://www.cmake.org/Wiki/VTK/Examples/Cxx/Filtering/ExtractVisibleCells
>>> works as expected at least at my vtk version.
>>>
>>> Initiating selection over sphere and over bacjground always prints
>>> "Selection has 2 nodes",
>>> Even though if it were supposed to select cells I would expect it to
>>> be 3 nodes cause sphere is built from triangles.
>>>
>>>
>>> Alex
>>>
>>> On Wed, Feb 13, 2013 at 12:26 PM, -Daniel- <[hidden email]> wrote:
>>>> I included the following line
>>>>   selector.SetFieldAssociation(1);
>>>>
>>>> But this solved not the problem. My selected cells are still invisible. (but
>>>> nodes founded..)
>>>>
>>>>
>>>>
>>>> --
>>>> View this message in context: http://vtk.1045678.n5.nabble.com/Selected-cells-not-visible-tp5718419p5718506.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
Reply | Threaded
Open this post in threaded view
|

Re: Selected cells not visible

-Daniel-
My printed informations of a primitve object (pyramid) are:  (using your codesnippet)
selected pyramid
all points: 5 , all cells: 6   of PolyData
rectangleSelection: 286 252 475 437  // green rectangle with xMin, yMin, xMax, yMax
selected nodes: 36

Node: 0
        0
Node: 1
        0
... and so on
Node: 34
        0
Node: 35
        0
        1
        2
        3

       
Only the last node seems relevant.