MOAB: Mesh Oriented datABase  (version 5.3.0)
EdgeSizeSimpleImplicit.cpp
Go to the documentation of this file.
00001 #include "EdgeSizeSimpleImplicit.hpp"
00002 
00003 namespace moab
00004 {
00005 
00006 EdgeSizeSimpleImplicit::EdgeSizeSimpleImplicit()
00007 {
00008     int i;
00009     // Default to the plane: x = 0.
00010     this->coeffC = 0.;
00011     for( i = 0; i < 3; ++i )
00012     {
00013         this->coeffB[i] = this->coeffA[i] = this->coeffA[i + 3] = 0.;
00014     }
00015     this->coeffB[0] = 1.;
00016     // Default to a scaling ratio of 1.
00017     this->ratio = 1.;
00018 }
00019 
00020 EdgeSizeSimpleImplicit::~EdgeSizeSimpleImplicit() {}
00021 
00022 bool EdgeSizeSimpleImplicit::evaluate_edge( const double* p0, const void* t0, double* p1, void* t1, const double* p2,
00023                                             const void* t2 )
00024 {
00025     (void)t0;
00026     (void)t1;
00027     (void)t2;
00028     double L2 = 0.;
00029     double delta;
00030     int i;
00031     for( i = 0; i < 3; ++i )
00032     {
00033         delta = p2[i + 3] - p0[i + 3];
00034         L2 += delta * delta;
00035     }
00036     // parametric coords in p1[{0,1,2}]
00037     double x  = p1[3];
00038     double y  = p1[4];
00039     double z  = p1[5];
00040     double F2 = this->coeffA[0] * x * x + 2. * this->coeffA[1] * x * y + 2. * this->coeffA[2] * x * z +
00041                 this->coeffA[3] * y * y + 2. * this->coeffA[4] * y * z + this->coeffA[5] * z * z + this->coeffB[0] * x +
00042                 this->coeffB[1] * y + this->coeffB[2] * z + this->coeffC;
00043     F2        = F2 * F2;  // square it
00044     double r2 = this->ratio * this->ratio;
00045     if( 4. * F2 / L2 < r2 ) return true;  // Midpoint is close to surface => split edge
00046 
00047     return false;  // Don't split edge
00048 }
00049 
00050 void EdgeSizeSimpleImplicit::set_implicit_function( double* coeffs )
00051 {
00052     int i;
00053     // Default to the plane: x = 0.
00054     for( i = 0; i < 3; ++i )
00055     {
00056         this->coeffA[i]     = coeffs[i];
00057         this->coeffA[i + 3] = coeffs[i + 3];
00058         this->coeffB[i]     = coeffs[i + 6];
00059     }
00060     this->coeffC = coeffs[9];
00061 }
00062 
00063 void EdgeSizeSimpleImplicit::get_implicit_function( double*& coeffs )
00064 {
00065     int i;
00066     // Default to the plane: x = 0.
00067     for( i = 0; i < 3; ++i )
00068     {
00069         coeffs[i]     = this->coeffA[i];
00070         coeffs[i + 3] = this->coeffA[i + 3];
00071         coeffs[i + 6] = this->coeffB[i];
00072     }
00073     coeffs[9] = this->coeffC;
00074 }
00075 
00076 }  // namespace moab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines