-
Notifications
You must be signed in to change notification settings - Fork 7
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
Adding straight skeleton with holes #30
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
This file contains 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
This file contains 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,42 @@ | ||
from compas.datastructures import Graph | ||
from compas.geometry import Polygon | ||
from compas_viewer import Viewer | ||
|
||
from compas_cgal.straight_skeleton_2 import create_interior_straight_skeleton_with_holes | ||
|
||
points = [ | ||
(-1.91, 3.59, 0.0), | ||
(-5.53, -5.22, 0.0), | ||
(-0.39, -1.98, 0.0), | ||
(2.98, -5.51, 0.0), | ||
(4.83, -2.02, 0.0), | ||
(9.70, -3.63, 0.0), | ||
(12.23, 1.25, 0.0), | ||
(3.42, 0.66, 0.0), | ||
(2.92, 4.03, 0.0), | ||
(-1.91, 3.59, 0.0), | ||
] | ||
|
||
holes = [ | ||
[(0.42, 0.88, 0.0), (1.1, -1.0, 0.0), (-1.97, -0.93, 0.0), (-1.25, 1.82, 0.0)], | ||
[(4.25, -0.64, 0.0), (2.9, -3.03, 0.0), (2.12, -2.16, 0.0), (2.89, -0.36, 0.0)], | ||
[(10.6, 0.29, 0.0), (9.48, -1.54, 0.0), (5.48, -1.26, 0.0), (5.98, -0.04, 0.0)], | ||
] | ||
|
||
|
||
polygon = Polygon(points) | ||
holes = [Polygon(hole) for hole in holes] | ||
lines = create_interior_straight_skeleton_with_holes(polygon, holes) | ||
graph = Graph.from_lines(lines) | ||
|
||
# ============================================================================== | ||
# Viz | ||
# ============================================================================== | ||
|
||
viewer = Viewer(width=1600, height=900) | ||
viewer.renderer_config.show_grid = False | ||
viewer.scene.add(graph, edgecolor=(1.0, 0.0, 0.0)) | ||
viewer.scene.add(polygon) | ||
for hole in holes: | ||
viewer.scene.add(hole) | ||
viewer.show() |
This file contains 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
This file contains 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
This file contains 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
This file contains 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if the return value is a list polylines (not lines), it will not always be possible to directly convert this into a graph. perhaps it would be helpful to have a helper for making the conversion...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The skeleton function is implemented to always return lines, so it should work to always convert them to a graph.
But I agree that the conversion is not proper yet. Ideally the return value should not be
PolylinesNumpy
, but acompas.datastructures.mesh
, as it could represent CGAL's data type for theStraightSkeleton_2
:https://doc.cgal.org/Manual/4.1/doc_html/cgal_manual/Straight_skeleton_2_ref/Concept_StraightSkeleton_2.html#Cross_link_anchor_1072
I anyway plan to add some other functions like the
create_interior_weighted_straight_skeleton_2
. So maybe I will tackle this in the next PR.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok so current one can be merged?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes