X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FExchangePlugin%2FTest%2FTestImport.py;h=6b986c2727f34761d3bcff1db69e884c7ed572e4;hb=a5560f9b9c5cc8e8f48522b5992539518733a6d3;hp=5a7b23d2a5437fd5dd0295877de518627abd5cea;hpb=a66a1008a2d33e0abb45b5f3fb350a6af8432e6f;p=modules%2Fshaper.git diff --git a/src/ExchangePlugin/Test/TestImport.py b/src/ExchangePlugin/Test/TestImport.py index 5a7b23d2a..6b986c272 100644 --- a/src/ExchangePlugin/Test/TestImport.py +++ b/src/ExchangePlugin/Test/TestImport.py @@ -20,22 +20,21 @@ aSession = ModelAPI_Session.get() #========================================================================= def testImport(theType, theFile, theVolume, theDelta): # Create a part for import - aSession.startOperation() + aSession.startOperation("Create part for import") aPartFeature = aSession.moduleDocument().addFeature("Part") aSession.finishOperation() aPart = aSession.activeDocument() - - aSession.startOperation() + + aSession.startOperation("Import file") aFeatureKind = "Import" anImportFeature = aPart.addFeature(aFeatureKind) assert anImportFeature, "{0}: Can not create a feature {1}".format(theType, aFeatureKind) - aFieldName = "import_file_selector" + aFieldName = "file_path" file = anImportFeature.string(aFieldName) assert file, "{0}: Can not receive string field {1}".format(theType, aFieldName) file.setValue(theFile) - anImportFeature.execute() aSession.finishOperation() - + # Check results assert anImportFeature.error() == '', "{0}: The error after execution: {1}".format(theType, anImportFeature.error()) assert len(anImportFeature.results()) == 1, "{0}: Wrong number of results: expected = 1, real = {1}".format(theType, len(anImportFeature.results())) @@ -43,27 +42,72 @@ def testImport(theType, theFile, theVolume, theDelta): assert aResultBody, "{0}: The result is not a body".format(theType) aShape = aResultBody.shape() assert aShape, "{0}: The body does not have a shape".format(theType) - + # Check shape volume aRefVolume = theVolume - aResVolume = GeomAlgoAPI_ShapeProps.volume(aShape) + aResVolume = GeomAlgoAPI_ShapeTools.volume(aShape) assert (math.fabs(aResVolume - aRefVolume) < theDelta), "{0}: The volume is wrong: expected = {1}, real = {2}".format(theType, aRefVolume, aResVolume) +def testImportXAO(): + # Create a part for import + aSession.startOperation("Create part for import") + aPartFeature = aSession.moduleDocument().addFeature("Part") + aSession.finishOperation() + aPart = aSession.activeDocument() + + aSession.startOperation("Import XAO") + anImportFeature = aPart.addFeature("Import") + anImportFeature.string("file_path").setValue("Data/test.xao") + aSession.finishOperation() + + # Check results + assert anImportFeature.error() == '' + assert anImportFeature.name() == "mygeom" + assert len(anImportFeature.results()) == 1 + assert modelAPI_ResultBody(anImportFeature.firstResult()) + assert anImportFeature.firstResult().data().name() == "mygeom_1" + aCompositeFeature = featureToCompositeFeature(anImportFeature) + assert aCompositeFeature.numberOfSubs(False) == 2 + + aFeature1 = aCompositeFeature.subFeature(0, False) + assert aFeature1.getKind() == "Group" + assert aFeature1.name() == "boite_1" + + aSelectionList = aFeature1.selectionList("group_list") + assert aSelectionList.selectionType() == "Solids" + assert aSelectionList.size() == 1 + assert aSelectionList.value(0).namingName("") == "mygeom_1_1" + + aFeature2 = aCompositeFeature.subFeature(1, False) + assert aFeature2.getKind() == "Group" + assert aFeature2.name() == "Group_2" + + aSelectionList = aFeature2.selectionList("group_list") + assert aSelectionList.selectionType() == "Faces" + assert aSelectionList.size() == 2 + assert aSelectionList.value(0).namingName("") == "mygeom_1/Shape1_1" + assert aSelectionList.value(1).namingName("") == "mygeom_1/Shape2_1" + if __name__ == '__main__': #========================================================================= # Create a shape imported from BREP #========================================================================= - testImport("BREP", "Data/solid.brep", 259982.29715, 10 ** -5) + testImport("BREP", "Data/solid.brep", 259982.297176, 10 ** -5) + testImport("BRP", "Data/solid.brp", 259982.297176, 10 ** -5) #========================================================================= # Create a shape imported from STEP #========================================================================= - testImport("STP", "Data/screw.stp", 3.78827059338e-06, 10 ** -17) - testImport("STEP", "Data/screw.step", 3.78827059338e-06, 10 ** -17) + testImport("STP", "Data/screw.stp", 3.78827401738e-06, 10 ** -17) + testImport("STEP", "Data/screw.step", 3.78827401738e-06, 10 ** -17) #========================================================================= # Create a shape imported from IGES #========================================================================= - testImport("IGES", "Data/bearing.iges", 6.86980756235e-14, 10 ** -25) - testImport("IGS", "Data/bearing.igs", 6.86980756235e-14, 10 ** -25) + testImport("IGES", "Data/bearing.iges", 6.86970803067e-14, 10 ** -25) + testImport("IGS", "Data/bearing.igs", 6.86970803067e-14, 10 ** -25) +#========================================================================= +# Create a shape imported from XAO +#========================================================================= + testImportXAO() #========================================================================= # End of test #=========================================================================