LR-splines  0.5
LRSpline.cpp
Go to the documentation of this file.
00001 #include "LRSpline/LRSpline.h"
00002 #include "LRSpline/Basisfunction.h"
00003 #include "LRSpline/Element.h"
00004 
00005 namespace LR {
00006 
00007 LRSpline::LRSpline() {
00008         dim_      = 0;
00009         element_.resize(0);
00010         lastElementEvaluation = -1;
00011 }
00012 
00013 void LRSpline::generateIDs() const {
00014         uint i=0;
00015         for(Basisfunction *b : basis_)
00016                 b->setId(i++);
00017         for(i=0; i<element_.size(); i++) 
00018                 element_[i]->setId(i);
00019 }
00020 
00021 void LRSpline::getEdgeFunctions(std::vector<Basisfunction*> &edgeFunctions, parameterEdge edge, int depth) const {
00022         edgeFunctions.clear();
00023         bool trivariate = (**basis_.begin()).nVariate() == 3;
00024         for(Basisfunction *b : basis_) {
00025                 bool ok = true;
00026                 if( edge & WEST )
00027                         if((*b)[0][order_[0]-depth] != start_[0]) 
00028                                 ok = false;
00029                 if( edge & EAST )
00030                         if((*b)[0][depth] != end_[0]) 
00031                                 ok = false;
00032                 if( edge & SOUTH )
00033                         if((*b)[1][order_[1]-depth] != start_[1]) 
00034                                 ok = false;
00035                 if( edge & NORTH )
00036                         if((*b)[1][depth] != end_[1]) 
00037                                 ok = false;
00038                 if( trivariate && (edge & BOTTOM) )
00039                         if((*b)[2][order_[2]-depth] != start_[2]) 
00040                                 ok = false;
00041                 if( trivariate && (edge & TOP ) )
00042                         if((*b)[2][depth] != end_[2]) 
00043                                 ok = false;
00044 
00045                 if(ok)
00046                         edgeFunctions.push_back(b);
00047         }
00048 }
00049 
00050 void LRSpline::getEdgeElements( std::vector<Element*> &edgeElements, parameterEdge edge ) const {
00051         edgeElements.clear();
00052         bool trivariate = (**basis_.begin()).nVariate() == 3;
00053         for(Element * el : element_) {
00054                 bool ok = true;
00055                 if( edge & WEST )
00056                         if(el->getParmin(0) != start_[0]) 
00057                                 ok = false;
00058                 if( edge & EAST )
00059                         if(el->getParmax(0) != end_[0]) 
00060                                 ok = false;
00061                 if( edge & SOUTH )
00062                         if(el->getParmin(1) != start_[1]) 
00063                                 ok = false;
00064                 if( edge & NORTH )
00065                         if(el->getParmax(1) != end_[1]) 
00066                                 ok = false;
00067                 if( trivariate && (edge & BOTTOM) )
00068                         if(el->getParmin(2) != start_[2]) 
00069                                 ok = false;
00070                 if( trivariate && (edge & TOP ) )
00071                         if(el->getParmax(2) != end_[2]) 
00072                                 ok = false;
00073 
00074                 if(ok)
00075                         edgeElements.push_back(el);
00076         }
00077 }
00078 
00079 bool LRSpline::setControlPoints(std::vector<double>& controlpoints) {
00080         if(controlpoints.size() != dim_*basis_.size())
00081                 return false;
00082         
00083         std::vector<double>::iterator newCP = controlpoints.begin();
00084 
00085         HashSet_iterator<Basisfunction*> bit;
00086         for(bit=basis_.begin(); bit!=basis_.end(); ++bit) {
00087                 std::vector<double>::iterator cp = (**bit).cp();
00088                 for(int i=0; i<dim_; i++, cp++, newCP++)
00089                         *cp = *newCP;
00090         }
00091         return true;
00092 }
00093 
00094 void LRSpline::rebuildDimension(int dimvalue) {
00095         for(Basisfunction *b : basis_)
00096                 b->setDimension(dimvalue);
00097         dim_ = dimvalue;
00098 }
00099 
00100 
00101 } // end namespace LR