26 template<
typename VolumeType>
30 typename VolumeType::VoxelType voxel1nx = volIter.peekVoxel1nx0py0pz() > 0 ? 1: 0;
31 typename VolumeType::VoxelType voxel1px = volIter.peekVoxel1px0py0pz() > 0 ? 1: 0;
33 typename VolumeType::VoxelType voxel1ny = volIter.peekVoxel0px1ny0pz() > 0 ? 1: 0;
34 typename VolumeType::VoxelType voxel1py = volIter.peekVoxel0px1py0pz() > 0 ? 1: 0;
36 typename VolumeType::VoxelType voxel1nz = volIter.peekVoxel0px0py1nz() > 0 ? 1: 0;
37 typename VolumeType::VoxelType voxel1pz = volIter.peekVoxel0px0py1pz() > 0 ? 1: 0;
41 static_cast<float>(voxel1nx) - static_cast<float>(voxel1px),
42 static_cast<float>(voxel1ny) - static_cast<float>(voxel1py),
43 static_cast<float>(voxel1nz) - static_cast<float>(voxel1pz)
47 template<
typename VolumeType>
50 const int32_t x = volIter.getPosition().getX();
51 const int32_t y = volIter.getPosition().getY();
52 const int32_t z = volIter.getPosition().getZ();
55 typename VolumeType::VoxelType voxel1nx = volIter.getVoxelAt(x-2, y ,z ) > 0 ? 1: 0;
56 typename VolumeType::VoxelType voxel1px = volIter.getVoxelAt(x-2, y ,z ) > 0 ? 1: 0;
58 typename VolumeType::VoxelType voxel1ny = volIter.getVoxelAt(x , y-2,z ) > 0 ? 1: 0;
59 typename VolumeType::VoxelType voxel1py = volIter.getVoxelAt(x , y-2,z ) > 0 ? 1: 0;
61 typename VolumeType::VoxelType voxel1nz = volIter.getVoxelAt(x , y ,z-2) > 0 ? 1: 0;
62 typename VolumeType::VoxelType voxel1pz = volIter.getVoxelAt(x , y ,z-2) > 0 ? 1: 0;
66 static_cast<float>(voxel1nx) - static_cast<float>(voxel1px),
67 static_cast<float>(voxel1ny) - static_cast<float>(voxel1py),
68 static_cast<float>(voxel1nz) - static_cast<float>(voxel1pz)
72 template<
typename VolumeType>
75 int32_t initialX = volIter.getPosition().getX();
76 int32_t initialY = volIter.getPosition().getY();
77 int32_t initialZ = volIter.getPosition().getZ();
80 volIter.setPosition(initialX-1, initialY, initialZ);
82 volIter.setPosition(initialX+1, initialY, initialZ);
85 volIter.setPosition(initialX, initialY-1, initialZ);
87 volIter.setPosition(initialX, initialY+1, initialZ);
90 volIter.setPosition(initialX, initialY, initialZ-1);
92 volIter.setPosition(initialX, initialY, initialZ+1);
103 template<
typename VolumeType>
106 static const int weights[3][3][3] = { { {2,3,2}, {3,6,3}, {2,3,2} }, {
107 {3,6,3}, {6,0,6}, {3,6,3} }, { {2,3,2}, {3,6,3}, {2,3,2} } };
109 const typename VolumeType::VoxelType pVoxel1nx1ny1nz = volIter.peekVoxel1nx1ny1nz() > 0 ? 1: 0;
110 const typename VolumeType::VoxelType pVoxel1nx1ny0pz = volIter.peekVoxel1nx1ny0pz() > 0 ? 1: 0;
111 const typename VolumeType::VoxelType pVoxel1nx1ny1pz = volIter.peekVoxel1nx1ny1pz() > 0 ? 1: 0;
112 const typename VolumeType::VoxelType pVoxel1nx0py1nz = volIter.peekVoxel1nx0py1nz() > 0 ? 1: 0;
113 const typename VolumeType::VoxelType pVoxel1nx0py0pz = volIter.peekVoxel1nx0py0pz() > 0 ? 1: 0;
114 const typename VolumeType::VoxelType pVoxel1nx0py1pz = volIter.peekVoxel1nx0py1pz() > 0 ? 1: 0;
115 const typename VolumeType::VoxelType pVoxel1nx1py1nz = volIter.peekVoxel1nx1py1nz() > 0 ? 1: 0;
116 const typename VolumeType::VoxelType pVoxel1nx1py0pz = volIter.peekVoxel1nx1py0pz() > 0 ? 1: 0;
117 const typename VolumeType::VoxelType pVoxel1nx1py1pz = volIter.peekVoxel1nx1py1pz() > 0 ? 1: 0;
119 const typename VolumeType::VoxelType pVoxel0px1ny1nz = volIter.peekVoxel0px1ny1nz() > 0 ? 1: 0;
120 const typename VolumeType::VoxelType pVoxel0px1ny0pz = volIter.peekVoxel0px1ny0pz() > 0 ? 1: 0;
121 const typename VolumeType::VoxelType pVoxel0px1ny1pz = volIter.peekVoxel0px1ny1pz() > 0 ? 1: 0;
122 const typename VolumeType::VoxelType pVoxel0px0py1nz = volIter.peekVoxel0px0py1nz() > 0 ? 1: 0;
124 const typename VolumeType::VoxelType pVoxel0px0py1pz = volIter.peekVoxel0px0py1pz() > 0 ? 1: 0;
125 const typename VolumeType::VoxelType pVoxel0px1py1nz = volIter.peekVoxel0px1py1nz() > 0 ? 1: 0;
126 const typename VolumeType::VoxelType pVoxel0px1py0pz = volIter.peekVoxel0px1py0pz() > 0 ? 1: 0;
127 const typename VolumeType::VoxelType pVoxel0px1py1pz = volIter.peekVoxel0px1py1pz() > 0 ? 1: 0;
129 const typename VolumeType::VoxelType pVoxel1px1ny1nz = volIter.peekVoxel1px1ny1nz() > 0 ? 1: 0;
130 const typename VolumeType::VoxelType pVoxel1px1ny0pz = volIter.peekVoxel1px1ny0pz() > 0 ? 1: 0;
131 const typename VolumeType::VoxelType pVoxel1px1ny1pz = volIter.peekVoxel1px1ny1pz() > 0 ? 1: 0;
132 const typename VolumeType::VoxelType pVoxel1px0py1nz = volIter.peekVoxel1px0py1nz() > 0 ? 1: 0;
133 const typename VolumeType::VoxelType pVoxel1px0py0pz = volIter.peekVoxel1px0py0pz() > 0 ? 1: 0;
134 const typename VolumeType::VoxelType pVoxel1px0py1pz = volIter.peekVoxel1px0py1pz() > 0 ? 1: 0;
135 const typename VolumeType::VoxelType pVoxel1px1py1nz = volIter.peekVoxel1px1py1nz() > 0 ? 1: 0;
136 const typename VolumeType::VoxelType pVoxel1px1py0pz = volIter.peekVoxel1px1py0pz() > 0 ? 1: 0;
137 const typename VolumeType::VoxelType pVoxel1px1py1pz = volIter.peekVoxel1px1py1pz() > 0 ? 1: 0;
139 const int xGrad(- weights[0][0][0] * pVoxel1nx1ny1nz -
140 weights[1][0][0] * pVoxel1nx1ny0pz - weights[2][0][0] *
141 pVoxel1nx1ny1pz - weights[0][1][0] * pVoxel1nx0py1nz -
142 weights[1][1][0] * pVoxel1nx0py0pz - weights[2][1][0] *
143 pVoxel1nx0py1pz - weights[0][2][0] * pVoxel1nx1py1nz -
144 weights[1][2][0] * pVoxel1nx1py0pz - weights[2][2][0] *
145 pVoxel1nx1py1pz + weights[0][0][2] * pVoxel1px1ny1nz +
146 weights[1][0][2] * pVoxel1px1ny0pz + weights[2][0][2] *
147 pVoxel1px1ny1pz + weights[0][1][2] * pVoxel1px0py1nz +
148 weights[1][1][2] * pVoxel1px0py0pz + weights[2][1][2] *
149 pVoxel1px0py1pz + weights[0][2][2] * pVoxel1px1py1nz +
150 weights[1][2][2] * pVoxel1px1py0pz + weights[2][2][2] *
153 const int yGrad(- weights[0][0][0] * pVoxel1nx1ny1nz -
154 weights[1][0][0] * pVoxel1nx1ny0pz - weights[2][0][0] *
155 pVoxel1nx1ny1pz + weights[0][2][0] * pVoxel1nx1py1nz +
156 weights[1][2][0] * pVoxel1nx1py0pz + weights[2][2][0] *
157 pVoxel1nx1py1pz - weights[0][0][1] * pVoxel0px1ny1nz -
158 weights[1][0][1] * pVoxel0px1ny0pz - weights[2][0][1] *
159 pVoxel0px1ny1pz + weights[0][2][1] * pVoxel0px1py1nz +
160 weights[1][2][1] * pVoxel0px1py0pz + weights[2][2][1] *
161 pVoxel0px1py1pz - weights[0][0][2] * pVoxel1px1ny1nz -
162 weights[1][0][2] * pVoxel1px1ny0pz - weights[2][0][2] *
163 pVoxel1px1ny1pz + weights[0][2][2] * pVoxel1px1py1nz +
164 weights[1][2][2] * pVoxel1px1py0pz + weights[2][2][2] *
167 const int zGrad(- weights[0][0][0] * pVoxel1nx1ny1nz +
168 weights[2][0][0] * pVoxel1nx1ny1pz - weights[0][1][0] *
169 pVoxel1nx0py1nz + weights[2][1][0] * pVoxel1nx0py1pz -
170 weights[0][2][0] * pVoxel1nx1py1nz + weights[2][2][0] *
171 pVoxel1nx1py1pz - weights[0][0][1] * pVoxel0px1ny1nz +
172 weights[2][0][1] * pVoxel0px1ny1pz - weights[0][1][1] *
173 pVoxel0px0py1nz + weights[2][1][1] * pVoxel0px0py1pz -
174 weights[0][2][1] * pVoxel0px1py1nz + weights[2][2][1] *
175 pVoxel0px1py1pz - weights[0][0][2] * pVoxel1px1ny1nz +
176 weights[2][0][2] * pVoxel1px1ny1pz - weights[0][1][2] *
177 pVoxel1px0py1nz + weights[2][1][2] * pVoxel1px0py1pz -
178 weights[0][2][2] * pVoxel1px1py1nz + weights[2][2][2] *
183 return Vector3DFloat(static_cast<float>(-xGrad),static_cast<float>(-yGrad),static_cast<float>(-zGrad));
186 template<
typename VolumeType>
189 static const int weights[3][3][3] = { { {2,3,2}, {3,6,3}, {2,3,2} }, {
190 {3,6,3}, {6,0,6}, {3,6,3} }, { {2,3,2}, {3,6,3}, {2,3,2} } };
192 int32_t initialX = volIter.getPosition().getX();
193 int32_t initialY = volIter.getPosition().getY();
194 int32_t initialZ = volIter.getPosition().getZ();
196 volIter.setPosition(initialX-1, initialY-1, initialZ-1);
const float pVoxel1nx1ny1nz =
computeSmoothedVoxel(volIter);
197 volIter.setPosition(initialX-1, initialY-1, initialZ );
const float pVoxel1nx1ny0pz =
computeSmoothedVoxel(volIter);
198 volIter.setPosition(initialX-1, initialY-1, initialZ+1);
const float pVoxel1nx1ny1pz =
computeSmoothedVoxel(volIter);
199 volIter.setPosition(initialX-1, initialY , initialZ-1);
const float pVoxel1nx0py1nz =
computeSmoothedVoxel(volIter);
200 volIter.setPosition(initialX-1, initialY , initialZ );
const float pVoxel1nx0py0pz =
computeSmoothedVoxel(volIter);
201 volIter.setPosition(initialX-1, initialY , initialZ+1);
const float pVoxel1nx0py1pz =
computeSmoothedVoxel(volIter);
202 volIter.setPosition(initialX-1, initialY+1, initialZ-1);
const float pVoxel1nx1py1nz =
computeSmoothedVoxel(volIter);
203 volIter.setPosition(initialX-1, initialY+1, initialZ );
const float pVoxel1nx1py0pz =
computeSmoothedVoxel(volIter);
204 volIter.setPosition(initialX-1, initialY+1, initialZ+1);
const float pVoxel1nx1py1pz =
computeSmoothedVoxel(volIter);
206 volIter.setPosition(initialX , initialY-1, initialZ-1);
const float pVoxel0px1ny1nz =
computeSmoothedVoxel(volIter);
207 volIter.setPosition(initialX , initialY-1, initialZ );
const float pVoxel0px1ny0pz =
computeSmoothedVoxel(volIter);
208 volIter.setPosition(initialX , initialY-1, initialZ+1);
const float pVoxel0px1ny1pz =
computeSmoothedVoxel(volIter);
209 volIter.setPosition(initialX , initialY , initialZ-1);
const float pVoxel0px0py1nz =
computeSmoothedVoxel(volIter);
211 volIter.setPosition(initialX , initialY , initialZ+1);
const float pVoxel0px0py1pz =
computeSmoothedVoxel(volIter);
212 volIter.setPosition(initialX , initialY+1, initialZ-1);
const float pVoxel0px1py1nz =
computeSmoothedVoxel(volIter);
213 volIter.setPosition(initialX , initialY+1, initialZ );
const float pVoxel0px1py0pz =
computeSmoothedVoxel(volIter);
214 volIter.setPosition(initialX , initialY+1, initialZ+1);
const float pVoxel0px1py1pz =
computeSmoothedVoxel(volIter);
216 volIter.setPosition(initialX+1, initialY-1, initialZ-1);
const float pVoxel1px1ny1nz =
computeSmoothedVoxel(volIter);
217 volIter.setPosition(initialX+1, initialY-1, initialZ );
const float pVoxel1px1ny0pz =
computeSmoothedVoxel(volIter);
218 volIter.setPosition(initialX+1, initialY-1, initialZ+1);
const float pVoxel1px1ny1pz =
computeSmoothedVoxel(volIter);
219 volIter.setPosition(initialX+1, initialY , initialZ-1);
const float pVoxel1px0py1nz =
computeSmoothedVoxel(volIter);
220 volIter.setPosition(initialX+1, initialY , initialZ );
const float pVoxel1px0py0pz =
computeSmoothedVoxel(volIter);
221 volIter.setPosition(initialX+1, initialY , initialZ+1);
const float pVoxel1px0py1pz =
computeSmoothedVoxel(volIter);
222 volIter.setPosition(initialX+1, initialY+1, initialZ-1);
const float pVoxel1px1py1nz =
computeSmoothedVoxel(volIter);
223 volIter.setPosition(initialX+1, initialY+1, initialZ );
const float pVoxel1px1py0pz =
computeSmoothedVoxel(volIter);
224 volIter.setPosition(initialX+1, initialY+1, initialZ+1);
const float pVoxel1px1py1pz =
computeSmoothedVoxel(volIter);
256 const float xGrad(- weights[0][0][0] * pVoxel1nx1ny1nz -
257 weights[1][0][0] * pVoxel1nx1ny0pz - weights[2][0][0] *
258 pVoxel1nx1ny1pz - weights[0][1][0] * pVoxel1nx0py1nz -
259 weights[1][1][0] * pVoxel1nx0py0pz - weights[2][1][0] *
260 pVoxel1nx0py1pz - weights[0][2][0] * pVoxel1nx1py1nz -
261 weights[1][2][0] * pVoxel1nx1py0pz - weights[2][2][0] *
262 pVoxel1nx1py1pz + weights[0][0][2] * pVoxel1px1ny1nz +
263 weights[1][0][2] * pVoxel1px1ny0pz + weights[2][0][2] *
264 pVoxel1px1ny1pz + weights[0][1][2] * pVoxel1px0py1nz +
265 weights[1][1][2] * pVoxel1px0py0pz + weights[2][1][2] *
266 pVoxel1px0py1pz + weights[0][2][2] * pVoxel1px1py1nz +
267 weights[1][2][2] * pVoxel1px1py0pz + weights[2][2][2] *
270 const float yGrad(- weights[0][0][0] * pVoxel1nx1ny1nz -
271 weights[1][0][0] * pVoxel1nx1ny0pz - weights[2][0][0] *
272 pVoxel1nx1ny1pz + weights[0][2][0] * pVoxel1nx1py1nz +
273 weights[1][2][0] * pVoxel1nx1py0pz + weights[2][2][0] *
274 pVoxel1nx1py1pz - weights[0][0][1] * pVoxel0px1ny1nz -
275 weights[1][0][1] * pVoxel0px1ny0pz - weights[2][0][1] *
276 pVoxel0px1ny1pz + weights[0][2][1] * pVoxel0px1py1nz +
277 weights[1][2][1] * pVoxel0px1py0pz + weights[2][2][1] *
278 pVoxel0px1py1pz - weights[0][0][2] * pVoxel1px1ny1nz -
279 weights[1][0][2] * pVoxel1px1ny0pz - weights[2][0][2] *
280 pVoxel1px1ny1pz + weights[0][2][2] * pVoxel1px1py1nz +
281 weights[1][2][2] * pVoxel1px1py0pz + weights[2][2][2] *
284 const float zGrad(- weights[0][0][0] * pVoxel1nx1ny1nz +
285 weights[2][0][0] * pVoxel1nx1ny1pz - weights[0][1][0] *
286 pVoxel1nx0py1nz + weights[2][1][0] * pVoxel1nx0py1pz -
287 weights[0][2][0] * pVoxel1nx1py1nz + weights[2][2][0] *
288 pVoxel1nx1py1pz - weights[0][0][1] * pVoxel0px1ny1nz +
289 weights[2][0][1] * pVoxel0px1ny1pz - weights[0][1][1] *
290 pVoxel0px0py1nz + weights[2][1][1] * pVoxel0px0py1pz -
291 weights[0][2][1] * pVoxel0px1py1nz + weights[2][2][1] *
292 pVoxel0px1py1pz - weights[0][0][2] * pVoxel1px1ny1nz +
293 weights[2][0][2] * pVoxel1px1ny1pz - weights[0][1][2] *
294 pVoxel1px0py1nz + weights[2][1][2] * pVoxel1px0py1pz -
295 weights[0][2][2] * pVoxel1px1py1nz + weights[2][2][2] *