Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
blender-addons
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
blender
blender-addons
Commits
aa62070c
Commit
aa62070c
authored
12 years ago
by
Tim Spriggs
Browse files
Options
Downloads
Patches
Plain Diff
use bmesh.from_pydata instead of mesh.faces
parent
d292abb9
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
io_convert_image_to_mesh_img/__init__.py
+4
-1
4 additions, 1 deletion
io_convert_image_to_mesh_img/__init__.py
io_convert_image_to_mesh_img/import_img.py
+33
-13
33 additions, 13 deletions
io_convert_image_to_mesh_img/import_img.py
with
37 additions
and
14 deletions
io_convert_image_to_mesh_img/__init__.py
+
4
−
1
View file @
aa62070c
...
...
@@ -20,7 +20,7 @@ bl_info = {
"
name
"
:
"
HiRISE DTM from PDS IMG
"
,
"
author
"
:
"
Tim Spriggs (tims@uahirise.org)
"
,
"
version
"
:
(
0
,
1
,
3
),
"
blender
"
:
(
2
,
6
,
2
),
"
blender
"
:
(
2
,
6
,
3
),
"
location
"
:
"
File > Import > HiRISE DTM from PDS IMG (.IMG)
"
,
"
description
"
:
"
Import a HiRISE DTM formatted as a PDS IMG file
"
,
"
warning
"
:
"
May consume a lot of memory
"
,
...
...
@@ -41,6 +41,9 @@ bl_info = {
# 0.1.3 - upstream blender updates
# performance enhancements by Chris Van Horne
# (TJS - 2012-03-14)
# 0.1.4 - use bmesh from_pydata in blender 2.6.3
# fixed/optimized bin2 method
# (TJS - 2012-04-30)
if
"
bpy
"
in
locals
():
...
...
This diff is collapsed.
Click to expand it.
io_convert_image_to_mesh_img/import_img.py
+
33
−
13
View file @
aa62070c
...
...
@@ -194,6 +194,8 @@ class hirise_dtm_importer(object):
def
bin2
(
self
,
image_iter
,
bin2_method_type
=
"
SLOW
"
):
'''
this is an iterator that: Given an image iterator will yield binned lines
'''
ignore_value
=
self
.
__ignore_value
img_props
=
next
(
image_iter
)
# dimensions shrink as we remove pixels
processed_dims
=
img_props
.
processed_dims
()
...
...
@@ -207,7 +209,7 @@ class hirise_dtm_importer(object):
# Take two lists [a1, a2, a3], [b1, b2, b3] and combine them into one
# list of [a1 + b1, a2+b2, ... ] as long as both values are not ignorable
combine_fun
=
lambda
a
,
b
:
a
!=
self
.
__
ignore_value
and
b
!=
self
.
__
ignore_value
and
a
+
b
or
self
.
__
ignore_value
combine_fun
=
lambda
a
,
b
:
a
!=
ignore_value
and
b
!=
ignore_value
and
(
a
+
b
)
/
2
or
ignore_value
line_count
=
0
ret_list
=
[]
...
...
@@ -220,7 +222,9 @@ class hirise_dtm_importer(object):
del
tmp_list
[
0
:
2
]
yield
ret_list
ret_list
=
[]
line_count
+=
1
else
:
last_line
=
line
line_count
+=
1
def
bin6
(
self
,
image_iter
,
bin6_method_type
=
"
SLOW
"
):
'''
this is an iterator that: Given an image iterator will yield binned lines
'''
...
...
@@ -276,9 +280,10 @@ class hirise_dtm_importer(object):
if
not
ints
:
binned_data
.
append
(
IGNORE_VALUE
)
else
:
binned_data
.
append
(
sum
(
ints
)
/
len
(
ints
)
)
binned_data
.
append
(
sum
(
ints
,
0.0
)
/
len
(
ints
)
)
base
+=
6
return
binned_data
def
bin6_real_fast
(
self
,
raw_data
):
...
...
@@ -499,7 +504,7 @@ class hirise_dtm_importer(object):
point_offset
+=
len
(
last_line
)
-
last_line
.
count
(
None
)
for
z
in
last_line
:
if
z
!=
None
:
coords
.
ext
end
(
[
x
*
scale_x
,
0.0
,
z
]
)
coords
.
app
end
(
(
x
*
scale_x
,
0.0
,
z
)
)
coord
+=
1
x
+=
1
...
...
@@ -531,7 +536,7 @@ class hirise_dtm_importer(object):
x
=
0
for
z
in
dtm_line
:
if
z
!=
None
:
coords
.
ext
end
(
[
x
*
scale_x
,
y_val
,
z
]
)
coords
.
app
end
(
(
x
*
scale_x
,
y_val
,
z
)
)
coord
+=
1
x
+=
1
...
...
@@ -549,12 +554,12 @@ class hirise_dtm_importer(object):
# Common case: we can create a square face
if
none_val
==
0
:
faces
.
ext
end
(
[
faces
.
app
end
(
(
previous_point_offset
,
previous_point_offset
+
1
,
point_offset
+
1
,
point_offset
,
]
)
)
)
face_count
+=
1
elif
none_val
==
1
:
# special case: we can implement a triangular face
...
...
@@ -579,12 +584,27 @@ class hirise_dtm_importer(object):
last_line
=
dtm_line
me
=
bpy
.
data
.
meshes
.
new
(
img_props
.
name
())
# create a new mesh
me
.
vertices
.
add
(
len
(
coords
)
/
3
)
me
.
vertices
.
foreach_set
(
"
co
"
,
coords
)
me
.
faces
.
add
(
len
(
faces
)
/
4
)
me
.
faces
.
foreach_set
(
"
vertices_raw
"
,
faces
)
#from_pydata(self, vertices, edges, faces)
#Make a mesh from a list of vertices/edges/faces
#Until we have a nicer way to make geometry, use this.
#:arg vertices:
# float triplets each representing (X, Y, Z)
# eg: [(0.0, 1.0, 0.5), ...].
#:type vertices: iterable object
#:arg edges:
# int pairs, each pair contains two indices to the
# *vertices* argument. eg: [(1, 2), ...]
#:type edges: iterable object
#:arg faces:
# iterator of faces, each faces contains three or more indices to
# the *vertices* argument. eg: [(5, 6, 8, 9), (1, 2, 3), ...]
#:type faces: iterable object
me
.
from_pydata
(
coords
,
[],
faces
)
# me.vertices.add(len(coords)/3)
# me.vertices.foreach_set("co", coords)
# me.faces.add(len(faces)/4)
# me.faces.foreach_set("vertices_raw", faces)
me
.
update
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment