Skip to content
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

Implement feature tree #1

Open
marcus7070 opened this issue Dec 10, 2019 · 6 comments
Open

Implement feature tree #1

marcus7070 opened this issue Dec 10, 2019 · 6 comments

Comments

@marcus7070
Copy link
Owner

References

Taken from here:

RoadMap: Planned Features

Selectors

tagged entities

support tagging entities when they are created, so they can be selected later on using that tag. ideally, tags are propagated to features that are created from these features ( ie, an edge tagged with ‘foo’ that is later extruded into a face means that face would be tagged with ‘foo’ as well )


Taken from cadquery/cadquery issue number 50 (not linking properly because I don't want to ping that issue with a link to this shitty draft):

Implement Feature Tree

CQ 2.0 should have a feature tree, which stores operations and their results in a way that can be searched and referenced by later steps.

Each branch in the tree should have an id, and an associated operation.

The tree will be stored in the modelling context.


Taken from cadquery/cadquery issue number 49:

Implement Selection by Operation ID

We need to be able to select geometry by the operationID that created it. This could require fingerprinting or other fancy tricks, since OCC does not provide an out-of-the-box way to identify which faces, edges, etc, were created by a given operation.

marcus7070 pushed a commit that referenced this issue Dec 28, 2019
@marcus7070
Copy link
Owner Author

^ GitHub is being silly, that's not this issue.

@marcus7070
Copy link
Owner Author

An idea:
Store a "feature" in an attribute of the CQ object every time a solid is created. Selectors can operate on a "feature" instead of the context solid.

part = (
    cq.Workplane("XY")
    .box(5, 5, 5)
    .box(1, 1, 10).tag("foo")
    .sphere(5)
    .faces(">X", tag="foo", feature=True)
)

^ will return the face of the tall thin box. feature=False would return the face of the first cube. Omitting the tag would select nothing, because it's looking for faces on the sphere.

feature=True could also be used without the tag argument, which would search the parent chain for the nearest .feature attribute, like how CQ already searches for the first solid to use and the context solid.

Rewrite all Boolean operators to include a call to CQ.create_feature(). .create_feature() takes a solid. For example, if the operation is a subtract then .create_feature() should be called with the solid to subtract.

CQ-editor could use feature tree display, where highlighting an item in the feature tree shows CQ.feature rather than CQ.objects.

@marcus7070
Copy link
Owner Author

log_feature might be a better name than create_feature, since no solids are created during this call.

@marcus7070
Copy link
Owner Author

Could do some fancy CQ.__getattribute__ stuff to log each method called on a CQ object, so that calls could be associated with CQ objects in the parent chain, or collected for features.

This would allow pretty icons next to each feature in the feature tree. Not too sure what else I could do with it.

@marcus7070
Copy link
Owner Author

At the occ_impl layer, write a decorator that appends the returned object to occ_impl.feature stack. At the fluent API level, CQ.newObject pops the whole occ.impl.feature stack and saves it.

@marcus7070
Copy link
Owner Author

I like storing the feature tree in CQ objects as part of the parent chain, because that enables garbage collection tied to the CQ object.

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

No branches or pull requests

1 participant