Пример #1
0
 def poll(cls, context):
     #restoration exists and is in scene
     if bridge_methods.active_spanning_restoration(context) != [None]:
         bridge = bridge_methods.active_spanning_restoration(context)[0]#TODO:...make this poll work for all selected teeth...
         if bridge:
             return True
         else:
             return False
     else:
         return False
Пример #2
0
def bridge_help_parser(scene):
    if not hasattr(scene, 'odc_props'):
        print('no ODC')
        return

    global help_display_box
    help_text = 'Bridge Help Wizard \n'

    if len(scene.odc_bridges) == 0:
        help_text += 'Need to plan a bridge \n'
        help_text += 'Select multiple single units and "Units to Bridge"'

        return help_text

    bridges = bridge_methods.active_spanning_restoration(bpy.context)

    for bridge in bridges:
        help_text += bridge_help_text(bridge)

    if help_text != help_display_box.raw_text:
        help_display_box.raw_text = help_text
        help_display_box.format_and_wrap_text()
        help_display_box.fit_box_width_to_text_lines()
        help_display_box.fit_box_height_to_text_lines()
        help_display_box.snap_to_corner(bpy.context, corner=[0, 1])
Пример #3
0
    def poll(cls, context):
        bridges = bridge_methods.active_spanning_restoration(context)

        if len(bridges):
            bridge = bridges[0]
            condition_1 = bridge.bridge and bridge.bridge in bpy.data.objects
        else:
            condition_1 = False

        return condition_1
Пример #4
0
 def poll(cls,context):
     bridges = bridge_methods.active_spanning_restoration(context)
     
     if len(bridges):
         bridge = bridges[0]
         condition_1 = bridge.bridge and bridge.bridge in bpy.data.objects
     else:
         condition_1 = False
         
     return condition_1
Пример #5
0
 def execute(self,context):
     settings = get_settings()
     dbg = settings.debug
     
     layers_copy = [layer for layer in context.scene.layers]
     context.scene.layers[0] = True
      
     odc_bridge = bridge_methods.active_spanning_restoration(context)[0]
     bridge_methods.make_pre_bridge(context, odc_bridge, debug=dbg) #TODO: debug settings
     
     for i, layer in enumerate(layers_copy):
         context.scene.layers[i] = layer
         
     context.scene.layers[5] = True
     odcutils.layer_management(context.scene.odc_bridges, debug = dbg)
     
     return {'FINISHED'}
Пример #6
0
    def invoke(self, context, event):

        if context.space_data.type == 'VIEW_3D':
            self.odc_bridge = bridge_methods.active_spanning_restoration(
                context)[0]
            #list of all teeth in the bridge
            self.units = self.odc_bridge.tooth_string.split(sep=":")
            self.target_index = 0
            self.a = self.units[0]
            self.b = self.units[1]
            self.a_group = "_Mesial Connector"
            self.b_group = "_Distal Connector"

            self.mes_distal_determine()

            if self.b not in self.units:
                self.report({
                    'ERROR'
                }, "No neighboring tooth or I haven't figured out how to deal with non adjacent teeth"
                            )
                return {'CANCELLED'}

            self._handle = bpy.types.SpaceView3D.draw_handler_add(
                bgl_utils.general_func_callback, (self, context), 'WINDOW',
                'POST_PIXEL')
            context.window_manager.modal_handler_add(self)

            #guess which teeth we want to bridge
            #TODO: International vs Universal
            self.message = "Bridge between %s and %s" % (self.a, self.b)

            help_message = [
                "Scroll wheel to select connector", "SPC to confirm",
                "Leftmouse to confirm and advance", "Esc to cancel"
            ]
            self.wrap = max([len(string) for string in help_message]) + 5
            self.help = ""
            for message in help_message:
                jmessage = message + " " * (self.wrap - len(message))
                self.help += jmessage

            return {'RUNNING_MODAL'}
        else:
            self.report({'WARNING'}, "Active space must be a View3d")
            return {'CANCELLED'}
Пример #7
0
    def invoke(self, context, event):

        if context.space_data.type == 'VIEW_3D':
            self.odc_bridge = bridge_methods.active_spanning_restoration(context)[0]
            #list of all teeth in the bridge
            self.units = self.odc_bridge.tooth_string.split(sep=":")
            self.target_index = 0
            self.a = self.units[0]
            self.b = self.units[1]
            self.a_group = "_Mesial Connector"
            self.b_group = "_Distal Connector"
            
            self.mes_distal_determine()
                
            if self.b not in self.units:
                self.report({'ERROR'}, "No neighboring tooth or I haven't figured out how to deal with non adjacent teeth")
                return {'CANCELLED'}
            
            self._handle = bpy.types.SpaceView3D.draw_handler_add(bgl_utils.general_func_callback, (self, context), 'WINDOW', 'POST_PIXEL')
            context.window_manager.modal_handler_add(self)


            #guess which teeth we want to bridge
            #TODO: International vs Universal
            self.message = "Bridge between %s and %s" % (self.a, self.b)
            
            help_message = ["Scroll wheel to select connector","SPC to confirm","Leftmouse to confirm and advance","Esc to cancel"]
            self.wrap = max([len(string) for string in help_message]) + 5
            self.help = ""
            for message in help_message:
                jmessage = message + " " * (self.wrap - len(message))
                self.help += jmessage
            
            
            return {'RUNNING_MODAL'}
        else:
            self.report({'WARNING'}, "Active space must be a View3d")
            return {'CANCELLED'}
Пример #8
0
    def execute(self, context):
        settings = get_settings()
        dbg = settings.debug
        odc_bridge = bridge_methods.active_spanning_restoration(context)[0]
        sce = context.scene
        Bridge = bpy.data.objects.get(odc_bridge.bridge)
        if not Bridge:
            self.report({
                'ERROR'
            }, 'Use "Boolean Bridge" to join individual units to an outer shell first'
                        )

        go_local = False
        if context.space_data.local_view:
            go_local = True
            bpy.ops.view3d.localview()

        if len(Bridge.modifiers):
            me = Bridge.to_mesh(context.scene, True, 'PREVIEW')
            mods = [mod for mod in Bridge.modifiers]
            for mod in mods:
                Bridge.modifiers.remove(mod)
            Bridge.data = me

        ### Remove the bottom 3 edge loops
        bridge_bme = bmesh.new()
        bridge_bme.from_object(Bridge, context.scene)

        bridge_bme.edges.ensure_lookup_table()
        bridge_bme.verts.ensure_lookup_table()
        bridge_bme.faces.ensure_lookup_table()

        for i in range(0, 3):
            non_man_eds = [ed for ed in bridge_bme.edges if not ed.is_manifold]
            bmesh.ops.delete(bridge_bme, geom=non_man_eds, context=2)

            non_man_vs = [v for v in bridge_bme.verts if not v.is_manifold]
            bmesh.ops.delete(bridge_bme, geom=non_man_vs, context=1)

            bridge_bme.edges.ensure_lookup_table()
            bridge_bme.verts.ensure_lookup_table()
            bridge_bme.faces.ensure_lookup_table()

        bridge_bme.to_mesh(Bridge.data)

        ### DONE Removing bottom 3 edge loops  ###

        bridge_teeth = [
            context.scene.odc_teeth[name]
            for name in odc_bridge.tooth_string.split(sep=":")
        ]
        intag_objects = [
            bpy.data.objects.get(tooth.intaglio) for tooth in bridge_teeth
            if tooth.rest_type != '1'
        ]
        if None in intag_objects:
            self.report({'ERROR'}, 'Missing Intaglio for some abutments')

        bpy.ops.object.select_all(action='DESELECT')

        join_obs = []
        for ob in intag_objects:
            new_me = ob.to_mesh(context.scene, True, 'PREVIEW')
            new_ob = bpy.data.objects.new(ob.name + ' dupli', new_me)
            new_ob.matrix_world = ob.matrix_world
            context.scene.objects.link(new_ob)
            join_obs.append(new_ob)

        print(join_obs)
        bpy.ops.object.select_all(action='DESELECT')
        for ob in join_obs:
            ob.select = True
        Bridge.hide = False
        Bridge.select = True
        context.scene.objects.active = Bridge

        Bridge.name += '_solid'
        bpy.ops.object.join()

        bridge_bme.free()
        bridge_bme = bmesh.new()
        bridge_bme.from_mesh(Bridge.data, True)
        bridge_bme.edges.ensure_lookup_table()
        bridge_bme.verts.ensure_lookup_table()
        bridge_bme.faces.ensure_lookup_table()

        non_man = [ed for ed in bridge_bme.edges if not ed.is_manifold]
        bmesh.ops.bridge_loops(bridge_bme, edges=non_man, use_pairs=True)
        #non_man = [ed.index for ed in bridge_bme.edges if not ed.is_manifold]
        #loops = mesh_cut.edge_loops_from_bmedges(bridge_bme, non_man)

        #for loop in loops:
        #for i in loop:
        #bridge_bme.verts[i].select_set(True)

        bmesh.ops.recalc_face_normals(bridge_bme, faces=bridge_bme.faces[:])
        bridge_bme.to_mesh(Bridge.data)
        #bridge_bme.transform(Bridge.matrix_world)

        #new_me = bpy.data.meshes.new(odc_bridge.name + '_solid')
        #bridge_bme.to_mesh(new_me)
        bridge_bme.free()

        #new_ob = bpy.data.objects.new(odc_bridge.name + '_solid', new_me)
        #context.scene.objects.link(new_ob)
        if go_local:
            bpy.ops.view3d.localview()

        return {'FINISHED'}
Пример #9
0
    def execute(self, context):
        settings = get_settings()
        dbg = settings.debug
        odc_bridge = bridge_methods.active_spanning_restoration(context)[0]

        layers_copy = [layer for layer in context.scene.layers]
        context.scene.layers[0] = True
        bridge_teeth = [
            context.scene.odc_teeth[name]
            for name in odc_bridge.tooth_string.split(sep=":")
        ]

        contour_obs = [
            bpy.data.objects.get(tooth.contour) for tooth in bridge_teeth
        ]
        if None in contour_obs:
            bad_unit = contour_obs.index(None)
            bad_tooth = bridge_teeth[bad_unit].name
            self.report({'ERROR'},
                        'Full Contour design missing for ' + bad_tooth)
            return {'CANCELLED'}

        left_teeth = []
        right_teeth = []
        for tooth in bridge_teeth:
            if tooth.name.startswith('2') or tooth.name.startswith('3'):
                left_teeth.append(tooth)
            else:
                right_teeth.append(tooth)

        print('left teeth')
        print([tooth.name for tooth in left_teeth])

        def get_key(tooth):
            return tooth.name

        print([
            tooth.name
            for tooth in sorted(left_teeth, key=get_key, reverse=True)
        ])
        if len(left_teeth):
            left_teeth_sorted = [
                tooth
                for tooth in sorted(left_teeth, key=get_key, reverse=True)
            ]
            left_contours = [
                bpy.data.objects.get(tooth.contour)
                for tooth in left_teeth_sorted
            ]
            left_base_ob = left_contours[0]
            print(left_base_ob.name)
            left_bridge_me = left_base_ob.to_mesh(context.scene,
                                                  apply_modifiers=True,
                                                  settings='PREVIEW')
            left_bridge_ob = bpy.data.objects.new(odc_bridge.name,
                                                  left_bridge_me)
            left_bridge_ob.matrix_world = left_base_ob.matrix_world
            context.scene.objects.link(left_bridge_ob)

            print(left_bridge_ob.name)
            for i in range(1, len(left_contours)):
                print('adding boolean modifier')
                mod = left_bridge_ob.modifiers.new(str(i), 'BOOLEAN')
                mod.operation = 'UNION'
                mod.object = left_contours[i]
                print(left_contours[i].name)

            left_final_me = left_bridge_ob.to_mesh(context.scene,
                                                   apply_modifiers=True,
                                                   settings='PREVIEW')
            mods = [mod for mod in left_bridge_ob.modifiers]
            for mod in mods:
                left_bridge_ob.modifiers.remove(mod)

            left_bridge_ob.data = left_final_me
            odc_bridge.bridge = left_bridge_ob.name

        if len(right_teeth):
            right_teeth_sorted = [
                tooth
                for tooth in sorted(right_teeth, key=get_key, reverse=True)
            ]
            right_contours = [
                bpy.data.objects.get(tooth.contour)
                for tooth in right_teeth_sorted
            ]
            right_base_ob = right_contours[0]
            right_bridge_me = right_base_ob.to_mesh(context.scene,
                                                    apply_modifiers=True,
                                                    settings='PREVIEW')
            right_bridge_ob = bpy.data.objects.new(odc_bridge.name,
                                                   right_bridge_me)
            right_bridge_ob.matrix_world = right_base_ob.matrix_world
            context.scene.objects.link(right_bridge_ob)

            for i in range(1, len(right_contours)):
                mod = right_bridge_ob.modifiers.new(str(i), 'BOOLEAN')
                mod.operation = 'UNION'
                mod.object = right_contours[i]

            right_final_me = right_bridge_ob.to_mesh(context.scene,
                                                     apply_modifiers=True,
                                                     settings='PREVIEW')
            mods = [mod for mod in right_bridge_ob.modifiers]
            for mod in mods:
                right_bridge_ob.modifiers.remove(mod)

            right_bridge_ob.data = right_final_me
            odc_bridge.bridge = right_bridge_ob.name

        if len(left_teeth) and len(right_teeth):
            mod = left_bridge_ob.modifiers.new('Midline', 'BOOLEAN')
            mod.operation = 'UNION'
            mod.object = right_bridge_ob

            left_bridge_ob.update_tag()
            context.scene.update()

            final_me = left_bridge_ob.to_mesh(context.scene,
                                              apply_modifiers=True,
                                              settings='PREVIEW')
            mods = [mod for mod in left_bridge_ob.modifiers]
            for mod in mods:
                left_bridge_ob.modifiers.remove(mod)

            left_bridge_ob.data = final_me
            context.scene.objects.unlink(right_bridge_ob)
            bpy.data.objects.remove(right_bridge_ob)
            bpy.data.meshes.remove(right_bridge_me)

            odc_bridge.bridge = left_bridge_ob.name
        return {'FINISHED'}
Пример #10
0
    def execute(self,context):
        settings = get_settings()
        dbg = settings.debug
        odc_bridge = bridge_methods.active_spanning_restoration(context)[0]
        
        layers_copy = [layer for layer in context.scene.layers]
        context.scene.layers[0] = True        
        bridge_teeth = [context.scene.odc_teeth[name] for name in odc_bridge.tooth_string.split(sep=":")]
        
        contour_obs = [bpy.data.objects.get(tooth.contour) for tooth in bridge_teeth]
        if None in contour_obs:
            bad_unit = contour_obs.index(None)
            bad_tooth = bridge_teeth[bad_unit].name
            self.report({'ERROR'}, 'Full Contour design missing for ' + bad_tooth)
            return {'CANCELLED'}

        left_teeth = []
        right_teeth = []
        for tooth in bridge_teeth:
            if tooth.name.startswith('2') or tooth.name.startswith('3'):
                left_teeth.append(tooth)
            else:
                right_teeth.append(tooth)

        print('left teeth')
        print([tooth.name for tooth in left_teeth])
        def get_key(tooth):
            return tooth.name
        print([tooth.name for tooth in sorted(left_teeth, key = get_key, reverse = True)])
        if len(left_teeth):
            left_teeth_sorted = [tooth for tooth in sorted(left_teeth, key = get_key, reverse = True)]
            left_contours = [bpy.data.objects.get(tooth.contour) for tooth in left_teeth_sorted]    
            left_base_ob = left_contours[0]
            print(left_base_ob.name)
            left_bridge_me = left_base_ob.to_mesh(context.scene, apply_modifiers = True, settings = 'PREVIEW')
            left_bridge_ob = bpy.data.objects.new(odc_bridge.name, left_bridge_me)
            left_bridge_ob.matrix_world = left_base_ob.matrix_world
            context.scene.objects.link(left_bridge_ob)
            
            print(left_bridge_ob.name)
            for i in range(1, len(left_contours)):
                print('adding boolean modifier')
                mod = left_bridge_ob.modifiers.new(str(i), 'BOOLEAN')
                mod.operation = 'INTERSECT'
                mod.object = left_contours[i]
                print(left_contours[i].name)
            
            left_final_me = left_bridge_ob.to_mesh(context.scene, apply_modifiers = True, settings = 'PREVIEW')
            mods = [mod for mod in left_bridge_ob.modifiers]
            for mod in mods:
                left_bridge_ob.modifiers.remove(mod)
            
            left_bridge_ob.data = left_final_me
            odc_bridge.bridge = left_bridge_ob.name
            
        if len(right_teeth):
            right_teeth_sorted = [tooth for tooth in sorted(right_teeth, key = get_key, reverse = True)]
            right_contours = [bpy.data.objects.get(tooth.contour) for tooth in right_teeth_sorted]    
            right_base_ob = right_contours[0]
            right_bridge_me = right_base_ob.to_mesh(context.scene, apply_modifiers = True, settings = 'PREVIEW')
            right_bridge_ob = bpy.data.objects.new(odc_bridge.name, right_bridge_me)
            right_bridge_ob.matrix_world = right_base_ob.matrix_world
            context.scene.objects.link(right_bridge_ob)
            
            for i in range(1, len(right_contours)):
                mod = right_bridge_ob.modifiers.new(str(i), 'BOOLEAN')
                mod.operation = 'UNION'
                mod.object = right_contours[i]
            
            right_final_me = right_bridge_ob.to_mesh(context.scene, apply_modifiers = True, settings = 'PREVIEW')
            mods = [mod for mod in right_bridge_ob.modifiers]
            for mod in mods:
                right_bridge_ob.modifiers.remove(mod)
            
            right_bridge_ob.data = right_final_me
            odc_bridge.bridge = right_bridge_ob.name
            
        if len(left_teeth) and len(right_teeth):
            mod = left_bridge_ob.modifiers.new('Midline', 'BOOLEAN')
            mod.operation = 'DIFFERENCE'
            mod.object = right_bridge_ob
            
            left_bridge_ob.update_tag()
            context.scene.update()
            
            final_me = left_bridge_ob.to_mesh(context.scene, apply_modifiers = True, settings = 'PREVIEW')
            mods = [mod for mod in left_bridge_ob.modifiers]
            for mod in mods:
                left_bridge_ob.modifiers.remove(mod)
            
            left_bridge_ob.data = final_me
            context.scene.objects.unlink(right_bridge_ob)
            bpy.data.objects.remove(right_bridge_ob)
            bpy.data.meshes.remove(right_bridge_me)
        
            odc_bridge.bridge = left_bridge_ob.name
        return {'FINISHED'} 
Пример #11
0
    def execute(self,context):
        settings = get_settings()
        dbg = settings.debug
        odc_bridge = bridge_methods.active_spanning_restoration(context)[0]
        sce = context.scene
        Bridge = bpy.data.objects.get(odc_bridge.bridge)
        if not Bridge:
            self.report({'ERROR'}, 'Use "Boolean Bridge" to join individual units to an outer shell first')
        
        go_local = False
        if context.space_data.local_view:
            go_local = True
            bpy.ops.view3d.localview()
            
        if len(Bridge.modifiers):
            me = Bridge.to_mesh(context.scene, True, 'PREVIEW')
            mods = [mod for mod in Bridge.modifiers]
            for mod in mods:
                Bridge.modifiers.remove(mod)
            Bridge.data = me
        
        ### Remove the bottom 3 edge loops
        bridge_bme = bmesh.new()
        bridge_bme.from_object(Bridge, context.scene)
        
        bridge_bme.edges.ensure_lookup_table()
        bridge_bme.verts.ensure_lookup_table()
        bridge_bme.faces.ensure_lookup_table()
        
        for i in range(0,3):
            non_man_eds = [ed for ed in bridge_bme.edges if not ed.is_manifold]
            bmesh.ops.delete(bridge_bme, geom = non_man_eds, context = 2)
            
            non_man_vs = [v for v in bridge_bme.verts if not v.is_manifold]
            bmesh.ops.delete(bridge_bme, geom = non_man_vs, context = 1)
            
            bridge_bme.edges.ensure_lookup_table()
            bridge_bme.verts.ensure_lookup_table()
            bridge_bme.faces.ensure_lookup_table()
        
        bridge_bme.to_mesh(Bridge.data)
        
        ### DONE Removing bottom 3 edge loops  ###
        
                
        bridge_teeth = [context.scene.odc_teeth[name] for name in odc_bridge.tooth_string.split(sep=":")]
        intag_objects = [bpy.data.objects.get(tooth.intaglio) for tooth in bridge_teeth if tooth.rest_type != '1']
        if None in intag_objects:
            self.report({'ERROR'}, 'Missing Intaglio for some abutments')
        
        bpy.ops.object.select_all(action = 'DESELECT')
        
        join_obs = []
        for ob in intag_objects:
            new_me = ob.to_mesh(context.scene, True, 'PREVIEW')
            new_ob = bpy.data.objects.new(ob.name + ' dupli', new_me)
            new_ob.matrix_world = ob.matrix_world
            context.scene.objects.link(new_ob)
            join_obs.append(new_ob)
            
        print(join_obs)
        bpy.ops.object.select_all(action = 'DESELECT')
        for ob in join_obs:
            ob.select = True
            
        Bridge.select = True
        context.scene.objects.active = Bridge
        
        Bridge.name += '_solid'
        bpy.ops.object.join()
        
        bridge_bme.free()
        bridge_bme = bmesh.new()    
        bridge_bme.from_mesh(Bridge.data, True)
        bridge_bme.edges.ensure_lookup_table()
        bridge_bme.verts.ensure_lookup_table()
        bridge_bme.faces.ensure_lookup_table()
        
        
        non_man = [ed for ed in bridge_bme.edges if not ed.is_manifold]
        bmesh.ops.bridge_loops(bridge_bme, edges = non_man, use_pairs = True)
        #non_man = [ed.index for ed in bridge_bme.edges if not ed.is_manifold]
        #loops = mesh_cut.edge_loops_from_bmedges(bridge_bme, non_man)
        
        #for loop in loops:
            #for i in loop:
                #bridge_bme.verts[i].select_set(True)
        
        bmesh.ops.recalc_face_normals(bridge_bme, faces = bridge_bme.faces[:])        
        bridge_bme.to_mesh(Bridge.data)
        #bridge_bme.transform(Bridge.matrix_world)
        
        #new_me = bpy.data.meshes.new(odc_bridge.name + '_solid')
        #bridge_bme.to_mesh(new_me)
        bridge_bme.free()

        #new_ob = bpy.data.objects.new(odc_bridge.name + '_solid', new_me)
        #context.scene.objects.link(new_ob)
        if go_local:
            bpy.ops.view3d.localview()
        
        return {'FINISHED'}