[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [3984] contrib/py/scripts/addons: Dear all.
Clemens Barth
barth at root-1.de
Mon Nov 19 22:19:40 CET 2012
Revision: 3984
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=3984
Author: blendphys
Date: 2012-11-19 21:19:38 +0000 (Mon, 19 Nov 2012)
Log Message:
-----------
Dear all.
This Atomic Blender addon imports Gwyddion (http://gwyddion.net/) Atomic Force
Microscopy images into Blender.
Note that this is a very first version, which still needs some improvements!
For instance, the loading of the images needs to be improved since it is a bit
slow. On the contrary, it seems to be quite stable ... well at least with my AFM
images, which I have created with the latest Gwyddion version 2.26.
The Wiki page, which I will finish by time, can be found here:
http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/Import-Export/Gwyddion
The addon can be downloaded from here:
http://root-1.de/X-Download/io_mesh_gwyddion.zip
I will set up also a thread in the Forum such that the addon can be discussed.
Blendphys
Added Paths:
-----------
contrib/py/scripts/addons/io_mesh_gwyddion/
contrib/py/scripts/addons/io_mesh_gwyddion/__init__.py
contrib/py/scripts/addons/io_mesh_gwyddion/import_gwyddion.py
Added: contrib/py/scripts/addons/io_mesh_gwyddion/__init__.py
===================================================================
--- contrib/py/scripts/addons/io_mesh_gwyddion/__init__.py (rev 0)
+++ contrib/py/scripts/addons/io_mesh_gwyddion/__init__.py 2012-11-19 21:19:38 UTC (rev 3984)
@@ -0,0 +1,199 @@
+# ##### 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 #####
+
+#
+#
+# Authors : Clemens Barth (Blendphys at root-1.de), ...
+#
+# Homepage : http://development.root-1.de/Atomic_Blender.php
+#
+# Start of project : 2012-11-12 by Clemens Barth
+# First publication in Blender : 2012-11-19
+# Last modified : 2012-11-19
+#
+# Acknowledgements
+# ================
+#
+# Other: Frank Palmino
+#
+
+bl_info = {
+ "name": "Atomic Blender - Gwyddion",
+ "description": "Loading Gwyddion Atomic Force Microscopy images",
+ "author": "Clemens Barth",
+ "version": (0,1),
+ "blender": (2,6),
+ "location": "File -> Import -> Gwyddion (.gwy)",
+ "warning": "",
+ "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/"
+ "Scripts/Import-Export/Gwyddion",
+ "tracker_url": "",
+ "category": "Import-Export"
+}
+
+import bpy
+from bpy.types import Operator
+from bpy_extras.io_utils import ImportHelper
+from bpy.props import (BoolProperty,
+ StringProperty,
+ EnumProperty,
+ FloatProperty)
+
+from . import import_gwyddion
+
+# -----------------------------------------------------------------------------
+# GUI
+
+# This is the class for the file dialog of the importer.
+class ImportGwyddion(Operator, ImportHelper):
+ bl_idname = "import_mesh.gwy"
+ bl_label = "Import Gwyddion (*.gwy)"
+ bl_options = {'PRESET', 'UNDO'}
+
+ filename_ext = ".gwy"
+ filter_glob = StringProperty(default="*.gwy", options={'HIDDEN'},)
+
+ use_camera = BoolProperty(
+ name="Camera", default=False,
+ description="Do you need a camera?")
+ use_lamp = BoolProperty(
+ name="Lamp", default=False,
+ description = "Do you need a lamp?")
+ fit = EnumProperty(
+ name="Processing",
+ description="Choose the image processing routine",
+ items=(('0', "None", "Load raw data"),
+ ('1', "Plane" , "Perform a plane fit"),
+ ('2', "Line" , "Perform a line fit")),
+ default='0',)
+ use_smooth = BoolProperty(
+ name="Smooth image data", default=False,
+ description = "Smooth the images")
+ scale_size = FloatProperty (
+ name = "Scale xy", default=0.5,
+ description = "Scale the lateral size")
+ scale_height = FloatProperty (
+ name = "Scale h", default=3.0,
+ description = "Scale the height")
+ use_all_channels = BoolProperty(
+ name="All channels", default=False,
+ description = "Load all images")
+ use_c1 = BoolProperty(
+ name="1", default=True,
+ description = "Channel 1")
+ use_c2 = BoolProperty(
+ name="2", default=False,
+ description = "Channel 2")
+ use_c3 = BoolProperty(
+ name="3", default=False,
+ description = "Channel 3")
+ use_c4 = BoolProperty(
+ name="4", default=False,
+ description = "Channel 4")
+ use_c5 = BoolProperty(
+ name="5", default=False,
+ description = "Channel 5")
+ use_c6 = BoolProperty(
+ name="6", default=False,
+ description = "Channel 6")
+ use_c7 = BoolProperty(
+ name="7", default=False,
+ description = "Channel 7")
+ use_c8 = BoolProperty(
+ name="8", default=False,
+ description = "Channel 8")
+
+ def draw(self, context):
+ layout = self.layout
+ row = layout.row()
+ row.prop(self, "use_camera")
+ row.prop(self, "use_lamp")
+ row = layout.row()
+ row.prop(self, "fit")
+ row = layout.row()
+ row.prop(self, "use_smooth")
+ row = layout.row()
+ row.prop(self, "scale_size")
+ row.prop(self, "scale_height")
+ row = layout.row()
+ row.label(text="Channels")
+ row.prop(self, "use_all_channels")
+ row = layout.row()
+ row.prop(self, "use_c1")
+ row.prop(self, "use_c2")
+ row.prop(self, "use_c3")
+ row.prop(self, "use_c4")
+ row = layout.row()
+ row.prop(self, "use_c5")
+ row.prop(self, "use_c6")
+ row.prop(self, "use_c7")
+ row.prop(self, "use_c8")
+
+ if self.use_all_channels:
+ self.use_c1, self.use_c2, self.use_c3, self.use_c4, \
+ self.use_c5, self.use_c6, self.use_c7, self.use_c8 \
+ = True, True, True, True, True, True, True, True
+
+ def execute(self, context):
+ # This is in order to solve this strange 'relative path' thing.
+ filepath_par = bpy.path.abspath(self.filepath)
+
+ channels = [self.use_c1, self.use_c2, self.use_c3, self.use_c4,
+ self.use_c5, self.use_c6, self.use_c7, self.use_c8]
+
+ # Execute main routine
+ #print("passed - 1")
+ images, AFMdata = import_gwyddion.load_gwyddion_images(filepath_par,
+ channels)
+
+ #print("passed - 2")
+ if self.fit == '1':
+ images = import_gwyddion.plane_fit(images, AFMdata)
+ if self.fit == '2':
+ images = import_gwyddion.line_fit(images, AFMdata)
+
+ #print("passed - 3")
+ import_gwyddion.create_mesh(images,
+ AFMdata,
+ self.use_smooth,
+ self.scale_size,
+ self.scale_height,
+ self.use_camera,
+ self.use_lamp)
+ #print("passed - 4")
+
+ return {'FINISHED'}
+
+
+# The entry into the menu 'file -> import'
+def menu_func_import(self, context):
+ self.layout.operator(ImportGwyddion.bl_idname, text="Gwyddion (.gwy)")
+
+
+def register():
+ import_gwyddion.initialize_linalg()
+ bpy.utils.register_module(__name__)
+ bpy.types.INFO_MT_file_import.append(menu_func_import)
+
+def unregister():
+ bpy.utils.unregister_module(__name__)
+ bpy.types.INFO_MT_file_import.remove(menu_func_import)
+
+if __name__ == "__main__":
+
+ register()
Added: contrib/py/scripts/addons/io_mesh_gwyddion/import_gwyddion.py
===================================================================
--- contrib/py/scripts/addons/io_mesh_gwyddion/import_gwyddion.py (rev 0)
+++ contrib/py/scripts/addons/io_mesh_gwyddion/import_gwyddion.py 2012-11-19 21:19:38 UTC (rev 3984)
@@ -0,0 +1,457 @@
+# ##### 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 #####
+
+import bpy
+import os
+import re
+from math import pi, sqrt
+from mathutils import Vector, Matrix
+import numpy as np
+import struct
+
+# All data for the images. Basically, each variable is a list with a length,
+# which equals the number of images.
+# Some of the variables are still not used. However, I keep them for purposes
+# in future.
+class AFMData(object):
+ def __init__(self, date, x_size, y_size, x_pixel, y_pixel, x_off, y_off,
+ voltage, feedback, gain, speed, amplitude, angle, datfile,
+ channel, unit, z_factor, spec_x_unit, spec_x_label, spec_y_unit,
+ spec_y_label, spec_y_factor, spec_points, spec_feedback,
+ spec_acquisition, spec_delay):
+ self.date = date
+ self.x_size = x_size
+ self.y_size = y_size
+ self.x_pixel = x_pixel
+ self.y_pixel = y_pixel
+ self.x_off = x_off
+ self.y_off = y_off
+ self.voltage = voltage
+ self.feedback = feedback
+ self.gain = gain
+ self.speed = speed
+ self.amplitude = amplitude
+ self.angle = angle
+ self.datfile = datfile
+ self.channel = channel
+ self.unit = unit
+ self.z_factor = z_factor
+ self.spec_x_unit = spec_x_unit
+ self.spec_x_label = spec_x_label
+ self.spec_y_unit = spec_y_unit
+ self.spec_y_label = spec_y_label
+ self.spec_y_factor = spec_y_factor
+ self.spec_points = spec_points
+ self.spec_feedback = spec_feedback
+ self.spec_acquisition = spec_acquisition
+ self.spec_delay = spec_delay
+
+class LinAlg(object):
+ def __init__(self, plane_M512, plane_M1024,
+ plane_x_vec512, plane_y_vec512,
+ plane_x_vec1024, plane_y_vec1024,
+ line_M512, line_M1024,
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list