GithubHelp home page GithubHelp logo

Comments (17)

aothms avatar aothms commented on May 27, 2024 1

It seems this has been fixed at some point in OCCT upstream where the header is included Open-Cascade-SAS/OCCT@7109a4a#diff-89e4ed09db4b90a88f132a00171a3172f26279c2269e97c6861f90f75c595246

Didn't take the time to figure out what tags include this commit. Maybe 7.6.3 🙏 ?

from pythonocc-generator.

Krande avatar Krande commented on May 27, 2024 1

Okay, I am happy to report that pythonocc-core now compiles successfully on all 3 platforms!

In fact, to my surprise all tests are passing on windows. The excitement was short lived however. It seems bld.bat and build.sh are not testing the same things on my branch.

Both Linux and OSX do pass a lot of tests, but are failing somewhere in the core_geometry_unittest.TestGeometry suite.

image

Here are the full logs from the github actions pipelines:

https://github.com/Krande/pythonocc-core/runs/7787358841?check_suite_focus=true

The conda package of pythonocc-core v7.6.2 is available for testing on windows here -> https://anaconda.org/krande/pythonocc-core/files.

I will do some testing myself as well and see if the failing tests on linux are due to changes in the occt v7.6 api or due to changes made in my SWIG adaption.

@looooo I thought you might be interested in this given you mentioned in tpaviot/pythonocc-core#1111 an interest in updating pythonocc-core to v7.6.

Update:

It appears that I actually did manage to pass all tests on windows after all. And the failing test could be the test_curve_adaptor which seems to be a problem related to opencascade itself (similar errors have been reported in the cpp code based on the issue tpaviot/pythonocc-core#1057). I'll try to skip this particular test and see if everything passes after that.

from pythonocc-generator.

tpaviot avatar tpaviot commented on May 27, 2024 1

changes for occt762 have been merged into master, pythonocc-core 7.6.2 compilation and tests work fine

from pythonocc-generator.

Krande avatar Krande commented on May 27, 2024

Here's an update.

By building on the latest work by trelau in his pybinder project I found the necessary excludes to remove the previous errors related to OSD_Streambuffer.

So now it runs a lot further before failing due to errors seemingly arbitrarily relating to BRepAdaptor, Adaptor2d_OffsetCurve and Bnd_Box2d depending on which platform.

See github actions workflow logs for compilation attempts on all platforms here and the latest commit I made to the generate_wrapper.py script here -> Krande@b0f6dd7

Excerpt from Windows compilation attempt here

[111/910] Building CXX object CMakeFiles\_BRep.dir\bin\BRepPYTHON_wrap.cxx.obj
FAILED: CMakeFiles/_BRep.dir/bin/BRepPYTHON_wrap.cxx.obj 
C:\PROGRA~1\MICROS~2\2022\ENTERP~1\VC\Tools\MSVC\1416~1.270\bin\HostX64\x64\cl.exe  /nologo /TP -DCSFDB -DHAVE_CONFIG_H -DOCCT_NO_DEPRECATED -DWIN32 -DWNT -D_BRep_EXPORTS -D_WINDOWS -I%SRC_DIR% -I%SRC_DIR%\OPENGL_INCLUDE_DIR -I%PREFIX%\Lib\site-packages\numpy\core\include -I%PREFIX%\Library\include\opencascade -I%SRC_DIR%\src\SWIG_files\headers -I%SRC_DIR%\src\Tesselator -I%SRC_DIR%\src\Visualization -I%SRC_DIR%\src\MeshDataSource -I%SRC_DIR%\src\Addons -I%PREFIX%\include /DWIN32 /D_WINDOWS /W3 /GR /EHsc /MD /O2 /Ob2 /DNDEBUG   /bigobj /wd4244 /wd4251 /wd4275 /wd4290 /showIncludes /FoCMakeFiles\_BRep.dir\bin\BRepPYTHON_wrap.cxx.obj /FdCMakeFiles\_BRep.dir\ /FS -c %SRC_DIR%\build\bin\BRepPYTHON_wrap.cxx
%SRC_DIR%\build\bin\BRepPYTHON_wrap.cxx(35867): error C2065: 'Bnd_Box2d': undeclared identifier
%SRC_DIR%\build\bin\BRepPYTHON_wrap.cxx(35867): error C2923: 'NCollection_Array1': 'Bnd_Box2d' is not a valid template type argument for parameter 'TheItemType'
%SRC_DIR%\build\bin\BRepPYTHON_wrap.cxx(35867): error C2065: 'Bnd_HArray1OfBox2d': undeclared identifier
%SRC_DIR%\build\bin\BRepPYTHON_wrap.cxx(35867): error C2059: syntax error: ')'
%SRC_DIR%\build\bin\BRepPYTHON_wrap.cxx(36377): error C2065: 'Bnd_HArray1OfSphere': undeclared identifier
%SRC_DIR%\build\bin\BRepPYTHON_wrap.cxx(36377): error C2059: syntax error: ')'
%SRC_DIR%\build\bin\BRepPYTHON_wrap.cxx(36542): error C2065: 'Bnd_HArray1OfBox': undeclared identifier
%SRC_DIR%\build\bin\BRepPYTHON_wrap.cxx(36542): error C2059: syntax error: ')'
%SRC_DIR%\build\bin\BRepPYTHON_wrap.cxx(36563): error C2065: 'Bnd_HArray1OfBox2d': undeclared identifier
%SRC_DIR%\build\bin\BRepPYTHON_wrap.cxx(36563): error C2059: syntax error: ')'
%SRC_DIR%\build\bin\BRepPYTHON_wrap.cxx(36617): error C2065: 'Bnd_Sphere': undeclared identifier
%SRC_DIR%\build\bin\BRepPYTHON_wrap.cxx(36617): error C2923: 'NCollection_Array1': 'Bnd_Sphere' is not a valid template type argument for parameter 'TheItemType'
%SRC_DIR%\build\bin\BRepPYTHON_wrap.cxx(36617): error C2065: 'Bnd_HArray1OfSphere': undeclared identifier
%SRC_DIR%\build\bin\BRepPYTHON_wrap.cxx(36617): error C2059: syntax error: ')'
%SRC_DIR%\build\bin\BRepPYTHON_wrap.cxx(36620): error C2065: 'Bnd_HArray1OfBox': undeclared identifier
%SRC_DIR%\build\bin\BRepPYTHON_wrap.cxx(36620): error C2059: syntax error: ')'
[112/910] Building CXX object CMakeFiles\_BRepTools.dir\bin\BRepToolsPYTHON_wrap.cxx.obj
[113/910] Swig compile src/SWIG_files/wrapper/BRepAdaptor.i for python
ninja: build stopped: subcommand failed.
    sys.exit(main())
  File "C:\Miniconda\envs\condabuild\lib\site-packages\conda_build\cli\main_build.py", line 488, in main
    execute(sys.argv[1:])
  File "C:\Miniconda\envs\condabuild\lib\site-packages\conda_build\cli\main_build.py", line 477, in execute
    outputs = api.build(args.recipe, post=args.post, test_run_post=args.test_run_post,
  File "C:\Miniconda\envs\condabuild\lib\site-packages\conda_build\api.py", line 186, in build
    return build_tree(
  File "C:\Miniconda\envs\condabuild\lib\site-packages\conda_build\build.py", line 3088, in build_tree
    packages_from_this = build(metadata, stats,
  File "C:\Miniconda\envs\condabuild\lib\site-packages\conda_build\build.py", line 2179, in build
    windows.build(m, build_file, stats=build_stats, provision_only=provision_only)
  File "C:\Miniconda\envs\condabuild\lib\site-packages\conda_build\windows.py", line 297, in build
    check_call_env(cmd, cwd=m.config.work_dir, stats=stats, rewrite_stdout_env=rewrite_env)
  File "C:\Miniconda\envs\condabuild\lib\site-packages\conda_build\utils.py", line 410, in check_call_env
    return _func_defaulting_env_to_os_environ('call', *popenargs, **kwargs)
  File "C:\Miniconda\envs\condabuild\lib\site-packages\conda_build\utils.py", line 390, in _func_defaulting_env_to_os_environ
    raise subprocess.CalledProcessError(proc.returncode, _args)
subprocess.CalledProcessError: Command '['cmd.exe', '/d', '/c', 'conda_build.bat']' returned non-zero exit status 1.
Error: Process completed with exit code 1.

from pythonocc-generator.

Krande avatar Krande commented on May 27, 2024

Hey, I took another stab at making modifications for the generator to work with OCCT v7.6, and have now gotten a bit further.

Now I am reaching almost 50% of the compilation of pythonocc-core for occt v7.6.2 by basically of adding/removing headers and skipping various function members etc..

However, I am running into an issue that I am unable to solve using tricks that seems to have worked until now.

The following error is giving me trouble:

...
[411/910] Building CXX object CMakeFiles\_HLRTopoBRep.dir\bin\HLRTopoBRepPYTHON_wrap.cxx.obj
FAILED: CMakeFiles/_HLRTopoBRep.dir/bin/HLRTopoBRepPYTHON_wrap.cxx.obj 
C:\PROGRA~1\MICROS~2\2022\ENTERP~1\VC\Tools\MSVC\1416~1.270\bin\HostX64\x64\cl.exe  /nologo /TP -DCSFDB -DHAVE_CONFIG_H -DHAVE_FREEIMAGE -DHAVE_FREETYPE -DHAVE_OPENGL_EXT -DHAVE_RAPIDJSON -DHAVE_VTK -DOCCT_NO_DEPRECATED -DUNICODE -DVTK_OPENGL2_BACKEND -DWIN32 -DWNT -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_HLRTopoBRep_EXPORTS -D_UNICODE -D_WINDOWS -I%SRC_DIR% -I%SRC_DIR%\OPENGL_INCLUDE_DIR -I%PREFIX%\Lib\site-packages\numpy\core\include -I%PREFIX%\Library\include -I%PREFIX%\Library\include\opencascade -I%SRC_DIR%\src\SWIG_files\headers -I%SRC_DIR%\src\Tesselator -I%SRC_DIR%\src\Visualization -I%SRC_DIR%\src\MeshDataSource -I%SRC_DIR%\src\Addons -I%PREFIX%\include /DWIN32 /D_WINDOWS /W3 /GR /EHsc /MD /O2 /Ob2 /DNDEBUG   /bigobj /wd4244 /wd4251 /wd4275 /wd4290 /showIncludes /FoCMakeFiles\_HLRTopoBRep.dir\bin\HLRTopoBRepPYTHON_wrap.cxx.obj /FdCMakeFiles\_HLRTopoBRep.dir\ /FS -c %SRC_DIR%\build\bin\HLRTopoBRepPYTHON_wrap.cxx
%PREFIX%\Library\include\opencascade\Contap_ArcFunction.hxx(47): error C2065: 'Adaptor2d_Curve2d': undeclared identifier
%PREFIX%\Library\include\opencascade\Contap_ArcFunction.hxx(47): error C2923: 'opencascade::handle': 'Adaptor2d_Curve2d' is not a valid template type argument for parameter 'T'
%PREFIX%\Library\include\opencascade\Contap_ArcFunction.hxx(81): error C2065: 'Adaptor2d_Curve2d': undeclared identifier
%PREFIX%\Library\include\opencascade\Contap_ArcFunction.hxx(81): error C2923: 'opencascade::handle': 'Adaptor2d_Curve2d' is not a valid template type argument for parameter 'T'
%PREFIX%\Library\include\opencascade\Contap_ArcFunction.lxx(45): error C2065: 'Adaptor2d_Curve2d': undeclared identifier
%PREFIX%\Library\include\opencascade\Contap_ArcFunction.lxx(45): error C2923: 'opencascade::handle': 'Adaptor2d_Curve2d' is not a valid template type argument for parameter 'T'
%PREFIX%\Library\include\opencascade\Contap_ArcFunction.lxx(47): error C2678: binary '=': no operator found which takes a left-hand operand of type 'opencascade::handle' (or there is no acceptable conversion)
...

The full compilation output can be found at:
https://github.com/Krande/pythonocc-core/runs/7748146537?check_suite_focus=true#step:5:1042

While the files are at:
https://github.com/Krande/pythonocc-core/tree/v7.6.2a1

I have tried to include Adaptor2d_Curve2d.hxx to the Contap.i, but unfortunately with no luck.

The only thing I've tried that seems to work is to go into the source Contap_ArcFunction.hxx located in the opencascade include directory in the conda package and manually add Adaptor2d_Curve2d.hxx to the include statements.

#ifndef _Contap_ArcFunction_HeaderFile
#define _Contap_ArcFunction_HeaderFile

#include <Adaptor3d_Surface.hxx>
#include <Adaptor2d_Curve2d.hxx>
#include <Contap_TFunction.hxx>
#include <gp_Dir.hxx>
#include <gp_Pnt.hxx>
#include <TColgp_SequenceOfPnt.hxx>
#include <IntSurf_Quadric.hxx>
#include <math_FunctionWithDerivative.hxx>

class Contap_ArcFunction  : public math_FunctionWithDerivative

But as far as I can tell this would require a custom compiled OCCT package on conda which seems unpractical to say the least.

@tpaviot @aothms Any advice you could give on this would be much appreciated?

from pythonocc-generator.

Krande avatar Krande commented on May 27, 2024

@aothms Thank you for the quick response! As a matter of fact I just now figured out what was wrong in my attempt at solving this.

I was adding the headers in the wrong file Contap.i instead of in HLRTopoBRep.i (which is what the error actually was telling me).

I just missed completed where it actually failed: FAILED: CMakeFiles/_HLRTopoBRep.dir/bin/HLRTopoBRepPYTHON_wrap.cxx.obj

So the tricks that worked before seems to still work. I'll let you know once I have this at a 100% :)

from pythonocc-generator.

aothms avatar aothms commented on May 27, 2024

Great, still a bit of a bug though that they resolved, headers should include the headers they depend on.

from pythonocc-generator.

Krande avatar Krande commented on May 27, 2024

Yes, I see there is a 7.6.3 Tag, but I'll run through all of it using 7.6.2 to find other issues first.

Here's another issue.

There is a specific pythonocc-core class ShapeTesselator that seems to point to Nodes() and UVNodes() methods on Poly_Triangulation that are no longer available in 7.6:

Poly_Triangulation does no more provide access to internal array structures: methods Nodes(), ChangeNode(), Triangles(), ChangeTriangle(), UVNodes(), ChangeUVNode(), Normals() have been removed. Methods of Poly_Triangulation for accessing individual nodal properties / triangles by index and implementing copy semantics should be used instead. The same is applicable to Poly_PolygonOnTriangulation interface.

https://dev.opencascade.org/doc/overview/html/occt__upgrade.html#upgrade_occt760_poly

Handle(Poly_Triangulation) myT = BRep_Tool::Triangulation(myFace, aLocation);


if (myT.IsNull()) {
    invalidFaceTriCount++;
    continue;
}

aface *this_face = new aface;

//write vertex buffer
const TColgp_Array1OfPnt& Nodes = myT->Nodes();
this_face->vertex_coord = new double[Nodes.Length() * 3];
this_face->number_of_coords = Nodes.Length();
for (Standard_Integer i = Nodes.Lower(); i <= Nodes.Upper(); i++) {
  gp_Pnt p = Nodes(i).Transformed(aLocation.Transformation());
  this_face->vertex_coord[((i-1) * 3)+ 0] = p.X();
  this_face->vertex_coord[((i-1) * 3)+ 1] = p.Y();
  this_face->vertex_coord[((i-1) * 3)+ 2] = p.Z();
}

https://github.com/Krande/pythonocc-core/blob/v7.6.2a1/src/Tesselator/ShapeTesselator.cpp#L109-L128

I am guessing this is just a matter of basically rewriting parts of the script to no longer point to the Nodes() method by substituting Nodes.Length() with myT.NbNodes()

Any hints on how I should rewrite Standard_Integer i = Nodes.Lower(); i <= Nodes.Upper(); i++?

from pythonocc-generator.

aothms avatar aothms commented on May 27, 2024

I think you can follow what IfcOpenShell does

https://github.com/IfcOpenShell/IfcOpenShell/blob/v0.7.0/src/ifcgeom_schema_agnostic/IfcGeomRepresentation.cpp#L154-L156

auto p = myT->Node(i).Transformed(aLocation).XYZ();
this_face->vertex_coord[((i-1) * 3)+ 0] = p.X();
this_face->vertex_coord[((i-1) * 3)+ 1] = p.Y();
this_face->vertex_coord[((i-1) * 3)+ 2] = p.Z();

(untested)

from pythonocc-generator.

Krande avatar Krande commented on May 27, 2024

Thanks for the tip!

But I think I might have found a workaround with limited impact on the existing code base using

const TColgp_Array1OfPnt& Nodes = myT->MapNodeArray()->Array1();

I guess I'll find out eventually if my hacks and workarounds does/does not break things!

from pythonocc-generator.

Krande avatar Krande commented on May 27, 2024

A new day, a little progress and another issue :)

I ran into an issue with wrapping an enum today when compiling the RWGltf module.

FAILED: CMakeFiles/_RWGltf.dir/bin/RWGltfPYTHON_wrap.cxx.obj 
C:\PROGRA~1\MIB055~1\2022\PROFES~1\VC\Tools\MSVC\1431~1.311\bin\Hostx86\x64\cl.exe  /nologo /TP -DCSFDB -DHAVE_CONFIG_H -DHAVE_FREEIMAGE -DHAVE_FREETYPE -DHAVE_OPENGL_EXT -DHAVE_RAPIDJSON -DHAVE_VTK -DOCCT_NO_DEPRECATED -DUNICODE -DVTK_OPENGL2_BACKEND -DWIN32 -DWNT -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_RWGltf_EXPORTS -D_UNICODE -D_WINDOWS -I ... -external:W0 /DWIN32 /D_WINDOWS /W3 /GR /EHsc /MD /O2 /Ob2 /DNDEBUG   /bigobj /wd4244 /wd4251 /wd4275 /wd4290 -std:c++14 /showIncludes /FoCMakeFiles\_RWGltf.dir\bin\RWGltfPYTHON_wrap.cxx.obj /FdCMakeFiles\_RWGltf.dir\ /FS -c ..\bin\RWGltfPYTHON_wrap.cxx
..\RWGltfPYTHON_wrap.cxx(22973): error C2065: 'ShapeMapGroup_Nodes': undeclared identifier
..\RWGltfPYTHON_wrap.cxx(22973): error C2660: 'SWIG_Python_SetConstant': function does not take 2 arguments
..\RWGltfPYTHON_wrap.cxx(1178): note: see declaration of 'SWIG_Python_SetConstant'
..\RWGltfPYTHON_wrap.cxx(22974): error C2065: 'ShapeMapGroup_Meshes': undeclared identifier
..\RWGltfPYTHON_wrap.cxx(22974): error C2660: 'SWIG_Python_SetConstant': function does not take 2 arguments
..\RWGltfPYTHON_wrap.cxx(1178): note: see declaration of 'SWIG_Python_SetConstant'
..\RWGltfPYTHON_wrap.cxx(22975): error C2065: 'ShapeMapGroup_PrimArray': undeclared identifier
..\RWGltfPYTHON_wrap.cxx(22975): error C2660: 'SWIG_Python_SetConstant': function does not take 2 arguments
..\RWGltfPYTHON_wrap.cxx(1178): note: see declaration of 'SWIG_Python_SetConstant'

The offending enum definitions in RWGltf.i:

...
enum ShapeMapGroup {
	ShapeMapGroup_Nodes = 0,
	ShapeMapGroup_Meshes = 1,
	ShapeMapGroup_PrimArray = 2,
};
...
class ShapeMapGroup(IntEnum):
	ShapeMapGroup_Nodes = 0
	ShapeMapGroup_Meshes = 1
	ShapeMapGroup_PrimArray = 2
ShapeMapGroup_Nodes = ShapeMapGroup.ShapeMapGroup_Nodes
ShapeMapGroup_Meshes = ShapeMapGroup.ShapeMapGroup_Meshes
ShapeMapGroup_PrimArray = ShapeMapGroup.ShapeMapGroup_PrimArray
...

And definitions in RWGltf.pyi:

class ShapeMapGroup(IntEnum):
    ShapeMapGroup_Nodes: int = ...
    ShapeMapGroup_Meshes: int = ...
    ShapeMapGroup_PrimArray: int = ...

ShapeMapGroup_Nodes = ShapeMapGroup.ShapeMapGroup_Nodes
ShapeMapGroup_Meshes = ShapeMapGroup.ShapeMapGroup_Meshes
ShapeMapGroup_PrimArray = ShapeMapGroup.ShapeMapGroup_PrimArray

Any ideas where I should start looking?

Update:

I ended up by simply skipping the enum altogether

from pythonocc-generator.

aothms avatar aothms commented on May 27, 2024

Wonderful progress!

from pythonocc-generator.

tpaviot avatar tpaviot commented on May 27, 2024

Thank you @Krande for your work, and sorry for being off for a few months after I took a new job position. I updated the generator to deal with occt7.6.2 headers. Just a few words regarding your commits: there's no need to create a specific swig_modifier for each occt version. Indeed related changes may be needed in future versions, and adding new headers on top of swig files does not create any backward/forward incompatibility. Note that the generate_wrapper.py script is formatted with black using default settings. The ShapeTesselator.cpp file needed a couple of additional tweaks to run on my linux machine and avoir segfaults. I also had to disable the test_curve_adaptor test, which is related to a weird issue, I'm not sure it is even needed. A build is running on Azure, I will report the status.

Anyway, congrats for your work! It's not obvious to enter the pythonocc generator, I'm glad to welcome a new contributor. Feel free to submit pull requests, splitted into atomic commits that do solve a documented issue (the build process using conda/azure is quite unstable and may suffer from many side effects).

from pythonocc-generator.

tpaviot avatar tpaviot commented on May 27, 2024

and thank you @aothms for your pointer to the ifcopenshell cpp code

from pythonocc-generator.

tpaviot avatar tpaviot commented on May 27, 2024

@Krande the next step is to check/update the pythonocc-demos to the new version.

from pythonocc-generator.

Krande avatar Krande commented on May 27, 2024

@tpaviot Just happy to help, and thank you for the feedback!

Regarding the changes I made to the generate_wrapper.py. I agree with your comments. My changes were primarily intended to increase my own familiarity with the SWIG generator process and was never intended to replace the current code base.

from pythonocc-generator.

Krande avatar Krande commented on May 27, 2024

That's great!

Then I think we can close this issue.

from pythonocc-generator.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.