std::list<ModelHighAPI_Selection> aListOfOneSel;
aListOfOneSel.push_back(theResult);
fillAttribute(aListOfOneSel,
- theFeature->selectionList(ExchangePlugin_ExportFeature::SELECTION_LIST_ID()));
+ theFeature->selectionList(ExchangePlugin_ExportFeature::XAO_SELECTION_LIST_ID()));
execute();
apply(); // finish operation to make sure the export is done on the current state of the history
}
correctSeparators(aTmpXAOFile);
theDumper << "exportToXAO(" << aDocName << ", '" << aTmpXAOFile << "'" ;
AttributeSelectionListPtr aShapeSelected =
- aBase->selectionList(ExchangePlugin_ExportFeature::SELECTION_LIST_ID());
+ aBase->selectionList(ExchangePlugin_ExportFeature::XAO_SELECTION_LIST_ID());
if (aShapeSelected->isInitialized() && aShapeSelected->size() == 1) {
theDumper<<", "<<aShapeSelected->value(0);
}
TestExport.py
Test2290.py
Test2459.py
+ Test18710.py
TestExportToXAOWithFields.py
TestExportToXAOWithGroupNotUpdated.py
TestExport_FiniteValidator.py
ModelAPI_AttributeString::typeId());
data()->addAttribute(ExchangePlugin_ExportFeature::XAO_GEOMETRY_NAME_ID(),
ModelAPI_AttributeString::typeId());
+ data()->addAttribute(ExchangePlugin_ExportFeature::XAO_SELECTION_LIST_ID(),
+ ModelAPI_AttributeSelectionList::typeId());
ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(),
ExchangePlugin_ExportFeature::XAO_FILE_PATH_ID());
ExchangePlugin_ExportFeature::XAO_AUTHOR_ID());
ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(),
ExchangePlugin_ExportFeature::XAO_GEOMETRY_NAME_ID());
+ ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(),
+ ExchangePlugin_ExportFeature::XAO_SELECTION_LIST_ID());
+
+ // to support previous version of document, move the selection list
+ // if the type of export operation is XAO
+ AttributeStringPtr aTypeAttr = string(EXPORT_TYPE_ID());
+ if (aTypeAttr->isInitialized() && aTypeAttr->value() == "XAO") {
+ AttributeSelectionListPtr aSelList = selectionList(SELECTION_LIST_ID());
+ int aSelListSize = aSelList->size();
+ AttributeSelectionListPtr aXAOSelList = selectionList(XAO_SELECTION_LIST_ID());
+ if (aSelListSize > 0 && aXAOSelList->size() == 0) {
+ for (int i = 0; i < aSelListSize; ++i) {
+ AttributeSelectionPtr aSelection = aSelList->value(i);
+ aXAOSelList->append(aSelection->context(), aSelection->value());
+ }
+ aXAOSelList->setSelectionType(aSelList->selectionType());
+ }
+ aSelList->clear();
+ }
}
void ExchangePlugin_ExportFeature::attributeChanged(const std::string& theID)
std::list<DocumentPtr> aDocuments; /// documents of Parts selected and used in export
std::map<DocumentPtr, GeomTrsfPtr> aDocTrsf; /// translation of the part
- AttributeSelectionListPtr aSelection = selectionList(SELECTION_LIST_ID());
+ AttributeSelectionListPtr aSelection = selectionList(XAO_SELECTION_LIST_ID());
bool aIsSelection = aSelection->isInitialized() && aSelection->size() > 0;
if (aIsSelection) { // a mode for export to geom result by result
for(int a = 0; a < aSelection->size(); a++) {
if (aFormat == "XAO") { // on export to GEOm the selection attribute is filled - this is
// an exceptional case where export to XAO feature must be kept
- AttributeSelectionListPtr aList = aThis->selectionList(SELECTION_LIST_ID());
+ AttributeSelectionListPtr aList = aThis->selectionList(XAO_SELECTION_LIST_ID());
return !aList->isInitialized() || aList->size() == 0;
}
return true;
static const std::string MY_SELECTION_LIST_ID("selection_list");
return MY_SELECTION_LIST_ID;
}
+ /// attribute name of xao selection list
+ inline static const std::string& XAO_SELECTION_LIST_ID()
+ {
+ static const std::string MY_SELECTION_LIST_ID("xao_selection_list");
+ return MY_SELECTION_LIST_ID;
+ }
/// attribute name of author for XAO format
inline static const std::string& XAO_AUTHOR_ID()
{
--- /dev/null
+# Copyright (C) 2020 CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+from salome.shaper import model
+
+from GeomAPI import *
+from ModelAPI import *
+from SketchAPI import *
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 5, 10)
+Export_1 = model.exportToXAO(Part_1_doc, '/tmp/shaper_vcnhioqf.xao', model.selection("SOLID", "Cylinder_1_1"), 'XAO')
+Export_1.setName("XAO")
+Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
+model.end()
+
+model.testNbResults(Part_1, 1)
+model.testNbSubResults(Part_1, [0])
+model.testNbSubShapes(Part_1, GeomAPI_Shape.SOLID, [2])
+model.testNbSubShapes(Part_1, GeomAPI_Shape.FACE, [9])
+model.testNbSubShapes(Part_1, GeomAPI_Shape.EDGE, [30])
+model.testNbSubShapes(Part_1, GeomAPI_Shape.VERTEX, [60])
+model.testResultsVolumes(Part_1, [1785.39816339744857])
+
+model.begin()
+ModelAPI.removeFeaturesAndReferences(FeatureSet([Cylinder_1.feature()]))
+model.end()
+
+model.testNbResults(Part_1, 1)
+model.testNbSubResults(Part_1, [0])
+model.testNbSubShapes(Part_1, GeomAPI_Shape.SOLID, [1])
+model.testNbSubShapes(Part_1, GeomAPI_Shape.FACE, [6])
+model.testNbSubShapes(Part_1, GeomAPI_Shape.EDGE, [24])
+model.testNbSubShapes(Part_1, GeomAPI_Shape.VERTEX, [48])
+model.testResultsVolumes(Part_1, [1000])
+
+assert(model.checkPythonDump())