parameters: (klampt_mesh)
return_statement: return ros_mesh
docstring: From a Klampt Geometry3D or TriangleMesh to a ROS Mesh
docstring_summary: From a Klampt Geometry3D or TriangleMesh to a ROS Mesh
docstring_tokens: From a Klampt Geometry3D or TriangleMesh to a ROS Mesh
function: def to_Mesh(klampt_mesh):
      """From a Klampt Geometry3D or TriangleMesh to a ROS Mesh"""
      from klampt import Geometry3D,TriangleMesh
      from shape_msgs.msg import MeshTriangle
      if isinstance(klampt_mesh,Geometry3D):
          mesh = klampt_mesh.getTriangleMesh()
          T = klampt_mesh.getCurrentTransform()
          if T != se3.identity():
              mesh.transform(*T)
          klampt_mesh = mesh
      ros_mesh = Mesh()
      for i in xrange(len(klampt_mesh.vertices)//3):
          k = i*3
          ros_mesh.vertices.append(Vector3(klampt_mesh.vertices[k],klampt_mesh.vertices[k+1],klampt_mesh.vertices[k+2]))
      for i in xrange(len(klampt_mesh.indices)//3):
          k = i*3
          ros_mesh.triangles.append(MeshTriangle([klampt_mesh.indices[k],klampt_mesh.indices[k+1],klampt_mesh.indices[k+2]]))
      return ros_mesh
function_tokens: def to_Mesh ( klampt_mesh ) : from klampt import Geometry3D , TriangleMesh from shape_msgs . msg import MeshTriangle if isinstance ( klampt_mesh , Geometry3D ) : mesh = klampt_mesh . getTriangleMesh ( ) T = klampt_mesh . getCurrentTransform ( ) if T != se3 . identity ( ) : mesh . transform ( * T ) klampt_mesh = mesh ros_mesh = Mesh ( ) for i in xrange ( len ( klampt_mesh . vertices ) // 3 ) : k = i * 3 ros_mesh . vertices . append ( Vector3 ( klampt_mesh . vertices [ k ] , klampt_mesh . vertices [ k + 1 ] , klampt_mesh . vertices [ k + 2 ] ) ) for i in xrange ( len ( klampt_mesh . indices ) // 3 ) : k = i * 3 ros_mesh . triangles . append ( MeshTriangle ( [ klampt_mesh . indices [ k ] , klampt_mesh . indices [ k + 1 ] , klampt_mesh . indices [ k + 2 ] ] ) ) return ros_mesh