1 // Copyright (C) 2014-2024 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_IndexedMapOfShape.h>
42 #include <GeomAPI_Shape.h>
43 #include <GeomAPI_ShapeExplorer.h>
44 #include <GeomAPI_Trsf.h>
46 #include <Locale_Convert.h>
48 #include <ModelAPI_AttributeSelectionList.h>
49 #include <ModelAPI_AttributeString.h>
50 #include <ModelAPI_AttributeStringArray.h>
51 #include <ModelAPI_AttributeIntArray.h>
52 #include <ModelAPI_AttributeTables.h>
53 #include <ModelAPI_AttributeDouble.h>
54 #include <ModelAPI_AttributeBoolean.h>
55 #include <ModelAPI_Data.h>
56 #include <ModelAPI_Document.h>
57 #include <ModelAPI_Object.h>
58 #include <ModelAPI_ResultBody.h>
59 #include <ModelAPI_ResultPart.h>
60 #include <ModelAPI_ResultGroup.h>
61 #include <ModelAPI_ResultField.h>
62 #include <ModelAPI_Session.h>
63 #include <ModelAPI_Validator.h>
64 #include <ModelAPI_Tools.h>
66 #include <Events_InfoMessage.h>
68 #include <XAO_Group.hxx>
69 #include <XAO_Field.hxx>
70 #include <XAO_Xao.hxx>
71 #include <XAO_Geometry.hxx>
73 #include <ExchangePlugin_Tools.h>
75 ExchangePlugin_ExportFeature::ExchangePlugin_ExportFeature()
79 ExchangePlugin_ExportFeature::~ExchangePlugin_ExportFeature()
81 // TODO Auto-generated destructor stub
85 * Request for initialization of data model of the feature: adding all attributes
87 void ExchangePlugin_ExportFeature::initAttributes()
89 data()->addAttribute(ExchangePlugin_ExportFeature::EXPORT_TYPE_ID(),
90 ModelAPI_AttributeString::typeId());
91 data()->addAttribute(ExchangePlugin_ExportFeature::FILE_PATH_ID(),
92 ModelAPI_AttributeString::typeId());
93 data()->addAttribute(ExchangePlugin_ExportFeature::XAO_FILE_PATH_ID(),
94 ModelAPI_AttributeString::typeId());
95 data()->addAttribute(ExchangePlugin_ExportFeature::FILE_FORMAT_ID(),
96 ModelAPI_AttributeString::typeId());
97 data()->addAttribute(ExchangePlugin_ExportFeature::SELECTION_LIST_ID(),
98 ModelAPI_AttributeSelectionList::typeId());
99 data()->addAttribute(ExchangePlugin_ExportFeature::XAO_AUTHOR_ID(),
100 ModelAPI_AttributeString::typeId());
101 data()->addAttribute(ExchangePlugin_ExportFeature::XAO_GEOMETRY_NAME_ID(),
102 ModelAPI_AttributeString::typeId());
103 data()->addAttribute(ExchangePlugin_ExportFeature::XAO_SELECTION_LIST_ID(),
104 ModelAPI_AttributeSelectionList::typeId());
105 data()->addAttribute(ExchangePlugin_ExportFeature::STL_FILE_PATH_ID(),
106 ModelAPI_AttributeString::typeId());
107 data()->addAttribute(ExchangePlugin_ExportFeature::STL_OBJECT_SELECTED(),
108 ModelAPI_AttributeSelection::typeId());
109 data()->addAttribute(ExchangePlugin_ExportFeature::STL_DEFLECTION_TYPE(),
110 ModelAPI_AttributeString::typeId());
111 data()->addAttribute(ExchangePlugin_ExportFeature::STL_RELATIVE(),
112 ModelAPI_AttributeDouble::typeId());
114 double defelection = Config_PropManager::real("Visualization", "body_deflection");
115 real(ExchangePlugin_ExportFeature::STL_RELATIVE())->setValue(defelection);
117 data()->addAttribute(ExchangePlugin_ExportFeature::STL_ABSOLUTE(),
118 ModelAPI_AttributeDouble::typeId());
119 data()->addAttribute(ExchangePlugin_ExportFeature::STL_FILE_TYPE(),
120 ModelAPI_AttributeString::typeId());
122 // export to memory buffer (implemented for XAO format only)
123 data()->addAttribute(ExchangePlugin_ExportFeature::MEMORY_BUFFER_ID(),
124 ModelAPI_AttributeString::typeId());
126 ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(),
127 ExchangePlugin_ExportFeature::XAO_FILE_PATH_ID());
128 ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(),
129 ExchangePlugin_ExportFeature::STL_FILE_PATH_ID());
130 ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(),
131 ExchangePlugin_ExportFeature::XAO_AUTHOR_ID());
132 ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(),
133 ExchangePlugin_ExportFeature::XAO_GEOMETRY_NAME_ID());
134 ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(),
135 ExchangePlugin_ExportFeature::XAO_SELECTION_LIST_ID());
136 ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(),
137 ExchangePlugin_ExportFeature::MEMORY_BUFFER_ID());
139 // to support previous version of document, move the selection list
140 // if the type of export operation is XAO
141 AttributeStringPtr aTypeAttr = string(EXPORT_TYPE_ID());
142 if (aTypeAttr->isInitialized() &&
143 (aTypeAttr->value() == "XAO" || aTypeAttr->value() == "XAOMem")) {
144 bool aWasBlocked = data()->blockSendAttributeUpdated(true, false);
145 AttributeSelectionListPtr aSelList = selectionList(SELECTION_LIST_ID());
146 AttributeSelectionListPtr aXAOSelList = selectionList(XAO_SELECTION_LIST_ID());
147 if (aSelList->size() > 0 && aXAOSelList->size() == 0)
148 aSelList->copyTo(aXAOSelList);
150 data()->blockSendAttributeUpdated(aWasBlocked, false);
154 void ExchangePlugin_ExportFeature::attributeChanged(const std::string& theID)
156 if (theID == XAO_FILE_PATH_ID()) {
157 string(ExchangePlugin_ExportFeature::FILE_PATH_ID())->setValue(
158 string(ExchangePlugin_ExportFeature::XAO_FILE_PATH_ID())->value());
160 else if (theID == STL_FILE_PATH_ID()) {
161 string(ExchangePlugin_ExportFeature::FILE_PATH_ID())->setValue(
162 string(ExchangePlugin_ExportFeature::STL_FILE_PATH_ID())->value());
167 * Computes or recomputes the results
169 void ExchangePlugin_ExportFeature::execute()
171 AttributeStringPtr aFormatAttr =
172 this->string(ExchangePlugin_ExportFeature::FILE_FORMAT_ID());
173 std::string aFormat = aFormatAttr->value();
175 bool isMemoryExport = false;
176 AttributeStringPtr aTypeAttr = string(EXPORT_TYPE_ID());
177 if (aTypeAttr->isInitialized() && aTypeAttr->value() == "XAOMem")
178 isMemoryExport = true;
180 AttributeStringPtr aFilePathAttr =
181 this->string(ExchangePlugin_ExportFeature::FILE_PATH_ID());
182 std::string aFilePath = aFilePathAttr->value();
183 if (aFilePath.empty() && !isMemoryExport)
186 exportFile(aFilePath, aFormat, isMemoryExport);
189 void ExchangePlugin_ExportFeature::exportFile(const std::string& theFileName,
190 const std::string& theFormat,
191 const bool isMemoryExport)
193 std::string aFormatName = theFormat;
195 if (aFormatName.empty()) { // get default format for the extension
196 if (isMemoryExport) return;
199 std::string anExtension = GeomAlgoAPI_Tools::File_Tools::extension(theFileName);
200 if (anExtension == "BREP" || anExtension == "BRP") {
201 aFormatName = "BREP";
202 } else if (anExtension == "STEP" || anExtension == "STP") {
203 aFormatName = "STEP";
204 } else if (anExtension == "IGES" || anExtension == "IGS") {
205 aFormatName = "IGES-5.1";
207 aFormatName = anExtension;
211 if (aFormatName == "XAO") {
212 exportXAO(theFileName, isMemoryExport);
214 } else if (aFormatName == "STL") {
215 exportSTL(theFileName);
219 // make shape for export from selected shapes
220 AttributeSelectionListPtr aSelectionListAttr =
221 this->selectionList(ExchangePlugin_ExportFeature::SELECTION_LIST_ID());
222 std::list<GeomShapePtr> aShapes;
223 std::list<ResultPtr> aContexts;
224 for (int i = 0, aSize = aSelectionListAttr->size(); i < aSize; ++i) {
225 AttributeSelectionPtr anAttrSelection = aSelectionListAttr->value(i);
227 /// do not export pictures
228 ResultPtr aBodyContext =
229 std::dynamic_pointer_cast<ModelAPI_Result>(anAttrSelection->context());
230 if (aBodyContext.get() && aBodyContext->hasTexture())
233 std::shared_ptr<GeomAPI_Shape> aCurShape = anAttrSelection->value();
234 if (aCurShape.get() == NULL)
235 aCurShape = anAttrSelection->context()->shape();
236 if (aCurShape.get() != NULL)
238 aShapes.push_back(aCurShape);
239 aContexts.push_back(anAttrSelection->context());
243 // Store compound if we have more than one shape.
244 std::shared_ptr<GeomAPI_Shape> aShape =
245 aShapes.size() == 1 ? aShapes.front() : GeomAlgoAPI_CompoundBuilder::compound(aShapes);
247 // Perform the export
249 bool aResult = false;
250 if (aFormatName == "BREP") {
251 aResult = BREPExport(theFileName, aFormatName, aShape, anError);
252 } else if (aFormatName == "STEP") {
253 aResult = STEPExport(theFileName, aShapes, aContexts, anError);
254 } else if (aFormatName.substr(0, 4) == "IGES") {
255 aResult = IGESExport(theFileName, aFormatName, aShape, anError);
257 anError = "Unsupported format: " + aFormatName;
260 if (!aResult || !anError.empty()) {
261 setError("An error occurred while exporting " + theFileName + ": " + anError);
266 /// Returns XAO string by the value from the table
267 static std::string valToString(const ModelAPI_AttributeTables::Value& theVal,
268 const ModelAPI_AttributeTables::ValueType& theType)
270 std::ostringstream aStr; // the resulting string value
272 case ModelAPI_AttributeTables::BOOLEAN:
273 aStr<<(theVal.myBool ? "true" : "false");
275 case ModelAPI_AttributeTables::INTEGER:
278 case ModelAPI_AttributeTables::DOUBLE:
279 aStr<<theVal.myDouble;
281 case ModelAPI_AttributeTables::STRING:
288 void ExchangePlugin_ExportFeature::exportSTL(const std::string& theFileName)
291 AttributeSelectionPtr aSelection = selection(STL_OBJECT_SELECTED());
292 GeomShapePtr aShape = aSelection->value();
294 aShape = aSelection->context()->shape();
297 // Get relative value and percent flag.
299 bool anIsRelative = false;
300 bool anIsASCII = false;
302 if (string(STL_DEFLECTION_TYPE())->value() == STL_DEFLECTION_TYPE_RELATIVE()) {
303 aValue = real(STL_RELATIVE())->value();
306 aValue = real(STL_ABSOLUTE())->value();
309 if (string(STL_FILE_TYPE())->value() == STL_FILE_TYPE_ASCII()) {
312 // Perform the export
314 bool aResult = false;
316 aResult = STLExport(theFileName,
323 if (!aResult || !anError.empty()) {
324 setError("An error occurred while exporting " + theFileName + ": " + anError);
330 void ExchangePlugin_ExportFeature::exportXAO(const std::string& theFileName,
331 const bool isMemoryExport)
340 std::string anAuthor = string(ExchangePlugin_ExportFeature::XAO_AUTHOR_ID())->value();
341 aXao.setAuthor(anAuthor);
343 // make shape for export from all results
344 std::list<GeomShapePtr> aShapes;
345 std::list<ResultPtr> aResults;
346 std::list<DocumentPtr> aDocuments; /// documents of Parts selected and used in export
347 std::map<DocumentPtr, GeomTrsfPtr> aDocTrsf; /// translation of the part
349 bool anExCludedIsImage = false;
350 AttributeSelectionListPtr aSelection = selectionList(XAO_SELECTION_LIST_ID());
351 bool aIsSelection = aSelection->isInitialized() && aSelection->size() > 0;
352 if (aIsSelection) { // a mode for export to geom result by result
353 for (int a = 0; a < aSelection->size(); a++) {
354 AttributeSelectionPtr anAttr = aSelection->value(a);
355 ResultPtr aBodyContext =
356 std::dynamic_pointer_cast<ModelAPI_Result>(anAttr->context());
357 if (aBodyContext.get() && !aBodyContext->isDisabled() && aBodyContext->shape().get()) {
358 /// do not export pictures
359 if (aBodyContext->hasTexture()){
360 anExCludedIsImage = true;
363 aResults.push_back(aBodyContext);
364 GeomShapePtr aShape = anAttr->value();
366 aShape = aBodyContext->shape();
367 aShapes.push_back(aShape);
368 if (aBodyContext->groupName() == ModelAPI_ResultPart::group()) {
369 ResultPartPtr aResPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(aBodyContext);
370 DocumentPtr aPartDoc = aResPart->partDoc();
371 if (!aPartDoc.get() || !aPartDoc->isOpened()) { // document is not accessible
372 std::string msg = "Can not export XAO for not loaded part";
373 Events_InfoMessage("ExportFeature", msg, this).send();
376 aDocuments.push_back(aPartDoc);
377 aDocTrsf[aPartDoc] = aResPart->summaryTrsf();
383 int aBodyCount = document()->size(ModelAPI_ResultBody::group());
384 for (int aBodyIndex = 0; aBodyIndex < aBodyCount; ++aBodyIndex) {
385 ResultBodyPtr aResultBody =
386 std::dynamic_pointer_cast<ModelAPI_ResultBody>(
387 document()->object(ModelAPI_ResultBody::group(), aBodyIndex));
388 if (!aResultBody.get())
390 aShapes.push_back(aResultBody->shape());
391 aResults.push_back(aResultBody);
394 if (aShapes.empty()) {
395 if(!anExCludedIsImage)
396 setError("No shapes to export");
401 GeomShapePtr aShape = (aShapes.size() == 1)
403 : GeomAlgoAPI_CompoundBuilder::compound(aShapes);
405 SetShapeToXAO(aShape, &aXao, anError);
407 if (!anError.empty()) {
408 setError("An error occurred while exporting " + theFileName + ": " + anError);
413 std::string aGeometryName = string(ExchangePlugin_ExportFeature::XAO_GEOMETRY_NAME_ID())->value();
414 if (aGeometryName.empty() && aResults.size() == 1) {
415 // get the name from the first result
416 ResultPtr aResultBody = *aResults.begin();
417 aGeometryName = Locale::Convert::toString(aResultBody->data()->name());
418 if (isMemoryExport) {
420 string(ExchangePlugin_ExportFeature::XAO_GEOMETRY_NAME_ID())->setValue(aGeometryName);
422 //data()->setName(Locale::Convert::toWString(aGeometryName));
426 aXao.getGeometry()->setName(aGeometryName);
428 std::set<ResultPtr> allResultsCashed; // cash to speed up searching in all results selected
430 // [bos #38360] [CEA] improve performances of exportXAO and PublishToStudy
431 GeomAPI_IndexedMapOfShape aSubShapesMap;
432 bool isSubShapesMap = false; // we will init it only if required (for performance reason)
434 // iterate all documents used
435 if (aDocuments.empty())
436 aDocuments.push_back(document());
437 std::list<DocumentPtr>::iterator aDoc = aDocuments.begin();
438 for(; aDoc != aDocuments.end(); aDoc++) {
440 int aGroupCount = (*aDoc)->size(ModelAPI_ResultGroup::group());
441 for (int aGroupIndex = 0; aGroupIndex < aGroupCount; ++aGroupIndex) {
442 ResultGroupPtr aResultGroup = std::dynamic_pointer_cast<ModelAPI_ResultGroup>(
443 (*aDoc)->object(ModelAPI_ResultGroup::group(), aGroupIndex));
444 if (!aResultGroup.get() || !aResultGroup->shape().get())
447 FeaturePtr aGroupFeature = (*aDoc)->feature(aResultGroup);
449 AttributeSelectionListPtr aSelectionList =
450 aGroupFeature->selectionList("group_list");
451 if (!ModelAPI_Tools::isInResults(aSelectionList,
453 allResultsCashed))// skip group not used in result
456 // conversion of dimension
457 std::string aSelectionType = aSelectionList->selectionType();
458 GeomAPI_Shape::ShapeType aSelType = GeomAPI_Shape::shapeTypeByStr(aSelectionType);
459 std::string aDimensionString =
460 ExchangePlugin_Tools::selectionType2xaoDimension(aSelectionType);
461 XAO::Dimension aGroupDimension = XAO::XaoUtils::stringToDimension(aDimensionString);
463 XAO::Group* aXaoGroup = aXao.addGroup(aGroupDimension,
464 Locale::Convert::toString(aResultGroup->data()->name()));
467 GeomAPI_ShapeExplorer aGroupResExplorer(aResultGroup->shape(), aSelType);
468 for(; aGroupResExplorer.more(); aGroupResExplorer.next()) {
469 GeomShapePtr aGroupShape = aGroupResExplorer.current();
470 if (aDocTrsf.find(*aDoc) != aDocTrsf.end())
471 aGroupShape->move(aDocTrsf[*aDoc]);
473 if (!isSubShapesMap) {
474 aSubShapesMap.MapShapes(aShape);
475 isSubShapesMap = true;
477 int aReferenceID = aSubShapesMap.FindIndexEqualLocations(aGroupShape);
478 if (aReferenceID == 0) // selected value does not found in the exported shape
480 std::string aReferenceString = XAO::XaoUtils::intToString(aReferenceID);
482 aXao.getGeometry()->getElementIndexByReference(aGroupDimension, aReferenceString);
483 aXaoGroup->add(anElementID);
485 } catch (XAO::XAO_Exception& e) {
487 std::string msg = "An error occurred while exporting group " +
488 Locale::Convert::toString(aResultGroup->data()->name());
492 msg += "=> skipping this group from XAO export.";
493 Events_InfoMessage("ExportFeature", msg, this).send();
494 aXao.removeGroup(aXaoGroup);
500 int aFieldCount = (*aDoc)->size(ModelAPI_ResultField::group());
501 for (int aFieldIndex = 0; aFieldIndex < aFieldCount; ++aFieldIndex) {
502 ResultFieldPtr aResultField = std::dynamic_pointer_cast<ModelAPI_ResultField>(
503 (*aDoc)->object(ModelAPI_ResultField::group(), aFieldIndex));
505 FeaturePtr aFieldFeature = (*aDoc)->feature(aResultField);
507 AttributeSelectionListPtr aSelectionList =
508 aFieldFeature->selectionList("selected");
509 std::string aSelectionType = aSelectionList->selectionType();
510 bool isWholePart = aSelectionType == "part";
511 // skip field not used in results
513 !ModelAPI_Tools::isInResults(aSelectionList, aResults, allResultsCashed))
516 // conversion of dimension
517 std::string aDimensionString =
518 ExchangePlugin_Tools::selectionType2xaoDimension(aSelectionType);
519 XAO::Dimension aFieldDimension = XAO::XaoUtils::stringToDimension(aDimensionString);
520 // get tables and their type
521 std::shared_ptr<ModelAPI_AttributeTables> aTables = aFieldFeature->tables("values");
522 std::string aTypeString = ExchangePlugin_Tools::valuesType2xaoType(aTables->type());
523 XAO::Type aFieldType = XAO::XaoUtils::stringToFieldType(aTypeString);
525 XAO::Field* aXaoField = aXao.addField(aFieldType, aFieldDimension, aTables->columns(),
526 Locale::Convert::toString(aResultField->data()->name()));
530 // set components names
531 AttributeStringArrayPtr aComponents = aFieldFeature->stringArray("components_names");
532 for(int aComp = 0; aComp < aComponents->size(); aComp++) {
533 std::string aName = aComponents->value(aComp);
534 aXaoField->setComponentName(aComp, aName);
537 AttributeIntArrayPtr aStamps = aFieldFeature->intArray("stamps");
538 for (int aStepIndex = 0; aStepIndex < aTables->tables(); aStepIndex++) {
539 XAO::Step* aStep = aXaoField->addNewStep(aStepIndex + 1);
540 aStep->setStep(aStepIndex + 1);
541 int aStampIndex = aStamps->value(aStepIndex);
542 aStep->setStamp(aStampIndex);
543 int aNumElements = isWholePart ? aXaoField->countElements() : aTables->rows();
544 int aNumComps = aTables->columns();
545 std::set<int> aFilledIDs; // to fill the rest by defaults
546 // omit default values first row
547 for(int aRow = isWholePart ? 0 : 1; aRow < aNumElements; aRow++) {
548 for(int aCol = 0; aCol < aNumComps; aCol++) {
551 // element index actually is the ID of the selection
552 AttributeSelectionPtr aSel = aSelectionList->value(aRow - 1);
553 if (!isSubShapesMap) {
554 aSubShapesMap.MapShapes(aShape);
555 isSubShapesMap = true;
557 int aReferenceID = aSubShapesMap.FindIndexEqualLocations(aSel->value());
558 if (aReferenceID == 0) // selected value does not found in the exported shape
561 std::string aReferenceString = XAO::XaoUtils::intToString(aReferenceID);
562 anElementID = aXao.getGeometry()->
563 getElementIndexByReference(aFieldDimension, aReferenceString);
566 ModelAPI_AttributeTables::Value aVal = aTables->value(
567 isWholePart ? 0 : aRow, aCol, aStepIndex);
568 std::string aStrVal = valToString(aVal, aTables->type());
569 aStep->setStringValue(isWholePart ? aRow : anElementID, aCol, aStrVal);
570 aFilledIDs.insert(anElementID);
573 if (!isWholePart) { // fill the rest values by default ones
574 XAO::GeometricElementList::iterator allElem =
575 aXao.getGeometry()->begin(aFieldDimension);
576 for(; allElem != aXao.getGeometry()->end(aFieldDimension); allElem++) {
577 if (aFilledIDs.find(allElem->first) != aFilledIDs.end())
579 for(int aCol = 0; aCol < aNumComps; aCol++) {
581 ModelAPI_AttributeTables::Value aVal = aTables->value(0, aCol, aStepIndex);
582 std::string aStrVal = valToString(aVal, aTables->type());
583 aStep->setStringValue(allElem->first, aCol, aStrVal);
588 } catch (XAO::XAO_Exception& e) {
590 std::string msg = "An error occurred while exporting field " +
591 Locale::Convert::toString(aResultField->data()->name());
595 msg += "=> skipping this field from XAO export.";
596 Events_InfoMessage("ExportFeature", msg, this).send();
597 aXao.removeField(aXaoField);
604 if (isMemoryExport) {
605 string(ExchangePlugin_ExportFeature::MEMORY_BUFFER_ID())->setValue(XAOExportMem(&aXao, anError));
608 XAOExport(theFileName, &aXao, anError);
611 if (!anError.empty()) {
612 setError("An error occurred while exporting " + theFileName + ": " + anError);
617 } catch (XAO::XAO_Exception& e) {
618 std::string anError = e.what();
619 setError("An error occurred while exporting " + theFileName + ": " + anError);
625 bool ExchangePlugin_ExportFeature::isMacro() const
627 if (!data().get() || !data()->isValid())
629 ExchangePlugin_ExportFeature* aThis = ((ExchangePlugin_ExportFeature*)(this));
630 AttributeStringPtr aFormatAttr = aThis->string(FILE_FORMAT_ID());
631 std::string aFormat(aFormatAttr.get() ? aFormatAttr->value() : "");
633 if (aFormat.empty()) { // get default format for the extension
634 AttributeStringPtr aFilePathAttr = aThis->string(FILE_PATH_ID());
635 std::string aFilePath = aFilePathAttr->value();
636 if (!aFilePath.empty()) {
637 std::string anExtension = GeomAlgoAPI_Tools::File_Tools::extension(aFilePath);
638 aFormat = anExtension;
642 if (aFormat == "XAO") { // on export to GEOM the selection attribute is filled - this is
643 // an exceptional case where export to XAO feature must be kept
644 AttributeSelectionListPtr aList = aThis->selectionList(XAO_SELECTION_LIST_ID());
645 return !aList->isInitialized() || aList->size() == 0;