-
Notifications
You must be signed in to change notification settings - Fork 7
/
PyAcGe.cpp
1605 lines (1464 loc) · 70.5 KB
/
PyAcGe.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
863
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "stdafx.h"
#include "PyAcGe.h"
#include "PyGeEntity3d.h"
#include "PyGePointEnt3d.h"
#include "PyGeSurface.h"
#include "PyGePlanarEnt.h"
#include "PyGePlane.h"
#include "PyGeInterval.h"
#include "PyGeEntity2d.h"
#include "PyGeBoundBlock2d.h"
#include "PyGeCurve2d.h"
#include "PyGeCurveCurveInt2d.h"
#include "PyGePointEnt2d.h"
#include "PyGeClipBoundary2d.h"
#include "PyGeLinearEnt2d.h"
#include "PyGeSplineEnt2d.h"
#include "PyGeBoundBlock3d.h"
#include "PyGeLinearEnt3d.h"
#include "PyGeSplineEnt3d.h"
#include "PyGeCurveCurveInt3d.h"
#include "PyGeCurveSurfInt.h"
#include "PyGeSurfSurfInt.h"
#include "PyGeKnotVector.h"
using namespace boost::python;
//---------------------------------------------------------------------------------------------------------------
// hashing
// This gives users control over how hashing behaves
// Python's dictionary, set calls __hash__, and should be equivalent to equals
// AcGePoint3d == AcGePoint3d uses tol, not perfect but good enough
// tiny overhead as it's another C <-> Python call.
inline double roundPointComponentToGTol(double value)
{
const double precision = AcGeContext::gTol.equalPoint();
return std::round(value / precision) * precision;
}
inline double roundVectorComponentToGTOL(double value)
{
const double precision = AcGeContext::gTol.equalVector();
return std::round(value / precision) * precision;
}
inline std::size_t AcGePoint2dHash(const AcGePoint2d& p)
{
std::size_t seed = 0;
boost::hash_combine(seed, roundPointComponentToGTol(p.x));
boost::hash_combine(seed, roundPointComponentToGTol(p.y));
return seed;
}
inline std::size_t AcGeVector2dHash(const AcGeVector2d& p)
{
std::size_t seed = 0;
boost::hash_combine(seed, roundVectorComponentToGTOL(p.x));
boost::hash_combine(seed, roundVectorComponentToGTOL(p.y));
return seed;
}
inline std::size_t AcGePoint3dHash(const AcGePoint3d& p)
{
std::size_t seed = 0;
boost::hash_combine(seed, roundPointComponentToGTol(p.x));
boost::hash_combine(seed, roundPointComponentToGTol(p.y));
boost::hash_combine(seed, roundPointComponentToGTol(p.z));
return seed;
}
inline std::size_t AcGeVector3dHash(const AcGeVector3d& p)
{
std::size_t seed = 0;
boost::hash_combine(seed, roundVectorComponentToGTOL(p.x));
boost::hash_combine(seed, roundVectorComponentToGTOL(p.y));
boost::hash_combine(seed, roundVectorComponentToGTOL(p.z));
return seed;
}
//---------------------------------------------------------------------------------------------------------------
//AcGeScale2d
double AcGeScale2dGetItem(const AcGeScale2d& p, int idx)
{
switch (idx)
{
case 0:
return p.sx;
case 1:
return p.sy;
default:
throw std::out_of_range{ "IndexError " };
}
}
void AcGeScale2dSetItem(AcGeScale2d& p, int idx, double val)
{
switch (idx)
{
case 0:
p.sx = val;
break;
case 1:
p.sy = val;
break;
default:
throw std::out_of_range{ "IndexError " };
}
}
std::string AcGeScale2dToString(const AcGeScale2d& s)
{
return std::format("({:.14f},{:.14f})", s.sx, s.sy);
}
std::string AcGeScale2dToStringRepr(const AcGeScale2d& s)
{
return std::format("<{}.Scale2d({:.14f},{:.14f})>", PyGeNamespace, s.sx, s.sy);
}
void makePyGeScale2dWrapper()
{
constexpr const std::string_view ctords = "Overloads:\n"
"- None: Any\n"
"- factor: float\n"
"- xFactor: float, yFactor: float\n";
constexpr const std::string_view setToProductOverloads = "Overloads:\n"
"- sclVec1: PyGe.Scale2d, s: float\n"
"- sclVec1: PyGe.Scale2d, ssclVec2: PyGe.Scale2d\n";
PyDocString DS("Scale2d");
class_<AcGeScale2d>("Scale2d")
.def(init<>())
.def(init<double>())
.def(init<double, double>(DS.CTOR(ctords)))
#if !defined(_BRXTARGET250)
.def("preMultBy", &AcGeScale2d::preMultBy, return_self<>(), DS.ARGS({ "left: PyGe.Scale2d" }))
.def("postMultBy", &AcGeScale2d::postMultBy, return_self<>(), DS.ARGS({ "right: PyGe.Scale2d" }))
.def<AcGeScale2d& (AcGeScale2d::*)(const AcGeScale2d&, double)>("setToProduct", &AcGeScale2d::setToProduct, return_self<>())
.def<AcGeScale2d& (AcGeScale2d::*)(const AcGeScale2d&, const AcGeScale2d&)>("setToProduct", &AcGeScale2d::setToProduct, return_self<>(), DS.OVRL(setToProductOverloads))
#endif
.def_readwrite("sx", &AcGeScale2d::sx)
.def_readwrite("sy", &AcGeScale2d::sy)
.def("__eq__", &AcGeScale2d::operator==)
.def("__ne__", &AcGeScale2d::operator!=)
.def<AcGeScale2d(AcGeScale2d::*)(double)const>("__mul__", &AcGeScale2d::operator*, DS.ARGS({ "val: float" }))
.def<AcGeScale2d& (AcGeScale2d::*)(double)>("__imul__", &AcGeScale2d::operator*=, DS.ARGS({ "val: float" }), return_self<>())
.def<AcGeScale2d(AcGeScale2d::*)(const AcGeScale2d&)const>("__mul__", &AcGeScale2d::operator*, DS.ARGS({ "val: PyGe.Scale2d" }))
.def<AcGeScale2d& (AcGeScale2d::*)(const AcGeScale2d&)>("__imul__", &AcGeScale2d::operator*=, DS.ARGS({ "val: PyGe.Scale2d" }), return_self<>())
.def("toString", &AcGeScale2dToString, DS.ARGS())
.def("__str__", &AcGeScale2dToString, DS.ARGS())
.def("__repr__", &AcGeScale2dToStringRepr, DS.ARGS())
.def("__getitem__", &AcGeScale2dGetItem, DS.ARGS({ "idx: int" }))
.def("__setitem__", &AcGeScale2dSetItem, DS.ARGS({ "idx: int","val: float" }))
;
}
//---------------------------------------------------------------------------------------------------------------
//AcGeTol
static AcGeTol getTol()
{
return AcGeContext::gTol;// copy to python doesn't accidentally change it
}
static void setGlobalTol(const AcGeTol& tol)
{
AcGeContext::gTol = tol;
}
void makePyGeTolWrapper()
{
PyDocString DS("Tol");
class_<AcGeTol>("Tol")
.def(init<>(DS.ARGS()))
.def("equalPoint", &AcGeTol::equalPoint, DS.ARGS())
.def("equalVector", &AcGeTol::equalVector, DS.ARGS())
.def("setEqualPoint", &AcGeTol::setEqualPoint, DS.ARGS({ "val : float" }))
.def("setEqualVector", &AcGeTol::setEqualVector, DS.ARGS({ "val : float" }))
.def("setGlobalTol", &setGlobalTol, DS.SARGS({ "val: PyGe.Tol" })).staticmethod("setGlobalTol")
.def("current", &getTol, DS.SARGS()).staticmethod("current")
;
}
struct AutoTol
{
AutoTol()
{
AcGeContext::gTol = getTol();
}
~AutoTol()
{
AcGeContext::gTol = m_tol;
}
double equalPoint()
{
return AcGeContext::gTol.equalPoint();
}
double equalVector()
{
return AcGeContext::gTol.equalVector();
}
void setEqualPoint(double ep)
{
AcGeContext::gTol.setEqualPoint(ep);
}
void setEqualVector(double ev)
{
AcGeContext::gTol.setEqualVector(ev);
}
AcGeTol m_tol = getTol();
};
void makePyGeAutoTolWrapper()
{
PyDocString DS("AutoTol");
class_<AutoTol>("AutoTol")
.def(init<>(DS.ARGS()))
.def("equalPoint", &AutoTol::equalPoint, DS.ARGS())
.def("equalVector", &AutoTol::equalVector, DS.ARGS())
.def("setEqualPoint", &AutoTol::setEqualPoint, DS.ARGS({ "val : float" }))
.def("setEqualVector", &AutoTol::setEqualVector, DS.ARGS({ "val : float" }))
;
}
//---------------------------------------------------------------------------------------------------------------
//AcGePoint2d
struct AcGePoint2dpickle : boost::python::pickle_suite
{
static boost::python::tuple getinitargs(const AcGePoint2d& p)
{
return boost::python::make_tuple(p.x, p.y);
}
};
boost::python::tuple AcGePoint2dToTuple(const AcGePoint2d& p)
{
PyAutoLockGIL lock;
return boost::python::make_tuple(p.x, p.y);
}
boost::python::list AcGePoint2dToList(const AcGePoint2d& p)
{
PyAutoLockGIL lock;
boost::python::list pylist;
pylist.append(p.x);
pylist.append(p.y);
return pylist;
}
std::string AcGePoint2dToString(const AcGePoint2d& p)
{
return std::format("({:.14f},{:.14f})", p.x, p.y);
}
std::string AcGePoint2dToStringRepr(const AcGePoint2d& s)
{
return std::format("<{}.Point2d({:.14f},{:.14f})>", PyGeNamespace, s.x, s.y);
}
static AcGePoint2d AcGePoint2dkOrigin()
{
return AcGePoint2d::kOrigin;
}
double AcGePoint2dGetItem(const AcGePoint2d& p, int idx)
{
switch (idx)
{
case 0:
return p.x;
case 1:
return p.y;
default:
throw std::out_of_range{ "IndexError " };
}
}
void AcGePoint2dSetItem(AcGePoint2d& p, int idx, double val)
{
switch (idx)
{
case 0:
p.x = val;
break;
case 1:
p.y = val;
break;
default:
throw std::out_of_range{ "IndexError " };
}
}
static boost::shared_ptr<AcGePoint2d> PyGePoint2dInitTuple(const boost::python::object& iterable)
{
if (extract<AcGePoint2d>(iterable).check())
return boost::shared_ptr<AcGePoint2d>(new AcGePoint2d(extract<AcGePoint2d>(iterable)));
return boost::shared_ptr<AcGePoint2d>(new AcGePoint2d(PyListToAcGePoint2d(iterable)));
}
void makePyGePoint2dWrapper()
{
constexpr const std::string_view ctords = "Overloads:\n"
"- None: Any\n"
"- x: float, y: float\n";
PyDocString DS("Point2d");
class_<AcGePoint2d>("Point2d")
.def(init<>())
.def(init<double, double>(DS.CTOR(ctords)))
.def("setToProduct", &AcGePoint2d::setToProduct, DS.ARGS({ "mat: PyGe.Matrix2d","pt: PyGe.Point2d" }), return_self<>())
.def("transformBy", &AcGePoint2d::transformBy, DS.ARGS({ "xform: PyGe.Matrix2d" }), return_self<>())
.def("rotateBy", &AcGePoint2d::rotateBy, DS.ARGS({ "val: float","pt: PyGe.Point2d=PyGe.Point2d.kOrgin" }), arg("AcGePoint2d") = AcGePoint2dkOrigin(), return_self<>())
.def("mirror", &AcGePoint2d::mirror, DS.ARGS({ "pt: PyGe.Line2d" }), return_self<>())
.def("scaleBy", &AcGePoint2d::scaleBy, DS.ARGS({ "val: float","pt: PyGe.Point2d=PyGe.Point2d.kOrgin" }), arg("AcGePoint2d") = AcGePoint2dkOrigin(), return_self<>())
.def("setToSum", &AcGePoint2d::setToSum, DS.ARGS({ "pt: PyGe.Point2d","vec: PyGe.Vector2d" }), return_self<>())
.def("set", &AcGePoint2d::set, DS.ARGS({ "xx: float", "yy: float" }), return_self<>())
.def("asVector", &AcGePoint2d::asVector, DS.ARGS())
.def("distanceTo", &AcGePoint2d::distanceTo, DS.ARGS({ "pt: PyGe.Point2d" }))
.def("isEqualTo", &AcGePoint2d::isEqualTo, DS.ARGS({ "pt: PyGe.Point2d","tol: PyGe.Tol=None" }), arg("AcGeTol") = getTol())
.def_readwrite("x", &AcGePoint2d::x)
.def_readwrite("y", &AcGePoint2d::y)
.add_static_property("kOrigin", &AcGePoint2dkOrigin, DS.ARGS())
.def("__eq__", &AcGePoint2d::operator==)
.def("__ne__", &AcGePoint2d::operator!=)
.def<AcGePoint2d(AcGePoint2d::*)(double)const>("__mul__", &AcGePoint2d::operator*, DS.ARGS({ "val: float" }))
.def<AcGePoint2d& (AcGePoint2d::*)(double)>("__imul__", &AcGePoint2d::operator*=, DS.ARGS({ "val: float" }), return_self<>())
.def<AcGePoint2d(AcGePoint2d::*)(double)const>("__truediv__", &AcGePoint2d::operator/, DS.ARGS({ "val: float" }))
.def<AcGePoint2d& (AcGePoint2d::*)(double)>("__itruediv__", &AcGePoint2d::operator/=, DS.ARGS({ "val: float" }), return_self<>())
.def<AcGePoint2d(AcGePoint2d::*)(const AcGeVector2d&)const>("__add__", &AcGePoint2d::operator , DS.ARGS({ "vec: PyGe.Vector3d" }))
.def<AcGePoint2d& (AcGePoint2d::*)(const AcGeVector2d&)>("__iadd__", &AcGePoint2d::operator =, DS.ARGS({ "vec: PyGe.Vector3d" }), return_self<>())
.def<AcGePoint2d(AcGePoint2d::*)(const AcGeVector2d&)const>("__sub__", &AcGePoint2d::operator-)
.def<AcGeVector2d(AcGePoint2d::*)(const AcGePoint2d&)const>("__sub__", &AcGePoint2d::operator-, DS.ARGS({ "other: PyGe.Point3d|PyGe.Vector3d" }))
.def<AcGePoint2d& (AcGePoint2d::*)(const AcGeVector2d&)>("__isub__", &AcGePoint2d::operator-=, DS.ARGS({ "vec: PyGe.Vector3d" }), return_self<>())
.def_pickle(AcGePoint2dpickle())
.def("toString", &AcGePoint2dToString, DS.ARGS())
.def("toTuple", &AcGePoint2dToTuple, DS.ARGS())
.def("toList", &AcGePoint2dToList, DS.ARGS())
.def("__str__", &AcGePoint2dToString, DS.ARGS())
.def("__repr__", &AcGePoint2dToStringRepr, DS.ARGS())
.def("__hash__", &AcGePoint2dHash, DS.ARGS())
.def("__getitem__", &AcGePoint2dGetItem, DS.ARGS({ "idx: int" }))
.def("__setitem__", &AcGePoint2dSetItem, DS.ARGS({ "idx: int","val: float" }))
.def("__init__", make_constructor(&PyGePoint2dInitTuple))
;
}
//---------------------------------------------------------------------------------------------------------------
//AcGeVector2d
struct AcGeVector2pickle : boost::python::pickle_suite
{
static boost::python::tuple getinitargs(const AcGeVector2d& p)
{
return boost::python::make_tuple(p.x, p.y);
}
};
boost::python::tuple AcGeVector2ToTuple(const AcGeVector2d& p)
{
PyAutoLockGIL lock;
return boost::python::make_tuple(p.x, p.y);
}
boost::python::list AcGeVector2ToList(const AcGeVector2d& p)
{
PyAutoLockGIL lock;
boost::python::list l;
l.append(p.x);
l.append(p.y);
return l;
}
std::string AcGeVector2ToString(const AcGeVector2d& p)
{
return std::format("({:.14f},{:.14f})", p.x, p.y);
}
std::string AcGeVector2dToStringRepr(const AcGeVector2d& s)
{
return std::format("<{}.Vector2d({:.14f},{:.14f})>", PyGeNamespace, s.x, s.y);
}
static AcGeVector2d AcGeVector2dkIdentity()
{
return AcGeVector2d::kIdentity;
}
static AcGeVector2d AcGeVector2dkXAxis()
{
return AcGeVector2d::kXAxis;
}
static AcGeVector2d AcGeVector2dkYAxis()
{
return AcGeVector2d::kYAxis;
}
static AcGeVector2d rmul_double_AcGeVector2d(const AcGeVector2d& vec, double scl)
{
return scl * vec;
}
static AcGeVector2d rmul_AcGeMatrix2d_AcGeVector2d(const AcGeVector2d& vec, const AcGeMatrix2d& mat)
{
return mat * vec;
}
double AcGeVector2dGetItem(const AcGeVector2d& p, int idx)
{
switch (idx)
{
case 0:
return p.x;
case 1:
return p.y;
default:
throw std::out_of_range{ "IndexError" };
}
}
void AcGeVector2dSetItem(AcGeVector2d& p, int idx, double val)
{
switch (idx)
{
case 0:
p.x = val;
break;
case 1:
p.y = val;
break;
default:
throw std::out_of_range{ "IndexError" };
}
}
static boost::shared_ptr<AcGeVector2d> PyGeVector2dInitTuple(const boost::python::object& iterable)
{
if (extract<AcGeVector2d>(iterable).check())
return boost::shared_ptr<AcGeVector2d>(new AcGeVector2d(extract<AcGeVector2d>(iterable)));
return boost::shared_ptr<AcGeVector2d>(new AcGeVector2d(PyListToAcGeVector2d(iterable)));
}
void makePyGeVector2dWrapper()
{
constexpr const std::string_view ctords = "Overloads:\n"
"- None: Any\n"
"- x: float, y: float\n";
constexpr const std::string_view setToProductOverloads = "Overloads:\n"
"- vec: PyGe.Vector2d, s: float\n"
"- xform: PyGe.Matrix2d, vec: PyGe.Vector3d\n";
constexpr const std::string_view rmulOverloads = "Overloads:\n"
"- val: float\n"
"- xform: PyGe.Matrix2d\n";
PyDocString DS("Vector2d");
class_<AcGeVector2d>("Vector2d")
.def(init<>())
.def(init<double, double>(DS.CTOR(ctords)))
.def_readwrite("x", &AcGeVector2d::x)
.def_readwrite("y", &AcGeVector2d::y)
.add_static_property("kIdentity", &AcGeVector2dkIdentity)
.add_static_property("kXAxis", &AcGeVector2dkXAxis)
.add_static_property("kYAxis", &AcGeVector2dkYAxis)
.def<AcGeVector2d& (AcGeVector2d::*)(const AcGeVector2d&, double)>("setToProduct", &AcGeVector2d::setToProduct, return_self<>())
.def<AcGeVector2d& (AcGeVector2d::*)(const AcGeMatrix2d&, const AcGeVector2d&)>("setToProduct", &AcGeVector2d::setToProduct, DS.OVRL(setToProductOverloads), return_self<>())
.def("transformBy", &AcGeVector2d::transformBy, DS.ARGS({ "xform: PyGe.Matrix2d" }), return_self<>())
.def("rotateBy", &AcGeVector2d::rotateBy, DS.ARGS({ "val: float" }), return_self<>())
.def("mirror", &AcGeVector2d::mirror, DS.ARGS({ "vec: PyGe.Vector2d" }), return_self<>())
.def("setToSum", &AcGeVector2d::setToSum, DS.ARGS({ "v1: PyGe.Vector2d", "v2: PyGe.Vector2d" }), return_self<>())
.def("negate", &AcGeVector2d::negate, DS.ARGS(), return_self<>())
.def("angle", &AcGeVector2d::angle, DS.ARGS())
.def("angleTo", &AcGeVector2d::angleTo, DS.ARGS({ "vec: PyGe.Vector2d" }))
.def("normal", &AcGeVector2d::normal, DS.ARGS({ "tol: PyGe.Tol=None" }), arg("AcGeTol") = getTol())
.def<AcGeVector2d& (AcGeVector2d::*)(const AcGeTol&)>("normalize", &AcGeVector2d::normalize, DS.ARGS({ "tol: PyGe.Tol=None" }), arg("AcGeTol") = getTol(), return_self<>())
.def("length", &AcGeVector2d::length, DS.ARGS())
.def("lengthSqrd", &AcGeVector2d::lengthSqrd, DS.ARGS())
.def("isUnitLength", &AcGeVector2d::isUnitLength, DS.ARGS({ "tol: PyGe.Tol=None" }), arg("AcGeTol") = getTol())
.def("isZeroLength", &AcGeVector2d::isZeroLength, DS.ARGS({ "tol: PyGe.Tol=None" }), arg("AcGeTol") = getTol())
.def<Adesk::Boolean(AcGeVector2d::*)(const AcGeVector2d&, const AcGeTol&)const>("isParallelTo", &AcGeVector2d::isParallelTo, DS.ARGS({ "vec: PyGe.Vector2d","tol: PyGe.Tol=None" }), arg("AcGeTol") = getTol())
.def<Adesk::Boolean(AcGeVector2d::*)(const AcGeVector2d&, const AcGeTol&)const>("isCodirectionalTo", &AcGeVector2d::isCodirectionalTo, DS.ARGS({ "vec: PyGe.Vector2d","tol: PyGe.Tol=None" }), arg("AcGeTol") = getTol())
.def<Adesk::Boolean(AcGeVector2d::*)(const AcGeVector2d&, const AcGeTol&)const>("isPerpendicularTo", &AcGeVector2d::isPerpendicularTo, DS.ARGS({ "vec: PyGe.Vector2d","tol: PyGe.Tol=None" }), arg("AcGeTol") = getTol())
.def("dotProduct", &AcGeVector2d::dotProduct, DS.ARGS({ "vec: PyGe.Vector2d" }))
.def("isEqualTo", &AcGeVector2d::isEqualTo, DS.ARGS({ "vec: PyGe.Vector3d","tol: PyGe.Tol=None" }), arg("AcGeTol") = getTol())
.def("set", &AcGeVector2d::set, DS.ARGS({ "xx: float","yy: float" }), return_self<>())
.def("__eq__", &AcGeVector2d::operator==)
.def("__ne__", &AcGeVector2d::operator!=)
.def<AcGeVector2d(AcGeVector2d::*)(double) const>("__mul__", &AcGeVector2d::operator*, DS.ARGS({ "val: float" }))
.def<AcGeVector2d& (AcGeVector2d::*)(double)>("__imul__", &AcGeVector2d::operator*=, DS.ARGS({ "val: float" }), return_self<>())
.def("__rmul__", &rmul_double_AcGeVector2d)
.def("__rmul__", &rmul_AcGeMatrix2d_AcGeVector2d, DS.OVRL(rmulOverloads))
.def<AcGeVector2d(AcGeVector2d::*)(double)const>("__truediv__", &AcGeVector2d::operator/, DS.ARGS({ "val: float" }))
.def<AcGeVector2d& (AcGeVector2d::*)(double)>("__itruediv__", &AcGeVector2d::operator/=, DS.ARGS({ "val: float" }), return_self<>())
.def<AcGeVector2d(AcGeVector2d::*)(const AcGeVector2d&)const>("__add__", &AcGeVector2d::operator , DS.ARGS({ "vec: PyGe.Vector2d" }))
.def<AcGeVector2d& (AcGeVector2d::*)(const AcGeVector2d&)>("__iadd__", &AcGeVector2d::operator =, DS.ARGS({ "vec: PyGe.Vector2d" }), return_self<>())
.def<AcGeVector2d(AcGeVector2d::*)()const>("__sub__", &AcGeVector2d::operator-)
.def<AcGeVector2d(AcGeVector2d::*)(const AcGeVector2d&)const>("__sub__", &AcGeVector2d::operator-, DS.ARGS({ "vec: PyGe.Vector2d=None" }))
.def<AcGeVector2d& (AcGeVector2d::*)(const AcGeVector2d&)>("__isub__", &AcGeVector2d::operator-=, DS.ARGS({ "vec: PyGe.Vector2d" }), return_self<>())
.def_pickle(AcGeVector2pickle())
.def("toString", &AcGeVector2ToString, DS.ARGS())
.def("toTuple", &AcGeVector2ToTuple, DS.ARGS())
.def("toList", &AcGeVector2ToList, DS.ARGS())
.def("__str__", &AcGeVector2ToString, DS.ARGS())
.def("__repr__", &AcGeVector2dToStringRepr, DS.ARGS())
.def("__getitem__", &AcGeVector2dGetItem, DS.ARGS({ "idx: int" }))
.def("__setitem__", &AcGeVector2dSetItem, DS.ARGS({ "idx: int","val: float" }))
.def("__hash__", &AcGeVector2dHash, DS.ARGS())
.def("__init__", make_constructor(&PyGeVector2dInitTuple))
;
}
//---------------------------------------------------------------------------------------------------------------
//AcGeMatrix2d
static AcGeMatrix2d AcGeMatrix2dkIdentity()
{
return AcGeMatrix2d::kIdentity;
}
static boost::python::tuple AcGeMatrix2dToTuple(const AcGeMatrix2d& x)
{
PyAutoLockGIL lock;
auto r0 = boost::python::make_tuple(
x.entry[0][0],
x.entry[0][1],
x.entry[0][2]);
auto r1 = boost::python::make_tuple(
x.entry[1][0],
x.entry[1][1],
x.entry[1][2]);
auto r2 = boost::python::make_tuple(
x.entry[2][0],
x.entry[2][1],
x.entry[2][2]);
return boost::python::make_tuple(r0, r1, r2);
}
static boost::python::list AcGeMatrix2dToList(const AcGeMatrix2d& x)
{
PyAutoLockGIL lock;
boost::python::list r0;
r0.append(x.entry[0][0]);
r0.append(x.entry[0][1]);
r0.append(x.entry[0][2]);
boost::python::list r1;
r1.append(x.entry[1][0]);
r1.append(x.entry[1][1]);
r1.append(x.entry[1][2]);
boost::python::list r2;
r2.append(x.entry[2][0]);
r2.append(x.entry[2][1]);
r2.append(x.entry[2][2]);
boost::python::list m;
m.append(r0);
m.append(r1);
m.append(r2);
return m;
}
std::string AcGeMatrix2dToString(const AcGeMatrix2d& x)
{
return std::format("(({0},{1},{2}),({3},{4},{5}),({6},{7},{8}))",
x.entry[0][0], x.entry[0][1], x.entry[0][2],
x.entry[1][0], x.entry[1][1], x.entry[1][2],
x.entry[2][0], x.entry[2][1], x.entry[2][2]);
}
std::string AcGeMatrix2dToStringRepr(const AcGeMatrix2d& x)
{
return std::format("<{0}.Matrix2d(({1},{2},{3}),({4},{5},{6}),({7},{8},{9}))>",
PyGeNamespace,
x.entry[0][0], x.entry[0][1], x.entry[0][2],
x.entry[1][0], x.entry[1][1], x.entry[1][2],
x.entry[2][0], x.entry[2][1], x.entry[2][2]);
}
static AcGeMatrix2d AcGeMatrix2dtranslation(const AcGeVector2d& vec)
{
return AcGeMatrix2d::translation(vec);
}
static AcGeMatrix2d AcGeMatrix2drotation(double angle, const AcGePoint2d& center)
{
return AcGeMatrix2d::rotation(angle, center);
}
static AcGeMatrix2d AcGeMatrix2scaling(double scaleAll, const AcGePoint2d& center)
{
return AcGeMatrix2d::scaling(scaleAll, center);
}
static AcGeMatrix2d AcGeMatrix2mirroring1(const AcGePoint2d& pnt)
{
return AcGeMatrix2d::mirroring(pnt);
}
static AcGeMatrix2d AcGeMatrix2mirroring2(const AcGeLine2d& line)
{
return AcGeMatrix2d::mirroring(line);
}
static AcGeMatrix2d AcGeMatrix2alignCoordSys
(const AcGePoint2d& fromOrigin,
const AcGeVector2d& fromE0,
const AcGeVector2d& fromE1,
const AcGePoint2d& toOrigin,
const AcGeVector2d& toE0,
const AcGeVector2d& toE1)
{
return AcGeMatrix2d::alignCoordSys(fromOrigin, fromE0, fromE1, toOrigin, toE0, toE1);
}
static void makePyGeMatrix2dWrapper()
{
PyDocString DS("Matrix2d");
class_<AcGeMatrix2d>("Matrix2d")
.def(init<>(DS.ARGS()))
.add_static_property("kIdentity", &AcGeMatrix2dkIdentity)
.def("setToIdentity", &AcGeMatrix2d::setToIdentity, DS.ARGS(), return_self<>())
.def("preMultBy", &AcGeMatrix2d::preMultBy, DS.ARGS({ "xform: PyGe.Matrix2d" }), return_self<>())
.def("postMultBy", &AcGeMatrix2d::postMultBy, DS.ARGS({ "xform: PyGe.Matrix2d" }), return_self<>())
.def("setToProduct", &AcGeMatrix2d::setToProduct, DS.ARGS({ "xform1: PyGe.Matrix2d","xform2: PyGe.Matrix2d" }), return_self<>())
.def("invert", &AcGeMatrix2d::invert, return_self<>(), DS.ARGS())
.def("inverse", &AcGeMatrix2d::inverse, DS.ARGS())
.def("isSingular", &AcGeMatrix2d::isSingular, DS.ARGS({ "tol: PyGe.Tol=None" }))
.def("transposeIt", &AcGeMatrix2d::transposeIt, return_self<>(), DS.ARGS())
.def("transpose", &AcGeMatrix2d::transpose, DS.ARGS())
.def("isEqualTo", &AcGeMatrix2d::isEqualTo, DS.ARGS({ "xform: PyGe.Matrix2d" }), arg("AcGeTol") = getTol())
.def("isUniScaledOrtho", &AcGeMatrix2d::isUniScaledOrtho, DS.ARGS({ "tol: PyGe.Tol=None" }), arg("AcGeTol") = getTol())
.def("isScaledOrtho", &AcGeMatrix2d::isScaledOrtho, DS.ARGS({ "tol: PyGe.Tol=None" }), arg("AcGeTol") = getTol())
.def("scale", &AcGeMatrix2d::scale, DS.ARGS())
.def("det", &AcGeMatrix2d::det, DS.ARGS())
.def("setTranslation", &AcGeMatrix2d::setTranslation, DS.ARGS({ "vec: PyGe.Vector2d" }), return_self<>())
.def<AcGeVector2d(AcGeMatrix2d::*)(void)const>("getTranslation", &AcGeMatrix2d::translation, DS.ARGS())
//.def("isConformal", &AcGeMatrix2d::isConformal)
.def("setCoordSystem", &AcGeMatrix2d::setCoordSystem, DS.ARGS({ "origin: PyGe.Point2d","e0: PyGe.Vector2d","e1: PyGe.Vector2d" }), return_self<>())
.def("getCoordSystem", &AcGeMatrix2d::getCoordSystem, DS.ARGS({ "origin: PyGe.Point2d","e0: PyGe.Vector2d","e1: PyGe.Vector2d" }))
.def("setToTranslation", &AcGeMatrix2d::setToTranslation, DS.ARGS({ "vec: PyGe.Vector2d" }), return_self<>())
.def("setToRotation", &AcGeMatrix2d::setToRotation, DS.ARGS({ "val: float","pt: PyGe.Point2d=PyGe.Point2d.kOrgin" }), arg("AcGePoint2d") = AcGePoint2dkOrigin(), return_self<>())
.def("setToScaling", &AcGeMatrix2d::setToScaling, DS.ARGS({ "val: float","pt: PyGe.Point2d=PyGe.Point2d.kOrgin" }), return_self<>())
.def<AcGeMatrix2d& (AcGeMatrix2d::*)(const AcGePoint2d&)>("setToMirroring", &AcGeMatrix2d::setToMirroring, return_self<>())
.def<AcGeMatrix2d& (AcGeMatrix2d::*)(const AcGeLine2d&)>("setToMirroring", &AcGeMatrix2d::setToMirroring, DS.ARGS({ "pt: PyGe.Point2d|PyGe.Line2d" }), return_self<>())
.def("setToAlignCoordSys", &AcGeMatrix2d::setToAlignCoordSys,
DS.ARGS({ "fo: PyGe.Point2d","fe0: PyGe.Vector2d","fe1: PyGe.Vector2d", "to: PyGe.Point2d","te0: PyGe.Vector2d","te1: PyGe.Vector2d" }), return_self<>())
.def("translation", &AcGeMatrix2dtranslation, DS.SARGS({ "vec: PyGe.Vector2d" })).staticmethod("translation")
.def("rotation", &AcGeMatrix2drotation, DS.SARGS({ "val: float","pt: PyGe.Point2d" })).staticmethod("rotation")
.def("scaling", &AcGeMatrix2scaling, DS.SARGS({ "scaleAll:float","center: PyGe.Point2d" })).staticmethod("scaling")
.def("mirroring", &AcGeMatrix2mirroring1)
.def("mirroring", &AcGeMatrix2mirroring2, DS.SARGS({ "pt: PyGe.Point2d|PyGe.Line2d" })).staticmethod("mirroring")
.def("alignCoordSys", &AcGeMatrix2alignCoordSys, DS.SARGS({ "fo: PyGe.Point2d","fe0: PyGe.Vector2d",
"fe1: PyGe.Vector2d", "to: PyGe.Point2d","te0: PyGe.Vector2d","te1: PyGe.Vector2d" })).staticmethod("alignCoordSys")
.def<double(AcGeMatrix2d::*)(unsigned int, unsigned int)const>("elementAt", &AcGeMatrix2d::operator(), DS.ARGS({ "row: int","col: int" }))
.def("__eq__", &AcGeMatrix2d::operator==)
.def("__ne__", &AcGeMatrix2d::operator!=)
.def<AcGeMatrix2d(AcGeMatrix2d::*)(const AcGeMatrix2d&) const>("__mul__", &AcGeMatrix2d::operator*, DS.ARGS({ "xform: PyGe.Matrix2d" }))
.def<AcGeMatrix2d& (AcGeMatrix2d::*)(const AcGeMatrix2d&)>("__imul__", &AcGeMatrix2d::operator*=, DS.ARGS({ "xform: PyGe.Matrix2d" }), return_self<>())
.def("toString", &AcGeMatrix2dToString, DS.ARGS())
.def("toTuple", &AcGeMatrix2dToTuple, DS.ARGS())
.def("toList", &AcGeMatrix2dToList, DS.ARGS())
.def("__str__", &AcGeMatrix2dToString, DS.ARGS())
.def("__repr__", &AcGeMatrix2dToStringRepr, DS.ARGS())
;
}
//---------------------------------------------------------------------------------------------------------------
//AcGeScale3d
double AcGeScale3dGetItem(const AcGeScale3d& p, int idx)
{
switch (idx)
{
case 0:
return p.sx;
case 1:
return p.sy;
case 2:
return p.sz;
default:
throw std::out_of_range{ "IndexError" };
}
}
void AcGeScale3dSetItem(AcGeScale3d& p, int idx, double val)
{
switch (idx)
{
case 0:
p.sx = val;
break;
case 1:
p.sy = val;
break;
case 2:
p.sz = val;
break;
default:
throw std::out_of_range{ "IndexError" };
}
}
std::string AcGeScale3dToString(const AcGeScale3d& s)
{
return std::format("({:.14f},{:.14f},{:.14f})", s.sx, s.sy, s.sz);
}
std::string AcGeScale3dToStringRepr(const AcGeScale3d& s)
{
return std::format("<{}.Scale3d({:.14f},{:.14f},{:.14f})>", PyGeNamespace, s.sx, s.sy, s.sz);
}
void makePyGeScale3dWrapper()
{
constexpr const std::string_view ctords = "Overloads:\n"
"- None: Any\n"
"- factor: float\n"
"- sx: float,sy: float,sz: float\n";
constexpr const std::string_view setToProductOverloads = "Overloads:\n"
"- sc: PyGe.Scale3d, s: float\n"
"- sc1: PyGe.Scale3d, sc2: PyGe.Scale3d\n";
PyDocString DS("Scale3d");
class_<AcGeScale3d>("Scale3d")
.def(init<>())
.def(init<double>())
.def(init<double, double, double>(DS.CTOR(ctords)))
.def_readwrite("sx", &AcGeScale3d::sx)
.def_readwrite("sy", &AcGeScale3d::sy)
.def_readwrite("sz", &AcGeScale3d::sz)
.def<AcGeScale3d(AcGeScale3d::*)(double)const>("__mul__", &AcGeScale3d::operator*, DS.ARGS({ "val: float" }))
.def<AcGeScale3d& (AcGeScale3d::*)(double)>("__imul__", &AcGeScale3d::operator*=, DS.ARGS({ "val: float" }), return_self<>())
.def<AcGeScale3d(AcGeScale3d::*)(const AcGeScale3d&)const>("__mul__", &AcGeScale3d::operator*, DS.ARGS({ "vec: PyGe.Vector3d" }))
.def<AcGeScale3d& (AcGeScale3d::*)(const AcGeScale3d&)>("__imul__", &AcGeScale3d::operator*=, DS.ARGS({ "vec: PyGe.Vector3d" }), return_self<>())
#if !defined(_BRXTARGET250)
.def("preMultBy", &AcGeScale3d::preMultBy, DS.ARGS({ "vec: PyGe.Vector3d" }), return_self<>())
.def("postMultBy", &AcGeScale3d::postMultBy, DS.ARGS({ "vec: PyGe.Vector3d" }), return_self<>())
.def<AcGeScale3d& (AcGeScale3d::*)(const AcGeScale3d&, double)>("setToProduct", &AcGeScale3d::setToProduct, return_self<>())
.def<AcGeScale3d& (AcGeScale3d::*)(const AcGeScale3d&, const AcGeScale3d&)>("setToProduct", &AcGeScale3d::setToProduct, DS.OVRL(setToProductOverloads), return_self<>())
#endif
.def("__eq__", &AcGeScale3d::operator==)
.def("__ne__", &AcGeScale3d::operator!=)
.def("toString", &AcGeScale3dToString, DS.ARGS())
.def("__str__", &AcGeScale3dToString, DS.ARGS())
.def("__repr__", &AcGeScale3dToStringRepr, DS.ARGS())
.def("__getitem__", &AcGeScale3dGetItem, DS.ARGS({ "idx: int" }))
.def("__setitem__", &AcGeScale3dSetItem, DS.ARGS({ "idx: int", "val: float" }))
;
}
//---------------------------------------------------------------------------------------------------------------
//AcGePoint3d
static AcGePoint3d PyIterableToAcGePoint3d(const boost::python::object& iterable)
{
return PyListToAcGePoint3d(iterable);
};
struct AcGePoint3dpickle : boost::python::pickle_suite
{
static boost::python::tuple getinitargs(const AcGePoint3d& p)
{
return boost::python::make_tuple(p.x, p.y, p.z);
}
};
boost::python::tuple AcGePoint3dToTuple(const AcGePoint3d& p)
{
PyAutoLockGIL lock;
return boost::python::make_tuple(p.x, p.y, p.z);
}
boost::python::list AcGePoint3dToList(const AcGePoint3d& p)
{
PyAutoLockGIL lock;
boost::python::list l;
l.append(p.x);
l.append(p.y);
l.append(p.z);
return l;
}
std::string AcGePoint3dToString(const AcGePoint3d& p)
{
return std::format("({:.14f},{:.14f},{:.14f})", p.x, p.y, p.z);
}
std::string AcGePoint3dToStringRepr(const AcGePoint3d& p)
{
return std::format("<{}.Point3d({:.14f},{:.14f},{:.14f})>", PyGeNamespace, p.x, p.y, p.z);
}
static AcGePoint3d AcGePoint3dkOrigin()
{
return AcGePoint3d::kOrigin;
}
AcGePoint3d rmul_AcGePoint3d_AcGeMatrix3d(const AcGePoint3d& pnt, const AcGeMatrix3d& mat)
{
return mat * pnt;
}
AcGePoint3d rmul_double_AcGepoint3d(const AcGePoint3d& pnt, double val)
{
return val * pnt;
}
int AcGePoint3dLen(const AcGePoint3d& p)
{
return 3;
}
double AcGePoint3dGetItem(const AcGePoint3d& p, int idx)
{
switch (idx)
{
case 0:
return p.x;
case 1:
return p.y;
case 2:
return p.z;
default:
throw std::out_of_range{ "IndexError " };
}
}
void AcGePoint3dSetItem(AcGePoint3d& p, int idx, double val)
{
switch (idx)
{
case 0:
p.x = val;
break;
case 1:
p.y = val;
break;
case 2:
p.z = val;
break;
default:
throw std::out_of_range{ "IndexError " };
}
}
static boost::shared_ptr<AcGePoint3d> PyGePoint3dInitTuple(const boost::python::object& iterable)
{
if (extract<AcGePoint3d>(iterable).check())
return boost::shared_ptr<AcGePoint3d>(new AcGePoint3d(extract<AcGePoint3d>(iterable)));
return boost::shared_ptr<AcGePoint3d>(new AcGePoint3d(PyListToAcGePoint3d(iterable)));
}
void makePyGePoint3dWrapper()
{
constexpr const std::string_view ctords = "Overloads:\n"
"- None: Any\n"
"- floats: tuple[float] | list[float]\n"
"- x: float,y: float,z: float\n"
"- pln: PyGe.PlanarEnt, pnt2d: PyGe.Point2d\n";
constexpr const std::string_view setOverloads = "Overloads:\n"
"- x: float, y: float, z: float\n"
"- pl: PyGe.PlanarEnt, pt2d: PyGe.Point2d\n";
PyDocString DS("PyGe.Point3d");
class_<AcGePoint3d>("Point3d")
.def(init<>())
.def(init<double, double, double>())
.def(init<const AcGePlanarEnt&, const AcGePoint2d&>(DS.CTOR(ctords)))
.def_readwrite("x", &AcGePoint3d::x)
.def_readwrite("y", &AcGePoint3d::y)
.def_readwrite("z", &AcGePoint3d::z)
.add_static_property("kOrigin", &AcGePoint3dkOrigin, DS.SARGS(12585))
.def("setToProduct", &AcGePoint3d::setToProduct, return_self<>(), DS.ARGS({ "mat: PyGe.Matrix3d","pnt: PyGe.Point3d" }, 12592))
.def("transformBy", &AcGePoint3d::transformBy, return_self<>(), DS.ARGS({ "mat: PyGe.Matrix3d" }, 12863))
.def("rotateBy", &AcGePoint3d::rotateBy, arg("AcGePoint3d") = AcGePoint3dkOrigin(), return_self<>(),
DS.ARGS({ "angle: float","vec: PyGe.Vector3d","wrtPoint: PyGe.Point3d=Point3d.kOrigin" }, 12589))
.def("mirror", &AcGePoint3d::mirror, return_self<>(), DS.ARGS({ "pln: PyGe.Plane" }, 12586))
.def("scaleBy", &AcGePoint3d::scaleBy, arg("AcGePoint3d") = AcGePoint3dkOrigin(), return_self<>(), DS.ARGS({ "factor: float","pnt: PyGe.Point3d='orgin'" }, 12590))
.def("convert2d", &AcGePoint3d::convert2d, DS.ARGS({ "pln: PyGe.PlanarEnt" }, 12582))
.def("setToSum", &AcGePoint3d::setToSum, return_self<>(), DS.ARGS({ "pnt: PyGe.Point3d","vec: PyGe.Vector3d" }, 12593))
.def("asVector", &AcGePoint3d::asVector, DS.ARGS(12581))
.def("distanceTo", &AcGePoint3d::distanceTo, DS.ARGS({ "pnt: PyGe.Point3d" }, 12583))
.def("project", &AcGePoint3d::project, DS.ARGS({ "pln: PyGe.Plane","vec: PyGe.Vector3d" }, 12588))
.def("orthoProject", &AcGePoint3d::orthoProject, DS.ARGS({ "pln: PyGe.Plane" }, 12587))
.def("isEqualTo", &AcGePoint3d::isEqualTo, DS.ARGS({ "pnt: PyGe.Point3d", "tol: PyGe.Tol=None" }, 12584), arg("AcGeTol") = getTol())
.def<AcGePoint3d& (AcGePoint3d::*)(const AcGePlanarEnt&, const AcGePoint2d&)>("set", &AcGePoint3d::set, return_self<>())
.def<AcGePoint3d& (AcGePoint3d::*)(double, double, double)>("set", &AcGePoint3d::set, return_self<>(), DS.OVRL(setOverloads))
.def("__eq__", &AcGePoint3d::operator==, DS.ARGS({ "pt: PyGe.Point3d" }))
.def("__ne__", &AcGePoint3d::operator!=, DS.ARGS({ "pt: PyGe.Point3d" }))
.def<AcGePoint3d(AcGePoint3d::*)(double)const>("__mul__", &AcGePoint3d::operator*, DS.ARGS({ "val: float" }))
.def<AcGePoint3d& (AcGePoint3d::*)(double)>("__imul__", &AcGePoint3d::operator*=, return_self<>(), DS.ARGS({ "val: float" }))
.def("__rmul__", &rmul_double_AcGepoint3d)
.def("__rmul__", &rmul_AcGePoint3d_AcGeMatrix3d, DS.ARGS({ "val: float|PyGe.Matrix3d" }))
.def<AcGePoint3d(AcGePoint3d::*)(double)const>("__truediv__", &AcGePoint3d::operator/, DS.ARGS({ "val: float" }))
.def<AcGePoint3d& (AcGePoint3d::*)(double)>("__itruediv__", &AcGePoint3d::operator/=, DS.ARGS({ "val: float" }), return_self<>())
.def<AcGePoint3d(AcGePoint3d::*)(const AcGeVector3d&)const>("__add__", &AcGePoint3d::operator , DS.ARGS({ "vec: PyGe.Vector3d" }))
.def<AcGePoint3d& (AcGePoint3d::*)(const AcGeVector3d&)>("__iadd__", &AcGePoint3d::operator =, DS.ARGS({ "vec: PyGe.Vector3d" }), return_self<>())
.def<AcGeVector3d(AcGePoint3d::*)(const AcGePoint3d&)const>("__sub__", &AcGePoint3d::operator-)
.def<AcGePoint3d(AcGePoint3d::*)(const AcGeVector3d&)const>("__sub__", &AcGePoint3d::operator-, DS.ARGS({ "val: PyGe.Vector3d | PyGe.Point3d" }))
.def<AcGePoint3d& (AcGePoint3d::*)(const AcGeVector3d&)>("__isub__", &AcGePoint3d::operator-=, DS.ARGS({ "vec: PyGe.Vector3d" }), return_self<>())
.def_pickle(AcGePoint3dpickle())
.def("toList", &AcGePoint3dToList, DS.ARGS())
.def("toTuple", &AcGePoint3dToTuple, DS.ARGS())
.def("toString", &AcGePoint3dToString, DS.ARGS())
.def("__len__", &AcGePoint3dLen, DS.ARGS())
.def("__str__", &AcGePoint3dToString, DS.ARGS())
.def("__repr__", &AcGePoint3dToStringRepr, DS.ARGS())
.def("__hash__", &AcGePoint3dHash, DS.ARGS())
.def("__getitem__", &AcGePoint3dGetItem, DS.ARGS({ "idx: int" }))
.def("__setitem__", &AcGePoint3dSetItem, DS.ARGS({ "idx: int","val: float" }))
.def("__init__", make_constructor(&PyGePoint3dInitTuple))
;
}
//---------------------------------------------------------------------------------------------------------------
//AcGeVector3d
struct AcGeVector3dpickle : boost::python::pickle_suite
{
static boost::python::tuple getinitargs(const AcGeVector3d& p)
{
return boost::python::make_tuple(p.x, p.y, p.z);
}
};
boost::python::tuple AcGeVector3dToTuple(const AcGeVector3d& p)
{
PyAutoLockGIL lock;
return boost::python::make_tuple(p.x, p.y, p.z);
}
boost::python::list AcGeVector3dToList(const AcGeVector3d& p)
{
PyAutoLockGIL lock;
boost::python::list l;
l.append(p.x);
l.append(p.y);
l.append(p.z);
return l;
}
static AcGeVector3d AcGeVector3dkIdentity()
{
return AcGeVector3d::kIdentity;
}
static AcGeVector3d AcGeVector3dkXAxis()
{
return AcGeVector3d::kXAxis;
}
static AcGeVector3d AcGeVector3dkYAxis()
{
return AcGeVector3d::kYAxis;
}
static AcGeVector3d AcGeVector3dkZAxis()
{
return AcGeVector3d::kZAxis;
}
std::string AcGeVector3dToString(const AcGeVector3d& p)
{
return std::format("({:.14f},{:.14f},{:.14f})", p.x, p.y, p.z);
}
std::string AcGeVector3dToStringRepr(const AcGeVector3d& p)
{
return std::format("<{}.Vector3d({:.14f},{:.14f},{:.14f})>", PyGeNamespace, p.x, p.y, p.z);
}
AcGeVector3d rmul_double_AcGeVector3d(const AcGeVector3d& vec, double val)
{
return val * vec;
}
AcGeVector3d rmul_AcGeMatrix3d_AcGeVector3d(const AcGeVector3d& vec, const AcGeMatrix3d& mat)
{
return mat * vec;
}
double AcGeVector3dGetItem(const AcGeVector3d& p, int idx)
{
switch (idx)
{
case 0:
return p.x;
case 1:
return p.y;
case 2:
return p.z;
default:
throw std::out_of_range{ "IndexError" };
}
}
void AcGeVector3dSetItem(AcGeVector3d& p, int idx, double val)