1 // Copyright (C) 2014-2019 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include <ExchangePlugin_ExportFeature.h>
30 #include <Config_Common.h>
31 #include <Config_PropManager.h>
33 #include <GeomAlgoAPI_BREPExport.h>
34 #include <GeomAlgoAPI_CompoundBuilder.h>
35 #include <GeomAlgoAPI_IGESExport.h>
36 #include <GeomAlgoAPI_STEPExport.h>
37 #include <GeomAlgoAPI_Tools.h>
38 #include <GeomAlgoAPI_XAOExport.h>
40 #include <GeomAPI_Shape.h>
41 #include <GeomAPI_ShapeExplorer.h>
42 #include <GeomAPI_Trsf.h>
44 #include <Locale_Convert.h>
46 #include <ModelAPI_AttributeSelectionList.h>
47 #include <ModelAPI_AttributeString.h>
48 #include <ModelAPI_AttributeStringArray.h>
49 #include <ModelAPI_AttributeIntArray.h>
50 #include <ModelAPI_AttributeTables.h>
51 #include <ModelAPI_Data.h>
52 #include <ModelAPI_Document.h>
53 #include <ModelAPI_Object.h>
54 #include <ModelAPI_ResultBody.h>
55 #include <ModelAPI_ResultPart.h>
56 #include <ModelAPI_ResultGroup.h>
57 #include <ModelAPI_ResultField.h>
58 #include <ModelAPI_Session.h>
59 #include <ModelAPI_Validator.h>
60 #include <ModelAPI_Tools.h>
62 #include <Events_InfoMessage.h>
64 #include <XAO_Group.hxx>
65 #include <XAO_Field.hxx>
66 #include <XAO_Xao.hxx>
67 #include <XAO_Geometry.hxx>
69 #include <ExchangePlugin_Tools.h>
71 ExchangePlugin_ExportFeature::ExchangePlugin_ExportFeature()
75 ExchangePlugin_ExportFeature::~ExchangePlugin_ExportFeature()
77 // TODO Auto-generated destructor stub
81 * Request for initialization of data model of the feature: adding all attributes
83 void ExchangePlugin_ExportFeature::initAttributes()
85 data()->addAttribute(ExchangePlugin_ExportFeature::EXPORT_TYPE_ID(),
86 ModelAPI_AttributeString::typeId());
87 data()->addAttribute(ExchangePlugin_ExportFeature::FILE_PATH_ID(),
88 ModelAPI_AttributeString::typeId());
89 data()->addAttribute(ExchangePlugin_ExportFeature::XAO_FILE_PATH_ID(),
90 ModelAPI_AttributeString::typeId());
91 data()->addAttribute(ExchangePlugin_ExportFeature::FILE_FORMAT_ID(),
92 ModelAPI_AttributeString::typeId());
93 data()->addAttribute(ExchangePlugin_ExportFeature::SELECTION_LIST_ID(),
94 ModelAPI_AttributeSelectionList::typeId());
95 data()->addAttribute(ExchangePlugin_ExportFeature::XAO_AUTHOR_ID(),
96 ModelAPI_AttributeString::typeId());
97 data()->addAttribute(ExchangePlugin_ExportFeature::XAO_GEOMETRY_NAME_ID(),
98 ModelAPI_AttributeString::typeId());
99 data()->addAttribute(ExchangePlugin_ExportFeature::XAO_SELECTION_LIST_ID(),
100 ModelAPI_AttributeSelectionList::typeId());
102 ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(),
103 ExchangePlugin_ExportFeature::XAO_FILE_PATH_ID());
104 ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(),
105 ExchangePlugin_ExportFeature::XAO_AUTHOR_ID());
106 ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(),
107 ExchangePlugin_ExportFeature::XAO_GEOMETRY_NAME_ID());
108 ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(),
109 ExchangePlugin_ExportFeature::XAO_SELECTION_LIST_ID());
111 // to support previous version of document, move the selection list
112 // if the type of export operation is XAO
113 AttributeStringPtr aTypeAttr = string(EXPORT_TYPE_ID());
114 if (aTypeAttr->isInitialized() && aTypeAttr->value() == "XAO") {
115 bool aWasBlocked = data()->blockSendAttributeUpdated(true, false);
116 AttributeSelectionListPtr aSelList = selectionList(SELECTION_LIST_ID());
117 AttributeSelectionListPtr aXAOSelList = selectionList(XAO_SELECTION_LIST_ID());
118 if (aSelList->size() > 0 && aXAOSelList->size() == 0)
119 aSelList->copyTo(aXAOSelList);
121 data()->blockSendAttributeUpdated(aWasBlocked, false);
125 void ExchangePlugin_ExportFeature::attributeChanged(const std::string& theID)
127 if (theID == XAO_FILE_PATH_ID()) {
128 string(ExchangePlugin_ExportFeature::FILE_PATH_ID())->setValue(
129 string(ExchangePlugin_ExportFeature::XAO_FILE_PATH_ID())->value());
134 * Computes or recomputes the results
136 void ExchangePlugin_ExportFeature::execute()
138 AttributeStringPtr aFormatAttr =
139 this->string(ExchangePlugin_ExportFeature::FILE_FORMAT_ID());
140 std::string aFormat = aFormatAttr->value();
142 AttributeStringPtr aFilePathAttr =
143 this->string(ExchangePlugin_ExportFeature::FILE_PATH_ID());
144 std::string aFilePath = aFilePathAttr->value();
145 if (aFilePath.empty())
148 exportFile(aFilePath, aFormat);
151 void ExchangePlugin_ExportFeature::exportFile(const std::string& theFileName,
152 const std::string& theFormat)
154 std::string aFormatName = theFormat;
156 if (aFormatName.empty()) { // get default format for the extension
158 std::string anExtension = GeomAlgoAPI_Tools::File_Tools::extension(theFileName);
159 if (anExtension == "BREP" || anExtension == "BRP") {
160 aFormatName = "BREP";
161 } else if (anExtension == "STEP" || anExtension == "STP") {
162 aFormatName = "STEP";
163 } else if (anExtension == "IGES" || anExtension == "IGS") {
164 aFormatName = "IGES-5.1";
166 aFormatName = anExtension;
170 if (aFormatName == "XAO") {
171 exportXAO(theFileName);
175 // make shape for export from selected shapes
176 AttributeSelectionListPtr aSelectionListAttr =
177 this->selectionList(ExchangePlugin_ExportFeature::SELECTION_LIST_ID());
178 std::list<GeomShapePtr> aShapes;
179 for (int i = 0, aSize = aSelectionListAttr->size(); i < aSize; ++i) {
180 AttributeSelectionPtr anAttrSelection = aSelectionListAttr->value(i);
181 std::shared_ptr<GeomAPI_Shape> aCurShape = anAttrSelection->value();
182 if (aCurShape.get() == NULL)
183 aCurShape = anAttrSelection->context()->shape();
184 if (aCurShape.get() != NULL)
185 aShapes.push_back(aCurShape);
188 // Store compound if we have more than one shape.
189 std::shared_ptr<GeomAPI_Shape> aShape =
190 aShapes.size() == 1 ? aShapes.front() : GeomAlgoAPI_CompoundBuilder::compound(aShapes);
192 // Perform the export
194 bool aResult = false;
195 if (aFormatName == "BREP") {
196 aResult = BREPExport(theFileName, aFormatName, aShape, anError);
197 } else if (aFormatName == "STEP") {
198 aResult = STEPExport(theFileName, aFormatName, aShape, anError);
199 } else if (aFormatName.substr(0, 4) == "IGES") {
200 aResult = IGESExport(theFileName, aFormatName, aShape, anError);
202 anError = "Unsupported format: " + aFormatName;
205 if (!anError.empty()) {
206 setError("An error occurred while exporting " + theFileName + ": " + anError);
211 /// Returns XAO string by the value from the table
212 static std::string valToString(const ModelAPI_AttributeTables::Value& theVal,
213 const ModelAPI_AttributeTables::ValueType& theType) {
214 std::ostringstream aStr; // the resulting string value
216 case ModelAPI_AttributeTables::BOOLEAN:
217 aStr<<(theVal.myBool ? "true" : "false");
219 case ModelAPI_AttributeTables::INTEGER:
222 case ModelAPI_AttributeTables::DOUBLE:
223 aStr<<theVal.myDouble;
225 case ModelAPI_AttributeTables::STRING:
232 /// Returns true if something in selection is presented in the results list
233 static bool isInResults(AttributeSelectionListPtr theSelection,
234 const std::list<ResultPtr>& theResults,
235 std::set<ResultPtr>& theCashedResults)
237 // collect all results into a cashed set
238 if (theCashedResults.empty()) {
239 std::list<ResultPtr> aResults;
240 std::list<ResultPtr>::const_iterator aRes = theResults.cbegin();
241 for(; aRes != theResults.cend(); aRes++) {
242 if (theCashedResults.count(*aRes))
245 theCashedResults.insert(*aRes);
246 if ((*aRes)->groupName() == ModelAPI_ResultBody::group()) {
247 ResultBodyPtr aResBody = std::dynamic_pointer_cast<ModelAPI_ResultBody>(*aRes);
248 std::list<ResultPtr> aResults;
249 ModelAPI_Tools::allSubs(aResBody, aResults, false);
250 for(std::list<ResultPtr>::iterator aR = aResults.begin(); aR != aResults.end(); aR++) {
251 theCashedResults.insert(std::dynamic_pointer_cast<ModelAPI_ResultBody>(*aR));
253 } else if ((*aRes)->groupName() == ModelAPI_ResultPart::group()) { // all results of the part
254 ResultPartPtr aResPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(*aRes);
255 DocumentPtr aPartDoc = aResPart->partDoc();
256 if (!aPartDoc.get() || !aPartDoc->isOpened()) { // document is not accessible
259 int aBodyCount = aPartDoc->size(ModelAPI_ResultBody::group());
260 for (int aBodyIndex = 0; aBodyIndex < aBodyCount; ++aBodyIndex) {
261 ResultBodyPtr aResBody =
262 std::dynamic_pointer_cast<ModelAPI_ResultBody>(
263 aPartDoc->object(ModelAPI_ResultBody::group(), aBodyIndex));
264 if (aResBody.get()) {
265 theCashedResults.insert(aResBody);
266 std::list<ResultPtr> aResults;
267 ModelAPI_Tools::allSubs(aResBody, aResults, false);
268 for(std::list<ResultPtr>::iterator aR = aResults.begin(); aR != aResults.end(); aR++) {
269 theCashedResults.insert(std::dynamic_pointer_cast<ModelAPI_ResultBody>(*aR));
276 // if context is in results, return true
277 for(int a = 0; a < theSelection->size(); a++) {
278 AttributeSelectionPtr anAttr = theSelection->value(a);
279 ResultPtr aContext = anAttr->context();
280 // check is it group selected for groups BOP
281 if (aContext.get() && aContext->groupName() == ModelAPI_ResultGroup::group()) {
282 // it is impossible by used results check which result is used in this group result,
283 // so check the results shapes is it in results of this document or not
284 FeaturePtr aSelFeature =
285 std::dynamic_pointer_cast<ModelAPI_Feature>(theSelection->owner());
286 if (!aSelFeature.get() || aSelFeature->results().empty())
288 GeomShapePtr aGroupResShape = aSelFeature->firstResult()->shape();
290 std::set<ResultPtr>::iterator allResultsIter = theCashedResults.begin();
291 for(; allResultsIter != theCashedResults.end(); allResultsIter++) {
292 GeomShapePtr aResultShape = (*allResultsIter)->shape();
294 GeomAPI_Shape::ShapeType aType =
295 GeomAPI_Shape::shapeTypeByStr(theSelection->selectionType());
296 GeomAPI_ShapeExplorer aGroupResExp(aGroupResShape, aType);
297 for(; aGroupResExp.more(); aGroupResExp.next()) {
298 if (aResultShape->isSubShape(aGroupResExp.current(), false))
299 return true; // at least one shape of the group is in the used results
303 ResultBodyPtr aSelected = std::dynamic_pointer_cast<ModelAPI_ResultBody>(anAttr->context());
304 if (!aSelected.get()) { // try to get selected feature and all its results
305 FeaturePtr aContextFeature = anAttr->contextFeature();
306 if (aContextFeature.get() && !aContextFeature->results().empty()) {
307 const std::list<ResultPtr>& allResluts = aContextFeature->results();
308 std::list<ResultPtr>::const_iterator aResIter = allResluts.cbegin();
309 for(; aResIter != allResluts.cend(); aResIter++) {
310 if (aResIter->get() && theCashedResults.count(*aResIter))
314 } else if (aSelected.get() && theCashedResults.count(aSelected))
320 void ExchangePlugin_ExportFeature::exportXAO(const std::string& theFileName)
329 std::string anAuthor = string(ExchangePlugin_ExportFeature::XAO_AUTHOR_ID())->value();
330 aXao.setAuthor(anAuthor);
332 // make shape for export from all results
333 std::list<GeomShapePtr> aShapes;
334 std::list<ResultPtr> aResults;
335 std::list<DocumentPtr> aDocuments; /// documents of Parts selected and used in export
336 std::map<DocumentPtr, GeomTrsfPtr> aDocTrsf; /// translation of the part
338 AttributeSelectionListPtr aSelection = selectionList(XAO_SELECTION_LIST_ID());
339 bool aIsSelection = aSelection->isInitialized() && aSelection->size() > 0;
340 if (aIsSelection) { // a mode for export to geom result by result
341 for(int a = 0; a < aSelection->size(); a++) {
342 AttributeSelectionPtr anAttr = aSelection->value(a);
343 ResultPtr aBodyContext =
344 std::dynamic_pointer_cast<ModelAPI_Result>(anAttr->context());
345 if (aBodyContext.get() && !aBodyContext->isDisabled() && aBodyContext->shape().get()) {
346 aResults.push_back(aBodyContext);
347 GeomShapePtr aShape = anAttr->value();
349 aShape = aBodyContext->shape();
350 aShapes.push_back(aShape);
351 if (aBodyContext->groupName() == ModelAPI_ResultPart::group()) {
352 ResultPartPtr aResPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(aBodyContext);
353 DocumentPtr aPartDoc = aResPart->partDoc();
354 if (!aPartDoc.get() || !aPartDoc->isOpened()) { // document is not accessible
355 std::string msg = "Can not export XAO for not loaded part";
356 Events_InfoMessage("ExportFeature", msg, this).send();
359 aDocuments.push_back(aPartDoc);
360 aDocTrsf[aPartDoc] = aResPart->summaryTrsf();
366 int aBodyCount = document()->size(ModelAPI_ResultBody::group());
367 for (int aBodyIndex = 0; aBodyIndex < aBodyCount; ++aBodyIndex) {
368 ResultBodyPtr aResultBody =
369 std::dynamic_pointer_cast<ModelAPI_ResultBody>(
370 document()->object(ModelAPI_ResultBody::group(), aBodyIndex));
371 if (!aResultBody.get())
373 aShapes.push_back(aResultBody->shape());
374 aResults.push_back(aResultBody);
377 if (aShapes.empty()) {
378 setError("No shapes to export");
383 GeomShapePtr aShape = (aShapes.size() == 1)
385 : GeomAlgoAPI_CompoundBuilder::compound(aShapes);
387 SetShapeToXAO(aShape, &aXao, anError);
389 if (!anError.empty()) {
390 setError("An error occurred while exporting " + theFileName + ": " + anError);
395 std::string aGeometryName = string(ExchangePlugin_ExportFeature::XAO_GEOMETRY_NAME_ID())->value();
396 if (aGeometryName.empty() && aResults.size() == 1) {
397 // get the name from the first result
398 ResultPtr aResultBody = *aResults.begin();
399 aGeometryName = Locale::Convert::toString(aResultBody->data()->name());
402 aXao.getGeometry()->setName(aGeometryName);
404 std::set<ResultPtr> allResultsCashed; // cash to speed up searching in all results selected
406 // iterate all documents used
407 if (aDocuments.empty())
408 aDocuments.push_back(document());
409 std::list<DocumentPtr>::iterator aDoc = aDocuments.begin();
410 for(; aDoc != aDocuments.end(); aDoc++) {
412 int aGroupCount = (*aDoc)->size(ModelAPI_ResultGroup::group());
413 for (int aGroupIndex = 0; aGroupIndex < aGroupCount; ++aGroupIndex) {
414 ResultGroupPtr aResultGroup = std::dynamic_pointer_cast<ModelAPI_ResultGroup>(
415 (*aDoc)->object(ModelAPI_ResultGroup::group(), aGroupIndex));
416 if (!aResultGroup.get() || !aResultGroup->shape().get())
419 FeaturePtr aGroupFeature = (*aDoc)->feature(aResultGroup);
421 AttributeSelectionListPtr aSelectionList =
422 aGroupFeature->selectionList("group_list");
423 if (!isInResults(aSelectionList, aResults, allResultsCashed))// skip group not used in result
426 // conversion of dimension
427 std::string aSelectionType = aSelectionList->selectionType();
428 GeomAPI_Shape::ShapeType aSelType = GeomAPI_Shape::shapeTypeByStr(aSelectionType);
429 std::string aDimensionString =
430 ExchangePlugin_Tools::selectionType2xaoDimension(aSelectionType);
431 XAO::Dimension aGroupDimension = XAO::XaoUtils::stringToDimension(aDimensionString);
433 XAO::Group* aXaoGroup = aXao.addGroup(aGroupDimension,
434 Locale::Convert::toString(aResultGroup->data()->name()));
437 GeomAPI_ShapeExplorer aGroupResExplorer(aResultGroup->shape(), aSelType);
438 for(; aGroupResExplorer.more(); aGroupResExplorer.next()) {
439 GeomShapePtr aGroupShape = aGroupResExplorer.current();
440 if (aDocTrsf.find(*aDoc) != aDocTrsf.end())
441 aGroupShape->move(aDocTrsf[*aDoc]);
442 int aReferenceID = GeomAlgoAPI_CompoundBuilder::id(aShape, aGroupShape);
443 if (aReferenceID == 0) // selected value does not found in the exported shape
445 std::string aReferenceString = XAO::XaoUtils::intToString(aReferenceID);
447 aXao.getGeometry()->getElementIndexByReference(aGroupDimension, aReferenceString);
448 aXaoGroup->add(anElementID);
450 } catch (XAO::XAO_Exception& e) {
452 std::string msg = "An error occurred while exporting group " +
453 Locale::Convert::toString(aResultGroup->data()->name());
457 msg += "=> skipping this group from XAO export.";
458 Events_InfoMessage("ExportFeature", msg, this).send();
459 aXao.removeGroup(aXaoGroup);
465 int aFieldCount = (*aDoc)->size(ModelAPI_ResultField::group());
466 for (int aFieldIndex = 0; aFieldIndex < aFieldCount; ++aFieldIndex) {
467 ResultFieldPtr aResultField = std::dynamic_pointer_cast<ModelAPI_ResultField>(
468 (*aDoc)->object(ModelAPI_ResultField::group(), aFieldIndex));
470 FeaturePtr aFieldFeature = (*aDoc)->feature(aResultField);
472 AttributeSelectionListPtr aSelectionList =
473 aFieldFeature->selectionList("selected");
474 std::string aSelectionType = aSelectionList->selectionType();
475 bool isWholePart = aSelectionType == "part";
476 // skip field not used in results
477 if (!isWholePart && !isInResults(aSelectionList, aResults, allResultsCashed))
480 // conversion of dimension
481 std::string aDimensionString =
482 ExchangePlugin_Tools::selectionType2xaoDimension(aSelectionType);
483 XAO::Dimension aFieldDimension = XAO::XaoUtils::stringToDimension(aDimensionString);
484 // get tables and their type
485 std::shared_ptr<ModelAPI_AttributeTables> aTables = aFieldFeature->tables("values");
486 std::string aTypeString = ExchangePlugin_Tools::valuesType2xaoType(aTables->type());
487 XAO::Type aFieldType = XAO::XaoUtils::stringToFieldType(aTypeString);
489 XAO::Field* aXaoField = aXao.addField(aFieldType, aFieldDimension, aTables->columns(),
490 Locale::Convert::toString(aResultField->data()->name()));
494 // set components names
495 AttributeStringArrayPtr aComponents = aFieldFeature->stringArray("components_names");
496 for(int aComp = 0; aComp < aComponents->size(); aComp++) {
497 std::string aName = aComponents->value(aComp);
498 aXaoField->setComponentName(aComp, aName);
501 AttributeIntArrayPtr aStamps = aFieldFeature->intArray("stamps");
502 for (int aStepIndex = 0; aStepIndex < aTables->tables(); aStepIndex++) {
503 XAO::Step* aStep = aXaoField->addNewStep(aStepIndex + 1);
504 aStep->setStep(aStepIndex + 1);
505 int aStampIndex = aStamps->value(aStepIndex);
506 aStep->setStamp(aStampIndex);
507 int aNumElements = isWholePart ? aXaoField->countElements() : aTables->rows();
508 int aNumComps = aTables->columns();
509 std::set<int> aFilledIDs; // to fill the rest by defaults
510 // omit default values first row
511 for(int aRow = isWholePart ? 0 : 1; aRow < aNumElements; aRow++) {
512 for(int aCol = 0; aCol < aNumComps; aCol++) {
515 // element index actually is the ID of the selection
516 AttributeSelectionPtr aSelection = aSelectionList->value(aRow - 1);
517 int aReferenceID = GeomAlgoAPI_CompoundBuilder::id(aShape, aSelection->value());
518 if (aReferenceID == 0) // selected value does not found in the exported shape
521 std::string aReferenceString = XAO::XaoUtils::intToString(aReferenceID);
522 anElementID = aXao.getGeometry()->
523 getElementIndexByReference(aFieldDimension, aReferenceString);
526 ModelAPI_AttributeTables::Value aVal = aTables->value(
527 isWholePart ? 0 : aRow, aCol, aStepIndex);
528 std::string aStrVal = valToString(aVal, aTables->type());
529 aStep->setStringValue(isWholePart ? aRow : anElementID, aCol, aStrVal);
530 aFilledIDs.insert(anElementID);
533 if (!isWholePart) { // fill the rest values by default ones
534 XAO::GeometricElementList::iterator allElem =
535 aXao.getGeometry()->begin(aFieldDimension);
536 for(; allElem != aXao.getGeometry()->end(aFieldDimension); allElem++) {
537 if (aFilledIDs.find(allElem->first) != aFilledIDs.end())
539 for(int aCol = 0; aCol < aNumComps; aCol++) {
541 ModelAPI_AttributeTables::Value aVal = aTables->value(0, aCol, aStepIndex);
542 std::string aStrVal = valToString(aVal, aTables->type());
543 aStep->setStringValue(allElem->first, aCol, aStrVal);
548 } catch (XAO::XAO_Exception& e) {
550 std::string msg = "An error occurred while exporting field " +
551 Locale::Convert::toString(aResultField->data()->name());
555 msg += "=> skipping this field from XAO export.";
556 Events_InfoMessage("ExportFeature", msg, this).send();
557 aXao.removeField(aXaoField);
564 XAOExport(theFileName, &aXao, anError);
566 if (!anError.empty()) {
567 setError("An error occurred while exporting " + theFileName + ": " + anError);
572 } catch (XAO::XAO_Exception& e) {
573 std::string anError = e.what();
574 setError("An error occurred while exporting " + theFileName + ": " + anError);
580 bool ExchangePlugin_ExportFeature::isMacro() const
582 if (!data().get() || !data()->isValid())
584 ExchangePlugin_ExportFeature* aThis = ((ExchangePlugin_ExportFeature*)(this));
585 AttributeStringPtr aFormatAttr = aThis->string(FILE_FORMAT_ID());
586 std::string aFormat(aFormatAttr.get() ? aFormatAttr->value() : "");
588 if (aFormat.empty()) { // get default format for the extension
589 AttributeStringPtr aFilePathAttr = aThis->string(FILE_PATH_ID());
590 std::string aFilePath = aFilePathAttr->value();
591 if (!aFilePath.empty()) {
592 std::string anExtension = GeomAlgoAPI_Tools::File_Tools::extension(aFilePath);
593 aFormat = anExtension;
597 if (aFormat == "XAO") { // on export to GEOM the selection attribute is filled - this is
598 // an exceptional case where export to XAO feature must be kept
599 AttributeSelectionListPtr aList = aThis->selectionList(XAO_SELECTION_LIST_ID());
600 return !aList->isInitialized() || aList->size() == 0;