3D print Toolbox Intersections gives error #37583

Closed
opened 2013-11-22 17:35:21 +01:00 by Mikhail Rachinskiy · 38 comments

Blender Version
Broken: Blender 2.69 ac021a4 Build Bot Official

Short description of error
Intersections check breaks on Ngons

Also I found that Intersections falsely triggered on particular models (blend file attached)

Exact steps for others to reproduce the error
Enable the Mesh: 3D Print Toolbox addon.
Open attached blend file, and press intersections button (falsely triggered)
intersect.blend

Create a Cylinder primitive and press the Intersections button. (gives eror)

Traceback (most recent call last):
  File "C:\Users\Mikhail\Downloads\26\2.69\scripts\addons\object_print3d_utils\o
perators.py", line 163, in execute
    return execute_check(self, context)
  File "C:\Users\Mikhail\Downloads\26\2.69\scripts\addons\object_print3d_utils\o
perators.py", line 117, in execute_check
    self.main_check(obj, info)
  File "C:\Users\Mikhail\Downloads\26\2.69\scripts\addons\object_print3d_utils\o
perators.py", line 158, in main_check
    faces_intersect = mesh_helpers.bmesh_check_self_intersect_object(obj)
  File "C:\Users\Mikhail\Downloads\26\2.69\scripts\addons\object_print3d_utils\m
esh_helpers.py", line 124, in bmesh_check_self_intersect_object
    face_map_index = {i: face_map_index_org[face_map.get(f, f)] for i, f in enum
erate(bm.faces)}
  File "C:\Users\Mikhail\Downloads\26\2.69\scripts\addons\object_print3d_utils\m
esh_helpers.py", line 124, in <dictcomp>
    face_map_index = {i: face_map_index_org[face_map.get(f, f)] for i, f in enum
erate(bm.faces)}
KeyError: <BMFace(0x0000000009F2F4C8), index=20, totverts=3>

Updated steps for others to reproduce the error

import bpy, bmesh
bpy.ops.mesh.primitive_cylinder_add(vertices=5)
bm = bmesh.new()
bm.from_mesh(bpy.context.object.data)
face_map_index_org = {f: i for i, f in enumerate(bm.faces)}
ret = bmesh.ops.triangulate(bm, faces=bm.faces)
face_map = ret["face_map"]
face_map_index = {i: face_map_index_org[face_map.get(f, f)] for i, f in enumerate(bm.faces)}
**Blender Version** Broken: Blender 2.69 ac021a4 Build Bot Official **Short description of error** Intersections check breaks on Ngons Also I found that Intersections falsely triggered on particular models (blend file attached) **Exact steps for others to reproduce the error** Enable the *Mesh: 3D Print Toolbox* addon. Open attached blend file, and press intersections button (falsely triggered) [intersect.blend](https://archive.blender.org/developer/F29986/intersect.blend) Create a Cylinder primitive and press the Intersections button. (gives eror) ``` Traceback (most recent call last): File "C:\Users\Mikhail\Downloads\26\2.69\scripts\addons\object_print3d_utils\o perators.py", line 163, in execute return execute_check(self, context) File "C:\Users\Mikhail\Downloads\26\2.69\scripts\addons\object_print3d_utils\o perators.py", line 117, in execute_check self.main_check(obj, info) File "C:\Users\Mikhail\Downloads\26\2.69\scripts\addons\object_print3d_utils\o perators.py", line 158, in main_check faces_intersect = mesh_helpers.bmesh_check_self_intersect_object(obj) File "C:\Users\Mikhail\Downloads\26\2.69\scripts\addons\object_print3d_utils\m esh_helpers.py", line 124, in bmesh_check_self_intersect_object face_map_index = {i: face_map_index_org[face_map.get(f, f)] for i, f in enum erate(bm.faces)} File "C:\Users\Mikhail\Downloads\26\2.69\scripts\addons\object_print3d_utils\m esh_helpers.py", line 124, in <dictcomp> face_map_index = {i: face_map_index_org[face_map.get(f, f)] for i, f in enum erate(bm.faces)} KeyError: <BMFace(0x0000000009F2F4C8), index=20, totverts=3> ``` **Updated steps for others to reproduce the error** ``` import bpy, bmesh bpy.ops.mesh.primitive_cylinder_add(vertices=5) bm = bmesh.new() bm.from_mesh(bpy.context.object.data) face_map_index_org = {f: i for i, f in enumerate(bm.faces)} ret = bmesh.ops.triangulate(bm, faces=bm.faces) face_map = ret["face_map"] face_map_index = {i: face_map_index_org[face_map.get(f, f)] for i, f in enumerate(bm.faces)}
Author
Member

Changed status to: 'Open'

Changed status to: 'Open'
Campbell Barton was assigned by Mikhail Rachinskiy 2013-11-22 17:35:21 +01:00
Author
Member

Added subscriber: @MikhailRachinskiy

Added subscriber: @MikhailRachinskiy

#38241 was marked as duplicate of this issue

#38241 was marked as duplicate of this issue

#39037 was marked as duplicate of this issue

#39037 was marked as duplicate of this issue
Campbell Barton removed their assignment 2013-11-25 07:23:01 +01:00

Added subscribers: @(Deleted), @ideasman42

Added subscribers: @(Deleted), @ideasman42

@dalai_testing, The Python exception looks like its caused by recent changes to triangulate (since 2.69 release), looks like mapping isn't stored correctly anymore.

I'll check on the incorrect intersections in intersect.blend

@dalai_testing, The Python exception looks like its caused by recent changes to triangulate (since 2.69 release), looks like mapping isn't stored correctly anymore. I'll check on the incorrect intersections in `intersect.blend`
Dalai Felinto self-assigned this 2013-11-25 17:25:41 +01:00

Removed subscriber: @(Deleted)

Removed subscriber: @(Deleted)

Simpler way to reproduce the problem:

import bpy, bmesh
bpy.ops.mesh.primitive_cylinder_add()
bm = bmesh_new()
bm.from_mesh(bpy.context.object.data)
face_map_index_org = {f: i for i, f in enumerate(bm.faces)}
ret = bmesh.ops.triangulate(bm, faces=bm.faces)
face_map = ret["face_map"]
face_map_index = {i: face_map_index_org[face_map.get(f, f)] for i, f in enumerate(bm.faces)}
Simpler way to reproduce the problem: ``` import bpy, bmesh bpy.ops.mesh.primitive_cylinder_add() bm = bmesh_new() bm.from_mesh(bpy.context.object.data) face_map_index_org = {f: i for i, f in enumerate(bm.faces)} ret = bmesh.ops.triangulate(bm, faces=bm.faces) face_map = ret["face_map"] face_map_index = {i: face_map_index_org[face_map.get(f, f)] for i, f in enumerate(bm.faces)} ```

@ideasman42 can you land me a hand here?

Check the file: tri-print.blend (open it, run the script in the Text Editor and check the console).

The code basically returns:

original faces:

0 <BMFace(0x10716b218), index=0, totverts=5>


new faces:

0 <BMFace(0x10716b218), index=0, totverts=3>
1 <BMFace(0x10716b250), index=1, totverts=3>
2 <BMFace(0x10716b288), index=2, totverts=3>


dead faces:

{<BMFace dead at 0x10fa138a0>: 0}

Which means that the original stored face pointer is still valid, but the value stored in face_map_index_org changes somehow. That's what is producing the crash. But I'm a bit clueless on what can be causing that.

@ideasman42 can you land me a hand here? Check the file: [tri-print.blend](https://archive.blender.org/developer/F32966/tri-print.blend) (open it, run the script in the Text Editor and check the console). The code basically returns: ``` original faces: ``` -------------- 0 <BMFace(0x10716b218), index=0, totverts=5> ``` new faces: ``` --------- 0 <BMFace(0x10716b218), index=0, totverts=3> 1 <BMFace(0x10716b250), index=1, totverts=3> 2 <BMFace(0x10716b288), index=2, totverts=3> ``` dead faces: ``` ---------- ``` {<BMFace dead at 0x10fa138a0>: 0} ``` Which means that the original stored face pointer is still valid, but the value stored in **face_map_index_org** changes somehow. That's what is producing the crash. But I'm a bit clueless on what can be causing that.

@ideasman42 I added a workaround here: http://developer.blender.org/D47

@ideasman42 I added a workaround here: http://developer.blender.org/D47

I mean, D47 is a workaround (I shouldn't have pasted the entire link, only the number is fine)

I mean, [D47](https://archive.blender.org/developer/D47) is a workaround (I shouldn't have pasted the entire link, only the number is fine)

Apparently the problem is that bmesh_face_swap_data and BM_face_kill are mangling the variables of f and f_new in bmesh_polygon.c.

Basically bpy_bm_generic_invalidate is being called for f_new, but &BPy_BMGeneric is the same for both f and f_new, so f ends up with an invalid BPy_BMGeneric->bm (even though BPy_BMGeneric->f is valid).

See the backtrace I get up to bpy_bm_generic_invalidate is called:
http://www.pasteall.org/47617

I tried a soft kill face solution - D50 just for testing, and although the original face no longer shows as 'dead', we still get a Key not found error. We could solve that in the addon if we stored str(f) instead of f as key, but if we do that we may as well do as in D47 and spare Blender core from being patched.

Apparently the problem is that **bmesh_face_swap_data** and **BM_face_kill** are mangling the variables of *f* and *f_new* in bmesh_polygon.c. Basically **bpy_bm_generic_invalidate** is being called for f_new, but &*BPy_BMGeneric* is the same for both *f* and *f_new*, so f ends up with an invalid BPy_BMGeneric->bm (even though BPy_BMGeneric->f is valid). See the backtrace I get up to **bpy_bm_generic_invalidate** is called: http://www.pasteall.org/47617 I tried a soft kill face solution - [D50](https://archive.blender.org/developer/D50) just for testing, and although the original face no longer shows as 'dead', we still get a Key not found error. We could solve that in the addon if we stored **str(f)** instead of **f** as key, but if we do that we may as well do as in [D47](https://archive.blender.org/developer/D47) and spare Blender core from being patched.

Added subscriber: @dfelinto

Added subscriber: @dfelinto

@dfelinto,
Simply not-swapping customdata seems to work.

adding this line at the end of bmesh_face_swap_data:
SWAP(void *, f_a->head.data, f_b->head.data);

@dfelinto, Simply not-swapping customdata seems to work. adding this line at the end of `bmesh_face_swap_data`: `SWAP(void *, f_a->head.data, f_b->head.data);`

This issue was referenced by blender/blender-addons-contrib@3b24eaad9a

This issue was referenced by blender/blender-addons-contrib@3b24eaad9af8025cb38879cbc345f7debceba5a9

This issue was referenced by blender/blender@3b24eaad9a

This issue was referenced by blender/blender@3b24eaad9af8025cb38879cbc345f7debceba5a9

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'

Closed by commit blender/blender@3b24eaad9a.

Closed by commit blender/blender@3b24eaad9a.
Author
Member

Hey Campbell,

intersections are good with Ngons now, but they are still falsely triggered with attached model.
Could you please look in to it?

Hey Campbell, intersections are good with Ngons now, but they are still falsely triggered with attached model. Could you please look in to it?

@MikhailRachinskiy, sure but in future prefer to open a new report (since this is a different issue).

@MikhailRachinskiy, sure but in future prefer to open a new report (since this is a different issue).

Changed status from 'Resolved' to: 'Open'

Changed status from 'Resolved' to: 'Open'
Dalai Felinto removed their assignment 2013-12-03 05:05:32 +01:00
Campbell Barton was assigned by Sergey Sharybin 2013-12-04 15:49:50 +01:00

Added subscriber: @Sergey

Added subscriber: @Sergey

@ideasman42, will you look into this?

@ideasman42, will you look into this?
Author
Member

Hey guys!

In the meantime I have found what triggers false intersections, it's geometry distance from the origin, yep.
As soon as you move geometry closer to the origin, intersections wont be triggered anymore.

To reproduce it, you need to:

  1. create a sphere
  2. enter edit mode
  3. move sphere geometry 20 units away
  4. make intersections check (resulting in 94 intersections)
Hey guys! In the meantime I have found what triggers false intersections, it's geometry distance from the origin, yep. As soon as you move geometry closer to the origin, intersections wont be triggered anymore. To reproduce it, you need to: 1. create a sphere 2. enter edit mode 3. move sphere geometry 20 units away 4. make intersections check (resulting in 94 intersections)
Author
Member

Guys?

Guys?

◀ Merged tasks: #38241.

◀ Merged tasks: #38241.

Added subscriber: @mont29

Added subscriber: @mont29

◀ Merged tasks: #39037.

◀ Merged tasks: #39037.

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Closed by commit blender/blender-addons-contrib@3b24eaad9a.
Author
Member

Why this task marked as resolved while issue is still appears?

Why this task marked as resolved while issue is still appears?

Changed status from 'Resolved' to: 'Open'

Changed status from 'Resolved' to: 'Open'

We had a bit of an accident mentioned there: http://lists.blender.org/pipermail/bf-committers/2014-May/043538.html Some of the re-opened tasks might be closed now unfortunately.

Re-opening it again. Sorry for the confusion.

We had a bit of an accident mentioned there: http://lists.blender.org/pipermail/bf-committers/2014-May/043538.html Some of the re-opened tasks might be closed now unfortunately. Re-opening it again. Sorry for the confusion.
Author
Member

Please fix this bug before 2.71 release, it's crucial for 3D printing.

Please fix this bug before 2.71 release, it's crucial for 3D printing.

This seems to be fixed here. Which version did you use to check it? Get a fresh copy of Blender from builder.blender.org

This seems to be fixed here. Which version did you use to check it? Get a fresh copy of Blender from builder.blender.org
Author
Member

Buildbot win64 90db85a, May 22 2014 - bug is still appears.

#38241 gives a prettty good description and blend file to test this out, but it has been marked as a duplicate to this task.

Buildbot win64 90db85a, May 22 2014 - bug is still appears. #38241 gives a prettty good description and blend file to test this out, but it has been marked as a duplicate to this task.

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'

Closing this task then, leave #38241.

Closing this task then, leave #38241.
Sign in to join this conversation.
No Milestone
No project
No Assignees
6 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender-addons#37583
No description provided.