compas_occ.conversions
¤
Functions¤
aabb_to_compas
¤
aabb_to_compas(aabb: Bnd_Box) -> Box
Convert an OCC oriented bounding box to a COMPAS box.
array1_from_floats1
¤
Construct a one-dimensional float array from a list of floats.
See Also
Examples:
array1_from_integers1
¤
Construct a one-dimensional integer array from a list of integers.
See Also
Examples:
array1_from_points1
¤
array2_from_floats2
¤
Construct a two-dimensional real array from a list of lists of floats.
See Also
Examples:
array2_from_points2
¤
Construct a two-dimensional point array from a list of lists of points.
Examples:
>>> from itertools import product
>>> from compas.geometry import Point
>>> from compas_occ.conversions import array2_from_points2
>>> points2 = [
... [Point(0, 0, 0), Point(1, 0, 0), Point(2, 0, 0)],
... [Point(0, 1, 0), Point(1, 1, 0), Point(2, 1, 0)],
... ]
>>> array2 = array2_from_points2(points2)
>>> array2
<OCC.Core.TColgp.TColgp_Array2OfPnt; ... >
>>> rows = range(array2.LowerRow(), array2.UpperRow() + 1)
>>> cols = range(array2.LowerCol(), array2.UpperCol() + 1)
>>> for i, j in product(rows, cols):
... value = array2.Value(i, j)
... x = value.X()
... y = value.Y()
... z = value.Z()
... print(x, y, z)
0.0 0.0 0.0
0.0 1.0 0.0
1.0 0.0 0.0
1.0 1.0 0.0
2.0 0.0 0.0
2.0 1.0 0.0
ax22d_to_compas
¤
Construct a COMPAS frame from a 2D OCC position.
See Also
Examples:
>>> from OCC.Core.gp import gp_Pnt2d, gp_Dir2d, gp_Ax22d
>>> from compas_occ.conversions import ax22d_to_compas
>>> ax2 = gp_Ax22d(gp_Pnt2d(0, 0), gp_Dir2d(0, 1), gp_Dir2d(1, 0))
>>> ax22d_to_compas(ax2)
Frame(point=Point(x=0.0, y=0.0, z=0.0), xaxis=Vector(x=0.0, y=1.0, z=0.0), yaxis=Vector(x=1.0, y=0.0, z=0.0))
ax2_to_compas
¤
Construct a COMPAS frame from an OCC position.
See Also
Examples:
>>> from OCC.Core.gp import gp_Pnt, gp_Dir, gp_Ax2
>>> from compas_occ.conversions import ax2_to_compas
>>> ax2 = gp_Ax2(gp_Pnt(0, 0, 0), gp_Dir(0, 0, 1), gp_Dir(1, 0, 0))
>>> ax2_to_compas(ax2)
Frame(point=Point(x=0.0, y=0.0, z=0.0), xaxis=Vector(x=1.0, y=0.0, z=0.0), yaxis=Vector(x=0.0, y=1.0, z=0.0))
ax3_to_compas
¤
Construct a COMPAS frame from an OCC position.
See Also
Examples:
>>> from OCC.Core.gp import gp_Pnt, gp_Dir, gp_Ax3
>>> from compas_occ.conversions import ax3_to_compas
>>> ax3 = gp_Ax3(gp_Pnt(0, 0, 0), gp_Dir(0, 0, 1), gp_Dir(1, 0, 0))
>>> ax3_to_compas(ax3)
Frame(point=Point(x=0.0, y=0.0, z=0.0), xaxis=Vector(x=1.0, y=0.0, z=0.0), yaxis=Vector(x=0.0, y=1.0, z=0.0))
axis2d_to_compas
¤
Convert a 2D OCC axis to a tuple of COMPAS point and vector.
See Also
Examples:
axis2d_to_compas_vector
¤
Convert a 2D OCC axis to a COMPAS vector.
Examples:
axis_to_compas
¤
Convert an OCC axis to a tuple of COMPAS point and vector.
See Also
Examples:
axis_to_compas_vector
¤
Convert an OCC axis to a COMPAS vector.
Examples:
axis_to_occ
¤
Convert a COMPAS point and vector to an OCC axis.
See Also
Examples:
bezier_to_compas
¤
bezier_to_compas(bezier: Geom_BezierCurve) -> Bezier
Construct a COMPAS Bezier curve from an OCC Bezier curve.
Examples:
>>> from OCC.Core.gp import gp_Pnt, gp_Dir, gp_Ax2, gp_Parab
>>> from compas_occ.conversions import bezier_to_compas
>>> from OCC.Core.Geom import Geom_BezierCurve
>>> from OCC.Core.TColgp import TColgp_Array1OfPnt
>>> from OCC.Core.gp import gp_Pnt
>>> array = TColgp_Array1OfPnt(1, 4)
>>> array.SetValue(1, gp_Pnt(0, 0, 0))
>>> array.SetValue(2, gp_Pnt(1, 0, 0))
>>> array.SetValue(3, gp_Pnt(1, 1, 0))
>>> array.SetValue(4, gp_Pnt(0, 1, 0))
>>> bezier = Geom_BezierCurve(array)
>>> bezier_to_compas(bezier)
Bezier(points=[...])
bspline_to_compas
¤
bspline_to_compas(bspline: Geom_BSplineCurve) -> NurbsCurve
Construct a COMPAS NURBS curve from an OCC B-spline curve.
circle2d_to_compas
¤
Construct a COMPAS circle from a 2D OCC circle.
See Also
Examples:
circle_to_compas
¤
Construct a COMPAS circle from an OCC circle.
See Also
Examples:
circle_to_occ
¤
circle_to_occ(circle: Circle) -> gp_Circ
Construct an OCC circle from a COMPAS circle.
See Also
Examples:
circle_to_occ2d
¤
circle_to_occ2d(circle: Circle) -> gp_Circ2d
Convert a COMPAS circle to a 2D OCC circle.
See Also
Examples:
compas_mesh_to_occ_shell
¤
compas_mesh_to_occ_shell(mesh: Mesh) -> TopoDS_Shell
Convert a general COMPAS mesh to an OCC shell.
compas_quadmesh_to_occ_shell
¤
compas_quadmesh_to_occ_shell(mesh: Mesh) -> TopoDS_Shell
Convert a COMPAS quad mesh to an OCC shell.
Raises:
-
ValueError–If the input mesh is not a quad mesh.
compas_transformation_to_trsf
¤
compas_transformation_to_trsf(matrix: Transformation) -> gp_Trsf
Convert a COMPAS transformation to a OCC transformation.
Parameters:
-
matrix(Transformation) –A COMPAS transformation.
Returns:
-
gp_Trsf–An OCC transformation.
Examples:
compas_trimesh_to_occ_shell
¤
compas_trimesh_to_occ_shell(mesh: Mesh) -> TopoDS_Shell
Convert a COMPAS triangle mesh to an OCC shell.
Raises:
-
ValueError–If the mesh is not a triangle mesh.
cone_to_occ
¤
cone_to_occ(cone: Cone) -> gp_Cone
Convert a COMPAS cone to an OCC cone.
See Also
Examples:
cylinder_to_compas
¤
Convert an OCC cylinder to a COMPAS cylinder.
See Also
- [
compas_sphere_from_occ_sphere][]
Examples:
>>> from OCC.Core.gp import gp_Pnt, gp_Dir, gp_Ax3, gp_Cylinder
>>> from compas_occ.conversions import cylinder_to_compas
>>> ax3 = gp_Ax3(gp_Pnt(0, 0, 0), gp_Dir(0, 0, 1), gp_Dir(1, 0, 0))
>>> cylinder = gp_Cylinder(ax3, 1)
>>> cylinder_to_compas(cylinder)
Cylinder(radius=1.0, height=1.0, frame=Frame(...))
cylinder_to_occ
¤
cylinder_to_occ(cylinder: Cylinder) -> gp_Cylinder
Convert a COMPAS cylinder to an OCC cylinder.
See Also
Examples:
direction2d_to_compas
¤
Construct a COMPAS vector from a 2D OCC direction.
Examples:
direction_to_compas
¤
Construct a COMPAS vector from an OCC direction.
Examples:
direction_to_occ
¤
direction_to_occ(vector: Vector) -> gp_Dir
Convert a COMPAS vector to an OCC direction.
See Also
Examples:
direction_to_occ2d
¤
direction_to_occ2d(vector: Vector) -> gp_Dir2d
Convert a COMPAS vector to a 2D OCC direction.
See Also
Examples:
ellipse2d_to_compas
¤
Construc a COMPAS ellipse from a 2D OCC ellipse.
See Also
Examples:
>>> from OCC.Core.gp import gp_Pnt2d, gp_Dir2d, gp_Ax22d, gp_Elips2d
>>> from compas_occ.conversions import ellipse_to_compas
>>> ax2 = gp_Ax22d(gp_Pnt2d(0, 0), gp_Dir2d(0, 1), gp_Dir2d(1, 0))
>>> elips = gp_Elips2d(ax2, 1, 0.5)
>>> ellipse2d_to_compas(elips)
Ellipse(major=1.0, minor=0.5, frame=Frame(...))
ellipse_to_compas
¤
Construc a COMPAS ellipse from an OCC ellipse.
See Also
Examples:
ellipse_to_occ
¤
ellipse_to_occ(ellipse: Ellipse) -> gp_Elips
Construct an OCC ellipse from a COMPAS ellipse.
See Also
Examples:
ellipse_to_occ2d
¤
ellipse_to_occ2d(ellipse: Ellipse) -> gp_Elips2d
Convert a COMPAS ellipse to a 2D OCC ellipse.
See Also
Examples:
floats2_from_array2
¤
Construct a list of lists of floats from a two-dimensional array of real numbers.
See Also
Examples:
frame_to_occ_ax2
¤
frame_to_occ_ax2(frame: Frame) -> gp_Ax2
Convert a COMPAS frame to a right-handed OCC coordinate system.
See Also
Examples:
frame_to_occ_ax3
¤
frame_to_occ_ax3(frame: Frame) -> gp_Ax3
Convert a COMPAS frame to a right-handed OCC coordinate system.
See Also
Examples:
harray1_from_points1
¤
hyperbola2d_to_compas
¤
hyperbola2d_to_compas(hypr: gp_Hypr2d) -> Hyperbola
Construct a COMPAS hyperbola from a 2D OCC hyperbola.
Examples:
>>> from OCC.Core.gp import gp_Pnt2d, gp_Dir2d, gp_Ax22d, gp_Hypr2d
>>> from compas_occ.conversions import hyperbola_to_compas
>>> ax2 = gp_Ax22d(gp_Pnt2d(0, 0), gp_Dir2d(0, 1), gp_Dir2d(1, 0))
>>> hypr = gp_Hypr2d(ax2, 1, 0.5)
>>> hyperbola2d_to_compas(hypr)
Hyperbola(major=1.0, minor=0.5, frame=Frame(...))
hyperbola_to_compas
¤
hyperbola_to_compas(hypr: gp_Hypr) -> Hyperbola
Construct a COMPAS hyperbola from an OCC hyperbola.
Examples:
line2d_to_compas
¤
Convert a 2D OCC line to a COMPAS line.
See Also
Examples:
line_to_compas
¤
Convert an OCC line to a COMPAS line.
See Also
Examples:
line_to_occ
¤
line_to_occ(line: Line) -> gp_Lin
Convert a COMPAS line to an OCC line.
See Also
Examples:
location_to_compas
¤
location_to_compas(location: TopLoc_Location) -> Frame
Construct a COMPAS frame from an OCC location.
Examples:
ngon_to_face
¤
Convert a Ngon to a BRep face with an underlying best-fit surface.
See Also
obb_to_compas
¤
obb_to_compas(obb: Bnd_OBB) -> Box
Convert an OCC oriented bounding box to a COMPAS box.
parabola2d_to_compas
¤
parabola2d_to_compas(parab: gp_Parab2d) -> Parabola
Construct a COMPAS parabola from a 2D OCC parabola.
Examples:
parabola_to_compas
¤
parabola_to_compas(parab: gp_Parab) -> Parabola
Construct a COMPAS parabola from an OCC parabola.
Examples:
plane_to_compas
¤
Convert an OCC plane to a COMPAS plane.
See Also
Examples:
plane_to_occ
¤
plane_to_occ(plane: Plane) -> gp_Pln
Convert a COMPAS plane to an OCC plane.
See Also
Examples:
plane_to_occ_ax2
¤
plane_to_occ_ax2(plane: Plane) -> gp_Ax2
Convert a COMPAS plane to a right-handed OCC coordinate system.
See Also
Examples:
plane_to_occ_ax3
¤
plane_to_occ_ax3(plane: Plane) -> gp_Ax3
Convert a COMPAS plane to a right-handed OCC coordinate system.
See Also
Examples:
point2d_to_compas
¤
Construct a COMPAS point from an OCC 2D point.
See Also
Examples:
point_to_compas
¤
Construct a COMPAS point from an OCC point.
See Also
Examples:
points1_from_array1
¤
Construct a list of points from a one-dimensional point array.
Examples:
>>> from compas_occ.conversions import points1_from_array1
>>> from OCC.Core.TColgp import TColgp_Array1OfPnt
>>> from OCC.Core.gp import gp_Pnt
points2_from_array2
¤
Construct a list of lists of points from two-dimensional point array.
Examples:
>>> from itertools import product
>>> from OCC.Core.TColgp import TColgp_Array2OfPnt
>>> from OCC.Core.gp import gp_Pnt
>>> array2 = TColgp_Array2OfPnt(1, 2, 1, 3)
>>> array2.SetValue(1, 1, gp_Pnt(0, 0, 0))
>>> array2.SetValue(1, 2, gp_Pnt(1, 0, 0))
>>> array2.SetValue(1, 3, gp_Pnt(2, 0, 0))
>>> array2.SetValue(2, 1, gp_Pnt(0, 1, 0))
>>> array2.SetValue(2, 2, gp_Pnt(1, 1, 0))
>>> array2.SetValue(2, 3, gp_Pnt(2, 1, 0))
>>> points2 = points2_from_array2(array2)
>>> rows = len(points2)
>>> cols = len(points2[0])
>>> for i, j in product(range(rows), range(cols)):
... print(points2[i][j])
Point(x=0.0, y=0.0, z=0.0)
Point(x=0.0, y=1.0, z=0.0)
Point(x=1.0, y=0.0, z=0.0)
Point(x=1.0, y=1.0, z=0.0)
Point(x=2.0, y=0.0, z=0.0)
Point(x=2.0, y=1.0, z=0.0)
quad_to_face
¤
Convert a quad to a BRep face with an underlying ruled surface.
Raises:
-
ValueError–If the number of points is not 4.
See Also
Examples:
sphere_to_compas
¤
Convert an OCC sphere to a COMPAS sphere.
See Also
Examples:
sphere_to_occ
¤
sphere_to_occ(sphere: Sphere) -> gp_Sphere
Convert a COMPAS sphere to an OCC sphere.
See Also
Examples:
torus_to_occ
¤
torus_to_occ(torus: Torus) -> gp_Torus
Convert a COMPAS torus to an OCC torus.
See Also
Examples:
triangle_to_face
¤
Convert a triangle to a BRep face.
Raises:
-
ValueError–If the number of points is not 3.
See Also
Examples:
vector2d_to_compas
¤
Construct a COMPAS vector from an OCC 2D vector.
Examples:
vector_to_compas
¤
Construct a COMPAS vector from an OCC vector.
Examples:
vector_to_occ
¤
vector_to_occ(vector: Vector) -> gp_Vec
Convert a COMPAS vector to an OCC vector.
See Also
Examples: