Advertisement
Guest User

Untitled

a guest
Aug 24th, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.43 KB | None | 0 0
  1. #ifndef __DEFORMATIONBATI3D_H__
  2. #define __DEFORMATIONBATI3D_H__
  3.  
  4.  
  5.  
  6. #include <iostream>
  7. #include <fstream>
  8.  
  9. #include <lib3ds/file.h>
  10. #include <lib3ds/mesh.h>
  11. #include <lib3ds/node.h>
  12.  
  13.  
  14. #include "LgPoint3.hpp"
  15. #include "LgPoint2.hpp"
  16. #include "CovarianceMatrix.h"
  17. #include "ClassKdTree.h"
  18. //#include "accelerators/kdtreeaccel.h"
  19. #include <Eigen/Core>
  20. #include <vector>
  21.  
  22.  
  23. #include <algorithm>
  24. #include <vector>
  25. #include <string>
  26. #include <cctype>
  27.  
  28.  
  29. using namespace std;
  30.  
  31.  
  32. class DeformationBati3D{
  33.  
  34. public :
  35.  
  36.  
  37. Lib3dsFile *m_file;
  38.  
  39. /*! Fournir le fichier 3DS et la liste des solutions du modele de Gauss-Helmert pour bouger les facades et blocs !*/
  40. /*! Pas besoin de bouger les strips, ils sont virutels!*/
  41.  
  42.  
  43. DeformationBati3D(Lib3dsFile *f,std::map<std::string,Lg::Point3d> & v_facade_normale,std::map<std::string,double> & v_offset_facade,std::map<std::string,Lg::Point2d> & v_offset_bloc_xy);
  44.  
  45.  
  46.  
  47. private :
  48.  
  49. double Tx,Ty;
  50.  
  51.  
  52. void DeformationBlocFacade(Lib3dsFile *f, Lib3dsNode *node,std::map<std::string,Lg::Point3d> & v_facade_normale,std::map<std::string,double> & v_offset_facade,std::map<std::string,Lg::Point2d> & v_offset_bloc_xy);
  53.  
  54.  
  55.  
  56.  
  57. inline bool BlocExist(std::string nom_bloc,std::map<std::string,Lg::Point2d> v_offset_bloc_xy){
  58.  
  59. std::map<std::string,Lg::Point2d>::iterator it;
  60.  
  61. it = v_offset_bloc_xy.find(nom_bloc);
  62. if (it != v_offset_bloc_xy.end())
  63. return true;
  64.  
  65.  
  66. return false;
  67.  
  68. }
  69.  
  70.  
  71. inline bool FacadeExist(std::string nom_facade,std::map<std::string,double> v_offset_facade_xy){
  72.  
  73. std::map<std::string,double>::iterator it;
  74.  
  75. it = v_offset_facade_xy.find(nom_facade);
  76. if (it != v_offset_facade_xy.end())
  77. return true;
  78.  
  79.  
  80. return false;
  81.  
  82. }
  83.  
  84.  
  85.  
  86. };
  87.  
  88.  
  89.  
  90.  
  91. #endif
  92.  
  93.  
  94.  
  95.  
  96. #include "Recalage.h"
  97.  
  98.  
  99. DeformationBati3D::DeformationBati3D(Lib3dsFile *f,std::map<std::string,Lg::Point3d> & v_facade_normale,std::map<std::string,double> & v_offset_facade,std::map<std::string,Lg::Point2d> & v_offset_bloc_xy) {
  100.  
  101. Tx=0.;
  102. Ty=0.;
  103. for(Lib3dsNode *node=f->nodes; node; node=node->next){
  104.  
  105. DeformationBlocFacade(f, node,v_facade_normale,v_offset_facade,v_offset_bloc_xy);
  106. }
  107. /*! Parcours le fichier lib3DS et ajoute une translation par facade et par bloc de batiment !*/
  108. m_file=f;
  109.  
  110.  
  111.  
  112. }
  113.  
  114.  
  115. void DeformationBati3D::DeformationBlocFacade(Lib3dsFile *f, Lib3dsNode *node,std::map<std::string,Lg::Point3d> & v_facade_normale,std::map<std::string,double> & v_offset_facade,std::map<std::string,Lg::Point2d> & v_offset_bloc_xy)
  116. {
  117. Lib3dsNode *p;
  118.  
  119. for (p=node->childs; p!=0; p=p->next){
  120.  
  121. if(p->name[0]=='B' ){
  122.  
  123. if(BlocExist(p->name,v_offset_bloc_xy) ){ // A chaque bloc une Translation 2D differente
  124.  
  125. Lg::Point2d translation= v_offset_bloc_xy.find(p->name)->second;
  126.  
  127. Tx=translation.x();
  128. Ty=translation.y();
  129.  
  130.  
  131. }else{
  132.  
  133.  
  134. Tx=0.;
  135. Ty=0.;
  136.  
  137. }
  138.  
  139. }
  140.  
  141. DeformationBlocFacade(f,p, v_facade_normale,v_offset_facade,v_offset_bloc_xy);
  142. }
  143.  
  144. Lib3dsMesh *mesh=lib3ds_file_mesh_by_name(f,node->name);
  145.  
  146. if(!mesh) return;
  147.  
  148. if(mesh->name[0]=='F' ){ // On ne perturbe que les facade pas les toits
  149.  
  150.  
  151. if( FacadeExist(mesh->name,v_offset_facade) ){ // Si la facade a été touché par le Ray-tracing
  152.  
  153. const double & nx = v_facade_normale.find(mesh->name)->second.x(); // Normal à la facade suivant x
  154. const double & ny = v_facade_normale.find(mesh->name)->second.y(); // Normal à la facade suivant y
  155.  
  156.  
  157. double of =v_offset_facade.find(mesh->name)->second;
  158.  
  159.  
  160. for (unsigned int i=0; i<mesh->points; ++i)
  161. {
  162. mesh->pointL[i].pos[0]=mesh->pointL[i].pos[0]+of*nx;
  163. mesh->pointL[i].pos[1]=mesh->pointL[i].pos[1]+of*ny;
  164.  
  165. }
  166.  
  167. }
  168.  
  169. }
  170.  
  171. if( mesh->name[0]=='F' || mesh->name[0]=='T' ){
  172.  
  173. string nameBloc=node->parent->parent->parent->parent->name;
  174.  
  175. if(BlocExist(nameBloc,v_offset_bloc_xy)){
  176.  
  177. for (unsigned i=0; i<mesh->points; ++i)
  178. {
  179. mesh->pointL[i].pos[0]=mesh->pointL[i].pos[0]+Tx;
  180. mesh->pointL[i].pos[1]=mesh->pointL[i].pos[1]+Ty;
  181. }
  182. }
  183. }
  184.  
  185. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement