Skip to content

Commit 5405595

Browse files
committed
small fixes
1 parent a39b579 commit 5405595

File tree

3 files changed

+27
-29
lines changed

3 files changed

+27
-29
lines changed

src/geo/tools.jl

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ function dir(dart::Dart)
1212
end
1313

1414

15-
1615
function getedges(s::Face)
1716
edges = Edge[]
1817
for loop in s.loops
@@ -47,7 +46,6 @@ function getpoints(s::Face)
4746
end
4847

4948

50-
5149
function getpoints(v::Volume)
5250
points = Set{Point}()
5351
for spin in v.spins
@@ -59,7 +57,6 @@ function getpoints(v::Volume)
5957
end
6058

6159

62-
6360
function is_neighbor(surf1::Face, surf2::Face)
6461
for dart in surf1.loops[1].darts
6562
for s in dart.edge.faces
@@ -71,7 +68,6 @@ end
7168

7269

7370

74-
7571
function in_segment(X, X1, X2)
7672
tol = 1e-6
7773
X1X = X-X1
@@ -115,21 +111,6 @@ function point_in_edge(p::Point, l::Edge)
115111
end
116112

117113

118-
function coplanar(face::Face, points::Vector{Point})
119-
face.flat || return false
120-
tol = 1e-6 # reduced tolerance
121-
122-
normal = getnormal(face.loops[1])
123-
p1 = face.loops[1].darts[1].points[1]
124-
125-
for p in points # check if every point is in the plane
126-
abs(dot(p.coord - p1.coord, normal)) > tol && return false
127-
end
128-
129-
return true
130-
end
131-
132-
133114
function split_edge(geo::GeoModel, edge::Edge, point::Point)
134115

135116
p1 = edge.points[1]
@@ -180,9 +161,6 @@ function split_edge(geo::GeoModel, edge::Edge, point::Point)
180161
end
181162

182163

183-
184-
185-
186164
function intersection(l1::Edge, l2::Edge)
187165
# Assumes:
188166
# L1: P = P1 +V1*t
@@ -236,9 +214,6 @@ function parallel(dart1::Dart, dart2::Dart)
236214
end
237215

238216

239-
240-
241-
242217
function colinear(points::Vector{Point})
243218
length(points)<2 && return true
244219
tol = 1e-6
@@ -260,6 +235,7 @@ function colinear(points::Vector{Point})
260235
end
261236

262237

238+
# Get a directed normal vector even if the loop is not flat
263239
function getnormal(loop::Loop)
264240
C = getcoords(loop.points)
265241

@@ -295,6 +271,21 @@ function getnormal(loop::Loop)
295271
end
296272

297273

274+
function coplanar(face::Face, points::Vector{Point})
275+
face.flat || return false
276+
tol = 1e-6 # reduced tolerance
277+
278+
normal = getnormal(face.loops[1])
279+
p1 = face.loops[1].darts[1].points[1]
280+
281+
for p in points # check if every point is in the plane
282+
abs(dot(p.coord - p1.coord, normal)) > tol && return false
283+
end
284+
285+
return true
286+
end
287+
288+
298289
function coplanar(points::Vector{Point})
299290
n = length(points)
300291
n<=3 && return true

src/tools/table.jl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,15 @@ function Base.size(table::DataTable)
7575
end
7676

7777

78-
function Base.getproperty(table::DataTable, sym::Symbol)
79-
return getindex(table, sym)
78+
function Base.getproperty(table::DataTable, name::Symbol)
79+
key = string(name)
80+
colidx = getcolidx(table)
81+
if haskey(colidx, key)
82+
idx = colidx[key]
83+
return getindex(table, key)
84+
end
85+
86+
return getfield(table, name)
8087
end
8188

8289

test/runtests.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ let
1616
"tools/runtests.jl",
1717
"mech/runtests.jl",
1818
"dynamic/runtests.jl",
19-
"hydromech/runtests.jl",
2019
"thermomech/runtests.jl",
21-
"acoustic-mech/runtests.jl"
20+
"acoustic-mech/runtests.jl",
21+
"hydromech/runtests.jl",
2222
]
2323
end
2424
end

0 commit comments

Comments
 (0)