def test_axis_direction_must_be_non_zero(): component = Component("test") height = 3 radius = 4 assert not component.set_cylinder_shape(axis_direction=QVector3D(0, 0, 0), height=height, radius=radius, units="m")
def test_cylinder_has_property_values_it_was_created_with(): component = Component("test") height = 3 radius = 4 units = "cubits" cylinder = component.set_cylinder_shape(axis_direction=QVector3D(1, 0, 0), height=height, radius=radius, units=units) assert cylinder.radius == approx(radius) assert cylinder.height == approx(height) assert cylinder.units == units
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, )