Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a shape_core_utils.py with common code #854

Open
gumyr opened this issue Jan 9, 2025 · 0 comments
Open

Create a shape_core_utils.py with common code #854

gumyr opened this issue Jan 9, 2025 · 0 comments
Labels
enhancement New feature or request

Comments

@gumyr
Copy link
Owner

gumyr commented Jan 9, 2025

There are bits of code that is duplicated in the base topology and geometry layers, downcast being a good example. Within geometry.py one will find:

            downcast_LUT = {
                TopAbs_ShapeEnum.TopAbs_VERTEX: TopoDS.Vertex_s,
                TopAbs_ShapeEnum.TopAbs_EDGE: TopoDS.Edge_s,
                TopAbs_ShapeEnum.TopAbs_WIRE: TopoDS.Wire_s,
                TopAbs_ShapeEnum.TopAbs_FACE: TopoDS.Face_s,
                TopAbs_ShapeEnum.TopAbs_SHELL: TopoDS.Shell_s,
                TopAbs_ShapeEnum.TopAbs_SOLID: TopoDS.Solid_s,
                TopAbs_ShapeEnum.TopAbs_COMPOUND: TopoDS.Compound_s,
            }
            assert other.wrapped is not None
            try:
                f_downcast = downcast_LUT[other.wrapped.ShapeType()]
            except KeyError as exc:
                raise ValueError(f"Unknown object type {other}") from exc

            result: Shape = copy.deepcopy(other, None)  # type: ignore[arg-type]
            result.wrapped = f_downcast(other.wrapped.Moved(self.wrapped))

Note that downcast could be placed in geometry.py as topology imports geometry but this code has to do with Shape objects which only reside in topology. Hence, an independent module that both could import would reduce code duplication.

There may be other bits of code that could go into this new file. Once the typing activities are complete, the output of pylint should be used to highlight all potential code.

@gumyr gumyr added the enhancement New feature or request label Jan 9, 2025
@gumyr gumyr added this to the Gating Release 1.0.0 milestone Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant