[vtk-developers] Edges, vtkLine, and vtkPolyLine

Julian Ibarz julian.ibarz at gmail.com
Sun Jun 1 06:42:48 EDT 2008


Personnally on the CVS version vtkExtractSelectedFrustum return always
nothing. It seems the normal of the planes are inversed. I changed this line
of this function :

void vtkExtractSelectedFrustum::ComputePlane(int idx,

                                       double v0[3],
                                       double v1[3],
                                       double v2[3],
                                       vtkPoints *points,

                                       vtkDoubleArray *norms)

{
[...]

vtkMath::Cross(e0,e1,n);

[...]
}

by

vtkMath::Cross(e1,e0,n);

And it seems to work for me. I don't know if i'm using this class bad.
This is an example of
program i maded to test this class and it works with my trick and not
with the CVS version

(could someone read this program and say me if i'm wrong or not ?) :

package org.jcae.vtk.test;

import javax.swing.JFrame;
import vtk.vtkActor;
import vtk.vtkCanvas;
import vtk.vtkConeSource;
import vtk.vtkDataSetMapper;
import vtk.vtkExtractSelectedFrustum;
import vtk.vtkPolyDataMapper;

public class BugFrustum {

    public static void main(String[] args)
    {
        JFrame frame = new JFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        vtkCanvas canvas = new vtkCanvas();
        vtkExtractSelectedFrustum selector = new
vtkExtractSelectedFrustum();

        // create sphere geometry
        vtkConeSource cone = new vtkConeSource();
        cone.SetHeight(3.0);
        cone.SetRadius(1.0);
        cone.SetResolution(10);
        // map to graphics objects
        vtkPolyDataMapper map = new vtkPolyDataMapper();
        map.SetInput(cone.GetOutput());

        // actor coordinates geometry, properties, transformation
        vtkActor aSphere = new vtkActor();
        aSphere.SetMapper(map);
        aSphere.GetProperty().SetColor(0, 0, 1); // color blue
        aSphere.GetProperty().SetRepresentationToWireframe();
        canvas.GetRenderer().AddActor(aSphere);

        frame.add(canvas);
        frame.setSize(800, 600);
        frame.setVisible(true);

        selector.CreateFrustum(new double[] {
            -10.,-10.,-10.,1.0,
            -10.,-10.,10.,1.0,
            -10.,10.,-10.,1.0,
            -10.,10.,10.,1.0,
            10.,-10.,-10.,1.0,
            10.,-10.,10.,1.0,
            10.,10.,-10.,1.0,
            10.,10.,10.,1.0,
        });

        selector.SetInput(cone.GetOutput());
        //UNCOMMENT TO CHECK THE BOUNDARIES
        //selector.ShowBoundsOn();
        // UNCOMMENT TO SEE THAT THE frustum extractor doesn't work inside
and outside the boundaries
        //selector.InsideOutOn();
        selector.Update();
        vtkActor actorFrustum = new vtkActor();
        vtkDataSetMapper mapFrustum = new vtkDataSetMapper();
        mapFrustum.SetInputConnection(selector.GetOutputPort());
        actorFrustum.SetMapper(mapFrustum);
        canvas.GetRenderer().AddActor(actorFrustum);

        canvas.lock();
        canvas.GetRenderer().ResetCamera();
        canvas.unlock();
        //UNCOMMENT TO SEE THAT THE CONE IS IN THE BOUNDARIES
        //canvas.GetRenderer().RemoveActor(aSphere);
    }
}


2008/5/30 Will Schroeder <will.schroeder at kitware.com>:

It is deliberate. a 1D cell has no edges. A 2D cell has no faces. The mind
> set is that edges and faces are (n-1)-dimensional boundary entities of a
> n-dimensional cell. There are other ways to address this; changing this
> behavior at this point is not a good idea.
>
> W
>
>
> On Fri, May 30, 2008 at 11:53 AM, Wilson, Andrew T <atwilso at sandia.gov>
> wrote:
>
>> I'm working on an application where I'm trying to select parts of a
>> wireframe using vtkExtractSelectedFrustum.  After some chasing, I've found
>> the following strange behavior:
>>
>> The GetNumberOfEdges() method on vtkLine and vtkPolyLine returns 0.  The
>> GetEdge(int id) method returns NULL.  This seems counterintuitive: those
>> cells are nothing *but* edges.  Is this deliberate?
>>
>> The downstream effect of this is that it's not possible for me to select
>> in
>> the middle of an edge because of the following bit of code.  This is from
>> vtkExtractSelectedFrustum.cxx around line 882:
>>
>>    if (nedges < 1 &&)
>>      {
>>      delete[] vertbuffer;
>>      return this->IsectDegenerateCell(cell);
>>      }
>>
>> IsectDegenerateCell test cells for being in or out by examining the
>> points.
>> For line and polyline cells that's not sufficient -- we need to test the
>> lines as well.
>>
>> The natural solution to this seems to be to have vtkLine and vtkPolyLine
>> return something reasonable for GetNumberOfEdges() and GetEdge().  If that
>> happens, there's code later in the method that will check the line
>> segments
>> against the frustum one by one, which is the right thing.
>>
>> Is there a reason not to do it this way?  If I don't hear any objections
>> I'll implement it and see if anything in the test cases breaks.
>>
>> -- Andy
>>
>>
>> _______________________________________________
>> vtk-developers mailing list
>> vtk-developers at vtk.org
>> http://www.vtk.org/mailman/listinfo/vtk-developers
>>
>
>
>
> --
> William J. Schroeder, PhD
> Kitware, Inc.
> 28 Corporate Drive
> Clifton Park, NY 12065
> will.schroeder at kitware.com
> http://www.kitware.com
> 518-371-3971 (phone and fax)
> _______________________________________________
> vtk-developers mailing list
> vtk-developers at vtk.org
> http://www.vtk.org/mailman/listinfo/vtk-developers
>
>


-- 
Julian Ibarz



-- 
Julian Ibarz
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20080601/5c3bd86a/attachment.html>


More information about the vtk-developers mailing list