Draft Ticket 2496: DraftGeomUtils.FindWires doesn't find all

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!
User avatar
Kunda1
Posts: 6223
Joined: Thu Jan 05, 2017 9:03 pm

Draft Ticket 2496: DraftGeomUtils.FindWires doesn't find all

Postby Kunda1 » Mon Aug 28, 2017 4:24 pm

issue #2496: DraftGeomUtils.FindWires doesn't find all
Description
Passing in a set of edges to DraftGeomUtils.findWires(), I would expect to get back a list of all wires in the set. However, an incomplete set is returned under some conditions.
Steps To Reproduce
Run this macro:

Code: Select all

import DraftGeomUtils

App.ActiveDocument.addObject("Part::Box","Box")
App.ActiveDocument.ActiveObject.Label = "Cube"
App.ActiveDocument.recompute()

obj = App.ActiveDocument.ActiveObject
print "The box object has " + str(len(obj.Shape.Edges)) + " edges"
print "length of obj.Shape.Wires: " + str(len(obj.Shape.Wires))


x =0
for f in obj.Shape.Faces:
    x += len(f.Wires)
print "Total found by counting wires in object faces: " + str(x)

print "wires found by DraftGeomUtils.findWires(obj.Shape.Edges) : " + str(len(DraftGeomUtils.findWires(obj.Shape.Edges)))
Additional Information
output on my system:

The box object has 12 edges
length of obj.Shape.Wires: 6
Total found by counting wires in object faces: 6
wires found by DraftGeomUtils.findWires(obj.Shape.Edges) : 1
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
User avatar
amrit3701
Posts: 241
Joined: Mon Jun 13, 2016 5:37 pm

Re: Draft Ticket 2496: DraftGeomUtils.FindWires doesn't find all

Postby amrit3701 » Mon Aug 28, 2017 5:48 pm

Kunda1 wrote:
Mon Aug 28, 2017 4:24 pm
output on my system:

The box object has 12 edges
length of obj.Shape.Wires: 6
Total found by counting wires in object faces: 6
wires found by DraftGeomUtils.findWires(obj.Shape.Edges) : 1
I have just copy and paste the above code and got expected result.

Code: Select all

>>> import DraftGeomUtils
>>> 
>>> App.ActiveDocument.addObject("Part::Box","Box")
<Part::PartFeature>
>>> App.ActiveDocument.ActiveObject.Label = "Cube"
>>> App.ActiveDocument.recompute()
1
>>> 
>>> obj = App.ActiveDocument.ActiveObject
>>> print "The box object has " + str(len(obj.Shape.Edges)) + " edges"
The box object has 12 edges
>>> print "length of obj.Shape.Wires: " + str(len(obj.Shape.Wires))
length of obj.Shape.Wires: 6
>>> 
>>> 
>>> x =0
>>> for f in obj.Shape.Faces:
...     x += len(f.Wires)
... 
>>> 
>>> print "Total found by counting wires in object faces: " + str(x)
Total found by counting wires in object faces: 6
>>> 
>>> print "wires found by DraftGeomUtils.findWires(obj.Shape.Edges) : " + str(len(DraftGeomUtils.findWires(obj.Shape.Edges)))
wires found by DraftGeomUtils.findWires(obj.Shape.Edges) : 6
Regards,
User avatar
amrit3701
Posts: 241
Joined: Mon Jun 13, 2016 5:37 pm

Re: Draft Ticket 2496: DraftGeomUtils.FindWires doesn't find all

Postby amrit3701 » Mon Aug 28, 2017 6:11 pm

amrit3701 wrote:
Mon Aug 28, 2017 5:48 pm
I have just copy and paste the above code and got expected result.

Code: Select all

>>> import DraftGeomUtils
>>> 
>>> App.ActiveDocument.addObject("Part::Box","Box")
<Part::PartFeature>
>>> App.ActiveDocument.ActiveObject.Label = "Cube"
>>> App.ActiveDocument.recompute()
1
>>> 
>>> obj = App.ActiveDocument.ActiveObject
>>> print "The box object has " + str(len(obj.Shape.Edges)) + " edges"
The box object has 12 edges
>>> print "length of obj.Shape.Wires: " + str(len(obj.Shape.Wires))
length of obj.Shape.Wires: 6
>>> 
>>> 
>>> x =0
>>> for f in obj.Shape.Faces:
...     x += len(f.Wires)
... 
>>> 
>>> print "Total found by counting wires in object faces: " + str(x)
Total found by counting wires in object faces: 6
>>> 
>>> print "wires found by DraftGeomUtils.findWires(obj.Shape.Edges) : " + str(len(DraftGeomUtils.findWires(obj.Shape.Edges)))
wires found by DraftGeomUtils.findWires(obj.Shape.Edges) : 6
System Details:
OS: Ubuntu 16.04.2 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.11921 (Git)
Build type: Unknown
Branch: (HEAD detached from 8ea482a)
Hash: 7c6e7025302f270e2a16034338effdc3e1a96778
Python version: 2.7.12
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 6.8.0.oce-0.17
Locale: English/India (en_IN)
User avatar
Kunda1
Posts: 6223
Joined: Thu Jan 05, 2017 9:03 pm

Re: Draft Ticket 2496: DraftGeomUtils.FindWires doesn't find all

Postby Kunda1 » Mon Aug 28, 2017 6:36 pm

Thanks Amit! Issue closed.
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
User avatar
amrit3701
Posts: 241
Joined: Mon Jun 13, 2016 5:37 pm

Re: Draft Ticket 2496: DraftGeomUtils.FindWires doesn't find all

Postby amrit3701 » Tue Aug 29, 2017 8:23 am

Kunda1 wrote:
Mon Aug 28, 2017 6:36 pm
Thanks Amit! Issue closed.
It's Amritpal not Amit. 8-)

Regards,
User avatar
Kunda1
Posts: 6223
Joined: Thu Jan 05, 2017 9:03 pm

Re: Draft Ticket 2496: DraftGeomUtils.FindWires doesn't find all

Postby Kunda1 » Tue Aug 29, 2017 9:31 am

Apologies amritpal, I was responding from my phone.
Cheers!
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features