Commit a6b91650 authored by Antonio El Khoury's avatar Antonio El Khoury
Browse files

Define method that loads a path from a kxml path file.

parent e1c0c527
......@@ -269,6 +269,9 @@ namespace hpp {
/// \brief Parsing a file
ktStatus parseFile(const std::string& inFileName);
/// \brief Load a path from file.
ktStatus loadPathFromFile (const std::string& fileName);
/// @}
/// \name Initialization
......
......@@ -46,6 +46,7 @@
#include "KineoWorks2/kwsJoint.h"
#include "kprParserXML/kprParserManager.h"
#include <kprParserXML/KineoParserXML.h>
#include "KineoModel/kppModelTree.h"
#include "KineoModel/kppDeviceNode.h"
#include "KineoModel/kppGeometryNode.h"
......@@ -866,5 +867,49 @@ namespace hpp {
hppDout(info, "Everything is fine ");
return KD_OK ;
}
ktStatus Planner::loadPathFromFile (const std::string& fileName)
{
CkprParserManagerShPtr parserManager
= CkprParserManager::defaultManager();
CkppDocumentShPtr document
= CkppDocument::create (parserManager->moduleManager ());
CkppComponentFactoryRegistryShPtr registry
= document->componentFactoryRegistry ();
CkprParserXMLSceneShPtr parserXMLScene
= parserManager->createXMLSceneParser ();
// Load path from file and try to link it to device component.
CkppPathComponentShPtr pathComponent;
for (unsigned int rank = 0; rank < getNbHppProblems(); ++rank)
{
if (KD_OK != parserXMLScene->loadPathFromFile (fileName,
robotIthProblem(rank),
registry,
pathComponent))
{
hppDout(notice, "Could not load path for problem " << rank);
return KD_ERROR;
}
else
{
if (!pathComponent)
{
hppDout(error, "Null pointer to path component.");
return KD_ERROR;
}
if (KD_ERROR
== addPath (rank,
CkwsPath::createCopy (pathComponent->kwsPath ())))
{
hppDout (error, "Could not add path in problem " << rank);
return KD_ERROR;
}
}
}
return KD_OK;
}
} // namespace core
} // namespace namespace hpp
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment