[Bf-extensions-cvs] [722e9d54] master: io_convert_image_to_mesh_img: complete rewrite: T51754
meta-androcto
noreply at git.blender.org
Thu Jun 15 14:14:09 CEST 2017
Commit: 722e9d54282befe9eac75b0cd6879a336fe0e394
Author: meta-androcto
Date: Thu Jun 15 22:13:42 2017 +1000
Branches: master
https://developer.blender.org/rBA722e9d54282befe9eac75b0cd6879a336fe0e394
io_convert_image_to_mesh_img: complete rewrite: T51754
===================================================================
M io_convert_image_to_mesh_img/__init__.py
D io_convert_image_to_mesh_img/import_img.py
A io_convert_image_to_mesh_img/mesh/__init__.py
A io_convert_image_to_mesh_img/mesh/dtm.py
A io_convert_image_to_mesh_img/mesh/terrain.py
A io_convert_image_to_mesh_img/mesh/triangulate.py
A io_convert_image_to_mesh_img/pvl/__init__.py
A io_convert_image_to_mesh_img/pvl/label.py
A io_convert_image_to_mesh_img/pvl/parse.py
A io_convert_image_to_mesh_img/pvl/patterns.py
A io_convert_image_to_mesh_img/ui/__init__.py
A io_convert_image_to_mesh_img/ui/importer.py
A io_convert_image_to_mesh_img/ui/terrainpanel.py
===================================================================
diff --git a/io_convert_image_to_mesh_img/__init__.py b/io_convert_image_to_mesh_img/__init__.py
index 35b60997..54213465 100644
--- a/io_convert_image_to_mesh_img/__init__.py
+++ b/io_convert_image_to_mesh_img/__init__.py
@@ -1,130 +1,65 @@
-# ##### BEGIN GPL LICENSE BLOCK #####
+# This file is a part of the HiRISE DTM Importer for Blender
#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
+# Copyright (C) 2017 Arizona Board of Regents on behalf of the Planetary Image
+# Research Laboratory, Lunar and Planetary Laboratory at the University of
+# Arizona.
#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
+# This program is free software: you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the Free
+# Software Foundation, either version 3 of the License, or (at your option)
+# any later version.
#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# for more details.
#
-# ##### END GPL LICENSE BLOCK #####
+# You should have received a copy of the GNU General Public License along
+# with this program. If not, see <http://www.gnu.org/licenses/>.
+
+"""A HiRISE DTM Importer for Blender"""
+
+import bpy
+
+from .ui import importer
+from .ui import terrainpanel
bl_info = {
- "name": "HiRISE DTM from PDS IMG",
- "author": "Tim Spriggs (tims at uahirise.org)",
- "version": (0, 1, 4),
- "blender": (2, 63, 0),
- "location": "File > Import > HiRISE DTM from PDS IMG (.IMG)",
- "description": "Import a HiRISE DTM formatted as a PDS IMG file",
+ "name": "HiRISE DTM Importer",
+ "author": "Nicholas Wolf (nicwolf at pirl.lpl.arizona.edu)",
+ "version": (0, 2, 1),
+ "blender": (2, 78, 0),
+ "license": "GPL",
+ "location": "File > Import > HiRISE DTM (.img)",
+ "description": "Import a HiRISE DTM as a mesh.",
"warning": "May consume a lot of memory",
- "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/"
- "Scripts/Import-Export/HiRISE_DTM_from_PDS_IMG",
"category": "Import-Export",
+ "wiki_url": "", # TBD
+ "tracker_url": "", # TBD
+ "link": "", # TBD
+ "support": "TESTING",
}
-
-# Revision History:
-# 0.1.1 - make default import 12x12 bin (fast) to not consume too much memory
-# by default (TJS - 2010-12-07)
-# 0.1.2 - included into svn under the tree:
-# trunk/py/scripts/addons/io_convert_image_to_mesh_img
-# may be moved out to contrib once the blender downloader works well
-# (TJS - 2010-12-14)
-# 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():
- import importlib
- importlib.reload(import_img)
-else:
- from . import import_img
-
-
-import bpy
-from bpy.props import *
-from bpy_extras.io_utils import ImportHelper
-
-
-class ImportHiRISEIMGDTM(bpy.types.Operator, ImportHelper):
- """Import a HiRISE DTM formatted as a PDS IMG file"""
- bl_idname = "import_shape.img"
- bl_label = "Import HiRISE DTM from PDS IMG"
- bl_options = {'UNDO'}
+ import imp
+ imp.reload(importer)
+ imp.reload(terrainpanel)
- filename_ext = ".IMG"
- filter_glob = StringProperty(default="*.IMG", options={'HIDDEN'})
-
- scale = FloatProperty(name="Scale",
- description="Scale the IMG by this value",
- min=0.0001,
- max=10.0,
- soft_min=0.001,
- soft_max=100.0,
- default=0.01)
-
- bin_mode = EnumProperty(items=(
- ('NONE', "None", "Don't bin the image"),
- ('BIN2', "2x2", "use 2x2 binning to import the mesh"),
- ('BIN6', "6x6", "use 6x6 binning to import the mesh"),
- ('BIN6-FAST', "6x6 Fast", "use one sample per 6x6 region"),
- ('BIN12', "12x12", "use 12x12 binning to import the mesh"),
- ('BIN12-FAST', "12x12 Fast", "use one sample per 12x12 region"),
- ),
- name="Binning",
- description="Import Binning",
- default='BIN12-FAST'
- )
-
- ## TODO: add support for cropping on import when the checkbox is checked
- # do_crop = BoolProperty(name="Crop Image", description="Crop the image during import", ... )
- ## we only want these visible when the above is "true"
- # crop_x = IntProperty(name="X", description="Offset from left side of image")
- # crop_y = IntProperty(name="Y", description="Offset from top of image")
- # crop_w = IntProperty(name="Width", description="width of cropped operation")
- # crop_h = IntProperty(name="Height", description="height of cropped region")
- ## This is also a bit ugly and maybe an anti-pattern. The problem is that
- ## importing a HiRISE DTM at full resolution will likely kill any mortal user with
- ## less than 16 GB RAM and getting at specific features in a DTM at full res
- ## may prove beneficial. Someday most mortals will have 16GB RAM.
- ## -TJS 2010-11-23
-
- def execute(self, context):
- filepath = self.filepath
- filepath = bpy.path.ensure_ext(filepath, self.filename_ext)
-
- return import_img.load(self, context,
- filepath=self.filepath,
- scale=self.scale,
- bin_mode=self.bin_mode,
- cropVars=False,
- )
-
-## How to register the script inside of Blender
def menu_import(self, context):
- self.layout.operator(ImportHiRISEIMGDTM.bl_idname, text="HiRISE DTM from PDS IMG (*.IMG)")
+ i = importer.ImportHiRISETerrain
+ self.layout.operator(i.bl_idname, text=i.bl_label)
+
def register():
bpy.utils.register_module(__name__)
-
bpy.types.INFO_MT_file_import.append(menu_import)
+
def unregister():
bpy.utils.unregister_module(__name__)
-
bpy.types.INFO_MT_file_import.remove(menu_import)
-if __name__ == "__main__":
+
+if __name__ == '__main__':
register()
diff --git a/io_convert_image_to_mesh_img/import_img.py b/io_convert_image_to_mesh_img/import_img.py
deleted file mode 100644
index 7c9e76d1..00000000
--- a/io_convert_image_to_mesh_img/import_img.py
+++ /dev/null
@@ -1,713 +0,0 @@
-# ##### BEGIN GPL LICENSE BLOCK #####
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-# ##### END GPL LICENSE BLOCK #####
-
-"""
-This script can import a HiRISE DTM .IMG file.
-"""
-
-import bpy
-from bpy.props import *
-
-from struct import pack, unpack
-import os
-import queue, threading
-
-class image_properties:
- """ keeps track of image attributes throughout the hirise_dtm_importer class """
- def __init__(self, name, dimensions, pixel_scale):
- self.name( name )
- self.dims( dimensions )
- self.processed_dims( dimensions )
- self.pixel_scale( pixel_scale )
-
- def dims(self, dims=None):
- if dims is not None:
- self.__dims = dims
- return self.__dims
-
- def processed_dims(self, processed_dims=None):
- if processed_dims is not None:
- self.__processed_dims = processed_dims
- return self.__processed_dims
-
- def name(self, name=None):
- if name is not None:
- self.__name = name
- return self.__name
-
- def pixel_scale(self, pixel_scale=None):
- if pixel_scale is not None:
- self.__pixel_scale = pixel_scale
- return self.__pixel_scale
-
-class hirise_dtm_importer(object):
- """ methods to understand/import a HiRISE DTM formatted as a PDS .IMG """
-
- def __init__(self, context, filepath):
- self.__context = context
- self.__filepath = filepath
- self.__ignore_value = 0x00000000
- self.__bin_mode = 'BIN6'
- self.scale( 1.0 )
- self.__cropXY = False
-
- def bin_mode(self, bin_mode=None):
- if bin_mode is not None:
- self.__bin_mode = bin_mode
- return self.__bin_mode
-
- def scale(self, scale=None):
- if scale is not None:
- self.__scale = scale
- return self.__scale
-
- def crop(self, widthX, widthY, offX, offY):
- self.__cropXY = [ widthX, widthY, offX, offY ]
- return self.__cropXY
-
- ############################################################################
- ## PDS Label Operations
- ##################################################################
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list