Material Management
Relevant source files
The following files were used as context for generating this wiki page:
Material Management is a centralized system within the project designed to define, store, and manage material properties used across various workbenches, such as FEM and CAM. It provides a standardized framework for material cards, which include physical, mechanical, thermal, and rendering properties. The system ensures consistency by utilizing a common data model and a centralized manager to handle material libraries and inheritance.
The system is architected around a hierarchy where individual materials can inherit properties from parent materials, organized into libraries for easy access and reuse. This module is critical for engineering simulations and manufacturing operations, where material-specific data like Young's Modulus or Density directly impacts analysis results and toolpath calculations.
Sources: src/Mod/Material/App/Materials.cpp, src/Mod/CAM/Roadmap/Epics/FeedsAndSpeeds.md:25-35
Core Architecture
The architecture of the Material Management system relies on three primary components: the MaterialManager, MaterialLibrary, and the Material object itself.
Component Overview
| Component | Description |
|---|---|
MaterialManager | A singleton class that manages the global state of materials, including loading libraries and resolving material requests by UUID. |
MaterialLibrary | A collection of material files stored on disk, providing a logical grouping for materials (e.g., "Steel", "Plastics"). |
Material | The core data object representing a single material, containing properties, inheritance links, and metadata. |
MaterialProperty | Represents a specific attribute of a material (e.g., Yield Strength), supporting various data types like Quantities, Floats, and Colors. |
| Sources: src/Mod/Material/App/MaterialManager.cpp:45-60, src/Mod/Material/App/Materials.cpp:32-45 |
Class Relationships
The following class diagram illustrates the relationships between the core material management classes and their property structures.
The MaterialManager acts as the primary entry point for accessing materials globally within the application.
Sources: src/Mod/Material/App/MaterialManager.cpp, src/Mod/Material/App/Materials.cpp:665-680
Material Data Model
Materials are defined using a structured schema that categorizes properties into functional groups. This is often serialized into YAML-based material cards.
Property Categories
The project defines several standard categories for material data, as evidenced in the material templates:
- General: Metadata such as Name, Author, License, and Description.
- Mechanical: Engineering constants like
YoungsModulus,PoissonRatio,YieldStrength, andDensity. - Thermal: Properties for heat analysis including
SpecificHeatandThermalConductivity. - Rendering: Visualization data like
DiffuseColor,Shininess, andTransparency. - VectorRendering: Line widths and patterns for 2D technical drawings.
Sources: src/Mod/Material/Templatematerial.yml:45-180
Property Data Types
The MaterialProperty class handles multiple data types to support complex engineering units and values.
Individual properties can be simple scalars or complex multidimensional arrays used for table lookups in advanced modules.
Sources: src/Mod/Material/App/Materials.cpp:115-150, src/Mod/Material/Templatematerial.yml:85-100
Inheritance and Persistence
The system supports a robust inheritance model where a material can derive from a "Father" material. This allows for hierarchical definitions, such as "Stainless Steel" inheriting from "Steel".
Inheritance Logic
When a material is saved as inherited, only the properties that differ from the parent are stored in the child material card. This reduces data redundancy and ensures that updates to base material properties (e.g., a correction in base Steel density) propagate to all specialized variants.
Sources: src/Mod/Material/App/Materials.cpp:1115-1140, src/Mod/Material/Templatematerial.yml:70-75
Validation Process
Before a material is used or saved, the system performs validation to ensure data integrity across the inheritance chain.
Validation ensures that property counts, types, and unit compatibility match between local and remote (inherited) versions of a material.
Sources: src/Mod/Material/App/Materials.cpp:1388-1440
Integration with CAM and FEM
Material Management provides the "Machinability" model used by the CAM workbench to calculate feeds and speeds.
Machinability and F&S Resolution
In the CAM workbench, the FeedSpeedResolver consults the Machinability data stored within the Material objects. This data typically includes per-tool-material curves for surface speed (Vc) and chipload (Fz).
Sources: src/Mod/CAM/Roadmap/Epics/FeedsAndSpeeds.md:85-110
| Feature | Machinability Data Usage |
|---|---|
| Tool Preset | Reads presets stored on the ToolBit but refers to the material for context. |
| Rule Registry | Matches machining rules against the workpiece material properties. |
| Formula Provider | Uses Density and SpecificHeat for thermal load estimations during cutting. |
| Sources: src/Mod/CAM/Roadmap/Epics/FeedsAndSpeeds.md:130-150 |
Summary
Material Management is a foundational module that standardizes how physical and aesthetic characteristics are defined within the project. By utilizing a centralized MaterialManager and a hierarchical inheritance model, it provides a scalable way to handle the vast array of materials required for engineering and manufacturing. Its integration with CAM and FEM ensures that simulation and production parameters are grounded in accurate, validated material data.
Sources: src/Mod/Material/App/MaterialManager.cpp, src/Mod/Material/App/Materials.cpp:1350-1365