]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Upgrade of export feature tests
authormpv <mpv@opencascade.com>
Wed, 14 Dec 2016 11:42:25 +0000 (14:42 +0300)
committermpv <mpv@opencascade.com>
Wed, 14 Dec 2016 11:42:25 +0000 (14:42 +0300)
src/ExchangePlugin/ExchangePlugin_Validators.cpp
src/ExchangePlugin/ExchangePlugin_msg_en.ts
src/ExchangePlugin/Test/TestExport.py

index a0117d84ef3131ef50cdd11088287c60c8fb31cc..8b3bcf587fb89bf4c761d6c714482e1236dcbda9 100644 (file)
@@ -44,14 +44,16 @@ bool ExchangePlugin_FormatValidator::isValid(const AttributePtr& theAttribute,
                                              Events_InfoMessage& theError) const
 {
   if (!theAttribute->isInitialized()) {
-    theError = "Is not initialized.";
+    theError = "%1 is not initialized.";
+    theError.arg(theAttribute->id());
     return false;
   }
 
   const AttributeStringPtr aStrAttr =
       std::dynamic_pointer_cast<ModelAPI_AttributeString>(theAttribute);
   if (!aStrAttr) {
-    theError = "Is not a string attribute.";
+    theError = "%1 is not a string attribute.";
+    theError.arg(theAttribute->id());
     return false;
   }
 
index 9afb36bb1801d6ca964b8d0ba50a311732348e58..ccc645ab8d3de5129603a5d6dbbe040ba6374e88 100644 (file)
       <translation>Set the XAO file geometry name</translation>
     </message>
   </context>
+  <context>
+    <name>Export:ExchangePlugin_ExportFormat</name>
+    <message>
+      <source>%1 is not initialized.</source>
+      <translation>Attribute %1 is not initialized.</translation>
+    </message>
+    <message>
+      <source>%1 is not a string attribute.</source>
+      <translation>Attribute %1 is not a string.</translation>
+    </message>
+  </context>
 </TS>
index f3afbf36f6bb5acce08eb1a8c693990dc9a474d7..ffd7f04c0715cc8ec42b8ce8e3830b29d6a9ecd7 100644 (file)
@@ -37,23 +37,21 @@ def testExport(theType, theFormat, theFile, theVolume, theDelta):
     aPart = aSession.activeDocument()
 
     aSession.startOperation("Import screw")
-    anImport = model.addImport(aPart, "Data/screw.step")
-#     anImportFeature = aPart.addFeature("Import")
-#     anImportFeature.string("file_path").setValue("Data/screw.step")
-#     anImportFeature.execute()
+    anImportFeature = aPart.addFeature("Import")
+    anImportFeature.string("file_path").setValue("Data/screw.step")
     aSession.finishOperation()
 
     removeFile(theFile)
     # Export a part
     aSession.startOperation("Export part")
-    model.exportToFile(aPart, theFile, anImport.results(), theFormat)
-#     anExportFeature = aPart.addFeature("Export")
-#     anExportFeature.string("file_format").setValue(theFormat)
-    anExportFeature.string("file_path").setValue(theFile)
-#     aSelectionListAttr = anExportFeature.selectionList("selection_list")
-#     aSelectionListAttr.setSelectionType("solids")
-#     aSelectionListAttr.append(anImportFeature.firstResult(), anImportFeature.firstResult().shape())
-#     anExportFeature.execute()
+    anExportFeature = aPart.addFeature("Export")
+    anExportFeature.string("file_format").setValue(theFormat)
+    print "theFile=",theFile
+    anExportFeature.string("file_path").setValue(theFile)
+    anExportFeature.string("ExportType").setValue("Regular")
+    aSelectionListAttr = anExportFeature.selectionList("selection_list")
+    aSelectionListAttr.setSelectionType("solids")
+    aSelectionListAttr.append(anImportFeature.firstResult(), anImportFeature.firstResult().shape())
     aSession.finishOperation()
 
     assert os.path.exists(theFile)
@@ -69,50 +67,60 @@ def testExportXAO():
     aPart = aSession.activeDocument()
 
     aSession.startOperation("Import Box_1")
-    anImport = model.addImport(aPart, "Data/Box_1.brep")
-#     anImportFeature = aPart.addFeature("Import")
-#     anImportFeature.string("file_path").setValue("Data/Box_1.brep")
-#     anImportFeature.execute()
+    anImportFeature = aPart.addFeature("Import")
+    anImportFeature.string("file_path").setValue("Data/Box_1.brep")
     aSession.finishOperation()
 
     # Create groups
-    aSession.startOperation()
-    aGroup = model.addGroup(aPart, anImport.results())
-    aGroup.defaultResult().data().setName("boite_1")
-    aGroup.groupList().setSelectionType("solid")
-#     aGroupFeature = aSession.activeDocument().addFeature("Group")
-#     aGroupFeature.data().setName("boite_1")
-#     aSelectionListAttr = aGroupFeature.selectionList("group_list")
-#     aSelectionListAttr.setSelectionType("solid")
-#     aSelectionListAttr.append(anImport.feature().lastResult(), None)
-#     aGroupFeature.execute()
+    aSession.startOperation("First group")
+    aGroupFeature = aSession.activeDocument().addFeature("Group")
+    aGroupFeature.data().setName("boite_1")
+    aSelectionListAttr = aGroupFeature.selectionList("group_list")
+    aSelectionListAttr.setSelectionType("solid")
+    aSelectionListAttr.append(anImportFeature.lastResult(), None)
     aSession.finishOperation()
 
-    aSession.startOperation()
-    aGroup = model.addGroup(aPart, [])
-    aGroup.groupList().setSelectionType("face")
-    aGroup.groupList().append("Box_1_1/Shape1_1")
-    aGroup.groupList().append("Box_1_1/Shape2_1")
-    aGroup.defaultResult().data().setName("")
-#     aGroupFeature = aSession.activeDocument().addFeature("Group")
-#     aGroupFeature.data().setName("")
-#     aSelectionListAttr = aGroupFeature.selectionList("group_list")
-#     aSelectionListAttr.setSelectionType("face")
-#     aSelectionListAttr.append("Box_1_1/Shape1")
-#     aSelectionListAttr.append("Box_1_1/Shape2")
-#     aGroupFeature.execute()
+    aSession.startOperation("Second Group")
+    aGroupFeature = aSession.activeDocument().addFeature("Group")
+    aGroupFeature.data().setName("")
+    aSelectionListAttr = aGroupFeature.selectionList("group_list")
+    aSelectionListAttr.setSelectionType("face")
+    aSelectionListAttr.append("Box_1_1/Shape1")
+    aSelectionListAttr.append("Box_1_1/Shape2")
+    aSession.finishOperation()
+
+    aSession.startOperation("Create a field")
+    aField = aSession.activeDocument().addFeature("Field")
+    aSelectionListAttr = aField.selectionList("selected")
+    aSelectionListAttr.setSelectionType("face")
+    aSelectionListAttr.append("Box_1_1/Shape1")
+    aSelectionListAttr.append("Box_1_1/Shape2")
+    aComponentNames = aField.stringArray("components_names")
+    aComponentNames.setSize(2) # two components
+    aComponentNames.setValue(0, "temperatue")
+    aComponentNames.setValue(1, "porosity")
+    aStamps = aField.intArray("stamps")
+    aStamps.setSize(1) # one step
+    aStamps.setValue(0, 10)
+    aTables = aField.tables("values")
+    aTables.setType(2) # double
+    aTables.setSize(1 + 2, 2, 1) # default row + number of selected, number of compoents, number of steps (tables)
+    aTables.setValue(1., 0, 0, 0) # value, index of selection, index of component, index of step
+    aTables.setValue(2., 1, 0, 0)
+    aTables.setValue(3., 2, 0, 0)
+    aTables.setValue(4., 0, 1, 0)
+    aTables.setValue(5., 1, 1, 0)
+    aTables.setValue(6., 2, 1, 0)
     aSession.finishOperation()
 
     # Export
-    aSession.startOperation("Export")
-    model.exportToXAO(aPart, "Data/export.xao", "me", "mygeom")
-#     anExportFeature = aPart.addFeature("Export")
-# #     anExportFeature.string("ExportType").setValue("XAO")
-#     anExportFeature.string("file_path").setValue("Data/export.xao")
-# #     anExportFeature.string("file_format").setValue("XAO")
-#     anExportFeature.string("xao_author").setValue("me")
-#     anExportFeature.string("xao_geometry_name").setValue("mygeom")
-#     anExportFeature.execute()
+    aSession.startOperation("Export to XAO")
+    anExportFeature = aPart.addFeature("Export")
+    anExportFeature.string("xao_file_path").setValue("Data/export.xao")
+    anExportFeature.string("file_format").setValue("XAO")
+    anExportFeature.string("ExportType").setValue("XAO")
+    anExportFeature.string("xao_author").setValue("me")
+    anExportFeature.string("xao_geometry_name").setValue("mygeom")
     aSession.finishOperation()
 
     # Check exported file