Commit 3758f2f1 authored by Robert Maynard's avatar Robert Maynard Committed by Kitware Robot
Browse files

Merge topic 'allow_collections_to_delete_file_after_reading'


 MeshOperator now deletes any temporary mesh files that the worker generates.
Acked-by: Kitware Robot's avatarKitware Robot <>
Acked-by: default avatarYumin Yuan <>
Merge-request: !5
parents 1179ce75 73cb1310
......@@ -26,6 +26,12 @@
#include "smtk/io/ExportJSON.txx"
#include "smtk/io/ImportJSON.h"
//todo: remove this once remus supports automatic transfer of FileHandles
// and Destructive Read of FileHandles
//force to use filesystem version 3
#include <boost/filesystem.hpp>
//todo: remove this once remus Issue #183 has been resolved.
// #include <boost/date_time/posix_time/posix_time.hpp>
// #include <boost/thread/thread.hpp>
......@@ -148,15 +154,46 @@ OperatorResult MeshOperator::operateInternal()
//now fetch the latest results from the server
remus::proto::JobResult updatedModel = client.retrieveResults(job);
remus::proto::JobResult meshMetaData = client.retrieveResults(job);
//parse the job result as a json string
smtk::io::ImportJSON::intoModelManager(, this->manager());
//determine all existing collection
typedef std::map< smtk::common::UUID, smtk::mesh::CollectionPtr > CollectionStorage;
CollectionStorage existingCollections(this->manager()->collectionBegin(),
cJSON* root = cJSON_Parse(;
//parse the job result as json mesh data
cJSON* root = cJSON_Parse(;
smtk::io::ImportJSON::ofMeshesOfModel(root, this->manager());
//iterate over all collections looking for new collections. When we find
//a new mesh collection, we will delete the file that was used to generate
//that collection, as that file is meant to be temporary and only exist
//for data transfer back from the worker.
//This all should be removed, and instead remus should handle all this logic
for(smtk::mesh::Manager::const_iterator i = this->manager()->collectionBegin();
i != this->manager()->collectionEnd();
smtk::mesh::CollectionPtr collection = i->second;
smtk::mesh::UUID collectionUUID = i->first;
if( existingCollections.find(collectionUUID) == existingCollections.end())
{ //found a new collection
std::string location = collection->readLocation();
{ //delete the file if it exists
::boost::filesystem::path cpath( location );
::boost::filesystem::remove( cpath );
//mark all models and submodels as modified
smtk::model::Models allModels = models;
for(smtk::model::Models::const_iterator m = models.begin();
......@@ -192,6 +192,14 @@ void Collection::writeLocation(const std::string& n)
this->m_writeLocation = n;
void Collection::clearReadWriteLocations()
std::string Collection::interfaceName() const
......@@ -90,6 +90,11 @@ public:
void writeLocation(const std::string& path);
const std::string& writeLocation() const;
//clear both the read and write locations for the collection. This
//is generally done when de-serializing a collection and the read and write
//locations are going to be deleted by the calling code.
void clearReadWriteLocations();
//get a string the identifies the interface type of the collection
// valid types are:
// "moab"
Markdown is supported
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