From 39a8b2be89dc0c361c540d4fab815fb6eb168263 Mon Sep 17 00:00:00 2001 From: Steven Masfaraud Date: Thu, 22 Jul 2021 16:08:42 +0200 Subject: [PATCH 1/5] dimensionned surface3D (easy ones) --- volmdlr/faces.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/volmdlr/faces.py b/volmdlr/faces.py index 01652438a..b02a992df 100644 --- a/volmdlr/faces.py +++ b/volmdlr/faces.py @@ -918,6 +918,10 @@ def point2d_to_3d(self, point2d): def point3d_to_2d(self, point3d): return point3d.to_2d(self.frame.origin, self.frame.u, self.frame.v) + def dimensioned_surface2d(dimensionless_surface2d:Surface2D): + return dimensionless_surface2d + + def contour2d_to_3d(self, contour2d): return contour2d.to_3d(self.frame.origin, self.frame.u, self.frame.v) @@ -990,6 +994,12 @@ def point3d_to_2d(self, point3d): # theta = volmdlr.core.sin_cos_angle(u1, u2) theta = math.atan2(u2, u1) return volmdlr.Point2D(theta, z) + + def dimensioned_surface2d(self, dimensionless_surface2d:Surface2D): + frame = volmdlr.OXY.copy() + frame.u = self.radius + return dimensionless_surface2d.frame_mapping(frame, side='old') + def arc3d_to_2d(self, arc3d): start = self.point3d_to_2d(arc3d.start) @@ -1185,6 +1195,13 @@ def point3d_to_2d(self, point3d): return volmdlr.Point2D(theta, phi) + def dimensioned_surface2d(self, dimensionless_surface2d:Surface2D): + frame = volmdlr.OXY.copy() + frame.u = self.R + frame.v = self.r + return dimensionless_surface2d.frame_mapping(frame, side='old') + + @classmethod def from_step(cls, arguments, object_dict): frame3d = object_dict[arguments[1]] @@ -1542,6 +1559,12 @@ def point3d_to_2d(self, point3d): theta = volmdlr.sin_cos_angle(u1, u2) return volmdlr.Point2D(theta, phi) + def dimensioned_surface2d(self, dimensionless_surface2d:Surface2D): + frame = volmdlr.OXY.copy() + frame.u = self.radius + frame.v = self.radius + return dimensionless_surface2d.frame_mapping(frame, side='old') + def linesegment2d_to_3d(self, linesegment2d): start = self.point2d_to_3d(linesegment2d.start) interior = self.point2d_to_3d(0.5 * (linesegment2d.start + linesegment2d.end)) From fb108a0273520e81e76823e07e4bc8d201e08651 Mon Sep 17 00:00:00 2001 From: Steven Masfaraud Date: Tue, 10 Jan 2023 14:37:15 +0100 Subject: [PATCH 2/5] fix: pylint self --- volmdlr/faces.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/volmdlr/faces.py b/volmdlr/faces.py index 145e8f3ed..1d9e139f9 100644 --- a/volmdlr/faces.py +++ b/volmdlr/faces.py @@ -1251,10 +1251,9 @@ def point2d_to_3d(self, point2d): def point3d_to_2d(self, point3d): return point3d.to_2d(self.frame.origin, self.frame.u, self.frame.v) - def dimensioned_surface2d(dimensionless_surface2d:Surface2D): + def dimensioned_surface2d(self, dimensionless_surface2d: Surface2D): return dimensionless_surface2d - def contour2d_to_3d(self, contour2d): return contour2d.to_3d(self.frame.origin, self.frame.u, self.frame.v) From d1253d58102059aafe34b65cc6031406d8bb7086 Mon Sep 17 00:00:00 2001 From: Steven Masfaraud Date: Tue, 10 Jan 2023 15:20:35 +0100 Subject: [PATCH 3/5] fix: pydocstyle --- code_pydocstyle.py | 8 ++++---- volmdlr/faces.py | 28 ++++++++++++++++++++++------ 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/code_pydocstyle.py b/code_pydocstyle.py index 60a5432cc..826c444d1 100644 --- a/code_pydocstyle.py +++ b/code_pydocstyle.py @@ -22,15 +22,15 @@ MAX_ERROR_BY_TYPE = { # If the error code is not in this dict, then there is no tolerance on the error. # http://www.pydocstyle.org/en/stable/error_codes.html - 'D101': 50, - 'D102': 656, + 'D101': 49, + 'D102': 654, 'D103': 30, - 'D205': 223, + 'D205': 215, 'D300': 6, - 'D400': 268, + 'D400': 262, 'D403': 46, } diff --git a/volmdlr/faces.py b/volmdlr/faces.py index 1d9e139f9..814e6c898 100644 --- a/volmdlr/faces.py +++ b/volmdlr/faces.py @@ -844,6 +844,12 @@ def contour3d_to_2d(self, contour3d): return volmdlr.wires.Contour2D(primitives2d) def contour2d_to_3d(self, contour2d): + """ + Computes the 3D representation of a given contour2D. + + :param contour2d: The given contour2D + """ + primitives3d = [] for primitive2d in contour2d.primitives: method_name = f'{primitive2d.__class__.__name__.lower()}_to_3d' @@ -1252,9 +1258,17 @@ def point3d_to_2d(self, point3d): return point3d.to_2d(self.frame.origin, self.frame.u, self.frame.v) def dimensioned_surface2d(self, dimensionless_surface2d: Surface2D): + """ + Computes the dimentioned surface2D associated to the given parametric surface2d. + """ return dimensionless_surface2d def contour2d_to_3d(self, contour2d): + """ + Computes the 3D representation of a given contour2D. + + :param contour2d: The given contour2D + """ return contour2d.to_3d(self.frame.origin, self.frame.u, self.frame.v) def contour3d_to_2d(self, contour3d): @@ -1310,7 +1324,7 @@ class CylindricalSurface3D(Surface3D): x_periodicity = volmdlr.TWO_PI y_periodicity = None - def __init__(self, frame, radius, name=''): + def __init__(self, frame: volmdlr.core.Frame3D, radius: float, name: str=''): self.frame = frame self.radius = radius Surface3D.__init__(self, name=name) @@ -1321,7 +1335,7 @@ def point2d_to_3d(self, point2d: volmdlr.Point2D): point2d.y) return self.frame.old_coordinates(p) - def point3d_to_2d(self, point3d): + def point3d_to_2d(self, point3d: volmdlr.core.Point3D): """ Returns the cylindrical coordinates volmdlr.Point2D(theta, z) of a cartesian coordinates point (x, y, z). @@ -1340,14 +1354,16 @@ def point3d_to_2d(self, point3d): theta = 0.0 return volmdlr.Point2D(theta, z) - - def dimensioned_surface2d(self, dimensionless_surface2d:Surface2D): + + def dimensioned_surface2d(self, dimensionless_surface2d: Surface2D): + """ + Computes the dimentioned surface2D associated to the given parametric surface2d. + """ frame = volmdlr.OXY.copy() frame.u = self.radius return dimensionless_surface2d.frame_mapping(frame, side='old') - - def arc3d_to_2d(self, arc3d): + def arc3d_to_2d(self, arc3d: vme.Arc3D): start = self.point3d_to_2d(arc3d.start) end = self.point3d_to_2d(arc3d.end) From ff9955144a11b3767476df1b98b831803181c43d Mon Sep 17 00:00:00 2001 From: WirajanDASILVA Date: Tue, 10 Jan 2023 17:49:03 -0300 Subject: [PATCH 4/5] fix pep8 --- volmdlr/faces.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/volmdlr/faces.py b/volmdlr/faces.py index 814e6c898..a556b2697 100644 --- a/volmdlr/faces.py +++ b/volmdlr/faces.py @@ -846,10 +846,10 @@ def contour3d_to_2d(self, contour3d): def contour2d_to_3d(self, contour2d): """ Computes the 3D representation of a given contour2D. - + :param contour2d: The given contour2D """ - + primitives3d = [] for primitive2d in contour2d.primitives: method_name = f'{primitive2d.__class__.__name__.lower()}_to_3d' @@ -1266,7 +1266,7 @@ def dimensioned_surface2d(self, dimensionless_surface2d: Surface2D): def contour2d_to_3d(self, contour2d): """ Computes the 3D representation of a given contour2D. - + :param contour2d: The given contour2D """ return contour2d.to_3d(self.frame.origin, self.frame.u, self.frame.v) @@ -1324,7 +1324,7 @@ class CylindricalSurface3D(Surface3D): x_periodicity = volmdlr.TWO_PI y_periodicity = None - def __init__(self, frame: volmdlr.core.Frame3D, radius: float, name: str=''): + def __init__(self, frame: volmdlr.core.Frame3D, radius: float, name: str = ''): self.frame = frame self.radius = radius Surface3D.__init__(self, name=name) @@ -1857,13 +1857,12 @@ def point3d_to_2d(self, point3d): phi = 0.0 return volmdlr.Point2D(theta, phi) - def dimensioned_surface2d(self, dimensionless_surface2d:Surface2D): + def dimensioned_surface2d(self, dimensionless_surface2d: Surface2D): frame = volmdlr.OXY.copy() frame.u = self.R frame.v = self.r return dimensionless_surface2d.frame_mapping(frame, side='old') - @classmethod def from_step(cls, arguments, object_dict): frame3d = object_dict[arguments[1]] @@ -2503,7 +2502,7 @@ def point3d_to_2d(self, point3d): return volmdlr.Point2D(theta, phi) - def dimensioned_surface2d(self, dimensionless_surface2d:Surface2D): + def dimensioned_surface2d(self, dimensionless_surface2d: Surface2D): frame = volmdlr.OXY.copy() frame.u = self.radius frame.v = self.radius From c32b7a642a91d744d287315d9a90ca085cd93c34 Mon Sep 17 00:00:00 2001 From: WirajanDASILVA Date: Tue, 10 Jan 2023 17:56:28 -0300 Subject: [PATCH 5/5] update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 835fc702b..9dfd37b74 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,7 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * ClosedPolygon2D: point_belongs, now the user can choose whether points on the edge of the polygon should be considered inside or not. * ArcEllipse2D: line_intersections, frame_mapping, linesegment_intersections - +* Add dimensionned surface3D ### Fixed