MeshKit  1.0
example_extrudemesh.cpp
Go to the documentation of this file.
00001 
00017 #include "meshkit/MKCore.hpp"
00018 #include "meshkit/MeshOp.hpp"
00019 #include "meshkit/ExtrudeMesh.hpp"
00020 #include "meshkit/ModelEnt.hpp"
00021 
00022 using namespace MeshKit;
00023 
00024 
00025 #define DEFAULT_TEST_FILE "cube.cub"
00026 
00027 MKCore *mk;
00028 
00029 int main(int argc, char **argv)
00030 {
00031   mk = new MKCore();
00032   //input
00033   size_t nverts = 4;
00034   double coords[] = {
00035     0, 0, 0,
00036     1, 0, 0,
00037     1, 1, 0,
00038     0, 1, 0
00039   };
00040   iMesh_EntityTopology topo = iMesh_QUADRILATERAL;
00041 
00042   // working with imesh instance
00043   iMesh *mesh = mk->imesh_instance();
00044   std::vector<iMesh::EntityHandle> verts(nverts);
00045   iMesh::EntityHandle face;
00046   iMesh::EntitySetHandle set;
00047 
00048   mesh->createVtxArr(nverts, iBase_INTERLEAVED, coords, &verts[0]);
00049   mesh->createEnt(topo, &verts[0], nverts, face);
00050   mesh->createEntSet(true, set);
00051   mesh->addEntToSet(face, set);
00052 
00053   ModelEnt me(mk, iBase_EntitySetHandle(0), /*igeom instance*/0,
00054               (moab::EntityHandle)set);
00055   MEntVector selection;
00056   selection.push_back(&me);
00057 
00058   ExtrudeMesh *em = (ExtrudeMesh*) mk->construct_meshop("ExtrudeMesh",
00059                                                         selection);
00060   em->set_name("extrude_mesh");
00061 
00062   Vector<3> dx; dx[0] = 0; dx[1] = 0; dx[2] = 10;
00063   em->set_transform(Extrude::Translate(dx, 10));
00064   em->copy_faces(true);
00065 
00066   // put them in the graph
00067   mk->get_graph().addArc(mk->root_node()->get_node(), em->get_node());
00068   mk->get_graph().addArc(em->get_node(), mk->leaf_node()->get_node());
00069 
00070   em->copy_sets().add_set(set);
00071   em->extrude_sets().add_set(set);
00072 
00073   // mesh embedded boundary mesh, by calling execute
00074   mk->setup_and_execute();
00075   mk->save_mesh("out_em.exo");
00076   return 0;
00077 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines