mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
debug internal mesher
This commit is contained in:
1 parent
97762756f8
commit
ceff5f3083
3 files changed
+73
-39
No files matched your search
+58
-29
@@ -40,20 +40,20 @@ class InternalMeshing(AMeshingTool):
|
||||
step: float = 50,
|
||||
limites=[-1, -1],
|
||||
linear: bool = True):
|
||||
if reach is None or len(reach.profiles) == 0:
|
||||
return reach
|
||||
|
||||
if limites[0] > limites[1]:
|
||||
lim = limites[1]
|
||||
limites[1] = limites[0]
|
||||
limites[0] = lim
|
||||
elif limites[0] == limites[1]:
|
||||
return reach
|
||||
# pre process
|
||||
|
||||
# we never modify original profiles, we work on copies
|
||||
m_profiles = self.st_to_m(reach, limites)
|
||||
new_profiles = self.interpolate_transversal_step(m_profiles,
|
||||
step)
|
||||
profiles = self.get_profiles(reach, limites)
|
||||
if profiles is None:
|
||||
return []
|
||||
|
||||
guide_list = self.get_guide_list(reach, profiles)
|
||||
if guide_list is None:
|
||||
return []
|
||||
|
||||
# we never modify original profiles, we work on the copies
|
||||
m_profiles = self.st_to_m(profiles, guide_list)
|
||||
new_profiles = self.interpolate_transversal_step(m_profiles, step)
|
||||
|
||||
for new_profiles2 in new_profiles:
|
||||
for p in new_profiles2:
|
||||
@@ -61,19 +61,7 @@ class InternalMeshing(AMeshingTool):
|
||||
|
||||
return new_profiles
|
||||
|
||||
def st_to_m(self, reach, limites):
|
||||
|
||||
gl = reach.compute_guidelines()
|
||||
profiles = [reach.profile(i).copy()
|
||||
for i in range(limites[0], limites[1]+1)
|
||||
]
|
||||
|
||||
# we make sure that the lines are in the left-to-right order
|
||||
guide_list = [
|
||||
x.name
|
||||
for x in profiles[0].named_points()
|
||||
if x.name in gl[0]
|
||||
]
|
||||
def st_to_m(self, profiles, guide_list):
|
||||
|
||||
gl1 = [""] + guide_list
|
||||
gl2 = guide_list + [""]
|
||||
@@ -193,23 +181,25 @@ class InternalMeshing(AMeshingTool):
|
||||
for i in range(len2):
|
||||
ltot2 += sect2.point(start2+i).dist(sect2.point(start2+i+1))
|
||||
beta.append(ltot2)
|
||||
beta = list(map(lambda x: x/ltot2, beta)) # current ratios
|
||||
for i in range(len1 - len2):
|
||||
beta.append(1.0)
|
||||
beta.append(0.0) # beta[-1]
|
||||
if len2 < 1 or ltot2 < 0.0001:
|
||||
# unique point (copy len1 times)
|
||||
# we are at an edge of the profile
|
||||
for i in range(len1-len2):
|
||||
p = sect2.point(start2).copy()
|
||||
sect2.insert_point(start2, p)
|
||||
len2 += 1
|
||||
if tag1 == '': # left end point
|
||||
sect2.point(start2).name = ''
|
||||
if tag2 == '': # left end point
|
||||
sect2.point(start2+1).name = ''
|
||||
elif ltot1 < 0.0001:
|
||||
sect2.add_npoints(len1-len2)
|
||||
len2 = len1
|
||||
else: # regular case
|
||||
beta = list(map(lambda x: x/ltot2, beta)) # current ratios
|
||||
for i in range(len1 - len2):
|
||||
beta.append(1.0)
|
||||
beta.append(0.0) # beta[-1]
|
||||
# loop on the points to insert
|
||||
for k in range(len1-len2):
|
||||
trouve = False
|
||||
@@ -343,3 +333,42 @@ class InternalMeshing(AMeshingTool):
|
||||
return new_rk, new_end_rk, new_begin_rk
|
||||
else:
|
||||
return new_rk, new_begin_rk, new_end_rk
|
||||
|
||||
def get_guide_list(self, reach, profiles):
|
||||
|
||||
gl = reach.compute_guidelines()
|
||||
|
||||
# we make sure that the lines are in the left-to-right order
|
||||
guide_list = [
|
||||
[
|
||||
x.name
|
||||
for x in p.named_points()
|
||||
if x.name in gl[0]
|
||||
]
|
||||
for p in profiles]
|
||||
|
||||
# we make sure the lines never cross
|
||||
for gl in guide_list:
|
||||
for i in range(len(guide_list[0])):
|
||||
if gl[i] != guide_list[0][i]:
|
||||
return None
|
||||
|
||||
return guide_list[0]
|
||||
|
||||
def get_profiles(self, reach, limites):
|
||||
|
||||
if reach is None or len(reach.profiles) == 0:
|
||||
return None
|
||||
|
||||
if limites[0] > limites[1]:
|
||||
lim = limites[1]
|
||||
limites[1] = limites[0]
|
||||
limites[0] = lim
|
||||
elif limites[0] == limites[1]:
|
||||
return None
|
||||
|
||||
profiles = [reach.profile(i).copy()
|
||||
for i in range(limites[0], limites[1]+1)
|
||||
]
|
||||
|
||||
return profiles
|
||||
Reference in new issue
Block a user