Skip to content

Commit 9a51936

Browse files
committed
fix merge conflicts
2 parents 708e700 + 6a3cce9 commit 9a51936

File tree

3 files changed

+75
-19
lines changed

3 files changed

+75
-19
lines changed

src/Basic.jl

+13-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,18 @@ module Basic
77
using Clipper
88

99

10-
p() = println("submodulaization")
10+
function offset(paths::Clipper.__ClipperPaths, dist::Int)
11+
o = Offset()
12+
pt = PolyTree()
13+
14+
for i = 1:length(paths)
15+
path = paths[i]
16+
add!(o, path, jtMiter, etClosedPolygon)
17+
end
18+
execute!(o, pt, dist)
19+
clear!(o)
20+
21+
return pt
22+
end
1123

1224
end # module

src/Clipper.jl

+44-18
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ module Clipper
22

33
using Cxx
44

5-
include("Basic.jl")
6-
75
# Export Clipper types
86
export Path, Paths, IntPoint
97

@@ -80,7 +78,12 @@ typealias __ClipperPolyTree Union(pcpp"ClipperLib::PolyTree",
8078
typealias __ClipperPolyNode Union(pcpp"ClipperLib::PolyNode",
8179
cpcpp"ClipperLib::PolyNode",
8280
vcpp"ClipperLib::PolyNode",
83-
rcpp"ClipperLib::PolyNode")
81+
rcpp"ClipperLib::PolyNode",
82+
Cxx.CppRef{cpcpp"ClipperLib::PolyNode", (false,false,false)})
83+
84+
typealias __ClipperPolyNodeArray Union(Cxx.CppValue{Cxx.CppTemplate{Cxx.CppBaseType{symbol("std::vector")},(Cxx.CppPtr{Cxx.CppValue{Cxx.CppBaseType{symbol("ClipperLib::PolyNode")},(false,false,false)},(false,false,false)},Cxx.CppValue{Cxx.CppTemplate{Cxx.CppBaseType{symbol("std::allocator")},(Cxx.CppPtr{Cxx.CppValue{Cxx.CppBaseType{symbol("ClipperLib::PolyNode")},(false,false,false)},(false,false,false)},)},(false,false,false)})},(false,false,false)},
85+
Cxx.CppPtr{Cxx.CppTemplate{Cxx.CppBaseType{symbol("std::vector")},(Cxx.CppPtr{Cxx.CppValue{Cxx.CppBaseType{symbol("ClipperLib::PolyNode")},(false,false,false)},(false,false,false)},Cxx.CppValue{Cxx.CppTemplate{Cxx.CppBaseType{symbol("std::allocator")},(Cxx.CppPtr{Cxx.CppValue{Cxx.CppBaseType{symbol("ClipperLib::PolyNode")},(false,false,false)},(false,false,false)},)},(false,false,false)})},(false,false,false)},
86+
Cxx.CppRef{Cxx.CppTemplate{Cxx.CppBaseType{symbol("std::vector")},(Cxx.CppPtr{Cxx.CppValue{Cxx.CppBaseType{symbol("ClipperLib::PolyNode")},(false,false,false)},(false,false,false)},Cxx.CppValue{Cxx.CppTemplate{Cxx.CppBaseType{symbol("std::allocator")},(Cxx.CppPtr{Cxx.CppValue{Cxx.CppBaseType{symbol("ClipperLib::PolyNode")},(false,false,false)},(false,false,false)},)},(false,false,false)})},(false,false,false)})
8487

8588
typealias __ClipperClipperOffset Union(pcpp"ClipperLib::ClipperOffset",
8689
cpcpp"ClipperLib::ClipperOffset",
@@ -917,62 +920,82 @@ end
917920
# Some "julian" encapsulation of Clipper types.
918921
#
919922

920-
function x(ip::__ClipperIntPoint)
923+
@inline function x(ip::__ClipperIntPoint)
921924
@cxx ip->X
922925
end
923-
function y(ip::__ClipperIntPoint)
926+
@inline function y(ip::__ClipperIntPoint)
924927
@cxx ip->Y
925928
end
926-
function ==(i1::__ClipperIntPoint, i2::__ClipperIntPoint)
929+
@inline function ==(i1::__ClipperIntPoint, i2::__ClipperIntPoint)
927930
x(i1) == x(i2) && y(i1) == y(i2)
928931
end
929-
function Base.isequal(i1::__ClipperIntPoint, i2::__ClipperIntPoint)
932+
@inline function Base.isequal(i1::__ClipperIntPoint, i2::__ClipperIntPoint)
930933
isequal(x(i1),x(i2)) && isequal(y(i1),y(i2))
931934
end
932935

933-
function Base.push!(a::__ClipperPath,
936+
@inline function Base.push!(a::__ClipperPath,
934937
b::__ClipperIntPoint)
935938
@cxx a->push_back(b)
936939
end
937940

941+
<<<<<<< HEAD
938942
function Base.push!(a::__ClipperPath, b::(Int, Int))
939943
push!(a, IntPoint(b...))
940944
end
941945

942946
function Base.push!(a::__ClipperPaths,
947+
=======
948+
@inline function Base.push!(a::__ClipperPaths,
949+
>>>>>>> master
943950
b::__ClipperPath)
944951
@cxx a->push_back(b)
945952
end
946953

947-
function Base.length(p::__ClipperPath)
954+
@inline function Base.length(p::__ClipperPath)
948955
@cxx p->size()
949956
end
950957

951-
function Base.length(p::__ClipperPaths)
958+
@inline function Base.length(p::__ClipperPaths)
952959
@cxx p->size()
953960
end
954961

955-
function Base.getindex(p::__ClipperPath, i::Integer)
956-
@cxx p->at(i-1)
962+
@inline function Base.length(p::__ClipperPolyNodeArray)
963+
@cxx p->size()
964+
end
965+
966+
@inline function Base.getindex(p::__ClipperPath, i::Integer)
967+
icxx"$p[$i-1];"
968+
end
969+
970+
@inline function Base.getindex(p::__ClipperPaths, i::Integer)
971+
icxx"$p[$i-1];"
972+
end
973+
974+
@inline function Base.getindex(p::__ClipperPolyNodeArray, i::Integer)
975+
icxx"$p[$i-1];"
957976
end
958977

959-
function Base.getindex(p::__ClipperPaths, i::Integer)
960-
@cxx p->at(i-1)
978+
@inline function Base.setindex!(path::__ClipperPath, pt::__ClipperIntPoint, i::Integer)
979+
icxx"$path[$i-1] = $pt;"
961980
end
962981

963-
function Base.isempty(p::__ClipperPath)
982+
@inline function Base.setindex!(paths::__ClipperPaths, path::__ClipperPath, i::Integer)
983+
icxx"$paths[$i-1] = $path;"
984+
end
985+
986+
@inline function Base.isempty(p::__ClipperPath)
964987
length(p) == 0
965988
end
966989

967-
function Base.isempty(p::__ClipperPaths)
990+
@inline function Base.isempty(p::__ClipperPaths)
968991
length(p) == 0
969992
end
970993

971-
function Base.endof(p::__ClipperPath)
994+
@inline function Base.endof(p::__ClipperPath)
972995
length(p)
973996
end
974997

975-
function Base.endof(p::__ClipperPaths)
998+
@inline function Base.endof(p::__ClipperPaths)
976999
length(p)
9771000
end
9781001

@@ -1014,4 +1037,7 @@ function Base.show(io::IO, p::__ClipperPaths)
10141037
end
10151038
end
10161039

1040+
# Clipper basic interface
1041+
include("Basic.jl")
1042+
10171043
end # module

test/runtests.jl

+18
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ p = Path()
2323
push!(p, (0, 0))
2424
@test p == Path([(0,0)])
2525

26+
# test setindex
27+
p = Path(2)
28+
p[1] = IntPoint(1,1)
29+
p[2] = IntPoint(2,2)
30+
@test length(p) == 2
31+
@test p[1] == IntPoint(1,1)
32+
@test p[2] == IntPoint(2,2)
33+
2634
# test area
2735
println("Testing area...")
2836
p = Path()
@@ -288,3 +296,13 @@ execute!(o, outpaths, -2)
288296
@test length(outpaths) == 2
289297
@show outpaths[1]
290298
@show outpaths
299+
300+
p = Path()
301+
push!(p, IntPoint(0,0))
302+
push!(p, IntPoint(10,0))
303+
push!(p, IntPoint(10,10))
304+
push!(p, IntPoint(0,10))
305+
ps = Paths()
306+
push!(ps, p)
307+
pt = Clipper.Basic.offset(ps, 2)
308+
@show pt

0 commit comments

Comments
 (0)