Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

Blend.cpp

Go to the documentation of this file.
00001 #include "Blend.h"
00002 
00003 /**
00004  *  Called by the various constructors to allow for a single location for
00005  *  the init of a Sphere object.
00006  */
00007 void Blend::init(Implicit* f, Implicit* g)
00008 {
00009   m_f = f;
00010   m_g = g;
00011   m_r1 = 1.0;
00012   m_r2 = 1.0;
00013 }
00014 
00015 /**
00016  * Default constructor.
00017  */
00018 Blend::Blend()
00019 {
00020   init(NULL,NULL);
00021 };
00022 
00023 /**
00024  * Constructor with two Implicits.
00025  */
00026 
00027 Blend::Blend(Implicit *f, Implicit *g)
00028 {
00029   init(f,g);
00030 }
00031 
00032 #ifndef INTERVAL_EVAL_ONLY
00033 double Blend::proc(gmVector3 x)
00034 {
00035   if ((m_f!=NULL) && (m_g!=NULL))
00036     return h(m_f->proc(x),m_g->proc(x));
00037   else
00038     return 0.0;
00039 }
00040 
00041 gmVector3 Blend::grad(gmVector3 x)
00042 {
00043   if ((m_f!=NULL) && (m_g!=NULL))
00044     {
00045       double fx = m_f->proc(x); 
00046       double gx = m_g->proc(x);
00047       return hf(fx,gx) * m_f->grad(x) + hg(fx,gx) * m_g->grad(x);
00048     }
00049   else
00050     return gmVector3();
00051 }
00052 
00053 gmMatrix3 Blend::hess(gmVector3 x)
00054 {
00055   if ((m_f!=NULL) && (m_g!=NULL))
00056     {
00057       double fx = m_f->proc(x); 
00058       double gx = m_g->proc(x);
00059       gmVector3 dfx = m_f->grad(x);
00060       gmVector3 dgx = m_g->grad(x);
00061 
00062       return hff(fx,gx) * outer(dfx,dfx) + 
00063              hfg(fx,gx) * outer(dfx,dgx) +
00064              hfg(fx,gx) * outer(dgx,dfx) + 
00065              hgg(fx,gx) * outer(dgx,dgx) +
00066              hf(fx,gx)  * m_f->hess(x)   + 
00067              hg(fx,gx)  * m_g->hess(x);
00068     }
00069   else
00070     return gmMatrix3();
00071 }
00072 #endif
00073 
00074 Intervald Blend::proc(Box<double> x)
00075 {
00076   if ((m_f!=NULL) && (m_g!=NULL))
00077     return h(m_f->proc(x),m_g->proc(x));
00078   else
00079     return Intervald(0.0);
00080 }
00081 
00082 Box3d Blend::grad(Box<double> x)
00083 {
00084   if ((m_f!=NULL) && (m_g!=NULL))
00085     {
00086       Intervald fx = m_f->proc(x);
00087       Intervald gx = m_g->proc(x);
00088       return hf(fx,gx) * m_f->grad(x) + hg(fx,gx) * m_g->grad(x);
00089     }
00090   else
00091     return Box3d(0.0);
00092 }
00093 
00094 IMatrix3d Blend::hess(Box<double> x)
00095 {
00096   if ((m_f!=NULL) && (m_g!=NULL))
00097     {
00098       Intervald fx = m_f->proc(x); 
00099       Intervald gx = m_g->proc(x);
00100       Box3d dfx = m_f->grad(x);
00101       Box3d dgx = m_g->grad(x);
00102 
00103       return hff(fx,gx) * outer(dfx,dfx) + 
00104              hfg(fx,gx) * outer(dfx,dgx) +
00105              hfg(fx,gx) * outer(dgx,dfx) + 
00106              hgg(fx,gx) * outer(dgx,dgx) +
00107              hf(fx,gx)  * m_f->hess(x)   + 
00108              hg(fx,gx)  * m_g->hess(x);
00109     }
00110   else
00111     return IMatrix3d(0.0);
00112 }
00113 
00114 void Blend::_setq(double* q)
00115 {
00116   m_r1 = q[0];
00117   m_r2 = q[1];
00118 
00119   if ((m_f!=NULL) && (m_g!=NULL))
00120     {
00121       m_f->_setq(&q[2]);
00122       m_g->_setq(&q[2+m_f->qlen()]);
00123     } 
00124 }
00125 
00126 void Blend::getq(double* q)
00127 {  
00128   q[0] = m_r1;
00129   q[1] = m_r2;
00130 
00131   if ((m_f!=NULL) && (m_g!=NULL))
00132     {
00133       m_f->getq(&q[2]);
00134       m_g->getq(&q[2+m_f->qlen()]);
00135     }  
00136 }
00137 
00138 void Blend::procq(gmVector3 x, double* q)
00139 {
00140   if ((m_f!=NULL) && (m_g!=NULL))
00141     {
00142       q[0] = hr1(m_f->proc(x),m_g->proc(x));
00143       q[1] = hr2(m_f->proc(x),m_g->proc(x));
00144 
00145       m_f->procq(x, &q[2]);
00146       m_g->procq(x, &q[2+m_f->qlen()]);
00147     }
00148 }
00149 
00150 void Blend::getqname(char** name)
00151 {
00152   name[0] = "Radius 1";
00153   name[1] = "Radius 2";
00154 
00155   if ((m_f!=NULL) && (m_g!=NULL))
00156     {
00157       m_f->getqname(&name[2]);
00158       m_g->getqname(&name[2+m_f->qlen()]);
00159     }
00160 }
00161 
00162 int Blend::qlen(void)
00163 {
00164   int retval = 2;
00165 
00166   if ((m_f!=NULL) && (m_g!=NULL))
00167     retval += m_f->qlen() + m_g->qlen();
00168 
00169   return retval;
00170 }
00171 

Generated on Mon Jun 28 14:58:13 2004 for Advanced Surface Library by doxygen 1.3.4