Pymeshit 0.2.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. pymeshit-0.2.4/LICENSE +26 -0
  2. pymeshit-0.2.4/MANIFEST.in +30 -0
  3. pymeshit-0.2.4/PKG-INFO +124 -0
  4. pymeshit-0.2.4/Pymeshit/__init__.py +228 -0
  5. pymeshit-0.2.4/Pymeshit/core/__init__.py +93 -0
  6. pymeshit-0.2.4/Pymeshit/intersection_utils.py +3974 -0
  7. pymeshit-0.2.4/Pymeshit/tetra_mesh_utils.py +1051 -0
  8. pymeshit-0.2.4/Pymeshit/triangle_direct.py +721 -0
  9. pymeshit-0.2.4/Pymeshit.egg-info/PKG-INFO +124 -0
  10. pymeshit-0.2.4/Pymeshit.egg-info/SOURCES.txt +65 -0
  11. pymeshit-0.2.4/Pymeshit.egg-info/dependency_links.txt +1 -0
  12. pymeshit-0.2.4/Pymeshit.egg-info/entry_points.txt +2 -0
  13. pymeshit-0.2.4/Pymeshit.egg-info/requires.txt +7 -0
  14. pymeshit-0.2.4/Pymeshit.egg-info/top_level.txt +3 -0
  15. pymeshit-0.2.4/Pymeshit_workflow_gui.py +16290 -0
  16. pymeshit-0.2.4/README.md +93 -0
  17. pymeshit-0.2.4/main.py +48 -0
  18. pymeshit-0.2.4/pyproject.toml +52 -0
  19. pymeshit-0.2.4/resources/MeshIT.qrc +48 -0
  20. pymeshit-0.2.4/resources/images/1D.png +0 -0
  21. pymeshit-0.2.4/resources/images/2D.png +0 -0
  22. pymeshit-0.2.4/resources/images/3D.png +0 -0
  23. pymeshit-0.2.4/resources/images/abaqus.png +0 -0
  24. pymeshit-0.2.4/resources/images/app_logo.icns +0 -0
  25. pymeshit-0.2.4/resources/images/app_logo.png +0 -0
  26. pymeshit-0.2.4/resources/images/app_logo_small.png +0 -0
  27. pymeshit-0.2.4/resources/images/blue.png +0 -0
  28. pymeshit-0.2.4/resources/images/borders.png +0 -0
  29. pymeshit-0.2.4/resources/images/camera.png +0 -0
  30. pymeshit-0.2.4/resources/images/close.png +0 -0
  31. pymeshit-0.2.4/resources/images/comsol.png +0 -0
  32. pymeshit-0.2.4/resources/images/faults.png +0 -0
  33. pymeshit-0.2.4/resources/images/feflow.png +0 -0
  34. pymeshit-0.2.4/resources/images/holeAll.png +0 -0
  35. pymeshit-0.2.4/resources/images/holeBucket.png +0 -0
  36. pymeshit-0.2.4/resources/images/holeMulti.png +0 -0
  37. pymeshit-0.2.4/resources/images/holePolygon.png +0 -0
  38. pymeshit-0.2.4/resources/images/holeSingle.png +0 -0
  39. pymeshit-0.2.4/resources/images/line.png +0 -0
  40. pymeshit-0.2.4/resources/images/loading.gif +0 -0
  41. pymeshit-0.2.4/resources/images/markAll.png +0 -0
  42. pymeshit-0.2.4/resources/images/markBucket.png +0 -0
  43. pymeshit-0.2.4/resources/images/markMulti.png +0 -0
  44. pymeshit-0.2.4/resources/images/markPolygon.png +0 -0
  45. pymeshit-0.2.4/resources/images/markSingle.png +0 -0
  46. pymeshit-0.2.4/resources/images/mesh.png +0 -0
  47. pymeshit-0.2.4/resources/images/meshitlogo.png +0 -0
  48. pymeshit-0.2.4/resources/images/moose.png +0 -0
  49. pymeshit-0.2.4/resources/images/ogs.png +0 -0
  50. pymeshit-0.2.4/resources/images/open.png +0 -0
  51. pymeshit-0.2.4/resources/images/paraview.png +0 -0
  52. pymeshit-0.2.4/resources/images/red.png +0 -0
  53. pymeshit-0.2.4/resources/images/save.png +0 -0
  54. pymeshit-0.2.4/resources/images/saveAs.png +0 -0
  55. pymeshit-0.2.4/resources/images/tetrahedron.png +0 -0
  56. pymeshit-0.2.4/resources/images/triangle.png +0 -0
  57. pymeshit-0.2.4/resources/images/units.png +0 -0
  58. pymeshit-0.2.4/resources/images/unmarkAll.png +0 -0
  59. pymeshit-0.2.4/resources/images/unmarkBucket.png +0 -0
  60. pymeshit-0.2.4/resources/images/unmarkMulti.png +0 -0
  61. pymeshit-0.2.4/resources/images/unmarkPolygon.png +0 -0
  62. pymeshit-0.2.4/resources/images/unmarkSingle.png +0 -0
  63. pymeshit-0.2.4/resources/images/wells.png +0 -0
  64. pymeshit-0.2.4/resources/images/white.png +0 -0
  65. pymeshit-0.2.4/resources/images/yellow.png +0 -0
  66. pymeshit-0.2.4/setup.cfg +4 -0
  67. pymeshit-0.2.4/tests/test_imports.py +12 -0
pymeshit-0.2.4/LICENSE ADDED
@@ -0,0 +1,26 @@
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+ This is the GNU General Public License version 3 (GPLv3).
9
+
10
+ You can find the full text of GPLv3 at: https://www.gnu.org/licenses/gpl-3.0.html
11
+
12
+ The GNU General Public License is a free, copyleft license for software and other kinds of works.
13
+
14
+ Key points:
15
+ - Freedom to run the program as you wish, for any purpose
16
+ - Freedom to study how the program works, and change it so it does your computing as you wish
17
+ - Freedom to redistribute copies so you can help your neighbor
18
+ - Freedom to distribute copies of your modified versions to others
19
+
20
+ This program is distributed in the hope that it will be useful,
21
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
22
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
+ GNU General Public License for more details.
24
+
25
+ You should have received a copy of the GNU General Public License
26
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
@@ -0,0 +1,30 @@
1
+ include README.md
2
+ include main.py
3
+ include Pymeshit_workflow_gui.py
4
+ recursive-include resources *
5
+ recursive-include Pymeshit *.py
6
+
7
+ exclude bin/*
8
+ exclude debug_plc/*
9
+ exclude doc/*
10
+ exclude github/*
11
+ exclude include/*
12
+ exclude release/*
13
+ exclude src/*
14
+ exclude *.pyd
15
+ exclude *.so
16
+ exclude *.dll
17
+ exclude *.exe
18
+ exclude *.o
19
+ exclude *.obj
20
+ exclude *.lib
21
+ exclude *.exp
22
+ exclude *.cpp
23
+ exclude *.c
24
+ exclude *.h
25
+ exclude *.cxx
26
+ exclude *.rc
27
+ exclude *.qrc
28
+ exclude *.stl
29
+ exclude _skipped.*
30
+ exclude tetgen-tmpfile*
@@ -0,0 +1,124 @@
1
+ Metadata-Version: 2.4
2
+ Name: Pymeshit
3
+ Version: 0.2.4
4
+ Summary: Complete mesh generation and manipulation package with GUI
5
+ Author-email: Waqas Hussain <waqas.hussain117@gmail.com>
6
+ License: GPL-3.0
7
+ Project-URL: Homepage, https://github.com/waqashussain117/PyMeshit
8
+ Project-URL: Bug Tracker, https://github.com/waqashussain117/PyMeshit/issues
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Intended Audience :: Science/Research
12
+ Classifier: Topic :: Scientific/Engineering
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.7
15
+ Classifier: Programming Language :: Python :: 3.8
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
20
+ Requires-Python: >=3.7
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Requires-Dist: numpy>=1.20.0
24
+ Requires-Dist: scipy>=1.7.0
25
+ Requires-Dist: triangle
26
+ Requires-Dist: matplotlib>=3.3.0
27
+ Requires-Dist: PySide6>=6.0.0
28
+ Requires-Dist: pyvista>=0.30.0
29
+ Requires-Dist: tetgen>=0.6.0
30
+ Dynamic: license-file
31
+
32
+ # PyMeshIt
33
+
34
+ PyMeshIt is a complete Python package for mesh generation and manipulation with a full-featured Qt-based GUI. It provides a comprehensive workflow to process point clouds and polylines into conforming surface meshes and tetrahedral meshes.
35
+
36
+ **Note:** This version runs entirely in Python without C++ dependencies, making it easier to install and deploy.
37
+
38
+ ## Highlights (GUI-driven workflow)
39
+
40
+ The included GUI (main.py) implements a full MeshIt workflow with the following main tabs:
41
+
42
+ - 1. Load Data — load points, wells (polylines) or VTU/Poly formats; manage multiple datasets and colors.
43
+ - 2. Convex Hull — compute dataset boundaries (convex or rim for/quasi-planar sheets) with corner detection.
44
+ - 3. Segmentation — refine hulls by target feature size and per-surface length tables (RefineByLength).
45
+ - 4. Triangulation — generate surface triangulations with gradient, min-angle, interpolation and uniform options.
46
+ - 5. Intersections — compute & visualize global surface–surface and polyline–surface intersections; triple point detection.
47
+ - 6. Refine & Mesh — refine intersection/hull lines, generate conforming surface meshes, constraint selection UI, per-surface mesh density table.
48
+ - 7. Pre‑Tetramesh — select conforming surfaces, validate for TetGen, manage selection tree for tetrahedralization.
49
+ - 8. Tetra Mesh — generate and visualize tetrahedral meshes, assign materials, export results.
50
+
51
+
52
+ ## Installation
53
+
54
+ ### From PyPI (Recommended)
55
+
56
+ ```bash
57
+ pip install triangle
58
+ pip install pymeshit # Needs to be fixed
59
+ ```
60
+
61
+ ### From Source
62
+
63
+ If you want to install from source:
64
+
65
+ ```bash
66
+ git clone https://github.com/waqashussain/meshit.git
67
+ cd meshit
68
+ pip install -e .
69
+ ```
70
+
71
+ ### Requirements
72
+
73
+ The package will automatically install all required dependencies:
74
+ - numpy
75
+ - scipy
76
+ - matplotlib
77
+ - PySide6
78
+ - pyvista
79
+ - tetgen
80
+ - triangle (optional)
81
+
82
+
83
+ ## Quick start (GUI)
84
+
85
+ After installation, run the GUI:
86
+
87
+ ```bash
88
+ meshit-gui
89
+ ```
90
+
91
+ Or from Python:
92
+
93
+ ```python
94
+ import Pymeshit
95
+ Pymeshit.main_wrapper()
96
+ ```
97
+
98
+ Typical workflow:
99
+ 1. Load one or more point or VTU files (File → Load).
100
+ 2. Compute hulls (Convex Hull tab).
101
+ 3. Compute segmentation (Segmentation tab) — set "Target Feature Size" or per-surface values.
102
+ 4. Run triangulation (Triangulation tab), choose interpolation and quality settings.
103
+ 5. Compute intersections (Intersections tab) to extract shared constraints and triple points.
104
+ 6. Refine intersection lines and generate conforming meshes (Refine & Mesh tab).
105
+ 7. Select conforming surfaces and validate for TetGen (Pre‑Tetramesh tab).
106
+ 8. Generate and visualize tetrahedral mesh (Tetra Mesh tab) and export.
107
+
108
+ ## Programmatic Usage
109
+
110
+ ```python
111
+ import pymeshit
112
+ from pymeshit.intersection_utils import align_intersections_to_convex_hull
113
+
114
+ # Use pymeshit functions programmatically
115
+ # ...
116
+ ```
117
+
118
+ ## Contributing
119
+
120
+ Contributions are welcome. Please open an issue for discussion and submit PRs for fixes and features. Keep GUI behavior consistent with the tab-based workflow.
121
+
122
+ ## License
123
+
124
+ This project is licensed under the GNU General Public License v3.0 - see the [LICENSE](LICENSE) file for details.
@@ -0,0 +1,228 @@
1
+ """
2
+ PyMeshit - Complete mesh generation and manipulation package with GUI
3
+
4
+ This package provides a comprehensive solution for mesh generation and manipulation,
5
+ including a graphical user interface for the complete workflow.
6
+ """
7
+
8
+ import sys # Import sys for error handling
9
+
10
+ # Define main_wrapper early to ensure it's always available
11
+ def main_wrapper():
12
+ from PySide6.QtWidgets import QApplication
13
+ from PySide6.QtGui import QIcon
14
+ from PySide6.QtWidgets import QSplashScreen
15
+ from PySide6.QtGui import QPixmap
16
+ from PySide6.QtCore import Qt
17
+ import os, sys
18
+
19
+ app = QApplication(sys.argv) # MUST be first
20
+
21
+ from Pymeshit_workflow_gui import MeshItWorkflowGUI # import GUI after app
22
+
23
+ # optional: icon/splash
24
+ icon_path = os.path.join(os.path.dirname(__file__), '..', 'resources', 'images', 'app_logo_small.png')
25
+ if os.path.exists(icon_path):
26
+ app.setWindowIcon(QIcon(icon_path))
27
+
28
+ splash_path = os.path.join(os.path.dirname(__file__), '..', 'resources', 'images', 'app_logo.png')
29
+ pixmap = QPixmap(splash_path) if os.path.exists(splash_path) else QPixmap(400, 300)
30
+ splash = QSplashScreen(pixmap, Qt.WindowStaysOnTopHint)
31
+ splash.show(); app.processEvents()
32
+
33
+ window = MeshItWorkflowGUI()
34
+ window.show()
35
+ splash.finish(window)
36
+ sys.exit(app.exec())
37
+
38
+ # Import core components with fallback
39
+ try:
40
+ from .core import (
41
+ MeshItModel,
42
+ Vector3D,
43
+ Surface,
44
+ Polyline,
45
+ create_surface,
46
+ create_polyline,
47
+ Triangle,
48
+ Intersection,
49
+ TriplePoint,
50
+ GradientControl,
51
+ )
52
+ except ImportError as e:
53
+ print(f"Warning: Could not import core components: {e}", file=sys.stderr)
54
+ print("Using Python fallback implementations", file=sys.stderr)
55
+
56
+ # Minimal fallback classes
57
+ class MeshItModel:
58
+ def __init__(self):
59
+ self.surfaces = []
60
+ self.model_polylines = []
61
+ def __str__(self):
62
+ return "MeshItModel(fallback)"
63
+
64
+ class Vector3D:
65
+ def __init__(self, x=0, y=0, z=0):
66
+ self.x, self.y, self.z = x, y, z
67
+
68
+ class Surface:
69
+ def __init__(self, points=None, edges=None, name="Surface", stype="Scattered"):
70
+ self.vertices = points or []
71
+ self.triangles = []
72
+ self.name = name
73
+
74
+ class Polyline:
75
+ def __init__(self, points=None, name="Polyline"):
76
+ self.vertices = points or []
77
+ self.segments = []
78
+ self.name = name
79
+
80
+ def create_surface(points, edges, name="Surface", stype="Scattered"):
81
+ return Surface(points, edges, name, stype)
82
+
83
+ def create_polyline(points, name="Polyline"):
84
+ return Polyline(points, name)
85
+
86
+ class Triangle:
87
+ def __init__(self, v1, v2, v3):
88
+ self.v1, self.v2, self.v3 = v1, v2, v3
89
+
90
+ class Intersection:
91
+ def __init__(self, id1, id2, is_polyline_mesh=False):
92
+ self.id1, self.id2 = id1, id2
93
+ self.is_polyline_mesh = is_polyline_mesh
94
+ self.points = []
95
+
96
+ class TriplePoint:
97
+ def __init__(self, point):
98
+ self.point = point
99
+ self.intersection_ids = []
100
+
101
+ class GradientControl:
102
+ _instance = None
103
+ def __new__(cls):
104
+ if cls._instance is None:
105
+ cls._instance = super().__new__(cls)
106
+ return cls._instance
107
+
108
+ # Try to import our direct Triangle wrapper (Python-only)
109
+ try:
110
+ from . import triangle_direct
111
+ HAS_DIRECT_TRIANGLE = True
112
+ except ImportError:
113
+ HAS_DIRECT_TRIANGLE = False
114
+
115
+ # Define version
116
+ __version__ = '0.2.0'
117
+
118
+ # Helper functions for adding geometries to a model
119
+ def add_surface_to_model(model, surface):
120
+ """Add a surface to a MeshItModel instance.
121
+
122
+ Args:
123
+ model: A MeshItModel instance
124
+ surface: A Surface instance to add
125
+ """
126
+ try:
127
+ model.surfaces = list(model.surfaces) + [surface]
128
+ except Exception as e:
129
+ print(f"Warning: Failed to add surface to model: {e}", file=sys.stderr)
130
+
131
+ def add_polyline_to_model(model, polyline):
132
+ """Add a polyline to a MeshItModel instance.
133
+
134
+ Args:
135
+ model: A MeshItModel instance
136
+ polyline: A Polyline instance to add
137
+ """
138
+ try:
139
+ model.model_polylines = list(model.model_polylines) + [polyline]
140
+ except Exception as e:
141
+ print(f"Warning: Failed to add polyline to model: {e}", file=sys.stderr)
142
+
143
+ # Helper functions for accessing model results
144
+ def get_intersections(model):
145
+ """Get the intersections from a MeshItModel instance.
146
+
147
+ Args:
148
+ model: A MeshItModel instance
149
+
150
+ Returns:
151
+ A list of Intersection objects or an empty list if not available
152
+ """
153
+ try:
154
+ return model.intersections
155
+ except AttributeError:
156
+ return []
157
+
158
+ def get_triple_points(model):
159
+ """Get the triple points from a MeshItModel instance.
160
+
161
+ Args:
162
+ model: A MeshItModel instance
163
+
164
+ Returns:
165
+ A list of TriplePoint objects or an empty list if not available
166
+ """
167
+ try:
168
+ return model.triple_points
169
+ except AttributeError:
170
+ return []
171
+
172
+ def compute_convex_hull(points):
173
+ """Compute the convex hull of a set of 3D points.
174
+
175
+ Args:
176
+ points: A list of 3D points, where each point is a list of 3 coordinates [x, y, z]
177
+
178
+ Returns:
179
+ A list of 3D points representing the convex hull
180
+ """
181
+ try:
182
+ # Create a surface from the points
183
+ surface = create_surface(points, [], "TempSurface", "Scattered")
184
+
185
+ # Calculate the convex hull
186
+ surface.calculate_convex_hull()
187
+
188
+ # Convert the convex hull points to a list of lists
189
+ hull_points = []
190
+ for point in surface.convex_hull:
191
+ hull_points.append([point.x, point.y, point.z])
192
+
193
+ return hull_points
194
+ except Exception as e:
195
+ print(f"Warning: Failed to compute convex hull: {e}", file=sys.stderr)
196
+
197
+ # Fall back to scipy for convex hull if available
198
+ try:
199
+ import numpy as np
200
+ from scipy.spatial import ConvexHull
201
+
202
+ points_array = np.array(points)
203
+ if points_array.shape[1] == 3: # 3D points
204
+ hull = ConvexHull(points_array)
205
+ return points_array[hull.vertices].tolist()
206
+ return []
207
+ except ImportError:
208
+ return []
209
+
210
+ # Duplicate main_wrapper function removed
211
+
212
+ __all__ = [
213
+ 'MeshItModel',
214
+ 'Vector3D',
215
+ 'Surface',
216
+ 'Polyline',
217
+ 'create_surface',
218
+ 'create_polyline',
219
+ 'Triangle',
220
+ 'Intersection',
221
+ 'TriplePoint',
222
+ 'add_surface_to_model',
223
+ 'add_polyline_to_model',
224
+ 'get_intersections',
225
+ 'get_triple_points',
226
+ 'compute_convex_hull',
227
+ 'main_wrapper'
228
+ ]
@@ -0,0 +1,93 @@
1
+ # This file is intentionally empty to make the directory a Python package
2
+
3
+ """
4
+ Core C++ bindings for MeshIt
5
+ """
6
+
7
+ try:
8
+ from ._meshit import (
9
+ MeshItModel,
10
+ Vector3D,
11
+ Surface,
12
+ Polyline,
13
+ create_surface,
14
+ create_polyline,
15
+ Triangle,
16
+ Intersection,
17
+ TriplePoint,
18
+ GradientControl
19
+ )
20
+ except ImportError as e:
21
+ import sys
22
+ print(f"Warning: C++ extensions not available: {e}", file=sys.stderr)
23
+ print("Using Python fallback implementations", file=sys.stderr)
24
+
25
+ # Provide dummy classes when C++ extensions are not available
26
+ class Vector3D:
27
+ def __init__(self, x=0, y=0, z=0):
28
+ self.x, self.y, self.z = x, y, z
29
+
30
+ def __repr__(self):
31
+ return f"Vector3D({self.x}, {self.y}, {self.z})"
32
+
33
+ class Surface:
34
+ def __init__(self, points=None, edges=None, name="Surface", stype="Scattered"):
35
+ self.points = points or []
36
+ self.edges = edges or []
37
+ self.name = name
38
+ self.stype = stype
39
+ self.convex_hull = []
40
+
41
+ def calculate_convex_hull(self):
42
+ # Dummy implementation
43
+ self.convex_hull = [Vector3D(*p) for p in self.points[:min(10, len(self.points))]]
44
+
45
+ class GradientControl:
46
+ def __init__(self):
47
+ pass
48
+
49
+ class Polyline:
50
+ def __init__(self, points=None, name="Polyline"):
51
+ self.points = points or []
52
+ self.name = name
53
+
54
+ class Triangle:
55
+ def __init__(self, v1=None, v2=None, v3=None):
56
+ self.v1, self.v2, self.v3 = v1, v2, v3
57
+
58
+ class Intersection:
59
+ def __init__(self):
60
+ self.points = []
61
+
62
+ class TriplePoint:
63
+ def __init__(self):
64
+ self.position = Vector3D()
65
+
66
+ class MeshItModel:
67
+ def __init__(self):
68
+ self.surfaces = []
69
+ self.model_polylines = []
70
+ self.intersections = []
71
+ self.triple_points = []
72
+
73
+ def __str__(self):
74
+ return f"MeshItModel(surfaces: {len(self.surfaces)}, polylines: {len(self.model_polylines)})"
75
+
76
+ def create_surface(points, edges=None, name="Surface", stype="Scattered"):
77
+ return Surface(points, edges, name, stype)
78
+
79
+ def create_polyline(points, name="Polyline"):
80
+ return Polyline(points, name)
81
+
82
+ __all__ = [
83
+ 'MeshItModel',
84
+ 'Vector3D',
85
+ 'Surface',
86
+ 'Polyline',
87
+ 'create_surface',
88
+ 'create_polyline',
89
+ 'Triangle',
90
+ 'Intersection',
91
+ 'TriplePoint',
92
+ 'GradientControl'
93
+ ]