├── images ├── print3dAddon.png └── print3dAddon_original.png ├── report.py ├── README.md ├── make_solid_helpers.py ├── __init__.py ├── ui.py ├── export.py ├── mesh_helpers.py ├── operators.py └── LICENSE /images/print3dAddon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basharbme/3d-print-toolbox-modified/master/images/print3dAddon.png -------------------------------------------------------------------------------- /images/print3dAddon_original.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basharbme/3d-print-toolbox-modified/master/images/print3dAddon_original.png -------------------------------------------------------------------------------- /report.py: -------------------------------------------------------------------------------- 1 | # ##### BEGIN GPL LICENSE BLOCK ##### 2 | # 3 | # This program is free software; you can redistribute it and/or 4 | # modify it under the terms of the GNU General Public License 5 | # as published by the Free Software Foundation; either version 2 6 | # of the License, or (at your option) any later version. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with this program; if not, write to the Free Software Foundation, 15 | # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 16 | # 17 | # ##### END GPL LICENSE BLOCK ##### 18 | 19 | # 20 | 21 | #---------------------------------------------------------- 22 | # File report.py 23 | # Report errors with the mesh. 24 | #---------------------------------------------------------- 25 | 26 | 27 | _data = [] 28 | 29 | 30 | def update(*args): 31 | _data[:] = args 32 | 33 | 34 | def info(): 35 | return tuple(_data) 36 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 3d-print-toolbox-modified 2 | Blender addon with utilities for 3d printing. It's based on '3D Print Toolbox' by Campbell Barton. In this modified version it's possible to have more influence on the clean up settings and it gives more flexibility. 3 | 4 | ### Blender version: 5 | Tested on Blender 2.80 Release Candidate 3 (windows64). 6 | If you need version for Blender 2.79 or older, check the link: [3d-print-toolbox-modified-blender2.79](https://github.com/agapas/3d-print-toolbox-modified-blender2.79) 7 | 8 | ### More info: 9 | Images below display original '3D Print Toolbox' (image on the left) and current modified version (image on the right): 10 | 11 |

12 | 13 | 14 |

15 | 16 | NOTE: 17 | 'Make Solid' works so far only if all selected objects are in the same collection. I'm still working on the full fix for the issue. 18 | 19 | #### Added Features 20 | 21 | * added [make-solid](https://github.com/agapas/make-solid) 22 | * made 'Check All' button more visible 23 | * completely changed 'Clean Up' part to have more influence on the clean up process 24 | * added 'Copy to Clipboard' of the Volume and Area in Report's Output 25 | 26 | #### Plans to add: 27 | 28 | * export selected objects to multiple STL 29 | 30 | ### Installing 31 | 32 | * go to: File/User Preferences/Add-ons and click 'Install Add-on from File...' 33 | * select the ZIP you downloaded and click 'Install Add-on from File...' 34 | * enable the addon 35 | * save user settings to keep addon enabled over multiple blender sessions 36 | 37 | ## License 38 | 39 | This project is licensed under the [GNU v3.0] License - see the [LICENSE.md](LICENSE) file for details. 40 | -------------------------------------------------------------------------------- /make_solid_helpers.py: -------------------------------------------------------------------------------- 1 | # ##### BEGIN GPL LICENSE BLOCK ##### 2 | # 3 | # This program is free software; you can redistribute it and/or 4 | # modify it under the terms of the GNU General Public License 5 | # as published by the Free Software Foundation; either version 2 6 | # of the License, or (at your option) any later version. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with this program; if not, write to the Free Software Foundation, 15 | # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 16 | # 17 | # ##### END GPL LICENSE BLOCK ##### 18 | 19 | # 20 | 21 | #---------------------------------------------------------- 22 | # File make_solid_helpers.py 23 | # Helper functions, to be used by MakeSolid class . 24 | #---------------------------------------------------------- 25 | 26 | import bpy 27 | import bmesh 28 | 29 | 30 | def prepare_meshes(): 31 | bpy.ops.object.make_single_user(object=True, obdata=True) 32 | bpy.ops.object.convert() 33 | bpy.ops.object.join() 34 | 35 | bpy.ops.object.mode_set(mode='EDIT') 36 | 37 | # selection dance for proper results 38 | bpy.ops.mesh.select_all(action='DESELECT') 39 | bpy.ops.mesh.select_all(action='SELECT') 40 | bpy.context.tool_settings.mesh_select_mode = (True, True, True) 41 | 42 | bpy.ops.mesh.normals_make_consistent(inside=False) 43 | bpy.ops.mesh.separate(type='LOOSE') 44 | bpy.ops.object.mode_set(mode='OBJECT') 45 | 46 | 47 | def prepare_mesh(obj, select_action): 48 | scene = bpy.context.scene 49 | layer = bpy.context.view_layer 50 | 51 | active_object = layer.objects.active 52 | layer.objects.active = obj 53 | bpy.ops.object.mode_set(mode='EDIT') 54 | 55 | # reveal hidden vertices in mesh 56 | bpy.ops.mesh.reveal() 57 | 58 | # mesh cleanup 59 | bpy.ops.mesh.select_all(action='SELECT') 60 | bpy.ops.mesh.separate(type='LOOSE') 61 | bpy.ops.mesh.delete_loose() 62 | 63 | bpy.ops.mesh.select_all(action='SELECT') 64 | bpy.ops.mesh.remove_doubles(threshold=0.0001) 65 | 66 | bpy.ops.mesh.select_all(action='SELECT') 67 | bpy.ops.mesh.fill_holes(sides=0) 68 | 69 | bpy.ops.mesh.select_all(action='SELECT') 70 | bpy.ops.mesh.quads_convert_to_tris() 71 | 72 | # back to previous settings 73 | bpy.ops.mesh.select_all(action=select_action) 74 | bpy.ops.object.mode_set(mode='OBJECT') 75 | layer.objects.active = active_object 76 | 77 | 78 | def cleanup_mesh(obj): 79 | mesh = obj.data 80 | bm = bmesh.new() 81 | bm.from_mesh(mesh) 82 | bmesh.ops.remove_doubles(bm, verts=bm.verts, dist=0.0001) 83 | bm.to_mesh(mesh) 84 | bm.free() 85 | 86 | 87 | def add_modifier(active, selected): 88 | bool_modifier = active.modifiers.new(name='Boolean', type='BOOLEAN') 89 | bool_modifier.object = selected 90 | bool_modifier.show_viewport = False 91 | bool_modifier.show_render = False 92 | bool_modifier.operation = 'UNION' 93 | try: 94 | bool_modifier.solver = 'CARVE' 95 | except: 96 | pass 97 | 98 | bpy.ops.object.modifier_apply(modifier='Boolean') 99 | 100 | view_layer = bpy.context.view_layer 101 | print ("layer_collection.name = " + bpy.context.layer_collection.name) 102 | print ("view_layer.active_layer_collection.name = " + view_layer.active_layer_collection.name) 103 | layer_collection = bpy.context.layer_collection or view_layer.active_layer_collection 104 | collection = layer_collection.collection 105 | collection.objects.unlink(selected) 106 | 107 | bpy.data.objects.remove(selected) 108 | 109 | 110 | def make_solid_batch(): 111 | active = bpy.context.active_object 112 | selected = bpy.context.selected_objects 113 | selected.remove(active) 114 | 115 | prepare_mesh(active, 'DESELECT') 116 | 117 | for sel in selected: 118 | prepare_mesh(sel, 'SELECT') 119 | add_modifier(active, sel) 120 | cleanup_mesh(active) 121 | 122 | 123 | def is_manifold(self): 124 | mesh = bpy.context.active_object.data 125 | bm = bmesh.new() 126 | bm.from_mesh(mesh) 127 | 128 | for edge in bm.edges: 129 | if not edge.is_manifold: 130 | bm.free() 131 | self.report({'ERROR'}, "Boolean operation result is non-manifold") 132 | return False 133 | 134 | bm.free() 135 | return True 136 | -------------------------------------------------------------------------------- /__init__.py: -------------------------------------------------------------------------------- 1 | # ##### BEGIN GPL LICENSE BLOCK ##### 2 | # 3 | # This program is free software; you can redistribute it and/or 4 | # modify it under the terms of the GNU General Public License 5 | # as published by the Free Software Foundation; either version 2 6 | # of the License, or (at your option) any later version. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with this program; if not, write to the Free Software Foundation, 15 | # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 16 | # 17 | # ##### END GPL LICENSE BLOCK ##### 18 | 19 | # 20 | 21 | bl_info = { 22 | "name": "3D Print Toolbox Modified", 23 | "description": "Utilities for 3D printing", 24 | "author": "Agnieszka Pas", 25 | "version": (2, 0, 0), 26 | "blender": (2, 80, 0), 27 | "location": "3D View > Toolbox", 28 | "warning": "", 29 | 'wiki_url': 'https://github.com/agapas/3d-print-toolbox-modified#readme', 30 | "category": "Mesh" 31 | } 32 | 33 | 34 | if "bpy" in locals(): 35 | import importlib 36 | importlib.reload(ui) 37 | importlib.reload(operators) 38 | importlib.reload(mesh_helpers) 39 | importlib.reload(make_solid_helpers) 40 | else: 41 | import math 42 | 43 | import bpy 44 | from bpy.props import ( 45 | StringProperty, 46 | BoolProperty, 47 | IntProperty, 48 | FloatProperty, 49 | FloatVectorProperty, 50 | EnumProperty, 51 | PointerProperty, 52 | ) 53 | from bpy.types import ( 54 | PropertyGroup, 55 | ) 56 | from . import ( 57 | ui, 58 | operators, 59 | ) 60 | 61 | 62 | class Print3D_Scene_Props(PropertyGroup): 63 | export_format: EnumProperty( 64 | name="Format", 65 | description="Format type to export to", 66 | items=( 67 | ('STL', "STL", ""), 68 | ('PLY', "PLY", ""), 69 | ('WRL', "VRML2", ""), 70 | ('X3D', "X3D", ""), 71 | ('OBJ', "OBJ", "") 72 | ), 73 | default='STL', 74 | ) 75 | use_export_texture: BoolProperty( 76 | name="Copy Textures", 77 | description="Copy textures on export to the output path", 78 | default=False, 79 | ) 80 | use_apply_scale: BoolProperty( 81 | name="Apply Scale", 82 | description="Apply scene scale setting on export", 83 | default=False, 84 | ) 85 | export_path: StringProperty( 86 | name="Export Directory", 87 | description="Path to directory where the files are created", 88 | default="//", maxlen=1024, subtype="DIR_PATH", 89 | ) 90 | thickness_min: FloatProperty( 91 | name="Thickness", 92 | description="Minimum thickness", 93 | subtype='DISTANCE', 94 | default=0.001, # 1mm 95 | min=0.0, max=10.0, 96 | ) 97 | threshold_zero: FloatProperty( 98 | name="Threshold", 99 | description="Limit for checking zero area/length", 100 | default=0.0001, 101 | precision=5, 102 | min=0.0, max=0.2, 103 | ) 104 | angle_distort: FloatProperty( 105 | name="Angle", 106 | description="Limit for checking distorted faces", 107 | subtype='ANGLE', 108 | default=math.radians(45.0), 109 | min=0.0, max=math.radians(180.0), 110 | ) 111 | angle_sharp: FloatProperty( 112 | name="Angle", 113 | subtype='ANGLE', 114 | default=math.radians(160.0), 115 | min=0.0, max=math.radians(180.0), 116 | ) 117 | angle_overhang: FloatProperty( 118 | name="Angle", 119 | subtype='ANGLE', 120 | default=math.radians(45.0), 121 | min=0.0, max=math.radians(90.0), 122 | ) 123 | 124 | 125 | classes = ( 126 | ui.VIEW3D_PT_Print3D_Object_Modified, 127 | ui.VIEW3D_PT_Print3D_Mesh_Modified, 128 | 129 | operators.MESH_OT_Print3D_Info_Volume, 130 | operators.MESH_OT_Print3D_Info_Area, 131 | operators.MESH_OT_Print3D_Select_Report, 132 | operators.MESH_OT_Print3D_Copy_Volume_To_Clipboard, 133 | operators.MESH_OT_Print3D_Copy_Area_To_Clipboard, 134 | 135 | operators.MESH_OT_Print3D_Check_Degenerate, 136 | operators.MESH_OT_Print3D_Check_Distorted, 137 | operators.MESH_OT_Print3D_Check_Solid, 138 | operators.MESH_OT_Print3D_Check_Intersections, 139 | operators.MESH_OT_Print3D_Check_Thick, 140 | operators.MESH_OT_Print3D_Check_Sharp, 141 | operators.MESH_OT_Print3D_Check_Overhang, 142 | operators.MESH_OT_Print3D_Check_All, 143 | 144 | operators.MESH_OT_Print3D_Clean_Degenerates, 145 | operators.MESH_OT_Print3D_Clean_Loose, 146 | operators.MESH_OT_Print3D_Clean_Doubles, 147 | operators.MESH_OT_Print3D_Clean_Non_Planars, 148 | operators.MESH_OT_Print3D_Clean_Concave, 149 | operators.MESH_OT_Print3D_Clean_Triangulate_Faces, 150 | operators.MESH_OT_Print3D_Clean_Holes, 151 | operators.MESH_OT_Print3D_Clean_Limited, 152 | 153 | operators.MESH_OT_Print3D_Export, 154 | 155 | operators.MESH_OT_Print3D_Make_Solid_From_Selected, 156 | 157 | Print3D_Scene_Props, 158 | ) 159 | 160 | 161 | def register(): 162 | for cls in classes: 163 | bpy.utils.register_class(cls) 164 | 165 | bpy.types.Scene.print_3d = PointerProperty(type=Print3D_Scene_Props) 166 | 167 | 168 | def unregister(): 169 | for cls in classes: 170 | bpy.utils.unregister_class(cls) 171 | 172 | del bpy.types.Scene.print_3d 173 | -------------------------------------------------------------------------------- /ui.py: -------------------------------------------------------------------------------- 1 | # ##### BEGIN GPL LICENSE BLOCK ##### 2 | # 3 | # This program is free software; you can redistribute it and/or 4 | # modify it under the terms of the GNU General Public License 5 | # as published by the Free Software Foundation; either version 2 6 | # of the License, or (at your option) any later version. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with this program; if not, write to the Free Software Foundation, 15 | # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 16 | # 17 | # ##### END GPL LICENSE BLOCK ##### 18 | 19 | # 20 | 21 | #---------------------------------------------------------- 22 | # File ui.py 23 | # Interface for this addon. 24 | #---------------------------------------------------------- 25 | 26 | from bpy.types import Panel 27 | import bmesh 28 | 29 | from . import report 30 | 31 | 32 | class Print3D_ToolBar: 33 | bl_label = "Print3D" 34 | bl_space_type = 'VIEW_3D' 35 | bl_region_type = 'TOOLS' 36 | 37 | _type_to_icon = { 38 | bmesh.types.BMVert: 'VERTEXSEL', 39 | bmesh.types.BMEdge: 'EDGESEL', 40 | bmesh.types.BMFace: 'FACESEL', 41 | } 42 | 43 | _check_all_icon = 'FORCE_VORTEX' 44 | 45 | @classmethod 46 | def poll(cls, context): 47 | obj = context.active_object 48 | return (obj and obj.type == 'MESH') 49 | 50 | @staticmethod 51 | def draw_report(layout, context): 52 | """Display Reports""" 53 | info = report.info() 54 | if info: 55 | obj = context.edit_object 56 | 57 | layout.label(text="Output:") 58 | box = layout.box() 59 | col = box.column(align=False) 60 | for i, (text, data) in enumerate(info): 61 | if obj and data and data[1]: 62 | bm_type, bm_array = data 63 | col.operator("mesh.print3d_select_report", 64 | text=text, 65 | icon=Print3D_ToolBar._type_to_icon[bm_type]).index = i 66 | elif 'Volume:' in text: 67 | rowsub = col.row(align=True) 68 | rowsub.label(text=text) 69 | rowsub.operator("mesh.print3d_copy_volume_to_clipboard", text="", icon='COPYDOWN').volume = text 70 | elif 'Area:' in text: 71 | rowsub = col.row(align=True) 72 | rowsub.label(text=text) 73 | rowsub.operator("mesh.print3d_copy_area_to_clipboard", text="", icon='COPYDOWN').area = text 74 | else: 75 | col.label(text=text) 76 | 77 | 78 | def draw(self, context): 79 | layout = self.layout 80 | 81 | scene = context.scene 82 | print_3d = scene.print_3d 83 | 84 | row = layout.row() 85 | layout.label(text="Statistics:") 86 | rowsub = layout.row(align=True) 87 | rowsub.operator("mesh.print3d_info_volume", text="Volume") 88 | rowsub.operator("mesh.print3d_info_area", text="Area") 89 | layout.separator() 90 | 91 | box = layout.box() 92 | col = box.column() 93 | col.operator("object.make_solid", text="Make Solid") 94 | 95 | row = layout.row() 96 | row.label(text="Checks:") 97 | col = layout.column(align=True) 98 | col.operator("mesh.print3d_check_solid", text="Solid") 99 | col.operator("mesh.print3d_check_intersect", text="Intersections") 100 | rowsub = col.row(align=True) 101 | rowsub.operator("mesh.print3d_check_degenerate", text="Degenerate") 102 | rowsub.prop(print_3d, "threshold_zero", text="") 103 | rowsub = col.row(align=True) 104 | rowsub.operator("mesh.print3d_check_distort", text="Distorted") 105 | rowsub.prop(print_3d, "angle_distort", text="") 106 | rowsub = col.row(align=True) 107 | rowsub.operator("mesh.print3d_check_thick", text="Thickness") 108 | rowsub.prop(print_3d, "thickness_min", text="") 109 | rowsub = col.row(align=True) 110 | rowsub.operator("mesh.print3d_check_sharp", text="Edge Sharp") 111 | rowsub.prop(print_3d, "angle_sharp", text="") 112 | rowsub = col.row(align=True) 113 | rowsub.operator("mesh.print3d_check_overhang", text="Overhang") 114 | rowsub.prop(print_3d, "angle_overhang", text="") 115 | 116 | col = layout.column() 117 | col.operator("mesh.print3d_check_all", 118 | text="CHECK ALL", 119 | icon=Print3D_ToolBar._check_all_icon) 120 | 121 | # Added mesh clean up operators: 122 | row = layout.row() 123 | row.label(text="Clean up:") 124 | 125 | box = layout.box() 126 | col = box.column() 127 | col.operator("mesh.print3d_clean_degenerates", text="Degenerate Dissolve") 128 | col = box.column() 129 | col.operator("mesh.print3d_clean_doubles", text="Remove Doubles") 130 | col = box.column() 131 | col.operator("mesh.print3d_clean_loose", text="Delete Loose") 132 | col = box.column() 133 | col.operator("mesh.print3d_clean_non_planars", text="Split Non Planar Faces") 134 | col = box.column() 135 | col.operator("mesh.print3d_clean_concaves", text="Split Concave Faces") 136 | col = box.column() 137 | col.operator("mesh.print3d_clean_triangulates", text="Triangulate Faces") 138 | col = box.column() 139 | col.operator("mesh.print3d_clean_holes", text="Fill Holes") 140 | col = box.column() 141 | col.operator("mesh.print3d_clean_limited", text="Limited Dissolve") 142 | 143 | Print3D_ToolBar.draw_report(layout, context) 144 | layout.separator() 145 | 146 | col = layout.column() 147 | rowsub = col.row(align=True) 148 | rowsub.label(text="Export Path:") 149 | rowsub.prop(print_3d, "use_apply_scale", text="", icon='ORIENTATION_GLOBAL') 150 | rowsub.prop(print_3d, "use_export_texture", text="", icon='FILE_IMAGE') 151 | rowsub = col.row() 152 | rowsub.prop(print_3d, "export_path", text="") 153 | 154 | rowsub = col.row(align=True) 155 | rowsub.prop(print_3d, "export_format", text="") 156 | rowsub.operator("mesh.print3d_export", text="Export", icon='EXPORT') 157 | 158 | 159 | # Showing panel in object mode 160 | class VIEW3D_PT_Print3D_Object_Modified(Panel, Print3D_ToolBar): 161 | bl_space_type = "VIEW_3D" 162 | bl_region_type = "UI" 163 | bl_category = "3D Printing" 164 | bl_idname = "VIEW3D_PT_print3d_object_modified" 165 | bl_context = "objectmode" 166 | 167 | 168 | # Showing panel in edit mode 169 | class VIEW3D_PT_Print3D_Mesh_Modified(Panel, Print3D_ToolBar): 170 | bl_space_type = "VIEW_3D" 171 | bl_region_type = "UI" 172 | bl_category = "3D Printing" 173 | bl_idname = "VIEW3D_PT_print3d_mesh_modified" 174 | bl_context = "mesh_edit" 175 | -------------------------------------------------------------------------------- /export.py: -------------------------------------------------------------------------------- 1 | # ##### BEGIN GPL LICENSE BLOCK ##### 2 | # 3 | # This program is free software; you can redistribute it and/or 4 | # modify it under the terms of the GNU General Public License 5 | # as published by the Free Software Foundation; either version 2 6 | # of the License, or (at your option) any later version. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with this program; if not, write to the Free Software Foundation, 15 | # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 16 | # 17 | # ##### END GPL LICENSE BLOCK ##### 18 | 19 | # 20 | 21 | #---------------------------------------------------------- 22 | # File export.py 23 | # Export wrappers and integration with external tools. 24 | #---------------------------------------------------------- 25 | 26 | import os 27 | import bpy 28 | 29 | 30 | def image_copy_guess(filepath, objects): 31 | # 'filepath' is the path we are writing to. 32 | import shutil 33 | from bpy_extras import object_utils 34 | 35 | image = None 36 | for obj in objects: 37 | image = object_utils.object_image_guess(obj) 38 | if image is not None: 39 | break 40 | 41 | if image is not None: 42 | imagepath = bpy.path.abspath(image.filepath, library=image.library) 43 | if os.path.exists(imagepath): 44 | filepath_noext = os.path.splitext(filepath)[0] 45 | ext = os.path.splitext(imagepath)[1] 46 | 47 | imagepath_dst = filepath_noext + ext 48 | print("copying texture: %r -> %r" % (imagepath, imagepath_dst)) 49 | try: 50 | shutil.copy(imagepath, imagepath_dst) 51 | except: 52 | import traceback 53 | traceback.print_exc() 54 | 55 | 56 | def write_mesh(context, info, report_cb): 57 | scene = context.scene 58 | collection = context.collection 59 | layer = context.view_layer 60 | unit = scene.unit_settings 61 | print_3d = scene.print_3d 62 | 63 | obj = layer.objects.active 64 | 65 | export_format = print_3d.export_format 66 | global_scale = unit.scale_length if (unit.system != 'NONE' and print_3d.use_apply_scale) else 1.0 67 | path_mode = 'COPY' if print_3d.use_export_texture else 'AUTO' 68 | 69 | context_override = context.copy() 70 | 71 | obj_tmp = None 72 | 73 | # PLY can only export single mesh objects! 74 | if export_format == 'PLY': 75 | context_backup = context.copy() 76 | bpy.ops.object.mode_set(mode='OBJECT', toggle=False) 77 | 78 | from . import mesh_helpers 79 | obj_tmp = mesh_helpers.object_merge(context, context_override["selected_objects"]) 80 | context_override["active_object"] = obj_tmp 81 | context_override["selected_objects"] = [obj_tmp] 82 | else: 83 | if obj not in context_override["selected_objects"]: 84 | context_override["selected_objects"].append(obj) 85 | 86 | export_path = bpy.path.abspath(print_3d.export_path) 87 | 88 | # Create name 'export_path/blendname-objname' 89 | # add the filename component 90 | if bpy.data.is_saved: 91 | name = os.path.basename(bpy.data.filepath) 92 | name = os.path.splitext(name)[0] 93 | else: 94 | name = "untitled" 95 | # add object name 96 | name += "-%s" % bpy.path.clean_name(obj.name) 97 | 98 | # first ensure the path is created 99 | if export_path: 100 | # this can fail with strange errors, 101 | # if the dir cant be made then we get an error later. 102 | try: 103 | os.makedirs(export_path, exist_ok=True) 104 | except: 105 | import traceback 106 | traceback.print_exc() 107 | 108 | filepath = os.path.join(export_path, name) 109 | 110 | # ensure addon is enabled 111 | import addon_utils 112 | 113 | def addon_ensure(addon_id): 114 | # Enable the addon, dont change preferences. 115 | default_state, loaded_state = addon_utils.check(addon_id) 116 | if not loaded_state: 117 | addon_utils.enable(addon_id, default_set=False) 118 | 119 | if export_format == 'STL': 120 | addon_ensure("io_mesh_stl") 121 | filepath = bpy.path.ensure_ext(filepath, ".stl") 122 | ret = bpy.ops.export_mesh.stl( 123 | context_override, 124 | filepath=filepath, 125 | ascii=False, 126 | use_mesh_modifiers=True, 127 | use_selection=True, 128 | global_scale=global_scale, 129 | ) 130 | elif export_format == 'PLY': 131 | addon_ensure("io_mesh_ply") 132 | filepath = bpy.path.ensure_ext(filepath, ".ply") 133 | ret = bpy.ops.export_mesh.ply( 134 | context_override, 135 | filepath=filepath, 136 | use_mesh_modifiers=True, 137 | global_scale=global_scale, 138 | ) 139 | elif export_format == 'X3D': 140 | addon_ensure("io_scene_x3d") 141 | filepath = bpy.path.ensure_ext(filepath, ".x3d") 142 | ret = bpy.ops.export_scene.x3d( 143 | context_override, 144 | filepath=filepath, 145 | use_mesh_modifiers=True, 146 | use_selection=True, 147 | path_mode=path_mode, 148 | global_scale=global_scale, 149 | ) 150 | elif export_format == 'WRL': 151 | addon_ensure("io_scene_vrml2") 152 | filepath = bpy.path.ensure_ext(filepath, ".wrl") 153 | ret = bpy.ops.export_scene.vrml2( 154 | context_override, 155 | filepath=filepath, 156 | use_mesh_modifiers=True, 157 | use_selection=True, 158 | path_mode=path_mode, 159 | global_scale=global_scale, 160 | ) 161 | elif export_format == 'OBJ': 162 | addon_ensure("io_scene_obj") 163 | filepath = bpy.path.ensure_ext(filepath, ".obj") 164 | ret = bpy.ops.export_scene.obj( 165 | context_override, 166 | filepath=filepath, 167 | use_mesh_modifiers=True, 168 | use_selection=True, 169 | path_mode=path_mode, 170 | global_scale=global_scale, 171 | ) 172 | else: 173 | assert 0 174 | 175 | # for formats that don't support images 176 | if export_format in {'STL', 'PLY'}: 177 | if path_mode == 'COPY': 178 | image_copy_guess(filepath, context_override["selected_objects"]) 179 | 180 | if obj_tmp is not None: 181 | obj = obj_tmp 182 | mesh = obj.data 183 | collection.objects.unlink(obj) 184 | bpy.data.objects.remove(obj) 185 | bpy.data.meshes.remove(mesh) 186 | del obj_tmp, obj, mesh 187 | 188 | # restore context 189 | for ob in context_backup["selected_objects"]: 190 | ob.select_set(True) 191 | layer.objects.active = context_backup["active_object"] 192 | 193 | if 'FINISHED' in ret: 194 | info.append(("%r ok" % os.path.basename(filepath), None)) 195 | 196 | if report_cb is not None: 197 | report_cb({'INFO'}, "Exported: %r" % filepath) 198 | return True 199 | else: 200 | info.append(("%r fail" % os.path.basename(filepath), None)) 201 | return False 202 | -------------------------------------------------------------------------------- /mesh_helpers.py: -------------------------------------------------------------------------------- 1 | # ##### BEGIN GPL LICENSE BLOCK ##### 2 | # 3 | # This program is free software; you can redistribute it and/or 4 | # modify it under the terms of the GNU General Public License 5 | # as published by the Free Software Foundation; either version 2 6 | # of the License, or (at your option) any later version. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with this program; if not, write to the Free Software Foundation, 15 | # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 16 | # 17 | # ##### END GPL LICENSE BLOCK ##### 18 | 19 | # 20 | 21 | #---------------------------------------------------------- 22 | # File mesh_helpers.py 23 | # Generic helper functions, to be used by any modules. 24 | #---------------------------------------------------------- 25 | 26 | import bmesh 27 | 28 | 29 | def bmesh_copy_from_object(obj, transform=True, triangulate=True, apply_modifiers=False): 30 | """ 31 | Returns a transformed, triangulated copy of the mesh 32 | """ 33 | 34 | assert(obj.type == 'MESH') 35 | 36 | if apply_modifiers and obj.modifiers: 37 | import bpy 38 | depsgraph = bpy.context.evaluated_depsgraph_get() 39 | obj_eval = obj.evaluated_get(depsgraph) 40 | me = obj_eval.to_mesh() 41 | bm = bmesh.new() 42 | bm.from_mesh(me) 43 | obj_eval.to_mesh_clear() 44 | del bpy 45 | else: 46 | me = obj.data 47 | if obj.mode == 'EDIT': 48 | bm_orig = bmesh.from_edit_mesh(me) 49 | bm = bm_orig.copy() 50 | else: 51 | bm = bmesh.new() 52 | bm.from_mesh(me) 53 | 54 | # TODO. remove all customdata layers. 55 | # would save ram 56 | 57 | if transform: 58 | bm.transform(obj.matrix_world) 59 | 60 | if triangulate: 61 | bmesh.ops.triangulate(bm, faces=bm.faces) 62 | 63 | return bm 64 | 65 | 66 | def bmesh_from_object(obj): 67 | """ 68 | Object/Edit Mode get mesh, use bmesh_to_object() to write back. 69 | """ 70 | me = obj.data 71 | is_editmode = (obj.mode == 'EDIT') 72 | if is_editmode: 73 | bm = bmesh.from_edit_mesh(me) 74 | else: 75 | bm = bmesh.new() 76 | bm.from_mesh(me) 77 | return bm 78 | 79 | 80 | def bmesh_to_object(obj, bm): 81 | """ 82 | Object/Edit Mode update the object. 83 | """ 84 | me = obj.data 85 | is_editmode = (obj.mode == 'EDIT') 86 | if is_editmode: 87 | bmesh.update_edit_mesh(me, loop_triangles=True) 88 | else: 89 | bm.to_mesh(me) 90 | # grr... cause an update 91 | if me.vertices: 92 | me.vertices[0].co[0] = me.vertices[0].co[0] 93 | 94 | 95 | def bmesh_calc_area(bm): 96 | """ 97 | Calculate the surface area. 98 | """ 99 | return sum(f.calc_area() for f in bm.faces) 100 | 101 | 102 | def bmesh_check_self_intersect_object(obj): 103 | """ 104 | Check if any faces self intersect 105 | 106 | returns an array of edge index values. 107 | """ 108 | import array 109 | import mathutils 110 | 111 | if not obj.data.polygons: 112 | return array.array('i', ()) 113 | 114 | bm = bmesh_copy_from_object(obj, transform=False, triangulate=False) 115 | tree = mathutils.bvhtree.BVHTree.FromBMesh(bm, epsilon=0.00001) 116 | overlap = tree.overlap(tree) 117 | faces_error = {i for i_pair in overlap for i in i_pair} 118 | 119 | return array.array('i', faces_error) 120 | 121 | 122 | def bmesh_face_points_random(f, num_points=1, margin=0.05): 123 | import random 124 | from random import uniform 125 | uniform_args = 0.0 + margin, 1.0 - margin 126 | 127 | # for pradictable results 128 | random.seed(f.index) 129 | 130 | vecs = [v.co for v in f.verts] 131 | 132 | for i in range(num_points): 133 | u1 = uniform(*uniform_args) 134 | u2 = uniform(*uniform_args) 135 | u_tot = u1 + u2 136 | 137 | if u_tot > 1.0: 138 | u1 = 1.0 - u1 139 | u2 = 1.0 - u2 140 | 141 | side1 = vecs[1] - vecs[0] 142 | side2 = vecs[2] - vecs[0] 143 | 144 | yield vecs[0] + u1 * side1 + u2 * side2 145 | 146 | 147 | def bmesh_check_thick_object(obj, thickness): 148 | import array 149 | import bpy 150 | 151 | # Triangulate 152 | bm = bmesh_copy_from_object(obj, transform=True, triangulate=False) 153 | # map original faces to their index. 154 | face_index_map_org = {f: i for i, f in enumerate(bm.faces)} 155 | ret = bmesh.ops.triangulate(bm, faces=bm.faces) 156 | face_map = ret["face_map"] 157 | del ret 158 | # old edge -> new mapping 159 | 160 | # Convert new/old map to index dict. 161 | 162 | # Create a real mesh (lame!) 163 | context = bpy.context 164 | layer = context.view_layer 165 | layer_collection = context.layer_collection or layer.active_layer_collection 166 | scene_collection = layer_collection.collection 167 | 168 | me_tmp = bpy.data.meshes.new(name="~temp~") 169 | bm.to_mesh(me_tmp) 170 | # bm.free() # delay free 171 | obj_tmp = bpy.data.objects.new(name=me_tmp.name, object_data=me_tmp) 172 | # base = scene.objects.link(obj_tmp) 173 | scene_collection.objects.link(obj_tmp) 174 | 175 | # Add new object to local view layer 176 | # XXX28 177 | ''' 178 | v3d = None 179 | if context.space_data and context.space_data.type == 'VIEW_3D': 180 | v3d = context.space_data 181 | 182 | if v3d and v3d.local_view: 183 | base.layers_from_view(context.space_data) 184 | ''' 185 | 186 | layer.update() 187 | ray_cast = obj_tmp.ray_cast 188 | 189 | EPS_BIAS = 0.0001 190 | 191 | faces_error = set() 192 | 193 | bm_faces_new = bm.faces[:] 194 | 195 | for f in bm_faces_new: 196 | no = f.normal 197 | no_sta = no * EPS_BIAS 198 | no_end = no * thickness 199 | for p in bmesh_face_points_random(f, num_points=6): 200 | # Cast the ray backwards 201 | p_a = p - no_sta 202 | p_b = p - no_end 203 | p_dir = p_b - p_a 204 | 205 | ok, co, no, index = ray_cast(p_a, p_dir, distance=p_dir.length) 206 | 207 | if ok: 208 | # Add the face we hit 209 | for f_iter in (f, bm_faces_new[index]): 210 | # if the face wasn't triangulated, just use existing 211 | f_org = face_map.get(f_iter, f_iter) 212 | f_org_index = face_index_map_org[f_org] 213 | faces_error.add(f_org_index) 214 | 215 | # finished with bm 216 | bm.free() 217 | 218 | scene_collection.objects.unlink(obj_tmp) 219 | bpy.data.objects.remove(obj_tmp) 220 | bpy.data.meshes.remove(me_tmp) 221 | 222 | layer.update() 223 | 224 | return array.array('i', faces_error) 225 | 226 | 227 | def object_merge(context, objects): 228 | """ 229 | Caller must remove. 230 | """ 231 | 232 | import bpy 233 | 234 | def cd_remove_all_but_active(seq): 235 | tot = len(seq) 236 | if tot > 1: 237 | act = seq.active_index 238 | for i in range(tot - 1, -1, -1): 239 | if i != act: 240 | seq.remove(seq[i]) 241 | 242 | scene = context.scene 243 | layer = context.view_layer 244 | layer_collection = context.layer_collection or layer.active_layer_collection 245 | scene_collection = layer_collection.collection 246 | 247 | # deselect all 248 | for obj in scene.objects: 249 | obj.select_set(False) 250 | 251 | # add empty object 252 | mesh_base = bpy.data.meshes.new(name="~tmp~") 253 | obj_base = bpy.data.objects.new(name="~tmp~", object_data=mesh_base) 254 | scene_collection.objects.link(obj_base) 255 | layer.objects.active = obj_base 256 | obj_base.select_set(True) 257 | 258 | depsgraph = context.evaluated_depsgraph_get() 259 | 260 | # loop over all meshes 261 | for obj in objects: 262 | if obj.type != 'MESH': 263 | continue 264 | 265 | # convert each to a mesh 266 | obj_eval = obj.evaluated_get(depsgraph) 267 | mesh_new = obj_eval.to_mesh() 268 | 269 | # remove non-active uvs/vcols 270 | cd_remove_all_but_active(mesh_new.vertex_colors) 271 | cd_remove_all_but_active(mesh_new.uv_layers) 272 | 273 | # join into base mesh 274 | obj_new = bpy.data.objects.new(name="~tmp-new~", object_data=mesh_new) 275 | base_new = scene_collection.objects.link(obj_new) 276 | obj_new.matrix_world = obj.matrix_world 277 | 278 | fake_context = context.copy() 279 | fake_context["active_object"] = obj_base 280 | fake_context["selected_editable_objects"] = [obj_base, obj_new] 281 | 282 | bpy.ops.object.join(fake_context) 283 | del base_new, obj_new 284 | 285 | # remove object and its mesh, join does this 286 | # scene_collection.objects.unlink(obj_new) 287 | # bpy.data.objects.remove(obj_new) 288 | 289 | obj_eval.to_mesh_clear() 290 | 291 | layer.update() 292 | 293 | # return new object 294 | return obj_base 295 | 296 | def face_is_distorted(ele, angle_distort): 297 | no = ele.normal 298 | angle_fn = no.angle 299 | 300 | for loop in ele.loops: 301 | if angle_fn(loop.calc_normal(), 1000.0) > angle_distort: 302 | return True 303 | return False 304 | -------------------------------------------------------------------------------- /operators.py: -------------------------------------------------------------------------------- 1 | # ##### BEGIN GPL LICENSE BLOCK ##### 2 | # 3 | # This program is free software; you can redistribute it and/or 4 | # modify it under the terms of the GNU General Public License 5 | # as published by the Free Software Foundation; either version 2 6 | # of the License, or (at your option) any later version. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with this program; if not, write to the Free Software Foundation, 15 | # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 16 | # 17 | # ##### END GPL LICENSE BLOCK ##### 18 | 19 | # 20 | 21 | #---------------------------------------------------------- 22 | # File operators.py 23 | # All Operator. 24 | #---------------------------------------------------------- 25 | 26 | import bpy 27 | from bpy.types import Operator 28 | from bpy.props import ( 29 | BoolProperty, 30 | IntProperty, 31 | FloatProperty, 32 | EnumProperty, 33 | StringProperty 34 | ) 35 | import bmesh 36 | 37 | from . import ( 38 | mesh_helpers, 39 | report, 40 | make_solid_helpers 41 | ) 42 | 43 | 44 | def clean_float(text): 45 | # strip trailing zeros: 0.000 -> 0.0 46 | index = text.rfind(".") 47 | if index != -1: 48 | index += 2 49 | head, tail = text[:index], text[index:] 50 | tail = tail.rstrip("0") 51 | text = head + tail 52 | return text 53 | 54 | 55 | def get_text_value(text): 56 | value_index = text.rfind(":") 57 | if value_index != -1: 58 | value_index += 2 59 | text = text[value_index:] 60 | 61 | index = text.rfind(".") 62 | if index != -1: 63 | index += 9 64 | text = text[:index] 65 | return text 66 | 67 | 68 | # get count of vertices, edges and faces in the mesh 69 | def elem_count(context): 70 | bm = bmesh.from_edit_mesh(context.edit_object.data) 71 | return len(bm.verts), len(bm.edges), len(bm.faces) 72 | 73 | 74 | # set the mode as edit, select mode as vertices, and reveal hidden vertices 75 | def setup_environment(): 76 | bpy.ops.object.mode_set(mode='EDIT') 77 | bpy.ops.mesh.select_mode(type='VERT') 78 | bpy.ops.mesh.reveal() 79 | 80 | 81 | # --------- 82 | # Mesh Info 83 | 84 | class MESH_OT_Print3D_Info_Volume(Operator): 85 | """Report the volume of the active mesh""" 86 | bl_idname = "mesh.print3d_info_volume" 87 | bl_label = "Print3D Info Volume" 88 | 89 | def execute(self, context): 90 | scene = context.scene 91 | unit = scene.unit_settings 92 | scale = 1.0 if unit.system == 'NONE' else unit.scale_length 93 | obj = context.active_object 94 | 95 | bm = mesh_helpers.bmesh_copy_from_object(obj, apply_modifiers=True) 96 | volume = bm.calc_volume() 97 | bm.free() 98 | 99 | info = [] 100 | if unit.system == 'METRIC': 101 | info.append(("Volume: %s cm³" % clean_float("%.4f" % ((volume * (scale ** 3.0)) / (0.01 ** 3.0))), None)) 102 | elif unit.system == 'IMPERIAL': 103 | info.append(("Volume: %s \"³" % clean_float("%.4f" % ((volume * (scale ** 3.0)) / (0.0254 ** 3.0))), None)) 104 | else: 105 | info.append(("Volume: %s³" % clean_float("%.8f" % volume), None)) 106 | 107 | report.update(*info) 108 | return {'FINISHED'} 109 | 110 | 111 | class MESH_OT_Print3D_Info_Area(Operator): 112 | """Report the surface area of the active mesh""" 113 | bl_idname = "mesh.print3d_info_area" 114 | bl_label = "Print3D Info Area" 115 | 116 | def execute(self, context): 117 | scene = context.scene 118 | unit = scene.unit_settings 119 | scale = 1.0 if unit.system == 'NONE' else unit.scale_length 120 | obj = context.active_object 121 | 122 | bm = mesh_helpers.bmesh_copy_from_object(obj, apply_modifiers=True) 123 | area = mesh_helpers.bmesh_calc_area(bm) 124 | bm.free() 125 | 126 | info = [] 127 | if unit.system == 'METRIC': 128 | info.append(("Area: %s cm²" % clean_float("%.4f" % ((area * (scale ** 2.0)) / (0.01 ** 2.0))), None)) 129 | elif unit.system == 'IMPERIAL': 130 | info.append(("Area: %s \"²" % clean_float("%.4f" % ((area * (scale ** 2.0)) / (0.0254 ** 2.0))), None)) 131 | else: 132 | info.append(("Area: %s²" % clean_float("%.8f" % area), None)) 133 | 134 | report.update(*info) 135 | return {'FINISHED'} 136 | 137 | 138 | # --------------- 139 | # Geometry Checks 140 | 141 | def execute_check(self, context): 142 | obj = context.active_object 143 | 144 | info = [] 145 | self.main_check(obj, info) 146 | report.update(*info) 147 | 148 | return {'FINISHED'} 149 | 150 | 151 | class MESH_OT_Print3D_Check_Solid(Operator): 152 | """Check for geometry is solid (has valid inside/outside) and correct normals""" 153 | bl_idname = "mesh.print3d_check_solid" 154 | bl_label = "Print3D Check Solid" 155 | 156 | @staticmethod 157 | def main_check(obj, info): 158 | import array 159 | 160 | bm = mesh_helpers.bmesh_copy_from_object(obj, transform=False, triangulate=False) 161 | 162 | edges_non_manifold = array.array('i', (i for i, ele in enumerate(bm.edges) 163 | if not ele.is_manifold)) 164 | edges_non_contig = array.array('i', (i for i, ele in enumerate(bm.edges) 165 | if ele.is_manifold and (not ele.is_contiguous))) 166 | 167 | info.append(("Non Manifold Edge: %d" % len(edges_non_manifold), 168 | (bmesh.types.BMEdge, edges_non_manifold))) 169 | 170 | info.append(("Bad Contig. Edges: %d" % len(edges_non_contig), 171 | (bmesh.types.BMEdge, edges_non_contig))) 172 | 173 | bm.free() 174 | 175 | def execute(self, context): 176 | return execute_check(self, context) 177 | 178 | 179 | class MESH_OT_Print3D_Check_Intersections(Operator): 180 | """Check geometry for self intersections""" 181 | bl_idname = "mesh.print3d_check_intersect" 182 | bl_label = "Print3D Check Intersections" 183 | 184 | @staticmethod 185 | def main_check(obj, info): 186 | faces_intersect = mesh_helpers.bmesh_check_self_intersect_object(obj) 187 | info.append(("Intersect Face: %d" % len(faces_intersect), 188 | (bmesh.types.BMFace, faces_intersect))) 189 | 190 | def execute(self, context): 191 | return execute_check(self, context) 192 | 193 | 194 | class MESH_OT_Print3D_Check_Degenerate(Operator): 195 | """Check for degenerate geometry that may not print properly """ \ 196 | """(zero area faces, zero length edges)""" 197 | bl_idname = "mesh.print3d_check_degenerate" 198 | bl_label = "Print3D Check Degenerate" 199 | 200 | @staticmethod 201 | def main_check(obj, info): 202 | import array 203 | 204 | scene = bpy.context.scene 205 | print_3d = scene.print_3d 206 | threshold = print_3d.threshold_zero 207 | 208 | bm = mesh_helpers.bmesh_copy_from_object(obj, transform=False, triangulate=False) 209 | 210 | faces_zero = array.array('i', (i for i, ele in enumerate(bm.faces) if ele.calc_area() <= threshold)) 211 | edges_zero = array.array('i', (i for i, ele in enumerate(bm.edges) if ele.calc_length() <= threshold)) 212 | 213 | info.append(("Zero Faces: %d" % len(faces_zero), 214 | (bmesh.types.BMFace, faces_zero))) 215 | 216 | info.append(("Zero Edges: %d" % len(edges_zero), 217 | (bmesh.types.BMEdge, edges_zero))) 218 | 219 | bm.free() 220 | 221 | def execute(self, context): 222 | return execute_check(self, context) 223 | 224 | 225 | class MESH_OT_Print3D_Check_Distorted(Operator): 226 | """Check for non-flat faces """ 227 | bl_idname = "mesh.print3d_check_distort" 228 | bl_label = "Print3D Check Distorted Faces" 229 | 230 | @staticmethod 231 | def main_check(obj, info): 232 | import array 233 | 234 | scene = bpy.context.scene 235 | print_3d = scene.print_3d 236 | angle_distort = print_3d.angle_distort 237 | 238 | bm = mesh_helpers.bmesh_copy_from_object(obj, transform=True, triangulate=False) 239 | bm.normal_update() 240 | 241 | faces_distort = array.array( 242 | 'i', 243 | (i for i, ele in enumerate(bm.faces) if mesh_helpers.face_is_distorted(ele, angle_distort)) 244 | ) 245 | 246 | info.append(("Non-Flat Faces: %d" % len(faces_distort), 247 | (bmesh.types.BMFace, faces_distort))) 248 | 249 | bm.free() 250 | 251 | def execute(self, context): 252 | return execute_check(self, context) 253 | 254 | 255 | class MESH_OT_Print3D_Check_Thick(Operator): 256 | """Check geometry is above the minimum thickness preference """ \ 257 | """(relies on correct normals)""" 258 | bl_idname = "mesh.print3d_check_thick" 259 | bl_label = "Print3D Check Thickness" 260 | 261 | @staticmethod 262 | def main_check(obj, info): 263 | scene = bpy.context.scene 264 | print_3d = scene.print_3d 265 | 266 | faces_error = mesh_helpers.bmesh_check_thick_object(obj, print_3d.thickness_min) 267 | 268 | info.append(("Thin Faces: %d" % len(faces_error), 269 | (bmesh.types.BMFace, faces_error))) 270 | 271 | def execute(self, context): 272 | return execute_check(self, context) 273 | 274 | 275 | class MESH_OT_Print3D_Check_Sharp(Operator): 276 | """Check edges are below the sharpness preference""" 277 | bl_idname = "mesh.print3d_check_sharp" 278 | bl_label = "Print3D Check Sharp" 279 | 280 | @staticmethod 281 | def main_check(obj, info): 282 | scene = bpy.context.scene 283 | print_3d = scene.print_3d 284 | angle_sharp = print_3d.angle_sharp 285 | 286 | bm = mesh_helpers.bmesh_copy_from_object(obj, transform=True, triangulate=False) 287 | bm.normal_update() 288 | 289 | edges_sharp = [ele.index for ele in bm.edges 290 | if ele.is_manifold and ele.calc_face_angle_signed() > angle_sharp] 291 | 292 | info.append(("Sharp Edge: %d" % len(edges_sharp), 293 | (bmesh.types.BMEdge, edges_sharp))) 294 | bm.free() 295 | 296 | def execute(self, context): 297 | return execute_check(self, context) 298 | 299 | 300 | class MESH_OT_Print3D_Check_Overhang(Operator): 301 | """Check faces don't overhang past a certain angle""" 302 | bl_idname = "mesh.print3d_check_overhang" 303 | bl_label = "Print3D Check Overhang" 304 | 305 | @staticmethod 306 | def main_check(obj, info): 307 | import math 308 | from mathutils import Vector 309 | 310 | scene = bpy.context.scene 311 | print_3d = scene.print_3d 312 | angle_overhang = (math.pi / 2.0) - print_3d.angle_overhang 313 | 314 | if angle_overhang == math.pi: 315 | info.append(("Skipping Overhang", ())) 316 | return 317 | 318 | bm = mesh_helpers.bmesh_copy_from_object(obj, transform=True, triangulate=False) 319 | bm.normal_update() 320 | 321 | z_down = Vector((0, 0, -1.0)) 322 | z_down_angle = z_down.angle 323 | 324 | # 4.0 ignores zero area faces 325 | faces_overhang = [ele.index for ele in bm.faces 326 | if z_down_angle(ele.normal, 4.0) < angle_overhang] 327 | 328 | info.append(("Overhang Face: %d" % len(faces_overhang), 329 | (bmesh.types.BMFace, faces_overhang))) 330 | bm.free() 331 | 332 | def execute(self, context): 333 | return execute_check(self, context) 334 | 335 | 336 | class MESH_OT_Print3D_Check_All(Operator): 337 | """Run all checks""" 338 | bl_idname = "mesh.print3d_check_all" 339 | bl_label = "Print3D Check All" 340 | 341 | check_cls = ( 342 | MESH_OT_Print3D_Check_Solid, 343 | MESH_OT_Print3D_Check_Intersections, 344 | MESH_OT_Print3D_Check_Degenerate, 345 | MESH_OT_Print3D_Check_Distorted, 346 | MESH_OT_Print3D_Check_Thick, 347 | MESH_OT_Print3D_Check_Sharp, 348 | MESH_OT_Print3D_Check_Overhang, 349 | ) 350 | 351 | def execute(self, context): 352 | obj = context.active_object 353 | 354 | info = [] 355 | for cls in self.check_cls: 356 | cls.main_check(obj, info) 357 | 358 | report.update(*info) 359 | 360 | return {'FINISHED'} 361 | 362 | 363 | # --------------- 364 | # Mesh Clean Up 365 | 366 | class MESH_OT_Print3D_Clean_Degenerates(Operator): 367 | """Dissolve zero area faces and zero length egdes""" 368 | bl_idname = "mesh.print3d_clean_degenerates" 369 | bl_label = "Degenerate Dissolve" 370 | bl_options = {'REGISTER', 'UNDO'} 371 | 372 | threshold: FloatProperty( 373 | name="Merge Distance", 374 | description="Minimum distance between elements to merge", 375 | default=0.0001, 376 | step=1 377 | ) 378 | 379 | def execute(self, context): 380 | self.context = context 381 | mode_orig = context.mode 382 | 383 | setup_environment() 384 | 385 | bm_key_orig = elem_count(context) 386 | 387 | self.dissolve_degenerate(self.threshold) 388 | 389 | bm_key = elem_count(context) 390 | 391 | if mode_orig != 'EDIT_MESH': 392 | bpy.ops.object.mode_set(mode='OBJECT') 393 | 394 | self.report( 395 | {'INFO'}, 396 | "Modified Verts:%+d, Edges:%+d, Faces:%+d" % 397 | (bm_key[0] - bm_key_orig[0], 398 | bm_key[1] - bm_key_orig[1], 399 | bm_key[2] - bm_key_orig[2] 400 | )) 401 | 402 | return {'FINISHED'} 403 | 404 | @staticmethod 405 | def dissolve_degenerate(threshold): 406 | """dissolve zero area faces and zero length edges""" 407 | bpy.ops.mesh.select_all(action='SELECT') 408 | bpy.ops.mesh.dissolve_degenerate(threshold=threshold) 409 | 410 | 411 | class MESH_OT_Print3D_Clean_Doubles(Operator): 412 | """Remove duplicate vertices""" 413 | bl_idname = "mesh.print3d_clean_doubles" 414 | bl_label = "Remove Doubles" 415 | bl_options = {'REGISTER', 'UNDO'} 416 | 417 | threshold: FloatProperty( 418 | name="Merge Distance", 419 | description="Minimum distance between elements to merge", 420 | default=0.0001, 421 | step=1 422 | ) 423 | 424 | def execute(self, context): 425 | self.context = context 426 | mode_orig = context.mode 427 | 428 | setup_environment() 429 | 430 | bm_key_orig = elem_count(context) 431 | 432 | self.remove_doubles(self.threshold) 433 | 434 | bm_key = elem_count(context) 435 | 436 | if mode_orig != 'EDIT_MESH': 437 | bpy.ops.object.mode_set(mode='OBJECT') 438 | 439 | self.report( 440 | {'INFO'}, 441 | "Modified Verts:%+d, Edges:%+d, Faces:%+d" % 442 | (bm_key[0] - bm_key_orig[0], 443 | bm_key[1] - bm_key_orig[1], 444 | bm_key[2] - bm_key_orig[2] 445 | )) 446 | 447 | return {'FINISHED'} 448 | 449 | @staticmethod 450 | def remove_doubles(threshold): 451 | """select all vertices and remove duplicated ones""" 452 | bpy.ops.mesh.select_all(action='SELECT') 453 | bpy.ops.mesh.remove_doubles(threshold=threshold) 454 | 455 | 456 | class MESH_OT_Print3D_Clean_Loose(Operator): 457 | """Delete loose vertices, edges or faces""" 458 | bl_idname = "mesh.print3d_clean_loose" 459 | bl_label = "Delete Loose" 460 | bl_options = {'REGISTER', 'UNDO'} 461 | 462 | use_verts: BoolProperty( 463 | name="Vertices", 464 | description="Remove loose vertices", 465 | default=True 466 | ) 467 | 468 | use_edges: BoolProperty( 469 | name="Edges", 470 | description="Remove loose edges", 471 | default=True 472 | ) 473 | 474 | use_faces: BoolProperty( 475 | name="Faces", 476 | description="Remove loose faces", 477 | default=True 478 | ) 479 | 480 | def execute(self, context): 481 | self.context = context 482 | mode_orig = context.mode 483 | 484 | setup_environment() 485 | 486 | bm_key_orig = elem_count(context) 487 | 488 | self.delete_loose(self.use_verts, self.use_edges, self.use_faces) 489 | 490 | bm_key = elem_count(context) 491 | 492 | if mode_orig != 'EDIT_MESH': 493 | bpy.ops.object.mode_set(mode='OBJECT') 494 | 495 | self.report( 496 | {'INFO'}, 497 | "Modified Verts:%+d, Edges:%+d, Faces:%+d" % 498 | (bm_key[0] - bm_key_orig[0], 499 | bm_key[1] - bm_key_orig[1], 500 | bm_key[2] - bm_key_orig[2] 501 | )) 502 | 503 | return {'FINISHED'} 504 | 505 | @staticmethod 506 | def delete_loose(use_verts, use_edges, use_faces): 507 | """delete loose vertices, edges or faces""" 508 | bpy.ops.mesh.select_all(action='SELECT') 509 | bpy.ops.mesh.delete_loose(use_verts=use_verts, use_edges=use_edges, use_faces=use_faces) 510 | 511 | 512 | class MESH_OT_Print3D_Clean_Non_Planars(Operator): 513 | """Split non-planar faces that exceed the angle threshold""" 514 | bl_idname = "mesh.print3d_clean_non_planars" 515 | bl_label = "Split Non Planar Faces" 516 | bl_options = {'REGISTER', 'UNDO'} 517 | 518 | angle_threshold: FloatProperty( 519 | name="Max Angle", 520 | description="Angle limit", 521 | default=0.174533, 522 | subtype="ANGLE", 523 | unit="ROTATION", 524 | step=10 525 | ) 526 | 527 | def execute(self, context): 528 | self.context = context 529 | mode_orig = context.mode 530 | 531 | setup_environment() 532 | 533 | bm_key_orig = elem_count(context) 534 | 535 | self.clean_non_planars(self.angle_threshold) 536 | 537 | bm_key = elem_count(context) 538 | 539 | if mode_orig != 'EDIT_MESH': 540 | bpy.ops.object.mode_set(mode='OBJECT') 541 | 542 | self.report( 543 | {'INFO'}, 544 | "Modified Verts:%+d, Edges:%+d, Faces:%+d" % 545 | (bm_key[0] - bm_key_orig[0], 546 | bm_key[1] - bm_key_orig[1], 547 | bm_key[2] - bm_key_orig[2] 548 | )) 549 | 550 | return {'FINISHED'} 551 | 552 | @staticmethod 553 | def clean_non_planars(angle_limit): 554 | """split non-planar faces that exceed the angle threshold""" 555 | bpy.ops.mesh.select_all(action='SELECT') 556 | bpy.ops.mesh.vert_connect_nonplanar(angle_limit=angle_limit) 557 | # bpy.ops.ui.reports_to_textblock() 558 | 559 | 560 | class MESH_OT_Print3D_Clean_Concave(Operator): 561 | """Make all faces convex""" 562 | bl_idname = "mesh.print3d_clean_concaves" 563 | bl_label = "Split Concave Faces" 564 | bl_options = {'REGISTER', 'UNDO'} 565 | 566 | def execute(self, context): 567 | self.context = context 568 | mode_orig = context.mode 569 | 570 | setup_environment() 571 | 572 | bm_key_orig = elem_count(context) 573 | 574 | self.clean_concaves() 575 | 576 | bm_key = elem_count(context) 577 | 578 | if mode_orig != 'EDIT_MESH': 579 | bpy.ops.object.mode_set(mode='OBJECT') 580 | 581 | self.report( 582 | {'INFO'}, 583 | "Modified Verts:%+d, Edges:%+d, Faces:%+d" % 584 | (bm_key[0] - bm_key_orig[0], 585 | bm_key[1] - bm_key_orig[1], 586 | bm_key[2] - bm_key_orig[2] 587 | )) 588 | 589 | return {'FINISHED'} 590 | 591 | @staticmethod 592 | def clean_concaves(): 593 | """make all faces convex""" 594 | bpy.ops.mesh.select_all(action='SELECT') 595 | bpy.ops.mesh.vert_connect_concave() 596 | 597 | 598 | class MESH_OT_Print3D_Clean_Triangulate_Faces(Operator): 599 | """Triangulate selected faces""" 600 | bl_idname = "mesh.print3d_clean_triangulates" 601 | bl_label = "Triangulate Faces" 602 | bl_options = {'REGISTER', 'UNDO'} 603 | 604 | def execute(self, context): 605 | self.context = context 606 | mode_orig = context.mode 607 | 608 | setup_environment() 609 | 610 | bm_key_orig = elem_count(context) 611 | 612 | bpy.ops.mesh.quads_convert_to_tris() 613 | 614 | bm_key = elem_count(context) 615 | 616 | if mode_orig != 'EDIT_MESH': 617 | bpy.ops.object.mode_set(mode='OBJECT') 618 | 619 | self.report( 620 | {'INFO'}, 621 | "Modified Verts:%+d, Edges:%+d, Faces:%+d" % 622 | (bm_key[0] - bm_key_orig[0], 623 | bm_key[1] - bm_key_orig[1], 624 | bm_key[2] - bm_key_orig[2] 625 | )) 626 | 627 | return {'FINISHED'} 628 | 629 | 630 | class MESH_OT_Print3D_Clean_Holes(Operator): 631 | """Fill in holes (boundary edge loops)""" 632 | bl_idname = "mesh.print3d_clean_holes" 633 | bl_label = "Fill Holes" 634 | bl_options = {'REGISTER', 'UNDO'} 635 | 636 | sides: IntProperty( 637 | name="Sides", 638 | description="Number of sides in hole required to fill (zero fills all holes)", 639 | default=4, 640 | step=1 641 | ) 642 | 643 | def execute(self, context): 644 | self.context = context 645 | mode_orig = context.mode 646 | 647 | setup_environment() 648 | 649 | bm_key_orig = elem_count(context) 650 | 651 | self.fill_holes(self.sides) 652 | 653 | bm_key = elem_count(context) 654 | 655 | if mode_orig != 'EDIT_MESH': 656 | bpy.ops.object.mode_set(mode='OBJECT') 657 | 658 | self.report( 659 | {'INFO'}, 660 | "Modified Verts:%+d, Edges:%+d, Faces:%+d" % 661 | (bm_key[0] - bm_key_orig[0], 662 | bm_key[1] - bm_key_orig[1], 663 | bm_key[2] - bm_key_orig[2] 664 | )) 665 | 666 | return {'FINISHED'} 667 | 668 | @staticmethod 669 | def fill_holes(sides): 670 | """fill in holes (boundary edge loops)""" 671 | bpy.ops.mesh.select_all(action='SELECT') 672 | bpy.ops.mesh.fill_holes(sides=sides) 673 | 674 | 675 | class MESH_OT_Print3D_Clean_Limited(Operator): 676 | """Dissolve selected edges and verts, limited by the angle of surrounding geometry""" 677 | bl_idname = "mesh.print3d_clean_limited" 678 | bl_label = "Limited Dissolve" 679 | bl_options = {'REGISTER', 'UNDO'} 680 | 681 | angle_threshold: FloatProperty( 682 | name="Max Angle", 683 | description="Angle limit", 684 | default=0.0872665, 685 | subtype="ANGLE", 686 | unit="ROTATION", 687 | step=10 688 | ) 689 | 690 | use_boundaries: BoolProperty( 691 | name="All Boundaries", 692 | description="Dissolve all vertices inbetween face boundaries", 693 | default=False 694 | ) 695 | 696 | def execute(self, context): 697 | self.context = context 698 | mode_orig = context.mode 699 | 700 | setup_environment() 701 | 702 | bm_key_orig = elem_count(context) 703 | 704 | self.limited_dissolve(self.angle_threshold, self.use_boundaries) 705 | 706 | bm_key = elem_count(context) 707 | 708 | if mode_orig != 'EDIT_MESH': 709 | bpy.ops.object.mode_set(mode='OBJECT') 710 | 711 | self.report( 712 | {'INFO'}, 713 | "Modified Verts:%+d, Edges:%+d, Faces:%+d" % 714 | (bm_key[0] - bm_key_orig[0], 715 | bm_key[1] - bm_key_orig[1], 716 | bm_key[2] - bm_key_orig[2] 717 | )) 718 | 719 | return {'FINISHED'} 720 | 721 | @staticmethod 722 | def limited_dissolve(angle, use_boundaries): 723 | """dissolve selected edges and verts, limited by the angle of surrounding geometry""" 724 | bpy.ops.mesh.dissolve_limited(angle_limit=angle, use_dissolve_boundaries=use_boundaries, delimit={'NORMAL'}) 725 | 726 | 727 | # ------------------------------------ 728 | # Make Solid from selected objects 729 | 730 | class MESH_OT_Print3D_Make_Solid_From_Selected(Operator): 731 | """Combine selected objects into one""" 732 | bl_idname = "object.make_solid" 733 | bl_label = "Make Solid" 734 | bl_options = {'REGISTER', 'UNDO'} 735 | 736 | mode: 'UNION' 737 | 738 | def execute(self, context): 739 | active = context.view_layer.objects.active 740 | selected = context.selected_objects 741 | 742 | if active is None or len(selected) < 2: 743 | self.report({'WARNING'}, "Select at least 2 objects") 744 | return {'CANCELLED'} 745 | else: 746 | make_solid_helpers.prepare_meshes() 747 | make_solid_helpers.make_solid_batch() 748 | make_solid_helpers.is_manifold(self) 749 | 750 | return {'FINISHED'} 751 | 752 | 753 | # ------------- 754 | # Select Report 755 | # ... helper function for info UI 756 | 757 | class MESH_OT_Print3D_Select_Report(Operator): 758 | """Select the data associated with this report""" 759 | bl_idname = "mesh.print3d_select_report" 760 | bl_label = "Print3D Select Report" 761 | bl_options = {'INTERNAL'} 762 | 763 | index: IntProperty() 764 | 765 | _type_to_mode = { 766 | bmesh.types.BMVert: 'VERT', 767 | bmesh.types.BMEdge: 'EDGE', 768 | bmesh.types.BMFace: 'FACE', 769 | } 770 | 771 | _type_to_attr = { 772 | bmesh.types.BMVert: "verts", 773 | bmesh.types.BMEdge: "edges", 774 | bmesh.types.BMFace: "faces", 775 | } 776 | 777 | def execute(self, context): 778 | obj = context.edit_object 779 | info = report.info() 780 | text, data = info[self.index] 781 | bm_type, bm_array = data 782 | 783 | bpy.ops.mesh.reveal() 784 | bpy.ops.mesh.select_all(action='DESELECT') 785 | bpy.ops.mesh.select_mode(type=self._type_to_mode[bm_type]) 786 | 787 | bm = bmesh.from_edit_mesh(obj.data) 788 | elems = getattr(bm, MESH_OT_Print3D_Select_Report._type_to_attr[bm_type])[:] 789 | 790 | try: 791 | for i in bm_array: 792 | elems[i].select_set(True) 793 | except: 794 | # possible arrays are out of sync 795 | self.report({'WARNING'}, "Report is out of date, re-run check") 796 | 797 | # cool, but in fact annoying 798 | #~ bpy.ops.view3d.view_selected(use_all_regions=False) 799 | 800 | return {'FINISHED'} 801 | 802 | 803 | class MESH_OT_Print3D_Copy_Volume_To_Clipboard(Operator): 804 | """Copy the volume value to clipboard""" 805 | bl_idname = "mesh.print3d_copy_volume_to_clipboard" 806 | bl_label = "" 807 | bl_options = {'REGISTER', 'UNDO'} 808 | 809 | volume: StringProperty(name="Copied to Clipboard (Volume):") 810 | 811 | def execute(self, context): 812 | volume = self.volume 813 | if volume: 814 | text_value = get_text_value(volume) 815 | context.window_manager.clipboard = text_value 816 | self.volume = text_value 817 | 818 | return {'FINISHED'} 819 | 820 | 821 | class MESH_OT_Print3D_Copy_Area_To_Clipboard(Operator): 822 | """Copy the area value to clipboard""" 823 | bl_idname = "mesh.print3d_copy_area_to_clipboard" 824 | bl_label = "" 825 | bl_options = {'REGISTER', 'UNDO'} 826 | 827 | area: StringProperty(name="Copied to Clipboard (Area):") 828 | 829 | def execute(self, context): 830 | area = self.area 831 | if area: 832 | text_value = get_text_value(area) 833 | context.window_manager.clipboard = text_value 834 | self.area = text_value 835 | 836 | return {'FINISHED'} 837 | 838 | 839 | # ------ 840 | # Export 841 | 842 | class MESH_OT_Print3D_Export(Operator): 843 | """Export active object using print3d settings""" 844 | bl_idname = "mesh.print3d_export" 845 | bl_label = "Print3D Export" 846 | 847 | def execute(self, context): 848 | from . import export 849 | 850 | info = [] 851 | ret = export.write_mesh(context, info, self.report) 852 | report.update(*info) 853 | 854 | if ret: 855 | return {'FINISHED'} 856 | else: 857 | return {'CANCELLED'} 858 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------