1 /* This file is part of MED.
2 *
3 * COPYRIGHT (C) 1999 - 2019 EDF R&D, CEA/DEN
4 * MED is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * MED is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with MED. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18
19 #include <med.h>
20 #include <med_config.h>
21 #include <med_outils.h>
22 #include <hdf5.h>
23 #include <string.h>
24
25 /**\ingroup MEDfilter
26 \brief \MEDfilterBlockOfEntityBrief
27 \param fid \fid
28 \param nentity \nentity \nentityMEDfilterCm
29 \param nvaluesperentity \nvaluesperentity \nvaluesperentityMEDfilterCm \nvaluesperentityMEDfilterEx
30 \param nconstituentpervalue \nconstituentpervalue \nconstituentpervalueMEDfilterEx
31 \param constituentselect \constituentselect \constituentselectMEDfilterEx
32 \param switchmode \switchmode
33 \param storagemode \storagemode
34 \param profilename \profilename
35 \param start \start
36 \param stride \stride
37 \param count \count
38 \param blocksize \blocksize
39 \param lastblocksize \lastblocksize
40 \retval filter \filter \filterMEDfilterCm
41 \return \error
42
43 \details
44 \MEDfilterBlockOfEntityDetails
45
46 \par Remarques
47 \MEDfilterBlockOfEntityNote
48 */
49
MEDfilterBlockOfEntityCr(const med_idt fid,const med_int nentity,const med_int nvaluesperentity,const med_int nconstituentpervalue,const med_int constituentselect,const med_switch_mode switchmode,const med_storage_mode storagemode,const char * const profilename,const med_size start,const med_size stride,const med_size count,const med_size blocksize,const med_size lastblocksize,med_filter * const filter)50 med_err MEDfilterBlockOfEntityCr(const med_idt fid,
51 const med_int nentity,
52 const med_int nvaluesperentity,
53 const med_int nconstituentpervalue,
54 const med_int constituentselect,
55 const med_switch_mode switchmode,
56 const med_storage_mode storagemode,
57 const char * const profilename,
58 const med_size start,
59 const med_size stride,
60 const med_size count,
61 const med_size blocksize,
62 const med_size lastblocksize,
63 med_filter* const filter) {
64
65
66 med_int _profilearraysize=0,_maxentitynum=0;
67 med_err _ret=-1;
68 med_size _start=start-1;
69
70 NOFINALBLANK(profilename,ERROR);
71
72 if ( start == 0) {
73 MED_ERR_(_ret,MED_ERR_RANGE,MED_ERR_FILTER,"");
74 ISCRUTE_size(start);
75 goto ERROR;
76 }
77
78 _maxentitynum=_start+(count-1)*(stride);
79
80 if ( strlen(profilename) ) {
81 _profilearraysize = MEDprofileSizeByName(fid,profilename);
82 if ( _maxentitynum > _profilearraysize ) {
83 MED_ERR_(_ret,MED_ERR_RANGE,MED_ERR_FILTER,MED_ERR_GSIZE_MSG);ISCRUTE(_maxentitynum);
84 SSCRUTE(profilename);ISCRUTE(_profilearraysize);
85 ISCRUTE_size(start);ISCRUTE_size(stride);ISCRUTE_size(count);ISCRUTE_size(blocksize);
86 goto ERROR;
87 }
88 }
89
90 /* Verify constituentselect is between [0, nconstituentpervalue] ( 0 is MED_ALL_CONSTITUENT ) */
91 if ( constituentselect > nconstituentpervalue) {
92 MED_ERR_(_ret,MED_ERR_RANGE,MED_ERR_FILTER,MED_ERR_VALUE_MSG);ISCRUTE(constituentselect);
93 ISCRUTE(nconstituentpervalue);
94 goto ERROR;
95 }
96
97 switch(switchmode) {
98 case MED_FULL_INTERLACE :
99
100
101 switch(storagemode) { /* switch Interlace */
102 case MED_GLOBAL_STMODE :
103
104 if ( _MEDfilterBlockOfEntityFullIGlobalCr(fid,nentity,nvaluesperentity,nconstituentpervalue,constituentselect,
105 storagemode,profilename,start,stride,count,blocksize,lastblocksize,filter) < 0 ) {
106 MED_ERR_(_ret,MED_ERR_SELECT,MED_ERR_FILTER,MED_ERR_MODE_MSG);
107 MESSAGE("MED_FULL_INTERLACE, MED_GLOBAL_STMODE");
108 goto ERROR;
109 }
110 break;
111 case MED_COMPACT_STMODE :
112 if ( _MEDfilterBlockOfEntityFullICompactCr(fid,nentity,nvaluesperentity,nconstituentpervalue,constituentselect,
113 storagemode,profilename,start,stride,count,blocksize,lastblocksize,filter) < 0 ) {
114 MED_ERR_(_ret,MED_ERR_SELECT,MED_ERR_FILTER,MED_ERR_MODE_MSG);
115 MESSAGE("MED_FULL_INTERLACE, MED_COMPACT_STMODE");
116 goto ERROR;
117 }
118 break;
119 default:
120 MED_ERR_(_ret,MED_ERR_INIT,MED_ERR_FILTER,MED_ERR_MODE_MSG);
121 MESSAGE("MED_UNDEF_STMODE");
122 MESSAGE("MED_FULL_INTERLACE");
123 SSCRUTE(profilename);
124 ISCRUTE_int(storagemode);
125 ISCRUTE(_profilearraysize);
126 goto ERROR;
127 break;
128 }
129
130 break;
131 case MED_NO_INTERLACE :
132
133 switch(storagemode) {
134
135 case MED_GLOBAL_STMODE :
136
137 if ( _MEDfilterBlockOfEntityNoIGlobalCr(fid,nentity,nvaluesperentity,nconstituentpervalue,constituentselect,
138 storagemode,profilename,start,stride,count,blocksize,lastblocksize,filter) < 0 ) {
139 MED_ERR_(_ret,MED_ERR_SELECT,MED_ERR_FILTER,MED_ERR_MODE_MSG);
140 MESSAGE("MED_NO_INTERLACE, MED_GLOBAL_STMODE");
141 goto ERROR;
142 }
143 break;
144
145 case MED_COMPACT_STMODE :
146 if ( _MEDfilterBlockOfEntityNoICompactCr(fid,nentity,nvaluesperentity,nconstituentpervalue,constituentselect,
147 storagemode,profilename,start,stride,count,blocksize,lastblocksize,filter) < 0 ) {
148 MED_ERR_(_ret,MED_ERR_SELECT,MED_ERR_FILTER,MED_ERR_MODE_MSG);
149 MESSAGE("MED_NO_INTERLACE, MED_COMPACT_STMODE");
150 goto ERROR;
151 }
152 break;
153
154 default:
155 MED_ERR_(_ret,MED_ERR_INIT,MED_ERR_FILTER,MED_ERR_MODE_MSG);
156 MESSAGE("MED_UNDEF_STMODE");
157 MESSAGE("MED_NO_INTERLACE");
158 SSCRUTE(profilename);
159 ISCRUTE_int(storagemode);
160 ISCRUTE(_profilearraysize);
161 goto ERROR;
162 break;
163 }
164
165 break;
166
167 default:
168 MED_ERR_(_ret,MED_ERR_RANGE,MED_ERR_INTERLACINGMODE,MED_ERR_VALUE_MSG);
169 ISCRUTE_int(switchmode);
170 goto ERROR;
171 }
172
173 _ret = 0;
174
175 ERROR:
176
177 /* if ( _memspace ) if ( (_ret = H5Sclose(_memspace)) < 0) { */
178 /* MESSAGE("Impossible de fermer le memspace : "); */
179 /* ISCRUTE(_memspace); _ret = -1; */
180 /* } */
181
182 return _ret;
183 }
184