# Error while constructing cell map: Invalid cell size for lines.

**URL:** https://discourse.vtk.org/t/error-while-constructing-cell-map-invalid-cell-size-for-lines/9137
**Category:** Support
**Tags:** python
**Created:** [August 12, 2022, 9:37am UTC](https://discourse.vtk.org/t/error-while-constructing-cell-map-invalid-cell-size-for-lines/9137 "2022-08-12T09:37:42Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Dwight98](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dwight98/32/5373_2.png) [@Dwight98](https://discourse.vtk.org/u/Dwight98)
#### Post date: [August 12, 2022, 9:37am UTC](https://discourse.vtk.org/t/error-while-constructing-cell-map-invalid-cell-size-for-lines/9137/1 "2022-08-12T09:37:42Z")

</div>

![1](https://discourse.vtk.org/uploads/default/original/2X/f/f7b3aaf87b578c7c059e6565eda3614b5a356d2b.png)  
The image above is two polygons I created with Geomagic studio, and I saved them separately as files in obj format，I then use the vtkBooleanOperationPolyDataFilter() method in vtk.py to do Intersection operations.However, the result of the program error is as shown in the following figure  
 ![2](https://discourse.vtk.org/uploads/default/original/2X/0/0e3eb8b8bda60b6184b96a40a23c716c3c9b1119.png)  
I don’t know why this is the case，Below is the vtk code I wrote based on Python，Please help me solve the problem, Sincere thanks！

# noinspection PyUnresolvedReferences

import vtkmodules.vtkInteractionStyle

# noinspection PyUnresolvedReferences

import vtkmodules.vtkRenderingOpenGL2  
from vtkmodules.vtkCommonColor import vtkNamedColors  
from vtkmodules.vtkFiltersGeneral import vtkBooleanOperationPolyDataFilter  
from vtkmodules.vtkIOGeometry import vtkOBJReader  
from vtk import vtkOBJExporter  
from vtkmodules.vtkRenderingCore import (  
vtkActor,  
vtkPolyDataMapper,  
vtkRenderWindow,  
vtkRenderWindowInteractor,  
vtkRenderer  
)

def main():  
colors =vtkNamedColors()  
#读取obj文件  
sphereSource1=vtkOBJReader()  
sphereSource1.SetFileName(‘E:\重要资料\矿山项目\point\boolUnion\_test(big).obj’)  
sphereSource1.Update()  
input1 = sphereSource1.GetOutput()

```
sphereSource2 = vtkOBJReader()
sphereSource2.SetFileName('E:\\重要资料\\矿山项目\\point\\boolUnion_test(small_move).obj') # 'D:/pycharm/lianxicunfang/MOXINGSHILI2/WggJingJJ.obj'
sphereSource2.Update()
input2 = sphereSource2.GetOutput()

inputMapper1=vtkPolyDataMapper()
inputMapper1.SetInputData(input1)
inputMapper1.ScalarVisibilityOff()
inputActor1=vtkActor()
inputActor1.SetMapper(inputMapper1)
inputActor1.GetProperty().SetColor(colors.GetColor3d("Tomato"))
print(input1.GetBounds()[1])#GetBounds(bounds[6]) Set the (xmin, xmax, ymin, ymax, zmin, zmax) bounding box values of the cell.
print(input1.GetBounds()[0])
print(input1.GetBounds()[1]-input1.GetBounds()[0])
inputActor1.SetPosition(input1.GetBounds()[1]-input1.GetBounds()[0],0,0)

inputMapper2=vtkPolyDataMapper()
inputMapper2.SetInputData(input2)
inputMapper2.ScalarVisibilityOff()
inputActor2=vtkActor()
inputActor2.SetMapper(inputMapper2)
inputActor2.GetProperty().SetColor(colors.GetColor3d("Mint"))
print(-(input2.GetBounds()[1]-input2.GetBounds()[0]))
inputActor2.SetPosition(-(input2.GetBounds()[1]-input2.GetBounds()[0]),0,0)
try:
    boolOperation=vtkBooleanOperationPolyDataFilter()
    boolOperation.SetOperationToIntersection()#进行的运算是相交运算
    boolOperation.SetInputConnection(0,sphereSource1.GetOutputPort())
    boolOperation.SetInputConnection(1,sphereSource2.GetOutputPort())
    boolOperation.Update()
    boolOperationMapper=vtkPolyDataMapper()
    boolOperationMapper.SetInputConnection(boolOperation.GetOutputPort())
    boolOperationMapper.ScalarVisibilityOff()

    boolOperationActor=vtkActor()
    boolOperationActor.SetMapper(boolOperationMapper)
    
    boolOperationActor.GetProperty().SetDiffuseColor(colors.GetColor3d('Banana'))

    renderer=vtkRenderer()
    renderer.AddActor(boolOperationActor)
    renderer.SetBackground(colors.GetColor3d("Silver"))
    renderWindow=vtkRenderWindow()
    renderWindow.AddRenderer(renderer)
    renWinInteractor=vtkRenderWindowInteractor()
    renWinInteractor.SetRenderWindow(renderWindow)
    renderWindow.Render()
    renWinInteractor.Start()
    porter = vtkOBJExporter()
    porter.SetFilePrefix('C:\\Users\\Lenovo\\Desktop\\1')
    porter.SetInput(renderWindow)
    porter.Write()
except Exception as err:
    print(str(err))

```

if **name** ==‘ **main** ’:  
main()
