Skip to content

Conversation

@c1ydehhx
Copy link
Contributor

In this PR, I added the mesh sample that draw the example in ICCAD-2013 CAD Contest paper. The result looks like this:

image

Copy link
Member

@yungyuc yungyuc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good start. Points to address:

  • Avoid and remove Python type annotation.
  • Remove _fp64p().
  • Use real number format (e.g., 70.0) for the coordinates.
  • Data and logic should be separated. Make data a string and logic in a helper class.


return spad

def poly_spad(coords: list[tuple[int, int]]):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't use type annotation in modmesh. Keep Python dynamic. When types are needed, do it in C++.

def mesh_iccad_2013(self):
world = core.WorldFp64()

def _fp64p(x, y):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove _fp64p(). It is redundant. Just use Point3dFp64 constructor. If the class name is too long to you, use a local alias.


return spad

world.add_segments(pad=rect_spad(70, 800, 180, 40))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use real number format (e.g., 70.0) for the coordinates.

self._pycon.writeToHistory(f"tri nedge: {mh.nedge}\n")

def mesh_iccad_2013(self):
world = core.WorldFp64()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Data and logic should be separated. Make data a string and logic in a helper class.

@yungyuc yungyuc added the pilot GUI and visualization label Jan 31, 2026
@c1ydehhx c1ydehhx force-pushed the ICCAD-2013-sample branch 2 times, most recently from cf3a3ef to 7dd7fc4 Compare January 31, 2026 05:29
@c1ydehhx
Copy link
Contributor Author

c1ydehhx commented Jan 31, 2026

Hi, @yungyuc. I already fix all comment:

I create a helper class named ICCAD2013Mesh. It accept the string format of ICCAD2013 table 1 to draw polygons.

    def mesh_iccad_2013(self):
        mesh = iccad_2013.ICCAD2013Mesh()
        mesh.add_item("RECT N M1 70 800 180 40")
        mesh.add_item(
            "PGON N M1 70 720 410 720 410 920 70 920 70 880 370 880 370 760 70 760"
        )
        mesh.add_item("RECT N M1 70 1060 180 40")
        mesh.add_item(
            "PGON N M1 70 980 410 980 410 1180 70 1180 70 1140 370 1140 370 1020 70 1020"
        )

        wid = self._mgr.add3DWidget()
        wid.updateWorld(mesh.get_world())
        wid.showMark()

ICCAD2013Mesh will parse string and store coordinate value as float. Add segment with its private function (rect_spad, poly_spad). add_item function will fetch first string segment to determine the item is polygon or rectangle, then transform the data as SegmentPadFp64 format. The mesh will produce world for widget.

Copy link
Member

@yungyuc yungyuc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Points to address:

  • Rename iccad_2013 to plain_layer, and the class name PlaneLayer.
  • Move plane_layer to be under modmesh.plot.
  • Move the GUI code to a new sub-module modmesh._canvas.
  • Use a separate PR to maintain dot files.
  • Rename _rect_spad() to add_rectangle() (drop leading underscore).
  • Rename _polygon_spad() to add_polygon() (drop leading underscore).
  • Rename add_item() to add_figure().

@@ -0,0 +1,33 @@
# Copyright (c) 2026, Han-Xuan Huang <c1ydehhx@gmail.com>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This (iccad_2013) is a horrible name for a graphical data processor. Name it more generic. I propose to name the module as plain_layer, and use PlaneLayer as the class name. "Plane" implies the two dimension.

The module should be moved under modmesh.plot, which has nothing to do with GUI.

Also read the code under cpp/modmesh/universe, which is the graphical C++ code that @tigercosmos is working on.

.gitignore Outdated
*.pdb
*.env
profiling/results/
.cache No newline at end of file
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not change dot files when adding feature. Use a separate PR to maintain dot files.


from .. import core
from ._gui_common import PilotFeature
from . import iccad_2013
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use a new module for drawing exclusively 2D graphics. I propose to name it modmesh._canvas (we may change it in the future).

def __init__(self):
self.world = core.WorldFp64()

def _rect_spad(self, x, y, w, h):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename _rect_spad() to add_rectangle().


return spad

def _poly_spad(self, coords):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename _polygon_spad() to add_polygon().


return spad

def add_item(self, str):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename add_item() to add_figure().

@c1ydehhx c1ydehhx force-pushed the ICCAD-2013-sample branch 2 times, most recently from 82f11b5 to 46d7b44 Compare January 31, 2026 06:36
@c1ydehhx
Copy link
Contributor Author

c1ydehhx commented Jan 31, 2026

Hi @yungyuc. I already fix the issue in comment.

I create PlaneLayer class with Layer abstract. The class returns polys list as data that can transform as segment for world. Moreover, I create Canva to create world and transform polys list to segment that can append to world. The class Canva returns world that cae use in pilot widget. It seperate GUI and data as different class.

I still need to add some tests for these class.

Copy link
Member

@yungyuc yungyuc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some points were not addressed. New points to address:

  • Do not add Layer. It is not a necessary abstraction.
  • The code for GUI should also be moved in _canvas.py.

from abc import ABC


class Layer(ABC):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not add Layer. It is not a necessary abstraction.

And I do not want to have a class of such a short name.

func=self.mesh_3dmix,
)

self._add_menu_item(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code to great GUI should also be moved in _canvas.py. You may also need a new menu.

@c1ydehhx
Copy link
Contributor Author

c1ydehhx commented Jan 31, 2026

I fixed all issues. @yungyuc

I create canva menu that can render ICCAD example.

image image

and I remove abstract class. Please review it, thanks.

Copy link
Member

@yungyuc yungyuc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Point to address:

  • _canvas should be before _profiling.

from . import _svg_gui
from . import _linear_wave
from . import _profiling
from . import _canvas
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_canvas should be before _profiling.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Thanks for the notice.

@c1ydehhx c1ydehhx force-pushed the ICCAD-2013-sample branch 2 times, most recently from 8c3b971 to 7d93610 Compare January 31, 2026 07:55
@yungyuc
Copy link
Member

yungyuc commented Jan 31, 2026

@c1ydehhx leave a global comment to notify when it's ready for the next review.

@yungyuc
Copy link
Member

yungyuc commented Feb 2, 2026

@c1ydehhx update?

@c1ydehhx
Copy link
Contributor Author

c1ydehhx commented Feb 2, 2026

Hi @yungyuc. I already fix the issue in comment. Thanks.

Copy link
Member

@yungyuc yungyuc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @yungyuc. I already fix the issue in comment. Thanks.

No, you didn't. Please review the code carefully and update.

And please rebase to the latest, squash the commits, and write a concise summary in the commit log.

}
m_oneMenu = m_mainWindow->menuBar()->addMenu(QString("One"));
m_meshMenu = m_mainWindow->menuBar()->addMenu(QString("Mesh"));
m_canvaMenu = m_mainWindow->menuBar()->addMenu(QString("Canva"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a typo. The name should be canvas, not canva.

QMenu * oneMenu() { return m_oneMenu; }
QMenu * meshMenu() { return m_meshMenu; }
QMenu * profilingMenu() { return m_profilingMenu; }
QMenu * canvaMenu() { return m_canvaMenu; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This canvasMenu should use the same order to be placed before profilingMenu.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pilot GUI and visualization

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants