[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [1563] contrib/py/scripts/addons/ io_import_LRO_Lola_MGS_Mola_img.py: #ver. 1.1.4: -Fix for recent API changes.
Valter Battioli
valter31 at interfree.it
Tue Feb 8 22:54:10 CET 2011
Revision: 1563
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=1563
Author: valtervb
Date: 2011-02-08 21:54:09 +0000 (Tue, 08 Feb 2011)
Log Message:
-----------
#ver. 1.1.4: -Fix for recent API changes. Thanks to Filiciss.
# -Some code cleaning (PEP8)
Modified Paths:
--------------
contrib/py/scripts/addons/io_import_LRO_Lola_MGS_Mola_img.py
Modified: contrib/py/scripts/addons/io_import_LRO_Lola_MGS_Mola_img.py
===================================================================
--- contrib/py/scripts/addons/io_import_LRO_Lola_MGS_Mola_img.py 2011-02-08 21:36:44 UTC (rev 1562)
+++ contrib/py/scripts/addons/io_import_LRO_Lola_MGS_Mola_img.py 2011-02-08 21:54:09 UTC (rev 1563)
@@ -19,15 +19,15 @@
bl_info = {
"name": "LRO Lola & MGS Mola img Importer",
"author": "ValterVB",
- "version": (1, 1, 3),
+ "version": (1, 1, 4),
"blender": (2, 5, 6),
- "api": 34043,
+ "api": 34473,
"location": "3D window > Tool Shelf",
"description": "Import DTM from LRO Lola and MGS Mola",
"warning": "May consume a lot of memory",
"wiki_url": "http://wiki.blender.org/index.php/Extensions:2.5/Py/"\
"Scripts/Import-Export/NASA_IMG_Importer",
- "tracker_url":"http://projects.blender.org/tracker/index.php?"\
+ "tracker_url": "http://projects.blender.org/tracker/index.php?"\
"func=detail&aid=25462",
"category": "Import-Export"}
@@ -38,7 +38,7 @@
# -Check on selected coordinates more complete
#ver. 1.1.0: -Optimized for less memory
#ver. 1.1.1: -Correct bug for real value of the High (bad error).
-# now it's less artistic, bat more real Always possible use
+# now it's less artistic, bat more real Always possible use
# the old formula. check Magnify (x4)
# -Correct the bug for directory with dot in the name
# -Add some warning and more information
@@ -46,22 +46,27 @@
#ver. 1.1.2: -Word correction
# -Correct the problem for Unix (Upper lower case)
# If the Ext of the file selected from user is upper
-# than the second file is Upper and Viceversa.
+# than the second file is Upper and Viceversa.
# (I can't verify because i have Win)
#ver. 1.1.3: -Little fix for previous fix on upper/lower case
+#ver. 1.1.4: -Fix for recent API changes. Thanks to Filiciss.
+# -Some code cleaning (PEP8)
#************************************************************************
-import bpy
+import bpy
import os.path
-import math, array, mathutils
+import math
+import array
+import mathutils
from mathutils import *
-TO_RAD=math.pi/180 #From degrees to radians
+TO_RAD = math.pi / 180 # From degrees to radians
# turning off relative path - it causes an error if it was true
if bpy.context.user_preferences.filepaths.use_relative_paths == True:
- bpy.context.user_preferences.filepaths.use_relative_paths = False
-
+ bpy.context.user_preferences.filepaths.use_relative_paths = False
+
+
# A very simple "bridge" tool.
# Connects two equally long vertex rows with faces.
# Returns a list of the new faces (list of lists)
@@ -71,8 +76,10 @@
# closed ... Creates a loop (first & last are closed).
# flipped ... Invert the normal of the face(s).
#
-# Note: You can set vertIdx1 to a single vertex index to create a fan/star of faces.
-# Note: If both vertex idx list are the same length they have to have at least 2 vertices.
+# Note: You can set vertIdx1 to a single vertex index to create a fan/star
+# of faces.
+# Note: If both vertex idx list are the same length they have to have at
+# least 2 vertices.
def createFaces(vertIdx1, vertIdx2, closed=False, flipped=False):
faces = []
@@ -126,288 +133,306 @@
vertIdx2[num + 1], vertIdx1[num + 1]]
faces.append(face)
return faces
-
+
+
#Utility Function ********************************************************
#
#Input: Latitude Output: Number of the line (1 to n)
def LatToLine(Latitude):
- tmpLines=round((MAXIMUM_LATITUDE-Latitude)*MAP_RESOLUTION+1.0)
- if tmpLines>LINES:tmpLines=LINES
+ tmpLines = round((MAXIMUM_LATITUDE - Latitude) * MAP_RESOLUTION + 1.0)
+ if tmpLines > LINES:
+ tmpLines = LINES
return tmpLines
-
-#Input: Number of the line (1 to n) Output: Latitude
+
+
+#Input: Number of the line (1 to n) Output: Latitude
def LineToLat(Line):
- if MAP_RESOLUTION==0:
+ if MAP_RESOLUTION == 0:
return 0
else:
- return float(MAXIMUM_LATITUDE-(Line-1)/MAP_RESOLUTION)
+ return float(MAXIMUM_LATITUDE - (Line - 1) / MAP_RESOLUTION)
+
#Input: Longitude Output: Number of the point (1 to n)
def LongToPoint(Longitude):
- tmpPoints=round((Longitude-WESTERNMOST_LONGITUDE)*MAP_RESOLUTION+1.0)
- if tmpPoints>LINE_SAMPLES:tmpPoints=LINE_SAMPLES
+ tmpPoints = round((Longitude - WESTERNMOST_LONGITUDE) *
+ MAP_RESOLUTION + 1.0)
+ if tmpPoints > LINE_SAMPLES:
+ tmpPoints = LINE_SAMPLES
return tmpPoints
+
#Input: Number of the Point (1 to n) Output: Longitude
def PointToLong(Point):
- if MAP_RESOLUTION==0:
+ if MAP_RESOLUTION == 0:
return 0
else:
- return float(WESTERNMOST_LONGITUDE+(Point-1)/MAP_RESOLUTION)
+ return float(WESTERNMOST_LONGITUDE + (Point - 1) / MAP_RESOLUTION)
+
#Input: Latitude Output: Neareast real Latitude on grid
def RealLat(Latitude):
- return float(LineToLat(LatToLine(Latitude)))
+ return float(LineToLat(LatToLine(Latitude)))
-#Input: Longitude Output: Neareast real Longitude on grid
+
+#Input: Longitude Output: Neareast real Longitude on grid
def RealLong(Longitude):
- return float(PointToLong(LongToPoint(Longitude)))
+ return float(PointToLong(LongToPoint(Longitude)))
#**************************************************************************
-#Read the LBL file
+#Read the LBL file
def ReadLabel(FileName):
global FileAndPath
- global LINES, LINE_SAMPLES, SAMPLE_TYPE, SAMPLE_BITS, UNIT, MAP_RESOLUTION, MAXIMUM_LATITUDE, MINIMUM_LATITUDE
- global WESTERNMOST_LONGITUDE, EASTERNMOST_LONGITUDE, SCALING_FACTOR,OFFSET, RadiusUM, TARGET_NAME
+ global LINES, LINE_SAMPLES, SAMPLE_TYPE, SAMPLE_BITS, UNIT, MAP_RESOLUTION
+ global MAXIMUM_LATITUDE, MINIMUM_LATITUDE, WESTERNMOST_LONGITUDE
+ global EASTERNMOST_LONGITUDE, SCALING_FACTOR, OFFSET, RadiusUM, TARGET_NAME
global Message
- if FileName=='':
- LINES=LINE_SAMPLES=SAMPLE_BITS=MAP_RESOLUTION=0
- MAXIMUM_LATITUDE=MINIMUM_LATITUDE=WESTERNMOST_LONGITUDE=EASTERNMOST_LONGITUDE=OFFSET=SCALING_FACTOR=0.0
- SAMPLE_TYPE=UNIT=TARGET_NAME=RadiusUM=Message=""
+ if FileName == '':
+ LINES = LINE_SAMPLES = SAMPLE_BITS = MAP_RESOLUTION = 0
+ MAXIMUM_LATITUDE = MINIMUM_LATITUDE = 0.0
+ WESTERNMOST_LONGITUDE = EASTERNMOST_LONGITUDE = 0.0
+ OFFSET = SCALING_FACTOR = 0.0
+ SAMPLE_TYPE = UNIT = TARGET_NAME = RadiusUM = Message = ""
return
-
- FileAndPath=FileName
- FileAndExt=os.path.splitext(FileAndPath)
+
+ FileAndPath = FileName
+ FileAndExt = os.path.splitext(FileAndPath)
try:
#Check for UNIX that is case sensitive
- #If the Ext of the file selected from user is Upper, than the second file is Upper and Viceversa
- if FileAndExt[1].isupper():
- f = open(FileAndExt[0] + ".LBL", 'r') #Open the label file
+ #If the Ext of the file selected from user is Upper, than the second
+ #file is Upper and Viceversa
+ if FileAndExt[1].isupper():
+ f = open(FileAndExt[0] + ".LBL", 'r') # Open the label file
else:
- f = open(FileAndExt[0] + ".lbl", 'r') #Open the label file
- Message=""
+ f = open(FileAndExt[0] + ".lbl", 'r') # Open the label file
+ Message = ""
except:
- Message="FILE LBL NOT AVAILABLE OR YOU HAVEN'T SELECTED A FILE"
+ Message = "FILE LBL NOT AVAILABLE OR YOU HAVEN'T SELECTED A FILE"
return
-
- block=""
- OFFSET=0
+
+ block = ""
+ OFFSET = 0
for line in f:
- tmp=line.split("=")
- if tmp[0].strip()=="OBJECT" and tmp[1].strip()=="IMAGE":
- block="IMAGE"
- elif tmp[0].strip()=="OBJECT" and tmp[1].strip()=="IMAGE_MAP_PROJECTION":
- block="IMAGE_MAP_PROJECTION"
- elif tmp[0].strip()=="END_OBJECT" and tmp[1].strip()=="IMAGE":
- block=""
- elif tmp[0].strip()=="END_OBJECT" and tmp[1].strip()=="IMAGE_MAP_PROJECTION":
- block=""
- elif tmp[0].strip()=="TARGET_NAME":
- block=""
- TARGET_NAME=tmp[1].strip()
- if block=="IMAGE":
- if line.find("LINES") !=-1 and not(line.startswith("/*")):
- tmp=line.split("=")
- LINES=int(tmp[1].strip())
+ tmp = line.split("=")
+ if tmp[0].strip() == "OBJECT" and tmp[1].strip() == "IMAGE":
+ block = "IMAGE"
+ elif tmp[0].strip() == "OBJECT" and tmp[1].strip() == "IMAGE_MAP_PROJECTION":
+ block = "IMAGE_MAP_PROJECTION"
+ elif tmp[0].strip() == "END_OBJECT" and tmp[1].strip() == "IMAGE":
+ block = ""
+ elif tmp[0].strip() == "END_OBJECT" and tmp[1].strip() == "IMAGE_MAP_PROJECTION":
+ block = ""
+ elif tmp[0].strip() == "TARGET_NAME":
+ block = ""
+ TARGET_NAME = tmp[1].strip()
+ if block == "IMAGE":
+ if line.find("LINES") != -1 and not(line.startswith("/*")):
+ tmp = line.split("=")
+ LINES = int(tmp[1].strip())
elif line.find("LINE_SAMPLES") != -1 and not(line.startswith("/*")):
- tmp=line.split("=")
- LINE_SAMPLES=int(tmp[1].strip())
+ tmp = line.split("=")
+ LINE_SAMPLES = int(tmp[1].strip())
elif line.find("UNIT") != -1 and not(line.startswith("/*")):
- tmp=line.split("=")
- UNIT=tmp[1].strip()
+ tmp = line.split("=")
+ UNIT = tmp[1].strip()
elif line.find("SAMPLE_TYPE") != -1 and not(line.startswith("/*")):
- tmp=line.split("=")
- SAMPLE_TYPE=tmp[1].strip()
+ tmp = line.split("=")
+ SAMPLE_TYPE = tmp[1].strip()
elif line.find("SAMPLE_BITS") != -1 and not(line.startswith("/*")):
- tmp=line.split("=")
- SAMPLE_BITS=int(tmp[1].strip())
+ tmp = line.split("=")
+ SAMPLE_BITS = int(tmp[1].strip())
elif line.find("SCALING_FACTOR") != -1 and not(line.startswith("/*")):
- tmp=line.split("=")
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list