Commit 30b7a9c6 authored by John Tourtellott's avatar John Tourtellott

Use smtk.io.MeshExport2DM to write mesh file out

Save the "material id" parameter name in scope variable
Requires Rob's smtk:smtk_mesh_export_2dm3dm
parent f4ded9bd
......@@ -151,9 +151,16 @@ def ExportCMB(spec):
print 'Categories:', sorted(list(scope.categories))
# Write mesh file
mesh_filename = scope.output_filebase + '.2dm'
mesh_path = os.path.join(scope.output_directory, mesh_filename)
print 'TODO Write mesh data to', mesh_path
if scope.mesh_collection is None:
print 'WARNING: No mesh collection; cannot write .2dm file'
else:
mesh_filename = scope.output_filebase + '.2dm'
mesh_path = os.path.join(scope.output_directory, mesh_filename)
print 'Writing mesh data to', mesh_path
mesh_writer = smtk.io.MeshExport2DM()
status = mesh_writer.write( \
scope.mesh_collection, scope.model, scope.matid_property_name, mesh_path)
print 'mesh write returned status', status
# Open output file and start exporting content
completed = False
......
......@@ -127,16 +127,20 @@ def init_scope(spec):
# Assign unique ids to all model cells
# (although only *required* for face entities)
next_id = assign_model_entity_ids(scope.model, 0, 'id', 1)
next_id = assign_model_entity_ids(scope.model, 1, 'id', next_id)
next_id = assign_model_entity_ids(scope.model, 2, 'id', next_id)
matid = 'id'
next_id = assign_model_entity_ids(scope.model, 0, matid, 1)
next_id = assign_model_entity_ids(scope.model, 1, matid, next_id)
next_id = assign_model_entity_ids(scope.model, 2, matid, next_id)
scope.matid_property_name = matid
scope.mesh_collection = None
mesh_manager = scope.model.meshes()
mesh_collections = mesh_manager.collectionsWithAssociations()
if len(mesh_collections) == 1:
scope.mesh_collection = mesh_collections[0]
scope.mesh_points = scope.mesh_collection.points()
# Get mesh points - only from 2D entities since that's what gets
# written to the .2dm file
scope.mesh_points = scope.mesh_collection.cells(smtk.mesh.Dims2).points()
#print 'Using meshCollection', scope.mesh_collection
else:
print 'WARNING: expecting 1 mesh, instead there are', len(mesh_collections)
......
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