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