简体   繁体   English

使用 vtkSMPTools 的多线程

[英]Multithreading with vtkSMPTools

I want to use vtkSMPTools to run my backend parallel (Python).我想使用vtkSMPTools并行运行我的后端 (Python)。 Sample code is as follows:示例代码如下:

import vtk

# Create an instance of vtkSMPTools
smpTools = vtk.vtkSMPTools()

# Use the For method to iterate over a range of indices in parallel
def func(i):
    # Code to execute in parallel goes here
    print(i)

smpTools.For(0, 100, func)

However, I am getting an error as follows: vtkmodules.vtkCommonCore.vtkSMPTools' object has no attribute 'For' .但是,我收到如下错误: vtkmodules.vtkCommonCore.vtkSMPTools' object has no attribute 'For'

I have checked the vtk documentation and can see For method is defined for vtkSMPTools.我检查了 vtk 文档,可以看到为 vtkSMPTools 定义了For方法。

I am unable to figure out what is the issue.我无法弄清楚是什么问题。 Please help me with this.请帮我解决一下这个。

I am able to import vtk.vtkSMPTools() .我能够导入vtk.vtkSMPTools() However, error comes when I am trying to use the For method.但是,当我尝试使用For方法时出现错误。

I fear vtkSMPTools are not expected to work from python code, as templated methods (like the For method in the c++ code) are not wrappable (see this doc )我担心 vtkSMPTools 预计不会在 python 代码中工作,因为模板化方法(如 C++ 代码中的For方法)不可包装(请参阅此文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM