MeshKit  1.0
example_edgemesher.cpp
Go to the documentation of this file.
00001 
00018 #include "meshkit/MKCore.hpp"
00019 #include "meshkit/EdgeMesher.hpp"
00020 #include "meshkit/SizingFunction.hpp"
00021 #include "meshkit/ModelEnt.hpp"
00022 #include "meshkit/Matrix.hpp"
00023 
00024 using namespace MeshKit;
00025 
00026 const int NUM_INTERVALS = 10; // on our curve, we want 10 intervals
00027 const int INTERVAL_SIZE = -1; // in sizing functions, -1 means not specified
00028 const bool save_mesh = true;
00029 
00030 #ifdef HAVE_ACIS
00031 std::string extension = ".sat";
00032 #elif HAVE_OCC
00033 std::string extension = ".stp";
00034 #endif
00035 
00036 int main(int argc, char **argv) 
00037 {
00038   MKCore * mk;       // handle for the instance of MeshKit
00039   MEntVector curves; // handle for the curve we need to retrieve, is a vector
00040   EdgeMesher * em;   // handle for our MeshOp that we will create
00041 
00042 // Prepare MK
00043   mk = new MKCore();  // Start up MK
00044   mk->load_geometry( (string(MESH_DIR) + "/" + string("spline") + extension).c_str() ); // Load the geometry
00045 
00046 // Prepare EdgeMesher
00047   mk->get_entities_by_dimension(1, curves); // get all 1D entites and store into "curves" (we only have 1)
00048   em = (EdgeMesher*) mk->construct_meshop("EdgeMesher", curves); // create the EdgeMesher MeshOp instance, will operate on the entities stored in curves
00049   SizingFunction sf(mk, NUM_INTERVALS, INTERVAL_SIZE); // create a sizing function
00050   curves[0]->sizing_function_index(sf.core_index()); // and apply it to our curve (we know curves[0] is our curve, because we only have 1)
00051 
00052 // Execute
00053   mk->setup(); // calls setup_this() on all nodes in the graph
00054   mk->execute(); // calls execute_this() on all nodes in the graph
00055 
00056 // Save stuff
00057   if (save_mesh)
00058     mk->save_mesh("edgemesher_out.vtk"); // save the meshed file for the curve we just meshed
00059 
00060   return 0;
00061 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines