MeshKit  1.0
example_tfimapping.cpp
Go to the documentation of this file.
00001 
00020 #include "meshkit/MKCore.hpp"
00021 #include "meshkit/TFIMapping.hpp"
00022 #include "meshkit/SizingFunction.hpp"
00023 #include "meshkit/ModelEnt.hpp"
00024 #include "meshkit/Matrix.hpp"
00025 #include "meshkit/EdgeMesher.hpp"
00026 
00027 using namespace MeshKit;
00028 
00029 const int NUM_INTERVALS = 3; // we want 3 intervals on each side (for no reason)
00030 const int INTERVAL_SIZE = -1; // in sizing functions, -1 means not specified
00031 const bool save_mesh = true;
00032 
00033 #ifdef HAVE_ACIS
00034 string extension = ".sat";
00035 #elif HAVE_OCC
00036 string extension = ".stp";
00037 #endif
00038 
00039 int main(int argc, char **argv)
00040 {
00041   MKCore * mk;         // handle for the instance of MeshKit
00042   MEntVector curves;   // handle for the curve we need to retrieve, is a vector
00043   MEntVector surfaces; // handle for the surface we need to retrieve, is a vector
00044   EdgeMesher * em;     // handle for a MeshOp that helps fulfill a pre-req for TFIMapping
00045   TFIMapping * tfi;    // handle for our TFIMapping MeshOp
00046 
00047 // Prepare MK
00048   mk = new MKCore(); // Start up MK
00049   mk->load_geometry( (string(MESH_DIR) + "/" + string("rectangle") + extension).c_str() ); // Load the geometry
00050 
00051 // Prepare EdgeMesher (TFIMapping requires that 1 edge be meshed)
00052   mk->get_entities_by_dimension(1, curves); // get all 1D entities and store into "curves"
00053   curves.resize(1); // We need to mesh one curve for TFI to suceed
00054   em = (EdgeMesher*) mk->construct_meshop("EdgeMesher", curves); // create an EdgeMesher to mesh 1 side
00055 
00056 // Prepare TFIMapping
00057   mk->get_entities_by_dimension(2, surfaces); // get all 2D entities and store into "surfaces" (we only have 1)
00058   tfi = (TFIMapping*) mk->construct_meshop("TFIMapping", surfaces); // create the TFIMapping MeshOp instance, will operate on the entities stored in surfaces
00059   mk->get_graph().addArc(em->get_node(), tfi->get_node()); // TFIMapping depends on EdgeMesher (tfi needs a meshed edge)
00060 
00061 // Specify Sizes
00062   SizingFunction sf(mk, NUM_INTERVALS, INTERVAL_SIZE); // create a sizing function
00063   surfaces[0]->sizing_function_index(sf.core_index()); // apply the same sizing function to them
00064 
00065 // Execute
00066   mk->setup(); // calls setup_this() on all nodes in the graph
00067   mk->execute(); // calls execute_this() on all nodes in the graph
00068 
00069 // Save
00070   if (save_mesh)
00071     mk->save_mesh("tfimapping_out.exo");
00072 
00073   return 0;
00074 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines