简体   繁体   中英

How to get area of a mesh?

How to get area of a mesh if subdivided into triangle?

I found the cross product for each triangle and computed the area.The area is coming wrong according to blender.I have looked up stack flow other posts but they are not of any help.Could you help me to figure out why I am get a low area of 16.3 something for my mesh.


 for i in f:
   # print("i",i)
    for k in i:
    # print("k",k)
     for j in z:
     # print("z",z)

      if (k==z.index(j)):


        f_v.append(j)
   # print(f_v)

    v0=np.array(f_v[0])
    v1=np.array(f_v[1])
    v2=np.array(f_v[2])

    ax=np.subtract(f_v[1],f_v[0])
    ax=np.subtract(f_v[2],f_v[1])
    ay=np.subtract(f_v[3],f_v[1])
   ..

    cxx=np.power(cx,2)
 #   cyy=np.power(ay,2)
    #czz=np.power(cz,2)

I've created meshplex to help you with this kind of tasks, and do it quickly. Simply load the mesh and sum up the cell volumes:

import meshplex

points = numpy.array([[0.0, 0.0, 0.0], [1.0, 0.0, 0.0], [0.0, 1.0, 0.0]])
cells = numpy.array([[0, 1, 2]])
mesh = meshplex.MeshTri(points, cells)
# or read it from a file
# mesh = meshplex.read("circle.vtk")

print(numpy.sum(mesh.cell_volumes))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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