mirror of https://gitlab.com/pamhyr/pamhyr2
Meshing: Define meshing with MailleurTT.
parent
ad59afc4f5
commit
473aac4500
|
|
@ -27,7 +27,7 @@ stages:
|
|||
#############
|
||||
|
||||
variables:
|
||||
MAGE_VERSION: "v8.3.4"
|
||||
MAGE_VERSION: "v8.3.3"
|
||||
|
||||
dl-mage-linux:
|
||||
stage: downloads
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -46,7 +46,9 @@ from View.Tools.PamhyrWindow import PamhyrWindow
|
|||
from View.Tools.Plot.PamhyrToolbar import PamhyrPlotToolbar
|
||||
from View.Tools.Plot.PamhyrCanvas import MplCanvas
|
||||
|
||||
from Meshing.Mage import MeshingWithMage
|
||||
from Meshing.Mage import (
|
||||
MeshingWithMage, MeshingWithMageMailleurTT
|
||||
)
|
||||
|
||||
from View.Geometry.Table import GeometryReachTableModel
|
||||
from View.Geometry.PlotXY import PlotXY
|
||||
|
|
@ -264,7 +266,7 @@ class GeometryWindow(PamhyrWindow):
|
|||
|
||||
def _edit_meshing(self):
|
||||
try:
|
||||
mesher = MeshingWithMage()
|
||||
mesher = MeshingWithMageMailleurTT()
|
||||
self._table.meshing(mesher, -1)
|
||||
except Exception as e:
|
||||
logger_exception(e)
|
||||
|
|
|
|||
Loading…
Reference in New Issue