简体   繁体   English

从Mayavi的切割平面检索线

[英]Retrieve the lines from a cutplane in mayavi

How can I retrieve the lines from a cutplane in mayavi? 如何从Mayavi的切割平面检索线?

I've been able to retrieve the points, but I don't have the information about conectivity. 我已经能够检索这些点,但是我没有有关连接性的信息。

cutplane.cutter.outputs[0].points.to_array()

You have found the points coordinates: 您已经找到了点坐标:

  PtsCoord = cutplane.cutter.outputs[0].points.to_array()

You can also find something called polys.to_array(). 您还可以找到名为polys.to_array()的东西。 Maybe here : 也许在这里:

  PolyAndTriIDs = cutplane.cutter.outputs[0].polys.to_array() 

This variable contains indexes of points that form triangles and polygons, then you can extract all coordinates with these lines: 此变量包含形成三角形和多边形的点的索引,然后可以使用这些线提取所有坐标:

  jj=0
  while (jj < PolyAndTriIDs.shape[0]):
    if PolyAndTriIDs[jj] == 3:  # triangles

      x1,y1,z1 = PtsCoord[PolyAndTriIDs[jj+1],:]
      x2,y2,z2 = PtsCoord[PolyAndTriIDs[jj+2],:]
      x3,y3,z3 = PtsCoord[PolyAndTriIDs[jj+3],:]
      jj=jj+4

    else: # quadrilateral
      x1,y1,z1 = PtsCoord[PolyAndTriIDs[jj+1],:]
      x2,y2,z2 = PtsCoord[PolyAndTriIDs[jj+2],:]
      x3,y3,z3 = PtsCoord[PolyAndTriIDs[jj+3],:]
      x4,y4,z4 = PtsCoord[PolyAndTriIDs[jj+4],:]
      jj=jj+5

HTH HTH

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

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