Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
David Thompson
SMTK
Commits
f164badc
Commit
f164badc
authored
Dec 02, 2015
by
Yumin Yuan
Browse files
More methods for writing JSON meshes and collections
parent
8c6f59df
Changes
4
Hide whitespace changes
Inline
Side-by-side
smtk/io/ExportJSON.cxx
View file @
f164badc
...
...
@@ -624,7 +624,7 @@ int ExportJSON::forOperatorResult(OperatorResult res, cJSON* entRec)
if
(
collectionIds
.
size
()
>
0
)
{
cJSON
*
mesh_records
=
cJSON_CreateObject
();
ExportJSON
::
forMesh
e
s
(
mesh_records
,
collectionIds
,
meshMgr
);
ExportJSON
::
forMesh
Collection
s
(
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 EntityRef
s.
/**\brief Serialize
input mesh Collection
s.
*
* 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
::
forMesh
e
s
(
int
ExportJSON
::
forMesh
Collection
s
(
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
{
...
...
smtk/io/ExportJSON.h
View file @
f164badc
...
...
@@ -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
,
...
...
smtk/io/ExportJSON.txx
View file @
f164badc
...
...
@@ -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.
...
...
smtk/typesystem.xml
View file @
f164badc
...
...
@@ -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&'"
/>
<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*'"
/>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment