使用vtk执行光线投射的python包

pycaster的Python项目详细描述


wercker status

背景

pycaster是一个简单的单模块包(模块也称为 pycaster)包含一个rayCaster类。这个类允许 对于要在由 “vtkpolydata”对象。

rayCaster类充当vtkOBBTree类的包装器 并使用执行光线投射。它可以计算 射线和表面之间的出入点。它还可以 计算光线在 表面,即固体内部。

该类具有一个静态方法“fromstl”,它允许 直接从加载并提取 来自初始化光线投射器的polydata。

文档

由于其 简单。

示例:ipython笔记本

两本ipython笔记本演示了 pycaster在stl模型上:

  • 演示在stl模型上使用pycaster的笔记本 可以找到一个空心球 here (STL文件可用时 here)。
  • 与上述非常相似的笔记本,唯一的例外是 从ct数据中提取人颅骨stl模型的操作 可以找到 here 当相应的stl文件可用时 here

用法示例

简而言之,使用pycaster的shell将如下所示:

from pycaster import pycaster

# Create a new rayCaster object through the 'fromSTL' static-method thus loading
# the STL file 'sphereHollow.stl' and creating a new rayCaster under 'caster'
caster = pycaster.rayCaster.fromSTL("sphereHollow.stl", scale=1.0)

# Set the source and target coordinate of the ray
pSource = [-50.0, 0.0, 0.0]
pTarget = [50.0, 0.0, 0.0]

# Use the 'castRay' method of the 'rayCaster' class to intersect a ray/line with
# the surface and return a list of coordinates, i.e., the intersection points
pointsIntersection = caster.castRay(pSource, pTarget)

# Use the calcDistanceInSolid to calculate the distance the ray 'travels' within
# the surface
caster.calcDistanceInSolid(pSource, pTarget)

要求

vtk>;=5.10.1鼻子>;=1.3.3

python 3.x支持

在编写^{tt1}时,$无法使用python 3.x作为 VTK Python绑定尚未移植到Python3.x。 pycaster已经用不同的python 2.7.x进行了广泛的测试 版本。

安装

此包已托管在pypi上 here而且很容易 通过PIP安装:

pip install pycaster

或者直接使用setuptools作为源代码:

python setup.py install

但是,给定vtkpycaster需求,而不是 始终使用PIP轻松构建我强烈建议如下:

  • 使用anaconda python发行版。我写了一篇关于 它提供的优势 here
  • 使用conda安装依赖项(请参阅前面的文章)
  • 使用pip安装pycaster,同时跳过依赖项 例如:
pip install pycaster --no-deps

测试&ci

pycaster附带用unittest和 使用nose执行批处理。发行版还附带了几个 .stl文件,用于测试包的不同方面。之后 安装您可以在python会话中轻松运行这些测试 使用以下代码:

from pycaster.test import test_all
test_all.runTests()

pycaster的每个提交都是在 Werckerci系统。申请是公开的 可以通过点击 本页顶部或整个 this 链接。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何在jetty请求日志中添加milliscond字段?   java在使用Scanner类从文件读取信息时遇到问题   为什么。类不适用于泛型类型?   SQLite插入上的java空指针异常   java能告诉我们Guava缓存是在禁用统计数据的情况下构建的吗?   java在应用程序中使用常量   java无法使用AutoIT和Selenium Webdriver在所需位置/文件夹保存图像   java如何在jtable中更新jprogress栏   java是比较给定日期和当前日期(在给定时区中没有时间段)的最佳方法   安卓代码中的java错误   java无法访问实体类中的字段   java如何在tomcat中处理三个JDBC连接池?   java无法使用Spring Security保护AngularJS页面   如何在没有TCP/IP协议栈的情况下用Java发送以太帧