class_docstr: Subdivide a triangle mesh by adding a new vertex at the center of each edge
  and dividing each face into four new faces. Vectors of vertex
  attributes can also be subdivided by averaging the values of the attributes
  at the two vertices which form each edge. This implementation
  preserves face orientation - if the vertices of a face are all ordered
  counter-clockwise, then the faces in the subdivided meshes will also have
  their vertices ordered counter-clockwise.
  
  If meshes is provided as an input, the initializer performs the relatively
  expensive computation of determining the new face indices. This one-time
  computation can be reused for all meshes with the same face topology
  but different vertex positions.
class_docstr_tok: ["Subdivide","a","triangle","mesh","by","adding","a","new","vertex","at","the","center","of","each","edge","and","dividing","each","face","into","four","new","faces",".","Vectors","of","vertex","attributes","can","also","be","subdivided","by","averaging","the","values","of","the","attributes","at","the","two","vertices","which","form","each","edge",".","This","implementation","preserves","face","orientation","-","if","the","vertices","of","a","face","are","all","ordered","counter-clockwise",",","then","the","faces","in","the","subdivided","meshes","will","also","have","their","vertices","ordered","counter-clockwise",".","If","meshes","is","provided","as","an","input",",","the","initializer","performs","the","relatively","expensive","computation","of","determining","the","new","face","indices",".","This","one-time","computation","can","be","reused","for","all","meshes","with","the","same","face","topology","but","different","vertex","positions","."]
docstr: Args:
      meshes: a Meshes object.
  
  Returns:
      subdivided_faces_packed: (4*sum(F_n), 3) shape LongTensor of
      original and new faces.
  
  Refer to pytorch3d.structures.meshes.py for more details on packed
  representations of faces.
  
  Each face is split into 4 faces e.g. Input face
  ::
             v0
             /\
            /  \
           /    \
       e1 /      \ e0
         /        \
        /          \
       /            \
      /______________\
    v2       e2       v1
  
    faces_packed = [[0, 1, 2]]
    faces_packed_to_edges_packed = [[2, 1, 0]]
  
  `faces_packed_to_edges_packed` is used to represent all the new
  vertex indices corresponding to the mid-points of edges in the mesh.
  The actual vertex coordinates will be computed in the forward function.
  To get the indices of the new vertices, offset
  `faces_packed_to_edges_packed` by the total number of vertices.
  ::
      faces_packed_to_edges_packed = [[2, 1, 0]] + 3 = [[5, 4, 3]]
  
  e.g. subdivided face
  ::
             v0
             /\
            /  \
           / f0 \
       v4 /______\ v3
         /\      /\
        /  \ f3 /  \
       / f2 \  / f1 \
      /______\/______\
     v2       v5       v1
  
     f0 = [0, 3, 4]
     f1 = [1, 5, 3]
     f2 = [2, 4, 5]
     f3 = [5, 4, 3]
docstr_tok: ["Args",":","meshes",":","a","Meshes","object",".","Returns",":","subdivided_faces_packed",":","(","4","*","sum","(","F_n",")",",","3",")","shape","LongTensor","of","original","and","new","faces",".","Refer","to","pytorch3d.structures.meshes.py","for","more","details","on","packed","representations","of","faces",".","Each","face","is","split","into","4","faces","e.g",".","Input","face",":",":","v0","\/\\","\/","\\","\/","\\","e1","\/","\\","e0","\/","\\","\/","\\","\/","\\","\/______________\\","v2","e2","v1","faces_packed","=","[","[","0",",","1",",","2","]","]","faces_packed_to_edges_packed","=","[","[","2",",","1",",","0","]","]","`","faces_packed_to_edges_packed","`","is","used","to","represent","all","the","new","vertex","indices","corresponding","to","the","mid-points","of","edges","in","the","mesh",".","The","actual","vertex","coordinates","will","be","computed","in","the","forward","function",".","To","get","the","indices","of","the","new","vertices",",","offset","`","faces_packed_to_edges_packed","`","by","the","total","number","of","vertices",".",":",":","faces_packed_to_edges_packed","=","[","[","2",",","1",",","0","]","]","+","3","=","[","[","5",",","4",",","3","]","]","e.g",".","subdivided","face",":",":","v0","\/\\","\/","\\","\/","f0","\\","v4","\/______\\","v3","\/\\","\/\\","\/","\\","f3","\/","\\","\/","f2","\\","\/","f1","\\","\/______\\\/______\\","v2","v5","v1","f0","=","[","0",",","3",",","4","]","f1","=","[","1",",","5",",","3","]","f2","=","[","2",",","4",",","5","]","f3","=","[","5",",","4",",","3","]"]
code: def subdivide_faces(self, meshes):
      r"""
          Args:
              meshes: a Meshes object.
  
          Returns:
              subdivided_faces_packed: (4*sum(F_n), 3) shape LongTensor of
              original and new faces.
  
          Refer to pytorch3d.structures.meshes.py for more details on packed
          representations of faces.
  
          Each face is split into 4 faces e.g. Input face
          ::
                     v0
                     /\
                    /  \
                   /    \
               e1 /      \ e0
                 /        \
                /          \
               /            \
              /______________\
            v2       e2       v1
  
            faces_packed = [[0, 1, 2]]
            faces_packed_to_edges_packed = [[2, 1, 0]]
  
          `faces_packed_to_edges_packed` is used to represent all the new
          vertex indices corresponding to the mid-points of edges in the mesh.
          The actual vertex coordinates will be computed in the forward function.
          To get the indices of the new vertices, offset
          `faces_packed_to_edges_packed` by the total number of vertices.
          ::
              faces_packed_to_edges_packed = [[2, 1, 0]] + 3 = [[5, 4, 3]]
  
          e.g. subdivided face
          ::
                     v0
                     /\
                    /  \
                   / f0 \
               v4 /______\ v3
                 /\      /\
                /  \ f3 /  \
               / f2 \  / f1 \
              /______\/______\
             v2       v5       v1
  
             f0 = [0, 3, 4]
             f1 = [1, 5, 3]
             f2 = [2, 4, 5]
             f3 = [5, 4, 3]
  
          """
      verts_packed = meshes.verts_packed()
      with torch.no_grad():
          faces_packed = meshes.faces_packed()
          faces_packed_to_edges_packed = (
              meshes.faces_packed_to_edges_packed()
              + verts_packed.shape[0]
          )
  
          f0 = torch.stack(
              [
                  faces_packed[:, 0],
                  faces_packed_to_edges_packed[:, 2],
                  faces_packed_to_edges_packed[:, 1],
              ],
              dim=1,
          )
          f1 = torch.stack(
              [
                  faces_packed[:, 1],
                  faces_packed_to_edges_packed[:, 0],
                  faces_packed_to_edges_packed[:, 2],
              ],
              dim=1,
          )
          f2 = torch.stack(
              [
                  faces_packed[:, 2],
                  faces_packed_to_edges_packed[:, 1],
                  faces_packed_to_edges_packed[:, 0],
              ],
              dim=1,
          )
          f3 = faces_packed_to_edges_packed
          subdivided_faces_packed = torch.cat(
              [f0, f1, f2, f3], dim=0
          )  # (4*sum(F_n), 3)
  
          return subdivided_faces_packed
  
file_path: pytorch3d/pytorch3d/ops/subdivide_meshes.py
imports: import torch
  import torch.nn
  from pytorch3d.structures import Meshes
label_desc: Use image node_id 2 for calling the SubdivideMeshes obj's underlying member method code with example usage: obj.subdivide_faces(meshes) and returns: subdivided_faces_packed