View: Shaded with Hard Edges

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!
grd
Posts: 328
Joined: Wed Apr 13, 2022 5:13 am
Location: Eindhoven, The Netherlands

Re: View: Shaded with Hard Edges

Post by grd »

adrianinsaval wrote: Sun May 14, 2023 10:57 pm
grd wrote: Sun May 14, 2023 12:53 pm No. I mean in (good old) Pro/Engineer there have always been 4 display modes: wireframe, hidden edges, and 2 shaded views: One with edges and one without, and this all works. Performance is never an issue. The only issue is maybe Coin3D. I am not OP but I would make a PR.
I thought this would be obvious but proprietary CADs don't use occt or coin, there's several things where occt and/or coin are just not as performant as most proprietary products so performance is something we do have to take into account. Of course, nobody's stopping anyone from making a PR, if you know how to make this work go ahead and propose it...
OP wants to have it and with that I think that he / she agrees with the penalties, but I don't think that there are any penalties, especially not with one model, or a small assy. So OP, make the request.
About Nim. Latest Release 2.0.2. Here is Nim in 100 seconds and a Nim package. There are Qt and OCCT packages.
User avatar
Chris_G
Veteran
Posts: 2580
Joined: Tue Dec 31, 2013 4:10 pm
Location: France
Contact:

Re: View: Shaded with Hard Edges

Post by Chris_G »

I suppose Techdraw uses the OCCT Hidden_Line_Removal, like Part's TopoShape ReflectLines :
https://github.com/FreeCAD/FreeCAD/blob ... .cpp#L2088
For me, the workaround posted here that uses Part's function above is pretty fluid for simple models. (example file below. Needs CurvesWB installed)
So I suppose creating a new viewmode in FC source taking the edges from Hidden_Line_Removal algo is possible.
I think the main problem is OP want to use this viewmode to select edges for further operation, but it may be very hard to link HLR edges numbering back to "real" shape edges numbers. (A new kind of TopoNaming problem).
Attachments
test_ReflectLines.FCStd
(12.6 KiB) Downloaded 20 times
maxwxyz
Posts: 160
Joined: Sat Dec 31, 2022 2:42 pm
Location: Munich, Germany
Contact:

Re: View: Shaded with Hard Edges

Post by maxwxyz »

I am OP but not able to create a PR as I cannot code. Is there anyone willing to implement this feature?
chrisb
Veteran
Posts: 53945
Joined: Tue Mar 17, 2015 9:14 am

Re: View: Shaded with Hard Edges

Post by chrisb »

maxwxyz wrote: Wed May 17, 2023 5:18 pm I am OP but not able to create a PR as I cannot code.
grd wrote: Sun May 14, 2023 12:53 pm I am not OP but I would make a PR.
So now it’s your turn.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
grd
Posts: 328
Joined: Wed Apr 13, 2022 5:13 am
Location: Eindhoven, The Netherlands

Re: View: Shaded with Hard Edges

Post by grd »

chrisb wrote: Wed May 17, 2023 8:33 pm So now it’s your turn.
This is funny. Yes, I did have a big mouth. But I am gonna call this one.

What needs to be done are three things:

1. There needs to be two buttons: One with "shaded" and one with "shaded with edges". And of course also code to deal with the buttons being pushed. When one button is pushed the other should be "un" pushed automatically. I don't know in which menu the two buttons need to be placed.

2. There needs to be code to implement the feature.

3. Maybe there needs to be code to save the current configuration but I don't think that it is necessary ATM.

And that is it IMO. Anyone has some other ideas?

I have two questions / remarks:

1. In which version of FreeCAD does this needs to be placed? 0.22?

2. I don't know how hard it is to implement the four buttons that are in Pro/Engineer: Wireframe, hidden edges, shaded and shaded with edges, but I think that is probably gonna be a lot harder to implement than the two buttons.
About Nim. Latest Release 2.0.2. Here is Nim in 100 seconds and a Nim package. There are Qt and OCCT packages.
User avatar
Chris_G
Veteran
Posts: 2580
Joined: Tue Dec 31, 2013 4:10 pm
Location: France
Contact:

Re: View: Shaded with Hard Edges

Post by Chris_G »

If OCCT Hidden_Line_Removal is used to find the relevant edges, then it is dependent to the camera view, so the shape must be recomputed on every camera move.
And, again, it won't offer a coherent edge selection mechanism.
Maybe there are other alternatives, like shaders ?
But, in my humble opinion (I am not a skilled FC developer), this is probably not a trivial task.
User avatar
adrianinsaval
Veteran
Posts: 5541
Joined: Thu Apr 05, 2018 5:15 pm

Re: View: Shaded with Hard Edges

Post by adrianinsaval »

grd wrote: Wed May 17, 2023 8:45 pm
maybe I'm just confused but I'm not sure if PR means what you think it means, PR means Pull Request which means you have coded something and submitted it to be considered for merge. You might be getting confused with FR: Feature Request, which is a concept we're not really using anymore in our tracker, if you want a new feature instead you need to think about what problem it would solve and create an issue on github describing that problem, you may then suggest said feature as a possible solution to this problem.
2. There needs to be code to implement the feature.
this is the crux of the matter and where you must focus if you want this implemented, we already have working UI to switch between different display styles, we don't need to change that, what is needed is to add a new display style.
1. In which version of FreeCAD does this needs to be placed? 0.22?
yes, we are not accepting new features for 0.21 at this stage but this isn't really important, when you develop a feature you develop on top of master, it does not matter what version number master is currently.
2. I don't know how hard it is to implement the four buttons that are in Pro/Engineer: Wireframe, hidden edges, shaded and shaded with edges, but I think that is probably gonna be a lot harder to implement than the two buttons.
IIRC only hidden edges is missing from these... There is one called hidden edges in the list but it's not what you would traditionally expect in CAD software, instead it shows the edges from the meshes used to display the shapes.
Chris_G wrote: Wed May 17, 2023 9:04 pm If OCCT Hidden_Line_Removal is used to find the relevant edges, then it is dependent to the camera view, so the shape must be recomputed on every camera move.
I highly doubt running HLR all the time like this could ever provide an acceptable level of performance. Perhaps for generating a screenshot but not for live display, instead one could look at what HLR is doing behind the scenes to detect smooth edges and try to do that directly on the 3D shape only once. But I've never taken a close look at how HLR works, perhaps @wandererfan can give some more insight on this subject.
User avatar
wandererfan
Veteran
Posts: 6270
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: View: Shaded with Hard Edges

Post by wandererfan »

adrianinsaval wrote: Wed May 17, 2023 9:58 pm But I've never taken a close look at how HLR works, perhaps @wandererfan can give some more insight on this subject.
I don't think HLR is going to (easily) give you what you need. What comes out of HLR has no tidy link back to what went in.

As @Chris_G said, hidden lines can only be determined in terms of a given view direction, so a panning movement would have to find the hidden lines on each increment of the move. Nobody wants to run HLR that often.

For hard/smooth/seam lines, you'd have to do a comparison of the edges you got back from HLR in each category to all the original edges. Since the projection and hiding process can change the length and geometry of the original edges, it isn't an easy comparison.

I believe there are methods in OCC to determine if something is a hard/seam/smooth edge by looking at how many faces an edge belongs to and the continuity of the adjacent faces (BRep_Tool maybe), but that's based on quick google search.
User avatar
saso
Veteran
Posts: 1920
Joined: Fri May 16, 2014 1:14 pm
Contact:

Re: View: Shaded with Hard Edges

Post by saso »

As said and shown before, @realthunder did a lot of work around this things, for example he already has the option to show/hide seam edge, I see no sense to go on with some strange workarounds to implement this... It might however be possible to go a bit deeper in to the HLR code and see how it is detecting the smooth edges and seams* and maybe get some ideas and help from that code.

* If we look closer, there seems to be already some difference on how HLR detects seams compared to RT implementation for his hidden line draw style option
Last edited by saso on Thu May 18, 2023 10:18 am, edited 2 times in total.
grd
Posts: 328
Joined: Wed Apr 13, 2022 5:13 am
Location: Eindhoven, The Netherlands

Re: View: Shaded with Hard Edges

Post by grd »

@saso I can be wrong but you are sure that it isn't a Coin3D issue? How is it possible that cqparts (that also rely on occt) has it working?
About Nim. Latest Release 2.0.2. Here is Nim in 100 seconds and a Nim package. There are Qt and OCCT packages.
Post Reply