View Issue Details

IDProjectCategoryView StatusLast Update
0004622FreeCADBugpublic2021-04-22 15:30
Reportergreyltc Assigned Tochennes  
PrioritynormalSeverityminorReproducibilityalways
Status feedbackResolutionopen 
PlatformLinuxOSArch LinuxOS Version5.11.11
Product Version0.19 
Summary0004622: OpenSCAD/OpenSCADTest/app/test_importCSG.py assertion failure
DescriptionI have an OpenSCAD test failing on recent builds from git

======================================================================
FAIL: test_import_resize (OpenSCADTest.app.test_importCSG.TestImportCSG)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "Mod/OpenSCAD/OpenSCADTest/app/test_importCSG.py", line 352, in test_import_resize
    self.assertAlmostEqual (object.Shape.BoundBox.XLength, 2*8.5, 1)
AssertionError: 25.499999999999996 != 17.0 within 1 places (8.499999999999996 difference)
Steps To Reproduce- have a recent stable release of occt installed (tested here with 7.5.0)
- build the latest commit from the master git branch ( a855033f215014d993fc067ea6d6ba89f0a369d5 as of this writing)
- run the built in tests with `FreeCADCmd --console --run-test 0`
TagsNo tags attached.
FreeCAD Informationwith commit a855033 from the master branch
==============
Summary report
==============

-- Build type: None
-- Compiler: /usr/lib/ccache/bin/c++ (10.2.0)
-- Flags: -Wall -Wextra -Wno-write-strings -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fPIC -w
-- Standard: Requires C++14
-- Python: 3.9.2 [/usr/bin/python] [.cpython-39-x86_64-linux-gnu]
-- PCL: not enabled
-- pybind11: not enabled
-- Boost: 1.75.0 (1.75.0)
-- XercesC: 3.2.3 [/usr/lib/libxerces-c.so] [/usr/include]
-- ZLIB: 1.2.11
-- PyCXX: 6.2.8 [/home/grey/git/freecad-git/src/FreeCAD/src]
-- OCC: 7.5.0 [TKFillet;TKMesh;TKernel;TKG2d;TKG3d;TKMath;TKIGES;TKSTL;TKShHealing;TKXSBase;TKBool;TKBO;TKBRep;TKTopAlgo;TKGeomAlgo;TKGeomBase;TKOffset;TKPrim;TKSTEPBase;TKSTEPAttr;TKSTEP209;TKSTEP;TKHLR;TKFeat] [/usr/lib] [/usr/include/opencascade]
-- SMESH: build internal
-- MEDFile: 4.1.0 [/usr/lib/libmedC.so;/usr/lib/libmed.so] [/usr/include]
-- HDF5: 1.12.0
-- VTK: 8.2.0
-- NETGEN: not enabled
-- SWIG: 4.0.2
-- Eigen3 3.3.9
-- Qt5Core: 5.15.2
-- Qt5Network: 5.15.2
-- Qt5Xml: 5.15.2
-- Qt5XmlPatterns: 5.15.2
-- Qt5Widgets: 5.15.2
-- Qt5PrintSupport: 5.15.2
-- Qt5OpenGL: 5.15.2
-- Qt5Svg: 5.15.2
-- Qt5UiTools: 5.15.2
-- Qt5Concurrent: 5.15.2
-- Qt5WebKitWidgets: 5.212.0
-- Shiboken2: 5.15.2 [/usr/lib64/cmake/Shiboken2-5.15.2] [/usr/include/shiboken2;/usr/include/python3.9]
-- PySide2: 5.15.2 [/usr/include/PySide2]
-- PySide2Tools: [/usr/bin/uic-qt5] [/usr/bin/rcc-qt5]
-- Freetype: 2.10.4
-- OpenGL: /usr/lib/libGL.so
-- OpenGLU: [/usr/lib/libGLU.so][/usr/include]
-- Coin3D: 4.0.1 [Coin] []
-- Pivy: 0.6.5
-- SPNAV: [/usr/lib/libspnav.so] [/usr/include]
-- Matplotlib: 3.4.1
-- Rift: not enabled (BUILD_VR)
-- Doxygen: 1.9.1
-- Language: English
-- Coin3D_DOC: not found

Activities

chennes

2021-04-12 18:19

developer   ~0015611

@greyltc I am having a hard time reproducing this -- when you have a minute, could you use the OpenSCAD workbench to insert the following object and then save and attach the resulting FCStd file?

resize(newsize = [0,0,10], auto = [0,0,0]) {
    sphere($fn = 96, $fa = 12, $fs = 2, r = 8.5);
}

floesche

2021-04-18 00:58

reporter   ~0015614

I see the same error, built from commit 33cca2e6c6a6ace4b1203a9ad0f9002a6c841e99.

Attached the requested FCStd file.
Issue-4622.FCStd (Attachment missing)

chennes

2021-04-18 22:10

developer   ~0015615

Thanks, @floesche -- the object in your FCStd file has the correct bounding box, so probably the test just needs a recompute() before the check. What kind of system are you on?

floesche

2021-04-18 22:20

reporter   ~0015616

Last edited: 2021-04-18 22:30

Very similar to @greyltc, just python is at 3.9.3 by now and the kernel at 5.11.15. Do you need any other information?


==============                                                                                                                                                                                               [33/583]
Summary report
==============

-- Build type:          None
-- Compiler:            /usr/bin/c++ (10.2.0)
-- Flags:               -Wall -Wextra -Wno-write-strings  -fPIC -w
-- Standard:            Requires C++14
-- Python:              3.9.3 [/usr/bin/python] [.cpython-39-x86_64-linux-gnu]
-- PCL:                 not enabled
-- pybind11:            not enabled
-- Boost:               1.75.0 (1.75.0)
-- XercesC:             3.2.3 [/usr/lib/libxerces-c.so] [/usr/include]
-- ZLIB:                1.2.11
-- PyCXX:               6.2.8 [./src]
-- OCC:                 7.5.0 [TKFillet;TKMesh;TKernel;TKG2d;TKG3d;TKMath;TKIGES;TKSTL;TKShHealing;TKXSBase;TKBool;TKBO;TKBRep;TKTopAlgo;TKGeomAlgo;TKGeomBase;TKOffset;TKPrim;TKSTEPBase;TKSTEPAttr;TKSTEP209;TKSTEP
;TKHLR;TKFeat] [/usr/lib] [/usr/include/opencascade]
-- SMESH:               build internal
--  MEDFile:            4.1.0 [/usr/lib/libmedC.so;/usr/lib/libmed.so] [/usr/include]
--  HDF5:               1.12.0
--  VTK:                8.2.0
-- NETGEN:              not enabled
-- SWIG:                4.0.2
-- Eigen3               3.3.9
-- Qt5Core:             5.15.2
-- Qt5Network:          5.15.2
-- Qt5Xml:              5.15.2
-- Qt5XmlPatterns:      5.15.2
-- Qt5Widgets:          5.15.2
-- Qt5PrintSupport:     5.15.2
-- Qt5OpenGL:           5.15.2
-- Qt5Svg:              5.15.2
-- Qt5UiTools:          5.15.2
-- Qt5Concurrent:       5.15.2
-- Qt5WebKitWidgets:    5.212.0
-- Shiboken2:           5.15.2 [/usr/lib64/cmake/Shiboken2-5.15.2] [/usr/include/shiboken2;/usr/include/python3.9]
-- PySide2:             5.15.2 [/usr/include/PySide2]
-- PySide2Tools:        [/usr/bin/uic-qt5] [/usr/bin/rcc-qt5]
-- Freetype:            2.10.4
-- OpenGL:              /usr/lib/libGL.so
-- OpenGLU:             [/usr/lib/libGLU.so][/usr/include]
-- Coin3D:              4.0.1 [Coin] []
-- Pivy:                0.6.5
-- SPNAV:               [/usr/lib/libspnav.so] [/usr/include]
-- Matplotlib:          3.4.1
-- Rift:                not enabled (BUILD_VR)
-- Doxygen:             1.9.1
--  Language:           English
--  Coin3D_DOC:         not found
=================================================

floesche

2021-04-19 14:50

reporter   ~0015617

Last edited: 2021-04-19 14:50

Not sure if this is helpful, but if I step through the test, I see the following:


(Pdb) object.Shape
<Solid object at 0x55e974e42440>
(Pdb) object.Shape.BoundBox
BoundBox (-17, -14.7224, -5, 8.5, 14.7224, 5)
(Pdb) object.Shape.BoundBox.XLength
25.499999999999996
(Pdb) object.Shape.BoundBox.YLength
29.444863728670914
(Pdb) object.Shape.BoundBox.ZLength
10.0

I tried to do a recompute on the doc.ActiveObject, with no result:


(Pdb) doc.ActiveObject.recompute()
True
(Pdb) object2 = doc.ActiveObject
(Pdb) object2.Shape
<Solid object at 0x55e973efa380>
(Pdb) object2.Shape.BoundBox
BoundBox (-17, -14.7224, -5, 8.5, 14.7224, 5)
(Pdb) object2.Shape.BoundBox.XLength
25.499999999999996
(Pdb) object2.Shape.BoundBox.YLength
29.444863728670914
(Pdb) object2.Shape.BoundBox.ZLength
10.0

Let me know if I can test something else.

chennes

2021-04-19 16:07

developer   ~0015618

In that FCStd file, when you view it from the top, are you seeing a circle, or an oval?

floesche

2021-04-19 18:41

reporter   ~0015619

It's a circle from the top, an oval from front.

In the "Report view" window I am also seeing the following when creating the OpenSCAD element:


14:38:42  {'newsize': ['0', '0', '10'], 'auto': ['0', '0', '0'], 'convexity': '0'}
14:38:42  ['0', '0', '10']
14:38:42  ['0', '0', '0']
14:38:42  Old bounding box: BoundBox (-8.5, -8.5, -8.5, 8.5, 8.5, 8.5)
14:38:42  ['17.0', '17.0', '10']
14:38:42  End processing CSG file

floesche

2021-04-19 18:58

reporter   ~0015620

…and the attached file is generated directly from the test_import.CSG.py file: I set a breakpoint at line 350 (after doc=self.utility_create_scad…) and the ran
doc.saveAs("/tmp/test_import_resize_l350.FCStd")
. Just in case this is different from what the GUI does.
test_import_resize_l350.FCStd (Attachment missing)

chennes

2021-04-19 19:22

developer   ~0015621

I wonder if the active object isn't what the test expects it to be. If you are seeing a circle from the top, then the bounding box being reported can't correspond to that object, since the reported box has different X and Y components. Can you verify that doc.ActiveObject is in fact giving you that spheroid, and not some other object?

floesche

2021-04-19 19:37

reporter   ~0015622

Sorry, how could I do that?

doc.ActiveObject.Label
gives me 'Matrix_Deformation'.

chennes

2021-04-19 19:42

developer   ~0015623

That's what I expect to see. Can you recompute the entire document and see if the bounds changes?

floesche

2021-04-19 19:54

reporter   ~0015624

Is that how I can recompute a document?


doc.recompute()
0
(Pdb) doc.ActiveObject.Shape.BoundBox.XLength
25.499999999999996

In any case, the XLength doesn't seem to be correct.

chennes

2021-04-19 21:45

developer   ~0015626

Are you also on Arch, or are using using a different distro? It looks like I'm going to have to find a way of reproducing it locally, there's a disconnect between what you are seeing onscreen (and posting here in your FCStd files) and the reported bounding box, and I can't figure out what that could be.

floesche

2021-04-19 21:49

reporter   ~0015627

Yes, I am also on Arch.

I don't know much about the data structures used in FreeCAD, but I know a bit about coding. So if you have ideas what I can try, I'd be happy to.

chennes

2021-04-19 22:02

developer   ~0015628

First, thanks for all the help you've provided so far! Second: to be honest I'm at a bit of a loss about what's going on, but my first order of business will be to add some print statements around the matrix deformation to make sure that at least the values going in and out of it are being calculated correctly.

floesche

2021-04-20 04:50

reporter   ~0015629

The bounding box seems to originate from the OpenCASCADE transformation. The test code ultimately calls
BRepBuilderAPI_GTransform mkTrf(this->_Shape, mat);
in TopoShape.cpp L3234. This is where the dimensions of the boundingbox changes from the expected to the unexpected dimensions.

The most fundamental way I could replicate this, was to do the transformation directly in DRAWEXE:


pload ALL
psphere s 8.5
puts [bounding s]
scalexyz t s 1 1 0.5858
puts [bounding t]

This creates the first bounding box:

-8.5000000999999994 -8.5000000999999994 -8.5000000999999994 8.5000000999999994 8.5000000999999994 8.5000000999999994
and the second:
-17.000000099999998 -14.72243196433546 -4.9797931000000002 8.5000000999999994 14.722431964335453 4.9797931000000002

These numbers are basically the same as the test generates.

Possibly all this is related to the (non)issue https://tracker.dev.opencascade.org/view.php?id=27042?

floesche

2021-04-22 15:30

reporter   ~0015642

After playing around with this for a bit, I have a few questions – maybe you can help with the answers?

1) I am guess, that the FreeCAD GUI is doing some additional steps when rendering the OpenSCAD parts. I might be on the wrong track, but is it possible, that OpenSCAD for FreeCAD GUI are converted from Part to Mesh and back to Part via "process3D_ObjectsViaOpenSCADShape" in OpenSCADUtils.py?

2) I am guessing, a similar transformation would defeat the purpose of this test. Alternatively, would a different mapping of "newsize" to another transformation in p_resize_action (importCSG.py L:494) make sense?

3) Is it possible to reproduce the test error or the DRAWEXE script on another system than Arch Linux?

Apologies if these questions have obvious answers. Any hints welcome.

Issue History

Date Modified Username Field Change
2021-04-07 10:03 greyltc New Issue
2021-04-10 02:48 chennes Assigned To => chennes
2021-04-10 02:48 chennes Status new => assigned
2021-04-12 18:19 chennes Status assigned => feedback
2021-04-12 18:19 chennes Note Added: 0015611
2021-04-18 00:58 floesche Note Added: 0015614
2021-04-18 00:58 floesche File Added: Issue-4622.FCStd
2021-04-18 22:10 chennes Note Added: 0015615
2021-04-18 22:20 floesche Note Added: 0015616
2021-04-18 22:21 floesche Note Edited: 0015616
2021-04-18 22:30 floesche Note Edited: 0015616
2021-04-19 14:50 floesche Note Added: 0015617
2021-04-19 14:50 floesche Note Edited: 0015617
2021-04-19 14:50 floesche Note Edited: 0015617
2021-04-19 16:07 chennes Note Added: 0015618
2021-04-19 18:41 floesche Note Added: 0015619
2021-04-19 18:58 floesche Note Added: 0015620
2021-04-19 18:58 floesche File Added: test_import_resize_l350.FCStd
2021-04-19 19:22 chennes Note Added: 0015621
2021-04-19 19:37 floesche Note Added: 0015622
2021-04-19 19:42 chennes Note Added: 0015623
2021-04-19 19:54 floesche Note Added: 0015624
2021-04-19 21:45 chennes Note Added: 0015626
2021-04-19 21:49 floesche Note Added: 0015627
2021-04-19 22:02 chennes Note Added: 0015628
2021-04-20 04:50 floesche Note Added: 0015629
2021-04-22 15:30 floesche Note Added: 0015642