def generate_geometry_model(self, component: Component, pixel_data: PixelData = None): """ Generates a geometry model depending on the type of geometry selected and the current values of the line edits that apply to the particular geometry type. :return: The generated model. """ if self.CylinderRadioButton.isChecked(): geometry = component.set_cylinder_shape( QVector3D( self.cylinderXLineEdit.value(), self.cylinderYLineEdit.value(), self.cylinderZLineEdit.value(), ), self.cylinderHeightLineEdit.value(), self.cylinderRadiusLineEdit.value(), self.unitsLineEdit.text(), pixel_data=pixel_data, ) if not geometry: show_warning_dialog( "3D vector is zero length in cylinder geometry.", "") elif self.boxRadioButton.isChecked(): component.set_box_shape( self.boxLengthLineEdit.value(), self.boxWidthLineEdit.value(), self.boxHeightLineEdit.value(), self.unitsLineEdit.text(), ) elif self.meshRadioButton.isChecked() and self.cad_file_name: mesh_geometry = OFFGeometryNoNexus() geometry_model = load_geometry(self.cad_file_name, self.unitsLineEdit.text(), mesh_geometry) # Units have already been used during loading the file, but we store them and file name # so we can repopulate their fields in the edit component window geometry_model.units = self.unitsLineEdit.text() geometry_model.file_path = self.cad_file_name component.set_off_shape( geometry_model, units=self.unitsLineEdit.text(), filename=self.fileLineEdit.text(), pixel_data=pixel_data, )
def test_box_has_property_values_it_was_created_with(): component = Component("test") length = 1.0 width = 2.0 height = 3.0 units = "m" box = component.set_box_shape(height=height, width=width, length=length, units=units) assert box.size[0] == approx(length) assert box.size[1] == approx(width) assert box.size[2] == approx(height) assert box.units == units