Geometry

The afem.geometry package provides entities and tools for the creation and use of what is commonly referred to as “construction geometry” or “reference geometry” for both 2-D and 3-D domains. This package primarily wraps a number of OpenCASCADE native types and tools in order to provide a more “Pythonic” user interface. The entities and tools in the geometry package do not cover every OpenCASCADE type, but rather those frequently encountered during regular use. The entities and tools can be imported by:

from afem.geometry import *

Geometry entities cover general types like points, curves, planes, and surfaces. Tools exists for the creation, modification, intersection, and projection of the geometric entities. The simple example below demonstrates some of the key entities and tools of the geometry package:

from afem.geometry import *
from afem.graphics import Viewer

gui = Viewer()

# Create a point directly from the entity. Default is (0, 0, 0).
p1 = Point()

# Create a point by array-like
p2 = PointByArray([5, 0, 5]).point

# Create a point by x-, y-, and z-coordinates.
p3 = PointByXYZ(10, 0, 0).point

# Interpolate the points with a curve
c1 = NurbsCurveByInterp([p1, p2, p3]).curve

gui.add(p1, p2, p3, c1)
gui.start()

# Copy curve and translate
c2 = c1.copy()
c2.translate((0, 10, 0))

gui.add(c2)
gui.start()

# Copy and translate again
c3 = c2.copy()
c3.translate((0, 10, 10))

gui.add(c3)
gui.start()

# Approximate a surface
s1 = NurbsSurfaceByApprox([c1, c2, c3]).surface

gui.add(s1)
gui.start()

# Extract an iso-curve
c4 = s1.u_iso(10.)

gui.add(c4)
gui.start()

# Create points along the curve
pnts = PointsAlongCurveByDistance(c4, 1.).points

gui.add(*pnts)
gui.start()

# Extract iso-curve
c5 = s1.v_iso(0.5)

gui.add(c5)
gui.start()

# Intersect two curves
cci = IntersectCurveCurve(c4, c5)

gui.clear()
gui.add(c4, c5, s1, *cci.points)
gui.start()

# Define a plane along a curve
pln = PlaneFromParameter(c4, 0., 2.).plane

# Intersect a surface and a plane
ssi = IntersectSurfaceSurface(s1, pln)

gui.add(s1, *ssi.curves)
gui.start()

# Project a point to a surface
p4 = pln.eval(5, 5)
proj = ProjectPointToSurface(p4, s1)
line = NurbsCurveByInterp([p4, proj.nearest_point]).curve

gui.add(p4, proj.nearest_point, line)
gui.start()

The entities, tool, and viewing tool are imported by:

from afem.geometry import *
from afem.graphics import Viewer

The first variable created is a Point and is constructed directly from the entity itself. Since the Point class is derived from the OpenCASCADE type OCCT.gp.gp_Pnt, one of the available constructor methods is using three floats to define an x-, y-, and z-coordinate. By default the location is (0., 0., 0.):

p1 = Point()

Points can also be created using a variety of tools including by an array or specified x-, y-, and z-coordinates. When tools are used the underlying entity must be retrieved from the tool by:

p2 = PointByArray([5, 0, 5]).point
p3 = PointByXYZ(10, 0, 0).point

A cubic curve can be created by interpolating points by:

c1 = NurbsCurveByInterp([p1, p2, p3]).curve

Most geometry types can be copied and a limited number of transformations can be directly applied to the entity depending on its type:

c2 = c1.copy()
c2.translate((0, 10, 0))

Here, a new NurbsCurve was created and then translated in the y-direction by 10 units. This new curve is then copied again and translated in both the y- and z-directions by 10 units each:

c3 = c2.copy()
c3.translate((0, 10, 10))

These three curves are then used to approximate a NurbsSurface:

s1 = NurbsSurfaceByApprox([c1, c2, c3]).surface

Isoparametric curves (i.e., isocurve) can be extracted from surfaces in both the u- and v-directions. Below, an isocurve is extract at a constant u=10:

c4 = s1.u_iso(10.)

This isocurve is used to generate evenly spaced points using a target distance of 1 unit:

pnts = PointsAlongCurveByDistance(c4, 1.).points

The PointsAlongCurveByDistance tool can also return the number of points created, the parameters on the curve for each point, the final spacing, and the interior points (i.e., exclude first and last). Others tools exist for creating points (and planes) along curves by a specified number rather than distance.

At this point the created geometry should look similar to the image below.

_images/geometry_basic1.png

Another isocurve in the opposite direction is created and the intersection is found by:

c5 = s1.v_iso(0.5)
cci = IntersectCurveCurve(c4, c5)

The IntersectCurveCurve tool provides intersection results including the point(s), parameter(s) on each curve, and number of intersections. Other tools exist for curve/surface and surface/surface intersections. Intersecting a plane and a surface is shown by:

pln = PlaneFromParameter(c4, 0., 2.).plane
ssi = IntersectSurfaceSurface(s1, pln)

A Plane is first created using the PlaneFromParameter tool and then used in the IntersectSurfaceSurface tool. The resulting intersection curves are approximated in 3-D space.

Projections to curves and surfaces are available using the projection tools. By default, projections are usually performed normal to the curve or surface, but some tools always projections along a specified direction. This operation actually becomes a curve intersection operation rather than a normal projection. The code below creates a point on a plane and then performs a normal projection to the surface:

p4 = pln.eval(5, 5)
proj = ProjectPointToSurface(p4, s1)
line = NurbsCurveByInterp([p4, proj.nearest_point]).curve

The line variable is created mostly for visualization purposes and to demonstrate some of the data that can be retrieved from the ProjectPointToSurface tool. All point projection results are stored in the tool and sorted by minimum to maximum distance.

The intersection and projection results should look similar to the image below. Note that there are no renderings for infinite planes.

_images/geometry_basic2.png

Entities

Geometry2D

class afem.geometry.entities.Geometry2D(obj)

Base class for 2-D geometry.

Parameters

obj (OCCT.Geom2d.Geom2d_Geometry) – The geometry object.

Raises

TypeError – If the wrapped type of obj does not match the expected type.

Point2D

class afem.geometry.entities.Point2D(*args)

A 2-D Cartesian point derived from gp_Pnt2d.

Direction2D

class afem.geometry.entities.Direction2D(*args)

Unit vector in 2-D space derived from gp_Dir2d.

Vector2D

class afem.geometry.entities.Vector2D(*args)

Vector in 2-D space derived from gp_Vec2d.

Curve2D

class afem.geometry.entities.Curve2D(obj)

Base class for 2-D curves around Geom2d_Curve.

NurbsCurve2D

class afem.geometry.entities.NurbsCurve2D(obj)

NURBS curve in 2-D space around Geom2d_BSplineCurve.

Geometry

class afem.geometry.entities.Geometry(obj)

Base class for geometry.

Parameters

obj – The geometry object.

Variables
  • C0 (OCCT.GeomAbs.GeomAbs_Shape.GeomAbs_C0) – Only geometric continuity.

  • C1 (OCCT.GeomAbs.GeomAbs_Shape.GeomAbs_C1) – Continuity of the first derivative.

  • C2 (OCCT.GeomAbs.GeomAbs_Shape.GeomAbs_C2) – Continuity of the second derivative.

  • C3 (OCCT.GeomAbs.GeomAbs_Shape.GeomAbs_C3) – Continuity of the third derivative.

  • CN (OCCT.GeomAbs.GeomAbs_Shape.GeomAbs_CN) – Continuity of the n-th derivative.

  • G1 (OCCT.GeomAbs.GeomAbs_Shape.GeomAbs_G1) – Tangent vectors on either side of a point on a curve are collinear with the same orientation.

  • G2 (OCCT.GeomAbs.GeomAbs_Shape.GeomAbs_G2) – Normalized vectors on either side of a point on a curve are equal.

  • ARC (OCCT.GeomAbs.GeomAbs_JoinType.GeomAbs_Arc) – Arc join type.

  • TANGENT (OCCT.GeomAbs.GeomAbs_JoinType.GeomAbs_Tangent) – Tangent join type.

  • INTERSECT (OCCT.GeomAbs.GeomAbs_JoinType.GeomAbs_Intersection) – Intersection join type.

Raises

TypeError – If the wrapped type of obj does not match the expected type.

Point

class afem.geometry.entities.Point(*args)

A 3-D Cartesian point derived from gp_Pnt.

Direction

class afem.geometry.entities.Direction(*args)

Unit vector in 3-D space derived from gp_Dir.

Vector

class afem.geometry.entities.Vector(*args)

Vector in 3-D space derived from gp_Vec.

Axis1

class afem.geometry.entities.Axis1(*args)

Axis in 3-D space derived from gp_Ax1.

Axis3

class afem.geometry.entities.Axis3(*args)

Coordinate system in 3-D space derived from gp_Ax3.

Curve

class afem.geometry.entities.Curve(obj)

Base class for curves around Geom_Curve.

Variables
  • LINE (OCCT.GeomAbs.GeomAbs_CurveType.GeomAbs_Line) – Line type.

  • CIRCLE (OCCT.GeomAbs.GeomAbs_CurveType.GeomAbs_Circle) – Circle type.

  • ELLIPSE (OCCT.GeomAbs.GeomAbs_CurveType.GeomAbs_Ellipse) – Ellipse type.

  • HYPERBOLA (OCCT.GeomAbs.GeomAbs_CurveType.GeomAbs_Hyperbola) – Hyperbola type.

  • PARABOLA (OCCT.GeomAbs.GeomAbs_CurveType.GeomAbs_Parabola) – Parabola type.

  • BEZIER (OCCT.GeomAbs.GeomAbs_CurveType.GeomAbs_BezierCurve) – Bezier curve type.

  • BSPLINE (OCCT.GeomAbs.GeomAbs_CurveType.GeomAbs_BSplineCurve) – BSpline curve type.

  • OFFSET (OCCT.GeomAbs.GeomAbs_CurveType.GeomAbs_OffsetCurve) – Offset curve type.

  • OTHER (OCCT.GeomAbs.GeomAbs_CurveType.GeomAbs_OtherCurve) – Other curve type.

Line

class afem.geometry.entities.Line(obj)

Infinite line around Geom_Line.

Circle

class afem.geometry.entities.Circle(obj)

Circular curve around Geom_Circle.

Ellipse

class afem.geometry.entities.Ellipse(obj)

Elliptical curve around Geom_Ellipse.

NurbsCurve

class afem.geometry.entities.NurbsCurve(obj)

NURBS curve around Geom_BSplineCurve.

TrimmedCurve

class afem.geometry.entities.TrimmedCurve(obj)

Trimmed curve around Geom_TrimmedCurve. This defines a basis curve limited by two parameter values.

Surface

class afem.geometry.entities.Surface(obj)

Base class for surfaces around Geom_Surface.

Variables
  • PLANE (OCCT.GeomAbs.GeomAbs_SurfaceType.GeomAbs_Plane) – Plane type.

  • CYLINDER (OCCT.GeomAbs.GeomAbs_SurfaceType.GeomAbs_Cylinder) – Cylinder type.

  • CONE (OCCT.GeomAbs.GeomAbs_SurfaceType.GeomAbs_Cone) – Cone type.

  • SPHERE (OCCT.GeomAbs.GeomAbs_SurfaceType.GeomAbs_Sphere) – Sphere type.

  • TORUS (OCCT.GeomAbs.GeomAbs_SurfaceType.GeomAbs_Torus) – Torus type.

  • BEZIER (OCCT.GeomAbs.GeomAbs_SurfaceType.GeomAbs_BezierSurface) – Bezier type.

  • BSPLINE (OCCT.GeomAbs.GeomAbs_SurfaceType.GeomAbs_BSplineSurface) – BSpline type.

  • REVOLUTION (OCCT.GeomAbs.GeomAbs_SurfaceType.GeomAbs_SurfaceOfRevolution) – Revolution type.

  • EXTRUSION (OCCT.GeomAbs.GeomAbs_SurfaceType.GeomAbs_SurfaceOfExtrusion) – Extrusion type.

  • OFFSET (OCCT.GeomAbs.GeomAbs_SurfaceType.GeomAbs_OffsetSurface) – Offset type.

  • OTHER (OCCT.GeomAbs.GeomAbs_SurfaceType.GeomAbs_OtherSurface) – Other type.

Plane

class afem.geometry.entities.Plane(obj)

Infinite plane around Geom_Plane.

NurbsSurface

class afem.geometry.entities.NurbsSurface(obj)

NURBS surface around Geom_BSplineSurface.

Create

PointByXYZ

class afem.geometry.create.PointByXYZ(x=0.0, y=0.0, z=0.0)

Create a point by x, y, and z location.

Parameters
  • x (float) – x-location.

  • y (float) – y-location.

  • z (float) – z-location.

PointByArray

class afem.geometry.create.PointByArray(xyz=0.0, 0.0, 0.0)

Create a point from an array.

Parameters

xyz (array_like) – Array describing point location.

Raises

ValueError – If the length of the array is not equal to three.

PointFromParameter

class afem.geometry.create.PointFromParameter(c, u0, ds, tol=1e-07)

Create a point along a curve at a specified distance from a parameter.

Parameters

PointsAlongCurveByNumber

class afem.geometry.create.PointsAlongCurveByNumber(c, n, u1=None, u2=None, d1=None, d2=None, tol=1e-07)

Create a specified number of points along a curve. The points will be equidistant.

Parameters
  • c (afem.adaptor.entities.AdaptorCurve or afem.geometry.entities.Curve or afem.topology.entities.Edge or afem.topology.entities.Wire) – The curve.

  • n (int) – Number of points to create.

  • u1 (float) – The parameter of the first point (default=*c.u1*).

  • u2 (float) – The parameter of the last point (default=*c.u2*).

  • d1 (float) – An offset distance for the first point. This is typically a positive number indicating a distance from u1 towards u2.

  • d2 (float) – An offset distance for the last point. This is typically a negative number indicating a distance from u2 towards u1.

  • tol (float) – Tolerance.

Raises

RuntimeError – If GCPnts_UniformAbscissa fails.

PointsAlongCurveByDistance

class afem.geometry.create.PointsAlongCurveByDistance(c, maxd, u1=None, u2=None, d1=None, d2=None, nmin=0, tol=1e-07)

Create points along a curve by distance between points. The points will be equidistant. This method calculates the number of points given the curve length and then uses PointsAlongCurveByNumber.

Parameters
  • c (afem.adaptor.entities.AdaptorCurve or afem.geometry.entities.Curve or afem.topology.entities.Edge or afem.topology.entities.Wire) – The curve.

  • maxd (float) – The maximum allowed spacing between points. The actual spacing will be adjusted to not to exceed this value.

  • u1 (float) – The parameter of the first point (default=c.u1).

  • u2 (float) – The parameter of the last point (default=c.u2).

  • d1 (float) – An offset distance for the first point. This is typically a positive number indicating a distance from u1 towards u2.

  • d2 (float) – An offset distance for the last point. This is typically a negative number indicating a distance from u2 towards u1.

  • nmin (int) – Minimum number of points to create.

  • tol (float) – Tolerance.

Raises

RuntimeError – If OCC method fails.

DirectionByXYZ

class afem.geometry.create.DirectionByXYZ(x=1.0, y=0.0, z=0.0)

Create a direction (i.e., unit vector) by x-, y-, and z-components.

Parameters
  • x (float) – x-component.

  • y (float) – y-component.

  • z (float) – z-component.

DirectionByArray

class afem.geometry.create.DirectionByArray(xyz=1.0, 0.0, 0.0)

Create a direction (i.e., unit vector) from an array-like object.

Parameters

xyz (array_like) – Array-like object defining xyz-components.

Raises

ValueError – If len(xyz) != 3.

DirectionByPoints

class afem.geometry.create.DirectionByPoints(p1, p2)

Create a direction (i.e., unit vector) between two points.

Parameters
  • p1 (point_like) – The first point.

  • p2 (point_like) – The last point.

VectorByXYZ

class afem.geometry.create.VectorByXYZ(x=1.0, y=0.0, z=0.0)

Create a vector by x-, y-, and z-components.

Parameters
  • x (float) – x-component.

  • y (float) – y-component.

  • z (float) – z-component.

VectorByArray

class afem.geometry.create.VectorByArray(xyz=1.0, 0.0, 0.0)

Create a vector from an array-like object.

Parameters

xyz (array_like) – Array-like object defining xyz-components.

Raises

ValueError – If len(xyz) != 3.

VectorByPoints

class afem.geometry.create.VectorByPoints(p1, p2)

Create a vector between two points.

Parameters
  • p1 (point_like) – The first point.

  • p2 (point_like) – The last point.

Raises

TypeError – If p1 or p2 cannot be converted to a Point.

LineByVector

class afem.geometry.create.LineByVector(p, d)

Create a line by an origin and a vector.

Parameters
  • p (point_like) – Origin of line.

  • d (vector_like) – Direction of line.

Raises
  • TypeError – If p cannot be converted to a Point

  • TypeError – If d cannot be converted to a Direction

LineByPoints

class afem.geometry.create.LineByPoints(p1, p2)

Create a line through two points.

Parameters
  • p1 (point_like) – The first point.

  • p2 (point_like) – The last point.

Raises

TypeError – If p1 or p2 cannot be converted to a Point.

CircleByNormal

class afem.geometry.create.CircleByNormal(center, normal, radius)

Create a circle using a center, normal, and radius.

Parameters
  • center (point_like) – The center point.

  • normal (vector_like) – The normal of the plane.

  • radius (float) – The radius.

CircleByPlane

class afem.geometry.create.CircleByPlane(center, plane, radius)

Create a circle using a center, plane, and radius.

Parameters

CircleBy3Points

class afem.geometry.create.CircleBy3Points(p1, p2, p3)

Create a circle using three points.

Parameters
  • p1 (point_like) – The first point.

  • p2 (point_like) – The second point.

  • p3 (point_like) – The third point.

NurbsCurve2DByInterp

class afem.geometry.create.NurbsCurve2DByInterp(qp, is_periodic=False, v1=None, v2=None, tol=1e-07)

Create a 2-D cubic curve by interpolating 2-D points.

Parameters
  • qp (collections.Sequence(point2d_like)) – Points to interpolate.

  • is_periodic (bool) – Flag for curve periodicity. If True the curve will be periodic and closed.

  • v1 (vector2d_like) – Tangent to match at first point.

  • v2 (vector2d_like) – Tangent to match at last point.

  • tol (float) – Tolerance used to check for coincident points and the magnitude of end vectors.

Raises

RuntimeError – If Geom2dAPI_Interpolate fails.

NurbsCurve2DByApprox

class afem.geometry.create.NurbsCurve2DByApprox(qp, dmin=3, dmax=8, continuity=GeomAbs_Shape.GeomAbs_C2, parm_type=Approx_ParametrizationType.Approx_ChordLength, tol=1e-06)

Create a 2-D NURBS curve by approximating 2-D points.

Parameters
  • qp (collections.Sequence(point2d_like)) – Points to approximate.

  • dmin (int) – Minimum degree.

  • dmax (int) – Maximum degree.

  • continuity (OCCT.GeomAbs.GeomAbs_Shape) – Desired continuity of curve.

  • parm_type (OCCT.Approx.Approx_ParametrizationType) – Parametrization type.

  • tol (float) – The tolerance used for approximation. The distance from the points to the resulting curve should be lower than tol.

Raises

RuntimeError – If OCC method fails to interpolate the points with a curve.

NurbsCurve2DByPoints

class afem.geometry.create.NurbsCurve2DByPoints(qp)

Create a 2-D linear curve (i.e., a polyline) between points. This method uses NurbsCurve2DByApprox to fit a linear curve.

Parameters

qp (collections.Sequence(point2d_like)) – Points.

NurbsCurveByInterp

class afem.geometry.create.NurbsCurveByInterp(qp, is_periodic=False, v1=None, v2=None, tol=1e-07)

Create a cubic curve by interpolating points.

Parameters
  • qp (collections.Sequence(point_like)) – Points to interpolate.

  • is_periodic (bool) – Flag for curve periodicity. If True the curve will be periodic and closed.

  • v1 (vector_like) – Tangent to match at first point.

  • v2 (vector_like) – Tangent to match at last point.

  • tol (float) – Tolerance used to check for coincident points and the magnitude of end vectors.

Raises

RuntimeError – If OCC method fails.

NurbsCurveByApprox

class afem.geometry.create.NurbsCurveByApprox(qp, dmin=3, dmax=8, continuity=GeomAbs_Shape.GeomAbs_C2, parm_type=Approx_ParametrizationType.Approx_ChordLength, tol=0.001)

Create a NURBS curve by approximating points.

Parameters
  • qp (collections.Sequence(point_like)) – Points to approximate.

  • dmin (int) – Minimum degree.

  • dmax (int) – Maximum degree.

  • continuity (OCCT.GeomAbs.GeomAbs_Shape) – Desired continuity of curve.

  • parm_type (OCCT.Approx.Approx_ParametrizationType) – Parametrization type.

  • tol (float) – The tolerance used for approximation. The distance from the points to the resulting curve should be lower than tol.

Raises

RuntimeError – If OCC method fails to interpolate the points with a curve.

NurbsCurveByPoints

class afem.geometry.create.NurbsCurveByPoints(qp)

Create a linear curve (i.e., a polyline) between points. This method uses NurbsCurveByApprox to fit a linear curve.

Parameters

qp (collections.Sequence(point_like)) – Points.

TrimmedCurveByPoints

class afem.geometry.create.TrimmedCurveByPoints(basis_curve, p1, p2, sense=True, adjust_periodic=True)

Create a trimmed curve using a basis curve and limiting points. The points are projected to the basis curve to find the limiting parameters.

Parameters
  • basis_curve (afem.geometry.entities.Curve) – The basis curve.

  • p1 (point_like) – The first point.

  • p2 (point_like) – The last point.

  • sense (bool) – If the basis curve is periodic, the trimmed curve will have the same orientation as the basis curve if True or opposite if False.

  • adjust_periodic (bool) – If the basis curve is periodic, the bounds of the trimmed curve may be different from u1 and u2 if True.

Raises
  • TypeError – If the basis curve is not a valid curve type.

  • ValueError – If u1 >= u2.

PlaneByNormal

class afem.geometry.create.PlaneByNormal(origin=0.0, 0.0, 0.0, vnorm=0.0, 0.0, 1.0)

Create a plane by an origin and a normal vector.

Parameters
  • origin (point_like) – The origin.

  • vnorm (vector_like) – The normal vector.

Raises
  • TypeError – If origin cannot be converted to Point.

  • TypeError – If vnorm cannot be converted to Direction.

PlaneByAxes

class afem.geometry.create.PlaneByAxes(origin=0.0, 0.0, 0.0, axes='xz')

Create a plane by an origin and basic axes.

Parameters
  • origin (point_like) – The origin.

  • axes (str) – The axes (‘xy’, ‘xz’, ‘yz’).

Raises
  • TypeError – If origin cannot be converted to Point.

  • ValueError – If axes is not a supported option.

PlaneByPoints

class afem.geometry.create.PlaneByPoints(p1, p2, p3)

Create a plane by three points. The points must not be collinear. The plane will be defined by (p2 - p1) x (p3 - p1).

Parameters
  • p1 (point_like) – First point. This point will be used as the origin.

  • p2 (point_like) – Second point.

  • p3 (point_like) – Third point.

Raises
  • TypeError – if p1, p2, or p3 cannot be converted to a Point.

  • ValueError – If the points are collinear.

PlaneByApprox

class afem.geometry.create.PlaneByApprox(pnts, tol=1e-07)

Create a plane by fitting points. The points must not be collinear.

Parameters
  • pnts (list(point_like)) – Points to fit plane. Should not be collinear.

  • tol (float) – Tolerance used to check for collinear points.

Raises
  • ValueError – If the number of points is less than three.

  • RuntimeError – If a plane cannot be fit to the points.

PlaneFromParameter

class afem.geometry.create.PlaneFromParameter(c, u0, ds, ref_pln=None, tol=1e-07)

Create a plane along a curve at a specified distance from a parameter.

Parameters
Returns

The plane.

Return type

afem.geometry.entities.Plane

PlaneByOrientation

class afem.geometry.create.PlaneByOrientation(origin=0.0, 0.0, 0.0, axes='xz', alpha=0.0, beta=0.0, gamma=0.0)

Create a plane by rotation angles.

Parameters
  • origin (point_like) – The origin.

  • axes (str) – The reference axes (‘xy’, ‘xz’, ‘yz’).

  • alpha (float) – Rotation in degrees about global x-axis.

  • beta (float) – Rotation in degrees about global y-axis.

  • gamma (float) – Rotation in degrees about global z-axis.

PlaneByCurveAndSurface

class afem.geometry.create.PlaneByCurveAndSurface(crv, srf, u)

Create a plane using a curve that lies on a surface. The x-axis of the plane is found by the cross product of the surface normal and the first derivative of the curve at the parameter. The normal of the plane is found by the cross product of the x-axis and the surface normal. The origin will be located at a point along the curve at the given parameter.

Parameters

PlanesAlongCurveByNumber

class afem.geometry.create.PlanesAlongCurveByNumber(c, n, ref_pln=None, u1=None, u2=None, d1=None, d2=None, tol=1e-07)

Create planes along a curve using a specified number. The origin of the planes will be equidistant along the curve.

Parameters
  • c (afem.adaptor.entities.AdaptorCurve or afem.geometry.entities.Curve or afem.topology.entities.Edge or afem.topology.entities.Wire) – The curve.

  • n (int) – Number of planes to create (n > 0).

  • ref_pln (afem.geometry.entities.Plane) – The normal of this plane will be used to define the normal of all planes along the curve. If no plane is provided, then the first derivative of the curve will define the plane normal.

  • u1 (float) – The parameter of the first plane (default=c.u1).

  • u2 (float) – The parameter of the last plane (default=c.u2).

  • d1 (float) – An offset distance for the first plane. This is typically a positive number indicating a distance from u1 towards u2.

  • d2 (float) – An offset distance for the last plane. This is typically a negative number indicating a distance from u2 towards u1.

  • tol (float) – Tolerance.

Raises

RuntimeError – If PointsAlongCurveByNumber fails to generate points along the curve.

PlanesAlongCurveByDistance

class afem.geometry.create.PlanesAlongCurveByDistance(c, maxd, ref_pln=None, u1=None, u2=None, d1=None, d2=None, nmin=0, tol=1e-07)

Create planes along a curve by distance between points. The origin of the planes will be equidistant along the curve. This method calculates the number of points given the curve length and then uses PlanesAlongCurveByNumber.

Parameters
  • c (afem.adaptor.entities.AdaptorCurve or afem.geometry.entities.Curve or afem.topology.entities.Edge or afem.topology.entities.Wire) – The curve.

  • maxd (float) – The maximum allowed spacing between planes. The actual spacing will be adjusted to not to exceed this value.

  • ref_pln (afem.geometry.entities.Plane) – The normal of this plane will be used to define the normal of all planes along the curve. If no plane is provided, then the first derivative of the curve will define the plane normal.

  • u1 (float) – The parameter of the first plane (default=c.u1).

  • u2 (float) – The parameter of the last plane (default=c.u2).

  • d1 (float) – An offset distance for the first plane. This is typically a positive number indicating a distance from u1 towards u2.

  • d2 (float) – An offset distance for the last plane. This is typically a negative number indicating a distance from u2 towards u1.

  • nmin (int) – Minimum number of planes to create.

  • tol (float) – Tolerance.

Raises

RuntimeError – If PointsAlongCurveByDistance fails to generate points along the curve.

PlanesBetweenPlanesByNumber

class afem.geometry.create.PlanesBetweenPlanesByNumber(pln1, pln2, n, d1=None, d2=None)

Create planes between two other planes. This method will create a line normal to the first plane at its origin and then intersect that line with the second plane. Planes are then created along this line using PlanesAlongCurveByNumber. Planes are not generated at the same location as the boundary planes.

Parameters
  • pln1 (afem.geometry.entities.Plane) – The first plane. This will be the reference plane to define the orientation of the new planes.

  • pln2 (afem.geometry.entities.Plane) – The last plane.

  • n (int) – The number of planes.

  • d1 (float) – An offset distance for the first plane. This is typically a positive number indicating a distance from u1 towards u2.

  • d2 (float) – An offset distance for the last plane. This is typically a negative number indicating a distance from u2 towards u1.

Raises

RuntimeError – If the line extending from the normal of the first plane cannot be intersected with the second plane.

PlanesBetweenPlanesByDistance

class afem.geometry.create.PlanesBetweenPlanesByDistance(pln1, pln2, maxd, d1=None, d2=None, nmin=0)

Create planes between two other planes by distance. This method will create a line normal to the first plane at its origin and then intersect that line with the second plane. Planes are then created along this line using PlanesAlongCurveByNumber. Planes are not generated at the same location as the boundary planes.

Parameters
  • pln1 (afem.geometry.entities.Plane) – The first plane. This will be the reference plane to define the orientation of the new planes.

  • pln2 (afem.geometry.entities.Plane) – The last plane.

  • maxd (float) – The maximum allowed spacing between planes. The actual spacing will be adjusted to not to exceed this value.

  • d1 (float) – An offset distance for the first plane. This is typically a positive number indicating a distance from u1 towards u2.

  • d2 (float) – An offset distance for the last plane. This is typically a negative number indicating a distance from u2 towards u1.

  • nmin (int) – Minimum number of planes to create.

Raises

RuntimeError – If the line extending from the normal of the first plane cannot be intersected with the second plane.

PlanesAlongCurveAndSurfaceByDistance

class afem.geometry.create.PlanesAlongCurveAndSurfaceByDistance(c, s, maxd, u1=None, u2=None, d1=None, d2=None, nmin=0, tol=1e-07)

Create planes along a curve and surface by distance between points. The origin of the planes will be equidistant along the curve. This method calculates the number of points given the curve length and then uses PlaneByCurveAndSurface at each point.

Parameters
  • c (afem.geometry.entities.Curve) – The curve.

  • s (afem.geometry.entities.Surface) – The surface.

  • maxd (float) – The maximum allowed spacing between planes. The actual spacing will be adjusted to not to exceed this value.

  • u1 (float) – The parameter of the first plane (default=c.u1).

  • u2 (float) – The parameter of the last plane (default=c.u2).

  • d1 (float) – An offset distance for the first plane. This is typically a positive number indicating a distance from u1 towards u2.

  • d2 (float) – An offset distance for the last plane. This is typically a negative number indicating a distance from u2 towards u1.

  • nmin (int) – Minimum number of planes to create.

  • tol (float) – Tolerance.

Raises

RuntimeError – If PointsAlongCurveByDistance fails to generate points along the curve.

NurbsSurfaceByInterp

class afem.geometry.create.NurbsSurfaceByInterp(crvs, q=3, parm_type=Approx_ParametrizationType.Approx_ChordLength, tol2d=1e-09)

Create a surface by interpolating curves. This method was developed from scratch using “The NURBS Book” since OpenCASCADE did not support interpolating surfaces with q = 1.

Parameters
  • crvs (list(curve_like)) – List of curves to interpolate.

  • q (int) – Degree. The parameter will be adjusted if the number of curves provided does not support the desired degree.

  • parm_type (OCCT.Approx.Approx_ParametrizationType) – Parametrization type.

  • tol2d (float) – 2-D tolerance.

NurbsSurfaceByApprox

class afem.geometry.create.NurbsSurfaceByApprox(crvs, dmin=3, dmax=8, tol3d=0.001, tol2d=1e-06, niter=5, continuity=GeomAbs_Shape.GeomAbs_C2, parm_type=Approx_ParametrizationType.Approx_ChordLength)

Create a NURBS surface by approximating curves.

Parameters
  • crvs (list(curve_like)) – List of curves.

  • dmin (int) – Minimum degree.

  • dmax (int) – Maximum degree.

  • tol3d (float) – 3-D tolerance.

  • tol2d (float) – 2-D tolerance.

  • niter (int) – Number of iterations.

  • continuity (OCCT.GeomAbs.GeomAbs_Shape) – Desired continuity of curve.

  • parm_type (OCCT.Approx.Approx_ParametrizationType) – Parametrization type.

Raises

RuntimeError – If OCC method fails to approximate the curves with a surface.

Project

PointProjector

class afem.geometry.project.PointProjector

Base class for point projections.

ProjectPointToCurve

class afem.geometry.project.ProjectPointToCurve(pnt, crv, direction=None, update=False)

Project a point to a curve.

Parameters

ProjectPointToSurface

class afem.geometry.project.ProjectPointToSurface(pnt, srf, direction=None, update=False, tol=1e-07)

Project a point to a surface.

Parameters
  • pnt (point_like) – Point to project.

  • srf (afem.adaptor.entities.AdaptorSurface or afem.geometry.entities.Surface or afem.topology.entities.Face) – Surface to project to.

  • direction (array_like) – Direction of projection. If None then a normal projection will be performed. By providing a direction the tool actually performs a line-surface intersection. This is generally not recommended but provided by request.

  • update (bool) – Option to update the point’s location to match the nearest point.

CurveProjector

class afem.geometry.project.CurveProjector

Base class for curve projections.

ProjectCurveToPlane

class afem.geometry.project.ProjectCurveToPlane(crv, pln, direction=None, keep_param=True)

Project a curve to a plane along a direction.

Parameters
Raises

RuntimeError – If the OCC method fails to project the curve to the plane.

ProjectCurveToSurface

class afem.geometry.project.ProjectCurveToSurface(crv, srf)

Project a curve to a surface. Only normal projections are supported.

Parameters
Raises

RuntimeError – If the OCC method fails to project the curve to the plane.

Intersect

CurveIntersector

class afem.geometry.intersect.CurveIntersector(c1, c2)

Base class for handling curve intersection methods and results.

IntersectCurveCurve

class afem.geometry.intersect.IntersectCurveCurve(crv1, crv2, itol=1e-07)

Curve-curve intersection. This method converts the curves to edges and performs the intersections that way. This proved to be more robust than OpenCASCADE’s native curve-curve intersection tool.

Parameters

IntersectCurveSurface

class afem.geometry.intersect.IntersectCurveSurface(crv, srf)

Curve-surface intersection.

Parameters

SurfaceIntersector

class afem.geometry.intersect.SurfaceIntersector

Base class for handling surface intersection methods and results.

IntersectSurfaceSurface

class afem.geometry.intersect.IntersectSurfaceSurface(srf1, srf2, itol=1e-07, approx=True)

Surface-surface intersection.

Parameters

Distance

DistancePointToCurve

class afem.geometry.distance.DistancePointToCurve(pnt, crv, tol=1e-10)

Calculate the extrema between a point and a curve.

Parameters
Raises

RuntimeError – If Extrema_ExtPC fails.

DistancePointToSurface

class afem.geometry.distance.DistancePointToSurface(pnt, srf, tol=1e-10)

Calculate the extrema between a point and a surface.

Parameters
Raises

RuntimeError – If Extrema_ExtPS fails.

DistanceCurveToCurve

class afem.geometry.distance.DistanceCurveToCurve(crv1, crv2, tol=1e-10)

Calculate the extrema between two curves.

Parameters
Raises

RuntimeError – If Extrema_ExtCC fails.

DistanceCurveToSurface

class afem.geometry.distance.DistanceCurveToSurface(crv, srf, tol=1e-10)

Calculate the extrema between a curve and surface.

Parameters
Raises

RuntimeError – If the extrema algorithm fails.

DistanceSurfaceToSurface

class afem.geometry.distance.DistanceSurfaceToSurface(srf1, srf2, tol=1e-10)

Calculate the extrema between two surfaces.

Parameters
Raises

RuntimeError – If Extrema_ExtSS fails.

Check

CheckGeom

class afem.geometry.check.CheckGeom

Geometry checker.

Utilities