trelau / AFEM

Airframe Finite Element Modeler
GNU Lesser General Public License v2.1
40 stars 16 forks source link

(WX) Viewer example doesn't work in Linux #10

Open lvh opened 3 years ago

lvh commented 3 years ago

Expected Behavior

python structure_wingbox.py shows the wingbox as shown in the README.

Current Behavior

After installing with conda as per README, salient part of the console output:

... <CROPPED>
Volume is  5918591.40625673
Centroid of cut shape is  Point(1108.596, 115.894, -92.779)
Volume of cut shape is  1031538.6147457744
Centroid of cut shape is  Point(1066.386, 117.746, -92.784)
Volume of cut shape is  783180.0934238355
Computing mesh...
sh: 1: SMDS_MemoryLimit: not found
Meshing complete in  13.501382827758789  seconds.
Press "c" to continue...

(structure_wingbox.py:139256): Gdk-WARNING **: 10:24:12.331: gdkdrawable-x11.c:952 drawable is not a pixmap or window
Traceback (most recent call last):
  File "/home/lvh/miniconda3/envs/afem/lib/python3.8/site-packages/wx/core.py", line 3285, in <lambda>
    lambda event: event.callable(*event.args, **event.kw) )
  File "/home/lvh/miniconda3/envs/afem/lib/python3.8/site-packages/OCCT/Visualization/WxViewer.py", line 144, in _init_wind
    wind = Xw_Window(self.display_connect, hwnd)
RuntimeError: Xw_Window, given invalid X window

Possible Solution

I found a StackOverflow thread suggesting that in current versions of wxpython you need to use GetId on Linux, not GetHandle. I confirmed the current (pyOCCT) code uses GetHandle, but it does have some Linux-specific code there.

Steps to Reproduce (for bugs)

On Linux (if it matters: Debian testing/unstable, running KDE):

  1. conda create -n afem
  2. conda activate afem
  3. conda install -c conda-forge -c trelau afem
  4. git clone trelau/AFEM # I use hub so this works
  5. cd examples/ && python structure_wingbox.py

FWIW I think the underlying issue is in pyOCCT, because I get effectively an analog issue but with python import_step.py. pythonOCC works fine, but they use a Qt viewer on this system by default.

Context

I was trying to run the example.

Your Environment

conda list:

# packages in environment at /home/lvh/miniconda3/envs/afem:
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                 conda_forge    conda-forge
_openmp_mutex             4.5                       1_gnu    conda-forge
afem                      1.1.0                    py38_0    trelau
alabaster                 0.7.12                     py_0  
atk                       2.36.0                        1    conda-forge
atk-1.0                   2.36.0               haf93ef1_1    conda-forge
babel                     2.8.0                      py_0  
boost-cpp                 1.73.0               h9359b55_3    conda-forge
brotlipy                  0.7.0           py38h1e0a361_1000    conda-forge
bzip2                     1.0.8                h516909a_2    conda-forge
c-ares                    1.16.1               h516909a_0    conda-forge
ca-certificates           2020.6.20            hecda079_0    conda-forge
cairo                     1.16.0            h3fc0475_1005    conda-forge
certifi                   2020.6.20        py38h32f6830_0    conda-forge
cffi                      1.14.1           py38h5bae8af_0    conda-forge
chardet                   3.0.4           py38h32f6830_1006    conda-forge
cryptography              3.0              py38h766eaa4_0    conda-forge
curl                      7.71.1               he644dc0_4    conda-forge
docutils                  0.16                     py38_1  
expat                     2.2.9                he1b5a44_2    conda-forge
fontconfig                2.13.1            h1056068_1002    conda-forge
freeimage                 3.18.0               he1b5a44_0    conda-forge
freetype                  2.10.2               he06d7ca_0    conda-forge
fribidi                   1.0.10               h516909a_0    conda-forge
future                    0.18.2           py38h32f6830_1    conda-forge
gdk-pixbuf                2.38.2               h3f25603_4    conda-forge
gettext                   0.19.8.1          hc5be6a0_1002    conda-forge
glib                      2.65.0               h6f030ca_0    conda-forge
gobject-introspection     1.64.1           py38h03d966d_1    conda-forge
graphite2                 1.3.13            he1b5a44_1001    conda-forge
gst-plugins-base          1.14.5               h0935bb2_2    conda-forge
gstreamer                 1.14.5               h36ae1b5_2    conda-forge
gtk2                      2.24.32              h194ddfc_3    conda-forge
harfbuzz                  2.4.0                hee91db6_5    conda-forge
hdf4                      4.2.13            hf30be14_1003    conda-forge
hdf5                      1.10.6          nompi_h3c11f04_101    conda-forge
icu                       67.1                 he1b5a44_0    conda-forge
idna                      2.10               pyh9f0ad1d_0    conda-forge
imagesize                 1.2.0                      py_0  
jinja2                    2.11.2                     py_0  
jpeg                      9d                   h516909a_0    conda-forge
jsoncpp                   1.8.4             hc9558a2_1002    conda-forge
krb5                      1.17.1               hfafb76e_2    conda-forge
ld_impl_linux-64          2.34                 hc38a660_9    conda-forge
libblas                   3.8.0               17_openblas    conda-forge
libcblas                  3.8.0               17_openblas    conda-forge
libcurl                   7.71.1               hcdd3856_4    conda-forge
libedit                   3.1.20191231         h46ee950_1    conda-forge
libev                     4.33                 h516909a_0    conda-forge
libffi                    3.2.1             he1b5a44_1007    conda-forge
libgcc-ng                 9.3.0               h24d8f2e_14    conda-forge
libgfortran-ng            7.5.0               hdf63c60_14    conda-forge
libglu                    9.0.0             he1b5a44_1001    conda-forge
libgomp                   9.3.0               h24d8f2e_14    conda-forge
libiconv                  1.15              h516909a_1006    conda-forge
liblapack                 3.8.0               17_openblas    conda-forge
libnetcdf                 4.7.4           nompi_h84807e1_105    conda-forge
libnghttp2                1.41.0               hab1572f_1    conda-forge
libopenblas               0.3.10          pthreads_hb3c22a3_4    conda-forge
libpng                    1.6.37               hed695b0_1    conda-forge
libssh2                   1.9.0                hab1572f_5    conda-forge
libstdcxx-ng              9.3.0               hdf63c60_14    conda-forge
libtiff                   4.1.0                hc7e4089_6    conda-forge
libuuid                   2.32.1            h14c3975_1000    conda-forge
libwebp-base              1.1.0                h516909a_3    conda-forge
libxcb                    1.13              h14c3975_1002    conda-forge
libxml2                   2.9.10               h72b56ed_2    conda-forge
lz4-c                     1.9.2                he1b5a44_1    conda-forge
markupsafe                1.1.1            py38h7b6447c_0  
ncurses                   6.2                  he1b5a44_1    conda-forge
netgen4smesh              6.2.1804             h6bb024c_0    trelau
numpy                     1.19.1           py38h8854b6b_0    conda-forge
occt                      7.4.0                ha3df0f5_7    conda-forge
openssl                   1.1.1g               h516909a_1    conda-forge
packaging                 20.4                       py_0  
pango                     1.42.4               h7062337_4    conda-forge
pathlib2                  2.3.5            py38h32f6830_1    conda-forge
pcre                      8.44                 he1b5a44_0    conda-forge
pip                       20.2.1                     py_0    conda-forge
pixman                    0.38.0            h516909a_1003    conda-forge
pthread-stubs             0.4               h14c3975_1001    conda-forge
pycparser                 2.20               pyh9f0ad1d_2    conda-forge
pygments                  2.6.1                      py_0  
pyocct                    7.4.0.0                  py38_1    trelau
pyopenssl                 19.1.0                     py_1    conda-forge
pyparsing                 2.4.7                      py_0  
pypubsub                  4.0.3                      py_0    conda-forge
pysocks                   1.7.1            py38h32f6830_1    conda-forge
python                    3.8.5           h4d41432_2_cpython    conda-forge
python_abi                3.8                      1_cp38    conda-forge
pytz                      2020.1                     py_0  
readline                  8.0                  he28a2e2_2    conda-forge
requests                  2.24.0             pyh9f0ad1d_0    conda-forge
scipy                     1.5.2            py38h8c5af15_0    conda-forge
setuptools                49.2.1           py38h32f6830_0    conda-forge
six                       1.15.0             pyh9f0ad1d_0    conda-forge
smesh4pyocct              8.3.0.4              hf484d3e_0    trelau
snowballstemmer           2.0.0                      py_0  
sphinx                    3.1.2                      py_0  
sphinx_rtd_theme          0.4.3                      py_0  
sphinxcontrib-applehelp   1.0.2                      py_0  
sphinxcontrib-devhelp     1.0.2                      py_0  
sphinxcontrib-htmlhelp    1.0.3                      py_0  
sphinxcontrib-jsmath      1.0.1                      py_0  
sphinxcontrib-qthelp      1.0.3                      py_0  
sphinxcontrib-serializinghtml 1.1.4                      py_0  
sqlite                    3.32.3               hcee41ef_1    conda-forge
tbb                       2020.1               hc9558a2_0    conda-forge
tk                        8.6.10               hed695b0_0    conda-forge
urllib3                   1.25.10                    py_0    conda-forge
vtk                       8.2.0           py38hf2e56f5_218    conda-forge
wheel                     0.34.2                     py_1    conda-forge
wxpython                  4.0.7.post2      py38hac52f33_3    conda-forge
xorg-kbproto              1.0.7             h14c3975_1002    conda-forge
xorg-libice               1.0.10               h516909a_0    conda-forge
xorg-libsm                1.2.3             h84519dc_1000    conda-forge
xorg-libx11               1.6.11               h516909a_0    conda-forge
xorg-libxau               1.0.9                h14c3975_0    conda-forge
xorg-libxdmcp             1.1.3                h516909a_0    conda-forge
xorg-libxext              1.3.4                h516909a_0    conda-forge
xorg-libxrender           0.9.10            h516909a_1002    conda-forge
xorg-libxt                1.2.0                h516909a_0    conda-forge
xorg-renderproto          0.11.1            h14c3975_1002    conda-forge
xorg-xextproto            7.3.0             h14c3975_1002    conda-forge
xorg-xproto               7.0.31            h14c3975_1007    conda-forge
xz                        5.2.5                h516909a_1    conda-forge
zlib                      1.2.11            h516909a_1006    conda-forge
zstd                      1.4.5                h6597ccf_2    conda-forge
lvh commented 3 years ago

FWIW: I was able to get it to work pretty easily in a Windows VM, increasing my conviction it's a WX-specific issue, likely the GetHandle vs GetId one.