本文整理汇总了Python中meshpy.tet.MeshInfo类的典型用法代码示例。如果您正苦于以下问题:Python MeshInfo类的具体用法?Python MeshInfo怎么用?Python MeshInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MeshInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: generate_Preview
def generate_Preview():
bpy.ops.object.mode_set(mode = 'OBJECT', toggle = False)
config = bpy.context.scene.CONFIG_MeshPy
vertList = []
faceList = []
meshPoints = []
meshFacets = []
split_faceList = []
split_vertList = []
ob = bpy.context.active_object
obname = ob.name
#compute mesh
compute_vertices(ob, meshPoints)
compute_polygones(ob, meshFacets)
if config.make_subdivision == False:
arg = "Y"
else:
arg = ""
mesh_info = MeshInfo()
mesh_info.set_points(meshPoints)
mesh_info.set_facets(meshFacets)
print(meshPoints)
print(meshFacets)
#args = ("pq" + str(config.ratio_quality) + "a" + str(config.ratio_maxsize) + str(arg))
'''
示例2: make_cylinder_mesh
def make_cylinder_mesh(radius=0.5, height=1, radial_subdivisions=10,
height_subdivisions=1, max_volume=None, periodic=False,
boundary_tagger=(lambda fvi, el, fn, all_v: [])):
from meshpy.tet import MeshInfo, build
from meshpy.geometry import make_cylinder
points, facets, facet_holestarts, facet_markers = \
make_cylinder(radius, height, radial_subdivisions,
height_subdivisions)
assert len(facets) == len(facet_markers)
if periodic:
return _make_z_periodic_mesh(
points, facets, facet_holestarts, facet_markers,
height=height,
max_volume=max_volume,
boundary_tagger=boundary_tagger)
else:
mesh_info = MeshInfo()
mesh_info.set_points(points)
mesh_info.set_facets_ex(facets, facet_holestarts, facet_markers)
generated_mesh = build(mesh_info, max_volume=max_volume)
from hedge.mesh import make_conformal_mesh_ext
from hedge.mesh.element import Tetrahedron
vertices = numpy.asarray(generated_mesh.points, dtype=float, order="C")
return make_conformal_mesh_ext(
vertices,
[Tetrahedron(i, el_idx, vertices)
for i, el_idx in enumerate(generated_mesh.elements)],
boundary_tagger)
示例3: mesh
def mesh(self):
mesh_info = MeshInfo()
mesh_info.set_points(transpose([self.flat_x,self.flat_y,self.flat_z]))
mesh = build(mesh_info)
print 'yo'
for i, t in enumerate(mesh.elements):
print i, t
示例4: generateCubeMesh
def generateCubeMesh():
mesh_info = MeshInfo()
mesh_info.set_points([
(0, 0, 0), (1, 0, 0), (1, 1, 0), (0, 1, 0),
(0, 0, 1), (1, 0, 1), (1, 1, 1), (0, 1, 1),
])
mesh_info.set_facets([
[0, 1, 2, 3],
[4, 5, 6, 7],
[0, 4, 5, 1],
[1, 5, 6, 2],
[2, 6, 7, 3],
[3, 7, 4, 0],
])
mesh = build(mesh_info)
cellList = []
vertexList = []
mupifMesh = Mesh.UnstructuredMesh()
print("Mesh Points:")
for i, p in enumerate(mesh.points):
print(i, p)
vertexList.extend([Vertex.Vertex(i, i, p)])
print("Point numbers in tetrahedra:")
for i, t in enumerate(mesh.elements):
print(i, t)
cellList.extend([Cell.Tetrahedron_3d_lin(mupifMesh, i, i, t)])
mupifMesh.setup(vertexList, cellList)
return(mupifMesh)
示例5: make_inverse_mesh_info
def make_inverse_mesh_info(rz, radial_subdiv):
# chop off points with zero radius
while rz[0][0] == 0:
rz.pop(0)
while rz[-1][0] == 0:
rz.pop(-1)
# construct outer cylinder
((min_r, max_r), (min_z, max_z)) = bounding_box(rz)
if rz[0][1] < rz[-1][1]:
# built in positive z direction
rz.extend([
(max_r+2, max_z),
(max_r+2, min_z),
])
else:
rz.extend([
(max_r+2, min_z),
(max_r+2, max_z),
])
from meshpy.tet import MeshInfo
from meshpy.geometry import EXT_CLOSED_IN_RZ, \
generate_surface_of_revolution
points, facets, facet_holestarts, facet_markers = \
generate_surface_of_revolution(rz, closure=EXT_CLOSED_IN_RZ,
radial_subdiv=radial_subdiv)
mesh_info = MeshInfo()
mesh_info.set_points(points)
mesh_info.set_facets_ex(facets, facet_holestarts, facet_markers)
return mesh_info
示例6: test_tetgen
def test_tetgen():
from meshpy.tet import MeshInfo, build
mesh_info = MeshInfo()
mesh_info.set_points([
(0, 0, 0),
(2, 0, 0),
(2, 2, 0),
(0, 2, 0),
(0, 0, 12),
(2, 0, 12),
(2, 2, 12),
(0, 2, 12),
])
mesh_info.set_facets([
[0, 1, 2, 3],
[4, 5, 6, 7],
[0, 4, 5, 1],
[1, 5, 6, 2],
[2, 6, 7, 3],
[3, 7, 4, 0],
])
build(mesh_info)
示例7: main
def main():
from math import pi, cos, sin
from meshpy.tet import MeshInfo, build
from meshpy.geometry import generate_surface_of_revolution,\
EXT_CLOSED_IN_RZ, GeometryBuilder
big_r = 3
little_r = 2.9
points = 50
dphi = 2*pi/points
rz = [(big_r+little_r*cos(i*dphi), little_r*sin(i*dphi))
for i in range(points)]
geob = GeometryBuilder()
geob.add_geometry(*generate_surface_of_revolution(rz,
closure=EXT_CLOSED_IN_RZ, radial_subdiv=20))
mesh_info = MeshInfo()
geob.set(mesh_info)
mesh_info.save_nodes("torus")
mesh_info.save_poly("torus")
mesh = build(mesh_info)
mesh.write_vtk("torus.vtk")
mesh.save_elements("torus_mesh")
mesh.save_nodes("torus_mesh")
mesh.write_neu(file("torus.neu", "w"),
{1: ("pec", 0)})
示例8: create_beam
def create_beam(vol):
# build using MeshPy
from meshpy.tet import MeshInfo,build
mesh_info = MeshInfo()
mesh_info.set_points([
(0,0,0),
(0,1,0),
(0,1,1),
(0,0,1),
(5,0,0),
(5,1,0),
(5,1,1),
(5,0,1),
])
mesh_info.set_facets([
[0,1,2,3],
[4,5,6,7],
[0,1,5,4],
[1,2,6,5],
[0,3,7,4],
[3,2,6,7],
])
mesh = build(mesh_info,max_volume=vol)
return fmsh.MeshPyTet(mesh)
示例9: main
def main():
#Test1: mesh testing
MeshPoints = []
MeshFacets = []
with open('MeshFacets', 'rb') as input:
MeshFacets = pickle.load(input)
with open('MeshPoints', 'rb') as input:
MeshPoints = pickle.load(input)
mesh_info = MeshInfo()
mesh_info.regions.resize(1)
mesh_info.regions[0] = [
MeshPoints[0][0], MeshPoints[0][1], MeshPoints[0][2], # point in volume -> first box
0, # region tag (user-defined number)
1, # max tet volume in region
]
print "Building mesh from {} facets and {} points".format(len(MeshFacets), len(MeshPoints))
try:
mesh = build(mesh_info, options=Options(switches="pqT", epsilon=0.01), volume_constraints=True)
except:
pass
try:
mesh = build(mesh_info, options=Options(switches="pqT", epsilon=0.0001), volume_constraints=True)
except:
pass
print "Created mesh with {} points, {} faces and {} elements.".format(len(mesh.points), len(mesh.faces), len(mesh.elements))
示例10: main
def main():
mesh_info = MeshInfo()
mesh_info.set_points([
(0, 0, 0),
(2, 0, 0),
(2, 2, 0),
(0, 2, 0),
(0, 0, 12),
(2, 0, 12),
(2, 2, 12),
(0, 2, 12),
])
mesh_info.set_facets([
[0, 1, 2, 3],
[4, 5, 6, 7],
[0, 4, 5, 1],
[1, 5, 6, 2],
[2, 6, 7, 3],
[3, 7, 4, 0],
])
mesh_info.save_nodes("bar")
mesh_info.save_poly("bar")
mesh = build(mesh_info)
mesh.save_nodes("barout")
mesh.save_elements("barout")
mesh.save_faces("barout")
mesh.write_vtk("test.vtk")
示例11: brep2lar
def brep2lar(larBrep):
V,FV = larBrep
mesh_info = MeshInfo()
mesh_info.set_points(V)
mesh_info.set_facets(FV)
mesh = build(mesh_info)
W = [v for h,v in enumerate(mesh.points)]
CW = [tet for k,tet in enumerate(mesh.elements)]
FW = sorted(set(AA(tuple)(CAT(AA(faces)(CW)))))
EW = sorted(set(AA(tuple)(CAT(AA(edges)(FW)))))
return W,CW,FW,EW
示例12: test_tetgen_points
def test_tetgen_points():
from meshpy.tet import MeshInfo, build, Options
import numpy as np
points = np.random.randn(10000, 3)
mesh_info = MeshInfo()
mesh_info.set_points(points)
options = Options("")
mesh = build(mesh_info, options=options)
print(len(mesh.points))
print(len(mesh.elements))
示例13: make_mesh_info
def make_mesh_info(rz, radial_subdiv):
from meshpy.tet import MeshInfo
from meshpy.geometry import EXT_OPEN, generate_surface_of_revolution
points, facets, facet_holestarts, facet_markers = \
generate_surface_of_revolution(rz, closure=EXT_OPEN,
radial_subdiv=radial_subdiv)
mesh_info = MeshInfo()
mesh_info.set_points(points)
mesh_info.set_facets_ex(facets, facet_holestarts, facet_markers)
return mesh_info
示例14: _make_z_periodic_mesh
def _make_z_periodic_mesh(points, facets, facet_holestarts, facet_markers, height,
max_volume, boundary_tagger):
from meshpy.tet import MeshInfo, build
from meshpy.geometry import Marker
mesh_info = MeshInfo()
mesh_info.set_points(points)
mesh_info.set_facets_ex(facets, facet_holestarts, facet_markers)
mesh_info.pbc_groups.resize(1)
pbcg = mesh_info.pbc_groups[0]
pbcg.facet_marker_1 = Marker.MINUS_Z
pbcg.facet_marker_2 = Marker.PLUS_Z
pbcg.set_transform(translation=[0, 0, height])
def zper_boundary_tagger(fvi, el, fn, all_v):
# we only ask about *boundaries*
# we should not try to have the user tag
# the (periodicity-induced) interior faces
face_marker = fvi2fm[frozenset(fvi)]
if face_marker == Marker.MINUS_Z:
return ["minus_z"]
if face_marker == Marker.PLUS_Z:
return ["plus_z"]
result = boundary_tagger(fvi, el, fn, all_v)
if face_marker == Marker.SHELL:
result.append("shell")
return result
generated_mesh = build(mesh_info, max_volume=max_volume)
fvi2fm = generated_mesh.face_vertex_indices_to_face_marker
from hedge.mesh import make_conformal_mesh_ext
from hedge.mesh.element import Tetrahedron
vertices = numpy.asarray(generated_mesh.points, dtype=float, order="C")
return make_conformal_mesh_ext(
vertices,
[Tetrahedron(i, el_idx, vertices)
for i, el_idx in enumerate(generated_mesh.elements)],
zper_boundary_tagger,
periodicity=[None, None, ("minus_z", "plus_z")])
示例15: main
def main():
from ply import parse_ply
import sys
data = parse_ply(sys.argv[1])
from meshpy.geometry import GeometryBuilder
builder = GeometryBuilder()
builder.add_geometry(
points=[pt[:3] for pt in data["vertex"].data],
facets=[fd[0] for fd in data["face"].data])
builder.wrap_in_box(1)
from meshpy.tet import MeshInfo, build
mi = MeshInfo()
builder.set(mi)
mi.set_holes([builder.center()])
mesh = build(mi)
print("%d elements" % len(mesh.elements))
mesh.write_vtk("out.vtk")