Skip to content

Commit

Permalink
remove tinyr
Browse files Browse the repository at this point in the history
  • Loading branch information
changliao1025 committed Jul 1, 2024
1 parent 413f4d4 commit 165f360
Show file tree
Hide file tree
Showing 24 changed files with 728 additions and 36,233 deletions.
68 changes: 34 additions & 34 deletions pyflowline/algorithms/auxiliary/find_index_in_list.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import copy
import numpy as np
import importlib.util
iFlag_cython = importlib.util.find_spec("cython")
iFlag_cython = importlib.util.find_spec("cython")
if iFlag_cython is not None:
from pyflowline.algorithms.cython.kernel import find_vertex_in_list
from pyflowline.external.tinyr.tinyr.tinyr import RTree
from tinyr import RTree
iFlag_use_rtree = 1
else:
iFlag_use_rtree =0
Expand All @@ -17,26 +17,26 @@ def find_vertex_on_edge(aVertex_in, pEdge_in):
aIndex_order=list()
aDistance=list()
nVertex= len(aVertex_in)
npoint = 0
npoint = 0
if nVertex > 0 :
if iFlag_use_rtree == 1:
index_vertex = RTree(max_cap=5, min_cap=2)
for i in range(nVertex):
lID = i
lID = i
x = aVertex_in[i].dLongitude_degree
y = aVertex_in[i].dLatitude_degree
y = aVertex_in[i].dLatitude_degree
left = x - 1E-5
right = x + 1E-5
bottom = y - 1E-5
top = y + 1E-5
pBound= (left, bottom, right, top)
index_vertex.insert(lID, pBound) #
index_vertex.insert(lID, pBound) #
pass
#now the new vertex
pVertex_start = pEdge_in.pVertex_start
pVertex_end = pEdge_in.pVertex_end
x1=pVertex_start.dLongitude_degree
y1=pVertex_start.dLatitude_degree
y1=pVertex_start.dLatitude_degree
x2=pVertex_end.dLongitude_degree
y2=pVertex_end.dLatitude_degree
left = np.min([x1, x2])
Expand All @@ -48,12 +48,12 @@ def find_vertex_on_edge(aVertex_in, pEdge_in):
for k in aIntersect:
pVertex = aVertex_in[k]
iFlag_overlap, dDistance, diff = pEdge_in.check_vertex_on_edge(pVertex)
if iFlag_overlap == 1:
iFlag_exist = 1
if iFlag_overlap == 1:
iFlag_exist = 1
aDistance.append(dDistance)
aIndex.append(k)
npoint = npoint + 1
else:
aIndex.append(k)
npoint = npoint + 1
else:
if diff < 1.0:
iFlag_overlap = pEdge_in.check_vertex_on_edge(pVertex)

Expand All @@ -64,27 +64,27 @@ def find_vertex_on_edge(aVertex_in, pEdge_in):
for i in np.arange( nVertex):
pVertex = aVertex_in[i]
iFlag_overlap, dDistance, diff = pEdge_in.check_vertex_on_edge(pVertex)
if iFlag_overlap == 1:
iFlag_exist = 1
if iFlag_overlap == 1:
iFlag_exist = 1
aDistance.append(dDistance)
aIndex.append(i)
npoint = npoint + 1
else:
aIndex.append(i)
npoint = npoint + 1
else:
if diff < 1.0:
iFlag_overlap = pEdge_in.check_vertex_on_edge(pVertex)

pass

#re-order
#re-order
if iFlag_exist == 1 :
x = np.array(aDistance)
b = np.argsort(x)
c = np.array(aIndex)
d= c[b]
aIndex_order = list(d)
aIndex_order = list(d)
else:
pass

return iFlag_exist, npoint , aIndex_order


Expand All @@ -106,11 +106,11 @@ def find_edge_in_list(aEdge_in, pEdge_in):
for i in np.arange( nEdge):
pEdge = aEdge_in[i]
if pEdge == pEdge_in:
iFlag_exist = 1
lIndex = i
break
iFlag_exist = 1
lIndex = i
break


return iFlag_exist, lIndex


Expand All @@ -132,10 +132,10 @@ def find_flowline_in_list(aFlowline_in, pFlowline_in):
for i in np.arange( nFlowline):
pFlowline = aFlowline_in[i]
if pFlowline == pFlowline_in:
iFlag_exist = 1
lIndex = i
break
iFlag_exist = 1
lIndex = i
break

return iFlag_exist, lIndex

def find_hexagon_through_edge(aHexagon_in, pEdge_in):
Expand All @@ -154,7 +154,7 @@ def find_hexagon_through_edge(aHexagon_in, pEdge_in):
for i in range(nHexagon):
pHexagon = aHexagon_in[i]
if pHexagon.has_this_edge(pEdge_in) ==1:
aHexagon_out.append(pHexagon)
aHexagon_out.append(pHexagon)

return aHexagon_out

Expand All @@ -170,7 +170,7 @@ def check_if_duplicates(aList_in):
# iFlag_unique = 0
# break
# else:
# pass
# pass
#return iFlag_unique
return int(len(aList_in) == len(set(aList_in)))

Expand All @@ -186,7 +186,7 @@ def add_unique_vertex(aVertex_in, pVertex_in, dThreshold_in = 1.0E-6):
[type]: [description]
"""
iFlag_exist = 0
nVertex = len(aVertex_in)
nVertex = len(aVertex_in)

iFlag_exist, dummy = find_vertex_in_list(aVertex_in, pVertex_in, dThreshold_in)

Expand All @@ -208,9 +208,9 @@ def find_list_in_list(aList_in, pList_in):
b = copy.deepcopy(a)
b.sort()
if (b == c ):
iFlag =1
iFlag =1
break
else:
iFlag = 0

return iFlag
30 changes: 15 additions & 15 deletions pyflowline/algorithms/auxiliary/find_vertex_in_list.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

import importlib.util
import numpy as np
iFlag_cython = importlib.util.find_spec("cython")
iFlag_cython = importlib.util.find_spec("cython")
if iFlag_cython is not None:
from pyflowline.external.tinyr.tinyr.tinyr import RTree
from tinyr import RTree
iFlag_use_rtree = 1
else:
iFlag_use_rtree =0
Expand All @@ -28,20 +28,20 @@ def find_vertex_in_list(aVertex_in, pVertex_in, dThreshold_in=1.0E-6):
#index_vertex = rtree.index.Index()
index_vertex = RTree(max_cap=5, min_cap=2)
for i in range(nVertex):
lID = i
lID = i
x=aVertex_in[i].dLongitude_degree
y=aVertex_in[i].dLatitude_degree
y=aVertex_in[i].dLatitude_degree
left = x - 1E-5
right = x + 1E-5
bottom = y - 1E-5
top = y + 1E-5
pBound = (left, bottom, right, top)
index_vertex.insert(lID, pBound) #
index_vertex.insert(lID, pBound) #
pass

#now the new vertex
x=pVertex_in.dLongitude_degree
y=pVertex_in.dLatitude_degree
y=pVertex_in.dLatitude_degree
left = x - 1E-5
right = x + 1E-5
bottom = y-1E-5
Expand All @@ -53,10 +53,10 @@ def find_vertex_in_list(aVertex_in, pVertex_in, dThreshold_in=1.0E-6):
pVertex = aVertex_in[k]
#dDistance = pVertex.calculate_distance(pVertex_in)
if pVertex == pVertex_in: #if dDistance < dThreshold_in:
iFlag_exist = 1

iFlag_exist = 1
lIndex = k
break
break
else:
pass
pass
Expand All @@ -67,16 +67,16 @@ def find_vertex_in_list(aVertex_in, pVertex_in, dThreshold_in=1.0E-6):
pVertex = aVertex_in[i]
#dDistance = pVertex.calculate_distance(pVertex_in)
if pVertex == pVertex_in: #if dDistance < dThreshold_in:
iFlag_exist = 1
lIndex = i
break

iFlag_exist = 1
lIndex = i
break
else:
pass

pass
pass

else:
pass

return iFlag_exist, lIndex
Binary file not shown.
Binary file not shown.
18 changes: 9 additions & 9 deletions pyflowline/algorithms/cython/kernel.cpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 165f360

Please sign in to comment.