Skip to content

Commit

Permalink
Border sphere with msms
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinAchondo authored Jun 12, 2024
1 parent 6155f4e commit 862d997
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion xppbe/Mesh/Mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,19 @@ def create_calculate_mesh_data(self):

def create_sphere_mesh(self):
r = self.R_max_dist + self.dR_exterior
self.sphere_mesh = trimesh.creation.icosphere(radius=r, subdivisions=self.density_border)
with open(os.path.join(self.path_files,'sphere.xyzr'),'w') as s_file:
s_file.write(f'0.0 0.0 0.0 {r}\n')
s_file.write(f'0.00001 0.0 0.0 {r*0.0001}')
generate_msms_mesh(os.path.join(self.path_files,'sphere.xyzr'),self.path_files,'sphere_border',self.density_border,1.4)

with open(os.path.join(self.path_files,'sphere_border'+f'_d{self.density_mol}'+'.face'),'r') as face_f:
face = face_f.read()
sph_faces = np.vstack(np.char.split(face.split("\n")[0:-1]))[:, :3].astype(int) - 1
with open(os.path.join(self.path_files,'sphere_border'+f'_d{self.density_mol}'+'.vert'),'r') as vert_f:
vert = vert_f.read()
sph_verts = np.vstack(np.char.split(vert.split("\n")[0:-1]))[:, :3].astype(np.float32)

self.sphere_mesh = trimesh.Trimesh(vertices=sph_verts, faces=sph_faces)
self.sphere_mesh.export(os.path.join(self.path_files,'mesh_sphere'+f'_d{self.density_border}'+'.off'),file_type='off')
self.region_meshes['D2'] = Region_Mesh('trimesh',self.sphere_mesh)

Expand Down

0 comments on commit 862d997

Please sign in to comment.