예제 #1
0
 def load_stl(self):
     '''
     Loads/reads stl file, returns an actor for the stl file, as well as points and polygons which can be saved and used to build a polydata object later.
     '''
     filep,startdir=get_file('*.stl')
     
     if filep is None:
         return
     if not(os.path.isfile(filep)):
         print('Data file invalid.')
         return
     
     reader = vtk.vtkSTLReader()
     reader.SetFileName(filep)
     reader.Update()
     
     self.stl_polydata = reader.GetOutput()
     self.np_pts = nps.vtk_to_numpy(self.stl_polydata.GetPoints().GetData())
     self.np_verts = nps.vtk_to_numpy(self.stl_polydata.GetPolys().GetData())
     self.ui.choose_vertex_button.setEnabled(True)
     self.ui.trans_reset_button.setEnabled(True)
     self.ui.trans_origin_button.setEnabled(True)
     
     self.c_trans = np.eye(4)
     self.ui.load_label.setText(filep)
     self.redraw()
예제 #2
0
    def get_point_data(self):
        '''
        Populates measurement and fiducial points from external file
        '''
        # if there's a file, with conditioning to make sure that the lists generated are the right dimension before sending to Tablemodel
        
        filep, _ = get_file('*.txt')
        if filep is None:
            return
        if not(os.path.isfile(filep)):
            print('Data file invalid.')
            return

        if self.tabwidget.currentIndex() == 1:
            #delete the relevant table_model as opposed to working on repopulating with insertRows
            del self.mmodel
            self.mdata = np.genfromtxt(filep)
            if len(self.mdata.shape) > 1:
                self.mdata = self.mdata.tolist()
            else:
                self.mdata = [self.mdata.tolist()]

            self.mmodel = table_model(self.mdata,['X','Y','Z'])
            self.mtable.setModel(self.mmodel)

        if self.tabwidget.currentIndex() == 2:
            del self.fmodel
            self.fdata = np.genfromtxt(filep)
            if len(self.fdata.shape) > 1:
                self.fdata = self.fdata.tolist()
            else:
                self.fdata = [self.fdata.tolist()]
            self.fmodel = table_model(self.fdata,['X','Y','Z'])
            self.ftable.setModel(self.fmodel)
예제 #3
0
    def populate(self):
        '''
        Gets an OpenRS file, calls load_h5 methods
        '''

        self.file, _ = get_file('*.OpenRS')

        if self.file is not None:
            self.setWindowTitle("%s  -  OpenRS v%s" % (self.file, __version__))
            self.psui.file = self.file
            self.mvui.file = self.file
            self.mvui.load_h5()
            self.psui.load_h5()
예제 #4
0
 def load_h5(self):
     if self.file is None:
         self.file, _ = get_file("*.OpenRS")
     
     if self.file is not None:
         #check the file has a populated model object
         with h5py.File(self.file, 'r') as f:
             if "model_data/piece0" not in f:
                 self.display_info('Model data could not be loaded.')
                 
         r = HDF5vtkug_reader()
         r.SetFileName(self.file)
         r.Update()
         self.active_vtu = r.GetOutputDataObject(0).GetBlock(0)
         self.ui.load_label.setText(self.file)
         #call draw_model
         self.ui.component_cb.setEnabled(True)
         self.ui.mesh_display.setEnabled(True)
         self.draw_model()
         self.display_info('Loaded model from data file.')
     self.ui.vtkWidget.update() #for display of info_actor
예제 #5
0
 def load_vtu(self):
     """
     Method to return a valid vtu file
     """
     
     filep,startdir=get_file('*.vtu')
     if filep is None:
         return
     if not(os.path.isfile(filep)):
         self.display_info('Invalid *.vtu file.')
         return
     
     self.active_vtu = filep
     self.ui.load_label.setText(filep)
     #call draw_model
     self.ui.component_cb.setEnabled(True)
     self.ui.mesh_display.setEnabled(True)
     self.ui.clip_active_button.setEnabled(True)
     self.draw_model()
     #connect after the first time draw_model runs and finds all components
     self.ui.component_cb.currentIndexChanged.connect(self.draw_model)
예제 #6
0
파일: compare.py 프로젝트: majroy/OpenRS
 def load_h5(self):
     if self.file is None:
         self.file, _ = get_file("*.OpenRS")
     
     if self.file is not None:
         #check the file has a populated model object
         with h5py.File(self.file, 'r') as f:
             if "model_data/piece0" not in f:
                 self.display_info('Model data could not be loaded.')
             try:
                 self.mdata = f['measurement_points/points'][()].tolist()
             except:
                 self.display_info('No measurement points could be loaded.')
         r = HDF5vtkug_reader()
         r.SetFileName(self.file)
         r.Update()
         self.active_vtu = r.GetOutputDataObject(0).GetBlock(0)
         # self.ui.load_label.setText(self.file)
         #call draw_model
         self.draw_model()
         self.display_info('Loaded model from data file.')
     self.ui.vtkWidget.update() #for display of info_actor
     self.update_measurement_table()
예제 #7
0
 def load_h5(self):
 
     if self.file is None:
         self.file, _ = get_file("*.OpenRS")
     
     if self.file is not None:
         #check if sample/points is empty
         with h5py.File(self.file, 'r') as f:
             if f['sample/points'].shape is None:
                 self.info_actor = generate_info_actor(self.ren,'Point data could not be loaded.')
                 return
     
     #otherwise read it
     with h5py.File(self.file, 'r') as f:
         self.np_pts = f['sample/points'][()]
         self.np_verts = f['sample/vertices'][()]
         self.c_trans = f['sample/transform'][()]
         
         #do fiducials and measurement points
         del self.ui.mmodel
         del self.ui.fmodel
         self.ui.mdata = f['measurement_points/points'][()].tolist()
         self.ui.fdata = f['fiducials/points'][()].tolist()
         self.ui.mmodel = table_model(self.ui.mdata,['X','Y','Z'])
         self.ui.mtable.setModel(self.ui.mmodel)
         self.ui.fmodel = table_model(self.ui.fdata,['X','Y','Z'])
         self.ui.ftable.setModel(self.ui.fmodel)
         
         self.ui.sgv.width.setValue(f['sgv'].attrs['width'])
         self.ui.sgv.depth.setValue(f['sgv'].attrs['depth'])
         self.ui.sgv.theta.setValue(f['sgv'].attrs['2theta'])
         self.ui.sgv.rotate_x.setValue(f['sgv'].attrs['rotate_x'])
         self.ui.sgv.rotate_y.setValue(f['sgv'].attrs['rotate_y'])
         self.ui.sgv.rotate_z.setValue(f['sgv'].attrs['rotate_z'])
     self.redraw() #draws stl/sample
     self.draw_all_points() #draws meas & fiducial
     self.info_actor = generate_info_actor(self.ren,'Loaded model from data file.')
예제 #8
0
 def set_ccx(self):
     f,_ = get_file("*.*")
     self.ccx_exec_path.setText(f)
     self.make_config_change()