From b55a2a917b825a3d3f0f697bd317c920d060f284 Mon Sep 17 00:00:00 2001 From: jfa Date: Wed, 14 Nov 2012 08:49:18 +0000 Subject: [PATCH] Mantis issue 0021511: STEP units. Rename parameter of ImportSTEP. Provide correct reading of files without units. --- src/GEOM_SWIG/geompyDC.py | 80 ++++++++++++++++++++++++++--------- src/STEPImport/STEPImport.cxx | 6 +-- 2 files changed, 63 insertions(+), 23 deletions(-) diff --git a/src/GEOM_SWIG/geompyDC.py b/src/GEOM_SWIG/geompyDC.py index 13f145feb..40a7dd53a 100644 --- a/src/GEOM_SWIG/geompyDC.py +++ b/src/GEOM_SWIG/geompyDC.py @@ -7358,73 +7358,113 @@ class geompyDC(GEOM._objref_GEOM_Gen): RaiseIfFailed("Import", self.InsertOp) return anObj - ## Shortcut to ImportFile() for BREP format + ## Shortcut to ImportFile() for BREP format. + # Import a shape from the BREP file with given name. + # @param theFileName The file, containing the shape. + # @return New GEOM.GEOM_Object, containing the imported shape. # # @ref swig_Import_Export "Example" def ImportBREP(self, theFileName): """ geompy.ImportFile(...) function for BREP format + Import a shape from the BREP file with given name. + + Parameters: + theFileName The file, containing the shape. + + Returns: + New GEOM.GEOM_Object, containing the imported shape. """ # Example: see GEOM_TestOthers.py return self.ImportFile(theFileName, "BREP") ## Shortcut to ImportFile() for IGES format - # @param doScale If True, file length units will be ignored (set to 'meter') - # and result model will be scaled. - # If False (default), file length units will be taken into account. + # Import a shape from the IGES file with given name. + # @param theFileName The file, containing the shape. + # @param ignoreUnits If True, file length units will be ignored (set to 'meter') + # and result model will be scaled, if its units are not meters. + # If False (default), file length units will be taken into account. + # @return New GEOM.GEOM_Object, containing the imported shape. # # @ref swig_Import_Export "Example" - def ImportIGES(self, theFileName, doScale = False): + def ImportIGES(self, theFileName, ignoreUnits = False): """ geompy.ImportFile(...) function for IGES format - Parameters: - doScale If True, file length units will be ignored (set to 'meter') - and result model will be scaled. - If False (default), file length units will be taken into account. + Parameters: + theFileName The file, containing the shape. + ignoreUnits If True, file length units will be ignored (set to 'meter') + and result model will be scaled, if its units are not meters. + If False (default), file length units will be taken into account. + + Returns: + New GEOM.GEOM_Object, containing the imported shape. """ # Example: see GEOM_TestOthers.py - if doScale: + if ignoreUnits: return self.ImportFile(theFileName, "IGES_SCALE") return self.ImportFile(theFileName, "IGES") ## Return length unit from given IGES file - # @param doScale If True, file length units will be ignored (set to 'meter') - # and result model will be scaled. - # If False (default), file length units will be taken into account. + # @param theFileName The file, containing the shape. + # @return String, containing the units name. # # @ref swig_Import_Export "Example" - def GetIGESUnit(self, theFileName, doScale = False): + def GetIGESUnit(self, theFileName): """ Return length units from given IGES file + + Parameters: + theFileName The file, containing the shape. + + Returns: + String, containing the units name. """ # Example: see GEOM_TestOthers.py aUnitName = self.InsertOp.ReadValue(theFileName, "IGES", "LEN_UNITS") return aUnitName ## Shortcut to ImportFile() for STEP format + # Import a shape from the STEP file with given name. + # @param theFileName The file, containing the shape. + # @param ignoreUnits If True, file length units will be ignored (set to 'meter') + # and result model will be scaled, if its units are not meters. + # If False (default), file length units will be taken into account. + # @return New GEOM.GEOM_Object, containing the imported shape. # # @ref swig_Import_Export "Example" - def ImportSTEP(self, theFileName, doScale = False): + def ImportSTEP(self, theFileName, ignoreUnits = False): """ geompy.ImportFile(...) function for STEP format - Parameters: - doScale If True, file length units will be ignored (set to 'meter') - and result model will be scaled. - If False (default), file length units will be taken into account. + Parameters: + theFileName The file, containing the shape. + ignoreUnits If True, file length units will be ignored (set to 'meter') + and result model will be scaled, if its units are not meters. + If False (default), file length units will be taken into account. + + Returns: + New GEOM.GEOM_Object, containing the imported shape. """ # Example: see GEOM_TestOthers.py - if doScale: + if ignoreUnits: return self.ImportFile(theFileName, "STEP_SCALE") return self.ImportFile(theFileName, "STEP") ## Return length unit from given IGES or STEP file + # @param theFileName The file, containing the shape. + # @return String, containing the units name. # # @ref swig_Import_Export "Example" def GetSTEPUnit(self, theFileName): """ Return length units from given STEP file + + Parameters: + theFileName The file, containing the shape. + + Returns: + String, containing the units name. """ # Example: see GEOM_TestOthers.py aUnitName = self.InsertOp.ReadValue(theFileName, "STEP", "LEN_UNITS") diff --git a/src/STEPImport/STEPImport.cxx b/src/STEPImport/STEPImport.cxx index 9b5f1e996..b82765339 100644 --- a/src/STEPImport/STEPImport.cxx +++ b/src/STEPImport/STEPImport.cxx @@ -131,7 +131,7 @@ extern "C" aValue = new TCollection_HAsciiString ("M"); else if (aLenUnits == "INCH") aValue = new TCollection_HAsciiString ("INCH"); - // TODO + // TODO (for other units than mm, cm, m or inch) //else if (aLenUnits == "") // aValue = new TCollection_HAsciiString (""); @@ -197,7 +197,7 @@ extern "C" Interface_Static::SetCVal("xstep.cascade.unit", "MM"); else if (aLenUnits == "centimetre") Interface_Static::SetCVal("xstep.cascade.unit", "CM"); - else if (aLenUnits == "metre") + else if (aLenUnits == "metre" || aLenUnits.IsEmpty()) Interface_Static::SetCVal("xstep.cascade.unit", "M"); else if (aLenUnits == "INCH") Interface_Static::SetCVal("xstep.cascade.unit", "INCH"); @@ -205,7 +205,7 @@ extern "C" theError = "The file contains not supported units."; return aResShape; } - // TODO + // TODO (for other units than mm, cm, m or inch) //else if (aLenUnits == "") // Interface_Static::SetCVal("xstep.cascade.unit", ""); } -- 2.39.2