-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy path__init__.py
203 lines (160 loc) · 8.94 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
'''
Copyright (C) 2015 Patrick Moore
Created by Patrick Moore
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
'''
bl_info = {
"name": "AITooth Segmentation",
"description": "Tools for automatically finding teeth from 3d scans",
"author": "Patrick Moore",
"version": (0, 0, 1),
"blender": (2, 7, 9),
"location": "View 3D > Tool Shelf",
"warning": "", # used for warning icon and text in addons panel
"wiki_url": "",
"tracker_url": "",
"category": "3D View"
}
# Blender imports
import bpy
from bpy.types import Operator, AddonPreferences
from bpy.props import StringProperty, IntProperty, BoolProperty, EnumProperty, FloatProperty, FloatVectorProperty
#TODO Preferences
#TODO Menu
#Tools
from .op_ai_teeth.ai_teeth import AITeeth_Polytrim
from . import helper_ops
from . import salience
from .operators import pick_teeth, optimize_model, get_convex_teeth, get_reduction_shell, get_two_part_model
class AISceneSettings(bpy.types.PropertyGroup):
accept_ua = BoolProperty(name = 'Accept User Agreement', default = False, description = "Acknowledge that you have read and agree to the user agreement")
acknowledge_upload = BoolProperty(name = 'Acknowledge Upload', default = False, description = "Acknowledge that you understand files will be transmitted to Google server")
certify_anonymous = BoolProperty(name = 'Certify Anonymous', default = False, description = "Certify that there are no patient identifiers (name, dob etc) on the model")
segmentation_quality = IntProperty(name = 'User Rating', default = -1, min = -1, max = 10, description = 'Subjective rating of quality of segmentation')
demo_file = BoolProperty(name = 'Demo Files', default = False, description = "If demo file, do not precompute or upload")
#addon preferences
class AITeethPreferences(AddonPreferences):
bl_idname = __name__
addons = bpy.context.user_preferences.addons
#cloud behavior
upload_timeout = IntProperty(name = 'Download Timeout', default = 120, min = 30, max = 300)
download_timeout = IntProperty(name = 'Download Timeout', default = 80, min = 10, max = 300)
tooth_system = EnumProperty(name = 'Tooth Nomenclature', items = [('FDI', 'FDI', 'FDI'),('UNIVERSAL','UNIVERSAL','UNVERSAL')], default = 'UNIVERSAL')
key_path = StringProperty(name = 'User Key File', subtype = 'FILE_PATH', default = '')
key_string = StringProperty(name = 'User Key', subtype = 'PASSWORD', default = '')
#Segmentation Editor Behavior
spline_preview_tess = IntProperty(name = 'Spline Teseslation', default = 20, min = 3, max = 100)
sketch_fit_epsilon = FloatProperty(name = 'Sketch Epsilon', default = 0.25, min = 0.001, max = 10)
patch_boundary_fit_epsilon = FloatProperty(name = 'Boundary Epsilon', default = 0.35, min = .001, max = 10)
spline_tessellation_epsilon = FloatProperty(name = 'Spline Epsilon', default = 0.1, min = .001, max = 10)
destructive = EnumProperty(name = 'Geometry Mode', items = [('DESTRUCTIVE', 'DESTRUCTIVE', 'DESTRUCTIVE'),('NON_DESTRUCTIVE','NON_DESTRUCTIVE','NON_DESTRUCTIVE')], default = 'DESTRUCTIVE')
#2D Interaction Behavior
non_man_snap_pxl_rad = IntProperty(name = 'Snap Radius Pixel', default = 20, min =5, max = 150)
sel_pxl_rad = IntProperty(name = 'Select Radius Pixel', default = 10, min = 3, max = 100)
loop_close_pxl_rad = IntProperty(name = 'Select Radius Pixel', default = 10, min = 3, max = 100)
#Menu Colors
menu_bg_color = FloatVectorProperty(name="Menu Backgrounng Color", description="FLoating Menu color", min=0, max=1, default=(.3,.3,.3), subtype="COLOR")
menu_border_color = FloatVectorProperty(name="Menu Border Color", description="FLoating menu border colro", min=0, max=1, default=(.1,.1,.1), subtype="COLOR")
deact_button_color = FloatVectorProperty(name="Button Color", description="Deactivated button color", min=0, max=1, default=(.5,.5,.5), subtype="COLOR")
act_button_color = FloatVectorProperty(name="Active Button Color", description="Activated button color", min=0, max=1, default=(.2,.2,1), subtype="COLOR")
#Geometry Colors
act_point_color = FloatVectorProperty(name="Active Point Color", description="Selected/Active point color", min=0, max=1, default=(.2,.7,.2), subtype="COLOR")
act_patch_color = FloatVectorProperty(name="Active Patch Color", description="Selected/Active patch color", min=0, max=1, default=(.2,.7,.2), subtype="COLOR")
spline_default_color = FloatVectorProperty(name="Spline Color", description="Spline color", min=0, max=1, default=(.2,.2,.7), subtype="COLOR")
hint_color = FloatVectorProperty(name="Hint Color", description="Hint Geometry color", min=0, max=1, default=(.5,1,.5), subtype="COLOR")
bad_segment_color = FloatVectorProperty(name="Active Button Color", description="Activated button color", min=0, max=1, default=(1,.6,.2), subtype="COLOR")
bad_segment_hint_color = FloatVectorProperty(name="Bad Segment Hint", description="Bad segment hint color", min=0, max=1, default=(1,0,0), subtype="COLOR")
def draw(self, context):
layout = self.layout
layout.label(text="AI Teeth Peferences")
#layout.prop(self, "mat_lib")
row = layout.row()
row.label('Labelling Settings')
row = layout.row()
row.prop(self, "tooth_system")
## Visualization
row = layout.row(align=True)
row.label("Timeout Settings")
row = layout.row(align=True)
row.prop(self, "upload_timeout")
row.prop(self, "download_timeout")
row = layout.row(align=True)
row.prop(self, "key_path")
row = layout.row(align=True)
row.prop(self, "key_string")
class VIEW3D_PT_AITeeth(bpy.types.Panel):
bl_space_type = "VIEW_3D"
bl_region_type="TOOLS"
bl_category = "Tooth Segmentation"
bl_label = "AI Teeth Segmentation"
bl_context = ""
def draw(self, context):
sce = bpy.context.scene
layout = self.layout
row = layout.row()
row.label('Acknowledments')
row = layout.row()
row.operator("ai_teeth.open_disclosures", text="Read Agreement")
row = layout.row()
row.prop(sce.ai_settings, "accept_ua")
row = layout.row()
row.prop(sce.ai_settings, "acknowledge_upload")
row = layout.row()
row.prop(sce.ai_settings, "certify_anonymous")
#split = layout.split()
row = layout.row()
row.operator("import_mesh.stl", text="Import Model")
row = layout.row()
row.operator("ai_teeth.anonymize_names", text = "Anonymize Name")
row = layout.row()
row.operator("ai_teeth.optimize_model", text = "Optimize Mesh")
row = layout.row()
row.operator("aiteeth.mark_tooth_locations", text = 'Indicate Teeth')
row = layout.row()
row.operator("ai_teeth.cloud_preprocess_model", text = "Cloud Preprocess Model")
row = layout.row()
row.operator("ai_teeth.polytrim", text = "Interactive Assisted Segment")
row = layout.row()
row.label('Premium/Cloud Features')
row = layout.row()
row.operator("ai_teeth.cloud_convex_teeth")
row = layout.row()
row.operator("ai_teeth.cloud_two_part_model")
row = layout.row()
row.operator("ai_teeth.cloud_reduction_shell")
def register():
bpy.utils.register_class(AITeethPreferences)
bpy.utils.register_class(AITeeth_Polytrim)
bpy.utils.register_class(VIEW3D_PT_AITeeth)
salience.register()
helper_ops.register()
get_convex_teeth.register()
pick_teeth.register()
optimize_model.register()
get_reduction_shell.register()
get_two_part_model.register()
bpy.utils.register_class(AISceneSettings)
bpy.types.Scene.ai_settings = bpy.props.PointerProperty(type = AISceneSettings)
def unregister():
bpy.utils.unregister_class(AITeethPreferences)
bpy.utils.unregister_class(AITeeth_Polytrim)
bpy.utils.unregister_class(VIEW3D_PT_AITeeth)
salience.unregister()
helper_ops.unregister()
pick_teeth.unregister()
optimize_model.unregister()
get_convex_teeth.unregister()
get_reduction_shell.unregister()
get_two_part_model.unregister()
bpy.utils.unregister_class(AISceneSettings)
del bpy.types.scene.ai_settings