mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
Meshing: Define meshing with MailleurTT.
This commit is contained in:
1 parent
ad59afc4f5
commit
473aac4500
3 files changed
+62
-3
No files matched your search
@@ -28,7 +28,9 @@ from ctypes import (
|
||||
POINTER, c_void_p,
|
||||
c_int, c_double, c_bool
|
||||
)
|
||||
from PyQt5.QtCore import QProcess
|
||||
|
||||
from tools import logger_color_red, logger_color_reset
|
||||
from Meshing.AMeshingTool import AMeshingTool
|
||||
|
||||
logger = logging.getLogger()
|
||||
@@ -259,3 +261,58 @@ class MeshingWithMage(AMeshingTool):
|
||||
|
||||
logger.debug(f"meshing: Import geometry from {m}")
|
||||
reach.import_geometry(m)
|
||||
|
||||
|
||||
class MeshingWithMageMailleurTT(AMeshingTool):
|
||||
def __init__(self):
|
||||
super(MeshingWithMageMailleurTT, self).__init__()
|
||||
|
||||
@classmethod
|
||||
def _exe_path(cls):
|
||||
ext = "" if os.name == "posix" else ".exe"
|
||||
|
||||
return os.path.abspath(
|
||||
os.path.join(
|
||||
os.path.dirname(__file__),
|
||||
"..", "..", "..", "mage", f"mailleurTT{ext}"
|
||||
)
|
||||
)
|
||||
|
||||
###########
|
||||
# Meshing #
|
||||
###########
|
||||
|
||||
def meshing(self, reach, step: float = 50):
|
||||
if reach is None or len(reach.profiles) == 0:
|
||||
return reach
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
st_file = self.export_reach_to_st(reach, tmp)
|
||||
m_file = st_file.rsplit(".ST", 1)[0] + ".M"
|
||||
|
||||
proc = QProcess()
|
||||
proc.setWorkingDirectory(tmp)
|
||||
|
||||
proc.start(
|
||||
self._exe_path(), [st_file, m_file, str(step)]
|
||||
)
|
||||
proc.waitForFinished()
|
||||
|
||||
errors = str(proc.readAllStandardError())
|
||||
if len(errors) != 0:
|
||||
logger.error(f"{logger_color_red()}{errors}{logger_color_reset()}")
|
||||
else:
|
||||
self.import_m_file(reach, m_file)
|
||||
return reach
|
||||
|
||||
def export_reach_to_st(self, reach, tmp):
|
||||
tmp_st = os.path.join(tmp, "meshing.ST")
|
||||
|
||||
logger.debug(f"meshing: Export ST to {tmp_st}")
|
||||
|
||||
reach.export_reach(tmp_st)
|
||||
return tmp_st
|
||||
|
||||
def import_m_file(self, reach, m):
|
||||
logger.debug(f"meshing: Import geometry from {m}")
|
||||
reach.import_geometry(m)
|
||||
Reference in new issue
Block a user