LR-splines  0.5
Element.h
Go to the documentation of this file.
00001 #ifndef ELEMENT_H
00002 #define ELEMENT_H
00003 
00004 #include "Streamable.h"
00005 #include <vector>
00006 #include "HashSet.h"
00007 
00008 namespace LR {
00009 
00010 class Basisfunction;
00011 class Meshline;
00012 
00013 /************************************************************************************************************************/
00019 class Element : public Streamable {
00020 
00021 public:
00022         Element();
00023         Element(int dim);
00024         Element(double start_u, double start_v, double stop_u, double stop_v);
00025         /************************************************************************************************************************/
00031         template <typename RandomIterator1,
00032                   typename RandomIterator2>
00033         Element(int dim, RandomIterator1 lowerLeft, RandomIterator2 upperRight) {
00034                 min.resize(dim);
00035                 max.resize(dim);
00036                 std::copy(lowerLeft,  lowerLeft  + dim, min.begin());
00037                 std::copy(upperRight, upperRight + dim, max.begin());
00038         }
00039         Element(std::vector<double> &lowerLeft, std::vector<double> &upperRight);
00040         void removeSupportFunction(Basisfunction *f);
00041         void addSupportFunction(Basisfunction *f);
00042         Element *split(int splitDim, double par_value);
00043         Element* copy();
00044         // get/set methods
00046         double getParmin(int i) const { return min[i]; };
00048         double getParmax(int i) const { return max[i]; };
00049         double umin()           const { return min[0]; };
00050         double vmin()           const { return min[1]; };
00051         double wmin()           const { return min[2]; };
00052         double umax()           const { return max[0]; };
00053         double vmax()           const { return max[1]; };
00054         double wmax()           const { return max[2]; };
00056         double area()           const { return (max[1]-min[1])*(max[0]-min[0]);                  };
00058         double volume()         const { return (max[2]-min[2])*(max[1]-min[1])*(max[0]-min[0]);  };
00059         HashSet_iterator<Basisfunction*> supportBegin()                 { return support_.begin(); };
00060         HashSet_iterator<Basisfunction*> supportEnd()                   { return support_.end();   };
00061         HashSet_const_iterator<Basisfunction*> constSupportBegin()const { return support_.begin(); };
00062         HashSet_const_iterator<Basisfunction*> constSupportEnd()  const { return support_.end();   };
00063         const HashSet<Basisfunction*>& support()                  const { return support_;   };
00065         int nBasisFunctions() const           { return support_.size(); };
00067         void setId(int id)                    { this->id_ = id; };
00069         int  getId() const                    { return id_; };
00071         int  getDim() const                   { return min.size(); };
00072         void setUmin(double u)                { min[0] = u; };
00073         void setVmin(double v)                { min[1] = v; };
00074         void setUmax(double u)                { max[0] = u; };
00075         void setVmax(double v)                { max[1] = v; };
00076 
00077         bool isOverloaded() const;
00078         void resetOverloadCount()    { overloadCount = 0;      }
00079         int incrementOverloadCount() { return overloadCount++; }
00080         int getOverloadCount() const { return overloadCount;   }
00081 
00082         void updateBasisPointers(std::vector<Basisfunction*> &basis) ;
00083 
00084         virtual void read(std::istream &is);
00085         virtual void write(std::ostream &os) const;
00086 
00087 private:
00088         std::vector<double> min;  // lower left corner in typical 2 or 3 dimensions
00089         std::vector<double> max;  // upper right corner 
00090         int id_;
00091 
00092         HashSet<Basisfunction*> support_;
00093         std::vector<int> support_ids_; // temporary storage for the read() method only
00094 
00095         int overloadCount ;
00096         
00097 };
00098 
00099 } // end namespace LR
00100 
00101 #endif
00102