MeshKit  1.0
EdgeMesher.hpp
Go to the documentation of this file.
00001 //-----------------------------------C++-------------------------------------//
00002 // File: src/algs/EdgeMesher.hpp
00003 // Wednesday February 11 10:50 2011
00004 // Brief: EdgeMesher class definition: four schemes are provided: equal meshing,
00005 //        Bias Meshing, Dual Bias Meshing, Curvature-based meshing 
00006 //---------------------------------------------------------------------------//
00007 
00008 #ifndef MESHKIT_EDGE_MESHER_HPP
00009 #define MESHKIT_EDGE_MESHER_HPP
00010 
00011 #include <stdlib.h>
00012 #include <stdio.h>
00013 #include <assert.h>
00014 #include <string>
00015 #include <iostream>
00016 #include <fstream>
00017 #include <string.h>
00018 #include <limits.h>
00019 
00020 #include "meshkit/iGeom.hpp"
00021 #include <set>
00022 #include <vector>
00023 
00024 #include "meshkit/MeshScheme.hpp"
00025 
00026 namespace MeshKit
00027 {
00028 //===========================================================================//
00037 //===========================================================================//
00038 
00039 using namespace std;
00040 
00041 class EdgeMesher : public MeshScheme
00042 {
00043 public:
00044         //six schemes for edge meshing
00045         enum EdgeSchemeType {EQUAL=0, BIAS, DUAL, CURVATURE, VARIABLE, EQUIGNOMONIC};
00046 
00047         
00048 public:
00049         //construction function for edge mesher
00050         EdgeMesher(MKCore *mk_core, const MEntVector &me_vec);
00051 
00052         //set up the parameters for edge meshing, e.g. compute the number of intervals
00053         virtual void setup_this();
00054 
00055         //Generate the edge mesh
00056         virtual void execute_this();
00057 
00059        static const char* name() 
00060          { return "EdgeMesher"; }
00061 
00066        static bool can_mesh(iBase_EntityType dim)
00067           { return iBase_EDGE == dim; }
00068 
00075        static bool can_mesh(ModelEnt *me)
00076           { return canmesh_edge(me); }
00077 
00078 
00082        static const moab::EntityType* output_types();
00083 
00087        virtual const moab::EntityType* mesh_types_arr() const
00088          { return output_types(); }
00089 
00090   // set/get some options
00091   EdgeSchemeType get_edge_scheme() const;
00092   void set_edge_scheme(EdgeSchemeType scheme);
00093 
00094   // used in bias and dual meshing schemes
00095   void set_ratio(double q);
00096   double get_ratio();
00097         ~EdgeMesher();
00098         
00099 private:
00100 
00101         struct Point3D
00102         {
00103                 double px;
00104                 double py;
00105                 double pz;      
00106         };
00107 
00108         EdgeSchemeType schemeType;
00109         double ratio;
00110 
00111         //return x, y, z coordinates based on the parametric coordinate u on the edge
00112         Point3D getXYZCoords(ModelEnt *ent, double u) const;
00113         
00114         //return the parametrical coordinate based the starting parametric coordinate ustart and distance in physical space
00115         double getUCoord(ModelEnt *ent, double ustart, double dist, double uguess, double umin, double umax) const;
00116 
00117         //Create more nodes if there is a high curvature on the edge
00118         void DivideIntoMore(ModelEnt *ent, Point3D p0, Point3D pMid, Point3D p1, double u0, double u1, double uMid, int &index, vector<double> &nodes, vector<double> &URecord);
00119 
00120         //calculate the error between the line segments and the edge in the physical space
00121         bool ErrorCalculate(ModelEnt *ent, Point3D p0, Point3D p1, Point3D pMid);
00122 
00123         //Sort the nodes on the edge
00124         void RapidSorting(vector<double> &nodes, vector<double> &URecord, int left, int right);
00125         void QuickSorting(vector<double> &nodes, vector<double> &URecord, int count);
00126 
00127         //four schemes for edge meshing
00128         //create the mesh for edges with equal distances
00129         void EqualMeshing(ModelEnt *ent, int num_edges, std::vector<double> &coords);
00130 
00131         //create the mesh for edges with bias distances
00132         void BiasMeshing(ModelEnt *ent, int num_edges, std::vector<double> &coords);
00133 
00134         //create the mesh for edges with dual bias distances
00135         void DualBiasMeshing(ModelEnt *ent, int &num_edges, std::vector<double> &coords);
00136 
00137         //create the mesh for edges based on curvatures 
00138         void CurvatureMeshing(ModelEnt *ent, int &num_edges, std::vector<double> &coords);
00139 
00140         //create the mesh for edges based on variable size from SizingFunction (var)
00141         void VariableMeshing(ModelEnt *ent, int &num_edges, std::vector<double> &coords);
00142 
00143         //create the edge mesh on the edge on a cube, such that the
00144         // dihedral angles from the center of the cube are equal (for gnomonic equi angle mesh on the sphere)
00145         void EquiAngleGnomonic(ModelEnt *ent, int num_edges, std::vector<double> &coords);
00146         //compute the distance between the parametric coordinate ustart and parametric coordinate uend.
00147         //double measure(iGeom::EntityHandle ent, double ustart, double uend) const;
00148 
00149 };
00150 
00151 //set up the scheme type for edge meshing
00152 inline void EdgeMesher::set_edge_scheme(EdgeMesher::EdgeSchemeType scheme)
00153 {
00154         schemeType = scheme;
00155 }
00156 
00157 //return the scheme type for edge meshing
00158 inline EdgeMesher::EdgeSchemeType EdgeMesher::get_edge_scheme() const
00159 {
00160         return schemeType;
00161 }
00162 
00163 // set the ratio for bias or dual meshing
00164 inline void EdgeMesher::set_ratio(double q)
00165 {
00166   ratio = q;
00167 }
00168 
00169 // get the ratio for bias or dual meshing
00170 inline double EdgeMesher::get_ratio()
00171 {
00172   return ratio;
00173 }
00174 }
00175 
00176 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines