YaDICs  V04.14.a
Yet another Digital Image Correlation software: platform dedicated to 2/3D Fluid and Solid kinematics field measurements.
 All Classes Files Functions Variables Pages
Cmesh.h
Go to the documentation of this file.
1 /**********************************************************************
2  * Copyright (C) 2012, The YaDICs Project Developers.
3  * See the COPYRIGHT file at the top-level directory of this distribution ./COPYRIGHT.
4  * See ./COPYING file for copying and redistribution conditions.
5  *
6  * This file is part of YaDICs.
7  * YaDICs is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * YaDICs is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with YaDICs. If not, see <http://www.gnu.org/licenses/>.
19  *
20  * Information about how to use the software are provided at http://yadic.univ-lille1.fr/
21  **********************************************************************/
22 
23 
24 #ifndef CMESH
25 #define CMESH
26 
27 
37 //-----------------------------CIMG_NETCDF-------------------------------
38 #define cimg_plugin "plugins/add_fileformat.h"
39 #define cimg_use_netcdf
40 
41 #ifdef cimg_use_netcdf
42  #include "../NetCDF.Tool/struct_parameter_NetCDF.h"
43 // #define cimg_plugin1 "plugins/netcdf_file_format4CImg1.h"
44 // #define cimglist_plugin1 "plugins/netcdf_file_format4CImgList1.h"
45  #define cimg_plugin2 "plugins/netcdf_file_format4CImg2.h"
46  #define cimglist_plugin2 "plugins/netcdf_file_format4CImgList2.h"
47  #include "../CImg.Tool/CImg_NetCDF.h"
48 #endif
49 //-----------------------------CIMG_NETCDF-------------------------------
50 
51 #include "Cmesh_factory.h"
52 #include "Cimage.h"
53 #include "CImg_math.h"
54 #include "textcolor.h"
55 
60 template<typename T,typename Timg>
61 class Cmesh
62 {
63 
64  public:
65 
66  std::string class_name;
67  std::string m_type, m_name;
68 
69  std::vector<std::string> m_componentName; //Composante names
70 
71  CImgList<T> m_node; // node table
72  CImgList<int> m_connect; // connectivity table
73 
74  int _3D, m_threadNB, m_numPix, m_storeMesh;
75  bool m_verbose;
76 
77  int m_dof;
78  std::vector<int> m_pitch;
79  std::vector<int> m_win;
80 
81 
82  Cmesh()
83  {// constructor
84 
85  class_name = "mesh : mother";
86 
87  #pragma omp parallel
88  {m_threadNB = omp_get_num_threads();}
89 
90  }
91 
92  virtual int exec(const Cimage<Timg> &oImage)
93  {//exec
94 
95  int error = assign(oImage);
96 
97  #pragma omp parallel
98  {
99  set_nodes(oImage, m_node); //generate node table
100  set_connectivity(oImage, m_node, m_connect);// generate connectivity table
101  }
102 
103  return error;
104 
105  }
106 
107  void init(CParameterNetCDF &fp)
108  {// mesh initialization
109 
110  get_attributes(fp);
111 
112  }
113 
114  virtual int get_attributes(CParameterNetCDF &fp)
115  {// get mesh attributes
116 
117  int error(0);
118  std::string att;
119 
120  att = "component";
121  error = fp.loadAttribute(att,m_componentName);
122  if (m_componentName.size() == 3){_3D = 1;}else{_3D = 0;}
123 
124  if (this->m_verbose){std::cout<<"\tcomponents : [ ";for (int i=0; i<m_componentName.size(); i++){std::cout<<m_componentName[i]<<" ";}std::cout<<"]\n";}
125 
126  }
127 
128  virtual int cropList(const Cimage<Timg> &oImage, const int &elem, CImg<Timg> &list, std::vector<T> &coord0) const = 0;
129 
130  int num_node() const
131  {// components dimension
132 
133  return m_node[0].size();
134 
135  }
136 
137  int num_elem() const
138  {// components dimension
139 
140  return m_connect.size();
141 
142  }
143 
144  int num_var() const
145  {
146 
147  return m_componentName.size();
148 
149  }
150 
151  virtual int num_mod() const
152  {
153 
154  return m_connect[0].size();
155 
156  }
157 
158  virtual int grid_dims(const int &i) const = 0;
159  virtual void set_nodes(const Cimage<Timg> &oImage, CImgList<T> &nodes) = 0;
160  virtual void set_connectivity(const Cimage<Timg> &oImage, const CImgList<T> &nodes, CImgList<int> &elements) = 0;
161  virtual int assign(const Cimage<Timg> &oImage) = 0;
162 
163 };
164 
165 #endif
load image and mask from cdl and store fields. It also creates a resized version of data in the case ...
Definition: Cmesh.h:61
Definition: Cimage.h:57