at123
(Ken Wiley)
August 7, 2019, 1:01pm
1
Hi,
I declared a vtkActor and set it to one colour. I pass a vtkBooleanOperationPolyDataFilter to the vtkPolyDataMapper and then to the vtkActor. When the vtkActor is rendered, it is not the colour I specified. Instead, it is blue and progressively transitions to red. How do I make it one colour?
Thanks. Any help would be greatly appreciated.
lorensen
(Bill Lorensen)
August 7, 2019, 1:39pm
2
Set ScalarVisibilityOff on your mapper.
at123
(Ken Wiley)
August 7, 2019, 2:07pm
3
Thanks so much! One more question, when I try to render a vtkBooleanOperatonPolyDataFilter using vtkMapper and vtkActor, the render fails and I am given this error:
Segmentation fault (core dumped)
Do you know what this means and how to fix it? Thanks!
lorensen
(Bill Lorensen)
August 7, 2019, 3:39pm
4
It’s hard to tell without seeing the code. Can you supply an example that illustrates the problem?
at123
(Ken Wiley)
August 7, 2019, 3:50pm
5
I have problems with lines 218 and 219. RemoveAllInputs() did not remove the data in port 0 and 1 of vtkBooleanOperationPolyDataFilter. It only removed data in port 0. So I tried to remove data for each port using RemoveAllInputConnections(portNumber) for port 0 and 1. This does the job. I get 0 inputs for both ports. The purpose of the code is to merge multiple volumes created by vtkDelaunay and display them. I get this error:
ERROR: In /work/standalone-x64-build/VTK-source/Filters/General/vtkOBBTree.cxx, line 1058
vtkOBBTree (0x801dfa0): Can’t build OBB tree - no data available!
I don’t know what is wrong and how to fix it. Thanks so much by the way!
code.txt (4.4 KB)
lorensen
(Bill Lorensen)
August 7, 2019, 6:40pm
6
Please post your code and a CMakelist file.
at123
(Ken Wiley)
August 7, 2019, 6:43pm
7
171 orderedContourDict = OrderedDict(sorted(self.reslicers[self.contourOrientation].contours.items()))
172 contourList = []
173 for slice, contour in orderedContourDict.items():
174 contourList.append(contour)
175
176 numberOfContours = len(orderedContourDict)
177 volumePolyDataList = []
178 for i in range(0, numberOfContours - 1):
179 appendPolyData = vtkAppendPolyData()
180 appendPolyData.AddInputData(contourList[i].GetContourRepresentation().GetContourRepresentationAsPolyData())
181 appendPolyData.AddInputData(contourList[i + 1].GetContourRepresentation().GetContourRepresentationAsPolyData())
182 appendPolyData.Update()
183 delaunay = vtkDelaunay3D()
184 delaunay.SetInputData(appendPolyData.GetOutput())
185 surfaceFilter = vtkDataSetSurfaceFilter()
186 surfaceFilter.SetInputConnection(0, delaunay.GetOutputPort())
187 surfaceFilter.Update()
188 polyData = surfaceFilter.GetOutput()
189 volumePolyDataList.append(polyData)
190
191 if len(volumePolyDataList) == 1:
192 delaunay = vtkDelaunay3D()
193 delaunay.SetInputData(volumePolyDataList[0])
194 delaunayMapper = vtkDataSetMapper()
195 delaunayMapper.SetInputConnection(delaunay.GetOutputPort())
196 self.actor.SetMapper(delaunayMapper)
197 self.planes.GetRenderWindow().Render()
198 else:
199 booleanOperation = vtkBooleanOperationPolyDataFilter()
200 booleanOperation1 = vtkBooleanOperationPolyDataFilter()
201 booleanOperation.SetOperationToUnion()
202 booleanOperation1.SetOperationToUnion()
203
204 for i in range(0, len(volumePolyDataList)):
205 if i == 0:
206 booleanOperation.AddInputData(0, volumePolyDataList[i])
207 #booleanOperation.Update()
208 elif i == 1:
209 booleanOperation.AddInputData(1, volumePolyDataList[i])
210 #booleanOperation.Update()
211 elif i == 2:
212 booleanOperation1.AddInputData(0, booleanOperation.GetOutput())
213 booleanOperation1.AddInputData(1, volumePolyDataList[i])
214 #booleanOperation1.Update()
215 else:
216 boolCopy = booleanOperation1.GetOutput()
217 # booleanOperation1.RemoveAllInputs()
218 booleanOperation1.RemoveAllInputConnections(0)
219 booleanOperation1.RemoveAllInputConnections(1)
220 # booleanOperation1.Update()
221 print(booleanOperation.GetNumberOfInputConnections(0), booleanOperation.GetNumberOfInputConnections(1), booleanOpera tion1.GetNumberOfInputConnections(0), booleanOperation1.GetNumberOfInputConnections(1))
222 booleanOperation1.AddInputData(0, boolCopy)
223 booleanOperation1.AddInputData(1, volumePolyDataList[i])
224 #booleanOperation1.Update()
225
226 print(booleanOperation.GetNumberOfInputConnections(0), booleanOperation.GetNumberOfInputConnections(1), booleanOperation1.Ge tNumberOfInputConnections(0), booleanOperation1.GetNumberOfInputConnections(1))
227
228 # print(booleanOperation.GetNumberOfInputConnections(0), booleanOperation.GetNumberOfInputConnections(1), booleanOperatio n1.GetNumberOfInputConnections(0), booleanOperation1.GetNumberOfInputConnections(1))
229
230 mapper = vtkPolyDataMapper()
231 if len(volumePolyDataList) == 2:
232 mapper.SetInputConnection(booleanOperation.GetOutputPort())
233 else:
234 mapper.SetInputConnection(booleanOperation1.GetOutputPort())
235 mapper.ScalarVisibilityOff()
236 self.actor.SetMapper(mapper)
237 self.planes.GetRenderWindow().Render()
238
239 self.reslicers[self.contourOrientation].stopContouring()
240 self.contouring = False
241 self.orientationBox.setEnabled(True)
242 self.startContouringButton.setEnabled(True)
243 self.generateVolumeButton.setEnabled(False)
244 self.cancelContouringButton.setEnabled(False)
245 self.applyButton.setEnabled(True)