Skip to content

Commit 613a61f

Browse files
Copilotosinjoku
andauthored
Cherrypick PR #47: Fix cad_mesh_grading_factor to accept float values and remove GradingFactor enum (#53)
* Initial plan * Cherrypick PR #47: Fix cad_mesh_grading_factor to accept float values and remove GradingFactor enum Co-authored-by: osinjoku <49887472+osinjoku@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: osinjoku <49887472+osinjoku@users.noreply.github.com>
1 parent 00283a1 commit 613a61f

File tree

6 files changed

+14
-35
lines changed

6 files changed

+14
-35
lines changed

CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111
- Python 3.14 support
1212

1313
### Changed
14-
- N/A
14+
- `MeshGenerator.cad_mesh_grading_factor` now accepts `float` values in range 0.0 to 1.0 instead of enum/integer-coded options
1515

1616
### Deprecated
1717
- N/A
1818

1919
### Removed
20-
- N/A
20+
- `GradingFactor` enum - incorrectly restricted the API to discrete values when the COM API accepts continuous float values from 0.0 to 1.0
2121

2222
### Fixed
2323
- Fixed `GeomType` enum not being exposed in package `__init__.py` - users can now import it directly with `from moldflow import GeomType`
24+
- Fixed `MeshGenerator.cad_mesh_grading_factor` to properly accept float/double values matching the COM API signature instead of restricting to enum values
2425

2526
### Security
2627
- N/A

docs/source/components/enums/grading_factor.rst

Lines changed: 0 additions & 4 deletions
This file was deleted.

src/moldflow/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@
6868
from .common import DuplicateOption
6969
from .common import EdgeDisplayOptions
7070
from .common import EntityType
71-
from .common import GradingFactor
7271
from .common import GeomType
7372
from .common import ImportUnitIndex
7473
from .common import ImportUnits

src/moldflow/common.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -393,15 +393,6 @@ class TriClassification(Enum):
393393
PRESERVE_ALL = 2
394394

395395

396-
class GradingFactor(Enum):
397-
"""
398-
Enum for GradingFactor
399-
"""
400-
401-
SLOW = 0
402-
FAST = 1
403-
404-
405396
class GeomType(Enum):
406397
"""
407398
Enum for GeomType

src/moldflow/mesh_generator.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
NurbsAlgorithm,
1414
CoolType,
1515
TriClassification,
16-
GradingFactor,
1716
GeomType,
1817
Mesher3DType,
1918
CADContactMesh,
@@ -732,15 +731,16 @@ def cad_mesh_grading_factor(self) -> float:
732731
return self.mesh_generator.CadMeshGradingFactor
733732

734733
@cad_mesh_grading_factor.setter
735-
def cad_mesh_grading_factor(self, value: GradingFactor | int) -> None:
734+
def cad_mesh_grading_factor(self, value: float) -> None:
736735
"""
737736
Set the CAD mesh grading factor option.
738737
"""
739738
process_log(
740739
__name__, LogMessage.PROPERTY_SET, locals(), name="cad_mesh_grading_factor", value=value
741740
)
742-
value = get_enum_value(value, GradingFactor)
743-
self.mesh_generator.CadMeshGradingFactor = value
741+
check_type(value, (int, float))
742+
check_range(value, 0, 1, True, True)
743+
self.mesh_generator.CadMeshGradingFactor = float(value)
744744

745745
@property
746746
def cad_mesh_minimum_curvature_percentage(self) -> float:

tests/api/unit_tests/test_unit_mesh_generator.py

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
NurbsAlgorithm,
1313
CoolType,
1414
TriClassification,
15-
GradingFactor,
1615
Mesher3DType,
1716
CADContactMesh,
1817
)
@@ -134,8 +133,9 @@ def test_functions_no_args(
134133
("cad_auto_size_scale", "CadAutoSizeScale", 50, (int, float)),
135134
("cad_sliver_remove", "CadSliverRemove", True, bool),
136135
("cad_sliver_remove", "CadSliverRemove", False, bool),
137-
("cad_mesh_grading_factor", "CadMeshGradingFactor", 0, int),
138-
("cad_mesh_grading_factor", "CadMeshGradingFactor", 1, int),
136+
("cad_mesh_grading_factor", "CadMeshGradingFactor", 0.0, (int, float)),
137+
("cad_mesh_grading_factor", "CadMeshGradingFactor", 0.5, (int, float)),
138+
("cad_mesh_grading_factor", "CadMeshGradingFactor", 1.0, (int, float)),
139139
(
140140
"cad_mesh_minimum_curvature_percentage",
141141
"CadMeshMinimumCurvaturePercentage",
@@ -312,8 +312,9 @@ def test_get_properties(
312312
("cad_auto_size_scale", "CadAutoSizeScale", 50, (int, float)),
313313
("cad_sliver_remove", "CadSliverRemove", True, bool),
314314
("cad_sliver_remove", "CadSliverRemove", False, bool),
315-
("cad_mesh_grading_factor", "CadMeshGradingFactor", 0, int),
316-
("cad_mesh_grading_factor", "CadMeshGradingFactor", 1, int),
315+
("cad_mesh_grading_factor", "CadMeshGradingFactor", 0.0, (int, float)),
316+
("cad_mesh_grading_factor", "CadMeshGradingFactor", 0.5, (int, float)),
317+
("cad_mesh_grading_factor", "CadMeshGradingFactor", 1.0, (int, float)),
317318
(
318319
"cad_mesh_minimum_curvature_percentage",
319320
"CadMeshMinimumCurvaturePercentage",
@@ -450,7 +451,7 @@ def test_set_properties(
450451
+ [("use_auto_size", x) for x in ["abc", -1, 1.0, 1, 1.5, None]]
451452
+ [("cad_auto_size_scale", x) for x in ["abc", True, None]]
452453
+ [("cad_sliver_remove", x) for x in ["abc", -1, 1.0, 1, 1.5, None]]
453-
+ [("cad_mesh_grading_factor", x) for x in ["abc", True, 1.5, None]]
454+
+ [("cad_mesh_grading_factor", x) for x in ["abc", True, None]]
454455
+ [("cad_mesh_minimum_curvature_percentage", x) for x in ["abc", True, None]]
455456
+ [("use_fallbacks", x) for x in ["abc", -1, 1.0, 1, 1.5, None]]
456457
+ [("max_edge_length_in_thickness_direction", x) for x in ["abc", True, None]]
@@ -505,7 +506,6 @@ def test_set_properties_invalid_value(
505506
"property_name, invalid_value",
506507
[("nurbs_mesher", x) for x in [-1, 10, 5]]
507508
+ [("cad_contact_mesh_type", x) for x in ["abc", "Something"]]
508-
+ [("cad_mesh_grading_factor", x) for x in [-1, 10, 5]]
509509
+ [("source_geom_type", x) for x in ["Hello", "abc"]]
510510
+ [("cool_type", x) for x in [-1, 10, 5]]
511511
+ [("tri_classification_opt", x) for x in [-1, 10, 5]],
@@ -552,14 +552,6 @@ def test_gel_false(self, mock_mesh_generator, mock_object):
552552
("tri_classification_opt", "TriClassificationOpt", x.value, x.value, int)
553553
for x in TriClassification
554554
]
555-
+ [
556-
("cad_mesh_grading_factor", "CadMeshGradingFactor", x, x.value, int)
557-
for x in GradingFactor
558-
]
559-
+ [
560-
("cad_mesh_grading_factor", "CadMeshGradingFactor", x.value, x.value, int)
561-
for x in GradingFactor
562-
]
563555
+ [("mesher_3d", "Mesher3D", x, x.value, str) for x in Mesher3DType]
564556
+ [("mesher_3d", "Mesher3D", x.value, x.value, str) for x in Mesher3DType]
565557
+ [("source_geom_type", "SourceGeomType", x, x.value, str) for x in GeomType]

0 commit comments

Comments
 (0)