Commit f164badc authored by Yumin Yuan's avatar Yumin Yuan
Browse files

More methods for writing JSON meshes and collections

parent 8c6f59df
......@@ -624,7 +624,7 @@ int ExportJSON::forOperatorResult(OperatorResult res, cJSON* entRec)
if(collectionIds.size() > 0)
{
cJSON* mesh_records = cJSON_CreateObject();
ExportJSON::forMeshes(mesh_records, collectionIds, meshMgr);
ExportJSON::forMeshCollections(mesh_records, collectionIds, meshMgr);
cJSON_AddItemToObject(entRec, "mesh_records", mesh_records);
}
}
......@@ -742,14 +742,14 @@ int ExportJSON::forManagerMeshes(
return status;
}
/**\brief Serialize all the smtk::mesh associated with given EntityRefs.
/**\brief Serialize input mesh Collections.
*
* This creates and populate an JSON Object "mesh_collections"
* and add it to the parent json node (\a pnode) with
* data required to recreate the smtk::mesh Collections
* associated with the given \a collectionIds.
* data required to recreate the mesh Collections
* associated with the given \a collectionIds of mesh manager (\a meshMgr)
*/
int ExportJSON::forMeshes(
int ExportJSON::forMeshCollections(
cJSON* pnode,
const smtk::common::UUIDs& collectionIds,
smtk::mesh::ManagerPtr meshMgr)
......@@ -776,6 +776,32 @@ int ExportJSON::forMeshes(
return status;
}
/**\brief Serialize all the mesh collections associated with given \a modelid.
*
* This creates and populate an JSON Object "mesh_collections"
* and add it to the parent json node (\a pnode) with
* all mesh collections associated with the given \a modelid.
*/
int ExportJSON::forModelMeshes(
const smtk::common::UUID& modelid,
cJSON* pnode,
smtk::model::ManagerPtr modelMgr)
{
if (!pnode || pnode->type != cJSON_Object)
{
return 0;
}
smtk::mesh::ManagerPtr meshMgr = modelMgr->meshes();
smtk::model::Model model(modelMgr, modelid);
if(!model.isValid() || !meshMgr)
{
return 0;
}
smtk::common::UUIDs cids = meshMgr->associatedCollectionIds(model);
return ExportJSON::forMeshCollections(pnode, cids, meshMgr);
}
namespace {
......
......@@ -103,12 +103,19 @@ public:
static int forSingleCollection(cJSON* mdesc,
smtk::mesh::CollectionPtr collection);
// Serialize all the smtk::mesh associated with given EntityRefs.
static int forMeshes(
// Serialize all the input mesh Collections in mesh manager \a meshMgr,
// given the mesh \a collectionIds.
static int forMeshCollections(
cJSON* pnode,
const smtk::common::UUIDs& collectionIds,
smtk::mesh::ManagerPtr meshMgr);
// Serialize all the smtk::mesh collections associated with given \a modelid.
static int forModelMeshes(
const smtk::common::UUID& modelid,
cJSON* pnode,
smtk::model::ManagerPtr modelMgr);
static int forLog(
cJSON* logrecordarray,
const smtk::io::Logger& log,
......
......@@ -54,8 +54,6 @@ int ExportJSON::forEntities(
}
if (sections & JSON_TESSELLATIONS)
status &= ExportJSON::forManagerTessellation(it->first, curChild, modelMgr);
if (sections & JSON_ANALYSISMESH)
status &= ExportJSON::forManagerAnalysis(it->first, curChild, modelMgr);
if (sections & JSON_PROPERTIES)
{
status &= ExportJSON::forManagerFloatProperties(it->first, curChild, modelMgr);
......@@ -63,7 +61,7 @@ int ExportJSON::forEntities(
status &= ExportJSON::forManagerIntegerProperties(it->first, curChild, modelMgr);
}
}
return 0;
return status;
}
/**\brief Populate the \a json node with the record(s) related to given \a entities.
......
......@@ -144,7 +144,8 @@
<suppress-warning text="skipping function 'smtk::io::ExportJSON::forOperator', unmatched parameter type 'cJSON*'"/>
<suppress-warning text="skipping function 'smtk::io::ExportJSON::forEntities', unmatched parameter type 'T const&amp;'"/>
<suppress-warning text="skipping function 'smtk::io::ExportJSON::forEntities', unmatched parameter type 'cJSON*'"/>
<suppress-warning text="skipping function 'smtk::io::ExportJSON::forMeshes', unmatched parameter type 'cJSON*'"/>
<suppress-warning text="skipping function 'smtk::io::ExportJSON::forMeshCollections', unmatched parameter type 'cJSON*'"/>
<suppress-warning text="skipping function 'smtk::io::ExportJSON::forModelMeshes', unmatched parameter type 'cJSON*'"/>
<suppress-warning text="skipping function 'smtk::io::ImportMesh::entireJSON', unmatched parameter type 'cJSON*'"/>
<suppress-warning text="skipping function 'smtk::io::ImportMesh::entireJSONToCollection', unmatched parameter type 'cJSON*'"/>
......
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