- // Test loaded plugin for existence of valid "Import" function:
- importFunctionPointer fp = (importFunctionPointer) GetProc(anImportLib, "Import");
- if (!fp) {
- std::string aFunctionError = "No valid \"Import\" function was found in the " + aLibName;
- Events_Error::send(aFunctionError, this);
-#ifdef _DEBUG
- std::cerr << aFunctionError << std::endl;
-#endif
- UnLoadLib(anImportLib)
- return NULL;
+
+ // 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);
+ }
+ }