1 // Copyright (C) 2014-2023 CEA, EDF
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_STLExport.h>
38 #include <GeomAlgoAPI_Tools.h>
39 #include <GeomAlgoAPI_XAOExport.h>
41 #include <GeomAPI_Shape.h>
42 #include <GeomAPI_ShapeExplorer.h>
43 #include <GeomAPI_Trsf.h>
45 #include <Locale_Convert.h>
47 #include <ModelAPI_AttributeSelectionList.h>
48 #include <ModelAPI_AttributeString.h>
49 #include <ModelAPI_AttributeStringArray.h>
50 #include <ModelAPI_AttributeIntArray.h>
51 #include <ModelAPI_AttributeTables.h>
52 #include <ModelAPI_AttributeDouble.h>
53 #include <ModelAPI_AttributeBoolean.h>
54 #include <ModelAPI_Data.h>
55 #include <ModelAPI_Document.h>
56 #include <ModelAPI_Object.h>
57 #include <ModelAPI_ResultBody.h>
58 #include <ModelAPI_ResultPart.h>
59 #include <ModelAPI_ResultGroup.h>
60 #include <ModelAPI_ResultField.h>
61 #include <ModelAPI_Session.h>
62 #include <ModelAPI_Validator.h>
63 #include <ModelAPI_Tools.h>
65 #include <Events_InfoMessage.h>
67 #include <XAO_Group.hxx>
68 #include <XAO_Field.hxx>
69 #include <XAO_Xao.hxx>
70 #include <XAO_Geometry.hxx>
72 #include <ExchangePlugin_Tools.h>
74 ExchangePlugin_ExportFeature::ExchangePlugin_ExportFeature()
78 ExchangePlugin_ExportFeature::~ExchangePlugin_ExportFeature()
80 // TODO Auto-generated destructor stub
84 * Request for initialization of data model of the feature: adding all attributes
86 void ExchangePlugin_ExportFeature::initAttributes()
88 data()->addAttribute(ExchangePlugin_ExportFeature::EXPORT_TYPE_ID(),
89 ModelAPI_AttributeString::typeId());
90 data()->addAttribute(ExchangePlugin_ExportFeature::FILE_PATH_ID(),
91 ModelAPI_AttributeString::typeId());
92 data()->addAttribute(ExchangePlugin_ExportFeature::XAO_FILE_PATH_ID(),
93 ModelAPI_AttributeString::typeId());
94 data()->addAttribute(ExchangePlugin_ExportFeature::FILE_FORMAT_ID(),
95 ModelAPI_AttributeString::typeId());
96 data()->addAttribute(ExchangePlugin_ExportFeature::SELECTION_LIST_ID(),
97 ModelAPI_AttributeSelectionList::typeId());
98 data()->addAttribute(ExchangePlugin_ExportFeature::XAO_AUTHOR_ID(),
99 ModelAPI_AttributeString::typeId());
100 data()->addAttribute(ExchangePlugin_ExportFeature::XAO_GEOMETRY_NAME_ID(),
101 ModelAPI_AttributeString::typeId());
102 data()->addAttribute(ExchangePlugin_ExportFeature::XAO_SELECTION_LIST_ID(),
103 ModelAPI_AttributeSelectionList::typeId());
104 data()->addAttribute(ExchangePlugin_ExportFeature::STL_FILE_PATH_ID(),
105 ModelAPI_AttributeString::typeId());
106 data()->addAttribute(ExchangePlugin_ExportFeature::STL_OBJECT_SELECTED(),
107 ModelAPI_AttributeSelection::typeId());
108 data()->addAttribute(ExchangePlugin_ExportFeature::STL_DEFLECTION_TYPE(),
109 ModelAPI_AttributeString::typeId());
110 data()->addAttribute(ExchangePlugin_ExportFeature::STL_RELATIVE(),
111 ModelAPI_AttributeDouble::typeId());
113 double defelection = Config_PropManager::real("Visualization", "body_deflection");
114 real(ExchangePlugin_ExportFeature::STL_RELATIVE())->setValue(defelection);
116 data()->addAttribute(ExchangePlugin_ExportFeature::STL_ABSOLUTE(),
117 ModelAPI_AttributeDouble::typeId());
118 data()->addAttribute(ExchangePlugin_ExportFeature::STL_FILE_TYPE(),
119 ModelAPI_AttributeString::typeId());
121 // export to memory buffer (implemented for XAO format only)
122 data()->addAttribute(ExchangePlugin_ExportFeature::MEMORY_BUFFER_ID(),
123 ModelAPI_AttributeString::typeId());
125 ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(),
126 ExchangePlugin_ExportFeature::XAO_FILE_PATH_ID());
127 ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(),
128 ExchangePlugin_ExportFeature::STL_FILE_PATH_ID());
129 ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(),
130 ExchangePlugin_ExportFeature::XAO_AUTHOR_ID());
131 ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(),
132 ExchangePlugin_ExportFeature::XAO_GEOMETRY_NAME_ID());
133 ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(),
134 ExchangePlugin_ExportFeature::XAO_SELECTION_LIST_ID());
135 ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(),
136 ExchangePlugin_ExportFeature::MEMORY_BUFFER_ID());
138 // to support previous version of document, move the selection list
139 // if the type of export operation is XAO
140 AttributeStringPtr aTypeAttr = string(EXPORT_TYPE_ID());
141 if (aTypeAttr->isInitialized() &&
142 (aTypeAttr->value() == "XAO" || aTypeAttr->value() == "XAOMem")) {
143 bool aWasBlocked = data()->blockSendAttributeUpdated(true, false);
144 AttributeSelectionListPtr aSelList = selectionList(SELECTION_LIST_ID());
145 AttributeSelectionListPtr aXAOSelList = selectionList(XAO_SELECTION_LIST_ID());
146 if (aSelList->size() > 0 && aXAOSelList->size() == 0)
147 aSelList->copyTo(aXAOSelList);
149 data()->blockSendAttributeUpdated(aWasBlocked, false);
153 void ExchangePlugin_ExportFeature::attributeChanged(const std::string& theID)
155 if (theID == XAO_FILE_PATH_ID()) {
156 string(ExchangePlugin_ExportFeature::FILE_PATH_ID())->setValue(
157 string(ExchangePlugin_ExportFeature::XAO_FILE_PATH_ID())->value());
159 else if (theID == STL_FILE_PATH_ID()) {
160 string(ExchangePlugin_ExportFeature::FILE_PATH_ID())->setValue(
161 string(ExchangePlugin_ExportFeature::STL_FILE_PATH_ID())->value());
166 * Computes or recomputes the results
168 void ExchangePlugin_ExportFeature::execute()
170 AttributeStringPtr aFormatAttr =
171 this->string(ExchangePlugin_ExportFeature::FILE_FORMAT_ID());
172 std::string aFormat = aFormatAttr->value();
174 bool isMemoryExport = false;
175 AttributeStringPtr aTypeAttr = string(EXPORT_TYPE_ID());
176 if (aTypeAttr->isInitialized() && aTypeAttr->value() == "XAOMem")
177 isMemoryExport = true;
179 AttributeStringPtr aFilePathAttr =
180 this->string(ExchangePlugin_ExportFeature::FILE_PATH_ID());
181 std::string aFilePath = aFilePathAttr->value();
182 if (aFilePath.empty() && !isMemoryExport)
185 exportFile(aFilePath, aFormat, isMemoryExport);
188 void ExchangePlugin_ExportFeature::exportFile(const std::string& theFileName,
189 const std::string& theFormat,
190 const bool isMemoryExport)
192 std::string aFormatName = theFormat;
194 if (aFormatName.empty()) { // get default format for the extension
195 if (isMemoryExport) return;
198 std::string anExtension = GeomAlgoAPI_Tools::File_Tools::extension(theFileName);
199 if (anExtension == "BREP" || anExtension == "BRP") {
200 aFormatName = "BREP";
201 } else if (anExtension == "STEP" || anExtension == "STP") {
202 aFormatName = "STEP";
203 } else if (anExtension == "IGES" || anExtension == "IGS") {
204 aFormatName = "IGES-5.1";
206 aFormatName = anExtension;
210 if (aFormatName == "XAO") {
211 exportXAO(theFileName, isMemoryExport);
213 } else if (aFormatName == "STL") {
214 exportSTL(theFileName);
218 // make shape for export from selected shapes
219 AttributeSelectionListPtr aSelectionListAttr =
220 this->selectionList(ExchangePlugin_ExportFeature::SELECTION_LIST_ID());
221 std::list<GeomShapePtr> aShapes;
222 std::list<ResultPtr> aContexts;
223 for (int i = 0, aSize = aSelectionListAttr->size(); i < aSize; ++i) {
224 AttributeSelectionPtr anAttrSelection = aSelectionListAttr->value(i);
226 /// do not export pictures
227 ResultPtr aBodyContext =
228 std::dynamic_pointer_cast<ModelAPI_Result>(anAttrSelection->context());
229 if (aBodyContext.get() && aBodyContext->hasTexture())
232 std::shared_ptr<GeomAPI_Shape> aCurShape = anAttrSelection->value();
233 if (aCurShape.get() == NULL)
234 aCurShape = anAttrSelection->context()->shape();
235 if (aCurShape.get() != NULL)
237 aShapes.push_back(aCurShape);
238 aContexts.push_back(anAttrSelection->context());
242 // Store compound if we have more than one shape.
243 std::shared_ptr<GeomAPI_Shape> aShape =
244 aShapes.size() == 1 ? aShapes.front() : GeomAlgoAPI_CompoundBuilder::compound(aShapes);
246 // Perform the export
248 bool aResult = false;
249 if (aFormatName == "BREP") {
250 aResult = BREPExport(theFileName, aFormatName, aShape, anError);
251 } else if (aFormatName == "STEP") {
252 aResult = STEPExport(theFileName, aShapes, aContexts, anError);
253 } else if (aFormatName.substr(0, 4) == "IGES") {
254 aResult = IGESExport(theFileName, aFormatName, aShape, anError);
256 anError = "Unsupported format: " + aFormatName;
259 if (!aResult || !anError.empty()) {
260 setError("An error occurred while exporting " + theFileName + ": " + anError);
265 /// Returns XAO string by the value from the table
266 static std::string valToString(const ModelAPI_AttributeTables::Value& theVal,
267 const ModelAPI_AttributeTables::ValueType& theType)
269 std::ostringstream aStr; // the resulting string value
271 case ModelAPI_AttributeTables::BOOLEAN:
272 aStr<<(theVal.myBool ? "true" : "false");
274 case ModelAPI_AttributeTables::INTEGER:
277 case ModelAPI_AttributeTables::DOUBLE:
278 aStr<<theVal.myDouble;
280 case ModelAPI_AttributeTables::STRING:
287 void ExchangePlugin_ExportFeature::exportSTL(const std::string& theFileName)
290 AttributeSelectionPtr aSelection = selection(STL_OBJECT_SELECTED());
291 GeomShapePtr aShape = aSelection->value();
293 aShape = aSelection->context()->shape();
296 // Get relative value and percent flag.
298 bool anIsRelative = false;
299 bool anIsASCII = false;
301 if (string(STL_DEFLECTION_TYPE())->value() == STL_DEFLECTION_TYPE_RELATIVE()) {
302 aValue = real(STL_RELATIVE())->value();
305 aValue = real(STL_ABSOLUTE())->value();
308 if (string(STL_FILE_TYPE())->value() == STL_FILE_TYPE_ASCII()) {
311 // Perform the export
313 bool aResult = false;
315 aResult = STLExport(theFileName,
322 if (!aResult || !anError.empty()) {
323 setError("An error occurred while exporting " + theFileName + ": " + anError);
329 void ExchangePlugin_ExportFeature::exportXAO(const std::string& theFileName,
330 const bool isMemoryExport)
339 std::string anAuthor = string(ExchangePlugin_ExportFeature::XAO_AUTHOR_ID())->value();
340 aXao.setAuthor(anAuthor);
342 // make shape for export from all results
343 std::list<GeomShapePtr> aShapes;
344 std::list<ResultPtr> aResults;
345 std::list<DocumentPtr> aDocuments; /// documents of Parts selected and used in export
346 std::map<DocumentPtr, GeomTrsfPtr> aDocTrsf; /// translation of the part
348 bool anExCludedIsImage = false;
349 AttributeSelectionListPtr aSelection = selectionList(XAO_SELECTION_LIST_ID());
350 bool aIsSelection = aSelection->isInitialized() && aSelection->size() > 0;
351 if (aIsSelection) { // a mode for export to geom result by result
352 for (int a = 0; a < aSelection->size(); a++) {
353 AttributeSelectionPtr anAttr = aSelection->value(a);
354 ResultPtr aBodyContext =
355 std::dynamic_pointer_cast<ModelAPI_Result>(anAttr->context());
356 if (aBodyContext.get() && !aBodyContext->isDisabled() && aBodyContext->shape().get()) {
357 /// do not export pictures
358 if (aBodyContext->hasTexture()){
359 anExCludedIsImage = true;
362 aResults.push_back(aBodyContext);
363 GeomShapePtr aShape = anAttr->value();
365 aShape = aBodyContext->shape();
366 aShapes.push_back(aShape);
367 if (aBodyContext->groupName() == ModelAPI_ResultPart::group()) {
368 ResultPartPtr aResPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(aBodyContext);
369 DocumentPtr aPartDoc = aResPart->partDoc();
370 if (!aPartDoc.get() || !aPartDoc->isOpened()) { // document is not accessible
371 std::string msg = "Can not export XAO for not loaded part";
372 Events_InfoMessage("ExportFeature", msg, this).send();
375 aDocuments.push_back(aPartDoc);
376 aDocTrsf[aPartDoc] = aResPart->summaryTrsf();
382 int aBodyCount = document()->size(ModelAPI_ResultBody::group());
383 for (int aBodyIndex = 0; aBodyIndex < aBodyCount; ++aBodyIndex) {
384 ResultBodyPtr aResultBody =
385 std::dynamic_pointer_cast<ModelAPI_ResultBody>(
386 document()->object(ModelAPI_ResultBody::group(), aBodyIndex));
387 if (!aResultBody.get())
389 aShapes.push_back(aResultBody->shape());
390 aResults.push_back(aResultBody);
393 if (aShapes.empty()) {
394 if(!anExCludedIsImage)
395 setError("No shapes to export");
400 GeomShapePtr aShape = (aShapes.size() == 1)
402 : GeomAlgoAPI_CompoundBuilder::compound(aShapes);
404 SetShapeToXAO(aShape, &aXao, anError);
406 if (!anError.empty()) {
407 setError("An error occurred while exporting " + theFileName + ": " + anError);
412 std::string aGeometryName = string(ExchangePlugin_ExportFeature::XAO_GEOMETRY_NAME_ID())->value();
413 if (aGeometryName.empty() && aResults.size() == 1) {
414 // get the name from the first result
415 ResultPtr aResultBody = *aResults.begin();
416 aGeometryName = Locale::Convert::toString(aResultBody->data()->name());
417 if (isMemoryExport) {
419 string(ExchangePlugin_ExportFeature::XAO_GEOMETRY_NAME_ID())->setValue(aGeometryName);
421 //data()->setName(Locale::Convert::toWString(aGeometryName));
425 aXao.getGeometry()->setName(aGeometryName);
427 std::set<ResultPtr> allResultsCashed; // cash to speed up searching in all results selected
429 // iterate all documents used
430 if (aDocuments.empty())
431 aDocuments.push_back(document());
432 std::list<DocumentPtr>::iterator aDoc = aDocuments.begin();
433 for(; aDoc != aDocuments.end(); aDoc++) {
435 int aGroupCount = (*aDoc)->size(ModelAPI_ResultGroup::group());
436 for (int aGroupIndex = 0; aGroupIndex < aGroupCount; ++aGroupIndex) {
437 ResultGroupPtr aResultGroup = std::dynamic_pointer_cast<ModelAPI_ResultGroup>(
438 (*aDoc)->object(ModelAPI_ResultGroup::group(), aGroupIndex));
439 if (!aResultGroup.get() || !aResultGroup->shape().get())
442 FeaturePtr aGroupFeature = (*aDoc)->feature(aResultGroup);
444 AttributeSelectionListPtr aSelectionList =
445 aGroupFeature->selectionList("group_list");
446 if (!ModelAPI_Tools::isInResults(aSelectionList,
448 allResultsCashed))// skip group not used in result
451 // conversion of dimension
452 std::string aSelectionType = aSelectionList->selectionType();
453 GeomAPI_Shape::ShapeType aSelType = GeomAPI_Shape::shapeTypeByStr(aSelectionType);
454 std::string aDimensionString =
455 ExchangePlugin_Tools::selectionType2xaoDimension(aSelectionType);
456 XAO::Dimension aGroupDimension = XAO::XaoUtils::stringToDimension(aDimensionString);
458 XAO::Group* aXaoGroup = aXao.addGroup(aGroupDimension,
459 Locale::Convert::toString(aResultGroup->data()->name()));
462 GeomAPI_ShapeExplorer aGroupResExplorer(aResultGroup->shape(), aSelType);
463 for(; aGroupResExplorer.more(); aGroupResExplorer.next()) {
464 GeomShapePtr aGroupShape = aGroupResExplorer.current();
465 if (aDocTrsf.find(*aDoc) != aDocTrsf.end())
466 aGroupShape->move(aDocTrsf[*aDoc]);
467 int aReferenceID = GeomAlgoAPI_CompoundBuilder::id(aShape, aGroupShape);
468 if (aReferenceID == 0) // selected value does not found in the exported shape
470 std::string aReferenceString = XAO::XaoUtils::intToString(aReferenceID);
472 aXao.getGeometry()->getElementIndexByReference(aGroupDimension, aReferenceString);
473 aXaoGroup->add(anElementID);
475 } catch (XAO::XAO_Exception& e) {
477 std::string msg = "An error occurred while exporting group " +
478 Locale::Convert::toString(aResultGroup->data()->name());
482 msg += "=> skipping this group from XAO export.";
483 Events_InfoMessage("ExportFeature", msg, this).send();
484 aXao.removeGroup(aXaoGroup);
490 int aFieldCount = (*aDoc)->size(ModelAPI_ResultField::group());
491 for (int aFieldIndex = 0; aFieldIndex < aFieldCount; ++aFieldIndex) {
492 ResultFieldPtr aResultField = std::dynamic_pointer_cast<ModelAPI_ResultField>(
493 (*aDoc)->object(ModelAPI_ResultField::group(), aFieldIndex));
495 FeaturePtr aFieldFeature = (*aDoc)->feature(aResultField);
497 AttributeSelectionListPtr aSelectionList =
498 aFieldFeature->selectionList("selected");
499 std::string aSelectionType = aSelectionList->selectionType();
500 bool isWholePart = aSelectionType == "part";
501 // skip field not used in results
503 !ModelAPI_Tools::isInResults(aSelectionList, aResults, allResultsCashed))
506 // conversion of dimension
507 std::string aDimensionString =
508 ExchangePlugin_Tools::selectionType2xaoDimension(aSelectionType);
509 XAO::Dimension aFieldDimension = XAO::XaoUtils::stringToDimension(aDimensionString);
510 // get tables and their type
511 std::shared_ptr<ModelAPI_AttributeTables> aTables = aFieldFeature->tables("values");
512 std::string aTypeString = ExchangePlugin_Tools::valuesType2xaoType(aTables->type());
513 XAO::Type aFieldType = XAO::XaoUtils::stringToFieldType(aTypeString);
515 XAO::Field* aXaoField = aXao.addField(aFieldType, aFieldDimension, aTables->columns(),
516 Locale::Convert::toString(aResultField->data()->name()));
520 // set components names
521 AttributeStringArrayPtr aComponents = aFieldFeature->stringArray("components_names");
522 for(int aComp = 0; aComp < aComponents->size(); aComp++) {
523 std::string aName = aComponents->value(aComp);
524 aXaoField->setComponentName(aComp, aName);
527 AttributeIntArrayPtr aStamps = aFieldFeature->intArray("stamps");
528 for (int aStepIndex = 0; aStepIndex < aTables->tables(); aStepIndex++) {
529 XAO::Step* aStep = aXaoField->addNewStep(aStepIndex + 1);
530 aStep->setStep(aStepIndex + 1);
531 int aStampIndex = aStamps->value(aStepIndex);
532 aStep->setStamp(aStampIndex);
533 int aNumElements = isWholePart ? aXaoField->countElements() : aTables->rows();
534 int aNumComps = aTables->columns();
535 std::set<int> aFilledIDs; // to fill the rest by defaults
536 // omit default values first row
537 for(int aRow = isWholePart ? 0 : 1; aRow < aNumElements; aRow++) {
538 for(int aCol = 0; aCol < aNumComps; aCol++) {
541 // element index actually is the ID of the selection
542 AttributeSelectionPtr aSel = aSelectionList->value(aRow - 1);
543 int aReferenceID = GeomAlgoAPI_CompoundBuilder::id(aShape, aSel->value());
544 if (aReferenceID == 0) // selected value does not found in the exported shape
547 std::string aReferenceString = XAO::XaoUtils::intToString(aReferenceID);
548 anElementID = aXao.getGeometry()->
549 getElementIndexByReference(aFieldDimension, aReferenceString);
552 ModelAPI_AttributeTables::Value aVal = aTables->value(
553 isWholePart ? 0 : aRow, aCol, aStepIndex);
554 std::string aStrVal = valToString(aVal, aTables->type());
555 aStep->setStringValue(isWholePart ? aRow : anElementID, aCol, aStrVal);
556 aFilledIDs.insert(anElementID);
559 if (!isWholePart) { // fill the rest values by default ones
560 XAO::GeometricElementList::iterator allElem =
561 aXao.getGeometry()->begin(aFieldDimension);
562 for(; allElem != aXao.getGeometry()->end(aFieldDimension); allElem++) {
563 if (aFilledIDs.find(allElem->first) != aFilledIDs.end())
565 for(int aCol = 0; aCol < aNumComps; aCol++) {
567 ModelAPI_AttributeTables::Value aVal = aTables->value(0, aCol, aStepIndex);
568 std::string aStrVal = valToString(aVal, aTables->type());
569 aStep->setStringValue(allElem->first, aCol, aStrVal);
574 } catch (XAO::XAO_Exception& e) {
576 std::string msg = "An error occurred while exporting field " +
577 Locale::Convert::toString(aResultField->data()->name());
581 msg += "=> skipping this field from XAO export.";
582 Events_InfoMessage("ExportFeature", msg, this).send();
583 aXao.removeField(aXaoField);
590 if (isMemoryExport) {
591 string(ExchangePlugin_ExportFeature::MEMORY_BUFFER_ID())->setValue(XAOExportMem(&aXao, anError));
594 XAOExport(theFileName, &aXao, anError);
597 if (!anError.empty()) {
598 setError("An error occurred while exporting " + theFileName + ": " + anError);
603 } catch (XAO::XAO_Exception& e) {
604 std::string anError = e.what();
605 setError("An error occurred while exporting " + theFileName + ": " + anError);
611 bool ExchangePlugin_ExportFeature::isMacro() const
613 if (!data().get() || !data()->isValid())
615 ExchangePlugin_ExportFeature* aThis = ((ExchangePlugin_ExportFeature*)(this));
616 AttributeStringPtr aFormatAttr = aThis->string(FILE_FORMAT_ID());
617 std::string aFormat(aFormatAttr.get() ? aFormatAttr->value() : "");
619 if (aFormat.empty()) { // get default format for the extension
620 AttributeStringPtr aFilePathAttr = aThis->string(FILE_PATH_ID());
621 std::string aFilePath = aFilePathAttr->value();
622 if (!aFilePath.empty()) {
623 std::string anExtension = GeomAlgoAPI_Tools::File_Tools::extension(aFilePath);
624 aFormat = anExtension;
628 if (aFormat == "XAO") { // on export to GEOM the selection attribute is filled - this is
629 // an exceptional case where export to XAO feature must be kept
630 AttributeSelectionListPtr aList = aThis->selectionList(XAO_SELECTION_LIST_ID());
631 return !aList->isInitialized() || aList->size() == 0;