Closed polyline does not create face

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
wearyhacker
Posts: 41
Joined: Fri May 18, 2018 9:07 pm

Closed polyline does not create face

Postby wearyhacker » Tue Nov 19, 2019 9:21 pm

OS: Ubuntu 19.10 (ubuntu:GNOME/ubuntu)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.
Build type: Release
Python version: 3.7.5rc1
Qt version: 5.12.4
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/United Kingdom (en_GB)
Build date 2019/11/19 12:02:48

Making a simple closed polyline (triangle/square) does not create a face even though the face property in the object is set to true. The only way to get the face to render is to downgrade the polyline. Strangely this produces a face object that renders. Then upgrade the object. This gives you back the original wire/polyline and the face now renders. What am I missing here? Is this intended behaviour?

Roger
chrisb
Posts: 24414
Joined: Tue Mar 17, 2015 9:14 am

Re: Closed polyline does not create face

Postby chrisb » Tue Nov 19, 2019 9:30 pm

It's perhaps related: ShapeStrings are no longer filled with faces, although it is set in preferences, see https://forum.freecadweb.org/viewtopic. ... 30#p348584.
User avatar
sgrogan
Posts: 5813
Joined: Wed Oct 22, 2014 5:02 pm

Re: Closed polyline does not create face

Postby sgrogan » Tue Nov 19, 2019 10:17 pm

wearyhacker wrote:
Tue Nov 19, 2019 9:21 pm
Is this intended behaviour?
I hope not ;)
I can confirm the problem with
OS: Windows 7 SP 1 (6.1)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.18760 (Git)
Build type: Release
Branch: master
Hash: ef73ab5f3a330d3c44138f23290f8c9f7a334caf
Python version: 3.6.7
Qt version: 5.12.1
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/United States (en_US)
vocx
Posts: 4081
Joined: Thu Oct 18, 2018 9:18 pm

Re: Closed polyline does not create face

Postby vocx » Tue Nov 19, 2019 11:06 pm

wearyhacker wrote:
Tue Nov 19, 2019 9:21 pm
Making a simple closed polyline (triangle/square) does not create a face even though the face property in the object is set to true. ...
You need to set the view property "DisplayMode" to "FlatLines". See Property editor.
vocx wrote:
Tue Nov 19, 2019 6:07 pm
[ Bug ] Initial Display Mode for Draft wires is Wireframe

In Draft, we did notice that the default "DisplayMode" of Draft objects changed from "FlatLines" to "Wireframe".

Up to this point it didn't seem to cause a problem, so we didn't investigate further. It is just a bit annoying. In Draft, certainly "FlatLines" is preferred as default.

It seems that the internal C++ code sets up "Wireframe" by default because that is preferred for Sketches (both Sketches and Draft objects are based on Part_Part2DObject). Presumably in Draft some code set the DisplayMode to "FlatLines", but now it seems it inherits the original "Wireframe" mode, and we aren't sure why.
Always add the important information to your posts if you need help.
To support the documentation effort, and code development, your donation is appreciated: paypal.
wearyhacker
Posts: 41
Joined: Fri May 18, 2018 9:07 pm

Re: Closed polyline does not create face

Postby wearyhacker » Wed Nov 20, 2019 6:43 pm

Changing the display mode works fine. It is just somewhat unexpected!

One thing I am still curious about is why downgrading a dwire/polyline produces a face. If anyone can explain that to me I would like to hear it :D .
vocx
Posts: 4081
Joined: Thu Oct 18, 2018 9:18 pm

Re: Closed polyline does not create face

Postby vocx » Wed Nov 20, 2019 8:06 pm

wearyhacker wrote:
Wed Nov 20, 2019 6:43 pm
...
One thing I am still curious about is why downgrading a dwire/polyline produces a face. If anyone can explain that to me I would like to hear it :D .
It's not so easy to explain. The shapes of FreeCAD are produced by the OCCT geometric kernel. This kernel defines various things, like edges, wires, faces, solids, etc. These are called "topological shapes" (TopoShape).

The Draft Workbench, just like other workbenches made in Python, creates what is called a "scripted object". This object defines various properties, and then assigns a TopoShape to the object. When you use Draft Downgrade, the code does a bunch of checks, looking at the properties of the object, looking at the shape, whether it is closed or not, and returns an object that is "dumber". The returned object doesn't have many properties, and cannot be edited like the original Draft Wire, but it has a face.

So, the Draft Wire is a higher level, more complex object. It does have a face, as you can clearly see, it just needs the proper option to show it. The created Face is a dumber object, but it has the proper option set by default, so it shows the face as well.
Always add the important information to your posts if you need help.
To support the documentation effort, and code development, your donation is appreciated: paypal.
wearyhacker
Posts: 41
Joined: Fri May 18, 2018 9:07 pm

Re: Closed polyline does not create face

Postby wearyhacker » Wed Nov 20, 2019 9:35 pm

Thanks for that. My background is more opengl and scenegraphs. I think I am getting the picture now. Though a bit of info about an objects imemediate upgrade and downgrade neighbours would be useful in the documentation. Though it might be already there and I mised it ;)
vocx
Posts: 4081
Joined: Thu Oct 18, 2018 9:18 pm

Re: Closed polyline does not create face

Postby vocx » Thu Nov 21, 2019 3:37 am

wearyhacker wrote:
Wed Nov 20, 2019 9:35 pm
Thanks for that. My background is more opengl and scenegraphs. I think I am getting the picture now. Though a bit of info about an objects imemediate upgrade and downgrade neighbours would be useful in the documentation. Though it might be already there and I mised it ;)
It may not be that useful, because in most cases the Draft Upgrade and Draft Downgrade tools aren't used a lot. They exist for niche cases. For this thread, you don't even need it, as the problem was elsewhere.
Always add the important information to your posts if you need help.
To support the documentation effort, and code development, your donation is appreciated: paypal.