Skip to content

Conversation

@3dJan
Copy link
Collaborator

@3dJan 3dJan commented Oct 22, 2025

This pull request introduces several improvements and new features to the Gladius project, focusing on enhanced Linux desktop integration, a more flexible beam lattice acceleration structure, build and packaging improvements, and codebase maintainability. The most significant updates are grouped as follows:

Linux Desktop Integration and Packaging Improvements:

  • Added generation and installation of a .desktop launcher and icon for Linux, improving desktop environment integration. The icon is now installed in the system icon theme directory, and the desktop entry is generated from a template (gladius/cmake/desktop/gladius.desktop.in) and installed system-wide. [1] [2]
  • The installer now ensures all relevant binaries are built before packaging, and the MCP variant is installed only if present, making packaging more robust and flexible. [1] [2]
  • Licenses are now installed at the root of the install prefix instead of a subdirectory, and additional file patterns for installation are included. [1] [2]

Beam Lattice Acceleration Refactor:

  • Replaced the boolean useVoxelAcceleration with a new BeamLatticeAcceleration enum, allowing explicit selection between BVH and Voxel acceleration structures. This change improves code clarity and extensibility in BeamLatticeResource. [1] [2] [3] [4] [5] [6]

Build System and Versioning Updates:

  • Updated the project and installer version to 1.2.15 and improved build cache messaging for better developer feedback. Also, the install target now depends on building all targets to avoid packaging incomplete builds. [1] [2] [3] [4]

OpenCL Program Management Enhancements:

  • Added support for an experimental two-level pipeline in CLProgram, enabled binary caching by default, and introduced new signature helpers for cache management. [1] [2] [3]

Codebase Maintenance and Minor Improvements:

  • Added missing includes and new lowering passes in Document.cpp, commented out unused saveBackup() call, and updated the document refresh and optimization logic for improved maintainability. [1] [2] [3] [4] [5]
  • Added a new reviewer chat mode document for code review guidance.

…ew function models from selected nodes and replace them with FunctionCall in the source model
…unctionExtractor

- Introduced a new struct `ExtractNameEntry` in `ModelEditor.h` to manage extraction name editing state, including a stable key, editable name, and type.
- Added vectors to store proposed and edited input/output names for extraction.
- Implemented a unit test in `FunctionExtractor_tests.cpp` to verify that custom names for function arguments and outputs are applied correctly and remain unique during extraction.
…ude initial steps for understanding recent commits
… enhance user experience with back/forward navigation
…apability and update MainWindow to toggle span mode
…de IDs; update OutputPortReferenceAnalyzer to utilize this method for marking reachable nodes
…d related nodes; update legacy references to support new naming convention
…ace ".matrix" with ".result" in output resolution logic
…rs and restore metadata; improve input handling in NodeBase

[ToOCLVisitor] Update output port references from "Matrix" to "Result" for consistency in output resolution logic
…st files

[GladiusLib_tests.cpp] Refactor tests to include utility functions for 3MF file handling and implement parameterized tests for bounding box validation
3dJan added 27 commits October 6, 2025 13:25
… enum for acceleration type and update related methods
…mpute spatial gradients using central finite differences and mirror referenced function inputs
- Introduced the FunctionGradient node to compute the normalized gradient of a referenced function.
- Implemented necessary methods for resolving function IDs, updating inputs and outputs, and validating configurations.
- Enhanced the Assembly and Model classes to accommodate FunctionGradient nodes.
- Updated the NodeFactory to create FunctionGradient instances.
- Added UI controls for FunctionGradient in NodeView, allowing users to select scalar outputs and vector inputs.
- Implemented visitor patterns for FunctionGradient in various visitors (ToCommandStreamVisitor, ToOCLVisitor, Visitor).
- Ensured proper integration with existing nodes and error handling for invalid configurations.
…p size control

Replace the combo widgets with button-driven popups for FunctionGradient scalar/vector selection to avoid dangling references in the node editor. Use ModelEditor->showPopupMenu to open per-node popups, capture data by-value, and apply selections by updating the node, setting m_parameterChanged, and marking the model as modified when available

Replace ImGui::SeparatorText with a plain header text for the gradient section

Add a Step Size DragFloat control that clamps negative values to zero, ensures the parameter is set modifiable, sets m_parameterChanged, and marks the model modified on change
…d avoid backup during async refresh

- ToOCLVisitor: add checks and early returns for missing/unused gradient output, null assembly, missing referenced model, wrong output type, unconsumed output, missing/invalid vector input and missing step size; emit a safe float3(0.0f) fallback (inlined or as local var) instead of throwing to make OCL generation resilient
- Writer3mf: detect functions containing FunctionGradient nodes and skip 3MF serialization while logging a warning to avoid NodeTypeMap/runtime errors; add TODO for future full serialization support
- Document: comment out saveBackup() call in refreshModelAsync to prevent backups being triggered during asynchronous model refresh
…, cache lowered functions, validate configurations, wire parameters and replace FunctionGradient nodes with FunctionCall; include parameter copying, consumer rewiring, name sanitization and error reporting
…ector to ignore non-gradient nodes during detection
…creating FunctionGradient nodes from FunctionCall and run lowering pass with error reporting

- Add functionCallControls to create a FunctionGradient from a FunctionCall (set function id, register inputs/outputs, copy parameter links or values, mark outputs used)
- Add "Create Function Gradient" button invocation in node content rendering
- Add "Lower Function Gradients" button and logic in functionGradientControls to run nodes::LowerFunctionGradient, collect/report errors, update assembly/model state and notify ModelEditor
- Add m_lowerGradientMessage and m_lowerGradientMessageIsError members for feedback display
- Add necessary include for nodes/LowerFunctionGradient and <exception>
- Wrap lowering/creation operations in try/catch and surface messages; set m_parameterChanged/m_modelChanged when modifications occur
…n UI, run lowering pass during assembly flattening, and fix mask wiring in lowering
…t lowering, reuse and error reporting; add ToOclVisitor fallback test to FunctionGradient_tests
…rough lowering and OCL emission

- Add FieldNames::Gradient and FieldNames::Magnitude constants
- Extend FunctionGradient type rule to include Gradient (float3) and Magnitude (float)
- Preserve and create Gradient and Magnitude output ports in FunctionGradient::updateInternalOutputs
- In LowerFunctionGradient, register Gradient and Magnitude inputs on synthesized end node and wire:
  - raw gradient -> mask -> Gradient input (Multiplication)
  - length -> mask -> Magnitude input (Multiplication)
- In ToOclVisitor, emit raw gradient and magnitude outputs (support inlining where possible or emit defined variables)
…xtension, lowering, and NormalizeDistanceField

Add comprehensive architecture and design documents to thegreatplan:
- gladius/thegreatplan/3mf-volumetric-implementation.md: describe 3MF volumetric & implicit namespaces, node graph model, pipeline, data types, and integration guidance
- gladius/thegreatplan/FunctionGradientExtension.md: document FunctionGradient extension (raw gradient and magnitude outputs), codegen/inlining behavior, masking/zero-gradient handling, and tests
- gladius/thegreatplan/FunctionGradientLowering.md: specify LowerFunctionGradient pass, function synthesis, caching, replacement algorithm, helpers, edge cases, and tests
- gladius/thegreatplan/NormalizeDistanceFieldNode.md: propose NormalizeDistanceField node, lowering approach using FunctionGradient.magnitude, API/UX, testing and rollout plan
- gladius/thegreatplan/more_ideas.md: add brief notes for mesh→beam-lattice importer and gradient node idea

Provide implementation notes, testing strategy, and rollout guidance to enable subsequent implementation and integration
…nt and magnitude outputs

Add assertions and new tests to verify FunctionGradient exposes Gradient and Magnitude outputs
and that ToOclVisitor emits gradient/magnitude-related variables when those outputs are used.
Update LowerFunctionGradient_tests to expect lowered functions to include Gradient and Magnitude
outputs so lowering and OCL emission behavior are validated
…I, and 3MF/OCL support

- Introduce NormalizeDistanceField node (DerivedNodes.h / DerivedNodes.cpp)
  - mirror referenced function inputs as arguments, provide FunctionId and StepSize params
  - add selection/validation helpers and getters/setters for configuration

- Implement LowerNormalizeDistanceField lowering pass (new LowerNormalizeDistanceField.{h,cpp})
  - find NormalizeDistanceField nodes, create helper functions that mirror referenced inputs
  - compose normalization by creating helper FunctionCall, FunctionGradient, Max (epsilon), and Division nodes
  - rewire consumers to normalized output, remove original NormalizeDistanceField node
  - add error reporting, sanitization, parameter copying and linking utilities

- Wire lowering into assembly flattening (Document.cpp)
  - run LowerNormalizeDistanceField after LowerFunctionGradient and before OptimizeOutputs

- UI: add creation and lowering controls in NodeView (NodeView.h / NodeView.cpp)
  - allow creating a NormalizeDistanceField from a FunctionCall and lowering selected nodes interactively
  - add status messaging for lowering results

- Visitor and OCL: add visitor hook and annotate ToOCL fallback output
  - add NormalizeDistanceField visit methods (Visitor.h / Visitor.cpp)
  - add nodesfwd entries and FieldNames for new params
  - annotate FunctionGradient fallback in ToOCLVisitor output for diagnostics

- 3MF: mark import/export behavior for unsupported nodes
  - add TODO comments in Importer3mf for NormalizeDistanceField/FunctionGradient import
  - update Writer3mf to detect and skip functions containing FunctionGradient or NormalizeDistanceField with a warning

- Misc: add helper declarations and plumbing to support new node and lowering
…g, UI, OCL and tests

- Importer3mf: map new 3MF node types (BeamLattice, FunctionGradient, NormalizeDistance) and allow dynamic inputs for FunctionCall/FunctionGradient/NormalizeDistance; initialize parameters (FunctionId/StepSize) and read selected scalar/vector names for implicit nodes
- Writer3mf: add serialization for FunctionGradient nodes (emit scalar/vector selection, function resource and step constant) and update unsupported-node detection to skip NormalizeDistanceField until serialization is implemented
- nodes/DerivedNodes: rename FunctionGradient vector output to NormalizedGradient and update type rules/ports and NormalizeDistanceField outputs to use Result per spec
- nodes/LowerFunctionGradient: wire normalized gradient output through lowering, register mirrored NormalizedGradient input and rewire consumers accordingly
- nodes/OptimizeOutputs & nodes/ToOCLVisitor: update consumers and inlining logic to reference NormalizedGradient
- nodes/nodesfwd: add FieldNames::NormalizedGradient and adjust StepSize identifier
- ui/NodeView: implement full NormalizeDistanceField configuration UI (select scalar output, select vector input, step size control, validation, and lowering button) with diagnostics and guarded lowering
- tests: add NormalizeDistanceField unit tests covering inputs/outputs, defaults, lowering behavior (helper function, FunctionGradient creation, Division node), category and description
- vcpkg overlay: update lib3mf REF and SHA to volumetric_beamlattice_gradient branch
- docs: remove obsolete 3mf-volumetric-implementation.md

Ensure consistency across nodes and lowering for normalized gradient handling and preserve backward compatibility where applicable
Update CPACK_PACKAGE_VERSION_PATCH in CMakeLists, installDir in CMakePresets.json, revision in src/version.h, and version-string in vcpkg.json
Copilot AI review requested due to automatic review settings October 22, 2025 13:47
@3dJan 3dJan merged commit 36531b5 into main Oct 22, 2025
5 of 7 checks passed
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR merges the develop branch into the current branch, introducing significant improvements across Linux desktop integration, build infrastructure, node graph capabilities, and codebase architecture. Key changes include:

  • Enhanced Linux desktop integration with .desktop launcher and icon installation
  • New FunctionGradient and NormalizeDistanceField nodes for advanced implicit modeling
  • Improved build system with version bump to 1.2.15 and dependency updates
  • UI enhancements including function navigation history, node extraction refactoring, and multi-monitor fullscreen support
  • New test infrastructure for output port reference analysis and gradient operations

Reviewed Changes

Copilot reviewed 72 out of 80 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
vcpkg.json, version.h Version bump to 1.2.15
vcpkg-overlay-ports/lib3mf* Removed unused lib3mflinux_ overlay, updated lib3mf reference
thegreatplan/*.md Added comprehensive design documents for gradient nodes, distance field normalization, and function extraction
tests/unittests/*_tests.cpp New test suites for FunctionGradient, NormalizeDistanceField, OutputPortReferenceAnalyzer, and FunctionExtractor
tests/integrationtests/* Parameterized integration tests for bounding box validation across all 3MF files
src/ui/* Major UI enhancements: navigation history, function extraction dialog, beam lattice import, multi-monitor support
src/nodes/* Core node system additions: FunctionGradient, NormalizeDistanceField, lowering transformations, reference analyzer
src/nodes/ToOCLVisitor.* Extended OpenCL code generation for gradient nodes with inlining optimizations
src/nodes/NodeBase.* Improved parameter type updating with metadata preservation
src/mcp/* MCP integration improvements for graph layout detection
src/io/3mf/* New BeamLatticeExporter for 3MF beam lattice export


std::unordered_set<std::string> const & getUnsupported3mfFiles()
{
static std::unordered_set<std::string> const unsupported{
Copy link

Copilot AI Oct 22, 2025

Choose a reason for hiding this comment

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

The unsupported file list hardcodes "3mf-implicit.3mf" with a comment referencing GLA-OpenCL-45. Consider adding the ticket reference as an inline comment or using a more descriptive name to clarify why this file is excluded, improving maintainability when the issue is resolved.

Suggested change
static std::unordered_set<std::string> const unsupported{
static std::unordered_set<std::string> const unsupported{
// Excluded due to known issue tracked in GLA-OpenCL-45

Copilot uses AI. Check for mistakes.
{
auto const color = m_lowerGradientMessageIsError ? ImVec4(1.f, 0.4f, 0.4f, 1.f)
: ImVec4(0.6f, 0.8f, 1.f, 1.f);
ImGui::TextColored(color, "%s", m_lowerGradientMessage.c_str());
Copy link

Copilot AI Oct 22, 2025

Choose a reason for hiding this comment

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

[nitpick] Using "%s" format specifier with c_str() is correct to prevent format string injection vulnerabilities. However, consider simplifying by using ImGui::TextColored(color, m_lowerGradientMessage.c_str()) directly since the message doesn't contain format specifiers, or ensure consistent use of the safer pattern throughout the codebase.

Suggested change
ImGui::TextColored(color, "%s", m_lowerGradientMessage.c_str());
ImGui::TextColored(color, m_lowerGradientMessage.c_str());

Copilot uses AI. Check for mistakes.
// The gradient output is always consumed if the gradient node exists
// (it needs to evaluate the function to compute the gradient)
auto const & gradientOutputs = gradientNode.getOutputs();
auto gradientOutIter = gradientOutputs.find(FieldNames::NormalizedGradient);
Copy link

Copilot AI Oct 22, 2025

Choose a reason for hiding this comment

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

The code checks for FieldNames::NormalizedGradient but based on the node design in other files, the output field should be FieldNames::Vector. Verify the correct field name is used; this may prevent proper optimization of the gradient node's scalar output consumption.

Suggested change
auto gradientOutIter = gradientOutputs.find(FieldNames::NormalizedGradient);
auto gradientOutIter = gradientOutputs.find(FieldNames::Vector);

Copilot uses AI. Check for mistakes.
// Check if parameter already exists and has a different type
const auto iter = m_parameter.find(expectedName);
OptionalSource source;
ParameterId existingId{-1};
Copy link

Copilot AI Oct 22, 2025

Choose a reason for hiding this comment

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

Using -1 as a sentinel value for ParameterId is type-unsafe. Consider using std::optional<ParameterId> or defining a named constant like InvalidParameterId to make the intent clearer and prevent potential type confusion.

Copilot uses AI. Check for mistakes.
Comment on lines +218 to +224
char filenameBuf[512];
size_t copyLen = std::min(m_filename.length(), sizeof(filenameBuf) - 1);
std::memcpy(filenameBuf, m_filename.c_str(), copyLen);
filenameBuf[copyLen] = '\0';
if (ImGui::InputText("##filename", filenameBuf, sizeof(filenameBuf)))
{
m_filename = filenameBuf;
Copy link

Copilot AI Oct 22, 2025

Choose a reason for hiding this comment

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

Manual buffer management with memcpy is error-prone. Since this uses ImGui's InputText with imgui_stdlib.h included (line 8), use ImGui::InputText("##filename", &m_filename) directly which accepts std::string* and eliminates the manual buffer handling.

Suggested change
char filenameBuf[512];
size_t copyLen = std::min(m_filename.length(), sizeof(filenameBuf) - 1);
std::memcpy(filenameBuf, m_filename.c_str(), copyLen);
filenameBuf[copyLen] = '\0';
if (ImGui::InputText("##filename", filenameBuf, sizeof(filenameBuf)))
{
m_filename = filenameBuf;
if (ImGui::InputText("##filename", &m_filename))
{
// m_filename is updated automatically

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants