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_generate_centroid_integrated.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_GENERATE_CENTROID_INTEGRATED
25 #define CMESH_GENERATE_CENTROID_INTEGRATED
26 
37 
54 template<typename T,typename Timg>
56 {
57 
58  public:
59 
60  int m_mode_num;
61 
63  {
65  this->class_name = "Cmesh_generate_centroid_integrated";
66 
67  }
68 
69  virtual int get_attributes(CParameterNetCDF &fp)
70  {
73 
74  int error(0);
75  std::string att;
76 
77  //m_win[x,y,z]
78  att = "window";
79  error = fp.loadAttribute(att,this->m_win);
80  for (int i=this->m_win.size(); i<3; i++){this->m_win.push_back(1);}
81  if (this->m_verbose){printf("\tMesh ZOI : [%i %i %i]\n",this->m_win[0], this->m_win[1], this->m_win[2]);}
82 
83  m_mode_num = this->m_dof;
84 
85  }
86 
87  virtual int cropList(const Cimage<Timg> &oImage, const int &elem, CImg<Timg> &list, std::vector<T> &coord0) const
88  {//extract sub_box from global image one using node and element table
89 
94  std::vector<T> coord1;
95  coord0.assign(3,0);coord1.assign(3,0);
96  int msk(1);
97  double unmasked(num_mod()*num_mod());
98 
99  cimglist_for(this->m_node, dim)
100  {//find corners positions
101 
102  coord0[dim] = this->m_node[dim][this->m_connect[elem].front()] - this->m_win[dim]/2 + 1;
103  coord1[dim] = this->m_node[dim][this->m_connect[elem].front()] - this->m_win[dim]/2 + this->m_win[dim] - 1;
104 
105  if (coord0[dim] < 1)
106  {
107  coord0[dim] = 1;
108  }
109 
110  if (coord1[dim] >= oImage.cur_dim(dim)-1)
111  {
112  coord1[dim] = oImage.cur_dim(dim) - 2;
113  }
114 
115  }
116 
117  if (!oImage.m_curMask.is_empty())
118  {//number of unmasked pixels within element
119  unmasked = oImage.m_curMask.get_crop(coord0[0],coord0[1],coord0[2],0,coord1[0],coord1[1],coord1[2],0,0).sum();
120  }
121 
122 
123  if (unmasked >= num_mod()*2)
124  {list.assign(coord1[0]-coord0[0]+1, coord1[1]-coord0[1]+1, coord1[2]-coord0[2]+1, 1, 0);}
125  else
126  {msk = 0;}
127 
128  return msk;
129 
130  }
131 
132  virtual int grid_dims(const int &i) const
133  {// return mesh grid dimensions
134 
135  switch(i)
136  {
137  case 0: return this->m_grid[0]; break;
138  case 1: return this->m_grid[1]; break;
139  case 2: return this->m_grid[2]; break;
140  case 3: return 1; break;
141  default:
142  {
143  std::cerr<<this->class_name<<"::"<<__func__<<": error: id="<<i<<" which is over [0-3]\n"<<std::flush;
144  return 0;
145  }
146  }
147 
148  }
149 
150  virtual int num_mod() const
151  {
152 
153  return m_mode_num;
154 
155  }
156 
157 
158 };
159 
160 #endif
As Cmesh_Q4 this class is based on regular and rectangular elements. This class works on 7 main attri...
Definition: Cmesh_generate_centroid.h:58
As Cmesh_Q4 this class is based on regular and rectangular elements. This class works on 7 main attri...
Definition: Cmesh_generate_centroid_integrated.h:55
Cmesh_generate_centroid_integrated()
Definition: Cmesh_generate_centroid_integrated.h:62
virtual int cropList(const Cimage< Timg > &oImage, const int &elem, CImg< Timg > &list, std::vector< T > &coord0) const
Definition: Cmesh_generate_centroid_integrated.h:87
virtual int get_attributes(CParameterNetCDF &fp)
Definition: Cmesh_generate_centroid_integrated.h:69
Class is based on Q4 elements, i.e. 4 nodes elements. This class works on 7 main attributes declared ...
Definition: Cmesh_generate_regularFem.h:52
Definition: Cimage.h:57