siren2 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 762027bc65686f211bfdaf6cbd711492632e8581
|
|
4
|
+
data.tar.gz: '08e1f0d55ad9dcc2f3d3e04eeb9b8d8f3ab36a35'
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 0ea41c6d0d923158487c5589d63688dfc526ec1eedbb9cfc0944f8d53ee5b6ff451060665cd790f9e2aea17110e873cb39606dd7bd4fab8eb2827976917f5a32
|
|
7
|
+
data.tar.gz: 32614fe45eb8de8cdb52e6503bc28c4aebedaf961aff6f822a802a51c23a7f45973374f41ac52209ad08e042e24418079fb3b9bea3286aeb5b90f85492e914d3
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017 Daisuke YAMAGUCHI
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Siren
|
|
2
|
+
|
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/siren`. To experiment with that code, run `bin/console` for an interactive prompt.
|
|
4
|
+
|
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
Add this line to your application's Gemfile:
|
|
10
|
+
|
|
11
|
+
```ruby
|
|
12
|
+
gem 'siren'
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
And then execute:
|
|
16
|
+
|
|
17
|
+
$ bundle
|
|
18
|
+
|
|
19
|
+
Or install it yourself as:
|
|
20
|
+
|
|
21
|
+
$ gem install siren
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
TODO: Write usage instructions here
|
|
26
|
+
|
|
27
|
+
## Development
|
|
28
|
+
|
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
30
|
+
|
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
32
|
+
|
|
33
|
+
## Contributing
|
|
34
|
+
|
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/dyama/siren.
|
|
36
|
+
|
data/Rakefile
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require "bundler/gem_tasks"
|
|
2
|
+
require "rake/testtask"
|
|
3
|
+
|
|
4
|
+
Rake::TestTask.new(:test) do |t|
|
|
5
|
+
t.libs << "test"
|
|
6
|
+
t.libs << "lib"
|
|
7
|
+
t.test_files = FileList['test/**/*_test.rb']
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
require "rake/extensiontask"
|
|
11
|
+
|
|
12
|
+
task :build => :compile
|
|
13
|
+
|
|
14
|
+
Rake::ExtensionTask.new("siren2") do |ext|
|
|
15
|
+
ext.lib_dir = "lib/siren2"
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
task :default => [:clobber, :compile, :test]
|
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "siren"
|
|
5
|
+
|
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
+
|
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
+
# require "pry"
|
|
11
|
+
# Pry.start
|
|
12
|
+
|
|
13
|
+
require "irb"
|
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
require "mkmf"
|
|
2
|
+
require 'pathname'
|
|
3
|
+
|
|
4
|
+
dir = File.expand_path(File.dirname(__FILE__))
|
|
5
|
+
siren_incdir = "#{dir}/inc"
|
|
6
|
+
siren_incpaths = []
|
|
7
|
+
siren_incpaths << siren_incdir
|
|
8
|
+
siren_incpaths << Dir.glob("#{siren_incdir}/*/").map.to_a
|
|
9
|
+
|
|
10
|
+
# Open CASCADE Technology configuration
|
|
11
|
+
# Check http://dev.opencascade.org/doc/refman/html/index.html
|
|
12
|
+
thirdparty_libs = []
|
|
13
|
+
occt_libpaths = []
|
|
14
|
+
occt_incpaths = []
|
|
15
|
+
|
|
16
|
+
if occt_libpaths.size == 0 and occt_incpaths.size == 0
|
|
17
|
+
os = RbConfig::CONFIG['host_os'].downcase
|
|
18
|
+
case os
|
|
19
|
+
when /linux|solaris|bsd/
|
|
20
|
+
occt_libpaths = [ '/opt/occ/710/lin64/gcc/lib' ]
|
|
21
|
+
occt_incpaths = [ '/opt/occ/710/inc' ]
|
|
22
|
+
when /darwin|mac os/
|
|
23
|
+
occt_libpaths = [ '/usr/local/opt/opencascade/lib' ]
|
|
24
|
+
occt_incpaths = [ '/usr/local/opt/opencascade/include/opencascade' ]
|
|
25
|
+
when /mswin|mingw/
|
|
26
|
+
occt_libpaths = [ '\occ\700\mingw32\gcc\lib' ]
|
|
27
|
+
occt_incpaths = [ '\occ\700\inc' ]
|
|
28
|
+
spec.cxx.flags << '-D_USE_MATH_DEFINES'
|
|
29
|
+
spec.cxx.flags << '-D__NO_INLINE__'
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
occt_libs = [
|
|
34
|
+
# Foundation classes
|
|
35
|
+
'TKernel', 'TKMath',
|
|
36
|
+
# Modeling data
|
|
37
|
+
'TKG2d', 'TKG3d', 'TKGeomBase', 'TKBRep',
|
|
38
|
+
# Modeling algorithms
|
|
39
|
+
'TKGeomAlgo', 'TKTopAlgo', 'TKBO', 'TKPrim',
|
|
40
|
+
'TKShHealing', 'TKHLR', 'TKMesh', 'TKBool',
|
|
41
|
+
'TKXMesh', 'TKFeat', 'TKFillet', 'TKOffset',
|
|
42
|
+
# Data excange
|
|
43
|
+
'TKXSBase', 'TKSTL', 'TKIGES', 'TKSTEP',
|
|
44
|
+
'TKSTEP209', 'TKSTEPAttr', 'TKSTEPBase',
|
|
45
|
+
]
|
|
46
|
+
|
|
47
|
+
# for Compiler
|
|
48
|
+
$CFLAGS += " -Wno-unused-function -Wno-unused-variable -Wno-unknown-pragmas"
|
|
49
|
+
$CPPFLAGS += " " + [occt_incpaths, siren_incpaths].flatten.map{|d| " -I#{d}"}.join
|
|
50
|
+
$CXXFLAGS += " -std=gnu++11"
|
|
51
|
+
|
|
52
|
+
# for Linker
|
|
53
|
+
$LDFLAGS = [occt_libpaths].flatten.map{|d| " -L#{d}"}.join
|
|
54
|
+
$LDFLAGS += [occt_libs, thirdparty_libs].flatten.map{|d| " -l#{d}"}.join
|
|
55
|
+
|
|
56
|
+
$srcs = []
|
|
57
|
+
$srcs << Dir.glob("#{dir}/src/*.{c,cpp}").map{|f| File.expand_path(f) }
|
|
58
|
+
$srcs << Dir.glob("#{dir}/src/*/*.{c,cpp}").map{|f| File.expand_path(f) }
|
|
59
|
+
$srcs.flatten!
|
|
60
|
+
|
|
61
|
+
$objs = []
|
|
62
|
+
$objs << $srcs.map{ |f| f.gsub(/\.\w+$/, '.o') }
|
|
63
|
+
$objs.flatten!
|
|
64
|
+
|
|
65
|
+
create_makefile("siren2/siren2")
|
|
66
|
+
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
#ifndef _BNDBOX_H_
|
|
2
|
+
#define _BNDBOX_H_
|
|
3
|
+
|
|
4
|
+
#include "siren.h"
|
|
5
|
+
#include <Bnd_Box.hxx>
|
|
6
|
+
#include <BRepBndLib.hxx>
|
|
7
|
+
|
|
8
|
+
extern VALUE sr_cBndBox;
|
|
9
|
+
|
|
10
|
+
bool siren_bndbox_install();
|
|
11
|
+
void siren_bndbox_final( void* p);
|
|
12
|
+
static rb_data_type_t siren_bndbox_type = { "BndBox", siren_bndbox_final };
|
|
13
|
+
VALUE siren_bndbox_new( const TopoDS_Shape& shape);
|
|
14
|
+
Bnd_Box* siren_bndbox_get(VALUE obj);
|
|
15
|
+
#define siren_is_bndbox(obj) (DATA_TYPE(obj) == &siren_bndbox_type)
|
|
16
|
+
|
|
17
|
+
VALUE siren_bndbox_init(int, VALUE*, VALUE);
|
|
18
|
+
VALUE siren_bndbox_to_s(int, VALUE*, VALUE);
|
|
19
|
+
VALUE siren_bndbox_min(int, VALUE*, VALUE);
|
|
20
|
+
VALUE siren_bndbox_max(int, VALUE*, VALUE);
|
|
21
|
+
VALUE siren_bndbox_add(int, VALUE*, VALUE);
|
|
22
|
+
VALUE siren_bndbox_is_out(int, VALUE*, VALUE);
|
|
23
|
+
VALUE siren_bndbox_center(int, VALUE*, VALUE);
|
|
24
|
+
VALUE siren_bndbox_xsize(int, VALUE*, VALUE);
|
|
25
|
+
VALUE siren_bndbox_ysize(int, VALUE*, VALUE);
|
|
26
|
+
VALUE siren_bndbox_zsize(int, VALUE*, VALUE);
|
|
27
|
+
VALUE siren_bndbox_is_void(int, VALUE*, VALUE);
|
|
28
|
+
VALUE siren_bndbox_is_whole(int, VALUE*, VALUE);
|
|
29
|
+
VALUE siren_bndbox_void_bang(int, VALUE*, VALUE);
|
|
30
|
+
VALUE siren_bndbox_whole_bang(int, VALUE*, VALUE);
|
|
31
|
+
VALUE siren_bndbox_is_xthin(int, VALUE*, VALUE);
|
|
32
|
+
VALUE siren_bndbox_is_ythin(int, VALUE*, VALUE);
|
|
33
|
+
VALUE siren_bndbox_is_zthin(int, VALUE*, VALUE);
|
|
34
|
+
VALUE siren_bndbox_is_openxmin(int, VALUE*, VALUE);
|
|
35
|
+
VALUE siren_bndbox_is_openxmax(int, VALUE*, VALUE);
|
|
36
|
+
VALUE siren_bndbox_is_openymin(int, VALUE*, VALUE);
|
|
37
|
+
VALUE siren_bndbox_is_openymax(int, VALUE*, VALUE);
|
|
38
|
+
VALUE siren_bndbox_is_openzmin(int, VALUE*, VALUE);
|
|
39
|
+
VALUE siren_bndbox_is_openzmax(int, VALUE*, VALUE);
|
|
40
|
+
VALUE siren_bndbox_openxmin_bang(int, VALUE*, VALUE);
|
|
41
|
+
VALUE siren_bndbox_openxmax_bang(int, VALUE*, VALUE);
|
|
42
|
+
VALUE siren_bndbox_openymin_bang(int, VALUE*, VALUE);
|
|
43
|
+
VALUE siren_bndbox_openymax_bang(int, VALUE*, VALUE);
|
|
44
|
+
VALUE siren_bndbox_openzmin_bang(int, VALUE*, VALUE);
|
|
45
|
+
VALUE siren_bndbox_openzmax_bang(int, VALUE*, VALUE);
|
|
46
|
+
VALUE siren_bndbox_set_gap(int, VALUE*, VALUE);
|
|
47
|
+
VALUE siren_bndbox_get_gap(int, VALUE*, VALUE);
|
|
48
|
+
VALUE siren_bndbox_dist(int, VALUE*, VALUE);
|
|
49
|
+
VALUE siren_bndbox_square(int, VALUE*, VALUE);
|
|
50
|
+
|
|
51
|
+
#endif
|
data/ext/siren2/inc/bo.h
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#ifndef _BO_H_
|
|
2
|
+
#define _BO_H_
|
|
3
|
+
|
|
4
|
+
#include "siren.h"
|
|
5
|
+
#include "shape.h"
|
|
6
|
+
|
|
7
|
+
#include <BRepAlgoAPI_BooleanOperation.hxx>
|
|
8
|
+
#include <BRepAlgoAPI_Common.hxx>
|
|
9
|
+
#include <BRepAlgoAPI_Cut.hxx>
|
|
10
|
+
#include <BRepAlgoAPI_Fuse.hxx>
|
|
11
|
+
|
|
12
|
+
#include <BRepProj_Projection.hxx>
|
|
13
|
+
|
|
14
|
+
bool siren_bo_install();
|
|
15
|
+
VALUE siren_bo_common (int, VALUE*, VALUE);
|
|
16
|
+
VALUE siren_bo_fuse (int, VALUE*, VALUE);
|
|
17
|
+
VALUE siren_bo_cut (int, VALUE*, VALUE);
|
|
18
|
+
VALUE siren_bo_projwire (int, VALUE*, VALUE);
|
|
19
|
+
|
|
20
|
+
#endif
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#ifndef _BREP_H_
|
|
2
|
+
#define _BREP_H_
|
|
3
|
+
|
|
4
|
+
#include "siren.h"
|
|
5
|
+
#include "vec.h"
|
|
6
|
+
#include "shape.h"
|
|
7
|
+
|
|
8
|
+
#include <BRepTools.hxx>
|
|
9
|
+
#include <BRep_Builder.hxx>
|
|
10
|
+
|
|
11
|
+
bool siren_brep_install();
|
|
12
|
+
|
|
13
|
+
VALUE siren_brep_save(int, VALUE*, VALUE);
|
|
14
|
+
VALUE siren_brep_load(int, VALUE*, VALUE);
|
|
15
|
+
VALUE siren_brep_dump(int, VALUE*, VALUE);
|
|
16
|
+
|
|
17
|
+
#endif
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
#ifndef _COMMON_H_
|
|
2
|
+
#define _COMMON_H_
|
|
3
|
+
|
|
4
|
+
#include "ruby.h"
|
|
5
|
+
#include "shape.h"
|
|
6
|
+
|
|
7
|
+
#include <gp_Vec.hxx>
|
|
8
|
+
#include <gp_Pnt.hxx>
|
|
9
|
+
#include <gp_Dir.hxx>
|
|
10
|
+
#include <gp_Ax1.hxx>
|
|
11
|
+
#include <gp_Ax2.hxx>
|
|
12
|
+
#include <gp_Ax3.hxx>
|
|
13
|
+
|
|
14
|
+
void siren_ary_to_xyz(VALUE ary, Standard_Real& x, Standard_Real& y, Standard_Real& z);
|
|
15
|
+
|
|
16
|
+
inline gp_Pnt siren_ary_to_pnt(VALUE val)
|
|
17
|
+
{
|
|
18
|
+
Standard_Real x, y, z;
|
|
19
|
+
siren_ary_to_xyz(val, x, y, z);
|
|
20
|
+
return gp_Pnt(x, y, z);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
inline gp_Vec siren_ary_to_vec(VALUE val)
|
|
24
|
+
{
|
|
25
|
+
Standard_Real x, y, z;
|
|
26
|
+
siren_ary_to_xyz(val, x, y, z);
|
|
27
|
+
return gp_Vec(x, y, z);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
inline gp_Dir siren_ary_to_dir(VALUE val)
|
|
31
|
+
{
|
|
32
|
+
Standard_Real x, y, z;
|
|
33
|
+
siren_ary_to_xyz(val, x, y, z);
|
|
34
|
+
return gp_Dir(x, y, z);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
inline gp_Ax1 siren_ary_to_ax1(VALUE pos, VALUE norm)
|
|
38
|
+
{
|
|
39
|
+
return gp_Ax1(siren_ary_to_pnt(pos), siren_ary_to_dir(norm));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
inline gp_Ax2 siren_ary_to_ax2(VALUE pos, VALUE norm, VALUE vdir)
|
|
43
|
+
{
|
|
44
|
+
return gp_Ax2(siren_ary_to_pnt(pos), siren_ary_to_dir(norm), siren_ary_to_dir(vdir));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
inline gp_Ax2 siren_ary_to_ax2(VALUE pos, VALUE norm)
|
|
48
|
+
{
|
|
49
|
+
return gp_Ax2(siren_ary_to_pnt(pos), siren_ary_to_dir(norm));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
inline gp_Ax3 siren_ary_to_ax3(VALUE pos, VALUE norm, VALUE vdir)
|
|
53
|
+
{
|
|
54
|
+
return gp_Ax3(siren_ary_to_pnt(pos), siren_ary_to_dir(norm), siren_ary_to_dir(vdir));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
inline gp_Ax3 siren_ary_to_ax3(VALUE pos, VALUE norm)
|
|
58
|
+
{
|
|
59
|
+
return gp_Ax3(siren_ary_to_pnt(pos), siren_ary_to_dir(norm));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
inline VALUE siren_pnt_to_ary(const gp_Pnt& pnt)
|
|
63
|
+
{
|
|
64
|
+
VALUE res[3];
|
|
65
|
+
res[0] = DBL2NUM(pnt.X());
|
|
66
|
+
res[1] = DBL2NUM(pnt.Y());
|
|
67
|
+
res[2] = DBL2NUM(pnt.Z());
|
|
68
|
+
return rb_ary_new_from_values(3, res);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
inline VALUE siren_dir_to_ary(const gp_Dir& dir)
|
|
72
|
+
{
|
|
73
|
+
VALUE res[3];
|
|
74
|
+
res[0] = DBL2NUM(dir.X());
|
|
75
|
+
res[1] = DBL2NUM(dir.Y());
|
|
76
|
+
res[2] = DBL2NUM(dir.Z());
|
|
77
|
+
return rb_ary_new_from_values(3, res);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
inline VALUE siren_vec_to_ary(const gp_Vec& vec)
|
|
81
|
+
{
|
|
82
|
+
VALUE res[3];
|
|
83
|
+
res[0] = DBL2NUM(vec.X());
|
|
84
|
+
res[1] = DBL2NUM(vec.Y());
|
|
85
|
+
res[2] = DBL2NUM(vec.Z());
|
|
86
|
+
return rb_ary_new_from_values(3, res);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
inline VALUE siren_pnt_new(double x, double y, double z)
|
|
90
|
+
{
|
|
91
|
+
VALUE res[3];
|
|
92
|
+
res[0] = DBL2NUM(x);
|
|
93
|
+
res[1] = DBL2NUM(y);
|
|
94
|
+
res[2] = DBL2NUM(z);
|
|
95
|
+
return rb_ary_new_from_values(3, res);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
#endif
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
#ifndef _CURVE_H_
|
|
2
|
+
#define _CURVE_H_
|
|
3
|
+
|
|
4
|
+
#include "siren.h"
|
|
5
|
+
|
|
6
|
+
#include <Geom_Curve.hxx>
|
|
7
|
+
#include <GeomAbs_CurveType.hxx>
|
|
8
|
+
|
|
9
|
+
extern VALUE sr_cCurve;
|
|
10
|
+
|
|
11
|
+
VALUE siren_curve_allocate(VALUE);
|
|
12
|
+
VALUE siren_curve_new(handle<Geom_Curve> curve);
|
|
13
|
+
|
|
14
|
+
void siren_curve_final(void* p);
|
|
15
|
+
static rb_data_type_t siren_curve_type = { "Curve", siren_curve_final };
|
|
16
|
+
|
|
17
|
+
#include "curve/line.h"
|
|
18
|
+
#include "curve/circle.h"
|
|
19
|
+
#include "curve/ellipse.h"
|
|
20
|
+
#include "curve/hyperbola.h"
|
|
21
|
+
#include "curve/parabola.h"
|
|
22
|
+
#include "curve/bzcurve.h"
|
|
23
|
+
#include "curve/bscurve.h"
|
|
24
|
+
#include "curve/offsetcurve.h"
|
|
25
|
+
|
|
26
|
+
inline GeomAbs_CurveType siren_curve_geomtype_native(handle<Geom_Curve> hgc)
|
|
27
|
+
{
|
|
28
|
+
handle<Standard_Type> type = hgc->DynamicType();
|
|
29
|
+
/* Geom_BoundedCurve */
|
|
30
|
+
if (STANDARD_TYPE(Geom_BezierCurve) == type) { return GeomAbs_BezierCurve; }
|
|
31
|
+
if (STANDARD_TYPE(Geom_BSplineCurve) == type) { return GeomAbs_BSplineCurve; }
|
|
32
|
+
/* Geom_Conic */
|
|
33
|
+
if (STANDARD_TYPE(Geom_Circle) == type) { return GeomAbs_Circle; }
|
|
34
|
+
if (STANDARD_TYPE(Geom_Ellipse) == type) { return GeomAbs_Ellipse; }
|
|
35
|
+
if (STANDARD_TYPE(Geom_Hyperbola) == type) { return GeomAbs_Hyperbola; }
|
|
36
|
+
if (STANDARD_TYPE(Geom_Parabola) == type) { return GeomAbs_Parabola; }
|
|
37
|
+
/* Line */
|
|
38
|
+
if (STANDARD_TYPE(Geom_Line) == type) { return GeomAbs_Line; }
|
|
39
|
+
return GeomAbs_OtherCurve;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
bool siren_curve_install();
|
|
43
|
+
handle<Geom_Curve>* siren_curve_get(VALUE obj);
|
|
44
|
+
struct RClass* siren_curve_rclass();
|
|
45
|
+
|
|
46
|
+
VALUE siren_curve_new(handle<Geom_Curve> curve);
|
|
47
|
+
VALUE siren_curve_init(int, VALUE*, VALUE);
|
|
48
|
+
|
|
49
|
+
#define SR_CURVE_GET(OCCT,SRT) \
|
|
50
|
+
handle<Geom_##OCCT> siren_##SRT##_get(VALUE self) \
|
|
51
|
+
{ \
|
|
52
|
+
auto curve = siren_curve_get(self); \
|
|
53
|
+
auto res = handle<Geom_##OCCT>::DownCast(*curve); \
|
|
54
|
+
if (res.IsNull()) { \
|
|
55
|
+
rb_raise(Qnil, "The geometry type is not " #SRT "."); \
|
|
56
|
+
} \
|
|
57
|
+
return res; \
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
#define SR_CURVE_INIT(CLASS) \
|
|
61
|
+
sr_c##CLASS = rb_define_class_under(sr_mSiren, #CLASS, sr_cCurve); \
|
|
62
|
+
rb_define_alloc_func(sr_c##CLASS, siren_curve_allocate);
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
#endif
|