unit-cell-gui 0.2.1__tar.gz → 0.2.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. {unit_cell_gui-0.2.1 → unit_cell_gui-0.2.3}/CHANGELOG.md +54 -0
  2. {unit_cell_gui-0.2.1 → unit_cell_gui-0.2.3}/CITATION.cff +2 -2
  3. {unit_cell_gui-0.2.1 → unit_cell_gui-0.2.3}/MANIFEST.in +2 -1
  4. {unit_cell_gui-0.2.1 → unit_cell_gui-0.2.3}/PKG-INFO +42 -2
  5. {unit_cell_gui-0.2.1 → unit_cell_gui-0.2.3}/README.md +41 -1
  6. unit_cell_gui-0.2.3/RELEASE_NOTES_0.2.2.md +42 -0
  7. unit_cell_gui-0.2.3/RELEASE_NOTES_0.2.3.md +53 -0
  8. {unit_cell_gui-0.2.1 → unit_cell_gui-0.2.3}/pyproject.toml +1 -1
  9. {unit_cell_gui-0.2.1 → unit_cell_gui-0.2.3}/src/unit_cell_gui/__init__.py +1 -1
  10. {unit_cell_gui-0.2.1 → unit_cell_gui-0.2.3}/src/unit_cell_gui/gl_geometry.py +18 -1
  11. {unit_cell_gui-0.2.1 → unit_cell_gui-0.2.3}/src/unit_cell_gui/opengl_viewer.py +348 -239
  12. {unit_cell_gui-0.2.1 → unit_cell_gui-0.2.3}/src/unit_cell_gui.egg-info/PKG-INFO +42 -2
  13. {unit_cell_gui-0.2.1 → unit_cell_gui-0.2.3}/src/unit_cell_gui.egg-info/SOURCES.txt +5 -3
  14. unit_cell_gui-0.2.3/tests/test_visibility_cache.py +275 -0
  15. unit_cell_gui-0.2.3/tests/test_z_atom_instancing.py +188 -0
  16. unit_cell_gui-0.2.1/RELEASE_NOTES_0.2.1.md +0 -51
  17. {unit_cell_gui-0.2.1 → unit_cell_gui-0.2.3}/LICENSE +0 -0
  18. {unit_cell_gui-0.2.1 → unit_cell_gui-0.2.3}/THIRD_PARTY_NOTICES.txt +0 -0
  19. {unit_cell_gui-0.2.1 → unit_cell_gui-0.2.3}/setup.cfg +0 -0
  20. {unit_cell_gui-0.2.1 → unit_cell_gui-0.2.3}/src/unit_cell_gui/hatching.py +0 -0
  21. {unit_cell_gui-0.2.1 → unit_cell_gui-0.2.3}/src/unit_cell_gui/models.py +0 -0
  22. {unit_cell_gui-0.2.1 → unit_cell_gui-0.2.3}/src/unit_cell_gui/py.typed +0 -0
  23. {unit_cell_gui-0.2.1 → unit_cell_gui-0.2.3}/src/unit_cell_gui/qt_config.py +0 -0
  24. {unit_cell_gui-0.2.1 → unit_cell_gui-0.2.3}/src/unit_cell_gui/render_geometry.py +0 -0
  25. {unit_cell_gui-0.2.1 → unit_cell_gui-0.2.3}/src/unit_cell_gui/view_helpers.py +0 -0
  26. {unit_cell_gui-0.2.1 → unit_cell_gui-0.2.3}/src/unit_cell_gui/viewer.py +0 -0
  27. {unit_cell_gui-0.2.1 → unit_cell_gui-0.2.3}/src/unit_cell_gui.egg-info/dependency_links.txt +0 -0
  28. {unit_cell_gui-0.2.1 → unit_cell_gui-0.2.3}/src/unit_cell_gui.egg-info/requires.txt +0 -0
  29. {unit_cell_gui-0.2.1 → unit_cell_gui-0.2.3}/src/unit_cell_gui.egg-info/top_level.txt +0 -0
  30. {unit_cell_gui-0.2.1 → unit_cell_gui-0.2.3}/tests/test_gl_geometry.py +0 -0
  31. {unit_cell_gui-0.2.1 → unit_cell_gui-0.2.3}/tests/test_render_geometry.py +0 -0
  32. {unit_cell_gui-0.2.1 → unit_cell_gui-0.2.3}/tests/test_unit_cell_gui.py +0 -0
@@ -1,5 +1,59 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.3 - 2026-10-06
4
+
5
+ ### Performance
6
+
7
+ - Render atoms with one indexed unit-sphere mesh and one compact instance
8
+ record per visible atom using `glDrawElementsInstanced`.
9
+ - Replace repeated per-vertex centre, radius, colour and occupancy data with
10
+ 144-byte instance records; keep the shared mesh and index buffers resident
11
+ during atom scale, colour, occupancy visibility and scene changes.
12
+ - Remove individual CPU sphere tessellation and the per-atom mesh cache.
13
+
14
+ ### Compatibility
15
+
16
+ - Preserve the public scene models, viewer aliases, display options, style
17
+ overrides, orientation synchronization and interaction signals.
18
+ - Keep OpenGL 3.3 core and GLSL 330 requirements, with 13 attribute locations
19
+ and no new dependencies or native extension.
20
+ - Preserve the original sphere triangles and normals, mixed/partial occupancy
21
+ materials, hidden occupancy sectors, external atoms, colour and engraving
22
+ modes, and the existing outline/intersection/hatching passes.
23
+ - Release and recreate mesh, index and instance buffers with viewer context
24
+ cleanup/reinitialization.
25
+
26
+ ## 0.2.2 - 2026-10-01
27
+
28
+ ### Fixed
29
+
30
+ - Individual polyhedron visibility changes now filter resident face, edge and
31
+ atom/face-intersection ranges at draw time, instead of rebuilding their
32
+ geometry and re-uploading the complete buffers.
33
+ - Apply the same visibility selection to opaque and transparent faces, edges,
34
+ hatching and intersection contours, including multiple polyhedra sharing a
35
+ site key.
36
+
37
+ ### Performance
38
+
39
+ - Cache engraving hatching separately for each polyhedron. Reuse GPU buffers
40
+ when the view and effective division count are unchanged; rebuild only the
41
+ affected polyhedra when visible depth extrema alter the density.
42
+ - Preserve the original hatching algorithms and density/GRIP normalization
43
+ over visible polyhedra. Keep at most four CPU density variants per polyhedron
44
+ for the current view; discard them when the view or scene changes.
45
+ - Vectorize finite-face clipping of sphere/face section segments while keeping
46
+ the original 160-sample circles and boundary tolerance.
47
+ - Defer intersection and hatching preparation until their layers are visible.
48
+ - Release per-polyhedron hatching GPU resources on scene replacement/clearing
49
+ and context cleanup; recreate them when needed.
50
+
51
+ ### Compatibility
52
+
53
+ - Keep all public scene models, display options, style overrides, viewer aliases
54
+ and orientation/interaction signals unchanged. Hosts using the existing
55
+ 0.2.x API do not need integration changes.
56
+
3
57
  ## 0.2.1 - 2026-09-15
4
58
 
5
59
  ### Fixed
@@ -8,7 +8,7 @@ authors:
8
8
  repository-code: https://github.com/ofussr/unit-cell-gui
9
9
  url: https://github.com/ofussr/unit-cell-gui
10
10
  orcid: https://orcid.org/0000-0002-5571-8525
11
- version: 0.2.1
12
- date-released: 2026-09-15
11
+ version: 0.2.3
12
+ date-released: 2026-10-06
13
13
  doi: 10.5281/zenodo.22714946
14
14
  license: MIT
@@ -2,6 +2,7 @@ include CHANGELOG.md
2
2
  include CITATION.cff
3
3
  include LICENSE
4
4
  include README.md
5
- include RELEASE_NOTES_0.2.1.md
5
+ include RELEASE_NOTES_0.2.2.md
6
+ include RELEASE_NOTES_0.2.3.md
6
7
  include THIRD_PARTY_NOTICES.txt
7
8
  recursive-include tests *.py
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: unit-cell-gui
3
- Version: 0.2.1
3
+ Version: 0.2.3
4
4
  Summary: PySide6 widget for rendering caller-supplied unit-cell scenes
5
5
  Author-email: Mikhail Mirushchenko <miruschenko98@gmail.com>
6
6
  License-Expression: MIT
@@ -137,6 +137,43 @@ Per-position colours, visibility and opaque-polyhedron selections are replaced
137
137
  atomically with `viewer.set_style_overrides(StyleOverrides(...))`. The widget
138
138
  copies these mappings, so the host can keep its own independent UI state.
139
139
 
140
+ ## Atom instancing
141
+
142
+ Atoms share one indexed sphere mesh with the same 16-by-24 tessellation as
143
+ previous releases. An OpenGL instance buffer stores each visible atom's
144
+ Cartesian centre, radius, eight RGB occupancy colours and cumulative occupancy
145
+ thresholds once, instead of repeating them for every triangle vertex. The atom
146
+ layer uses one `glDrawElementsInstanced` call.
147
+
148
+ The base sphere and its indices occupy 18,792 bytes per viewer; instance records
149
+ add 144 bytes per visible atom. For 1,000 atoms, these buffers total 162,792
150
+ bytes, compared with 328,320,000 bytes for the previous expanded atom buffer.
151
+ This comparison excludes bonds, outlines, polyhedra and Qt/driver overhead.
152
+ The number of sphere triangles is unchanged, so this is primarily a reduction
153
+ in geometry preparation and buffer storage, not a frame-rate guarantee.
154
+
155
+ OpenGL 3.3 core remains sufficient: the renderer uses 13 vertex attribute
156
+ locations, within the guaranteed minimum of 16. No C++ extension, new package
157
+ dependency or host-application API change is required.
158
+
159
+ ## Visibility and rendering caches
160
+
161
+ Both global and per-site polyhedron visibility filter already prepared geometry
162
+ at draw time. Faces, edges and atom/face intersection contours remain in GPU
163
+ buffers when a site is hidden or shown. This avoids rebuilding the full
164
+ polyhedron layer for each individual visibility change.
165
+
166
+ Engraving hatching is cached per polyhedron. Its density still follows the
167
+ depth range of the visible polyhedra: hiding the nearest or farthest object can
168
+ change other objects' effective division counts. Only affected hatch buffers
169
+ are updated. Rotation, zoom, panning and window-size changes keep the original
170
+ view-dependent hatching behaviour. CPU density variants are bounded and are
171
+ discarded when the view or scene changes.
172
+
173
+ Intersection contours and hatching are prepared when their layers are first
174
+ needed. The initial preparation still has a cost; subsequent site visibility
175
+ changes reuse the prepared data.
176
+
140
177
 
141
178
  ## Renderer compatibility
142
179
 
@@ -146,11 +183,14 @@ style-override, orientation-synchronization and interaction calls remain the
146
183
  same. `OpenGLUnitCellViewer` remains available as an explicit name and refers
147
184
  to the same renderer class.
148
185
 
186
+ ## Used in
187
+
188
+ `unit-cell-gui` is used as the crystal-structure viewer in [XRD Combine](https://github.com/ofussr/XRD-Combine), where it is integrated with CIF processing, diffraction tools, and synchronized crystallographic views.
149
189
 
150
190
  ## How to cite
151
191
 
152
192
  If you use `unit-cell-gui` in academic work, please cite the Zenodo record:
153
193
 
154
- [![DOI](https://zenodo.org/badge/1366573933.svg)](https://zenodo.org/badge/latestdoi/1366573933)
194
+ [![DOI](https://img.shields.io/badge/DOI-10.5281%2Fzenodo.22714946-blue.svg)](https://doi.org/10.5281/zenodo.22714946)
155
195
 
156
196
  You can also use the metadata provided in [`CITATION.cff`](CITATION.cff).
@@ -119,6 +119,43 @@ Per-position colours, visibility and opaque-polyhedron selections are replaced
119
119
  atomically with `viewer.set_style_overrides(StyleOverrides(...))`. The widget
120
120
  copies these mappings, so the host can keep its own independent UI state.
121
121
 
122
+ ## Atom instancing
123
+
124
+ Atoms share one indexed sphere mesh with the same 16-by-24 tessellation as
125
+ previous releases. An OpenGL instance buffer stores each visible atom's
126
+ Cartesian centre, radius, eight RGB occupancy colours and cumulative occupancy
127
+ thresholds once, instead of repeating them for every triangle vertex. The atom
128
+ layer uses one `glDrawElementsInstanced` call.
129
+
130
+ The base sphere and its indices occupy 18,792 bytes per viewer; instance records
131
+ add 144 bytes per visible atom. For 1,000 atoms, these buffers total 162,792
132
+ bytes, compared with 328,320,000 bytes for the previous expanded atom buffer.
133
+ This comparison excludes bonds, outlines, polyhedra and Qt/driver overhead.
134
+ The number of sphere triangles is unchanged, so this is primarily a reduction
135
+ in geometry preparation and buffer storage, not a frame-rate guarantee.
136
+
137
+ OpenGL 3.3 core remains sufficient: the renderer uses 13 vertex attribute
138
+ locations, within the guaranteed minimum of 16. No C++ extension, new package
139
+ dependency or host-application API change is required.
140
+
141
+ ## Visibility and rendering caches
142
+
143
+ Both global and per-site polyhedron visibility filter already prepared geometry
144
+ at draw time. Faces, edges and atom/face intersection contours remain in GPU
145
+ buffers when a site is hidden or shown. This avoids rebuilding the full
146
+ polyhedron layer for each individual visibility change.
147
+
148
+ Engraving hatching is cached per polyhedron. Its density still follows the
149
+ depth range of the visible polyhedra: hiding the nearest or farthest object can
150
+ change other objects' effective division counts. Only affected hatch buffers
151
+ are updated. Rotation, zoom, panning and window-size changes keep the original
152
+ view-dependent hatching behaviour. CPU density variants are bounded and are
153
+ discarded when the view or scene changes.
154
+
155
+ Intersection contours and hatching are prepared when their layers are first
156
+ needed. The initial preparation still has a cost; subsequent site visibility
157
+ changes reuse the prepared data.
158
+
122
159
 
123
160
  ## Renderer compatibility
124
161
 
@@ -128,11 +165,14 @@ style-override, orientation-synchronization and interaction calls remain the
128
165
  same. `OpenGLUnitCellViewer` remains available as an explicit name and refers
129
166
  to the same renderer class.
130
167
 
168
+ ## Used in
169
+
170
+ `unit-cell-gui` is used as the crystal-structure viewer in [XRD Combine](https://github.com/ofussr/XRD-Combine), where it is integrated with CIF processing, diffraction tools, and synchronized crystallographic views.
131
171
 
132
172
  ## How to cite
133
173
 
134
174
  If you use `unit-cell-gui` in academic work, please cite the Zenodo record:
135
175
 
136
- [![DOI](https://zenodo.org/badge/1366573933.svg)](https://zenodo.org/badge/latestdoi/1366573933)
176
+ [![DOI](https://img.shields.io/badge/DOI-10.5281%2Fzenodo.22714946-blue.svg)](https://doi.org/10.5281/zenodo.22714946)
137
177
 
138
178
  You can also use the metadata provided in [`CITATION.cff`](CITATION.cff).
@@ -0,0 +1,42 @@
1
+ # unit-cell-gui 0.2.2
2
+
3
+ This maintenance release fixes pauses when hiding or showing individual
4
+ polyhedra through `StyleOverrides.polyhedron_site_visibility`.
5
+
6
+ ## Faster individual visibility changes
7
+
8
+ - Keep polyhedron faces, edges and atom/face intersection contours in GPU
9
+ buffers and select visible site ranges during drawing.
10
+ - Cache engraving hatching per polyhedron and reuse unchanged GPU buffers.
11
+ When hiding a depth-extreme polyhedron changes other polyhedra's density,
12
+ update only the affected hatch geometry.
13
+ - Preserve the original visible-depth normalization, density and GRIP controls,
14
+ shared-edge hatch directions and intact quadrilateral faces.
15
+
16
+ ## Initial preparation and resource handling
17
+
18
+ - Vectorize sphere/face section clipping without reducing the original
19
+ 160-sample resolution or changing boundary tolerance.
20
+ - Prepare intersection contours and hatching only when their layers are needed.
21
+ - Bound CPU hatching variants for the current view and release per-polyhedron
22
+ GPU buffers when a scene is replaced, cleared or its context is cleaned up.
23
+
24
+ ## Compatibility
25
+
26
+ The public API is unchanged: `UnitCellViewer`, `CrystalCanvas`,
27
+ `OpenGLUnitCellViewer`, scene models, display options, style overrides,
28
+ orientation synchronization and interaction signals remain compatible with
29
+ 0.2.1. No host-application changes are required for this visibility fix.
30
+
31
+ ## Validation
32
+
33
+ - 41 tests passed with a real OpenGL context, including visibility, clipping,
34
+ hatching, resource cleanup and context-rebuild checks.
35
+ - 15 framebuffer comparisons against 0.2.1 were pixel-identical, covering
36
+ colour and engraving views, transparent and opaque polyhedra, individual and
37
+ global visibility, rotation, atom scaling, external atoms and quadrilateral
38
+ hatching.
39
+ - In one synthetic nine-octahedron scene on Mesa software OpenGL, median
40
+ individual-toggle time decreased from approximately 544 ms to 15 ms.
41
+ This is a local benchmark, not a timing guarantee for other structures or
42
+ hardware.
@@ -0,0 +1,53 @@
1
+ # unit-cell-gui 0.2.3
2
+
3
+ This release reduces atom geometry preparation and memory use by sharing one
4
+ indexed sphere mesh across every visible atom. Existing host applications can
5
+ keep their current integration code.
6
+
7
+ ## Atom rendering
8
+
9
+ - Draw the complete atom layer with `glDrawElementsInstanced`.
10
+ - Store each atom's centre, radius, eight RGB colours and cumulative occupancy
11
+ thresholds once in a 144-byte instance record.
12
+ - Keep one base sphere and its index buffer per viewer, totaling 18,792 bytes.
13
+ Retain the original 16-by-24 tessellation and all 720 triangles per sphere;
14
+ exact indexing preserves the original triangle order and normals.
15
+ - Remove CPU generation and caching of separate sphere meshes for every atom.
16
+ - Reuse the base sphere during scene/style changes and recreate all new GPU
17
+ resources after OpenGL context cleanup.
18
+
19
+ For 1,000 atoms, the main atom geometry buffers shrink from 328,320,000 bytes
20
+ (328.32 MB) to 162,792 bytes (approximately 0.163 MB), including the shared mesh
21
+ and indices. This excludes bonds, atom outlines, intersections, polyhedra and
22
+ Qt/driver overhead. Large scenes can still spend time on those other layers.
23
+ The sphere triangle count has not changed; this is not a frame-rate guarantee.
24
+
25
+ ## Compatibility
26
+
27
+ - Public API, scene models, viewer aliases, display/style options and signals
28
+ remain unchanged from 0.2.2.
29
+ - OpenGL 3.3 core and GLSL 330 remain sufficient; 13 vertex attributes are used,
30
+ below the guaranteed minimum of 16. No new dependencies or C++ extension.
31
+ - Preserve camera-facing mixed and partial occupancy sectors, hidden sectors,
32
+ colour overrides, external-atom filtering, atom scaling and engraving fills.
33
+ - Keep bonds, contours, intersections, polyhedra and hatching on their existing
34
+ rendering paths.
35
+
36
+ ## Validation
37
+
38
+ - 48 tests passed with Mesa software OpenGL forced to OpenGL 3.3 / GLSL 330,
39
+ including actual indexed instanced drawing, attribute divisors, index binding,
40
+ buffer sizes, cleanup and reinitialization. All 48 also passed using the
41
+ installed wheel, with Python sources compiled successfully.
42
+ - 20 framebuffer comparisons against commit `81f76a1` (0.2.2): 19 were
43
+ pixel-identical. One differed at one pixel by one channel step out of 255,
44
+ consistent with float32 transformation rounding. Cases cover colour/engraving,
45
+ eight and more than eight components, partial/hidden occupancy, external
46
+ atoms, rotation, scaling, transparent/opaque polyhedra and quadrilateral
47
+ hatching.
48
+ - Installed-wheel smoke check: two viewers embedded in one host window,
49
+ synchronized orientations and continued rendering after one viewer closes.
50
+ - In one local synthetic scene containing 1,000 single-component atoms, first
51
+ CPU atom preparation decreased from 7.063 s to 0.00984 s; repeated preparation
52
+ decreased from 0.410 s to 0.00842 s. These single-run measurements exclude
53
+ GPU rendering and other scene layers; they are not hardware timing guarantees.
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "unit-cell-gui"
7
- version = "0.2.1"
7
+ version = "0.2.3"
8
8
  description = "PySide6 widget for rendering caller-supplied unit-cell scenes"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -8,7 +8,7 @@ from .hatching import (
8
8
  quadrilateral_hatch_line_count,
9
9
  )
10
10
  from .models import Atom, AtomComponent, DisplayOptions, Polyhedron, Scene, StyleOverrides
11
- __version__ = "0.2.1"
11
+ __version__ = "0.2.3"
12
12
 
13
13
 
14
14
  def __getattr__(name):
@@ -55,6 +55,23 @@ def sphere_mesh(
55
55
  return np.asarray(positions, dtype=np.float32), np.asarray(normals, dtype=np.float32)
56
56
 
57
57
 
58
+ def indexed_sphere_mesh() -> tuple[np.ndarray, np.ndarray, np.ndarray]:
59
+ """Index the default unit sphere without changing its triangle sequence.
60
+
61
+ Exact deduplication preserves even the original seam and pole coordinates.
62
+ Expanding the returned indices reproduces ``sphere_mesh(zeros(3), 1)``.
63
+ """
64
+ positions, normals = sphere_mesh(np.zeros(3), 1.0)
65
+ vertices, indices = np.unique(
66
+ np.concatenate((positions, normals), axis=1), axis=0, return_inverse=True,
67
+ )
68
+ return (
69
+ np.ascontiguousarray(vertices[:, :3]),
70
+ np.ascontiguousarray(vertices[:, 3:]),
71
+ np.ascontiguousarray(indices, dtype=np.uint32),
72
+ )
73
+
74
+
58
75
  def cylinder_mesh(
59
76
  first: np.ndarray,
60
77
  second: np.ndarray,
@@ -133,4 +150,4 @@ def line_vertices(first: np.ndarray, second: np.ndarray) -> tuple[np.ndarray, np
133
150
  return positions, normals
134
151
 
135
152
 
136
- __all__ = ["cylinder_mesh", "line_vertices", "polygon_triangles", "sphere_mesh"]
153
+ __all__ = ["cylinder_mesh", "indexed_sphere_mesh", "line_vertices", "polygon_triangles", "sphere_mesh"]