# get intersection between 2 obj

**URL:** https://discourse.vtk.org/t/get-intersection-between-2-obj/5699
**Category:** Support
**Created:** [May 4, 2021, 11:57am UTC](https://discourse.vtk.org/t/get-intersection-between-2-obj/5699 "2021-05-04T11:57:35Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![RAUMIK\_RANA](https://discourse.vtk.org/user_avatar/discourse.vtk.org/raumik_rana/32/3338_2.png) [@RAUMIK\_RANA](https://discourse.vtk.org/u/RAUMIK_RANA)
#### Post date: [May 4, 2021, 11:57am UTC](https://discourse.vtk.org/t/get-intersection-between-2-obj/5699/1 "2021-05-04T11:57:35Z")

</div>

I am trying to get intersection between 2 obj files.  
first one is sphere and second one is cylinder.  
I am using ‘vtkCollisionDetectionFilter’ for that.  
but I did not get it.  
I got 0 points in polyData.  
here is my code.

```auto
def filterOBJ(path1,path2):

    reader1 = vtk.vtkOBJReader()

    reader1.SetFileName(path1)

    reader1.Update()

    mapper1 = vtk.vtkPolyDataMapper()

    if vtk.VTK_MAJOR_VERSION <= 5:

        mapper1.SetInput(reader1.GetOutput())

    else:

        mapper1.SetInputConnection(reader1.GetOutputPort())

    print(reader1.GetOutput().GetNumberOfPoints())

    # print(reader.GetOutput ().GetNumberOfPoints())

    actor1 = vtk.vtkActor()

    actor1.SetMapper(mapper1)

    ren.AddActor(actor1)

    

    reader2 = vtk.vtkOBJReader()

    reader2.SetFileName(path2)

    reader2.Update()

    mapper2 = vtk.vtkPolyDataMapper()

    if vtk.VTK_MAJOR_VERSION <= 5:

        mapper2.SetInput(reader2.GetOutput())

    else:

        mapper2.SetInputConnection(reader2.GetOutputPort())

    

    print(reader2.GetOutput().GetNumberOfPoints())

    actor2 = vtk.vtkActor()

    actor2.SetMapper(mapper2)

    ren.AddActor(actor2)

    vtk.vtkTriangle 

    collision = vtk.vtkCollisionDetectionFilter()

    collision.SetInputData(0,reader1.GetOutput())

    collision.SetInputData(1,reader2.GetOutput())

    collision.Update()

    collisionMapper = vtk.vtkPolyDataMapper()

    collisionMapper.SetInputData(collision.GetContactsOutput())

    print(collision.GetContactsOutput().GetPoints().GetNumberOfPoints())

    # print(collision.GetOutput ())

    # collisionMapper.update()

    collisionActor = vtk.vtkActor()

    collisionActor.SetMapper(collisionMapper)

    ren.AddActor(collisionActor)

```
