Skip to content

Commit a999607

Browse files
Fix cad_mesh_grading_factor to accept float values and remove incorrect GradingFactor enum (#47)
* Initial plan * Fix cad_mesh_grading_factor to accept float and remove GradingFactor enum Co-authored-by: sankalps0549 <230025240+sankalps0549@users.noreply.github.com> * Fix check_type and check_range calls to use correct signatures Co-authored-by: sankalps0549 <230025240+sankalps0549@users.noreply.github.com> * Remove cad_mesh_grading_factor from invalid enum test since it's no longer an enum Co-authored-by: sankalps0549 <230025240+sankalps0549@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: sankalps0549 <230025240+sankalps0549@users.noreply.github.com>
1 parent 86035b8 commit a999607

7 files changed

Lines changed: 32 additions & 34 deletions

File tree

CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2525
### Security
2626
- N/A
2727

28+
## [26.0.5]
29+
30+
### Added
31+
- N/A
32+
33+
### Changed
34+
- `MeshGenerator.cad_mesh_grading_factor` now accepts `float` values in range 0.0 to 1.0 instead of enum/integer-coded options
35+
36+
### Deprecated
37+
- N/A
38+
39+
### Removed
40+
- `GradingFactor` enum - incorrectly restricted the API to discrete values when the COM API accepts continuous float values from 0.0 to 1.0
41+
42+
### Fixed
43+
- Fixed `MeshGenerator.cad_mesh_grading_factor` to properly accept float/double values matching the COM API signature instead of restricting to enum values
44+
45+
### Security
46+
- N/A
47+
2848
## [26.0.4]
2949

3050
### Added

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]

version.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"major": "26",
33
"minor": "0",
4-
"patch": "4"
4+
"patch": "5"
55
}

0 commit comments

Comments
 (0)