OCCT-Light 0.1
C ABI and C++ veneer for multi-language CAD workflows
Loading...
Searching...
No Matches
curves2d.hpp
Go to the documentation of this file.
1// Copyright (c) 2026 Capgemini Engineering Research and Development.
2//
3// This file is part of OCCT-Light software library.
4//
5// This library is free software; you can redistribute it and/or modify it under
6// the terms of the GNU Affero General Public License version 3 as published
7// by the Free Software Foundation, with an option to use any later version.
8// Consult the file LICENSE_AGPL_30.txt included in OCCT-Light distribution
9// for complete text of the license and disclaimer of any warranty.
10//
11// Alternatively, this file may be used under the terms of a commercial
12// license or contractual agreement.
13//
14// SPDX-License-Identifier: AGPL-3.0-or-later
15
25#ifndef OCCTL_HPP_CURVES2D_HPP
26#define OCCTL_HPP_CURVES2D_HPP
27
29
30#include <occtl-hpp/core.hpp>
31#include <occtl-hpp/geom.hpp>
32
33#include <cstdint>
34#include <cstdlib>
35#include <tuple>
36#include <utility>
37#include <vector>
38
39#if defined(__cpp_lib_span) && __cpp_lib_span >= 202002L
40 #include <span>
41 #define OCCTL_HPP_HAS_SPAN 1
42#else
43 #define OCCTL_HPP_HAS_SPAN 0
44#endif
45
46namespace occtl
47{
48
49using GeomTangencyQualifier = occtl_curve2d_tangency_qualifier_t;
50
56{
57public:
59 Curve2d(occtl_graph_t* theGraph = nullptr, occtl_rep_id_t theId = occtl_rep_id_t{0}) noexcept
60 : myGraph(theGraph),
61 myId(theId)
62 {
63 }
64
66 explicit operator bool() const noexcept { return myGraph != nullptr && myId.bits != 0; }
67
69 occtl_graph_t* graph() const noexcept { return myGraph; }
70
72 occtl_rep_id_t id() const noexcept { return myId; }
73
77 {
78 occtl_rep_id_t aId{};
79 check(::occtl_curve2d_reverse(myGraph, myId, &aId));
80 return Curve2d(myGraph, aId);
81 }
82
85 Curve2d transformed(double theTranslateX,
86 double theTranslateY,
87 double theRotateAngle,
88 double theScaleX,
89 double theScaleY) const
90 {
91 occtl_rep_id_t aId{};
93 myId,
94 theTranslateX,
95 theTranslateY,
96 theRotateAngle,
97 theScaleX,
98 theScaleY,
99 &aId));
100 return Curve2d(myGraph, aId);
101 }
102
105 Curve2d translated(const Vector2& theDelta) const
106 {
107 occtl_rep_id_t aId{};
108 check(::occtl_curve2d_translated(myGraph, myId, theDelta.c_type(), &aId));
109 return Curve2d(myGraph, aId);
110 }
111
114 Curve2d rotated(double theAngle) const
115 {
116 occtl_rep_id_t aId{};
117 check(::occtl_curve2d_rotated(myGraph, myId, theAngle, &aId));
118 return Curve2d(myGraph, aId);
119 }
120
123 Curve2d scaled(const Point2& theOrigin, double theFactor) const
124 {
125 occtl_rep_id_t aId{};
126 check(::occtl_curve2d_scaled(myGraph, myId, theOrigin.c_type(), theFactor, &aId));
127 return Curve2d(myGraph, aId);
128 }
129
132 double length() const
133 {
134 double aLen = 0.0;
135 check(::occtl_curve2d_length(myGraph, myId, &aLen));
136 return aLen;
137 }
138
142 std::pair<double, double> project_point(const Point2& thePoint) const
143 {
144 double aParam = 0.0;
145 double aDist = 0.0;
146 check(::occtl_curve2d_project_point(myGraph, myId, thePoint.c_type(), &aParam, &aDist));
147 return {aParam, aDist};
148 }
149
152 double parameter_of_point(const Point2& thePoint) const
153 {
154 double aParam = 0.0;
155 check(::occtl_curve2d_parameter_of_point(myGraph, myId, thePoint.c_type(), &aParam));
156 return aParam;
157 }
158
162 {
163 occtl_curve_kind_t aKind{};
164 check(::occtl_curve2d_kind(myGraph, myId, &aKind));
165 return aKind;
166 }
167
170 int32_t is_periodic() const
171 {
172 int32_t aVal = 0;
173 check(::occtl_curve2d_is_periodic(myGraph, myId, &aVal));
174 return aVal;
175 }
176
179 int32_t is_closed() const
180 {
181 int32_t aVal = 0;
182 check(::occtl_curve2d_is_closed(myGraph, myId, &aVal));
183 return aVal;
184 }
185
189 {
191 check(::occtl_curve2d_continuity(myGraph, myId, &aCont));
192 return aCont;
193 }
194
197 void parameter_range(double& theUMin, double& theUMax) const
198 {
199 check(::occtl_curve2d_parameter_range(myGraph, myId, &theUMin, &theUMax));
200 }
201
205 {
206 occtl_geom2d_line_t aOut{};
207 check(::occtl_curve2d_as_line(myGraph, myId, &aOut));
208 return aOut;
209 }
210
214 {
216 check(::occtl_curve2d_as_circle(myGraph, myId, &aOut));
217 return aOut;
218 }
219
223 {
225 check(::occtl_curve2d_as_ellipse(myGraph, myId, &aOut));
226 return aOut;
227 }
228
232 {
234 check(::occtl_curve2d_as_hyperbola(myGraph, myId, &aOut));
235 return aOut;
236 }
237
241 {
243 check(::occtl_curve2d_as_parabola(myGraph, myId, &aOut));
244 return aOut;
245 }
246
247 struct TrimmedView;
248 struct OffsetView;
249 struct BSplineView;
250
253 inline TrimmedView as_trimmed() const;
254
257 inline OffsetView as_offset() const;
258
266 inline BSplineView as_bspline() const;
267
270 int32_t bspline_degree() const
271 {
272 int32_t aVal = 0;
273 check(::occtl_curve2d_bspline_degree(myGraph, myId, &aVal));
274 return aVal;
275 }
276
279 size_t bspline_pole_count() const
280 {
281 size_t aVal = 0;
282 check(::occtl_curve2d_bspline_pole_count(myGraph, myId, &aVal));
283 return aVal;
284 }
285
288 size_t bspline_knot_count() const
289 {
290 size_t aVal = 0;
291 check(::occtl_curve2d_bspline_knot_count(myGraph, myId, &aVal));
292 return aVal;
293 }
294
297 int32_t bspline_is_rational() const
298 {
299 int32_t aVal = 0;
300 check(::occtl_curve2d_bspline_is_rational(myGraph, myId, &aVal));
301 return aVal;
302 }
303
306 int32_t bezier_degree() const
307 {
308 int32_t aVal = 0;
309 check(::occtl_curve2d_bezier_degree(myGraph, myId, &aVal));
310 return aVal;
311 }
312
315 size_t bezier_pole_count() const
316 {
317 size_t aVal = 0;
318 check(::occtl_curve2d_bezier_pole_count(myGraph, myId, &aVal));
319 return aVal;
320 }
321
324 int32_t bezier_is_rational() const
325 {
326 int32_t aVal = 0;
327 check(::occtl_curve2d_bezier_is_rational(myGraph, myId, &aVal));
328 return aVal;
329 }
330
333 std::vector<occtl_point2_t> bspline_poles() const
334 {
335 size_t aNb = 0;
336 check(::occtl_curve2d_bspline_poles(myGraph, myId, nullptr, 0, &aNb));
337 std::vector<occtl_point2_t> aVec(aNb);
338 check(::occtl_curve2d_bspline_poles(myGraph, myId, aVec.data(), aNb, &aNb));
339 return aVec;
340 }
341
344 std::vector<double> bspline_knots() const
345 {
346 size_t aNb = 0;
347 check(::occtl_curve2d_bspline_knots(myGraph, myId, nullptr, 0, &aNb));
348 std::vector<double> aVec(aNb);
349 check(::occtl_curve2d_bspline_knots(myGraph, myId, aVec.data(), aNb, &aNb));
350 return aVec;
351 }
352
355 std::vector<int32_t> bspline_multiplicities() const
356 {
357 size_t aNb = 0;
358 check(::occtl_curve2d_bspline_multiplicities(myGraph, myId, nullptr, 0, &aNb));
359 std::vector<int32_t> aVec(aNb);
360 check(::occtl_curve2d_bspline_multiplicities(myGraph, myId, aVec.data(), aNb, &aNb));
361 return aVec;
362 }
363
366 std::vector<double> bspline_weights() const
367 {
368 size_t aNb = 0;
369 check(::occtl_curve2d_bspline_weights(myGraph, myId, nullptr, 0, &aNb));
370 std::vector<double> aVec(aNb);
371 check(::occtl_curve2d_bspline_weights(myGraph, myId, aVec.data(), aNb, &aNb));
372 return aVec;
373 }
374
377 std::vector<double> bspline_flat_knots() const
378 {
379 size_t aNb = 0;
380 check(::occtl_curve2d_bspline_flat_knots(myGraph, myId, nullptr, 0, &aNb));
381 std::vector<double> aVec(aNb);
382 check(::occtl_curve2d_bspline_flat_knots(myGraph, myId, aVec.data(), aNb, &aNb));
383 return aVec;
384 }
385
390 const occtl_point2_t* bspline_poles_view(size_t& theCount) const
391 {
392 const occtl_point2_t* aData = nullptr;
393 check(::occtl_curve2d_bspline_poles_view(myGraph, myId, &aData, &theCount));
394 return aData;
395 }
396
400 {
401 occtl_rep_id_t aId{};
402 check(::occtl_curve2d_create_line(graph, theLine, &aId));
403 return Curve2d(graph, aId);
404 }
405
409 {
410 occtl_rep_id_t aId{};
411 check(::occtl_curve2d_create_circle(graph, theCircle, &aId));
412 return Curve2d(graph, aId);
413 }
414
417 static std::vector<occtl_geom2d_circle_t> circles_tangent_to_two_radius(
420 {
421 size_t aCount = 0;
422 check(
423 ::occtl_curve2d_create_tangent_circle_to_two_radius(graph, &theInfo, 0, nullptr, &aCount));
424 std::vector<occtl_geom2d_circle_t> aCircles(aCount);
425 for (size_t anIndex = 0; anIndex < aCount; ++anIndex)
426 {
428 &theInfo,
429 anIndex,
430 &aCircles[anIndex],
431 &aCount));
432 }
433 return aCircles;
434 }
435
438 static std::vector<Curve2d> blend_arcs(occtl_graph_t* graph,
439 const occtl_curve2d_blend_arc_info_t& theInfo)
440 {
441 size_t aCount = 0;
442 check(::occtl_curve2d_create_blend_arc(graph, &theInfo, 0, nullptr, &aCount));
443 std::vector<Curve2d> anArcs;
444 anArcs.reserve(aCount);
445 for (size_t anIndex = 0; anIndex < aCount; ++anIndex)
446 {
447 occtl_rep_id_t anArc{};
448 check(::occtl_curve2d_create_blend_arc(graph, &theInfo, anIndex, &anArc, &aCount));
449 anArcs.emplace_back(graph, anArc);
450 }
451 return anArcs;
452 }
453
456 static std::vector<occtl_geom2d_line_t> lines_tangent_to_two(
459 {
460 size_t aCount = 0;
461 check(::occtl_curve2d_create_tangent_line_to_two(graph, &theInfo, 0, nullptr, &aCount));
462 std::vector<occtl_geom2d_line_t> aLines(aCount);
463 for (size_t anIndex = 0; anIndex < aCount; ++anIndex)
464 {
466 &theInfo,
467 anIndex,
468 &aLines[anIndex],
469 &aCount));
470 }
471 return aLines;
472 }
473
476 static std::vector<occtl_geom2d_line_t> lines_tangent_through_point(
479 {
480 size_t aCount = 0;
481 check(::occtl_curve2d_create_tangent_line_through_point(graph, &theInfo, 0, nullptr, &aCount));
482 std::vector<occtl_geom2d_line_t> aLines(aCount);
483 for (size_t anIndex = 0; anIndex < aCount; ++anIndex)
484 {
486 &theInfo,
487 anIndex,
488 &aLines[anIndex],
489 &aCount));
490 }
491 return aLines;
492 }
493
496 static std::vector<occtl_geom2d_line_t> lines_tangent_with_angle(
499 {
500 size_t aCount = 0;
501 check(::occtl_curve2d_create_tangent_line_with_angle(graph, theInfo, 0, nullptr, &aCount));
502 std::vector<occtl_geom2d_line_t> aLines(aCount);
503 for (size_t anIndex = 0; anIndex < aCount; ++anIndex)
504 {
506 theInfo,
507 anIndex,
508 &aLines[anIndex],
509 &aCount));
510 }
511 return aLines;
512 }
513
516 static std::vector<occtl_geom2d_circle_t> circles_tangent_to_three(
519 {
520 size_t aCount = 0;
521 check(::occtl_curve2d_create_tangent_circle_to_three(graph, &theInfo, 0, nullptr, &aCount));
522 std::vector<occtl_geom2d_circle_t> aCircles(aCount);
523 for (size_t anIndex = 0; anIndex < aCount; ++anIndex)
524 {
526 &theInfo,
527 anIndex,
528 &aCircles[anIndex],
529 &aCount));
530 }
531 return aCircles;
532 }
533
536 static std::vector<occtl_geom2d_circle_t> circles_tangent_fixed_center(
539 {
540 size_t aCount = 0;
541 check(::occtl_curve2d_create_tangent_circle_fixed_center(graph, &theInfo, 0, nullptr, &aCount));
542 std::vector<occtl_geom2d_circle_t> aCircles(aCount);
543 for (size_t anIndex = 0; anIndex < aCount; ++anIndex)
544 {
546 &theInfo,
547 anIndex,
548 &aCircles[anIndex],
549 &aCount));
550 }
551 return aCircles;
552 }
553
556 static std::vector<occtl_geom2d_circle_t> circles_tangent_center_on_curve(
559 {
560 size_t aCount = 0;
561 check(
562 ::occtl_curve2d_create_tangent_circle_center_on_curve(graph, theInfo, 0, nullptr, &aCount));
563 std::vector<occtl_geom2d_circle_t> aCircles(aCount);
564 for (size_t anIndex = 0; anIndex < aCount; ++anIndex)
565 {
567 theInfo,
568 anIndex,
569 &aCircles[anIndex],
570 &aCount));
571 }
572 return aCircles;
573 }
574
577 static std::vector<occtl_geom2d_circle_t> circles_tangent_on_curve_radius(
580 {
581 size_t aCount = 0;
582 check(
583 ::occtl_curve2d_create_tangent_circle_on_curve_radius(graph, theInfo, 0, nullptr, &aCount));
584 std::vector<occtl_geom2d_circle_t> aCircles(aCount);
585 for (size_t anIndex = 0; anIndex < aCount; ++anIndex)
586 {
588 theInfo,
589 anIndex,
590 &aCircles[anIndex],
591 &aCount));
592 }
593 return aCircles;
594 }
595
599 {
600 occtl_rep_id_t aId{};
601 check(::occtl_curve2d_create_ellipse(graph, theEllipse, &aId));
602 return Curve2d(graph, aId);
603 }
604
608 {
609 occtl_rep_id_t aId{};
610 check(::occtl_curve2d_create_hyperbola(graph, theHyperbola, &aId));
611 return Curve2d(graph, aId);
612 }
613
617 {
618 occtl_rep_id_t aId{};
619 check(::occtl_curve2d_create_parabola(graph, theParabola, &aId));
620 return Curve2d(graph, aId);
621 }
622
627 {
628 occtl_rep_id_t aId{};
630 return Curve2d(graph, aId);
631 }
632
637 {
638 occtl_rep_id_t aId{};
639 check(::occtl_curve2d_create_bezier(graph, &theInfo, &aId));
640 return Curve2d(graph, aId);
641 }
642
647 {
648 occtl_rep_id_t aId{};
650 return Curve2d(graph, aId);
651 }
652
657 {
658 occtl_rep_id_t aId{};
659 check(::occtl_curve2d_create_offset(graph, &theInfo, &aId));
660 return Curve2d(graph, aId);
661 }
662
665 std::vector<Curve2d> to_bezier_segments(
666 const occtl_curve_bezier_segments_options_t* theOptions = nullptr) const;
667
670 occtl_point2_t eval_d0(const double theU) const
671 {
672 occtl_point2_t aP{};
673 check(::occtl_curve2d_eval_d0(myGraph, myId, theU, &aP));
674 return aP;
675 }
676
679 std::pair<occtl_point2_t, occtl_vector2_t> eval_d1(const double theU) const
680 {
681 occtl_point2_t aP{};
682 occtl_vector2_t aD1{};
683 check(::occtl_curve2d_eval_d1(myGraph, myId, theU, &aP, &aD1));
684 return {aP, aD1};
685 }
686
689 std::tuple<occtl_point2_t, occtl_vector2_t, occtl_vector2_t> eval_d2(const double theU) const
690 {
691 occtl_point2_t aP{};
692 occtl_vector2_t aD1{}, aD2{};
693 check(::occtl_curve2d_eval_d2(myGraph, myId, theU, &aP, &aD1, &aD2));
694 return {aP, aD1, aD2};
695 }
696
699 std::tuple<occtl_point2_t, occtl_vector2_t, occtl_vector2_t, occtl_vector2_t> eval_d3(
700 const double theU) const
701 {
702 occtl_point2_t aP{};
703 occtl_vector2_t aD1{}, aD2{}, aD3{};
704 check(::occtl_curve2d_eval_d3(myGraph, myId, theU, &aP, &aD1, &aD2, &aD3));
705 return {aP, aD1, aD2, aD3};
706 }
707
710 occtl_vector2_t eval_dn(const double theU, const int32_t theN) const
711 {
712 occtl_vector2_t aDN{};
713 check(::occtl_curve2d_eval_dn(myGraph, myId, theU, theN, &aDN));
714 return aDN;
715 }
716
717private:
718 occtl_graph_t* myGraph;
719 occtl_rep_id_t myId;
720};
721
723{
724 double u_first;
725 double u_last;
726};
727
729{
730 double offset;
731};
732
734{
735 double aU0 = 0.0;
736 double aU1 = 0.0;
737 check(::occtl_curve2d_as_trimmed(myGraph, myId, &aU0, &aU1));
738 return {aU0, aU1};
739}
740
742{
743 double aOff = 0.0;
744 check(::occtl_curve2d_as_offset(myGraph, myId, &aOff));
745 return {aOff};
746}
747
755{
757
758 int32_t degree() const noexcept { return raw.degree; }
759
760 bool is_rational() const noexcept { return raw.is_rational != 0; }
761
762 bool is_periodic() const noexcept { return raw.is_periodic != 0; }
763
764 bool is_closed() const noexcept { return raw.is_closed != 0; }
765
766 occtl_geom_continuity_t continuity() const noexcept
767 {
768 return static_cast<occtl_geom_continuity_t>(raw.continuity);
769 }
770
771 size_t pole_count() const noexcept { return raw.pole_count; }
772
773 size_t knot_count() const noexcept { return raw.knot_count; }
774
775 size_t flat_knot_count() const noexcept { return raw.flat_knot_count; }
776
777#if OCCTL_HPP_HAS_SPAN
778 std::span<const occtl_point2_t> poles() const noexcept { return {raw.poles, raw.pole_count}; }
779
780 std::span<const double> weights() const noexcept
781 {
782 return raw.weights ? std::span<const double>{raw.weights, raw.pole_count}
783 : std::span<const double>{};
784 }
785
786 std::span<const double> knots() const noexcept { return {raw.knots, raw.knot_count}; }
787
788 std::span<const int32_t> multiplicities() const noexcept
789 {
790 return {raw.multiplicities, raw.knot_count};
791 }
792
793 std::span<const double> flat_knots() const noexcept
794 {
795 return {raw.flat_knots, raw.flat_knot_count};
796 }
797#else
798 const occtl_point2_t* poles() const noexcept { return raw.poles; }
799
800 const double* weights() const noexcept { return raw.weights; }
801
802 const double* knots() const noexcept { return raw.knots; }
803
804 const int32_t* multiplicities() const noexcept { return raw.multiplicities; }
805
806 const double* flat_knots() const noexcept { return raw.flat_knots; }
807#endif
808};
809
811{
812 BSplineView aView{};
813 aView.raw = OCCTL_CURVE2D_BSPLINE_INIT;
814 check(::occtl_curve2d_as_bspline(myGraph, myId, &aView.raw));
815 return aView;
816}
817
818inline std::vector<Curve2d> Curve2d::to_bezier_segments(
819 const occtl_curve_bezier_segments_options_t* theOptions) const
820{
821 occtl_rep_id_t* aIds = nullptr;
822 size_t aNb = 0;
823 check(::occtl_curve2d_to_bezier_segments(myGraph, myId, theOptions, &aIds, &aNb));
824 std::vector<Curve2d> aResult;
825 aResult.reserve(aNb);
826 for (size_t anI = 0; anI < aNb; ++anI)
827 {
828 aResult.emplace_back(myGraph, aIds[anI]);
829 }
830 std::free(aIds);
831 return aResult;
832}
833
834} // namespace occtl
835
836#endif // OCCTL_HPP_CURVES2D_HPP
Non-owning reference to a 2D geometric curve stored in a graph.
Definition curves2d.hpp:56
int32_t bezier_is_rational() const
Returns 1 when the Bezier curve is rational, 0 otherwise.
Definition curves2d.hpp:324
double length() const
Returns the curve length over its full parameter range.
Definition curves2d.hpp:132
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.
Definition curves2d.hpp:85
static std::vector< occtl_geom2d_line_t > lines_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.
Definition curves2d.hpp:456
std::vector< double > bspline_flat_knots() const
Copies the expanded (flat) knot sequence into a vector.
Definition curves2d.hpp:377
std::vector< occtl_point2_t > bspline_poles() const
Copies all poles into a std::vector<occtl_point2_t>.
Definition curves2d.hpp:333
occtl_vector2_t eval_dn(const double theU, const int32_t theN) const
Returns the N-th derivative vector at theU.
Definition curves2d.hpp:710
static Curve2d from_circle(occtl_graph_t *graph, const occtl_geom2d_circle_t &theCircle)
Constructs a 2D curve from a circle.
Definition curves2d.hpp:408
occtl_geom2d_line_t as_line() const
Extracts the underlying line.
Definition curves2d.hpp:204
OffsetView as_offset() const
Extracts the scalar offset of an offset curve.
Definition curves2d.hpp:741
std::vector< int32_t > bspline_multiplicities() const
Copies all knot multiplicities into a std::vector<int32_t>.
Definition curves2d.hpp:355
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.
Definition curves2d.hpp:635
static Curve2d from_offset(occtl_graph_t *graph, const occtl_curve2d_offset_create_info_t &theInfo)
Constructs an offset 2D curve.
Definition curves2d.hpp:655
occtl_geom2d_circle_t as_circle() const
Extracts the underlying circle.
Definition curves2d.hpp:213
static std::vector< occtl_geom2d_circle_t > circles_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.
Definition curves2d.hpp:577
std::vector< double > bspline_knots() const
Copies all distinct knot values into a std::vector<double>.
Definition curves2d.hpp:344
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.
Definition curves2d.hpp:625
std::tuple< occtl_point2_t, occtl_vector2_t, occtl_vector2_t, occtl_vector2_t > eval_d3(const double theU) const
Evaluates point, first, second, and third derivatives at theU.
Definition curves2d.hpp:699
static Curve2d from_line(occtl_graph_t *graph, const occtl_geom2d_line_t &theLine)
Constructs a 2D curve from a line.
Definition curves2d.hpp:399
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).
Definition curves2d.hpp:59
int32_t bezier_degree() const
Returns the Bezier polynomial degree.
Definition curves2d.hpp:306
double parameter_of_point(const Point2 &thePoint) const
Returns the parameter on the 2D curve nearest to a given point.
Definition curves2d.hpp:152
static std::vector< occtl_geom2d_circle_t > circles_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.
Definition curves2d.hpp:417
size_t bspline_knot_count() const
Returns the number of distinct knot values.
Definition curves2d.hpp:288
int32_t is_closed() const
Returns 1 when the curve is closed, 0 otherwise.
Definition curves2d.hpp:179
static std::vector< occtl_geom2d_line_t > lines_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.
Definition curves2d.hpp:496
size_t bezier_pole_count() const
Returns the number of Bezier poles.
Definition curves2d.hpp:315
static std::vector< occtl_geom2d_circle_t > circles_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.
Definition curves2d.hpp:516
occtl_point2_t eval_d0(const double theU) const
Evaluates the 2D curve point at parameter theU.
Definition curves2d.hpp:670
size_t bspline_pole_count() const
Returns the number of poles.
Definition curves2d.hpp:279
occtl_graph_t * graph() const noexcept
Borrows it — returns the graph pointer.
Definition curves2d.hpp:69
occtl_geom2d_ellipse_t as_ellipse() const
Extracts the underlying ellipse.
Definition curves2d.hpp:222
occtl_curve_kind_t kind() const
Returns the kind of geometry.
Definition curves2d.hpp:161
std::pair< occtl_point2_t, occtl_vector2_t > eval_d1(const double theU) const
Evaluates point and first derivative at theU.
Definition curves2d.hpp:679
Curve2d rotated(double theAngle) const
Returns a rotated copy of this curve stored in the same graph.
Definition curves2d.hpp:114
occtl_geom_continuity_t continuity() const
Returns the geometric continuity class.
Definition curves2d.hpp:188
const occtl_point2_t * bspline_poles_view(size_t &theCount) const
Returns a zero-copy view of the poles array.
Definition curves2d.hpp:390
static std::vector< occtl_geom2d_circle_t > circles_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.
Definition curves2d.hpp:556
static Curve2d from_trimmed(occtl_graph_t *graph, const occtl_curve_trimmed_create_info_t &theInfo)
Constructs a trimmed 2D curve.
Definition curves2d.hpp:645
int32_t bspline_degree() const
Returns the polynomial degree.
Definition curves2d.hpp:270
static std::vector< occtl_geom2d_circle_t > circles_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.
Definition curves2d.hpp:536
occtl_geom2d_parabola_t as_parabola() const
Extracts the underlying parabola.
Definition curves2d.hpp:240
int32_t bspline_is_rational() const
Returns 1 when the B-spline is rational (NURBS), 0 otherwise.
Definition curves2d.hpp:297
std::vector< double > bspline_weights() const
Copies all weights into a std::vector<double>.
Definition curves2d.hpp:366
static Curve2d from_hyperbola(occtl_graph_t *graph, const occtl_geom2d_hyperbola_t &theHyperbola)
Constructs a 2D curve from a hyperbola.
Definition curves2d.hpp:607
Curve2d reversed() const
Returns a reversed copy of this curve stored in the same graph.
Definition curves2d.hpp:76
std::vector< Curve2d > to_bezier_segments(const occtl_curve_bezier_segments_options_t *theOptions=nullptr) const
Decomposes this 2D curve into adjacent Bezier curve segments.
Definition curves2d.hpp:818
static std::vector< occtl_geom2d_line_t > lines_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.
Definition curves2d.hpp:476
void parameter_range(double &theUMin, double &theUMax) const
Returns the parameter range [u_min, u_max] via out-parameters.
Definition curves2d.hpp:197
static Curve2d from_parabola(occtl_graph_t *graph, const occtl_geom2d_parabola_t &theParabola)
Constructs a 2D curve from a parabola.
Definition curves2d.hpp:616
occtl_rep_id_t id() const noexcept
Returns the representation id.
Definition curves2d.hpp:72
std::pair< double, double > project_point(const Point2 &thePoint) const
Projects a 2D point onto the curve.
Definition curves2d.hpp:142
std::tuple< occtl_point2_t, occtl_vector2_t, occtl_vector2_t > eval_d2(const double theU) const
Evaluates point, first, and second derivatives at theU.
Definition curves2d.hpp:689
occtl_geom2d_hyperbola_t as_hyperbola() const
Extracts the underlying hyperbola.
Definition curves2d.hpp:231
BSplineView as_bspline() const
Returns a §10.5 aggregate inspection view of a 2D B-spline curve.
Definition curves2d.hpp:810
static Curve2d from_ellipse(occtl_graph_t *graph, const occtl_geom2d_ellipse_t &theEllipse)
Constructs a 2D curve from an ellipse.
Definition curves2d.hpp:598
TrimmedView as_trimmed() const
Extracts the parameter bounds from a trimmed curve.
Definition curves2d.hpp:733
Curve2d scaled(const Point2 &theOrigin, double theFactor) const
Returns a scaled copy of this curve stored in the same graph.
Definition curves2d.hpp:123
static std::vector< Curve2d > blend_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.
Definition curves2d.hpp:438
Curve2d translated(const Vector2 &theDelta) const
Returns a translated copy of this curve stored in the same graph.
Definition curves2d.hpp:105
int32_t is_periodic() const
Returns 1 when the curve is periodic, 0 otherwise.
Definition curves2d.hpp:170
C++ veneer for the core module.
void check(const ::occtl_status_t theStatus)
Throw on non-OK; otherwise a no-op.
Definition core.hpp:85
C++ veneer for the geom module.
OCCT-Light: 2D curve (pcurve) API on BRepGraph.
occtl_status_t occtl_curve2d_eval_d1(const occtl_graph_t *graph, occtl_rep_id_t curve_id, double u, occtl_point2_t *out_point, occtl_vector2_t *out_d1)
occtl_status_t occtl_curve2d_transformed(occtl_graph_t *graph, occtl_rep_id_t curve_id, double translate_x, double translate_y, double rotate_angle, double scale_x, double scale_y, occtl_rep_id_t *out_id)
occtl_status_t occtl_curve2d_bspline_knot_count(const occtl_graph_t *graph, occtl_rep_id_t curve_id, size_t *out_count)
occtl_status_t occtl_curve2d_bspline_poles(const occtl_graph_t *graph, occtl_rep_id_t curve_id, occtl_point2_t *out_buf, size_t capacity, size_t *out_count)
occtl_status_t occtl_curve2d_is_closed(const occtl_graph_t *graph, occtl_rep_id_t curve_id, int32_t *out_is_closed)
occtl_status_t occtl_curve2d_bspline_flat_knots(const occtl_graph_t *graph, occtl_rep_id_t curve_id, double *out_buf, size_t capacity, size_t *out_count)
occtl_status_t occtl_curve2d_create_tangent_circle_to_three(occtl_graph_t *graph, const occtl_curve2d_circle_tangent_to_three_info_t *info, size_t solution_index, occtl_geom2d_circle_t *out_circle, size_t *out_count)
occtl_status_t occtl_curve2d_length(const occtl_graph_t *graph, occtl_rep_id_t curve_id, double *out_length)
occtl_status_t occtl_curve2d_as_ellipse(const occtl_graph_t *graph, occtl_rep_id_t curve_id, occtl_geom2d_ellipse_t *out_ellipse)
occtl_status_t occtl_curve2d_create_tangent_line_through_point(occtl_graph_t *graph, const occtl_curve2d_line_tangent_through_point_info_t *info, size_t solution_index, occtl_geom2d_line_t *out_line, size_t *out_count)
occtl_status_t occtl_curve2d_is_periodic(const occtl_graph_t *graph, occtl_rep_id_t curve_id, int32_t *out_is_periodic)
occtl_status_t occtl_curve2d_create_tangent_circle_to_two_radius(occtl_graph_t *graph, const occtl_curve2d_circle_tangent_to_two_radius_info_t *info, size_t solution_index, occtl_geom2d_circle_t *out_circle, size_t *out_count)
occtl_status_t occtl_curve2d_bspline_pole_count(const occtl_graph_t *graph, occtl_rep_id_t curve_id, size_t *out_count)
occtl_status_t occtl_curve2d_bezier_is_rational(const occtl_graph_t *graph, occtl_rep_id_t curve_id, int32_t *out_is_rational)
occtl_status_t occtl_curve2d_as_parabola(occtl_graph_t *graph, occtl_rep_id_t curve_id, occtl_geom2d_parabola_t *out_parabola)
occtl_status_t occtl_curve2d_as_circle(const occtl_graph_t *graph, occtl_rep_id_t curve_id, occtl_geom2d_circle_t *out_circle)
occtl_status_t occtl_curve2d_reverse(occtl_graph_t *graph, occtl_rep_id_t curve_id, occtl_rep_id_t *out_id)
occtl_status_t occtl_curve2d_create_hyperbola(occtl_graph_t *graph, occtl_geom2d_hyperbola_t hyperbola, occtl_rep_id_t *out_id)
occtl_status_t occtl_curve2d_create_parabola(occtl_graph_t *graph, occtl_geom2d_parabola_t parabola, occtl_rep_id_t *out_id)
occtl_status_t occtl_curve2d_as_line(const occtl_graph_t *graph, occtl_rep_id_t curve_id, occtl_geom2d_line_t *out_line)
occtl_status_t occtl_curve2d_bspline_weights(const occtl_graph_t *graph, occtl_rep_id_t curve_id, double *out_buf, size_t capacity, size_t *out_count)
occtl_status_t occtl_curve2d_as_hyperbola(occtl_graph_t *graph, occtl_rep_id_t curve_id, occtl_geom2d_hyperbola_t *out_hyperbola)
occtl_status_t occtl_curve2d_bspline_is_rational(const occtl_graph_t *graph, occtl_rep_id_t curve_id, int32_t *out_is_rational)
occtl_status_t occtl_curve2d_create_tangent_circle_on_curve_radius(occtl_graph_t *graph, const occtl_curve2d_circle_tangent_on_curve_radius_info_t *info, size_t solution_index, occtl_geom2d_circle_t *out_circle, size_t *out_count)
occtl_status_t occtl_curve2d_create_bspline(occtl_graph_t *graph, const occtl_curve2d_bspline_create_info_t *info, occtl_rep_id_t *out_id)
occtl_status_t occtl_curve2d_parameter_range(const occtl_graph_t *graph, occtl_rep_id_t curve_id, double *out_u_min, double *out_u_max)
occtl_status_t occtl_curve2d_as_bspline(const occtl_graph_t *graph, occtl_rep_id_t curve_id, occtl_curve2d_bspline_t *out)
occtl_status_t occtl_curve2d_create_blend_arc(occtl_graph_t *graph, const occtl_curve2d_blend_arc_info_t *info, size_t solution_index, occtl_rep_id_t *out_id, size_t *out_count)
occtl_status_t occtl_curve2d_as_offset(const occtl_graph_t *graph, occtl_rep_id_t curve_id, double *out_offset)
occtl_status_t occtl_curve2d_to_bezier_segments(occtl_graph_t *graph, occtl_rep_id_t curve_id, const occtl_curve_bezier_segments_options_t *options, occtl_rep_id_t **out_segments, size_t *out_count)
occtl_status_t occtl_curve2d_create_circle(occtl_graph_t *graph, occtl_geom2d_circle_t circle, occtl_rep_id_t *out_id)
occtl_status_t occtl_curve2d_kind(const occtl_graph_t *graph, occtl_rep_id_t curve_id, occtl_curve_kind_t *out_kind)
occtl_status_t occtl_curve2d_create_ellipse(occtl_graph_t *graph, occtl_geom2d_ellipse_t ellipse, occtl_rep_id_t *out_id)
occtl_status_t occtl_curve2d_continuity(occtl_graph_t *graph, occtl_rep_id_t curve_id, occtl_geom_continuity_t *out_continuity)
occtl_status_t occtl_curve2d_create_line(occtl_graph_t *graph, occtl_geom2d_line_t line, occtl_rep_id_t *out_id)
occtl_status_t occtl_curve2d_translated(occtl_graph_t *graph, occtl_rep_id_t curve_id, occtl_vector2_t delta, occtl_rep_id_t *out_id)
occtl_status_t occtl_curve2d_eval_d2(const occtl_graph_t *graph, occtl_rep_id_t curve_id, double u, occtl_point2_t *out_point, occtl_vector2_t *out_d1, occtl_vector2_t *out_d2)
occtl_status_t occtl_curve2d_bezier_pole_count(const occtl_graph_t *graph, occtl_rep_id_t curve_id, size_t *out_count)
occtl_status_t occtl_curve2d_scaled(occtl_graph_t *graph, occtl_rep_id_t curve_id, occtl_point2_t origin, double factor, occtl_rep_id_t *out_id)
occtl_status_t occtl_curve2d_create_tangent_line_to_two(occtl_graph_t *graph, const occtl_curve2d_line_tangent_to_two_info_t *info, size_t solution_index, occtl_geom2d_line_t *out_line, size_t *out_count)
occtl_status_t occtl_curve2d_project_point(const occtl_graph_t *graph, occtl_rep_id_t curve_id, occtl_point2_t point, double *out_param, double *out_distance)
occtl_status_t occtl_curve2d_bspline_degree(const occtl_graph_t *graph, occtl_rep_id_t curve_id, int32_t *out_degree)
occtl_status_t occtl_curve2d_rotated(occtl_graph_t *graph, occtl_rep_id_t curve_id, double angle, occtl_rep_id_t *out_id)
occtl_status_t occtl_curve2d_bspline_knots(const occtl_graph_t *graph, occtl_rep_id_t curve_id, double *out_buf, size_t capacity, size_t *out_count)
occtl_status_t occtl_curve2d_eval_dn(const occtl_graph_t *graph, occtl_rep_id_t curve_id, double u, int32_t n, occtl_vector2_t *out_derivative)
occtl_status_t occtl_curve2d_bspline_multiplicities(const occtl_graph_t *graph, occtl_rep_id_t curve_id, int32_t *out_buf, size_t capacity, size_t *out_count)
occtl_status_t occtl_curve2d_as_trimmed(const occtl_graph_t *graph, occtl_rep_id_t curve_id, double *out_u_first, double *out_u_last)
occtl_status_t occtl_curve2d_bezier_degree(const occtl_graph_t *graph, occtl_rep_id_t curve_id, int32_t *out_degree)
occtl_status_t occtl_curve2d_create_trimmed(occtl_graph_t *graph, const occtl_curve_trimmed_create_info_t *info, occtl_rep_id_t *out_id)
occtl_status_t occtl_curve2d_eval_d0(const occtl_graph_t *graph, occtl_rep_id_t curve_id, double u, occtl_point2_t *out_point)
occtl_status_t occtl_curve2d_parameter_of_point(const occtl_graph_t *graph, occtl_rep_id_t curve_id, occtl_point2_t point, double *out_param)
occtl_status_t occtl_curve2d_eval_d3(const occtl_graph_t *graph, occtl_rep_id_t curve_id, double u, occtl_point2_t *out_point, occtl_vector2_t *out_d1, occtl_vector2_t *out_d2, occtl_vector2_t *out_d3)
occtl_status_t occtl_curve2d_bspline_poles_view(occtl_graph_t *graph, occtl_rep_id_t curve_id, const occtl_point2_t **out_data, size_t *out_count)
occtl_status_t occtl_curve2d_create_tangent_line_with_angle(occtl_graph_t *graph, const occtl_curve2d_line_tangent_with_angle_info_t *info, size_t solution_index, occtl_geom2d_line_t *out_line, size_t *out_count)
occtl_status_t occtl_curve2d_create_tangent_circle_fixed_center(occtl_graph_t *graph, const occtl_curve2d_circle_tangent_fixed_center_info_t *info, size_t solution_index, occtl_geom2d_circle_t *out_circle, size_t *out_count)
occtl_status_t occtl_curve2d_create_tangent_circle_center_on_curve(occtl_graph_t *graph, const occtl_curve2d_circle_tangent_center_on_curve_info_t *info, size_t solution_index, occtl_geom2d_circle_t *out_circle, size_t *out_count)
occtl_status_t occtl_curve2d_create_bezier(occtl_graph_t *graph, const occtl_curve2d_bezier_create_info_t *info, occtl_rep_id_t *out_id)
occtl_status_t occtl_curve2d_create_offset(occtl_graph_t *graph, const occtl_curve2d_offset_create_info_t *info, occtl_rep_id_t *out_id)
enum occtl_curve2d_tangency_qualifier occtl_curve2d_tangency_qualifier_t
enum occtl_curve_kind occtl_curve_kind_t
enum occtl_geom_continuity occtl_geom_continuity_t
struct occtl_graph occtl_graph_t
Definition occtl_topo_types.h:152
Aggregate inspection view of a 2D B-spline curve (§10.5).
Definition curves2d.hpp:755
Definition curves2d.hpp:729
Definition curves2d.hpp:723
2D point value type. Mirrors occtl_point2_t with STL-flavoured access.
Definition geom.hpp:38
const occtl_point2_t & c_type() const noexcept
Borrows-it view of the underlying C value type, for direct ABI calls.
Definition geom.hpp:58
2D free-vector value type. Mirrors occtl_vector2_t.
Definition geom.hpp:128
const occtl_vector2_t & c_type() const noexcept
Borrows-it view of the underlying C value type.
Definition geom.hpp:148
Definition occtl_curves2d.h:867
Definition occtl_curves2d.h:93
Definition occtl_curves2d.h:812
Definition occtl_curves2d.h:1667
const occtl_point2_t * poles
Definition occtl_curves2d.h:1684
const double * flat_knots
Definition occtl_curves2d.h:1689
const int32_t * multiplicities
Definition occtl_curves2d.h:1688
const double * weights
Definition occtl_curves2d.h:1685
int32_t is_periodic
Definition occtl_curves2d.h:1673
size_t knot_count
Definition occtl_curves2d.h:1677
int32_t is_rational
Definition occtl_curves2d.h:1672
size_t pole_count
Definition occtl_curves2d.h:1676
const double * knots
Definition occtl_curves2d.h:1687
size_t flat_knot_count
Definition occtl_curves2d.h:1678
int32_t degree
Definition occtl_curves2d.h:1671
int32_t continuity
Definition occtl_curves2d.h:1675
int32_t is_closed
Definition occtl_curves2d.h:1674
Definition occtl_curves2d.h:294
Definition occtl_curves2d.h:247
Definition occtl_curves2d.h:170
Definition occtl_curves2d.h:133
Definition occtl_curves2d.h:205
Definition occtl_curves2d.h:941
Definition occtl_curves_common.h:119
Definition occtl_curves_common.h:86
Definition occtl_geom.h:874
Definition occtl_geom.h:885
Definition occtl_geom.h:895
Definition occtl_geom.h:866
Definition occtl_geom.h:905
Definition occtl_geom.h:49
Definition occtl_core.h:251
uint64_t bits
Definition occtl_core.h:252
Definition occtl_geom.h:56