CenterOfMass is not working in tvtk
- Dominant language
- Python
- Stars
- 1.4k
- Forks
- 316
- Avg merge
- 7h 44m
- Merged PRs (30d)
- 5
Description
in tvtk the center of mass allways returns (0,0,0)
**Code tvtk:**
```
from tvtk.api import tvtk
points = tvtk.Points()
top = 1
bottom = .1
points.insert_next_point(0,0,1)
points.insert_next_point(top,0,1)
points.insert_next_point(top,top,1)
points.insert_next_point(0,top,1)
points.insert_next_point(0,0,0)
points.insert_next_point(bottom,0,0)
points.insert_next_point(bottom,bottom,0)
points.insert_next_point(0,bottom,0)
polydata = tvtk.PolyData()
polydata.points = points
cofm = tvtk.CenterOfMass()
cofm.set_input_data(polydata)
cofm.use_scalars_as_weights = False
cofm.update()
print(cofm.center)
```
**Code vtk works:**
```import vtk
points = vtk.vtkPoints()
top = 1
bottom = .1
points.InsertNextPoint(0,0,1)
points.InsertNextPoint(top,0,1)
points.InsertNextPoint(top,top,1)
points.InsertNextPoint(0,top,1)
points.InsertNextPoint(0,0,0)
points.InsertNextPoint(bottom,0,0)
points.InsertNextPoint(bottom,bottom,0)
points.InsertNextPoint(0,bottom,0)
polydata = vtk.vtkPolyData()
polydata.SetPoints(points)
cofm = vtk.vtkCenterOfMass()
cofm.SetInputData(polydata)
cofm.SetUseScalarsAsWeights(False)
cofm.Update();
cofm.GetCenter()
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing the example with tvtk.Points, tvtk.PolyData, and tvtk.CenterOfMass, then compare its behavior with the corresponding vtk.vtkCenterOfMass calls shown in the issue. Trace the tvtk wrapper path for set_input_data, use_scalars_as_weights, update, and center; done means the example returns the expected nonzero center like the direct VTK version.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- computer-graphics
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100