Skip to content
Snippets Groups Projects
Select Git revision
  • be0ccc99a6e361280ef208f9be6fd716237b0d7f
  • stable default protected
  • MA_Pape_2018
  • MA_2018_Lopatin
  • feature/mesh_viewer
  • feature/#468_access_isosurface_scalar
  • feature/#459_default_primitives
  • master protected
  • feature/#470_Create_a_color_lookup_table
  • feature/#473_resize_companion_window
  • feature/#462_do_not_use_arb_extensions
  • feature/#495_Provide_data_for_larger_isosurfaces
  • feature/#323_default_image
  • feature/#480_Create_a_smaller_test_mesh_for_combustion_demo
  • feature/#236_Get_Integration_tests_running_on_CI
  • feature/#447_Copy_standard_assets_to_build_folder
  • 447-copy-standard-assets-to-build-folder-and-remove-resource-path
  • feature/#445_mesh_render_settings_component
  • feature/#251_Make_sure_tests_cpp_is_compiled_once
  • feature/#455_Remove_navigation_and_improve_interaction_for_combustion_demo
  • feature/446_strange_txt_files
  • v18.06.0
  • v18.05.0
  • #251_bad
  • #251_good
  • v18.03.0
  • v18.02.0
  • v18.01.0
  • v17.12.0
  • v17.11.0
  • v17.10.0
  • v17.09.0
  • v17.07.0
33 results

openvr_mock.hpp

Blame
  • defects.py 1.45 KiB
    # TODO:
    # 1. Functions for each of the defects
    #   a. ABC
    #   b. Over extrusion
    #   c. Under extrusion
    #   d. Void
    #   e. Geometric deviation
    from abc import ABC, abstractmethod
    
    from .parser import Command, Gcode
    
    class Defect(ABC):
        def __init__(self, incidence_ratio:float, intensity:float) -> None:
            """Parameters:
            -----
            *  @param incidence_ratio ∈ [0, 1]: percentage of the gcode commands upon which the defect may incide\n
            *  @param intensity ∈ [0, 1]: percentage of the intensity of the defect"""
            super().__init__()
            assert 0 <= incidence_ratio <= 1, "incidence_ratio should be a float between 0 and 1"
            assert 0 <= intensity <= 1, "incidence_ratio should be a float between 0 and 1"
    
            self.incidence_ratio = incidence_ratio
            self.intensity = intensity
        
        @abstractmethod
        def apply(self, command:Command) -> None:
            pass
    
    class OverExtrusion(Defect):
        def apply(self, command:Command) -> None:
            if not (type(command) == float or type(command) == float): return
            last_coords = command.get_last_position()
            original_extrusion = command.e - last_coords['e']
            command.e += original_extrusion * self.intensity
    
    if __name__ == '__main__':
        gcode = Gcode('data/defects_scans/single_line_cross/no_defect/CE3PRO_single_line_cross.gcode')
        defects = [OverExtrusion(1, 1)]
        gcode.apply_defects(defects)
        gcode.save('./source/gcode/gcode_with_defects.gcode')