Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiling OCP for Apple M1 Max (arm64) #68

Closed
bernhard-42 opened this issue Nov 28, 2021 · 22 comments
Closed

Compiling OCP for Apple M1 Max (arm64) #68

bernhard-42 opened this issue Nov 28, 2021 · 22 comments

Comments

@bernhard-42
Copy link

Trying to get CadQuery running on an arm64 CPU based Macbook Pro (M1 Max):

I have set up conda via MambaForge which provides Python and conda packages for Mac arm64 CPU (installer):

(base) $ mamba activate cq
(cq) $ file $(which python)
/opt/mamba/envs/cq/bin/python: Mach-O 64-bit executable arm64```

Issue

I came pretty far, however stuck with one final compilation error (the single pywrap warning, see below, seems to be unrelated):

$ cmake --build build -j 8 -- -k 0

[1/2] Building CXX object CMakeFiles/OCP.dir/RWGltf.cpp.o
FAILED: CMakeFiles/OCP.dir/RWGltf.cpp.o
/usr/bin/c++ -DOCP_EXPORTS -I/Users/bernhard/Development/cadquery/OCP/OCP -I/opt/mamba/envs/cq/include/opencascade -isystem /opt/mamba/envs/cq/include -isystem /opt/mamba/envs/cq/include/python3.8 -isystem /opt/mamba/envs/cq/include/vtk-9.0 -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.0.sdk -fPIC -fpermissive -fvisibility=hidden -fvisibility-inlines-hidden -std=gnu++17 -MD -MT CMakeFiles/OCP.dir/RWGltf.cpp.o -MF CMakeFiles/OCP.dir/RWGltf.cpp.o.d -o CMakeFiles/OCP.dir/RWGltf.cpp.o -c /Users/bernhard/Development/cadquery/OCP/OCP/RWGltf.cpp
In file included from /Users/bernhard/Development/cadquery/OCP/OCP/RWGltf.cpp:6:
In file included from /opt/mamba/envs/cq/include/pybind11/pybind11.h:17:
/opt/mamba/envs/cq/include/pybind11/detail/init.h:63:68: error: no matching constructor for initialization of 'RWGltf_GltfOStreamWriter'
inline Class *construct_or_initialize(Args &&...args) { return new Class{std::forward<Args>(args)...}; }
                                                                   ^    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/mamba/envs/cq/include/pybind11/detail/init.h:178:31: note: in instantiation of function template specialization 'pybind11::detail::initimpl::construct_or_initialize<RWGltf_GltfOStreamWriter, int &, 0>' requested here
            v_h.value_ptr() = construct_or_initialize<Cpp<Class>>(std::forward<Args>(args)...);
                              ^
/opt/mamba/envs/cq/include/pybind11/pybind11.h:1408:14: note: in instantiation of function template specialization 'pybind11::detail::initimpl::constructor<int &>::execute<pybind11::class_<RWGltf_GltfOStreamWriter, shared_ptr<RWGltf_GltfOStreamWriter>>, pybind11::arg, 0>' requested here
        init.execute(*this, extra...);
             ^
/Users/bernhard/Development/cadquery/OCP/OCP/RWGltf.cpp:473:10: note: in instantiation of function template specialization 'pybind11::class_<RWGltf_GltfOStreamWriter, shared_ptr<RWGltf_GltfOStreamWriter>>::def<int &, pybind11::arg>' requested here
        .def(py::init< int & >()  , py::arg("theOStream") )
         ^
/opt/mamba/envs/cq/include/opencascade/RWGltf_GltfOStreamWriter.hxx:21:7: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'int' to 'const RWGltf_GltfOStreamWriter' for 1st argument
class RWGltf_GltfOStreamWriter : public rapidjson::Writer<rapidjson::OStreamWrapper>
      ^
/opt/mamba/envs/cq/include/opencascade/RWGltf_GltfOStreamWriter.hxx:25:3: note: candidate constructor not viable: no known conversion from 'int' to 'rapidjson::OStreamWrapper &' (aka 'BasicOStreamWrapper<basic_ostream<char>> &') for 1st argument
  RWGltf_GltfOStreamWriter (rapidjson::OStreamWrapper& theOStream)
  ^
1 error generated.
ninja: build stopped: cannot make progress due to previous errors.

The steps I used to get there:

brew install cmake ninja

# Install Mambaforge https://github.com/conda-forge/miniforge
# https://github.com/conda-forge/miniforge/releases/latest/download/Mambaforge-MacOSX-x86_64.sh

mamba create -n cq python=3.8
mamba activate cq
mamba install pybind11 occt=7.5.2 pandas

git clone https://github.com/CadQuery/OCP.git
cd OCP/

git submodule update --init
cd pywrap/
pip install .
cd ..

PREFIX=/Library/Developer/CommandLineTools

SDK=SDKs/MacOSX12.sdk

C_INC=$PREFIX/$SDK/usr/include/
CPP_INC=$PREFIX/$SDK/usr/include/c++/v1/
GL_INC=$PREFIX/$SDK/System/Library/Frameworks/OpenGL.framework/Versions/A/Headers/
VTK_INC=/opt/mamba/envs/cq/include/vtk-9.0/

LIBCLANG=$PREFIX/usr/lib/libclang.dylib

mkdir -p include
rm -f ./include/OpenGL
ln -s $GL_INC ./include/OpenGL
pywrap -i $CPP_INC -i $C_INC -i ./include -i $VTK_INC -l $LIBCLANG all ocp.toml

cmake -B build -S ./OCP -G Ninja -DCMAKE_BUILD_TYPE=Release -DPython3_FIND_STRATEGY=LOCATION -DPython3_ROOT_DIR=$CONDA_PREFIX
cmake --build build -j 8 -- -k 0

pywrap issue

The pywrap run only had one issue:

Since this error appeared in a dump JSON routine, I thought to ignore and compile nevertheless.

 72%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▌                                                          | 225/313 [04:09<02:20,  1.60s/it]
[W 211128 14:04:44 translation_unit:47] ./opencascade/Graphic3d_WorldViewProjState.hxx
[W 211128 14:04:44 translation_unit:48] dummy.cxx:154:5: error: use of undeclared identifier 'OCCT_DUMP_FIELD_VALUE_NUMERICAL'
[W 211128 14:04:44 translation_unit:48] dummy.cxx:154:60: error: expected ';' after expression
[W 211128 14:04:44 translation_unit:48] dummy.cxx:155:5: error: use of undeclared identifier 'OCCT_DUMP_FIELD_VALUE_POINTER'
[W 211128 14:04:44 translation_unit:48] dummy.cxx:155:57: error: expected ';' after expression
[W 211128 14:04:44 translation_unit:48] dummy.cxx:156:5: error: use of undeclared identifier 'OCCT_DUMP_FIELD_VALUE_NUMERICAL'
[W 211128 14:04:44 translation_unit:48] dummy.cxx:156:68: error: expected ';' after expression
[W 211128 14:04:44 translation_unit:48] dummy.cxx:157:5: error: use of undeclared identifier 'OCCT_DUMP_FIELD_VALUE_NUMERICAL'
[W 211128 14:04:44 translation_unit:48] dummy.cxx:157:67: error: expected ';' after expression
@adam-urbanczyk
Copy link
Member

Could you share RWGltf.cpp and tmp_filtered.pkl?

@bernhard-42
Copy link
Author

tmp_filtered.pkl has 253M. Shall I load it and extract some smaller parts to share?
Or what would be a good place to share such a big file?

@bernhard-42
Copy link
Author

And now that I think of it, I do have an "OCP" folder with cpp files in the OCP repo, but I actually don't remember/know where it came from. Is this something the process build creates?
I just started on a clone of OCP that I created some time ago.

@bernhard-42
Copy link
Author

Is this something the process build creates?

To answer my own question, the OCP folder gets created by the process. Just repeated the steps in a fresh clone.

@bernhard-42
Copy link
Author

btw. I tried it on OCP master branch - if that info helps

@bernhard-42
Copy link
Author

To be able to continue, I commented out the section of klass = m.attr("RWGltf_GltfOStreamWriter"); in OCP/RWGltf.cpp
Afterwards I was able to create the library:

$ ls -lh ../OCP/OCP.cpython-38-darwin.so
-rwxr-xr-x  1 bernhard  staff   268M Nov 28 17:31 ../OCP/OCP.cpython-38-darwin.so
$ file ../OCP/OCP.cpython-38-darwin.so
../OCP/OCP.cpython-38-darwin.so: Mach-O 64-bit bundle arm64

I then did the following to create a cadquery environment:

mamba create -n cq2 python=3.8 pybind11 occt=7.5.2 pandas scipy ezdxf nptyping typing_extensions jupyterlab multimethod nlopt
mamba activate cq2

# "install" OCP
cp ./OCP/OCP.cpython-38-darwin.so $CONDA_PREFIX/lib/python3.8/site-packages/

# install cadquery
git clone https://github.com/cadquery/cadquery.git
cd cadquery
pip install .

SUCCESS!

image

@adam-urbanczyk
Copy link
Member

You can provide just the part related to RWGltf_GltfOStreamWriter. I'll look up the exact location later.

@bernhard-42
Copy link
Author

So the only remaining problem is the Gltf Writer. I did some more research and now think the pywrap error (which seems to come from a missing #include <Standard_Dump.hxx>) and the compile error could belong together. But the whole OCP thing is to complex for a non C++ developer.
I am happy to have a working CadQuery environment on an arm64 Mac - and can happily ignore the missing Gltf writer for the time being

@bernhard-42
Copy link
Author

This is the section I commented out:

    // Class RWGltf_GltfOStreamWriter from ./opencascade/RWGltf_GltfOStreamWriter.hxx
    klass = m.attr("RWGltf_GltfOStreamWriter");

    
    // nested enums

    static_cast<py::class_<RWGltf_GltfOStreamWriter , shared_ptr<RWGltf_GltfOStreamWriter>  >>(klass)
    // constructors
        .def(py::init< int & >()  , py::arg("theOStream") )
    // custom constructors
    // methods
    // methods using call by reference i.s.o. return
    // static methods
    // static methods using call by reference i.s.o. return
    // operators
    // additional methods and static methods
    // properties
    // methods returning by ref wrapped as properties
;

The .def wants int, however the include file OCP/opencascade/RWGltf_GltfOStreamWriter.hxx says

// Copyright (c) 2019 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.

#ifndef _RWGltf_GltfOStreamWriter_HeaderFile
#define _RWGltf_GltfOStreamWriter_HeaderFile

#include <rapidjson/prettywriter.h>
#include <rapidjson/ostreamwrapper.h>

//! rapidjson::Writer wrapper for forward declaration.
class RWGltf_GltfOStreamWriter : public rapidjson::Writer<rapidjson::OStreamWrapper>
{
public:
  //! Main constructor.
  RWGltf_GltfOStreamWriter (rapidjson::OStreamWrapper& theOStream)
  : rapidjson::Writer<rapidjson::OStreamWrapper> (theOStream) {}
};

#endif // _RWGltf_GltfOStreamWriter_HeaderFile

@adam-urbanczyk
Copy link
Member

Thanks, I was referring to the parts of tmp_filtered.pkl though.

@bernhard-42
Copy link
Author

I compared a linux build with my setup and turns out that I had pybind11 2.8 instead of 2.6.
I switched to pybind11 2.6.2 and suddenly a new pywrap warning appeared (or I missed it yesterday):

[W 211129 22:13:46 translation_unit:47] ./opencascade/RWGltf_GltfOStreamWriter.hxx
[W 211129 22:13:46 translation_unit:48] dummy.cxx:7:10: fatal error: 'rapidjson/rapidjson.h' file not found

I installed rapidjson via mamba and added the mamba env include path.

Now both pywrap and cmake are successful and the OCP package works.

The final build steps were:

brew install cmake ninja

# Install Mambaforge https://github.com/conda-forge/miniforge
# https://github.com/conda-forge/miniforge/releases/latest/download/Mambaforge-MacOSX-x86_64.sh

mamba create -n cq python=3.8
mamba activate cq
mamba install pybind11=2.6 occt=7.5.2 pandas rapidjson

git clone https://github.com/CadQuery/OCP.git
cd OCP/

git submodule update --init
cd pywrap/
pip install .
cd ..

PREFIX=/Library/Developer/CommandLineTools

SDK=SDKs/MacOSX12.sdk

C_INC=$PREFIX/$SDK/usr/include/
CPP_INC=$PREFIX/$SDK/usr/include/c++/v1/
GL_INC=$PREFIX/$SDK/System/Library/Frameworks/OpenGL.framework/Versions/A/Headers/
VTK_INC=$CONDA_PREFIX/include/vtk-9.0/
MAMBA_INC=$CONDA_PREFIX/include

LIBCLANG=$PREFIX/usr/lib/libclang.dylib

mkdir -p include
rm -f ./include/OpenGL
ln -s $GL_INC ./include/OpenGL
pywrap -i $CPP_INC -i $C_INC -i ./include -i $VTK_INC -i $MAMBA_INC -l $LIBCLANG all ocp.toml

cmake -B build -S ./OCP -G Ninja -DCMAKE_BUILD_TYPE=Release -DPython3_FIND_STRATEGY=LOCATION -DPython3_ROOT_DIR=$CONDA_PREFIX
cmake --build build -j 8 -- -k 0

@adam-urbanczyk
Copy link
Member

Interesting, rapidjson should be a dep of OCCT. Didn't you have it in the original env?

@bernhard-42
Copy link
Author

Yes, maybe it was, I didn't pay too much attention when I (re-) installed ...

However, I don't think the pywrap error message around rapidjson appeared with pybind11 2.8.

Anyways, switching to pybind11 2.6 solved the problem for me. And it is the same version that you use for Linux.

@bernhard-42
Copy link
Author

Are you planning to build both libs for MacOS in the future?

And maybe for the intel library, would it be possible to switch to RELEASE (as I did above). The current DEBUG version has 1.3GB unpacked.

Finally, will you support the latest occt 7.6.0 soon or do you maybe prefer to wait for 7.6.1

@adam-urbanczyk
Copy link
Member

Pywrap parsing does not use pybind11 at all - sounds unlikely that the version has impact.

Which intel library? OCP on mac is built with DEBUG - need to fix that.

Yes, I'm working on 7.6.

@bernhard-42
Copy link
Author

Pywrap parsing does not use pybind11 at all - sounds unlikely that the version has impact.

OK, then I don't know why it suddenly worked. Anyways, it works :-)

Which intel library?

yes, I meant OCP on Mac.

Yes, I'm working on 7.6.

cool, thanks!

@bernhard-42
Copy link
Author

@adam-urbanczyk Don't want to open a separate thread now, just a question:

Would it be possible to build a Universal library for the Mac for 7.6.x (that works for ARM and Intel)?

A universal library looks like that:

$ file /usr/lib/zsh/5.8/zsh/termcap.so
/usr/lib/zsh/5.8/zsh/termcap.so: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit bundle x86_64] [arm64e:Mach-O 64-bit bundle arm64e]
/usr/lib/zsh/5.8/zsh/termcap.so (for architecture x86_64):	Mach-O 64-bit bundle x86_64
/usr/lib/zsh/5.8/zsh/termcap.so (for architecture arm64e):	Mach-O 64-bit bundle arm64e

I made a test and as soon as I add -arch arm64 -arch x86_64 to the linker step of an example, It creates the universal (fat) binary.

@bernhard-42
Copy link
Author

fyi: https://dev.opencascade.org/content/testing-occt-apple-m1-arm64

@bernhard-42
Copy link
Author

I am reopening the issue to further investigate into CadQuery and OCP on Apple M1.

I did not expect it to work, but thought to share the result of running CadQuery tests against an Apple M1. It actually does look promising to me, the only ugly thing is the segmentation fault.

I hope that helps you to get in idea about the state of CadQuery on Apple M1

Compiling OCP 7.6.0

  • Install Mambaforge https://github.com/conda-forge/miniforge

    wget https://github.com/conda-forge/miniforge/releases/latest/download/Mambaforge-MacOSX-x86_64.sh
    bash Mambaforge-MacOSX-x86_64.sh
  • Install cmakeand ninja

    brew install cmake ninja
  • Create conda environment (no idea why mamba doesn't find logzero)

    grep -v logzero env.yml > env_m1.yml
    echo "  - pip:" >> env_m1.yml
    echo "    - logzero" >> env_m1.yml
  • Get OCP

    git clone https://github.com/CadQuery/OCP.git
    cd OCP/
    
    git submodule update --init
    cd pywrap/
    pip install .
    cd ..
  • Set environment

    PREFIX=/Library/Developer/CommandLineTools
    
    SDK=SDKs/MacOSX12.sdk
    
    C_INC=$PREFIX/$SDK/usr/include/
    CPP_INC=$PREFIX/$SDK/usr/include/c++/v1/
    GL_INC=$PREFIX/$SDK/System/Library/Frameworks/OpenGL.framework/Versions/A/Headers/
    VTK_INC=$CONDA_PREFIX/include/vtk-9.1/
    MAMBA_INC=$CONDA_PREFIX/include
    
    LIBCLANG=$PREFIX/usr/lib/libclang.dylib
    
    mkdir -p include
    rm -f ./include/OpenGL
    ln -s $GL_INC ./include/OpenGL
  • Create bindings

    pywrap -i $CPP_INC -i $C_INC -i ./include -i $VTK_INC -i $MAMBA_INC -l $LIBCLANG all ocp.toml
  • Compile OCP

    cmake -B build -S ./OCP -G Ninja -DCMAKE_BUILD_TYPE=Release -DPython3_FIND_STRATEGY=LOCATION -DPython3_ROOT_DIR=$CONDA_PREFIX
    cmake --build build -j 8 -- -k 0
    
  • Result

    $ ls -lh build/OCP.cpython-39-darwin.so
    -rwxr-xr-x  1 bernhard  staff   271M Feb 18 18:24 build/OCP.cpython-39-darwin.so

Tests on the M1

Using the OCP.cpython-39-darwin.so file created above against Cadquery branch occt7.6:

Fatal errors:

The two methods BRepAdaptor_HCurve and BRepAdaptor_HCompCurve are not found, so I commented out all occurences in shapes.py (luckily not so many)

py_test delivers one fatal error

tests/test_cadquery.py::TestCadQuery::testBrepImportExport Fatal Python error: Segmentation fault

Current thread 0x00000001032d8580 (most recent call first):
  File "/Users/bernhard/Development/cadquery/cadquery/cadquery/occ_impl/shapes.py", line 467 in exportBrep
  File "/Users/bernhard/Development/cadquery/cadquery/tests/test_cadquery.py", line 5057 in testBrepImportExport

Non fatal errors

Running pytest -v -k 'not testBrepImportExport' then delivered the following errors:

tests/test_assembly.py::test_vtkjs_export FAILED                     [  1%]
tests/test_assembly.py::test_vrml_export FAILED                      [  1%]
tests/test_assembly.py::test_toJSON FAILED                           [  1%]
tests/test_assembly.py::test_save[wrl-args4] FAILED                  [  2%]
tests/test_assembly.py::test_save_vtkjs FAILED                       [  3%]
tests/test_cadquery.py::TestCadQuery::testLocationAt FAILED          [ 31%]
tests/test_examples.py::test_example[87] FAILED                      [ 78%]
tests/test_exporters.py::TestExporters::testAMF FAILED               [ 79%]
tests/test_exporters.py::TestExporters::testTJS FAILED               [ 80%]
tests/test_exporters.py::TestExporters::testVTP FAILED               [ 81%]
tests/test_jupyter.py::TestJupyter::test_repr_javascript FAILED      [ 83%]
tests/test_sketch.py::test_distribute FAILED                         [ 93%]

Details of pytest:

FAILED tests/test_assembly.py::test_vtkjs_export - TypeError: __init__(): incompatible constructor arguments. The following argument types are supported:
FAILED tests/test_assembly.py::test_vrml_export - TypeError: __init__(): incompatible constructor arguments. The following argument types are supported:
FAILED tests/test_assembly.py::test_toJSON - TypeError: __init__(): incompatible constructor arguments. The following argument types are supported:
FAILED tests/test_assembly.py::test_save[wrl-args4] - TypeError: __init__(): incompatible constructor arguments. The following argument types are supported:
FAILED tests/test_assembly.py::test_save_vtkjs - TypeError: __init__(): incompatible constructor arguments. The following argument types are supported:
FAILED tests/test_cadquery.py::TestCadQuery::testLocationAt - AttributeError: 'Edge' object has no attribute '_geomAdaptorH'
FAILED tests/test_examples.py::test_example[87] - assert AttributeError("'Wire' object has no attribute '_geomAdaptorH'") is None
FAILED tests/test_exporters.py::TestExporters::testAMF - AttributeError: 'OCP.Poly.Poly_Triangulation' object has no attribute 'Nodes'
FAILED tests/test_exporters.py::TestExporters::testTJS - AttributeError: 'OCP.Poly.Poly_Triangulation' object has no attribute 'Nodes'
FAILED tests/test_exporters.py::TestExporters::testVTP - TypeError: __init__(): incompatible constructor arguments. The following argument types are supported:
FAILED tests/test_jupyter.py::TestJupyter::test_repr_javascript - TypeError: __init__(): incompatible constructor arguments. The following argument types are supported:
FAILED tests/test_sketch.py::test_distribute - AttributeError: 'Edge' object has no attribute '_geomAdaptorH'

Three errors are a consequence of removing all occurences of BRepAdaptor_HCurve and BRepAdaptor_HCompCurve:

  • testLocationAt
  • test_example
  • test_distribute

That leaves

______________________________________________________________________________ test_vtkjs_export ______________________________________________________________________________

nested_assy = <cadquery.assembly.Assembly object at 0x1580124c0>

    def test_vtkjs_export(nested_assy):

>       exportVTKJS(nested_assy, "assy")

tests/test_assembly.py:204:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cadquery/occ_impl/exporters/assembly.py:103: in exportVTKJS
    renderWindow = _vtkRenderWindow(assy)
cadquery/occ_impl/exporters/assembly.py:90: in _vtkRenderWindow
    toVTK(assy, renderer)
cadquery/occ_impl/assembly.py:191: in toVTK
    data = Compound.makeCompound(assy.shapes).toVtkPolyData(tolerance)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <cadquery.occ_impl.shapes.Compound object at 0x158013610>, tolerance = 0.001, angularTolerance = 0.1, normals = True

    def toVtkPolyData(
        self, tolerance: float, angularTolerance: float = 0.1, normals: bool = True
    ) -> vtkPolyData:
        """
        Convert shape to vtkPolyData
        """

        vtk_shape = IVtkOCC_Shape(self.wrapped)
        shape_data = IVtkVTK_ShapeData()
>       shape_mesher = IVtkOCC_ShapeMesher(
            tolerance, angularTolerance, theNbUIsos=0, theNbVIsos=0
        )
E       TypeError: __init__(): incompatible constructor arguments. The following argument types are supported:
E           1. OCP.IVtkOCC.IVtkOCC_ShapeMesher()
E
E       Invoked with: 0.001, 0.1; kwargs: theNbUIsos=0, theNbVIsos=0

cadquery/occ_impl/shapes.py:1193: TypeError
______________________________________________________________________________ test_vrml_export _______________________________________________________________________________

simple_assy = <cadquery.assembly.Assembly object at 0x1463e6370>

    def test_vrml_export(simple_assy):

>       exportVRML(simple_assy, "assy.wrl")

tests/test_assembly.py:212:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cadquery/occ_impl/exporters/assembly.py:121: in exportVRML
    exporter.SetRenderWindow(_vtkRenderWindow(assy))
cadquery/occ_impl/exporters/assembly.py:90: in _vtkRenderWindow
    toVTK(assy, renderer)
cadquery/occ_impl/assembly.py:191: in toVTK
    data = Compound.makeCompound(assy.shapes).toVtkPolyData(tolerance)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <cadquery.occ_impl.shapes.Compound object at 0x1463e6b50>, tolerance = 0.001, angularTolerance = 0.1, normals = True

    def toVtkPolyData(
        self, tolerance: float, angularTolerance: float = 0.1, normals: bool = True
    ) -> vtkPolyData:
        """
        Convert shape to vtkPolyData
        """

        vtk_shape = IVtkOCC_Shape(self.wrapped)
        shape_data = IVtkVTK_ShapeData()
>       shape_mesher = IVtkOCC_ShapeMesher(
            tolerance, angularTolerance, theNbUIsos=0, theNbVIsos=0
        )
E       TypeError: __init__(): incompatible constructor arguments. The following argument types are supported:
E           1. OCP.IVtkOCC.IVtkOCC_ShapeMesher()
E
E       Invoked with: 0.001, 0.1; kwargs: theNbUIsos=0, theNbVIsos=0

cadquery/occ_impl/shapes.py:1193: TypeError
_________________________________________________________________________________ test_toJSON _________________________________________________________________________________

simple_assy = <cadquery.assembly.Assembly object at 0x145979b80>, nested_assy = <cadquery.assembly.Assembly object at 0x145a744f0>
empty_top_assy = <cadquery.assembly.Assembly object at 0x158012ac0>

    def test_toJSON(simple_assy, nested_assy, empty_top_assy):

>       r1 = toJSON(simple_assy)

tests/test_assembly.py:220:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cadquery/occ_impl/assembly.py:229: in toJSON
    data = toString(Compound.makeCompound(assy.shapes), tolerance)
cadquery/occ_impl/exporters/vtk.py:21: in toString
    writer.SetInputData(shape.toVtkPolyData(tolerance, angularTolerance))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <cadquery.occ_impl.shapes.Compound object at 0x1460d9250>, tolerance = 0.001, angularTolerance = 0.1, normals = True

    def toVtkPolyData(
        self, tolerance: float, angularTolerance: float = 0.1, normals: bool = True
    ) -> vtkPolyData:
        """
        Convert shape to vtkPolyData
        """

        vtk_shape = IVtkOCC_Shape(self.wrapped)
        shape_data = IVtkVTK_ShapeData()
>       shape_mesher = IVtkOCC_ShapeMesher(
            tolerance, angularTolerance, theNbUIsos=0, theNbVIsos=0
        )
E       TypeError: __init__(): incompatible constructor arguments. The following argument types are supported:
E           1. OCP.IVtkOCC.IVtkOCC_ShapeMesher()
E
E       Invoked with: 0.001, 0.1; kwargs: theNbUIsos=0, theNbVIsos=0

cadquery/occ_impl/shapes.py:1193: TypeError
____________________________________________________________________________ test_save[wrl-args4] _____________________________________________________________________________

extension = 'wrl', args = ('VRML',), nested_assy = <cadquery.assembly.Assembly object at 0x145e257c0>, nested_assy_sphere = <cadquery.assembly.Assembly object at 0x145940490>

    @pytest.mark.parametrize(
        "extension, args",
        [
            ("step", ()),
            ("xml", ()),
            ("stp", ("STEP",)),
            ("caf", ("XML",)),
            ("wrl", ("VRML",)),
        ],
    )
    def test_save(extension, args, nested_assy, nested_assy_sphere):

        filename = "nested." + extension
>       nested_assy.save(filename, *args)

tests/test_assembly.py:242:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cadquery/assembly.py:445: in save
    exportVRML(self, path)
cadquery/occ_impl/exporters/assembly.py:121: in exportVRML
    exporter.SetRenderWindow(_vtkRenderWindow(assy))
cadquery/occ_impl/exporters/assembly.py:90: in _vtkRenderWindow
    toVTK(assy, renderer)
cadquery/occ_impl/assembly.py:191: in toVTK
    data = Compound.makeCompound(assy.shapes).toVtkPolyData(tolerance)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <cadquery.occ_impl.shapes.Compound object at 0x142568250>, tolerance = 0.001, angularTolerance = 0.1, normals = True

    def toVtkPolyData(
        self, tolerance: float, angularTolerance: float = 0.1, normals: bool = True
    ) -> vtkPolyData:
        """
        Convert shape to vtkPolyData
        """

        vtk_shape = IVtkOCC_Shape(self.wrapped)
        shape_data = IVtkVTK_ShapeData()
>       shape_mesher = IVtkOCC_ShapeMesher(
            tolerance, angularTolerance, theNbUIsos=0, theNbVIsos=0
        )
E       TypeError: __init__(): incompatible constructor arguments. The following argument types are supported:
E           1. OCP.IVtkOCC.IVtkOCC_ShapeMesher()
E
E       Invoked with: 0.001, 0.1; kwargs: theNbUIsos=0, theNbVIsos=0

cadquery/occ_impl/shapes.py:1193: TypeError
_______________________________________________________________________________ test_save_vtkjs _______________________________________________________________________________

nested_assy = <cadquery.assembly.Assembly object at 0x158059a30>

    def test_save_vtkjs(nested_assy):

>       nested_assy.save("nested", "VTKJS")

tests/test_assembly.py:255:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cadquery/assembly.py:449: in save
    exportVTKJS(self, path)
cadquery/occ_impl/exporters/assembly.py:103: in exportVTKJS
    renderWindow = _vtkRenderWindow(assy)
cadquery/occ_impl/exporters/assembly.py:90: in _vtkRenderWindow
    toVTK(assy, renderer)
cadquery/occ_impl/assembly.py:191: in toVTK
    data = Compound.makeCompound(assy.shapes).toVtkPolyData(tolerance)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <cadquery.occ_impl.shapes.Compound object at 0x1580ce760>, tolerance = 0.001, angularTolerance = 0.1, normals = True

    def toVtkPolyData(
        self, tolerance: float, angularTolerance: float = 0.1, normals: bool = True
    ) -> vtkPolyData:
        """
        Convert shape to vtkPolyData
        """

        vtk_shape = IVtkOCC_Shape(self.wrapped)
        shape_data = IVtkVTK_ShapeData()
>       shape_mesher = IVtkOCC_ShapeMesher(
            tolerance, angularTolerance, theNbUIsos=0, theNbVIsos=0
        )
E       TypeError: __init__(): incompatible constructor arguments. The following argument types are supported:
E           1. OCP.IVtkOCC.IVtkOCC_ShapeMesher()
E
E       Invoked with: 0.001, 0.1; kwargs: theNbUIsos=0, theNbVIsos=0

cadquery/occ_impl/shapes.py:1193: TypeError
____________________________________________________________________________ TestExporters.testAMF ____________________________________________________________________________

self = <tests.test_exporters.TestExporters testMethod=testAMF>

    def testAMF(self):
>       self._exportBox(exporters.ExportTypes.AMF, ["<amf units", "</object>"])

tests/test_exporters.py:75:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_exporters.py:30: in _exportBox
    exporters.exportShape(
cadquery/utils.py:38: in wrapped
    return f(*args, **kwargs)
cadquery/occ_impl/exporters/__init__.py:172: in exportShape
    tess = tessellate(shape, angularTolerance)
cadquery/occ_impl/exporters/__init__.py:147: in tessellate
    return shape.tessellate(tolerance, angularTolerance)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <cadquery.occ_impl.shapes.Compound object at 0x1425f0220>, tolerance = 0.1, angularTolerance = 0.1

    def tessellate(
        self, tolerance: float, angularTolerance: float = 0.1
    ) -> Tuple[List[Vector], List[Tuple[int, int, int]]]:

        self.mesh(tolerance, angularTolerance)

        vertices: List[Vector] = []
        triangles: List[Tuple[int, int, int]] = []
        offset = 0

        for f in self.Faces():

            loc = TopLoc_Location()
            poly = BRep_Tool.Triangulation_s(f.wrapped, loc)
            Trsf = loc.Transformation()
            reverse = (
                True
                if f.wrapped.Orientation() == TopAbs_Orientation.TopAbs_REVERSED
                else False
            )

            # add vertices
            vertices += [
                Vector(v.X(), v.Y(), v.Z())
>               for v in (v.Transformed(Trsf) for v in poly.Nodes())
            ]
E           AttributeError: 'OCP.Poly.Poly_Triangulation' object has no attribute 'Nodes'

cadquery/occ_impl/shapes.py:1161: AttributeError
____________________________________________________________________________ TestExporters.testTJS ____________________________________________________________________________

self = <tests.test_exporters.TestExporters testMethod=testTJS>

    def testTJS(self):
>       self._exportBox(
            exporters.ExportTypes.TJS, ["vertices", "formatVersion", "faces"]
        )

tests/test_exporters.py:85:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_exporters.py:30: in _exportBox
    exporters.exportShape(
cadquery/utils.py:38: in wrapped
    return f(*args, **kwargs)
cadquery/occ_impl/exporters/__init__.py:156: in exportShape
    tess = tessellate(shape, angularTolerance)
cadquery/occ_impl/exporters/__init__.py:147: in tessellate
    return shape.tessellate(tolerance, angularTolerance)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <cadquery.occ_impl.shapes.Compound object at 0x1582ba310>, tolerance = 0.1, angularTolerance = 0.1

    def tessellate(
        self, tolerance: float, angularTolerance: float = 0.1
    ) -> Tuple[List[Vector], List[Tuple[int, int, int]]]:

        self.mesh(tolerance, angularTolerance)

        vertices: List[Vector] = []
        triangles: List[Tuple[int, int, int]] = []
        offset = 0

        for f in self.Faces():

            loc = TopLoc_Location()
            poly = BRep_Tool.Triangulation_s(f.wrapped, loc)
            Trsf = loc.Transformation()
            reverse = (
                True
                if f.wrapped.Orientation() == TopAbs_Orientation.TopAbs_REVERSED
                else False
            )

            # add vertices
            vertices += [
                Vector(v.X(), v.Y(), v.Z())
>               for v in (v.Transformed(Trsf) for v in poly.Nodes())
            ]
E           AttributeError: 'OCP.Poly.Poly_Triangulation' object has no attribute 'Nodes'

cadquery/occ_impl/shapes.py:1161: AttributeError
____________________________________________________________________________ TestExporters.testVTP ____________________________________________________________________________

self = <tests.test_exporters.TestExporters testMethod=testVTP>

    def testVTP(self):

>       exporters.export(self._box(), "out.vtp")

tests/test_exporters.py:105:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cadquery/occ_impl/exporters/__init__.py:113: in export
    exportVTP(shape, fname, tolerance, angularTolerance)
cadquery/occ_impl/exporters/vtk.py:11: in exportVTP
    writer.SetInputData(shape.toVtkPolyData(tolerance, angularTolerance))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <cadquery.occ_impl.shapes.Compound object at 0x1425897c0>, tolerance = 0.1, angularTolerance = 0.1, normals = True

    def toVtkPolyData(
        self, tolerance: float, angularTolerance: float = 0.1, normals: bool = True
    ) -> vtkPolyData:
        """
        Convert shape to vtkPolyData
        """

        vtk_shape = IVtkOCC_Shape(self.wrapped)
        shape_data = IVtkVTK_ShapeData()
>       shape_mesher = IVtkOCC_ShapeMesher(
            tolerance, angularTolerance, theNbUIsos=0, theNbVIsos=0
        )
E       TypeError: __init__(): incompatible constructor arguments. The following argument types are supported:
E           1. OCP.IVtkOCC.IVtkOCC_ShapeMesher()
E
E       Invoked with: 0.1, 0.1; kwargs: theNbUIsos=0, theNbVIsos=0

cadquery/occ_impl/shapes.py:1193: TypeError
______________________________________________________________________ TestJupyter.test_repr_javascript _______________________________________________________________________

self = <tests.test_jupyter.TestJupyter testMethod=test_repr_javascript>

    def test_repr_javascript(self):
        cube = cq.Workplane("XY").box(1, 1, 1)
        assy = cq.Assembly().add(cube)
        shape = cube.val()

        self.assertIsInstance(shape, cq.occ_impl.shapes.Solid)

        # Test no exception on rendering to js
>       js1 = shape._repr_javascript_()

tests/test_jupyter.py:16:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cadquery/occ_impl/shapes.py:1228: in _repr_javascript_
    return display(self)._repr_javascript_()
cadquery/occ_impl/jupyter_tools.py:167: in display
    shape=toString(shape),
cadquery/occ_impl/exporters/vtk.py:21: in toString
    writer.SetInputData(shape.toVtkPolyData(tolerance, angularTolerance))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <cadquery.occ_impl.shapes.Solid object at 0x1461b1460>, tolerance = 0.001, angularTolerance = 0.1, normals = True

    def toVtkPolyData(
        self, tolerance: float, angularTolerance: float = 0.1, normals: bool = True
    ) -> vtkPolyData:
        """
        Convert shape to vtkPolyData
        """

        vtk_shape = IVtkOCC_Shape(self.wrapped)
        shape_data = IVtkVTK_ShapeData()
>       shape_mesher = IVtkOCC_ShapeMesher(
            tolerance, angularTolerance, theNbUIsos=0, theNbVIsos=0
        )
E       TypeError: __init__(): incompatible constructor arguments. The following argument types are supported:
E           1. OCP.IVtkOCC.IVtkOCC_ShapeMesher()
E
E       Invoked with: 0.001, 0.1; kwargs: theNbUIsos=0, theNbVIsos=0

cadquery/occ_impl/shapes.py:1193: TypeError

@bernhard-42 bernhard-42 reopened this Feb 18, 2022
@adam-urbanczyk
Copy link
Member

CQ is on 7.5.3. No point in trying 7.6 yet.

@bernhard-42
Copy link
Author

Got it. I now ran pytest against OCP 7.5.3.

Again a segmentation fault for tests/test_cadquery.py::TestCadQuery::testBrepImportExport

Fatal Python error: Segmentation fault in occ_impl/shapes.py", line 467 in exportBrep:

    BRepTools.Write_s(self.wrapped, f)

The rest is working (fine with some warnings)

@adam-urbanczyk
Copy link
Member

conda-forge cross-compiles for osx-arm64 now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants