[vtkusers] How to compute intersection between surface polydata in vtk?
Jean-Dominique Barnichon
jeando.barnichon at free.fr
Fri Apr 7 13:51:29 EDT 2006
Well,
I'm using vtk5.0.
I've dowloaded again from the bioengineering website, and it does not
seem updated yet.
So yes, I would very much like if you could send me the new version that
is compatible with vtk5.0.
Thanks,
Jean-Do
Goodwin Lawlor a écrit :
> Hi Jean-Do,
>
> What vtk version are you using? I've updated the source files on the
> bioengineering website for vtk5.0
>
> The error is due to the old class code not being compatible with the
> new pipeline (>vtk4.5 I think).
>
> I'll send the updated class files to you, if you like.
>
> hth
>
> Goodwin
>
> ps I'm updating all the code there soon... probably moving it to
> sourceforge.
>
> Jean-Dominique Barnichon wrote:
>> Michael,
>>
>> thanks for pointing me there.
>> I gave it a try, but I'm actually stuck.
>> Config: winXp(SP2) + msvc7.0 + vtk5.0.
>> So I downloaded everything required from bioengineering web site
>> (vtkBioeng.zip), ran cmake and eventually built vtkBioeng library as
>> a shared library (vtkBioeng.dll). So far so good.
>> Then I translated most of the testCollisionDetection.tcl sample given
>> from tcl to c++ (see code below)
>> When I run it, I end up with an error located at the following line:
>> vtkCollisionDetectionFilter *collide =
>> vtkCollisionDetectionFilter::New();
>> Trying to debug it, an access violation is reported in the
>> constructor of vtkCollisionDetectionFilter, at line #4 :
>> this->Inputs[0] = NULL;
>> Apparently, from what I understand, it looks like the array Inputs[]
>> (inherited from vtkPolyDataSource) is not initialized (value is
>> 0x00000000).
>>
>> In case you have you already tested this sample :
>> - did you experience similar problem?
>> - if no, was it in c++ or in tcl, with which vtk version 4.x or 5.x?
>>
>> Thanks for helping
>> Jean-Do
>>
>> File testCollisionDetection.cpp
>>
>> #include "vtkProperty.h"
>> #include "vtkPolyDataMapper.h"
>> #include "vtkActor.h"
>> #include "vtkRenderWindow.h"
>> #include "vtkRenderWindowInteractor.h"
>> #include "vtkRenderer.h"
>> #include "vtkCamera.h"
>> #include "vtkSphereSource.h"
>> #include "vtkMatrix4x4.h"
>> #include "vtkCollisionDetectionFilter.h"
>> #include "vtkGlyph3D.h"
>> #include "vtkInteractorStyleJoystickActor.h"
>> #include "vtkTextActor.h"
>>
>> int _tmain(int argc, _TCHAR* argv[])
>> {
>> vtkSphereSource *sphere0 = vtkSphereSource::New();
>> sphere0->SetPhiResolution(30);
>> sphere0->SetThetaResolution(30);
>> sphere0->SetCenter(-0.7, 0, 0);
>> sphere0->Update();
>>
>> vtkSphereSource *sphere1 = vtkSphereSource::New();
>> sphere1->SetPhiResolution(30);
>> sphere1->SetThetaResolution(30);
>> sphere1->Update();
>>
>> vtkMatrix4x4 *matrix0 = vtkMatrix4x4::New();
>> vtkMatrix4x4 *matrix1 = vtkMatrix4x4::New();
>>
>> vtkCollisionDetectionFilter *collide =
>> vtkCollisionDetectionFilter::New();
>> collide->SetInput(0, sphere0->GetOutput());
>> collide->SetMatrix(0, matrix0);
>> collide->SetInput(1, sphere1->GetOutput());
>> collide->SetMatrix(1, matrix1);
>> collide->SetBoxTolerance(0.0);
>> collide->SetCellTolerance(0.0);
>> collide->SetNumberOfCellsPerBucket(2);
>> //collide->SetCollisionModeToFirstContact();
>> collide->GeneratePolydataOutputOn();
>> // collide->AddObserver->EndEvent(cbCollision());
>>
>> vtkTextActor *txt = vtkTextActor::New();
>>
>> vtkSphereSource *point = vtkSphereSource::New();
>> point->SetRadius(0.01);
>> vtkPolyData *pointdata = vtkPolyData::New();
>> pointdata->SetPoints(collide->GetContactPoints());
>>
>> vtkGlyph3D *points = vtkGlyph3D::New();
>> points->SetInput(pointdata);
>> points->SetSource(point->GetOutput());
>>
>> vtkPolyDataMapper *mapper1 = vtkPolyDataMapper::New();
>> mapper1->SetInput(collide->GetOutput());
>> vtkActor *actor1 = vtkActor::New();
>> actor1->SetMapper(mapper1);
>> (actor1->GetProperty())->BackfaceCullingOn();
>> actor1->SetUserMatrix(matrix0);
>>
>> vtkPolyDataMapper *mapper2 = vtkPolyDataMapper::New();
>> mapper2->SetInput(collide->GetOutput(1));
>> vtkActor *actor2 = vtkActor::New();
>> actor2->SetMapper(mapper2);
>> (actor2->GetProperty())->BackfaceCullingOn();
>> actor2->SetUserMatrix(matrix1);
>>
>> vtkPolyDataMapper *mapper3 = vtkPolyDataMapper::New();
>> mapper3->SetInput(points->GetOutput());
>> vtkActor *actor3 = vtkActor::New();
>> actor3->SetMapper(mapper3);
>> (actor3->GetProperty())->SetColor(0,0,0);
>>
>> vtkRenderer *ren = vtkRenderer::New();
>> ren->AddActor(actor1);
>> ren->AddActor(actor2);
>> //ren AddObserver EndEvent ChangeOrigin
>> //ren AddActor actor3
>> ren->AddActor(txt);
>> ren->SetBackground(0.5,0.5,0.5);
>>
>> vtkRenderWindow *renWin = vtkRenderWindow::New();
>> renWin->AddRenderer(ren);
>> vtkInteractorStyleJoystickActor *istyle =
>> vtkInteractorStyleJoystickActor::New();
>> vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
>> iren->SetRenderWindow(renWin);
>> iren->SetInteractorStyle(istyle);
>>
>> iren->Initialize();
>> renWin->Render();
>> iren->Start();
>> }
>>
>>
>>> If both of your inputs are polydata, this filter might be useful:
>>>
>>> http://www.bioengineering-research.com/vtk/vtkCollisionDetectionFilter.htm
>>>
>>>
>>>
>>> On Apr 2, 2006, at 12:20 AM, Jean-Dominique Barnichon wrote:
>>>
>>>> One of the surface is not a plane, it is a polyplane (i.e. a 2D
>>>> (xy) polyline extruded along the z direction.
>>>> Jean-Do
>>>>
>>>> Bill Lorensen a écrit :
>>>>> If one surface is a plane, you can use ClipPolyData and define an
>>>>> implicit plane as the clipper.
>>>>>
>>>>> Bill
>>>>>
>>>>> At 09:13 AM 4/1/2006, Jean-Dominique Barnichon wrote:
>>>>>> Dear all,
>>>>>>
>>>>>> I need to find the intersection between two surfaces, each one
>>>>>> being defined as a polydata (actually one surface is a vertical
>>>>>> polyplane, and the other one is a topographical surface).
>>>>>>
>>>>>> Such intersection operation is already effective in other
>>>>>> libraries such as CGAL (http://www.cgal.org) and GTS
>>>>>> (http://gts.sourceforge.net).
>>>>>> However, it is still not clear to me which approach i should
>>>>>> follow to perform such an operation with vtk.
>>>>>> From what i understood, one can either :
>>>>>> - use vtkOBBTree::IntersectWithOBBTree(...), but in this case the
>>>>>> related parameters (especially the int(*function)) are not
>>>>>> obvious to me. Would it be possible to have a bit more
>>>>>> information on this method and its usage?
>>>>>> - treat polydata as an implicit surface using the
>>>>>> vtkImplicitPolydata class (proposed by Dave Pont), which then
>>>>>> allows to use vtkClipPolyData class (though this class is not
>>>>>> part of vtk, yet?).
>>>>>>
>>>>>> Recently, there has been quite few threads related to very
>>>>>> similar topics, but i did not get whether involved people have
>>>>>> eventually succeeded or not in computing the intersection using
>>>>>> one of the above mentioned method.
>>>>>>
>>>>>> Any help/advice is welcomed.
>>>>>> Thanks in advance
>>>>>> Jean-Do
>>>>>> _______________________________________________
>>>>>> 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
>>>>>
>>>>>
>>>>>
>>>>
>>>> _______________________________________________
>>>> 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
>>>>
>>>
>>>
>>>
>>
>
>
More information about the vtkusers
mailing list