remove dead code and simplify read_triangle
@@ -6,7 +6,7 @@ import os
import numpy
-def readVertex(filename, REAL):
+def read_vertex(filename, REAL):
"""
It reads the vertex of the triangles from the mesh file and it stores
them on an array.
@@ -32,49 +32,7 @@ def readVertex(filename, REAL):
return vertex
-def readVertex2(filename, REAL):
- """
- It reads the vertex of the triangles from the mesh file and it stores
- them on an array.
- It reads the file line by line.
-
- Arguments
- ----------
- filename: name of the file that contains the surface information.
- (filename.vert)
- REAL : data type.
-
- Returns
- -------
- vertex: array, vertices of the triangles.
- """
-
- x = []
- y = []
- z = []
- with open(filename, 'r') as f:
- lines = f.readlines()
- for line in lines:
- line = line.split()
- x0 = line[0]
- y0 = line[1]
- z0 = line[2]
- x.append(REAL(x0))
- y.append(REAL(y0))
- z.append(REAL(z0))
-
- x = numpy.array(x)
- y = numpy.array(y)
- z = numpy.array(z)
- vertex = numpy.zeros((len(x), 3))
- vertex[:, 0] = x
- vertex[:, 1] = y
- vertex[:, 2] = z
-
- return vertex
-
-
-def readTriangle(filename, surf_type):
+def read_triangle(filename, surf_type):
"""
It reads the triangles from the mesh file and it stores them on an
array.
@@ -95,58 +53,17 @@ def readTriangle(filename, surf_type):
if geo_path:
full_path = geo_path
X = numpy.loadtxt(os.path.join(full_path, filename), dtype=int)
- triangle = numpy.zeros((len(X), 3), dtype=int)
- # if surf_type<=10:
if surf_type == 'internal_cavity':
- triangle[:, 0] = X[:, 0]
- triangle[:, 1] = X[:, 1]
- triangle[:, 2] = X[:, 2]
+ triangle = X[:, :3]
else:
- triangle[:, 0] = X[:, 0]
- triangle[:,
- 1] = X[:, 2
- ] # v2 and v3 are flipped to match my sign convention!
- triangle[:, 2] = X[:, 1]
+ # v2 and v3 are flipped to match my sign convention!
+ triangle = X[:, (0, 2, 1)]
triangle -= 1
return triangle
-def readTriangle2(filename):
- """
- It reads the triangles from the mesh file and it stores them on an
- array.
- It reads the file line by line.
-
- Arguments
- ----------
- filename : name of the file that contains the surface information.
- (filename.faces)
-
- Returns
- -------
- triangle: array, triangles indices.
- """
-
- triangle = []
-
- with open(filename, 'r') as f:
- lines = f.readlines()
- for line in lines:
- line = line.split()
- v1 = line[0]
- v2 = line[2] # v2 and v3 are flipped to match my sign convention!
- v3 = line[1]
- triangle.append([int(v1) - 1, int(v2) - 1, int(v3) - 1])
- # -1-> python starts from 0, matlab from 1
-
- triangle = numpy.array(triangle)
-
- return triangle
-
-
-
def readCheck(aux, REAL):
"""
It checks if it is not reading more than one term.
