Open Vertices

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
openBrain
Veteran
Posts: 9034
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: Open Vertices

Post by openBrain »

mopy wrote: Fri Oct 15, 2021 12:48 pm Well, the least thing to do - as always. Document the behavior.
Well, admittedly the document is sparse and somewhat wrong. But remember it has been done by a volunteer on its spare time.
Saying so is just lack of respect for contributors. If you can do better, take an account to the wiki and roll up your sleeves. ;)
You could do something like this to find transitive relations:
A bit hazardous as it tends to prove that you have a limited understanding of how sketcher internally works.
Anyway, let's not talk about implementation. Let's talk functional.
How we want this to evolve ? "Find missing coincidences" already highlights the missing coincidences -- it has bug also, will discuss this later --.
The question is : on which criteria should "Highlight open vertexes" sort which point to highlight or not ?
openBrain
Veteran
Posts: 9034
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: Open Vertices

Post by openBrain »

chrisb wrote: Fri Oct 15, 2021 1:10 pm You probably looked into the implementation? Then it is a precision issue, where equality isn't necessarily transitive.
Yes I do. But I miss to understand your 2nd sentence. :oops:
chrisb
Veteran
Posts: 53922
Joined: Tue Mar 17, 2015 9:14 am

Re: Open Vertices

Post by chrisb »

As shown in my first example: In the corner, where three lines meet, the points are coincident and thus should all three have the same coordinates. Yet they are marked as open.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
openBrain
Veteran
Posts: 9034
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: Open Vertices

Post by openBrain »

chrisb wrote: Fri Oct 15, 2021 7:39 am I found a related issue: Finding missing coincidences shows in the attached sketch 1 open, where 0 would be correct, and 2 would be consistent.Bildschirmfoto 2021-10-15 um 09.39.14.png
chrisb wrote: Fri Oct 15, 2021 1:08 pm Here is a slightly modified sketch. It correctly pads perfectly, yet Validate Sketch shows a missing coincidence. It can of course be ignored here, and I prefer to have false positives instead of missed hits, but if there are a lot more of really missing coincidences they can only be fixed automatically when this one is (mal-)fixed too - which then needs editing in sketcher again.

Surprisingly by making the diagonal construction geometry the false Open vertex vanishes.

I think it would at least be worth a feature request, if not a minor bug report.
chrisb, could you split your 2 quoted posts as well as this answer into a separate topic ?
Actually these are really 2 separate issues.
On "Find missing coincidences", the actual problem is that transitivity of coincidence between points isn't managed (at all).
So depending on which order you set your constraints, you can be lucky or not. :)
I didn't find a reliable way ATM to create a faulty example from scratch using the GUI, but you have to believe me because I debugged the code based on your 1st example. :)
If needed, I could pretty easily generate a faulty sketch using Python API.
It could look simple to enhance, but can be a bit of code so I guess it's worth a ticket. ;)
If needed, I can give some more details about what happens internally with your file once topic is splitted. ;)
wmayer
Founder
Posts: 20243
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Open Vertices

Post by wmayer »

openBrain wrote: Fri Oct 15, 2021 1:07 pm Actually coincident constraints doesn't come into play here. Specifically, the "Highlight open vertexes" function totally ignores the constraints.
It applies a simple rule that is "Highlight points where not exactly 2 vertices strictly are", which also means :
* It doesn't highlight point pairs having strictly equal coordinates, even if no coincidence is set between both
* It totally ignore the Tolerance value set above (which from UI point of view is a bit weird)
The function to detect open vertices actually should be moved to another place in the dialog because it has absolutely nothing to do with the function that searches for coincident points.

The latter searches for points in the sketch that can be considered equal but no coincident constraint is set. This way one can find tiny gaps in the sketch. The former function doesn't work on the sketch at all but the (OCCT) shape that has been created out of the sketch.
openBrain
Veteran
Posts: 9034
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: Open Vertices

Post by openBrain »

wmayer wrote: Fri Oct 15, 2021 1:48 pm The function to detect open vertices actually should be moved to another place in the dialog because it has absolutely nothing to do with the function that searches for coincident points.
Fine for me, but I like to hear from the community because it's generally a good occasion to also improve a bit the tools so they better match user expectation. ;) Anyway that is a totally satisfying fix.
The latter searches for points in the sketch that can be considered equal but no coincident constraint is set. This way one can find tiny gaps in the sketch. The former function doesn't work on the sketch at all but the (OCCT) shape that has been created out of the sketch.
For me it was totally clear (particularly after looking at the code). ;) My intention wasn't to go in deep details (as OCCT and this), but just that everybody reading this thread got the information that "Highlight open vertexes" totally ignores sketch constraints so it's clear for the rest of the discussion. ;)
wmayer
Founder
Posts: 20243
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Open Vertices

Post by wmayer »

On "Find missing coincidences", the actual problem is that transitivity of coincidence between points isn't managed (at all).
So depending on which order you set your constraints, you can be lucky or not. :)
I didn't find a reliable way ATM to create a faulty example from scratch using the GUI, but you have to believe me because I debugged the code based on your 1st example.
This can be easily confirmed. Draw three lines. Select one end point of the first and third line and make them coincident. Now select a point of the second line and the point you made coincident. So you should end up with two constraints that reference point A+C and either B+A or B+C (because you cannot easily see if you select the point of the first or third line).

Now the algorithm to search missing coincident constraints works this way:
  1. it makes an array of end points of the geometries
  2. it sorts the points by their x,y,z coordinates
  3. it goes through the sorted list and checks if two adjacent elements are coincident points
  4. if yes it creates a coincident constraint with the given point ids and adds it to a list
  5. now it takes the defined coincident constraints of the sketch and removes the matches it finds from the list above
  6. if this list is not empty it claims there are missing coincident constraints
The problem is that in the list the constraints for points A+B and B+C will be added so that at least one of them will remain in the list (because for A+C no matching element was found).

Idea of improvement:
Get the point ids of equal points. Go through the list of coincident constraints that reference two points of this list and increment a counter for the point ids. At the end the counter for each point id must be at least 1.
openBrain
Veteran
Posts: 9034
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: Open Vertices

Post by openBrain »

wmayer wrote: Fri Oct 15, 2021 3:03 pm This can be easily confirmed. Draw three lines. Select one end point of the first and third line and make them coincident. Now select a point of the second line and the point you made coincident. So you should end up with two constraints that reference point A+C and either B+A or B+C (because you cannot easily see if you select the point of the first or third line).
Actually I tried that (and other combinations) but can't succeed to create a repeatable faulty case. IMO because there is some uncertainty in the point that is selected when 2 are already coincident, and eventually then in the sorting algorithm. Or I'm just a donkey when using my mouse. :) Anyway, I share your analysis, why I said it's easy to get a 100% faulty case with Python API. ;)

Please allow me to add some clarifications in your algorithm explanation :
Now the algorithm to search missing coincident constraints works this way:
  1. it makes an array of end points of the geometries
  2. it sorts the points by their x,y,z coordinates
  3. it goes through the sorted list and checks if two adjacent elements are located inside the tolerance set by user
  4. if yes it creates a virtual coincident constraint with the given point ids and adds it to a list
  5. now it takes the defined coincident constraints of the sketch and removes the matches it finds from the list above
  6. if this list is not empty it claims there are missing coincident coThe problem is that in the list the constraints for points A+B and B+C will be added so that at least one of them will remain in the list (because for A+C no matching element was found).
    nstraints
Idea of improvement:
Get the point ids of equal points. Go through the list of coincident constraints that reference two points of this list and increment a counter for the point ids. At the end the counter for each point id must be at least 1.
Sounds good.
mopy
Posts: 20
Joined: Fri Oct 08, 2021 4:58 am

Re: Open Vertices

Post by mopy »

Idea of improvement:
Get the point ids of equal points. Go through the list of coincident constraints that reference two points of this list and increment a counter for the point ids. At the end the counter for each point id must be at least 1.
I took a different approach for my little project:
It's based on the only on GeoIds:
- build sets of (transitive) connected (constrained) points.
- find points within tolerance by going through the geometry list
- check if they are contained in or connect to on of the above sets
+ create missing constraints

Ths algo works also for e.g. parallel and equal constraints (by using length or angle)
chrisb
Veteran
Posts: 53922
Joined: Tue Mar 17, 2015 9:14 am

Re: Open Vertices

Post by chrisb »

openBrain wrote: Fri Oct 15, 2021 1:15 pm
chrisb wrote: Fri Oct 15, 2021 1:10 pm You probably looked into the implementation? Then it is a precision issue, where equality isn't necessarily transitive.
Yes I do. But I miss to understand your 2nd sentence. :oops:
It's obsolete now. If you want I can explain it anyway for the sake of completeness.
openBrain wrote: Fri Oct 15, 2021 1:20 pm chrisb, could you split your 2 quoted posts as well as this answer into a separate topic ?
With all the follow-ups in the meantime I am now hesitant about splitting. Would it be suitable to create two new topics and link them here?
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Post Reply