-
Notifications
You must be signed in to change notification settings - Fork 9
[FXC-6484] Add CADDesignIntent model and design_intent field to GeometryEntityInfo #1946
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
Open
andrzej-krupka
wants to merge
1
commit into
main
Choose a base branch
from
andrzej/cad-design-intent
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| """Data models for CAD design intent (feature tree) metadata.""" | ||
|
|
||
| from typing import Dict, List, Optional | ||
|
|
||
| import pydantic as pd | ||
|
|
||
| from flow360.component.simulation.framework.base_model import Flow360BaseModel | ||
|
|
||
|
|
||
| class CADFeature(Flow360BaseModel): | ||
| """A single CAD feature (e.g., fillet, chamfer, extrusion) from the CAD feature tree.""" | ||
|
|
||
| id: str = pd.Field(description="Deterministic UUID identifying this feature.") | ||
| name: str = pd.Field(description="Feature name as reported by the CAD kernel.") | ||
| cad_type: str = pd.Field(description="CAD feature type string (e.g., 'Fillet', 'Extrude').") | ||
| parent_id: str = pd.Field( | ||
| "", description="ID of the parent feature, or empty string for root features." | ||
| ) | ||
| produced_entity_ids: List[str] = pd.Field( | ||
| [], | ||
| description="IDs of geometry entities (faces/edges) produced as the primary output of this feature.", | ||
| ) | ||
| reference_entity_ids: List[str] = pd.Field( | ||
| [], | ||
| description="IDs of geometry entities used as construction or positioning references.", | ||
| ) | ||
| support_entity_ids: List[str] = pd.Field( | ||
| [], | ||
| description="IDs of geometry entities used as support (e.g., faces selected for a fillet).", | ||
| ) | ||
| properties: Dict[str, str] = pd.Field( | ||
| {}, | ||
| description="Key-value pairs of feature parameters (e.g., radius, depth).", | ||
| ) | ||
| child_feature_ids: List[str] = pd.Field( | ||
| [], | ||
| description="IDs of child features in the feature tree.", | ||
| ) | ||
|
|
||
| def get_all_entity_ids(self) -> List[str]: | ||
| """Return the union of all entity IDs referenced by this feature.""" | ||
| return list( | ||
| dict.fromkeys( | ||
| self.produced_entity_ids + self.reference_entity_ids + self.support_entity_ids | ||
| ) | ||
| ) | ||
|
|
||
|
|
||
| class CADDesignIntent(Flow360BaseModel): | ||
| """Top-level container for CAD design intent extracted from the feature tree.""" | ||
|
|
||
| version: str = pd.Field("0.1.0", frozen=True) | ||
| features: List[CADFeature] = pd.Field( | ||
| [], description="Flat list of all CAD features extracted from the model." | ||
| ) | ||
|
|
||
| def get_feature_by_id(self, feature_id: str) -> Optional[CADFeature]: | ||
| """Return the feature with the given ID, or None if not found.""" | ||
| for feature in self.features: | ||
| if feature.id == feature_id: | ||
| return feature | ||
| return None | ||
|
|
||
| def get_features_by_type(self, cad_type: str) -> List[CADFeature]: | ||
| """Return all features whose cad_type matches (case-insensitive).""" | ||
| lower = cad_type.lower() | ||
| return [f for f in self.features if f.cad_type.lower() == lower] | ||
|
|
||
| def get_producing_features(self, entity_id: str) -> List[CADFeature]: | ||
| """Return all features that produced the given entity ID.""" | ||
| return [f for f in self.features if entity_id in f.produced_entity_ids] | ||
|
|
||
| def get_sibling_features(self, feature_id: str) -> List[CADFeature]: | ||
| """Return features that share the same parent as the given feature (excluding itself).""" | ||
| feature = self.get_feature_by_id(feature_id) | ||
| if feature is None: | ||
| return [] | ||
| return [ | ||
| f | ||
| for f in self.features | ||
| if f.parent_id == feature.parent_id and f.id != feature_id | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.