diff --git a/.github/workflows/build-job.yml b/.github/workflows/build-job.yml index a08a314c3..bb910455f 100644 --- a/.github/workflows/build-job.yml +++ b/.github/workflows/build-job.yml @@ -69,7 +69,7 @@ jobs: - name: Generate (Windows on Linux) if: inputs.platform == 'Windows' run: | - micromamba create --yes --platform win-64 --no-deps --prefix ./occt occt=8.0.0 + micromamba create --yes --platform win-64 --no-deps --prefix ./occt occt=8.0.1 micromamba run -n bindgen cmake -S . -B . -G Ninja \ -DPython_ROOT_DIR=$CONDA_PREFIX \ -DPython3_ROOT_DIR=$CONDA_PREFIX \ @@ -88,7 +88,7 @@ jobs: -DPython3_ROOT_DIR=$CONDA_PREFIX \ -DPython_FIND_VIRTUALENV=ONLY \ -DPython3_FIND_VIRTUALENV=ONLY - cmake --build . + cmake --build . -- -v ls -lRht - name: Copy pkl output @@ -160,7 +160,8 @@ jobs: run: | micromamba run -n bindgen cmake -B build -S "../${OCP_src}" -G Ninja \ -DCMAKE_BUILD_TYPE=Release - micromamba run -n bindgen cmake --build build -j 2 -- -k 0 + micromamba run -n bindgen cmake --build build -j 2 -- -v -k 0 + micromamba run -n bindgen cmake --build build -j 2 rm -rf build/CMakeFiles - name: Compile (Mac) @@ -169,7 +170,8 @@ jobs: micromamba run -n bindgen cmake -B build -S "../${OCP_src}" -G Ninja \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_OSX_SYSROOT=/opt/MacOSX10.15.sdk/ - micromamba run -n bindgen cmake --build build -j 2 -- -k 0 + micromamba run -n bindgen cmake --build build -j 2 -- -v -k 0 + micromamba run -n bindgen cmake --build build -j 2 rm -rf build/CMakeFiles - name: Compile (Windows) @@ -183,6 +185,7 @@ jobs: -DPython3_ROOT_DIR=$env:CONDA_PREFIX ` -DCMAKE_LINKER=lld-link.exe micromamba run -n bindgen cmake --build build -j 1 -- -v -k 0 + micromamba run -n bindgen cmake --build build -j 1 micromamba run -n bindgen cmake -E rm -rf build\CMakeFiles env: CXX: "cl.exe" diff --git a/CMakeLists.txt b/CMakeLists.txt index ea536dcc4..57585e5c9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,8 +1,10 @@ cmake_minimum_required(VERSION 3.29) project(OCP) +cmake_host_system_information(RESULT N_CORES QUERY NUMBER_OF_LOGICAL_CORES) + set(N_PROC - 2 + ${N_CORES} CACHE STRING "Number of processes used for generating code") set(DLL_EXT dll @@ -127,7 +129,7 @@ add_custom_command( ${CMAKE_SOURCE_DIR} ${CXX_INCLUDES} parse ${CMAKE_SOURCE_DIR}/ocp.toml tmp.pkl ${PLATFORM} WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - DEPENDS ${CMAKE_SOURCE_DIR}/ocp.toml + # DEPENDS ${CMAKE_SOURCE_DIR}/ocp.toml USES_TERMINAL COMMENT "Running pywrap - parse") diff --git a/environment.devenv.yml b/environment.devenv.yml index 5c8995b36..a7ca36d6f 100644 --- a/environment.devenv.yml +++ b/environment.devenv.yml @@ -9,7 +9,7 @@ dependencies: - ninja {% if get_env("STAGE", default="generate") == "generate" %} - clangdev - - python-clang=21.* + - python-clang=22.* - joblib - toml - click @@ -23,6 +23,7 @@ dependencies: - toposort - py-lief - msitools # [linux] + - cxxheaderparser {% else %} - cxx-compiler - tbb-devel # [win] diff --git a/ocp.toml b/ocp.toml index 2ad9d6195..cec0a08f3 100644 --- a/ocp.toml +++ b/ocp.toml @@ -344,6 +344,7 @@ modules = [ "APIHeaderSection", "UnitsMethods", "RWMesh", +"BRepGraph", ] exclude = [ @@ -1347,8 +1348,6 @@ exclude = [ "IMeshData_Types.hxx" ] -# "BVH_Box.hxx","BVH_tools.hxx" - exceptions = ["Standard_Failure"] exclude_collection = [ @@ -1377,7 +1376,22 @@ exclude_collection = [ "DynamicArray_BRepExtrema_ProximityDistTool::ProxPnt_Status", "DataMap_unsigned int_AIS_MouseGesture", "DataMap_unsigned int_AIS_SelectionScheme", -"DataMap_TopoDS_Shape_TNaming_PtrRefShape_TopTools_ShapeMapHasher" +"DataMap_TopoDS_Shape_TNaming_PtrRefShape_TopTools_ShapeMapHasher", +"LinearVector_GLuint64", +# BRepGraph related +"FlatDataMap_BRepGraph_ItemId_BRepGraph_ItemId", +"FlatMap_BRepGraph_ItemUID", +"FlatMap_BRepGraph_NodeId", +"FlatMap_BRepGraph_UID", +"ForwardRangeIterator_BRepGraph_CacheIterator", +"ForwardRangeIterator_BRepGraph_ChildExplorer", +"ForwardRangeIterator_BRepGraph_DefsIterator::DefsVertexOfEdge", +"ForwardRangeIterator_BRepGraph_LayerIterator", +"ForwardRangeIterator_BRepGraph_ParentExplorer", +"ForwardRangeIterator_BRepGraph_RefsIterator::RefsVertexOfEdge", +"ForwardRangeIterator_BRepGraph_RelatedIterator", +"ForwardRangeIterator_BRepGraph_RootProductIterator", +"ForwardRangeIterator_BRepGraph_SupplementIterator", ] collection_pattern = "NCollection" @@ -1390,7 +1404,7 @@ class OpenGl_ShaderProgram; module_mapping = "lambda x: Path(x).splitpath()[-1].split('.')[0].split('_')[0]" byref_types = ["Standard_Real","Standard_Integer","Standard_Boolean","int","double","bool","float"] -byref_types_smart_ptr = ["opencascade::handle", "handle", "Handle"] +byref_types_smart_ptr = ["occ::handle", "opencascade::handle", "handle", "Handle"] parsing_header = '''#pragma clang diagnostic ignored "-Wmacro-redefined" class Adaptor2d_Curve2d; @@ -1862,8 +1876,7 @@ struct NSOpenGLContext {};""" # exclude_methods = ["AIS_InteractiveContext::EntityOwners"] include_header_pre = """#include -#include -auto OptionsForAttach = [](){return AIS_Manipulator::OptionsForAttach();};""" +#include """ include_body_pre = "py::class_(m,\"AIS_Manipulator_OptionsForAttach\");" exclude_typedefs = ["AIS_DataMapOfShapeDrawer","AIS_DataMapOfIOStatus","AIS_DataMapOfILC","AIS_IndexedDataMapOfOwnerPrs"] @@ -2444,7 +2457,7 @@ using rapidjson::BasicOStreamWrapper;""" [Modules.BRepTopAdaptor] - exclude_classes = ["BRepTopAdaptor_FClass2d"] + exclude_methods = ["BRepTopAdaptor_FClass2d::Copy"] [Modules.BRepTopAdaptor.parsing_headers] @@ -2633,3 +2646,7 @@ using rapidjson::BasicOStreamWrapper;""" [Modules.Bnd] exclude_typedefs = ["Bnd_B2d","Bnd_B2f","Bnd_B3d","Bnd_B3f"] + + [Modules.BRepGraph] + + exclude_classes = ["std::hash*", "BRepGraph_Data", "BRepGraph_IteratorDetail::*", "BRepGraph_RefsIterator::Detail::*", "BRepGraph_ReverseIterator::DefTraits*"] diff --git a/pywrap b/pywrap index 76a16d0ca..6f208df85 160000 --- a/pywrap +++ b/pywrap @@ -1 +1 @@ -Subproject commit 76a16d0ca37aa097b7b86a614c37e91c9374d19f +Subproject commit 6f208df85dfe6ad8cf06633d5daae339f8015f37 diff --git a/tests/test_ocp.py b/tests/test_ocp.py index c27eea379..cbe60552a 100644 --- a/tests/test_ocp.py +++ b/tests/test_ocp.py @@ -3,26 +3,32 @@ from OCP.BRepPrimAPI import BRepPrimAPI_MakeBox from OCP.TopoDS import TopoDS_Shape -from OCP.collections import List_TopoDS_Shape +from OCP.collections import List_TopoDS_Shape, Array1_TopoDS_Shape # %% TopoDS_Shape -def test_hash(): +@fixture +def boxes(): s1 = BRepPrimAPI_MakeBox(1, 1, 1).Shape() s2 = BRepPrimAPI_MakeBox(1, 1, 1).Shape() s3 = BRepPrimAPI_MakeBox(1, 1, 1).Shape() + return s1, s2, s3 + + +def test_hash(boxes): + + s1, s2, s3 = boxes + assert len({s1, s2, s3}) == 3 assert len({s1, s1, s3}) == 2 -def test_iter(): +def test_iter(boxes): - s1 = TopoDS_Shape() - s2 = TopoDS_Shape() - s3 = TopoDS_Shape() + s1, s2, s3 = boxes shape_list = List_TopoDS_Shape() @@ -38,6 +44,38 @@ def test_iter(): for s in shape_list: assert isinstance(s, TopoDS_Shape) + for s in list(shape_list): + assert isinstance(s, TopoDS_Shape) + + +def test_shape_list_bool(boxes): + + l = List_TopoDS_Shape() + + assert not l + assert l.IsEmpty() + + for s in boxes: + l.Append(s) + + assert l + assert not l.IsEmpty() + + +def test_shape_array(boxes): + + l = Array1_TopoDS_Shape(0, 2) + + assert l + assert not l.IsEmpty() + assert len(l) == 3 + + for i, s in enumerate(boxes): + l.SetValue(i, s) + + for i, s in enumerate(boxes): + assert s.IsEqual(l(i)) + # %% primitive @@ -275,3 +313,46 @@ def test_location(): assert trans.X() == 2.0 assert trans.Y() == 0.0 assert trans.Z() == 0.0 + + +# %% Vis materials and handling of fields in general +from OCP.Image import Image_Texture +from OCP.Quantity import Quantity_ColorRGBA, Quantity_TOC_RGB +from OCP.TCollection import TCollection_HAsciiString +from OCP.XCAFDoc import XCAFDoc_VisMaterial, XCAFDoc_VisMaterialPBR +from OCP.collections import Vec3_float + + +def test_vismaterialpbr(): + + name = "Dummy" + rgba = (0.0, 0.0, 0.0, 1.0) + metallic = 0.0 + roughness = 0.5 + emissive_strength = 5.0 + emissive_factor = (1.0, 0.35, 0.0) + emissive = [ + e * emissive_strength for e in emissive_factor + ] # strength not supported in occt + + pbr = XCAFDoc_VisMaterialPBR() + + pbr.BaseColor = Quantity_ColorRGBA(*rgba) + pbr.Metallic = metallic + pbr.Roughness = roughness + pbr.EmissiveFactor = Vec3_float(*emissive) + m = XCAFDoc_VisMaterial() + m.SetPbrMaterial(pbr) + m.SetRawName(TCollection_HAsciiString(name)) + + p = m.PbrMaterial() + + assert m.RawName().ToCString() == name + assert ( + p.BaseColor.GetRGB().Values(Quantity_TOC_RGB) == (0.0, 0.0, 0.0) + and p.BaseColor.Alpha() == 1.0 + ) + assert (p.Metallic, p.Roughness) == (metallic, roughness) + assert (p.EmissiveFactor.r(), p.EmissiveFactor.g(), p.EmissiveFactor.b()) == approx( + emissive + ) diff --git a/tests/test_step.py b/tests/test_step.py index 7ec5207ff..dcc2e2bec 100644 --- a/tests/test_step.py +++ b/tests/test_step.py @@ -28,7 +28,10 @@ from OCP.BRepBuilderAPI import BRepBuilderAPI_MakeVertex -def _step_with_supplemental_geom(path: str, loc_name: str,) -> None: +def _step_with_supplemental_geom( + path: str, + loc_name: str, +) -> None: # create a doc and add a dummy vertex shape app = XCAFApp_Application.GetApplication_s() @@ -65,7 +68,9 @@ def _step_with_supplemental_geom(path: str, loc_name: str,) -> None: cgr = StepRepr_ConstructiveGeometryRepresentation() cgr.Init( - "Additional coordinate system", cs_array, rep.ContextOfItems(), + "Additional coordinate system", + cs_array, + rep.ContextOfItems(), ) cgrr = StepRepr_ConstructiveGeometryRepresentationRelationship()