#include "AppUtil.hpp" #include "CGMApp.hpp" #include "GeometryQueryTool.hpp" #include "GeometryModifyTool.hpp" #include "CubitCompat.hpp" #include "CubitFacetData.hpp" #include "CubitPointData.hpp" #include "CubitQuadFacetData.hpp" #include "DLIList.hpp" #include "OCCModifyEngine.hpp" #include "Surface.hpp" #include "ShellSM.hpp" #include "Lump.hpp" #include "Body.hpp" #include "BodySM.hpp" #include "RefEntityFactory.hpp" #include "RefFace.hpp" #include "RefGroup.hpp" #include "RefVertex.hpp" #include "GroupingEntity.hpp" #include "SenseEntity.hpp" #include bool generateThingy( RefGroup* container, DLIList& model) { GeometryModifyTool* gmt = GeometryModifyTool::instance(OCCModifyEngine::instance()); CubitStatus stat; int i; Body* body = gmt->pyramid(1., 4, 1., 1., 0.); if (!body) return false; container->add_ref_entity(body); // Add first face of first shell does not help: //container->add_ref_entity(body->get_first_sense_entity_ptr()->get_basic_topology_entity_ptr()); model.append(body); // model.append(container); return true; } int main(int argc, char* argv[]) { if (argc < 2) { std::cout << "Usage:\n" << " " << argv[0] << " output_filename\n" << "where\n" << " output_filename is the path to a CGM facet model to write\n" ; return 1; } // Initialize CGM std::vector args(argv + 1, argv + argc); CGMApp::instance()->startup(args); RefGroup* container = RefEntityFactory::instance()->construct_RefGroup("Foobly"); DLIList model; //DLIList model; if (generateThingy(container, model)) { DLIList containedEnts; container->get_sub_entities(containedEnts); std::cout << "Container has " << containedEnts.size() << " entries\n"; int numExp; CubitString version; CubitStatus s = CubitCompat_export_solid_model(model, argv[1], "OCC", numExp, version, NULL); std::cout << "Wrote \"" << argv[1] << "\" (" << numExp << " entity, version \"" << version.c_str() << "\")\n"; DLIList allGroups; GeometryQueryTool::instance()->ref_groups(allGroups); std::cout << "There are now " << allGroups.size() << " groups\n"; int before = static_cast(allGroups.size()); // Now delete the entities and import the file to see // if the group was saved. std::cout << "Clearing geometry\n"; GeometryQueryTool::instance()->delete_geometry(); allGroups.clean_out(); GeometryQueryTool::instance()->ref_groups(allGroups); std::cout << "There are now " << allGroups.size() << " groups\n"; s = CubitCompat_import_solid_model(argv[1], "OCC", /* logfile_name = */ NULL, /* heal_step = */ CUBIT_TRUE, /* import_bodies = */ CUBIT_TRUE, /* import_surfaces = */ CUBIT_TRUE, /* import_curves = */ CUBIT_TRUE, /* import_vertices = */ CUBIT_TRUE, /* free_surfaces = */ CUBIT_TRUE, &model); if (s != CUBIT_SUCCESS) { std::cerr << "Could not import \"" << argv[1] << "\"\n"; return 1; } std::cout << "Imported geometry\n"; allGroups.clean_out(); GeometryQueryTool::instance()->ref_groups(allGroups); std::cout << "There are now " << allGroups.size() << " groups"; if (allGroups.size() != before) { std::cout << ", but there should have been " << before << "\n"; return 1; } std::cout << ", as expected.\n"; } return 0; }