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

Added straight skeleton 2 #29

Merged
merged 14 commits into from
May 12, 2024
Merged

Added straight skeleton 2 #29

merged 14 commits into from
May 12, 2024

Conversation

romanarust
Copy link
Member

New feature:

Straight skeletons 2:
https://doc.cgal.org/latest/Straight_skeleton_2/index.html

Upcoming add ons:

  • skeleton from polygon with holes
  • polygon offset

@romanarust romanarust requested a review from tomvanmele April 25, 2024 09:43
@tomvanmele
Copy link
Member

oh nice! will have a look...

Copy link
Member

@tomvanmele tomvanmele left a comment

Choose a reason for hiding this comment

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

looks very good. just a few minor things...

@@ -0,0 +1,33 @@
import numpy as np
from compas.geometry import normal_polygon
from compas.tolerance import Tolerance
Copy link
Member

Choose a reason for hiding this comment

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

currently you should do from compas.tolerance import TOL, which is the global instance of the Tolerance class.

i will replace this with a singleton in the future, but currently this would be better...

If the normal of the polygon is not [0, 0, 1].
"""
points = list(points)
tol = Tolerance()
Copy link
Member

Choose a reason for hiding this comment

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

remove

"""
points = list(points)
tol = Tolerance()
if not tol.is_allclose(normal_polygon(points, True), [0, 0, 1]):
Copy link
Member

Choose a reason for hiding this comment

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

TOL.is_allclose

{
poly.push_back(Point(V(i, 0), V(i, 1)));
}
assert(poly.is_counterclockwise_oriented());
Copy link
Member

Choose a reason for hiding this comment

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

perhaps it is worth checking what happens with these assertions on the Python side

Copy link
Member Author

@romanarust romanarust May 9, 2024

Choose a reason for hiding this comment

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

i removed the assert, as the orientation check is anyway on python side

@@ -0,0 +1,16 @@
from compas_cgal.straight_skeleton_2 import create_interior_straight_skeleton
Copy link
Member

Choose a reason for hiding this comment

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

perhaps it would be worth adding a few tests of "known"/"predictable" skeletons?

@tomvanmele
Copy link
Member

}
assert(poly.is_counterclockwise_oriented());
SsPtr iss = CGAL::create_interior_straight_skeleton_2(poly.vertices_begin(), poly.vertices_end());
Edges edgelist;
Copy link
Member

Choose a reason for hiding this comment

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

perhaps this typedef conflicts with the one from skeletonization.h

if(&*v1 < &*v2){
std::vector<double> s_vec = {v1->point().x(), v1->point().y(), 0};
std::vector<double> t_vec = {v2->point().x(), v2->point().y(), 0};
Edge edge = std::make_tuple(s_vec, t_vec);
Copy link
Member

Choose a reason for hiding this comment

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

same here...

Comment on lines 6 to 7
typedef std::tuple<std::vector<double>, std::vector<double>> Edge;
typedef std::list<Edge> Edges;
Copy link
Member

Choose a reason for hiding this comment

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

perhaps we can move these guys to the compas namespace?

Copy link
Member

Choose a reason for hiding this comment

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

same for the definitions in skeletonization.h...

Copy link
Member Author

Choose a reason for hiding this comment

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

i put the typedefs of Edge and Edges into the compas namespace and removed them from skeletonization and straight_skeleton_2.. still failing on windows 😒

Copy link
Member Author

Choose a reason for hiding this comment

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

It finally builds! just forgot to add the "straight_skeleton_2.cpp" to the setup.py 😅

@tomvanmele
Copy link
Member

cool seems to work now 🎉

Copy link
Member

@tomvanmele tomvanmele left a comment

Choose a reason for hiding this comment

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

LGTM

@tomvanmele tomvanmele merged commit acd1f64 into main May 12, 2024
10 checks passed
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