Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef __DEFORMATIONBATI3D_H__
- #define __DEFORMATIONBATI3D_H__
- #include <iostream>
- #include <fstream>
- #include <lib3ds/file.h>
- #include <lib3ds/mesh.h>
- #include <lib3ds/node.h>
- #include "LgPoint3.hpp"
- #include "LgPoint2.hpp"
- #include "CovarianceMatrix.h"
- #include "ClassKdTree.h"
- //#include "accelerators/kdtreeaccel.h"
- #include <Eigen/Core>
- #include <vector>
- #include <algorithm>
- #include <vector>
- #include <string>
- #include <cctype>
- using namespace std;
- class DeformationBati3D{
- public :
- Lib3dsFile *m_file;
- /*! Fournir le fichier 3DS et la liste des solutions du modele de Gauss-Helmert pour bouger les facades et blocs !*/
- /*! Pas besoin de bouger les strips, ils sont virutels!*/
- 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);
- private :
- double Tx,Ty;
- 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);
- inline bool BlocExist(std::string nom_bloc,std::map<std::string,Lg::Point2d> v_offset_bloc_xy){
- std::map<std::string,Lg::Point2d>::iterator it;
- it = v_offset_bloc_xy.find(nom_bloc);
- if (it != v_offset_bloc_xy.end())
- return true;
- return false;
- }
- inline bool FacadeExist(std::string nom_facade,std::map<std::string,double> v_offset_facade_xy){
- std::map<std::string,double>::iterator it;
- it = v_offset_facade_xy.find(nom_facade);
- if (it != v_offset_facade_xy.end())
- return true;
- return false;
- }
- };
- #endif
- #include "Recalage.h"
- 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) {
- Tx=0.;
- Ty=0.;
- for(Lib3dsNode *node=f->nodes; node; node=node->next){
- DeformationBlocFacade(f, node,v_facade_normale,v_offset_facade,v_offset_bloc_xy);
- }
- /*! Parcours le fichier lib3DS et ajoute une translation par facade et par bloc de batiment !*/
- m_file=f;
- }
- 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)
- {
- Lib3dsNode *p;
- for (p=node->childs; p!=0; p=p->next){
- if(p->name[0]=='B' ){
- if(BlocExist(p->name,v_offset_bloc_xy) ){ // A chaque bloc une Translation 2D differente
- Lg::Point2d translation= v_offset_bloc_xy.find(p->name)->second;
- Tx=translation.x();
- Ty=translation.y();
- }else{
- Tx=0.;
- Ty=0.;
- }
- }
- DeformationBlocFacade(f,p, v_facade_normale,v_offset_facade,v_offset_bloc_xy);
- }
- Lib3dsMesh *mesh=lib3ds_file_mesh_by_name(f,node->name);
- if(!mesh) return;
- if(mesh->name[0]=='F' ){ // On ne perturbe que les facade pas les toits
- if( FacadeExist(mesh->name,v_offset_facade) ){ // Si la facade a été touché par le Ray-tracing
- const double & nx = v_facade_normale.find(mesh->name)->second.x(); // Normal à la facade suivant x
- const double & ny = v_facade_normale.find(mesh->name)->second.y(); // Normal à la facade suivant y
- double of =v_offset_facade.find(mesh->name)->second;
- for (unsigned int i=0; i<mesh->points; ++i)
- {
- mesh->pointL[i].pos[0]=mesh->pointL[i].pos[0]+of*nx;
- mesh->pointL[i].pos[1]=mesh->pointL[i].pos[1]+of*ny;
- }
- }
- }
- if( mesh->name[0]=='F' || mesh->name[0]=='T' ){
- string nameBloc=node->parent->parent->parent->parent->name;
- if(BlocExist(nameBloc,v_offset_bloc_xy)){
- for (unsigned i=0; i<mesh->points; ++i)
- {
- mesh->pointL[i].pos[0]=mesh->pointL[i].pos[0]+Tx;
- mesh->pointL[i].pos[1]=mesh->pointL[i].pos[1]+Ty;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement