33 #include <Inventor/nodes/SoNode.h>
36 #include <MemoryX/interface/components/CommonStorageInterface.h>
37 #include <MemoryX/interface/components/PriorKnowledgeInterface.h>
50 #include <VirtualRobot/ManipulationObject.h>
51 #include <VirtualRobot/Visualization/CoinVisualization/CoinVisualizationFactory.h>
57 const memoryx::PriorKnowledgeInterfacePrx& priorKnowledgePrx)
59 this->priorKnowledgePrx = priorKnowledgePrx;
60 classesSegmentPrx = this->priorKnowledgePrx->getObjectClassesSegment();
61 databasePrx = this->priorKnowledgePrx->getCommonStorage();
67 catch (
const armarx::LocalException&)
76 std::unique_lock lock(mutexEntities);
77 this->classesSegmentPrx = other.classesSegmentPrx;
78 this->databasePrx = other.databasePrx;
79 this->memoryXController = other.memoryXController;
80 this->priorKnowledgePrx = other.priorKnowledgePrx;
81 this->fileManager = other.fileManager;
88 std::vector<std::string>
91 std::unique_lock lock(mutexEntities);
92 return classesSegmentPrx->getReadCollectionsNS();
95 std::vector<memoryx::ObjectClassPtr>
97 const std::string& collection)
const
99 std::vector<memoryx::ObjectClassPtr> classPtr;
100 std::unique_lock lock(mutexEntities);
104 memoryx::CollectionInterfacePrx collectionInterface =
105 this->databasePrx->requestCollection(collection);
108 memoryx::EntityIdList ids = collectionInterface->findAllIds();
110 for (memoryx::EntityIdList::const_iterator it = ids.begin(); it != ids.end(); ++it)
114 const memoryx::EntityBasePtr entity = classesSegmentPrx->getEntityById(*it);
119 classPtr.push_back(objClass);
123 catch (
const memoryx::DBNotSpecifiedException&)
134 const std::string& collection)
const
136 std::unique_lock lock(mutexEntities);
137 std::vector<memoryx::ObjectClassPtr> objectClasses = this->getAllObjectClassesPtr(collection);
139 if (!objectClasses.empty())
145 if (ptr->getName() == className)
158 const bool& collisionModel)
const
160 std::unique_lock lock(mutexEntities);
166 VirtualRobot::VisualizationNodePtr visNode;
167 bool hasModel =
true;
171 VirtualRobot::CollisionModelPtr collisionModel = simoxWrapper->getCollisionModel();
179 visNode = collisionModel->getVisualization();
184 visNode = simoxWrapper->getVisualization();
192 return VirtualRobot::CoinVisualizationFactory::getCoinVisualization(visNode);
195 std::map<std::string, std::string>
199 std::unique_lock lock(mutexEntities);
200 std::map<std::string, std::string> allAttributes;
204 return allAttributes;
207 memoryx::NameList attributeNames = objectClass->getAttributeNames();
212 for (memoryx::NameList::const_iterator it = attributeNames.begin(); it != attributeNames.end();
215 memoryx::EntityAttributeBasePtr attrValue = objectClass->getAttribute(*it);
216 armarx::VariantPtr attributeValue = armarx::VariantPtr::dynamicCast(attrValue->getValue());
218 if (attributeValue && (attributeValue->getOutputValueOnly() !=
""))
220 if (*it ==
"ManipulationFile")
222 allAttributes.insert(std::pair<std::string, std::string>(
223 *it, simoxWrapper->getManipulationObjectFileName()));
225 else if (*it ==
"IvFile" || *it ==
"IvFileCollision" || *it ==
"texFiles")
230 std::string maniPath = simoxWrapper->getManipulationObjectFileName();
233 const memoryx::GridFileInterfacePrx prx =
234 databasePrx->getFileProxyById(mongoPtr->dbName, mongoPtr->docId);
238 << objectClass->getName() <<
VAROUT(mongoPtr->dbName)
239 <<
VAROUT(mongoPtr->docId);
240 allAttributes.insert(std::pair<std::string, std::string>(*it,
""));
244 std::string ivFilePath =
245 maniPath.substr(0, maniPath.rfind(
"/") + 1) + prx->getFilename();
247 allAttributes.insert(std::pair<std::string, std::string>(*it, ivFilePath));
249 catch (
const armarx::InvalidTypeException&)
252 << objectClass->getName();
253 allAttributes.insert(std::pair<std::string, std::string>(*it,
""));
256 else if (*it ==
"featureFile")
259 objectClass->addWrapper(
261 allAttributes.insert(std::pair<std::string, std::string>(
262 *it, texturedRecognitionWrapper->getFeatureFile()));
266 allAttributes.insert(
267 std::pair<std::string, std::string>(*it, attributeValue->getOutputValueOnly()));
272 allAttributes.insert(std::pair<std::string, std::string>(*it,
""));
276 return allAttributes;
283 std::unique_lock lock(mutexEntities);
285 memoryx::NameList collectionNames = this->getCollectionNames();
286 std::map<memoryx::ObjectClassPtr, std::string> possibleObjectClasses;
287 std::string className = objectInstance->getMostProbableClass();
289 for (std::vector<std::string>::const_iterator it = collectionNames.begin();
290 it != collectionNames.end();
297 possibleObjectClasses.insert(std::pair<memoryx::ObjectClassPtr, std::string>(ptr, *it));
301 if (possibleObjectClasses.size() > 1)
306 return possibleObjectClasses.begin()->second;
308 else if (possibleObjectClasses.size() == 1)
310 return possibleObjectClasses.begin()->second;