Ejemplo n.º 1
0
def linesBody(mb, bodyName, successorJointsName):
  """
  Return a mesh represented by lines and the appropriate static transform.
  """
  apd = tvtk.AppendPolyData()
  sources = []

  # create a line from the body base to the next joint
  for s in map(mb.jointIndexByName, successorJointsName[bodyName]):
    X_s = mb.transform(s)
    sources.append(tvtk.LineSource(point1=(0., 0., 0.),
                                   point2=tuple(X_s.translation())))

  # add an empty source to avoid a warning if AppendPolyData have 0 source
  if len(sources) == 0:
    sources.append(tvtk.PointSource(radius=0.))

  map(lambda s: apd.add_input(s.output), sources)
  apd.update()

  pdm = tvtk.PolyDataMapper()
  pdm.input_connection = apd.output_port
  actor = tvtk.Actor(mapper=pdm)
  actor.property.color = (0., 0., 0.)
  actor.user_transform = tvtk.Transform()

  return actor, sva.PTransformd.Identity()
Ejemplo n.º 2
0
 def _mode_changed(self):
     v = self._target
     # Workaround for different version of VTK:
     if hasattr(v.glyph.glyph_source, 'glyph_source'):
         g = v.glyph.glyph_source
     else:
         g = v.glyph
     if self.mode == 'point':
         g.glyph_source = tvtk.PointSource(radius=0, number_of_points=1)
     else:
         g.glyph_source = g.glyph_list[self.mode_]
     if self.mode_ == 0:
         g.glyph_source.glyph_type = self.mode[2:]
Ejemplo n.º 3
0
 def __source_dict_default(self):
     """Default value for source dict."""
     sd = {
         'arrow': tvtk.ArrowSource(),
         'cone': tvtk.ConeSource(),
         'cube': tvtk.CubeSource(),
         'cylinder': tvtk.CylinderSource(),
         'disk': tvtk.DiskSource(),
         'earth': tvtk.EarthSource(),
         'line': tvtk.LineSource(),
         'outline': tvtk.OutlineSource(),
         'plane': tvtk.PlaneSource(),
         'point': tvtk.PointSource(),
         'polygon': tvtk.RegularPolygonSource(),
         'sphere': tvtk.SphereSource(),
         'superquadric': tvtk.SuperquadricSource(),
         'textured sphere': tvtk.TexturedSphereSource(),
         'glyph2d': tvtk.GlyphSource2D()
     }
     return sd