OCCT-Light 0.1
C ABI and C++ veneer for multi-language CAD workflows
Loading...
Searching...
No Matches
occtl::Curve2d Class Reference

Non-owning reference to a 2D geometric curve stored in a graph. More...

#include <curves2d.hpp>

Classes

struct  BSplineView
 Aggregate inspection view of a 2D B-spline curve (§10.5). More...
 
struct  OffsetView
 
struct  TrimmedView
 

Public Member Functions

 Curve2d (occtl_graph_t *theGraph=nullptr, occtl_rep_id_t theId=occtl_rep_id_t{0}) noexcept
 Constructs a null reference (no graph, invalid id).
 
 operator bool () const noexcept
 Returns true when the reference points into a valid graph.
 
occtl_graph_tgraph () const noexcept
 Borrows it — returns the graph pointer.
 
occtl_rep_id_t id () const noexcept
 Returns the representation id.
 
Curve2d reversed () const
 Returns a reversed copy of this curve stored in the same graph.
 
Curve2d transformed (double theTranslateX, double theTranslateY, double theRotateAngle, double theScaleX, double theScaleY) const
 Returns a transformed copy of this curve stored in the same graph.
 
Curve2d translated (const Vector2 &theDelta) const
 Returns a translated copy of this curve stored in the same graph.
 
Curve2d rotated (double theAngle) const
 Returns a rotated copy of this curve stored in the same graph.
 
Curve2d scaled (const Point2 &theOrigin, double theFactor) const
 Returns a scaled copy of this curve stored in the same graph.
 
double length () const
 Returns the curve length over its full parameter range.
 
std::pair< double, double > project_point (const Point2 &thePoint) const
 Projects a 2D point onto the curve.
 
double parameter_of_point (const Point2 &thePoint) const
 Returns the parameter on the 2D curve nearest to a given point.
 
occtl_curve_kind_t kind () const
 Returns the kind of geometry.
 
int32_t is_periodic () const
 Returns 1 when the curve is periodic, 0 otherwise.
 
int32_t is_closed () const
 Returns 1 when the curve is closed, 0 otherwise.
 
occtl_geom_continuity_t continuity () const
 Returns the geometric continuity class.
 
void parameter_range (double &theUMin, double &theUMax) const
 Returns the parameter range [u_min, u_max] via out-parameters.
 
occtl_geom2d_line_t as_line () const
 Extracts the underlying line.
 
occtl_geom2d_circle_t as_circle () const
 Extracts the underlying circle.
 
occtl_geom2d_ellipse_t as_ellipse () const
 Extracts the underlying ellipse.
 
occtl_geom2d_hyperbola_t as_hyperbola () const
 Extracts the underlying hyperbola.
 
occtl_geom2d_parabola_t as_parabola () const
 Extracts the underlying parabola.
 
TrimmedView as_trimmed () const
 Extracts the parameter bounds from a trimmed curve.
 
OffsetView as_offset () const
 Extracts the scalar offset of an offset curve.
 
BSplineView as_bspline () const
 Returns a §10.5 aggregate inspection view of a 2D B-spline curve.
 
int32_t bspline_degree () const
 Returns the polynomial degree.
 
size_t bspline_pole_count () const
 Returns the number of poles.
 
size_t bspline_knot_count () const
 Returns the number of distinct knot values.
 
int32_t bspline_is_rational () const
 Returns 1 when the B-spline is rational (NURBS), 0 otherwise.
 
int32_t bezier_degree () const
 Returns the Bezier polynomial degree.
 
size_t bezier_pole_count () const
 Returns the number of Bezier poles.
 
int32_t bezier_is_rational () const
 Returns 1 when the Bezier curve is rational, 0 otherwise.
 
std::vector< occtl_point2_tbspline_poles () const
 Copies all poles into a std::vector<occtl_point2_t>.
 
std::vector< double > bspline_knots () const
 Copies all distinct knot values into a std::vector<double>.
 
std::vector< int32_t > bspline_multiplicities () const
 Copies all knot multiplicities into a std::vector<int32_t>.
 
std::vector< double > bspline_weights () const
 Copies all weights into a std::vector<double>.
 
std::vector< double > bspline_flat_knots () const
 Copies the expanded (flat) knot sequence into a vector.
 
const occtl_point2_tbspline_poles_view (size_t &theCount) const
 Returns a zero-copy view of the poles array.
 
std::vector< Curve2dto_bezier_segments (const occtl_curve_bezier_segments_options_t *theOptions=nullptr) const
 Decomposes this 2D curve into adjacent Bezier curve segments.
 
occtl_point2_t eval_d0 (const double theU) const
 Evaluates the 2D curve point at parameter theU.
 
std::pair< occtl_point2_t, occtl_vector2_teval_d1 (const double theU) const
 Evaluates point and first derivative at theU.
 
std::tuple< occtl_point2_t, occtl_vector2_t, occtl_vector2_teval_d2 (const double theU) const
 Evaluates point, first, and second derivatives at theU.
 
std::tuple< occtl_point2_t, occtl_vector2_t, occtl_vector2_t, occtl_vector2_teval_d3 (const double theU) const
 Evaluates point, first, second, and third derivatives at theU.
 
occtl_vector2_t eval_dn (const double theU, const int32_t theN) const
 Returns the N-th derivative vector at theU.
 

Static Public Member Functions

static Curve2d from_line (occtl_graph_t *graph, const occtl_geom2d_line_t &theLine)
 Constructs a 2D curve from a line.
 
static Curve2d from_circle (occtl_graph_t *graph, const occtl_geom2d_circle_t &theCircle)
 Constructs a 2D curve from a circle.
 
static std::vector< occtl_geom2d_circle_tcircles_tangent_to_two_radius (occtl_graph_t *graph, const occtl_curve2d_circle_tangent_to_two_radius_info_t &theInfo)
 Computes all fixed-radius circles tangent to two 2D curves.
 
static std::vector< Curve2dblend_arcs (occtl_graph_t *graph, const occtl_curve2d_blend_arc_info_t &theInfo)
 Computes all fixed-radius 2D blend arcs tangent to two 2D curves.
 
static std::vector< occtl_geom2d_line_tlines_tangent_to_two (occtl_graph_t *graph, const occtl_curve2d_line_tangent_to_two_info_t &theInfo)
 Computes all 2D lines tangent to two 2D curves.
 
static std::vector< occtl_geom2d_line_tlines_tangent_through_point (occtl_graph_t *graph, const occtl_curve2d_line_tangent_through_point_info_t &theInfo)
 Computes all 2D lines tangent to a 2D curve through a point.
 
static std::vector< occtl_geom2d_line_tlines_tangent_with_angle (occtl_graph_t *graph, const occtl_curve2d_line_tangent_with_angle_info_t *theInfo)
 Computes all 2D lines tangent to a curve at a fixed angle to a line.
 
static std::vector< occtl_geom2d_circle_tcircles_tangent_to_three (occtl_graph_t *graph, const occtl_curve2d_circle_tangent_to_three_info_t &theInfo)
 Computes all 2D circles tangent to three 2D curves.
 
static std::vector< occtl_geom2d_circle_tcircles_tangent_fixed_center (occtl_graph_t *graph, const occtl_curve2d_circle_tangent_fixed_center_info_t &theInfo)
 Computes all 2D circles tangent to a curve with a fixed center.
 
static std::vector< occtl_geom2d_circle_tcircles_tangent_center_on_curve (occtl_graph_t *graph, const occtl_curve2d_circle_tangent_center_on_curve_info_t *theInfo)
 Computes all 2D circles tangent to two curves with center on a curve.
 
static std::vector< occtl_geom2d_circle_tcircles_tangent_on_curve_radius (occtl_graph_t *graph, const occtl_curve2d_circle_tangent_on_curve_radius_info_t *theInfo)
 Computes fixed-radius 2D circles tangent to a curve with center on another curve.
 
static Curve2d from_ellipse (occtl_graph_t *graph, const occtl_geom2d_ellipse_t &theEllipse)
 Constructs a 2D curve from an ellipse.
 
static Curve2d from_hyperbola (occtl_graph_t *graph, const occtl_geom2d_hyperbola_t &theHyperbola)
 Constructs a 2D curve from a hyperbola.
 
static Curve2d from_parabola (occtl_graph_t *graph, const occtl_geom2d_parabola_t &theParabola)
 Constructs a 2D curve from a parabola.
 
static Curve2d from_bspline (occtl_graph_t *graph, const occtl_curve2d_bspline_create_info_t &theInfo)
 Constructs a 2D B-spline curve from the given create info.
 
static Curve2d from_bezier (occtl_graph_t *graph, const occtl_curve2d_bezier_create_info_t &theInfo)
 Constructs a 2D Bezier curve from the given create info.
 
static Curve2d from_trimmed (occtl_graph_t *graph, const occtl_curve_trimmed_create_info_t &theInfo)
 Constructs a trimmed 2D curve.
 
static Curve2d from_offset (occtl_graph_t *graph, const occtl_curve2d_offset_create_info_t &theInfo)
 Constructs an offset 2D curve.
 

Detailed Description

Non-owning reference to a 2D geometric curve stored in a graph.

Wraps one occtl_rep_id_t inside an occtl_graph_t*. Copying is shallow — both copies refer to the same graph representation.

Member Function Documentation

◆ as_bspline()

Curve2d::BSplineView occtl::Curve2d::as_bspline ( ) const
inline

Returns a §10.5 aggregate inspection view of a 2D B-spline curve.

The returned view's pointer fields borrow from this curve's graph rep and remain valid until the rep is removed from the graph.

Exceptions
Errorwith OCCTL_WRONG_KIND when kind() != BSPLINE, or OCCTL_VERSION_MISMATCH on unsupported layout version.

◆ as_circle()

occtl_geom2d_circle_t occtl::Curve2d::as_circle ( ) const
inline

Extracts the underlying circle.

Exceptions
Errorwith OCCTL_WRONG_KIND when kind() != OCCTL_CURVE_KIND_CIRCLE.

◆ as_ellipse()

occtl_geom2d_ellipse_t occtl::Curve2d::as_ellipse ( ) const
inline

Extracts the underlying ellipse.

Exceptions
Errorwith OCCTL_WRONG_KIND when kind() != OCCTL_CURVE_KIND_ELLIPSE.

◆ as_hyperbola()

occtl_geom2d_hyperbola_t occtl::Curve2d::as_hyperbola ( ) const
inline

Extracts the underlying hyperbola.

Exceptions
Errorwith OCCTL_WRONG_KIND when kind() != OCCTL_CURVE_KIND_HYPERBOLA.

◆ as_line()

occtl_geom2d_line_t occtl::Curve2d::as_line ( ) const
inline

Extracts the underlying line.

Exceptions
Errorwith OCCTL_WRONG_KIND when kind() != OCCTL_CURVE_KIND_LINE.

◆ as_offset()

Curve2d::OffsetView occtl::Curve2d::as_offset ( ) const
inline

Extracts the scalar offset of an offset curve.

Exceptions
Errorwith OCCTL_WRONG_KIND when kind() != OFFSET.

◆ as_parabola()

occtl_geom2d_parabola_t occtl::Curve2d::as_parabola ( ) const
inline

Extracts the underlying parabola.

Exceptions
Errorwith OCCTL_WRONG_KIND when kind() != OCCTL_CURVE_KIND_PARABOLA.

◆ as_trimmed()

Curve2d::TrimmedView occtl::Curve2d::as_trimmed ( ) const
inline

Extracts the parameter bounds from a trimmed curve.

Exceptions
Errorwith OCCTL_WRONG_KIND when kind() != TRIMMED.

◆ bezier_degree()

int32_t occtl::Curve2d::bezier_degree ( ) const
inline

Returns the Bezier polynomial degree.

Exceptions
Errorwhen kind != BEZIER.

◆ bezier_is_rational()

int32_t occtl::Curve2d::bezier_is_rational ( ) const
inline

Returns 1 when the Bezier curve is rational, 0 otherwise.

Exceptions
Errorwhen kind != BEZIER.

◆ bezier_pole_count()

size_t occtl::Curve2d::bezier_pole_count ( ) const
inline

Returns the number of Bezier poles.

Exceptions
Errorwhen kind != BEZIER.

◆ blend_arcs()

static std::vector< Curve2d > occtl::Curve2d::blend_arcs ( occtl_graph_t graph,
const occtl_curve2d_blend_arc_info_t theInfo 
)
inlinestatic

Computes all fixed-radius 2D blend arcs tangent to two 2D curves.

Exceptions
Errorwhen the underlying solver call fails.

◆ bspline_degree()

int32_t occtl::Curve2d::bspline_degree ( ) const
inline

Returns the polynomial degree.

Exceptions
Errorwhen kind != BSPLINE.

◆ bspline_flat_knots()

std::vector< double > occtl::Curve2d::bspline_flat_knots ( ) const
inline

Copies the expanded (flat) knot sequence into a vector.

Exceptions
Errorwhen kind != BSPLINE or extraction fails.

◆ bspline_is_rational()

int32_t occtl::Curve2d::bspline_is_rational ( ) const
inline

Returns 1 when the B-spline is rational (NURBS), 0 otherwise.

Exceptions
Errorwhen kind != BSPLINE.

◆ bspline_knot_count()

size_t occtl::Curve2d::bspline_knot_count ( ) const
inline

Returns the number of distinct knot values.

Exceptions
Errorwhen kind != BSPLINE.

◆ bspline_knots()

std::vector< double > occtl::Curve2d::bspline_knots ( ) const
inline

Copies all distinct knot values into a std::vector<double>.

Exceptions
Errorwhen kind != BSPLINE or extraction fails.

◆ bspline_multiplicities()

std::vector< int32_t > occtl::Curve2d::bspline_multiplicities ( ) const
inline

Copies all knot multiplicities into a std::vector<int32_t>.

Exceptions
Errorwhen kind != BSPLINE or extraction fails.

◆ bspline_pole_count()

size_t occtl::Curve2d::bspline_pole_count ( ) const
inline

Returns the number of poles.

Exceptions
Errorwhen kind != BSPLINE.

◆ bspline_poles()

std::vector< occtl_point2_t > occtl::Curve2d::bspline_poles ( ) const
inline

Copies all poles into a std::vector<occtl_point2_t>.

Exceptions
Errorwhen kind != BSPLINE or extraction fails.

◆ bspline_poles_view()

const occtl_point2_t * occtl::Curve2d::bspline_poles_view ( size_t &  theCount) const
inline

Returns a zero-copy view of the poles array.

Valid until the graph rep is removed or a mutating call is made on it.

Exceptions
Errorwhen kind != BSPLINE or view is unavailable.

◆ bspline_weights()

std::vector< double > occtl::Curve2d::bspline_weights ( ) const
inline

Copies all weights into a std::vector<double>.

Exceptions
Errorwith OCCTL_WRONG_KIND when the curve is non-rational.

◆ circles_tangent_center_on_curve()

static std::vector< occtl_geom2d_circle_t > occtl::Curve2d::circles_tangent_center_on_curve ( occtl_graph_t graph,
const occtl_curve2d_circle_tangent_center_on_curve_info_t theInfo 
)
inlinestatic

Computes all 2D circles tangent to two curves with center on a curve.

Exceptions
Errorwhen the underlying solver call fails.

◆ circles_tangent_fixed_center()

static std::vector< occtl_geom2d_circle_t > occtl::Curve2d::circles_tangent_fixed_center ( occtl_graph_t graph,
const occtl_curve2d_circle_tangent_fixed_center_info_t theInfo 
)
inlinestatic

Computes all 2D circles tangent to a curve with a fixed center.

Exceptions
Errorwhen the underlying solver call fails.

◆ circles_tangent_on_curve_radius()

static std::vector< occtl_geom2d_circle_t > occtl::Curve2d::circles_tangent_on_curve_radius ( occtl_graph_t graph,
const occtl_curve2d_circle_tangent_on_curve_radius_info_t theInfo 
)
inlinestatic

Computes fixed-radius 2D circles tangent to a curve with center on another curve.

Exceptions
Errorwhen the underlying solver call fails.

◆ circles_tangent_to_three()

static std::vector< occtl_geom2d_circle_t > occtl::Curve2d::circles_tangent_to_three ( occtl_graph_t graph,
const occtl_curve2d_circle_tangent_to_three_info_t theInfo 
)
inlinestatic

Computes all 2D circles tangent to three 2D curves.

Exceptions
Errorwhen the underlying solver call fails.

◆ circles_tangent_to_two_radius()

static std::vector< occtl_geom2d_circle_t > occtl::Curve2d::circles_tangent_to_two_radius ( occtl_graph_t graph,
const occtl_curve2d_circle_tangent_to_two_radius_info_t theInfo 
)
inlinestatic

Computes all fixed-radius circles tangent to two 2D curves.

Exceptions
Errorwhen the underlying solver call fails.

◆ continuity()

occtl_geom_continuity_t occtl::Curve2d::continuity ( ) const
inline

Returns the geometric continuity class.

Exceptions
Errorwhen the underlying call fails.

◆ eval_d0()

occtl_point2_t occtl::Curve2d::eval_d0 ( const double  theU) const
inline

Evaluates the 2D curve point at parameter theU.

Exceptions
Erroron NULL graph or out-of-range.

◆ eval_d1()

std::pair< occtl_point2_t, occtl_vector2_t > occtl::Curve2d::eval_d1 ( const double  theU) const
inline

Evaluates point and first derivative at theU.

Exceptions
Erroron NULL graph or out-of-range.

◆ eval_d2()

std::tuple< occtl_point2_t, occtl_vector2_t, occtl_vector2_t > occtl::Curve2d::eval_d2 ( const double  theU) const
inline

Evaluates point, first, and second derivatives at theU.

Exceptions
Erroron NULL graph or out-of-range.

◆ eval_d3()

std::tuple< occtl_point2_t, occtl_vector2_t, occtl_vector2_t, occtl_vector2_t > occtl::Curve2d::eval_d3 ( const double  theU) const
inline

Evaluates point, first, second, and third derivatives at theU.

Exceptions
Erroron NULL graph or out-of-range.

◆ eval_dn()

occtl_vector2_t occtl::Curve2d::eval_dn ( const double  theU,
const int32_t  theN 
) const
inline

Returns the N-th derivative vector at theU.

Exceptions
Erroron NULL graph or out-of-range.

◆ from_bezier()

static Curve2d occtl::Curve2d::from_bezier ( occtl_graph_t graph,
const occtl_curve2d_bezier_create_info_t theInfo 
)
inlinestatic

Constructs a 2D Bezier curve from the given create info.

Exceptions
Erroron invalid geometry or version mismatch.

◆ from_bspline()

static Curve2d occtl::Curve2d::from_bspline ( occtl_graph_t graph,
const occtl_curve2d_bspline_create_info_t theInfo 
)
inlinestatic

Constructs a 2D B-spline curve from the given create info.

Exceptions
Erroron invalid geometry or version mismatch.

◆ from_circle()

static Curve2d occtl::Curve2d::from_circle ( occtl_graph_t graph,
const occtl_geom2d_circle_t theCircle 
)
inlinestatic

Constructs a 2D curve from a circle.

Exceptions
Erroron invalid geometry.

◆ from_ellipse()

static Curve2d occtl::Curve2d::from_ellipse ( occtl_graph_t graph,
const occtl_geom2d_ellipse_t theEllipse 
)
inlinestatic

Constructs a 2D curve from an ellipse.

Exceptions
Erroron invalid geometry.

◆ from_hyperbola()

static Curve2d occtl::Curve2d::from_hyperbola ( occtl_graph_t graph,
const occtl_geom2d_hyperbola_t theHyperbola 
)
inlinestatic

Constructs a 2D curve from a hyperbola.

Exceptions
Erroron invalid geometry.

◆ from_line()

static Curve2d occtl::Curve2d::from_line ( occtl_graph_t graph,
const occtl_geom2d_line_t theLine 
)
inlinestatic

Constructs a 2D curve from a line.

Exceptions
Erroron invalid geometry.

◆ from_offset()

static Curve2d occtl::Curve2d::from_offset ( occtl_graph_t graph,
const occtl_curve2d_offset_create_info_t theInfo 
)
inlinestatic

Constructs an offset 2D curve.

Exceptions
Erroron invalid geometry or version mismatch.

◆ from_parabola()

static Curve2d occtl::Curve2d::from_parabola ( occtl_graph_t graph,
const occtl_geom2d_parabola_t theParabola 
)
inlinestatic

Constructs a 2D curve from a parabola.

Exceptions
Erroron invalid geometry.

◆ from_trimmed()

static Curve2d occtl::Curve2d::from_trimmed ( occtl_graph_t graph,
const occtl_curve_trimmed_create_info_t theInfo 
)
inlinestatic

Constructs a trimmed 2D curve.

Exceptions
Erroron invalid geometry or version mismatch.

◆ is_closed()

int32_t occtl::Curve2d::is_closed ( ) const
inline

Returns 1 when the curve is closed, 0 otherwise.

Exceptions
Errorwhen the underlying call fails.

◆ is_periodic()

int32_t occtl::Curve2d::is_periodic ( ) const
inline

Returns 1 when the curve is periodic, 0 otherwise.

Exceptions
Errorwhen the underlying call fails.

◆ kind()

occtl_curve_kind_t occtl::Curve2d::kind ( ) const
inline

Returns the kind of geometry.

Exceptions
Errorwhen the underlying call fails.

◆ length()

double occtl::Curve2d::length ( ) const
inline

Returns the curve length over its full parameter range.

Exceptions
Errorwhen the underlying call fails.

◆ lines_tangent_through_point()

static std::vector< occtl_geom2d_line_t > occtl::Curve2d::lines_tangent_through_point ( occtl_graph_t graph,
const occtl_curve2d_line_tangent_through_point_info_t theInfo 
)
inlinestatic

Computes all 2D lines tangent to a 2D curve through a point.

Exceptions
Errorwhen the underlying solver call fails.

◆ lines_tangent_to_two()

static std::vector< occtl_geom2d_line_t > occtl::Curve2d::lines_tangent_to_two ( occtl_graph_t graph,
const occtl_curve2d_line_tangent_to_two_info_t theInfo 
)
inlinestatic

Computes all 2D lines tangent to two 2D curves.

Exceptions
Errorwhen the underlying solver call fails.

◆ lines_tangent_with_angle()

static std::vector< occtl_geom2d_line_t > occtl::Curve2d::lines_tangent_with_angle ( occtl_graph_t graph,
const occtl_curve2d_line_tangent_with_angle_info_t theInfo 
)
inlinestatic

Computes all 2D lines tangent to a curve at a fixed angle to a line.

Exceptions
Errorwhen the underlying solver call fails.

◆ parameter_of_point()

double occtl::Curve2d::parameter_of_point ( const Point2 thePoint) const
inline

Returns the parameter on the 2D curve nearest to a given point.

Exceptions
Errorwhen the underlying call fails.

◆ parameter_range()

void occtl::Curve2d::parameter_range ( double &  theUMin,
double &  theUMax 
) const
inline

Returns the parameter range [u_min, u_max] via out-parameters.

Exceptions
Errorwhen the underlying call fails.

◆ project_point()

std::pair< double, double > occtl::Curve2d::project_point ( const Point2 thePoint) const
inline

Projects a 2D point onto the curve.

Returns
A pair of (parameter, distance).
Exceptions
Errorwhen the underlying call fails.

◆ reversed()

Curve2d occtl::Curve2d::reversed ( ) const
inline

Returns a reversed copy of this curve stored in the same graph.

Exceptions
Errorwhen the underlying call fails.

◆ rotated()

Curve2d occtl::Curve2d::rotated ( double  theAngle) const
inline

Returns a rotated copy of this curve stored in the same graph.

Exceptions
Errorwhen the underlying call fails.

◆ scaled()

Curve2d occtl::Curve2d::scaled ( const Point2 theOrigin,
double  theFactor 
) const
inline

Returns a scaled copy of this curve stored in the same graph.

Exceptions
Errorwhen the underlying call fails.

◆ to_bezier_segments()

std::vector< Curve2d > occtl::Curve2d::to_bezier_segments ( const occtl_curve_bezier_segments_options_t theOptions = nullptr) const
inline

Decomposes this 2D curve into adjacent Bezier curve segments.

Exceptions
Erroron invalid options or conversion failure.

◆ transformed()

Curve2d occtl::Curve2d::transformed ( double  theTranslateX,
double  theTranslateY,
double  theRotateAngle,
double  theScaleX,
double  theScaleY 
) const
inline

Returns a transformed copy of this curve stored in the same graph.

Exceptions
Errorwhen the underlying call fails.

◆ translated()

Curve2d occtl::Curve2d::translated ( const Vector2 theDelta) const
inline

Returns a translated copy of this curve stored in the same graph.

Exceptions
Errorwhen the underlying call fails.

The documentation for this class was generated from the following file: