siren2 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/LICENSE +21 -0
- data/README.md +36 -0
- data/Rakefile +18 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/ext/siren2/extconf.rb +66 -0
- data/ext/siren2/inc/bndbox.h +51 -0
- data/ext/siren2/inc/bo.h +20 -0
- data/ext/siren2/inc/brep.h +17 -0
- data/ext/siren2/inc/common.h +98 -0
- data/ext/siren2/inc/curve.h +65 -0
- data/ext/siren2/inc/curve/bscurve.h +22 -0
- data/ext/siren2/inc/curve/bzcurve.h +17 -0
- data/ext/siren2/inc/curve/circle.h +29 -0
- data/ext/siren2/inc/curve/ellipse.h +15 -0
- data/ext/siren2/inc/curve/hyperbola.h +15 -0
- data/ext/siren2/inc/curve/line.h +17 -0
- data/ext/siren2/inc/curve/offsetcurve.h +15 -0
- data/ext/siren2/inc/curve/parabola.h +15 -0
- data/ext/siren2/inc/filler.h +26 -0
- data/ext/siren2/inc/heal.h +19 -0
- data/ext/siren2/inc/io/iges.h +19 -0
- data/ext/siren2/inc/io/step.h +18 -0
- data/ext/siren2/inc/io/stl.h +13 -0
- data/ext/siren2/inc/offset.h +35 -0
- data/ext/siren2/inc/shape.h +140 -0
- data/ext/siren2/inc/shape/chunk.h +26 -0
- data/ext/siren2/inc/shape/compound.h +22 -0
- data/ext/siren2/inc/shape/edge.h +50 -0
- data/ext/siren2/inc/shape/face.h +67 -0
- data/ext/siren2/inc/shape/shell.h +21 -0
- data/ext/siren2/inc/shape/solid.h +41 -0
- data/ext/siren2/inc/shape/vertex.h +23 -0
- data/ext/siren2/inc/shape/wire.h +31 -0
- data/ext/siren2/inc/siren.h +39 -0
- data/ext/siren2/inc/surface/dummy +0 -0
- data/ext/siren2/inc/topalgo.h +52 -0
- data/ext/siren2/inc/trans.h +48 -0
- data/ext/siren2/inc/vec.h +65 -0
- data/ext/siren2/src/bndbox.cpp +343 -0
- data/ext/siren2/src/bo.cpp +66 -0
- data/ext/siren2/src/brep.cpp +69 -0
- data/ext/siren2/src/common.cpp +18 -0
- data/ext/siren2/src/curve.cpp +75 -0
- data/ext/siren2/src/curve/bscurve.cpp +118 -0
- data/ext/siren2/src/curve/bzcurve.cpp +55 -0
- data/ext/siren2/src/curve/circle.cpp +146 -0
- data/ext/siren2/src/curve/ellipse.cpp +17 -0
- data/ext/siren2/src/curve/hyperbola.cpp +17 -0
- data/ext/siren2/src/curve/line.cpp +24 -0
- data/ext/siren2/src/curve/offsetcurve.cpp +17 -0
- data/ext/siren2/src/curve/parabola.cpp +17 -0
- data/ext/siren2/src/filler.cpp +191 -0
- data/ext/siren2/src/heal.cpp +92 -0
- data/ext/siren2/src/io/iges.cpp +85 -0
- data/ext/siren2/src/io/step.cpp +47 -0
- data/ext/siren2/src/io/stl.cpp +22 -0
- data/ext/siren2/src/offset.cpp +256 -0
- data/ext/siren2/src/shape.cpp +617 -0
- data/ext/siren2/src/shape/chunk.cpp +65 -0
- data/ext/siren2/src/shape/compound.cpp +96 -0
- data/ext/siren2/src/shape/edge.cpp +254 -0
- data/ext/siren2/src/shape/face.cpp +366 -0
- data/ext/siren2/src/shape/shell.cpp +41 -0
- data/ext/siren2/src/shape/solid.cpp +256 -0
- data/ext/siren2/src/shape/vertex.cpp +68 -0
- data/ext/siren2/src/shape/wire.cpp +100 -0
- data/ext/siren2/src/siren.cpp +80 -0
- data/ext/siren2/src/surface/dummy +0 -0
- data/ext/siren2/src/topalgo.cpp +246 -0
- data/ext/siren2/src/trans.cpp +330 -0
- data/ext/siren2/src/vec.cpp +454 -0
- data/lib/io/dxf.rb +68 -0
- data/lib/io/plot.rb +38 -0
- data/lib/io/ply.rb +57 -0
- data/lib/io/stl.rb +35 -0
- data/lib/io/svg.rb +44 -0
- data/lib/kernel/array.rb +133 -0
- data/lib/kernel/float.rb +15 -0
- data/lib/shape.rb +157 -0
- data/lib/shape/compound.rb +11 -0
- data/lib/shape/edge.rb +15 -0
- data/lib/shape/face.rb +7 -0
- data/lib/shape/shell.rb +21 -0
- data/lib/shape/solid.rb +10 -0
- data/lib/shape/vertex.rb +7 -0
- data/lib/shape/wire.rb +14 -0
- data/lib/shapes.rb +52 -0
- data/lib/siren.rb +166 -0
- data/lib/siren2/version.rb +3 -0
- data/lib/vec.rb +81 -0
- data/siren2.gemspec +28 -0
- metadata +195 -0
@@ -0,0 +1,18 @@
|
|
1
|
+
#include "common.h"
|
2
|
+
|
3
|
+
void siren_ary_to_xyz(VALUE ary, Standard_Real& x, Standard_Real& y, Standard_Real& z)
|
4
|
+
{
|
5
|
+
x = 0.0; y = 0.0; z = 0.0;
|
6
|
+
|
7
|
+
int len = RARRAY_LEN(ary);
|
8
|
+
if (len > 0) {
|
9
|
+
x = NUM2DBL(RARRAY_AREF(ary, 0));
|
10
|
+
}
|
11
|
+
if (len > 1) {
|
12
|
+
y = NUM2DBL(RARRAY_AREF(ary, 1));
|
13
|
+
}
|
14
|
+
if (len > 2) {
|
15
|
+
z = NUM2DBL(RARRAY_AREF(ary, 2));
|
16
|
+
}
|
17
|
+
return;
|
18
|
+
}
|
@@ -0,0 +1,75 @@
|
|
1
|
+
/*
|
2
|
+
* Document-class: Curve
|
3
|
+
*
|
4
|
+
*/
|
5
|
+
|
6
|
+
#include "curve.h"
|
7
|
+
|
8
|
+
VALUE sr_cCurve;
|
9
|
+
|
10
|
+
VALUE siren_curve_allocate(VALUE klass)
|
11
|
+
{
|
12
|
+
void* p = ruby_xmalloc(sizeof(handle<Geom_Curve>));
|
13
|
+
new(p) handle<Geom_Curve>();
|
14
|
+
return Data_Wrap_Struct(klass, NULL, siren_curve_final, p);
|
15
|
+
}
|
16
|
+
|
17
|
+
handle<Geom_Curve>* siren_curve_get(VALUE obj)
|
18
|
+
{
|
19
|
+
handle<Geom_Curve>* m;
|
20
|
+
Data_Get_Struct(obj, handle<Geom_Curve>, m);
|
21
|
+
return m;
|
22
|
+
}
|
23
|
+
|
24
|
+
VALUE siren_curve_new(handle<Geom_Curve> curve)
|
25
|
+
{
|
26
|
+
VALUE klass;
|
27
|
+
GeomAbs_CurveType type = siren_curve_geomtype_native(curve);
|
28
|
+
switch (type) {
|
29
|
+
case GeomAbs_Line: klass = sr_cLine; break;
|
30
|
+
case GeomAbs_Circle: klass = sr_cCircle; break;
|
31
|
+
case GeomAbs_Ellipse: klass = sr_cEllipse; break;
|
32
|
+
case GeomAbs_Hyperbola: klass = sr_cHyperbola; break;
|
33
|
+
case GeomAbs_Parabola: klass = sr_cParabola; break;
|
34
|
+
case GeomAbs_BezierCurve: klass = sr_cBzCurve; break;
|
35
|
+
case GeomAbs_BSplineCurve: klass = sr_cBSCurve; break;
|
36
|
+
case GeomAbs_OffsetCurve: klass = sr_cOffsetCurve; break;
|
37
|
+
default: rb_raise(Qnil, "Failed to make Curve object."); break;
|
38
|
+
}
|
39
|
+
auto val = siren_curve_allocate(klass);
|
40
|
+
auto pc = siren_curve_get(val);
|
41
|
+
*pc = curve;
|
42
|
+
return val;
|
43
|
+
}
|
44
|
+
|
45
|
+
bool siren_curve_install()
|
46
|
+
{
|
47
|
+
sr_cCurve = rb_define_class_under(sr_mSiren, "Curve", rb_cObject);
|
48
|
+
rb_define_alloc_func(sr_cCurve, siren_curve_allocate);
|
49
|
+
rb_define_method(sr_cCurve, "initialize", RUBY_METHOD_FUNC(siren_curve_init), -1);
|
50
|
+
siren_line_install();
|
51
|
+
siren_circle_install();
|
52
|
+
siren_ellipse_install();
|
53
|
+
siren_hyperbola_install();
|
54
|
+
siren_parabola_install();
|
55
|
+
siren_bzcurve_install();
|
56
|
+
siren_bscurve_install();
|
57
|
+
siren_offsetcurve_install();
|
58
|
+
return true;
|
59
|
+
}
|
60
|
+
|
61
|
+
VALUE siren_curve_init(int argc, VALUE* argv, VALUE self)
|
62
|
+
{
|
63
|
+
rb_raise(Qnil, "private method `new' called for Curve:Class");
|
64
|
+
return Qnil;
|
65
|
+
}
|
66
|
+
|
67
|
+
void siren_curve_final(void* p)
|
68
|
+
{
|
69
|
+
handle<Geom_Curve>* hgcurve = static_cast<handle<Geom_Curve>*>(p);
|
70
|
+
if (!(*hgcurve).IsNull()) {
|
71
|
+
(*hgcurve).Nullify();
|
72
|
+
}
|
73
|
+
ruby_xfree(p);
|
74
|
+
}
|
75
|
+
|
@@ -0,0 +1,118 @@
|
|
1
|
+
/**
|
2
|
+
* bscurve.cpp
|
3
|
+
*/
|
4
|
+
|
5
|
+
#include "curve.h"
|
6
|
+
|
7
|
+
VALUE sr_cBSCurve;
|
8
|
+
|
9
|
+
SR_CURVE_GET(BSplineCurve, bscurve)
|
10
|
+
|
11
|
+
bool siren_bscurve_install()
|
12
|
+
{
|
13
|
+
SR_CURVE_INIT(BSCurve)
|
14
|
+
rb_define_method(sr_cBSCurve, "initialize", RUBY_METHOD_FUNC(siren_bscurve_init), -1);
|
15
|
+
rb_define_method(sr_cBSCurve, "degree", RUBY_METHOD_FUNC(siren_bscurve_degree), -1);
|
16
|
+
rb_define_method(sr_cBSCurve, "knots", RUBY_METHOD_FUNC(siren_bscurve_knots), -1);
|
17
|
+
rb_define_method(sr_cBSCurve, "mults", RUBY_METHOD_FUNC(siren_bscurve_mults), -1);
|
18
|
+
rb_define_method(sr_cBSCurve, "poles", RUBY_METHOD_FUNC(siren_bscurve_poles), -1);
|
19
|
+
rb_define_method(sr_cBSCurve, "weights", RUBY_METHOD_FUNC(siren_bscurve_weights), -1);
|
20
|
+
return true;
|
21
|
+
}
|
22
|
+
|
23
|
+
VALUE siren_bscurve_init(int argc, VALUE* argv, VALUE self)
|
24
|
+
{
|
25
|
+
VALUE d;
|
26
|
+
VALUE ks, ms, ps, ws;
|
27
|
+
rb_scan_args(argc, argv, "41", &d, &ks, &ms, &ps, &ws);
|
28
|
+
|
29
|
+
int plen = RARRAY_LEN(ps);
|
30
|
+
|
31
|
+
TColgp_Array1OfPnt poles(0, plen - 1);
|
32
|
+
TColStd_Array1OfReal weights(0, plen - 1);
|
33
|
+
for (int i=0; i < plen; i++) {
|
34
|
+
poles.SetValue(i, siren_ary_to_pnt(RARRAY_AREF(ps, i)));
|
35
|
+
if (argc >= 5) {
|
36
|
+
VALUE w = RARRAY_AREF(ws, i);
|
37
|
+
weights.SetValue(i, VALUE(w));
|
38
|
+
}
|
39
|
+
else {
|
40
|
+
weights.SetValue(i, 1.0);
|
41
|
+
}
|
42
|
+
}
|
43
|
+
|
44
|
+
int klen = RARRAY_LEN(ks);
|
45
|
+
TColStd_Array1OfReal knots(0, klen - 1);
|
46
|
+
TColStd_Array1OfInteger mults(0, klen - 1);
|
47
|
+
|
48
|
+
for (int i=0; i < klen; i++) {
|
49
|
+
VALUE knot = RARRAY_AREF(ks, i);
|
50
|
+
knots.SetValue(i, VALUE(knot));
|
51
|
+
VALUE mult = RARRAY_AREF(ms, i);
|
52
|
+
mults.SetValue(i, (Standard_Integer)DBL2NUM(mult));
|
53
|
+
}
|
54
|
+
|
55
|
+
handle<Geom_Curve> curve
|
56
|
+
= new Geom_BSplineCurve(poles, weights, knots, mults, d, Standard_False);
|
57
|
+
|
58
|
+
// initialize において self は既に rb_instance_alloc されているので、
|
59
|
+
// DATA_PTR と DATA_TYPE のみを設定する
|
60
|
+
void* p = ruby_xmalloc(sizeof(handle<Geom_Curve>));
|
61
|
+
handle<Geom_Curve>* hgcurve = new(p) handle<Geom_Curve>();
|
62
|
+
*hgcurve = curve;
|
63
|
+
DATA_PTR(self) = hgcurve;
|
64
|
+
#if 0
|
65
|
+
DATA_TYPE(self) = &siren_bscurve_type;
|
66
|
+
#endif
|
67
|
+
return self;
|
68
|
+
}
|
69
|
+
|
70
|
+
VALUE siren_bscurve_degree(int argc, VALUE* argv, VALUE self)
|
71
|
+
{
|
72
|
+
handle<Geom_BSplineCurve> curve = siren_bscurve_get(self);
|
73
|
+
return INT2FIX((int)curve->Degree());
|
74
|
+
}
|
75
|
+
|
76
|
+
VALUE siren_bscurve_knots(int argc, VALUE* argv, VALUE self)
|
77
|
+
{
|
78
|
+
handle<Geom_BSplineCurve> curve = siren_bscurve_get(self);
|
79
|
+
VALUE knots = rb_ary_new();
|
80
|
+
for (int i = 1; i <= curve->NbKnots(); i++) {
|
81
|
+
rb_ary_push(knots, (curve->Knot(i)));
|
82
|
+
}
|
83
|
+
return knots;
|
84
|
+
}
|
85
|
+
|
86
|
+
VALUE siren_bscurve_mults(int argc, VALUE* argv, VALUE self)
|
87
|
+
{
|
88
|
+
handle<Geom_BSplineCurve> curve = siren_bscurve_get(self);
|
89
|
+
VALUE mults = rb_ary_new();
|
90
|
+
for (int i = 1; i <= curve->NbKnots(); i++) {
|
91
|
+
rb_ary_push(mults, INT2FIX(curve->Multiplicity(i)));
|
92
|
+
}
|
93
|
+
return mults;
|
94
|
+
}
|
95
|
+
|
96
|
+
VALUE siren_bscurve_poles(int argc, VALUE* argv, VALUE self)
|
97
|
+
{
|
98
|
+
handle<Geom_BSplineCurve> curve = siren_bscurve_get(self);
|
99
|
+
VALUE poles = rb_ary_new();
|
100
|
+
for (int i = 1; i <= curve->NbPoles(); i++) {
|
101
|
+
VALUE item = rb_ary_new();
|
102
|
+
rb_ary_push(item, (curve->Pole(i).X()));
|
103
|
+
rb_ary_push(item, (curve->Pole(i).Y()));
|
104
|
+
rb_ary_push(item, (curve->Pole(i).Z()));
|
105
|
+
rb_ary_push(poles, item);
|
106
|
+
}
|
107
|
+
return poles;
|
108
|
+
}
|
109
|
+
|
110
|
+
VALUE siren_bscurve_weights(int argc, VALUE* argv, VALUE self)
|
111
|
+
{
|
112
|
+
handle<Geom_BSplineCurve> curve = siren_bscurve_get(self);
|
113
|
+
VALUE weights = rb_ary_new();
|
114
|
+
for (int i = 1; i <= curve->NbPoles(); i++) {
|
115
|
+
rb_ary_push(weights, (curve->Weight(i)));
|
116
|
+
}
|
117
|
+
return weights;
|
118
|
+
}
|
@@ -0,0 +1,55 @@
|
|
1
|
+
/**
|
2
|
+
* bzcurve.cpp
|
3
|
+
*/
|
4
|
+
|
5
|
+
#include "curve.h"
|
6
|
+
|
7
|
+
VALUE sr_cBzCurve;
|
8
|
+
|
9
|
+
SR_CURVE_GET(BezierCurve, bzcurve)
|
10
|
+
|
11
|
+
bool siren_bzcurve_install()
|
12
|
+
{
|
13
|
+
SR_CURVE_INIT(BzCurve)
|
14
|
+
rb_define_method(sr_cBzCurve, "initialize", RUBY_METHOD_FUNC(siren_bzcurve_init), -1);
|
15
|
+
return true;
|
16
|
+
}
|
17
|
+
|
18
|
+
VALUE siren_bzcurve_init(int argc, VALUE* argv, VALUE self)
|
19
|
+
{
|
20
|
+
VALUE ps, ws;
|
21
|
+
rb_scan_args(argc, argv, "11", &ps, &ws);
|
22
|
+
bool has_weight = argc == 2;
|
23
|
+
int plen = RARRAY_LEN(ps);
|
24
|
+
TColgp_Array1OfPnt poles(1, plen);
|
25
|
+
TColStd_Array1OfReal weights(1, plen);
|
26
|
+
// Start index of weights must be 1. Crash construction of Geom_BezierCurve
|
27
|
+
// if another index specified.
|
28
|
+
for (int i = 0; i < plen; i++) {
|
29
|
+
poles.SetValue(i + 1, siren_ary_to_pnt(RARRAY_AREF(ps, i)));
|
30
|
+
if (has_weight) {
|
31
|
+
VALUE w = RARRAY_AREF(ws, i);
|
32
|
+
weights.SetValue(i + 1, VALUE(w));
|
33
|
+
}
|
34
|
+
}
|
35
|
+
handle<Geom_Curve> curve = nullptr;
|
36
|
+
try {
|
37
|
+
if (has_weight) {
|
38
|
+
curve = new Geom_BezierCurve(poles, weights);
|
39
|
+
}
|
40
|
+
else {
|
41
|
+
curve = new Geom_BezierCurve(poles);
|
42
|
+
}
|
43
|
+
}
|
44
|
+
catch (...) {
|
45
|
+
rb_raise(Qnil, "Failed to make a BzCurve.");
|
46
|
+
}
|
47
|
+
void* p = ruby_xmalloc(sizeof(handle<Geom_Curve>));
|
48
|
+
handle<Geom_Curve>* hgcurve = new(p) handle<Geom_Curve>();
|
49
|
+
*hgcurve = curve;
|
50
|
+
DATA_PTR(self) = hgcurve;
|
51
|
+
#if 0
|
52
|
+
DATA_TYPE(self) = &siren_bzcurve_type;
|
53
|
+
#endif
|
54
|
+
return self;
|
55
|
+
}
|
@@ -0,0 +1,146 @@
|
|
1
|
+
#include "curve.h"
|
2
|
+
|
3
|
+
VALUE sr_cCircle;
|
4
|
+
|
5
|
+
SR_CURVE_GET(Circle, circle)
|
6
|
+
|
7
|
+
bool siren_circle_install()
|
8
|
+
{
|
9
|
+
SR_CURVE_INIT(Circle)
|
10
|
+
rb_define_method(sr_cCircle, "initialize", RUBY_METHOD_FUNC(siren_curve_init), -1);
|
11
|
+
rb_define_method(sr_cCircle, "radius", RUBY_METHOD_FUNC(siren_circle_radius), -1);
|
12
|
+
rb_define_method(sr_cCircle, "radius=", RUBY_METHOD_FUNC(siren_circle_radius_set), -1);
|
13
|
+
rb_define_method(sr_cCircle, "center", RUBY_METHOD_FUNC(siren_circle_center), -1);
|
14
|
+
rb_define_method(sr_cCircle, "center=", RUBY_METHOD_FUNC(siren_circle_center_set), -1);
|
15
|
+
rb_define_method(sr_cCircle, "area", RUBY_METHOD_FUNC(siren_circle_area), -1);
|
16
|
+
rb_define_method(sr_cCircle, "length", RUBY_METHOD_FUNC(siren_circle_length), -1);
|
17
|
+
rb_define_method(sr_cCircle, "normal", RUBY_METHOD_FUNC(siren_circle_normal), -1);
|
18
|
+
rb_define_method(sr_cCircle, "normal=", RUBY_METHOD_FUNC(siren_circle_normal_set), -1);
|
19
|
+
rb_define_method(sr_cCircle, "dir", RUBY_METHOD_FUNC(siren_circle_dir), -1);
|
20
|
+
rb_define_method(sr_cCircle, "dir=", RUBY_METHOD_FUNC(siren_circle_dir_set), -1);
|
21
|
+
rb_define_method(sr_cCircle, "dist", RUBY_METHOD_FUNC(siren_circle_dist), -1);
|
22
|
+
rb_define_method(sr_cCircle, "distdist", RUBY_METHOD_FUNC(siren_circle_distdist), -1);
|
23
|
+
rb_define_method(sr_cCircle, "contain", RUBY_METHOD_FUNC(siren_circle_contain), -1);
|
24
|
+
return true;
|
25
|
+
}
|
26
|
+
|
27
|
+
VALUE siren_circle_radius(int argc, VALUE* argv, VALUE self)
|
28
|
+
{
|
29
|
+
Standard_Real r = siren_circle_get(self)->Radius();
|
30
|
+
return (r);
|
31
|
+
}
|
32
|
+
|
33
|
+
VALUE siren_circle_radius_set(int argc, VALUE* argv, VALUE self)
|
34
|
+
{
|
35
|
+
VALUE r;
|
36
|
+
rb_scan_args(argc, argv, "1", &r);
|
37
|
+
siren_circle_get(self)->SetRadius(r);
|
38
|
+
return Qnil;
|
39
|
+
}
|
40
|
+
|
41
|
+
VALUE siren_circle_center(int argc, VALUE* argv, VALUE self)
|
42
|
+
{
|
43
|
+
gp_Pnt center = siren_circle_get(self)->Circ().Location();
|
44
|
+
return siren_pnt_to_ary(center);
|
45
|
+
}
|
46
|
+
|
47
|
+
VALUE siren_circle_center_set(int argc, VALUE* argv, VALUE self)
|
48
|
+
{
|
49
|
+
VALUE pos;
|
50
|
+
rb_scan_args(argc, argv, "1", &pos);
|
51
|
+
gp_Pnt p = siren_ary_to_pnt(pos);
|
52
|
+
handle<Geom_Circle> circle = siren_circle_get(self);
|
53
|
+
gp_Circ circ = circle->Circ();
|
54
|
+
circ.SetLocation(p);
|
55
|
+
circle->SetCirc(circ);
|
56
|
+
return pos;
|
57
|
+
}
|
58
|
+
|
59
|
+
VALUE siren_circle_area(int argc, VALUE* argv, VALUE self)
|
60
|
+
{
|
61
|
+
handle<Geom_Circle> circle = siren_circle_get(self);
|
62
|
+
return (circle->Circ().Area());
|
63
|
+
}
|
64
|
+
|
65
|
+
VALUE siren_circle_length(int argc, VALUE* argv, VALUE self)
|
66
|
+
{
|
67
|
+
handle<Geom_Circle> circle = siren_circle_get(self);
|
68
|
+
return (circle->Circ().Length());
|
69
|
+
}
|
70
|
+
|
71
|
+
VALUE siren_circle_normal(int argc, VALUE* argv, VALUE self)
|
72
|
+
{
|
73
|
+
handle<Geom_Circle> circle = siren_circle_get(self);
|
74
|
+
// Returns the main axis of the circle.
|
75
|
+
// It is the axis perpendicular to the plane of the circle,
|
76
|
+
// passing through the "Location" point (center) of the circle.
|
77
|
+
gp_Ax1 axis = circle->Circ().Axis();
|
78
|
+
return siren_dir_to_ary(axis.Direction());
|
79
|
+
}
|
80
|
+
|
81
|
+
VALUE siren_circle_normal_set(int argc, VALUE* argv, VALUE self)
|
82
|
+
{
|
83
|
+
VALUE norm;
|
84
|
+
rb_scan_args(argc, argv, "1", &norm);
|
85
|
+
gp_Dir dir = siren_ary_to_dir(norm);
|
86
|
+
handle<Geom_Circle> circle = siren_circle_get(self);
|
87
|
+
gp_Circ circ = circle->Circ();
|
88
|
+
gp_Ax1 axis = circ.Axis();
|
89
|
+
axis.SetDirection(dir);
|
90
|
+
circ.SetAxis(axis);
|
91
|
+
circle->SetCirc(circ);
|
92
|
+
return norm;
|
93
|
+
}
|
94
|
+
|
95
|
+
VALUE siren_circle_dir(int argc, VALUE* argv, VALUE self)
|
96
|
+
{
|
97
|
+
handle<Geom_Circle> circle = siren_circle_get(self);
|
98
|
+
gp_Ax1 axis = circle->Circ().XAxis();
|
99
|
+
return siren_dir_to_ary(axis.Direction());
|
100
|
+
}
|
101
|
+
|
102
|
+
VALUE siren_circle_dir_set(int argc, VALUE* argv, VALUE self)
|
103
|
+
{
|
104
|
+
VALUE val;
|
105
|
+
rb_scan_args(argc, argv, "1", &val);
|
106
|
+
gp_Dir dir = siren_ary_to_dir(val);
|
107
|
+
handle<Geom_Circle> circle = siren_circle_get(self);
|
108
|
+
gp_Circ circ = circle->Circ();
|
109
|
+
gp_Ax2 axis;
|
110
|
+
axis.SetAxis(circ.Axis());
|
111
|
+
axis.SetXDirection(dir);
|
112
|
+
circ.SetPosition(axis);
|
113
|
+
circle->SetCirc(circ);
|
114
|
+
return val;
|
115
|
+
}
|
116
|
+
|
117
|
+
VALUE siren_circle_dist(int argc, VALUE* argv, VALUE self)
|
118
|
+
{
|
119
|
+
VALUE pos;
|
120
|
+
rb_scan_args(argc, argv, "1", &pos);
|
121
|
+
gp_Pnt p = siren_ary_to_pnt(pos);
|
122
|
+
handle<Geom_Circle> circle = siren_circle_get(self);
|
123
|
+
gp_Circ circ = circle->Circ();
|
124
|
+
return (circ.Distance(p));
|
125
|
+
}
|
126
|
+
|
127
|
+
VALUE siren_circle_distdist(int argc, VALUE* argv, VALUE self)
|
128
|
+
{
|
129
|
+
VALUE pos;
|
130
|
+
rb_scan_args(argc, argv, "1", &pos);
|
131
|
+
gp_Pnt p = siren_ary_to_pnt(pos);
|
132
|
+
handle<Geom_Circle> circle = siren_circle_get(self);
|
133
|
+
gp_Circ circ = circle->Circ();
|
134
|
+
return (circ.SquareDistance(p));
|
135
|
+
}
|
136
|
+
|
137
|
+
VALUE siren_circle_contain(int argc, VALUE* argv, VALUE self)
|
138
|
+
{
|
139
|
+
VALUE pos;
|
140
|
+
VALUE lintol = 1.0e-7;
|
141
|
+
rb_scan_args(argc, argv, "11", &pos, &lintol);
|
142
|
+
gp_Pnt p = siren_ary_to_pnt(pos);
|
143
|
+
handle<Geom_Circle> circle = siren_circle_get(self);
|
144
|
+
gp_Circ circ = circle->Circ();
|
145
|
+
return circ.Contains(p, lintol) ? Qtrue : Qfalse;
|
146
|
+
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
/**
|
2
|
+
* ellipse.cpp
|
3
|
+
* Implementation of singleton methods for ELLIPSE
|
4
|
+
*/
|
5
|
+
|
6
|
+
#include "curve.h"
|
7
|
+
|
8
|
+
VALUE sr_cEllipse;
|
9
|
+
|
10
|
+
SR_CURVE_GET(Ellipse, ellipse)
|
11
|
+
|
12
|
+
bool siren_ellipse_install()
|
13
|
+
{
|
14
|
+
SR_CURVE_INIT(Ellipse)
|
15
|
+
rb_define_method(sr_cEllipse, "initialize", RUBY_METHOD_FUNC(siren_curve_init), -1);
|
16
|
+
return true;
|
17
|
+
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
/**
|
2
|
+
* hyperbola.cpp
|
3
|
+
* Implementation of singleton methods for HYPERBOLA
|
4
|
+
*/
|
5
|
+
|
6
|
+
#include "curve.h"
|
7
|
+
|
8
|
+
VALUE sr_cHyperbola;
|
9
|
+
|
10
|
+
SR_CURVE_GET(Hyperbola, hyperbola)
|
11
|
+
|
12
|
+
bool siren_hyperbola_install()
|
13
|
+
{
|
14
|
+
SR_CURVE_INIT(Hyperbola)
|
15
|
+
rb_define_method(sr_cHyperbola, "initialize", RUBY_METHOD_FUNC(siren_curve_init), -1);
|
16
|
+
return true;
|
17
|
+
}
|