|
1 | 1 | ******************************************************************************** |
2 | 2 | Tutorial |
3 | 3 | ******************************************************************************** |
| 4 | + |
| 5 | +``compas_occ`` provides an easy to use interface to the Open Cascade 3D geometry kernel, |
| 6 | +built around the Python bindings provided in ``pythonocc-core``. |
| 7 | + |
| 8 | +:mod:`compas_occ.geometry` defines :class:`compas_occ.geometry.OCCNurbsCurve` |
| 9 | +and :class:`compas_occ.geometry.OCCNurbsSurface`, which are wrappers around the |
| 10 | +``BSplineCurve`` and ``BSplineSurface`` objects of OCC, repsectively. |
| 11 | +The :mod:`compas_occ` wrappers provide an API for working with NURBS curves and surfaces |
| 12 | +similar to the API of RhinoCommon. |
| 13 | + |
| 14 | +:mod:`compas_occ.brep` is a package for working with Boundary Representation objects |
| 15 | +with the NURBS curves and surfaces of :mod:`compas_occ.geometry` as underlying geometry. |
| 16 | + |
| 17 | + |
| 18 | +Curves |
| 19 | +====== |
| 20 | + |
| 21 | +.. currentmodule:: compas_occ.geometry |
| 22 | + |
| 23 | +The simplest way to construct a curve is from its control points. |
| 24 | + |
| 25 | +.. code-block:: python |
| 26 | +
|
| 27 | + from compas.geometry import Point |
| 28 | + from compas_occ.geometry import OCCNurbsCurve as NurbsCurve |
| 29 | +
|
| 30 | + points = [Point(0, 0, 0), Point(3, 3, 0), Point(6, -3, 3), Point(9, 0, 0)] |
| 31 | + curve = NurbsCurve.from_points(points) |
| 32 | +
|
| 33 | +Other construction methods are |
| 34 | + |
| 35 | +* :meth:`OCCNurbsCurve.from_parameters` |
| 36 | +* :meth:`OCCNurbsCurve.from_interpolation` |
| 37 | +* :meth:`OCCNurbsCurve.from_step` |
| 38 | +* :meth:`OCCNurbsCurve.from_line` |
| 39 | +* :meth:`OCCNurbsCurve.from_arc` |
| 40 | +* :meth:`OCCNurbsCurve.from_circle` |
| 41 | +* :meth:`OCCNurbsCurve.from_ellipse` |
| 42 | + |
| 43 | +Since :class:`OCCNurbsCurve` implements the COMPAS data framework, |
| 44 | +there are also the following special methods (see :ref:`Data` for more information). |
| 45 | + |
| 46 | +* :meth:`OCCNurbsCurve.from_data` |
| 47 | +* :meth:`OCCNurbsCurve.from_json` |
| 48 | + |
| 49 | +Curves are currently not directly supported by :mod:`compas_view2`. |
| 50 | +However, they can be easily visualised by using a high-resolution polyline instead. |
| 51 | + |
| 52 | +.. code-block:: python |
| 53 | +
|
| 54 | + from compas.geometry import Point, Polyline |
| 55 | + from compas_occ.geometry import OCCNurbsCurve as NurbsCurve |
| 56 | + from compas_view2.app import App |
| 57 | +
|
| 58 | + points = [Point(0, 0, 0), Point(3, 3, 0), Point(6, -3, 3), Point(9, 0, 0)] |
| 59 | + curve = NurbsCurve.from_points(points) |
| 60 | +
|
| 61 | + viewer = App() |
| 62 | +
|
| 63 | + viewer.add(Polyline(curve.locus()), linewidth=3) |
| 64 | + viewer.add(Polyline(curve.points), show_points=True) |
| 65 | +
|
| 66 | + viewer.show() |
| 67 | +
|
| 68 | +
|
| 69 | +Surfaces |
| 70 | +======== |
| 71 | + |
| 72 | +*...coming soon...* |
| 73 | + |
| 74 | + |
| 75 | +Data |
| 76 | +==== |
| 77 | + |
| 78 | +*...coming soon...* |
| 79 | + |
| 80 | + |
| 81 | +Rhino |
| 82 | +===== |
| 83 | + |
| 84 | +*...coming soon...* |
| 85 | + |
| 86 | + |
| 87 | +Blender |
| 88 | +======= |
| 89 | + |
| 90 | +*...coming soon...* |
0 commit comments