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
Sketcher: Arc to Other distance constraint #9166
Conversation
Is there a way of moving the angle of the constraint after placing it? |
@adrianinsaval Angle is defined by the shorter distance between circles so it can't move. |
#9257 fixes the display problems |
Why is this not going in 0.21 ? As circle to circle distance was introduced in 0.21 it would make sense that this goes in as well. Edit: It's a known issue: (Besides, I can't seem to be able to use circle distances when the tool is activated first (before selection). |
@PaddleStroke this PR requires #9703 |
This one could go in as well Imo. It's not a big change and would make things more consistent rather than having half of circle-circle distance merged in 0.21. |
I tend to agree but we would need someone to review it. |
I can give it a go tomorrow if my review is deamed sufficient. |
581e64a
to
9638f98
Compare
#9703 merged so this one can become a not-draft Pull request |
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.
Code looks good to me.
Main complain is that the syntax changes should not belong to this PR and should be a separate PR.
Without the syntax changes this PR would be like 150 lines. Here it's 1500 ... It makes reviewing much more difficult and long.
I have not built to test.
9638f98
to
201a283
Compare
@FlachyJoe can you resolve those conflicts? |
@PaddleStroke Do I need to add anything to make this work with the Constrain Contextual implementation? |
Just rebase and chennes will merge I think. On my side I'm currently
implementing the point to circle constraint in sketcher_dimension, so I can
look at arc to circle at the same time.
By the way do you plan to do point to arc as well? And line to arc ?
…On Wed, Aug 30, 2023, 22:35 Florian Foinant-Willig ***@***.***> wrote:
@PaddleStroke <https://github.com/PaddleStroke> Do I need to add anything
to make this work with the Constrain Contextual implementation?
—
Reply to this email directly, view it on GitHub
<#9166 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEYO6MK7ARYLXKL4PAHZSY3XX6PX5ANCNFSM6AAAAAAWQQP7UU>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
201a283
to
17f6de1
Compare
Yes I'll do it. I maybe can add these as commit to this PR so all the arc stuff come in the same time. EDIT : @PaddleStroke should I allow you to push in my arc-distance branch so the required Contextual code will be merged together? |
Good idea.
That may make things a bit complex especially since there's already open PR touching Sketcher_Dimension (and one that changes the arc stuff in it). So just focus on adding the constraints and once that merge we'll add support for them in Dimension so that we don't have conflicts. |
Switch back to Draft until arc-line and arc-point commits are ready. |
8d27281
to
8b4831a
Compare
At it now. |
src/Mod/Sketcher/App/Sketch.cpp
Outdated
int Sketch::addDistanceConstraint(int geoId1, int geoId2, double* value, bool driving) | ||
{ | ||
geoId1 = checkGeoId(geoId1); | ||
geoId2 = checkGeoId(geoId2); | ||
|
||
if (Geoms[geoId1].type == Circle) { | ||
GCS::Circle *c1, *c2; |
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.
Generally, we declare variables inside the scope where they are necessary.
I do understand that you can make use of c1 in the two blocks (if and else). However, in practice it is not even the same "c1", but just a circle. In the case of c2, it is not even necessary in the first block.
} | ||
GCS::Line* l = &Lines[Geoms[geoId2].index]; | ||
int tag = ++ConstraintsCounter; | ||
GCSsys.addConstraintC2LDistance(*c1, *l, value, tag, driving); |
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.
And if c1 is not either a circle or an arc, then we pass an uninitialised c1 to addConstraintC2LDistance...
else if (Geoms[geoId2].type == Arc) { | ||
c2 = &Arcs[Geoms[geoId2].index]; | ||
} | ||
if (c1 == nullptr || c2 == nullptr) { |
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.
Here we are relying on c1 being nullptr if it was not assigned... however, it is not for granted that a pointer is initialised with nullptr.
radius2 = circleSeg2->getRadius(); | ||
center2 = circleSeg2->getCenter(); | ||
} | ||
if (radius1 == 0.0 || radius2 == 0.0) { |
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.
This code does not show intent clearly. It relies on what is supported now for edges and the fact that they may have radii.
The whole block is heavy to read because what is written is implied rather than explicit. The branching is not very well structured either... we should look into recoding this.
@@ -4274,6 +4253,45 @@ void CmdSketcherConstrainDistance::activated(int iMsg) | |||
|
|||
return; | |||
} | |||
double ActDist = 0.0; |
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.
Splitting the block of circle-circle with the circle-line is a little bit awkward.
@@ -815,61 +814,75 @@ void EditModeConstraintCoinManager::processConstraints(const GeoListFacade& geol | |||
case DistanceY: { | |||
assert(Constr->First >= -extGeoCount && Constr->First < intGeoCount); | |||
Base::Vector3d pnt1(0., 0., 0.), pnt2(0., 0., 0.); | |||
pnt1 = geolistfacade.getPoint(Constr->First, Constr->FirstPos); |
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.
Then pnt1 can also be directly initialised to this.
pnt1.ProjectToLine( | ||
ct - l2p1, | ||
l2p2 - l2p1); // project on the line translated to origin | ||
if (isCircle(*geo1) || isArcOfCircle(*geo1)) { |
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.
This code keeps being repeated and could be refactored.
src/Mod/Sketcher/Gui/Utils.cpp
Outdated
|
||
point1 = circle1->getCenter(); | ||
point2 = circle2->getCenter(); | ||
if (geom1->is<Part::GeomCircle>()) { |
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.
This is again the repeated code of above.
if (Constr->FirstPos != Sketcher::PointPos::none){ // circular to point distance | ||
Base::Vector3d ct; | ||
double rad = 0.0; | ||
if (isCircle(*geo2)){ |
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.
Idem.
For fixing the issues above, I provide some commits: However, this branch heavily conflicts with master because of some changes brought to how to represent angles. I would propose:
Does it sound ok? |
720f263
to
5cbb381
Compare
…factor duplicated code
5cbb381
to
e4a03c4
Compare
@abdullahtahiriyo done |
Thanks for the correction in the refactored function with the wrong type cast. I will merge this. We should monitor the change to make distances negative possible. I have done some testing, but the tests are not exhaustive. I think there will not be unintended effects for existing sketches, but I definitely want to hear about it if anybody realises. With respect to sketching stability: I only want to note here that I am unsure about how stable sketches using this construct will be (also the same goes for circle), due to the flipping that may occur: But that, I think is a matter of learning from it. |
Thank you @abdullahtahiriyo. |
Great work guys ! I will implement in sketcher_dimension asap. |
Point to line distance is broken. I am not sure but this might be this PR that introduced this problem. |
@PaddleStroke thank you to show this. Fixed by #11784 |
Ah interesting. Great thanks for the quick fix ! |
@FlachyJoe could this PR introduce the issues in the current weekly build or maybe #11784 : |
Propagate circles distance constraint to arcs.