32 template<std::
size_t N>
41 std::set<std::vector<Point<N>*>> figures;
42 std::list<std::pair<Point<N>,
double>> points;
106 std::set<std::vector<Point<N>*>>&
getFigures();
115 std::list<std::pair<Point<N>,
double>>&
getPoints();
192 template<std::
size_t P>
193 friend std::ostream& operator<<(std::ostream& os, const Pavage<P>& pavage);
197 template<std::
size_t N>
235 points.push_back(std::make_pair(
Point<N>({valmin}), 0.0));
236 pointXMin = &(points.back().first);
238 points.push_back(std::make_pair(
Point<N>({valmax}), 0.0));
239 pointXMax = &(points.back().first);
242 std::vector<Point<N>*> figureCur;
243 for (
unsigned i=0; i<=N-1; i++){
245 std::vector<double> v(N-1, valmin);
247 for (
unsigned j=0;j<i;j++){
256 figureCur.push_back(pointXMin);
257 figureCur.push_back(pointXMax);
258 for(
unsigned k=0; k<v.size(); k++){
262 for(
unsigned l=0; l<N; l++){
266 p.setCoord(k+1, v.at(k));
271 for (
typename std::list<std::pair<
Point<N>,
double>>::iterator it1=points.begin(); it1 != points.end(); ++it1){
272 if ((*it1).first==p){
274 pointToInsert = &((*it1).first);
280 figureCur.push_back(pointToInsert);
283 points.push_back(std::make_pair(std::move(p), 0.0));
284 figureCur.push_back(&(points.back().first));
288 figures.insert(figureCur);
290 }
while (std::prev_permutation(v.begin(), v.end()));
297 if (!notToDisplay && N==2){
298 for (std::pair<
Point<N>,
double>& paire : points){
303 double theta =
pi()/4.;
304 double newX = std::round(std::sin(theta)*y + std::cos(theta)*x);
305 double newY = std::round(std::cos(theta)*y - std::sin(theta)*x);
313 template<std::
size_t N>
316 if (_points.size() != N+1) {
317 std::cerr <<
"Il faut donner " << N+1 <<
" points" << std::endl;
321 std::vector<Point<N>*> newFigure;
323 for(
auto& pair : _points){
324 newFigure.push_back(&pair.first);
327 figures.insert(newFigure);
330 template<std::
size_t N>
332 std::list<Point<N>*> singlePoints;
333 for (
const std::pair<
Point<N>,
double>& pair : this->points){
334 singlePoints.push_back(
const_cast<Point<N>*
>(&(pair.first)));
339 template<std::
size_t N>
342 if (*point ==_point){
349 template<std::
size_t N>
350 std::ostream& operator<<(std::ostream& os, const Pavage<N>& pavage){
351 auto& figures =
const_cast<Pavage<N>&
>(pavage).getFigures();
354 os << const_cast<Pavage<N>&>(pavage).getPoints().size() <<
" points, " << figures.size() <<
" figures." << std::endl;
355 for (
typename std::set<std::vector<
Point<N>*>>::iterator it=figures.begin(); it != figures.end(); ++it){
356 os <<
"Figure " << cpt <<
" : ";
357 for(
unsigned int i=0; i<N+1; i++){
358 os << *(it->at(i)) <<
" ";
366 template<std::
size_t N>
368 return this->figures;
371 template<std::
size_t N>
376 template<std::
size_t N>
378 if (this->figures.size() == 0){
384 template<std::
size_t N>
388 for(
unsigned int i=0; i<figure.size(); i++){
389 std::vector<std::vector<double>> det1;
390 std::vector<std::vector<double>> det2;
393 Point<N>* pointDuMemeCote = figure.at(i);
396 for (
unsigned int j=0 ; j < N; j++){
397 std::vector<double> line1;
398 std::vector<double> line2;
399 for (
unsigned int k=0; k< figure.size(); k++){
403 line1.push_back(pt.
getCoord(j) - figure.at(k)->getCoord(j));
407 line2.push_back(pointDuMemeCote->
getCoord(j) - figure.at(k)->getCoord(j));
410 det1.push_back(line1);
411 det2.push_back(line2);
422 if (determinant1*determinant2<=0){
429 template<std::
size_t N>
433 if (this->points.size() >= N+1){
436 if (!contain(this->getSinglePoints(), pt)){
439 points.push_back(std::make_pair(std::move(pt), val));
441 Point<N>& noCopyPt = points.back().first;
442 std::set<std::vector<Point<N>*>> newFigures;
448 for (
typename std::set<std::vector<
Point<N>*>>::iterator it=figures.begin(); it != figures.end(); ++it){
449 std::vector<Point<N>*> figureCur = *it;
450 if (this->isPointInFigure(figureCur,noCopyPt) && newFigures.find(figureCur) == newFigures.end()){
453 for (
unsigned i=0; i <figureCur.size(); i++){
455 std::vector<Point<N>*> newFigure;
456 for (
unsigned j=0; j < figureCur.size(); j++){
457 Point<N>* copyPoint(figureCur.at(j));
459 newFigure.push_back(copyPoint);
463 newFigure.push_back(&(noCopyPt));
464 newFigures.insert(newFigure);
467 this->figures.erase(it);
473 for (
typename std::set<std::vector<
Point<N>*>>::iterator it=newFigures.begin(); it != newFigures.end(); ++it){
474 if (volume(*it) != 0){
475 this->figures.insert(*it);
481 for (std::pair<
Point<N>,
double>& pair : this->points){
482 if (
const_cast<Point<N>&
>(pt) == pair.first){
490 else if (this->points.size() == N) {
491 this->points.push_back(std::make_pair(std::move(pt), val));
492 std::vector<Point<N>*> figure;
494 for (std::pair<
Point<N>,
double>& paire : this->points) {
496 figure.push_back(&pt);
498 this->figures.insert(figure);
503 this->points.push_back(std::make_pair(std::move(pt), val));
512 if(this->toUpdate > 5){
514 this->affectValToBoundries();
519 template<std::
size_t N>
522 std::vector<std::vector<double>> det;
524 if (figure.size() ==0){
525 std::cerr <<
"Volume impossible a calculer" << std::endl;
529 if (figure.size() ==1){
532 if (figure.size() ==2){
541 if (figure.size()==3){
542 std::vector<double> curColumn;
543 for(
unsigned int i=0; i<figure.size(); i++){
545 for(
unsigned j=0; j<N; j++){
546 curColumn.push_back(figure.at(i)->getCoord(j));
548 curColumn.push_back(1);
549 det.push_back(curColumn);
563 Point<N>* firstPoint = figure.at(0);
564 for(
unsigned int i=1; i<figure.size(); i++){
565 std::vector<double> curColumn;
566 for(
unsigned j=0; j<N; j++){
567 curColumn.push_back(figure.at(i)->getCoord(j)-firstPoint->
getCoord(j));
569 det.push_back(curColumn);
577 template<std::
size_t N>
582 for (
typename std::set<std::vector<
Point<N>*>>::iterator it=figures.begin(); it != figures.end(); ++it){
584 std::vector<Point<N>*> figureCur = *it;
585 if (this->isPointInFigure(figureCur,point)){
587 double denominateur = this->volume(figureCur);
588 if (denominateur == 0){
589 std::cerr <<
"Volume de la figure nulle"<<std::endl;
592 std::vector<double> coordsBarycentriques;
594 for (
unsigned i=0; i < figureCur.size(); i++){
603 std::vector<Point<N>*> newFigure;
605 for (
unsigned j=0; j < figureCur.size(); j++){
607 newFigure.push_back(figureCur.at(j));
610 newFigure.push_back(&(
const_cast<Point<N>&
>(point)));
613 double numerateur = this->volume(newFigure);
616 double coordBarycentriquei=std::abs(numerateur)/std::abs(denominateur);
617 coordsBarycentriques.push_back(coordBarycentriquei);
619 for (
unsigned i=0; i < figureCur.size(); i++){
621 for(std::pair<
Point<N>,
double>& pair :
const_cast<std::list<std::pair<Point<N>,
double> >& >(points)){
622 if (
const_cast<Point<N>&
>(pair.first) == *figureCur.at(i)){
628 interpo += coordsBarycentriques.at(i)*eval;
636 template<std::
size_t N>
638 auto& pts = this->getPoints();
640 for (std::pair<
Point<N>,
double>* boundry : this->getBoundries()){
643 for (
auto& pt : pts){
644 if (!pt.first.isBoundry()){
645 double distance = boundry->first.distance(pt.first);
647 moyVal += distance*pt.second;
650 boundry->second=moyVal/sumDist;
654 template<std::
size_t N>
657 std::list<std::pair<Point<N>,
double>*> boundries;
658 std::list<std::pair<Point<N>,
double>>& listOfPoints = this->getPoints();
660 typename std::list<std::pair<Point<N>,
double>>::iterator it;
662 for (it = listOfPoints.begin(); it != listOfPoints.end(); ++it){
664 for (
unsigned int i=0; i<N; i++){
666 std::pair<Point<N>,
double>& paire = *it;
667 boundries.insert(boundries.end(),&paire);
Bibliothèque d'opération sur des points de dimension N templatée.
void affectValToBoundries()
Affectation de valeurs aux bornes du pavage.
double determinant(std::vector< std::vector< double >> det)
Calcul d'un déterminant.
bool isPointInFigure(const std::vector< Point< N > * > &figure, const Point< N > &pt) const
Test d'appartenance d'un point à une figure.
bool isBoundry()
Détermine si le point est une borne.
classe representant un pavage consitué de trisimplexe dans un espace de dimension N ...
double volume(const std::vector< Point< N > * > &figure) const
Calcul du volume d'une figure.
std::list< std::pair< Point< N >, double > > & getPoints()
Getter des couples (point, valeur) du pavage.
Calcul de la Factorial de N.
double getCoord(unsigned int index) const
Getter d'une coordonnée.
bool empty() const
Teste si le pavage est vide.
void addPoint(Point< N > &pt, double val)
Ajout d'un point au pavage.
void setCoord(unsigned int index, double val)
setter d'une coordonnée du point e la coordonnée d'index index du point
void toBoundry()
Identificateur d'un point comme borne.
bool contain(std::list< Point< N > * > _points, const Point< N > &_point) const
Test d'appartenance d'un point a une liste de pointeurs sur point.
double interpolation(const Point< N > &point) const
Calcul de la valeur d'interpolation d'un point.
std::list< std::pair< Point< N >, double > * > getBoundries()
Récupềre les bornes du pavage.
constexpr double pi()
Calcul de pi.
Pavage()
Constructeur vide d'un pavage.
classe representant un point dans un espace de dimension N
Fonction mathématiques de base.
std::set< std::vector< Point< N > * > > & getFigures()
Getter des figures du pavage.
std::list< Point< N > * > getSinglePoints() const
Getter des points du pavage.