- importFunctionPointer fp = (importFunctionPointer) GetProc(anImportLib, "Import");
- // Perform the import
- TCollection_AsciiString anError;
- TDF_Label anUnknownLabel = TDF_Label();
- TopoDS_Shape aShape = fp(aFileName,
- aFormatName,
- anError,
- anUnknownLabel);
- // Check if shape is valid
- if ( aShape.IsNull() ) {
- const static std::string aShapeError =
- "An error occurred while importing " + theFileName + ": " + anError.ToCString();
- setError(aShapeError);
- return false;
- }
- //
- // Pass the results into the model
- std::string anObjectName = aPath.Name().ToCString();
- data()->setName(anObjectName);
- std::shared_ptr<ModelAPI_ResultBody> aResultBody = document()->createBody(data());
- std::shared_ptr<GeomAPI_Shape> aGeomShape(new GeomAPI_Shape);
- aGeomShape->setImpl(new TopoDS_Shape(aShape));
-
- //LoadNamingDS of the imported shape
- loadNamingDS(aGeomShape, aResultBody);
-
- setResult(aResultBody);
-
- return true;
+ }
+
+ // Pass the results into the model
+ std::string anObjectName = GeomAlgoAPI_Tools::File_Tools::name(theFileName);
+ data()->setName(anObjectName);
+ std::shared_ptr<ModelAPI_ResultBody> aResultBody = document()->createBody(data());
+
+ //LoadNamingDS of the imported shape
+ loadNamingDS(aGeomShape, aResultBody);
+
+ setResult(aResultBody);
+
+ if (aXao.get()) {
+ XAO::Geometry* aXaoGeometry = aXao->getGeometry();
+
+ // Creates group results
+ for (int aGroupIndex = 0; aGroupIndex < aXao->countGroups(); ++aGroupIndex) {
+ XAO::Group* aXaoGroup = aXao->getGroup(aGroupIndex);
+
+ std::shared_ptr<ModelAPI_Feature> aGroupFeature = document()->addFeature("Group", false);
+ if (aGroupFeature) {
+ if (!aXaoGroup->getName().empty())
+ aGroupFeature->data()->setName(aXaoGroup->getName());
+ AttributeSelectionListPtr aSelectionList = aGroupFeature->selectionList("group_list");
+ aSelectionList->setSelectionType(XAO::XaoUtils::dimensionToString(aXaoGroup->getDimension()));
+
+ for (int anElementIndex = 0; anElementIndex < aXaoGroup->count(); ++anElementIndex) {
+ aSelectionList->append(aResultBody, GeomShapePtr());
+ int anElementID = aXaoGroup->get(anElementIndex);
+ std::string aReferenceString =
+ aXaoGeometry->getElementReference(aXaoGroup->getDimension(), anElementID);
+ int aReferenceID = XAO::XaoUtils::stringToInt(aReferenceString);
+ aSelectionList->value(anElementIndex)->setId(aReferenceID);
+ }
+
+ document()->setCurrentFeature(aGroupFeature, true);
+ }
+ }
+ }
+
+ return true;