2 * This program is free software: you can redistribute it and/or modify
3 * it under the terms of the GNU Lesser General Public License as
4 * published by the Free Software Foundation, either version 3 of the
5 * License, or (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 * @file Display3DFactory.ih
19 * @author Martial Tola <http://liris.cnrs.fr/martial.tola/>
20 * @date mercredi 21 septembre 2011
24 * Implementation of inline methods defined in Display3DFactory.h
26 * This file is part of the DGtal library.
29 #include "DGtal/helpers/StdDefs.h"
30 #include "DGtal/images/ImageHelper.h"
32 ///////////////////////////////////////////////////////////////////////////////
33 // Implementation of inline methods //
36 ///////////////////////////////////////////////////////////////////////////////
38 ///////////////////////////////////////////////////////////////////////////////
39 // Implementation of inline functions and external operators //
41 // DiscreteExteriorCalculus
42 template <typename Space, typename KSpace>
43 template <DGtal::Dimension dimEmbedded, DGtal::Dimension dimAmbient, typename TLinearAlgebraBackend, typename TInteger>
46 DGtal::Display3DFactory<Space, KSpace>::draw(Display3D<Space, KSpace>& display, const DGtal::DiscreteExteriorCalculus<dimEmbedded, dimAmbient, TLinearAlgebraBackend, TInteger>& calculus)
48 BOOST_STATIC_ASSERT(( dimAmbient == 3 ));
50 typedef DiscreteExteriorCalculus<dimEmbedded, dimAmbient, TLinearAlgebraBackend, TInteger> Calculus;
51 typedef typename Calculus::ConstIterator ConstIterator;
52 typedef typename Calculus::Cell Cell;
53 typedef typename Calculus::SCell SCell;
55 display << DGtal::CustomColors3D(DGtal::Color::Black, DGtal::Color::White);
57 for (ConstIterator ci=calculus.begin(), cie=calculus.end(); ci!=cie; ci++)
59 const Cell& cell = ci->first;
60 const bool& flipped = ci->second.flipped;
61 const SCell displayed_cell = calculus.myKSpace.signs(cell, flipped ? KSpace::NEG : KSpace::POS);
63 display << displayed_cell;
66 // DiscreteExteriorCalculus
69 template <typename Space, typename KSpace>
70 template <typename TCalculus, DGtal::Order order, DGtal::Duality duality>
73 DGtal::Display3DFactory<Space, KSpace>::draw(Display3D<Space, KSpace>& display, const DGtal::KForm<TCalculus, order, duality>& kform, double cmap_min, double cmap_max)
75 typedef typename TCalculus::Scalar Scalar;
76 typedef typename TCalculus::Index Index;
78 if (cmap_min == 0 && cmap_max == 0)
81 for (Index index=0; index<kform.myContainer.rows(); index++)
83 const Scalar value = kform.myContainer(index);
84 if (!std::isfinite(value)) continue;
85 if (first || cmap_min > value) cmap_min = value;
86 if (first || cmap_max < value) cmap_max = value;
91 if (cmap_min == cmap_max) cmap_max += 1;
93 typedef typename DGtal::GradientColorMap<Scalar, DGtal::CMAP_JET> ColorMap;
94 const ColorMap color_map(cmap_min, cmap_max);
96 drawWithColorMap(display, kform, color_map);
99 template <typename Space, typename KSpace>
100 template <typename Calculus, DGtal::Order order, DGtal::Duality duality, typename ColorMap>
103 DGtal::Display3DFactory<Space, KSpace>::drawWithColorMap(Display3D<Space, KSpace>& display, const DGtal::KForm<Calculus, order, duality>& kform, const ColorMap& colormap)
105 BOOST_STATIC_ASSERT(( Calculus::dimensionAmbient == 3 ));
106 ASSERT( kform.myCalculus );
108 typedef typename Calculus::Scalar Scalar;
109 typedef typename Calculus::SCell SCell;
110 typedef typename Calculus::Index Index;
112 for (Index index=0; index<kform.length(); index++)
114 const SCell displayed_cell = kform.getSCell(index);
115 const Scalar displayed_value = kform.myContainer(index);
117 if (std::isfinite(displayed_value)) display << DGtal::CustomColors3D(DGtal::Color::Black, colormap(displayed_value) );
120 display << displayed_cell;
126 template <typename Space, typename KSpace>
127 template <typename Calculus, DGtal::Duality duality>
129 DGtal::Display3DFactory<Space, KSpace>::draw(Display3D<Space, KSpace>& display, const DGtal::VectorField<Calculus, duality>& vector_field, const double& scale, const double& epsilon, const DGtal::Color color)
131 BOOST_STATIC_ASSERT(( Calculus::dimensionAmbient == 3 ));
132 ASSERT( vector_field.myCalculus );
134 typedef typename DGtal::VectorField<Calculus, duality>::Vector Vector;
136 display << DGtal::CustomColors3D(DGtal::Color::Black, color);
138 for (typename Calculus::Index index=0; index<vector_field.length(); index++)
140 const typename Calculus::SCell& cell = vector_field.getSCell(index);
141 const DGtal::Z3i::RealPoint origin = display.sCellEmbedder()(cell);
143 Vector vector = vector_field.getVector(index);
146 if (!std::isfinite(vector[0]) || !std::isfinite(vector[1]) || !std::isfinite(vector[2])) continue;
147 const typename Calculus::Scalar& norm = vector.norm();
148 if (norm <= epsilon) continue;
149 if (norm <= .5) vector *= .5/norm;
151 display.addCone(origin+vector, origin);
156 // SphericalAccumulator
157 template <typename Space, typename KSpace>
158 template <typename TV>
161 DGtal::Display3DFactory<Space,KSpace>::draw( Display & display,
162 const DGtal::SphericalAccumulator<TV> & aAccumulator,
163 const typename DGtal::Z3i::RealVector &shift,
166 DGtal::Color saveFillColor = display.getFillColor();
167 typedef typename DGtal::SphericalAccumulator<TV>::Size Size;
168 typename DGtal::SphericalAccumulator<TV>::RealVector a,b,c,d;
170 DGtal::int32_t m = 1, M=0;
171 for(typename DGtal::SphericalAccumulator<TV>::ConstIterator it = aAccumulator.begin(),
172 itend= aAccumulator.end(); it != itend; ++it)
174 aAccumulator.binCoordinates(it, i,j);
175 if (aAccumulator.isValidBin(i,j))
177 if (aAccumulator.count(i,j) > M) M=aAccumulator.count(i,j);
178 if (aAccumulator.count(i,j) < m) m=aAccumulator.count(i,j);
181 HueShadeColorMap<typename DGtal::SphericalAccumulator<TV>::Quantity> cmap(m,M+1);
183 for(typename DGtal::SphericalAccumulator<TV>::ConstIterator it = aAccumulator.begin(),
184 itend= aAccumulator.end(); it != itend; ++it)
186 aAccumulator.binCoordinates(it, i,j);
187 if (aAccumulator.isValidBin(i,j))
189 aAccumulator.binCoordinates(it, i,j);
190 aAccumulator.getBinGeometry(i,j,a,b,c,d);
200 display.setFillColor(cmap(aAccumulator.count(i,j)));
201 display.addQuad(a, b, c, d);
204 display.setFillColor( saveFillColor);
206 // SphericalAccumulator
211 template <typename Space, typename KSpace>
212 template <typename TPoint>
214 void DGtal::Display3DFactory<Space,KSpace>::draw( Display & display,
215 const DGtal::Mesh<TPoint> & aMesh )
217 std::string mode = display.getMode( aMesh.className() );
218 if ( mode == "Faces" || mode=="")
219 drawAsFaces( display, aMesh );
222 template <typename Space, typename KSpace>
223 template <typename TPoint>
225 void DGtal::Display3DFactory<Space,KSpace>::drawAsFaces( Display & display,
226 const DGtal::Mesh<TPoint> & aMesh )
228 DGtal::Color fillColorSave = display.getFillColor();
229 bool useGlobalColor = !aMesh.isStoringFaceColors();
230 for(unsigned int i=0; i< aMesh.nbFaces(); i++)
232 typename Mesh<TPoint>::MeshFace aFace = aMesh.getFace(i);
233 size_t aNum = aFace.size();
235 display.setFillColor(aMesh.getFaceColor(i));
239 TPoint p1 = aMesh.getVertex(aFace.at(0));
240 TPoint p2 = aMesh.getVertex(aFace.at(1));
241 TPoint p3 = aMesh.getVertex(aFace.at(2));
242 TPoint p4 = aMesh.getVertex(aFace.at(3));
244 display.addQuad(p1, p2, p3, p4);
247 TPoint p1 = aMesh.getVertex(aFace.at(0));
248 TPoint p2 = aMesh.getVertex(aFace.at(1));
249 TPoint p3 = aMesh.getVertex(aFace.at(2));
251 display.addTriangle(p1, p2,p3);
254 std::vector<typename Display::RealPoint> vectPoly;
255 for(unsigned int j=0; j< aFace.size(); j++)
257 typename Display::RealPoint point(aMesh.getVertex(aFace.at(j)));
258 vectPoly.push_back(point);
260 display.addPolygon(vectPoly);
263 trace.warning()<< "Face not valid, only "<< aNum << "vertex... "<< std::endl;
266 display.setFillColor(fillColorSave);
271 // StandardDSS6Computer
272 template <typename Space, typename KSpace>
273 template <typename TIterator, typename TInteger, int connectivity>
275 void DGtal::Display3DFactory<Space,KSpace>::drawAsBalls( Display & display,
276 const DGtal::StandardDSS6Computer<TIterator,TInteger,connectivity> & a )
278 typedef TIterator ConstIterator;
279 typedef typename IteratorCirculatorTraits<ConstIterator>::Value Point3d;
282 display << CustomColors3D( display.getLineColor(), display.getFillColor() );
283 for (ConstIterator i = a.begin(); i != a.end(); ++i)
288 // Draw a linking polygonal line if the voxels are drawn as points.
289 if(display.getMode("PointVector")=="Grid")
291 ConstIterator k = a.begin();
293 DGtal::Z3i::RealPoint rprevp = display.embed( prevp);
295 for ( ; k != a.end(); ++k) {
297 DGtal::Z3i::RealPoint rp = display.embed( p );
299 display.addLine(rprevp,rp);
305 template <typename Space, typename KSpace>
306 template <typename TIterator, typename TInteger, int connectivity>
309 DGtal::Display3DFactory<Space,KSpace>::drawAsBoundingBox( Display & display,
310 const DGtal::StandardDSS6Computer<TIterator,TInteger,connectivity> & a )
313 typedef TIterator ConstIterator;
315 typedef typename IteratorCirculatorTraits<ConstIterator>::Value Point3d;
316 typedef DGtal::PointVector<3,double> PointD3d;
317 typedef typename DGtal::StandardDSS6Computer<TIterator,TInteger,connectivity>::PointR3d PointR3d;
319 typedef typename IteratorCirculatorTraits<ConstIterator>::Value Vector3d;
320 typedef DGtal::PointVector<3,double> VectorD3d;
322 typedef TInteger Integer;
325 Vector3d v; //direction vector
326 PointR3d muR; //intercept
327 PointR3d omegaR; //thickness
328 a.getParameters ( v, muR, omegaR );
331 mu[0] = NumberTraits<Integer>::castToDouble ( muR[0].first ) / NumberTraits<Integer>::castToDouble ( muR[0].second );
332 mu[1] = NumberTraits<Integer>::castToDouble ( muR[1].first ) / NumberTraits<Integer>::castToDouble ( muR[1].second );
333 mu[2] = NumberTraits<Integer>::castToDouble ( muR[2].first ) / NumberTraits<Integer>::castToDouble ( muR[2].second );
336 omega[0] = NumberTraits<Integer>::castToDouble ( omegaR[0].first ) / NumberTraits<Integer>::castToDouble ( omegaR[0].second );
337 omega[1] = NumberTraits<Integer>::castToDouble ( omegaR[1].first ) / NumberTraits<Integer>::castToDouble ( omegaR[1].second );
338 omega[2] = NumberTraits<Integer>::castToDouble ( omegaR[2].first ) / NumberTraits<Integer>::castToDouble ( omegaR[2].second );
340 //casting coordinates of v in double
341 VectorD3d u = VectorD3d(NumberTraits<Integer>::castToDouble(v[0]),
342 NumberTraits<Integer>::castToDouble(v[1]),
343 NumberTraits<Integer>::castToDouble(v[2]) );
345 double n = u[0]*u[0] + u[1]*u[1] + u[2]*u[2];
347 //first and last points
348 Point3d first = *a.begin();
349 Point3d last = *(--a.end());
350 PointD3d f = PointD3d(NumberTraits<Integer>::castToDouble(first[0]),
351 NumberTraits<Integer>::castToDouble(first[1]),
352 NumberTraits<Integer>::castToDouble(first[2]) );
353 PointD3d l = PointD3d(NumberTraits<Integer>::castToDouble(last[0]),
354 NumberTraits<Integer>::castToDouble(last[1]),
355 NumberTraits<Integer>::castToDouble(last[2]) );
359 //last coefficient of the normal plane to the DSS direction
360 //passing trough f and l
361 double df = -u[0]*f[0] -u[1]*f[1] -u[2]*f[2];
362 double dl = -u[0]*l[0] -u[1]*l[1] -u[2]*l[2];
365 PointD3d omega1, omega2;
367 omega1 = PointD3d(0,omega[1],0);
368 omega2 = PointD3d(0,0,omega[2]);
371 omega1 = PointD3d(omega[0],0,0);
372 omega2 = PointD3d(0,0,omega[2]);
373 } else {//omega[2] == 0
374 omega1 = PointD3d(omega[0],0,0);
375 omega2 = PointD3d(0,omega[1],0);
379 double m1 = u[0]*mu[0] + u[1]*mu[1] + u[2]*mu[2];
380 double m2 = u[0]*(mu[0]+omega1[0]) + u[1]*(mu[1]+omega1[1]) + u[2]*(mu[2]+omega1[2]);
381 double m3 = u[0]*(mu[0]+omega2[0]) + u[1]*(mu[1]+omega2[1]) + u[2]*(mu[2]+omega2[2]);
382 double m4 = u[0]*(mu[0]+omega[0]) + u[1]*(mu[1]+omega[1]) + u[2]*(mu[2]+omega[2]);
385 PointD3d pf = PointD3d( mu[0] - ( (m1+df)*u[0] )/n,
386 mu[1] - ( (m1+df)*u[1] )/n,
387 mu[2] - ( (m1+df)*u[2] )/n );
388 PointD3d pl = PointD3d( mu[0] - ( (m1+dl)*u[0] )/n,
389 mu[1] - ( (m1+dl)*u[1] )/n,
390 mu[2] - ( (m1+dl)*u[2] )/n );
392 display.addLine(pf, pl);
394 PointD3d pf2 = PointD3d((mu[0]+omega1[0]) - ( (m2+df)*u[0] )/n,
395 (mu[1]+omega1[1]) - ( (m2+df)*u[1] )/n,
396 (mu[2]+omega1[2]) - ( (m2+df)*u[2] )/n );
397 PointD3d pl2 = PointD3d((mu[0]+omega1[0]) - ( (m2+dl)*u[0] )/n,
398 (mu[1]+omega1[1]) - ( (m2+dl)*u[1] )/n,
399 (mu[2]+omega1[2]) - ( (m2+dl)*u[2] )/n );
401 display.addLine(pf2, pl2);
403 PointD3d pf3 = PointD3d((mu[0]+omega2[0]) - ( (m3+df)*u[0] )/n,
404 (mu[1]+omega2[1]) - ( (m3+df)*u[1] )/n,
405 (mu[2]+omega2[2]) - ( (m3+df)*u[2] )/n );
406 PointD3d pl3 = PointD3d((mu[0]+omega2[0]) - ( (m3+dl)*u[0] )/n,
407 (mu[1]+omega2[1]) - ( (m3+dl)*u[1] )/n,
408 (mu[2]+omega2[2]) - ( (m3+dl)*u[2] )/n );
410 display.addLine(pf3, pl3);
412 PointD3d pf4 = PointD3d((mu[0]+omega[0]) - ( (m4+df)*u[0] )/n,
413 (mu[1]+omega[1]) - ( (m4+df)*u[1] )/n,
414 (mu[2]+omega[2]) - ( (m4+df)*u[2] )/n );
415 PointD3d pl4 = PointD3d((mu[0]+omega[0]) - ( (m4+dl)*u[0] )/n,
416 (mu[1]+omega[1]) - ( (m4+dl)*u[1] )/n,
417 (mu[2]+omega[2]) - ( (m4+dl)*u[2] )/n );
419 display.addLine(pf4, pl4);
422 display.addLine(pf, pf2);
423 display.addLine(pf2,pf4);
424 display.addLine(pf4, pf3);
425 display.addLine(pf3, pf);
427 display.addLine(pl, pl2);
428 display.addLine(pl2, pl4);
429 display.addLine(pl4, pl3);
430 display.addLine(pl3, pl);
434 template <typename Space, typename KSpace>
435 template <typename TIterator, typename TInteger, int connectivity>
437 void DGtal::Display3DFactory<Space,KSpace>::draw( Display & display,
438 const DGtal::StandardDSS6Computer<TIterator,TInteger,connectivity> & a )
440 std::string mode = display.getMode( a.className() );
441 if ( mode == "BoundingBox" )
442 drawAsBoundingBox( display, a );
443 else if ( mode == "Points" )
444 drawAsBalls( display, a );
445 else if ( ( mode == "" ) )
447 drawAsBalls( display, a );
450 // StandardDSS6Computer
453 // Naive3DDSSComputer
455 template <typename Space, typename KSpace>
456 template <typename TIterator, typename TInteger, int connectivity>
458 void DGtal::Display3DFactory<Space,KSpace>::drawAsBalls( Display & display,
459 const DGtal::Naive3DDSSComputer<TIterator,TInteger,connectivity> & a )
461 typedef TIterator ConstIterator;
462 typedef typename IteratorCirculatorTraits<ConstIterator>::Value Point3d;
465 display << CustomColors3D( display.getLineColor(), display.getFillColor() );
466 for (ConstIterator it = a.begin(); it != a.end(); ++it)
471 // Draw a linking polygonal line if the voxels are drawn as points.
472 if(display.getMode("PointVector")=="Grid")
474 ConstIterator it = a.begin();
476 DGtal::Z3i::RealPoint rprevp = display.embed( prevp);
478 for ( ; it != a.end(); ++it) {
480 DGtal::Z3i::RealPoint rp = display.embed( p );
482 display.addLine(rprevp,rp);
488 template <typename Space, typename KSpace>
489 template <typename TIterator, typename TInteger, int connectivity>
492 DGtal::Display3DFactory<Space,KSpace>::drawAsBoundingBox( Display & display,
493 const DGtal::Naive3DDSSComputer<TIterator,TInteger,connectivity> & a )
496 typedef TIterator ConstIterator;
498 typedef typename IteratorCirculatorTraits<ConstIterator>::Value Point3d;
499 typedef DGtal::PointVector<3,double> PointD3d;
500 typedef typename DGtal::Naive3DDSSComputer<TIterator,TInteger,connectivity>::PointR3d PointR3d;
502 typedef typename IteratorCirculatorTraits<ConstIterator>::Value Vector3d;
503 typedef DGtal::PointVector<3,double> VectorD3d;
505 typedef TInteger Integer;
508 Vector3d v; //direction vector
509 PointR3d muR; //intercept
510 PointR3d omegaR; //thickness
511 a.getParameters ( v, muR, omegaR );
514 mu[0] = NumberTraits<Integer>::castToDouble ( muR[0].first ) / NumberTraits<Integer>::castToDouble ( muR[0].second );
515 mu[1] = NumberTraits<Integer>::castToDouble ( muR[1].first ) / NumberTraits<Integer>::castToDouble ( muR[1].second );
516 mu[2] = NumberTraits<Integer>::castToDouble ( muR[2].first ) / NumberTraits<Integer>::castToDouble ( muR[2].second );
519 omega[0] = NumberTraits<Integer>::castToDouble ( omegaR[0].first ) / NumberTraits<Integer>::castToDouble ( omegaR[0].second );
520 omega[1] = NumberTraits<Integer>::castToDouble ( omegaR[1].first ) / NumberTraits<Integer>::castToDouble ( omegaR[1].second );
521 omega[2] = NumberTraits<Integer>::castToDouble ( omegaR[2].first ) / NumberTraits<Integer>::castToDouble ( omegaR[2].second );
523 //casting coordinates of v in double
524 VectorD3d u = VectorD3d(NumberTraits<Integer>::castToDouble(v[0]),
525 NumberTraits<Integer>::castToDouble(v[1]),
526 NumberTraits<Integer>::castToDouble(v[2]) );
527 //Squared L2 norm of u
528 double n = u[0]*u[0] + u[1]*u[1] + u[2]*u[2];
530 //first and last points
531 Point3d first = *a.begin();
532 Point3d last = *(--a.end());
533 PointD3d f = PointD3d(NumberTraits<Integer>::castToDouble(first[0]),
534 NumberTraits<Integer>::castToDouble(first[1]),
535 NumberTraits<Integer>::castToDouble(first[2]) );
536 PointD3d l = PointD3d(NumberTraits<Integer>::castToDouble(last[0]),
537 NumberTraits<Integer>::castToDouble(last[1]),
538 NumberTraits<Integer>::castToDouble(last[2]) );
542 //last coefficient of the normal plane to the DSS direction
543 //passing trough f and l
544 double df = -u[0]*f[0] -u[1]*f[1] -u[2]*f[2];
545 double dl = -u[0]*l[0] -u[1]*l[1] -u[2]*l[2];
548 PointD3d omega1, omega2;
550 omega1 = PointD3d(0,omega[1],0);
551 omega2 = PointD3d(0,0,omega[2]);
554 omega1 = PointD3d(omega[0],0,0);
555 omega2 = PointD3d(0,0,omega[2]);
556 } else {//omega[2] == 0
557 omega1 = PointD3d(omega[0],0,0);
558 omega2 = PointD3d(0,omega[1],0);
562 double m1 = u[0]*mu[0] + u[1]*mu[1] + u[2]*mu[2];
563 double m2 = u[0]*(mu[0]+omega1[0]) + u[1]*(mu[1]+omega1[1]) + u[2]*(mu[2]+omega1[2]);
564 double m3 = u[0]*(mu[0]+omega2[0]) + u[1]*(mu[1]+omega2[1]) + u[2]*(mu[2]+omega2[2]);
565 double m4 = u[0]*(mu[0]+omega[0]) + u[1]*(mu[1]+omega[1]) + u[2]*(mu[2]+omega[2]);
568 PointD3d pf = PointD3d( mu[0] - ( (m1+df)*u[0] )/n,
569 mu[1] - ( (m1+df)*u[1] )/n,
570 mu[2] - ( (m1+df)*u[2] )/n );
571 PointD3d pl = PointD3d( mu[0] - ( (m1+dl)*u[0] )/n,
572 mu[1] - ( (m1+dl)*u[1] )/n,
573 mu[2] - ( (m1+dl)*u[2] )/n );
575 display.addLine(pf, pl);
577 PointD3d pf2 = PointD3d((mu[0]+omega1[0]) - ( (m2+df)*u[0] )/n,
578 (mu[1]+omega1[1]) - ( (m2+df)*u[1] )/n,
579 (mu[2]+omega1[2]) - ( (m2+df)*u[2] )/n );
580 PointD3d pl2 = PointD3d((mu[0]+omega1[0]) - ( (m2+dl)*u[0] )/n,
581 (mu[1]+omega1[1]) - ( (m2+dl)*u[1] )/n,
582 (mu[2]+omega1[2]) - ( (m2+dl)*u[2] )/n );
584 display.addLine(pf2, pl2);
586 PointD3d pf3 = PointD3d((mu[0]+omega2[0]) - ( (m3+df)*u[0] )/n,
587 (mu[1]+omega2[1]) - ( (m3+df)*u[1] )/n,
588 (mu[2]+omega2[2]) - ( (m3+df)*u[2] )/n );
589 PointD3d pl3 = PointD3d((mu[0]+omega2[0]) - ( (m3+dl)*u[0] )/n,
590 (mu[1]+omega2[1]) - ( (m3+dl)*u[1] )/n,
591 (mu[2]+omega2[2]) - ( (m3+dl)*u[2] )/n );
593 display.addLine(pf3, pl3);
595 PointD3d pf4 = PointD3d((mu[0]+omega[0]) - ( (m4+df)*u[0] )/n,
596 (mu[1]+omega[1]) - ( (m4+df)*u[1] )/n,
597 (mu[2]+omega[2]) - ( (m4+df)*u[2] )/n );
598 PointD3d pl4 = PointD3d((mu[0]+omega[0]) - ( (m4+dl)*u[0] )/n,
599 (mu[1]+omega[1]) - ( (m4+dl)*u[1] )/n,
600 (mu[2]+omega[2]) - ( (m4+dl)*u[2] )/n );
602 display.addLine(pf4, pl4);
605 display.addLine(pf, pf2);
606 display.addLine(pf2,pf4);
607 display.addLine(pf4, pf3);
608 display.addLine(pf3, pf);
610 display.addLine(pl, pl2);
611 display.addLine(pl2, pl4);
612 display.addLine(pl4, pl3);
613 display.addLine(pl3, pl);
617 template <typename Space, typename KSpace>
618 template <typename TIterator, typename TInteger, int connectivity>
620 void DGtal::Display3DFactory<Space,KSpace>::draw( Display & display,
621 const DGtal::Naive3DDSSComputer<TIterator,TInteger,connectivity> & a )
623 std::string mode = display.getMode( a.className() );
624 if ( mode == "BoundingBox" )
625 drawAsBoundingBox( display, a );
626 else if ( mode == "Points" )
627 drawAsBalls( display, a );
628 else if ( ( mode == "" ) )
630 drawAsBalls( display, a );
633 // Naive3DDSSComputer
636 // DigitalSetBySTLSet
637 template <typename Space, typename KSpace>
638 template<typename Domain, typename Compare>
640 void DGtal::Display3DFactory<Space,KSpace>::drawAsPavingTransparent( Display & display,
641 const DGtal::DigitalSetBySTLSet<Domain, Compare> & s )
643 typedef typename Domain::Point Point;
644 typedef typename std::set<Point>::const_iterator ConstIterator;
646 ASSERT(Domain::Space::dimension == 3);
648 display.createNewCubeList();
649 for ( ConstIterator it = s.begin();
653 DGtal::Z3i::RealPoint rp = display.embed((*it) );
658 template <typename Space, typename KSpace>
659 template<typename Domain, typename Compare>
661 void DGtal::Display3DFactory<Space,KSpace>::drawAsPaving( Display & display,
662 const DGtal::DigitalSetBySTLSet<Domain, Compare> & s )
664 typedef typename DGtal::DigitalSetBySTLSet<Domain, Compare>::ConstIterator ConstIterator;
666 ASSERT(Domain::Space::dimension == 3);
668 display.createNewCubeList( );
669 for ( ConstIterator it = s.begin();
673 DGtal::Z3i::RealPoint rp = display.embed((*it) );
678 template <typename Space, typename KSpace>
679 template<typename Domain, typename Compare>
681 void DGtal::Display3DFactory<Space,KSpace>::drawAsGrid( Display & display,
682 const DGtal::DigitalSetBySTLSet<Domain, Compare> & s )
684 typedef typename DGtal::DigitalSetBySTLSet<Domain, Compare>::ConstIterator ConstIterator;
686 ASSERT(Domain::Space::dimension == 3);
688 for ( ConstIterator it = s.begin();
692 DGtal::Z3i::RealPoint rp = display.embed((*it) );
693 display.addBall(rp,1.0/static_cast<double>( POINT_AS_BALL_RADIUS), POINT_AS_BALL_RES);
697 template <typename Space, typename KSpace>
698 template<typename Domain, typename Compare>
700 void DGtal::Display3DFactory<Space,KSpace>::draw( Display & display,
701 const DGtal::DigitalSetBySTLSet<Domain, Compare> & s )
703 ASSERT(Domain::Space::dimension == 3);
705 std::string mode = display.getMode( s.className() );
706 ASSERT( (mode=="Paving" || mode=="PavingTransp" || mode=="Grid" || mode=="Both" || mode=="") );
708 if ( mode == "Paving" || ( mode == "" ) )
709 drawAsPaving( display, s );
710 else if ( mode == "PavingTransp" )
711 drawAsPavingTransparent( display, s );
712 else if ( mode == "Grid" )
713 drawAsGrid( display, s );
714 else if ( ( mode == "Both" ) )
716 drawAsPaving( display, s );
717 drawAsGrid( display, s );
720 // DigitalSetBySTLSet
723 // DigitalSetByAssociativeContainer
724 template <typename Space, typename KSpace>
725 template<typename Domain, typename Container>
727 void DGtal::Display3DFactory<Space,KSpace>::drawAsPavingTransparent( Display & display,
728 const DGtal::DigitalSetByAssociativeContainer<Domain, Container> & s )
730 typedef typename DGtal::DigitalSetByAssociativeContainer<Domain, Container>::ConstIterator ConstIterator;
732 ASSERT(Domain::Space::dimension == 3);
734 display.createNewCubeList( );
735 for ( ConstIterator it = s.begin();
739 DGtal::Z3i::RealPoint rp = display.embed((*it) );
744 template <typename Space, typename KSpace>
745 template<typename Domain, typename Container>
747 void DGtal::Display3DFactory<Space,KSpace>::drawAsPaving( Display & display,
748 const DGtal::DigitalSetByAssociativeContainer<Domain, Container> & s )
750 typedef typename DGtal::DigitalSetByAssociativeContainer<Domain, Container>::ConstIterator ConstIterator;
752 ASSERT(Domain::Space::dimension == 3);
754 display.createNewCubeList( );
755 for ( ConstIterator it = s.begin();
759 DGtal::Z3i::RealPoint rp = display.embed((*it) );
764 template <typename Space, typename KSpace>
765 template<typename Domain, typename Container>
767 void DGtal::Display3DFactory<Space,KSpace>::drawAsGrid( Display & display,
768 const DGtal::DigitalSetByAssociativeContainer<Domain, Container> & s )
770 typedef typename DGtal::DigitalSetByAssociativeContainer<Domain, Container>::ConstIterator ConstIterator;
773 ASSERT(Domain::Space::dimension == 3);
775 for ( ConstIterator it = s.begin();
779 DGtal::Z3i::RealPoint rp = display.embed((*it) );
780 display.addBall(rp,1.0/static_cast<double>( POINT_AS_BALL_RADIUS), POINT_AS_BALL_RES);
784 template <typename Space, typename KSpace>
785 template<typename Domain, typename Container>
787 void DGtal::Display3DFactory<Space,KSpace>::draw( Display & display,
788 const DGtal::DigitalSetByAssociativeContainer<Domain, Container> & s )
790 ASSERT(Domain::Space::dimension == 3);
792 std::string mode = display.getMode( s.className() );
793 ASSERT( (mode=="Paving" || mode=="PavingTransp" || mode=="Grid" || mode=="Both" || mode=="") );
795 if ( mode == "Paving" || ( mode == "" ) )
796 drawAsPaving( display, s );
797 else if ( mode == "PavingTransp" )
798 drawAsPavingTransparent( display, s );
799 else if ( mode == "Grid" )
800 drawAsGrid( display, s );
801 else if ( ( mode == "Both" ) )
803 drawAsPaving( display, s );
804 drawAsGrid( display, s );
807 // DigitalSetByAssociativeContainer
810 // DigitalSetBySTLVector
811 template <typename Space, typename KSpace>
812 template<typename Domain>
814 void DGtal::Display3DFactory<Space,KSpace>::drawAsPavingTransparent( Display & display,
815 const DGtal::DigitalSetBySTLVector<Domain> & v )
817 typedef typename Domain::Point Point;
818 typedef typename std::vector<Point>::const_iterator ConstIterator;
820 ASSERT(Domain::Space::dimension == 3);
822 display.createNewCubeList( );
823 for ( ConstIterator it = v.begin();
827 DGtal::Z3i::RealPoint rp = display.embed((*it) );
832 template <typename Space, typename KSpace>
833 template<typename Domain>
835 void DGtal::Display3DFactory<Space,KSpace>::drawAsPaving( Display & display,
836 const DGtal::DigitalSetBySTLVector<Domain> & v )
838 typedef typename Domain::Point Point;
839 typedef typename std::vector<Point>::const_iterator ConstIterator;
841 ASSERT(Domain::Space::dimension == 3);
843 display.createNewCubeList( );
844 for ( ConstIterator it = v.begin();
848 DGtal::Z3i::RealPoint rp = display.embed((*it) );
853 template <typename Space, typename KSpace>
854 template<typename Domain>
856 void DGtal::Display3DFactory<Space,KSpace>::drawAsGrid( Display & display,
857 const DGtal::DigitalSetBySTLVector<Domain> & v )
859 typedef typename Domain::Point Point;
860 typedef typename std::vector<Point>::const_iterator ConstIterator;
862 ASSERT(Domain::Space::dimension == 3);
864 for ( ConstIterator it = v.begin();
868 DGtal::Z3i::RealPoint rp = display.embed((*it) );
869 display.addBall(rp,1.0/static_cast<double>( POINT_AS_BALL_RADIUS), POINT_AS_BALL_RES);
873 template <typename Space, typename KSpace>
874 template<typename Domain>
876 void DGtal::Display3DFactory<Space,KSpace>::draw( Display & display,
877 const DGtal::DigitalSetBySTLVector<Domain> & v )
879 ASSERT(Domain::Space::dimension == 3);
881 std::string mode = display.getMode( v.className() );
882 ASSERT( (mode=="Paving" || mode=="PavingTransp" || mode=="Grid" || mode=="Both" || mode=="") );
884 if ( mode == "Paving" || ( mode == "" ) )
885 drawAsPaving( display, v );
886 else if ( mode == "PavingTransp" )
887 drawAsPavingTransparent( display, v );
888 else if ( mode == "Grid" )
889 drawAsGrid( display, v );
890 else if ( ( mode == "Both" ) )
892 drawAsPaving( display, v);
893 drawAsGrid( display, v );
896 // DigitalSetBySTLVector
900 template <typename Space, typename KSpace>
901 template <typename SpaceDom>
903 void DGtal::Display3DFactory<Space,KSpace>::drawAsBoundingBox( Display & display,
904 const DGtal::HyperRectDomain<SpaceDom> & h )
906 DGtal::Color fillColorSave = display.getFillColor();
907 ASSERT(Space::dimension == 2 || Space::dimension == 3 || "drawAsBoundingBox-NOT-YET-IMPLEMENTED-in-ND");
909 DGtal::Z3i::RealPoint upperBound;
910 DGtal::Z3i::RealPoint lowerBound;
912 if (SpaceDom::dimension == 3)
914 upperBound = display.embed( DGtal::Z3i::Point(h.myUpperBound[0], h.myUpperBound[1], h.myUpperBound[2]));
915 lowerBound = display.embed( DGtal::Z3i::Point(h.myLowerBound[0], h.myLowerBound[1], h.myLowerBound[2]));
917 if (SpaceDom::dimension == 2)
919 upperBound = display.embed( DGtal::Z3i::Point(h.myUpperBound[0], h.myUpperBound[1], 0));
920 lowerBound = display.embed( DGtal::Z3i::Point(h.myLowerBound[0], h.myLowerBound[1], 0));
924 display.setFillColor(DGtal::Color(250,250,250,10));
925 double shiftSize=0.01;
926 if (SpaceDom::dimension == 3)
929 display.addQuad(DGtal::Z3i::RealPoint(upperBound[0]+(0.5+shiftSize),
930 upperBound[1]+(0.5+shiftSize),
931 upperBound[2]+(0.5+shiftSize)),
932 DGtal::Z3i::RealPoint(lowerBound[0]-(0.5+shiftSize),
933 upperBound[1]+(0.5+shiftSize),
934 upperBound[2]+(0.5+shiftSize)),
935 DGtal::Z3i::RealPoint(lowerBound[0]-(0.5+shiftSize),
936 lowerBound[1]-(0.5+shiftSize),
937 upperBound[2]+(0.5+shiftSize)),
938 DGtal::Z3i::RealPoint(upperBound[0]+(0.5+shiftSize),
939 lowerBound[1]-(0.5+shiftSize),
940 upperBound[2]+(0.5+shiftSize)));
942 display.addQuad(DGtal::Z3i::RealPoint(upperBound[0]+(0.5+shiftSize),
943 upperBound[1]+(0.5+shiftSize),
944 lowerBound[2]-(0.5+shiftSize)),
945 DGtal::Z3i::RealPoint(upperBound[0]+(0.5+shiftSize),
946 lowerBound[1]-(0.5+shiftSize),
947 lowerBound[2]-(0.5+shiftSize)),
948 DGtal::Z3i::RealPoint(lowerBound[0]-(0.5+shiftSize),
949 lowerBound[1]-(0.5+shiftSize),
950 lowerBound[2]-(0.5+shiftSize)),
951 DGtal::Z3i::RealPoint(lowerBound[0]-(0.5+shiftSize),
952 upperBound[1]+(0.5+shiftSize),
953 lowerBound[2]-(0.5+shiftSize)));
955 display.addQuad(DGtal::Z3i::RealPoint(upperBound[0]+(0.5+shiftSize),
956 upperBound[1]+(0.5+shiftSize),
957 upperBound[2]+(0.5+shiftSize)),
958 DGtal::Z3i::RealPoint(upperBound[0]+(0.5+shiftSize),
959 upperBound[1]+(0.5+shiftSize),
960 lowerBound[2]-(0.5+shiftSize)),
961 DGtal::Z3i::RealPoint(lowerBound[0]-(0.5+shiftSize),
962 upperBound[1]+(0.5+shiftSize),
963 lowerBound[2]-(0.5+shiftSize)),
964 DGtal::Z3i::RealPoint(lowerBound[0]-(0.5+shiftSize),
965 upperBound[1]+(0.5+shiftSize),
966 upperBound[2]+(0.5+shiftSize)));
968 display.addQuad(DGtal::Z3i::RealPoint(upperBound[0]+(0.5+shiftSize),
969 lowerBound[1]-(0.5+shiftSize),
970 upperBound[2]+(0.5+shiftSize)),
971 DGtal::Z3i::RealPoint(lowerBound[0]-(0.5+shiftSize),
972 lowerBound[1]-(0.5+shiftSize),
973 upperBound[2]+(0.5+shiftSize)),
974 DGtal::Z3i::RealPoint(lowerBound[0]-(0.5+shiftSize),
975 lowerBound[1]-(0.5+shiftSize),
976 lowerBound[2]-(0.5+shiftSize)),
977 DGtal::Z3i::RealPoint(upperBound[0]+(0.5+shiftSize),
978 lowerBound[1]-(0.5+shiftSize),
979 lowerBound[2]-(0.5+shiftSize)));
981 display.addQuad(DGtal::Z3i::RealPoint(upperBound[0]+(0.5+shiftSize),
982 upperBound[1]+(0.5+shiftSize),
983 upperBound[2]+(0.5+shiftSize)),
984 DGtal::Z3i::RealPoint(upperBound[0]+(0.5+shiftSize),
985 lowerBound[1]-(0.5+shiftSize),
986 upperBound[2]+(0.5+shiftSize)),
987 DGtal::Z3i::RealPoint(upperBound[0]+(0.5+shiftSize),
988 lowerBound[1]-(0.5+shiftSize),
989 lowerBound[2]-(0.5+shiftSize)),
990 DGtal::Z3i::RealPoint(upperBound[0]+(0.5+shiftSize),
991 upperBound[1]+(0.5+shiftSize),
992 lowerBound[2]-(0.5+shiftSize)));
994 display.addQuad(DGtal::Z3i::RealPoint(lowerBound[0]-(0.5+shiftSize),
995 upperBound[1]+(0.5+shiftSize),
996 upperBound[2]+(0.5+shiftSize)),
997 DGtal::Z3i::RealPoint(lowerBound[0]-(0.5+shiftSize),
998 upperBound[1]+(0.5+shiftSize),
999 lowerBound[2]-(0.5+shiftSize)),
1000 DGtal::Z3i::RealPoint(lowerBound[0]-(0.5+shiftSize),
1001 lowerBound[1]-(0.5+shiftSize),
1002 lowerBound[2]-(0.5+shiftSize)),
1003 DGtal::Z3i::RealPoint(lowerBound[0]-(0.5+shiftSize),
1004 lowerBound[1]-(0.5+shiftSize),
1005 upperBound[2]+(0.5+shiftSize)));
1007 display.setFillColor( fillColorSave);
1010 template <typename Space, typename KSpace>
1011 template <typename SpaceDom>
1013 void DGtal::Display3DFactory<Space,KSpace>::drawAsGrid( Display & display,
1014 const DGtal::HyperRectDomain<SpaceDom> & h )
1016 ASSERT(Space::dimension == 3 || "drawAsGrid-NOT-YET-IMPLEMENTED-in-ND");
1018 if (Space::dimension == 3)
1021 for (auto z = h.myLowerBound[2]; z <= h.myUpperBound[2]; z++)
1023 for (auto x = h.myLowerBound[0]; x <= h.myUpperBound[0]; x++)
1025 DGtal::Z3i::RealPoint rp1 = display.embed( DGtal::Z3i::Point(x, h.myLowerBound[1], z) );
1026 DGtal::Z3i::RealPoint rp2 = display.embed( DGtal::Z3i::Point(x, h.myUpperBound[1], z) );
1028 display.addLine( rp1, rp2);
1030 for (auto y = h.myLowerBound[1]; y <= h.myUpperBound[1]; y++)
1032 DGtal::Z3i::RealPoint rp1 = display.embed( DGtal::Z3i::Point(h.myLowerBound[0], y, z) );
1033 DGtal::Z3i::RealPoint rp2 = display.embed( DGtal::Z3i::Point(h.myUpperBound[0], y, z) );
1035 display.addLine( rp1, rp2 );
1040 for (auto y = h.myLowerBound[1]; y <= h.myUpperBound[1]; y++)
1042 for (auto x = h.myLowerBound[0]; x <= h.myUpperBound[0]; x++)
1044 DGtal::Z3i::RealPoint rp1 = display.embed( DGtal::Z3i::Point(x, y, h.myLowerBound[2]) );
1045 DGtal::Z3i::RealPoint rp2 = display.embed( DGtal::Z3i::Point(x, y, h.myLowerBound[2]) );
1047 display.addLine( rp1, rp2);
1049 for (auto z = h.myLowerBound[2]; z <= h.myUpperBound[2]; z++)
1051 DGtal::Z3i::RealPoint rp1 = display.embed( DGtal::Z3i::Point(h.myLowerBound[0], y, z) );
1052 DGtal::Z3i::RealPoint rp2 = display.embed( DGtal::Z3i::Point(h.myUpperBound[0], y, z) );
1054 display.addLine( rp1, rp2);
1059 for (auto x = h.myLowerBound[0]; x <= h.myUpperBound[0]; x++)
1061 for (auto y = h.myLowerBound[1]; y <= h.myUpperBound[1]; y++)
1063 DGtal::Z3i::RealPoint rp1 = display.embed( DGtal::Z3i::Point(x, y, h.myLowerBound[2]) );
1064 DGtal::Z3i::RealPoint rp2 = display.embed( DGtal::Z3i::Point(x, y, h.myUpperBound[2]) );
1066 display.addLine( rp1, rp2);
1068 for (auto z = h.myLowerBound[2]; z <= h.myUpperBound[2]; z++)
1070 DGtal::Z3i::RealPoint rp1 = display.embed( DGtal::Z3i::Point(x, h.myLowerBound[1], z) );
1071 DGtal::Z3i::RealPoint rp2 = display.embed( DGtal::Z3i::Point(x, h.myLowerBound[1], z) );
1073 display.addLine( rp1, rp2);
1079 template <typename Space, typename KSpace>
1080 template <typename SpaceDom>
1082 void DGtal::Display3DFactory<Space,KSpace>::drawAsPavingBalls( Display & display,
1083 const DGtal::HyperRectDomain<SpaceDom> & h )
1085 DGtal::Color fillColorSave = display.getFillColor();
1087 ASSERT(Space::dimension == 3 || "drawAsPavingPoints-NOT-YET-IMPLEMENTED-in-ND");
1088 if (Space::dimension == 3)
1091 for (auto z = h.myLowerBound[2]; z <= h.myUpperBound[2]; z++)
1093 for (auto x = h.myLowerBound[0]; x <= h.myUpperBound[0]; x++)
1096 for (auto y = h.myLowerBound[1]; y <= h.myUpperBound[1]; y++)
1098 DGtal::Z3i::RealPoint rp = display.embed( DGtal::Z3i::Point(x, y, z) );
1099 display.setFillColor(DGtal::Color(255, 0 ,0));
1100 display.addBall(rp,1.0/static_cast<double>( POINT_AS_BALL_RADIUS), POINT_AS_BALL_RES);
1105 display.setFillColor(fillColorSave);
1108 template <typename Space, typename KSpace>
1109 template <typename SpaceDom>
1111 void DGtal::Display3DFactory<Space,KSpace>::drawAsPaving( Display & display,
1112 const DGtal::HyperRectDomain<SpaceDom> & h )
1114 DGtal::Color fillColorSave = display.getFillColor();
1116 ASSERT(Space::dimension == 3 || "drawAsPaving-NOT-YET-IMPLEMENTED-in-ND");
1118 if (Space::dimension == 3)
1121 for (auto z = h.myLowerBound[2]; z <= h.myUpperBound[2]; z++)
1123 for (auto x = h.myLowerBound[0]; x <= h.myUpperBound[0]; x++)
1125 for (auto y = h.myLowerBound[1]; y <= h.myUpperBound[1]; y++)
1127 DGtal::Z3i::RealPoint rp = display.embed( DGtal::Z3i::Point(x, y, z) );
1131 //a transparent color for the paving
1132 display.setFillColor( Color(255, 255 ,255, 15));
1133 display.addCube(rp, 1.0);
1138 display.setFillColor(fillColorSave);
1142 template <typename Space, typename KSpace>
1143 template <typename SpaceDom>
1146 DGtal::Display3DFactory<Space,KSpace>::draw( Display & display, const DGtal::HyperRectDomain<SpaceDom> & aDomain )
1148 std::string mode = display.getMode( aDomain.className() );
1150 ASSERT((mode=="" || mode=="Grid" || mode=="Paving"|| mode=="PavingPoints"|| mode=="PavingGrids" ||
1151 mode=="BoundingBox")||
1152 ("DGtal::Display3DFactory<Space,KSpace>::draw( Display3DD<Space, KSpace> & display, const DGtal::HyperRectDomain<Space> & aDomain ): Unknown mode "+mode)=="");
1155 if ( mode == "BoundingBox" )
1157 display.createNewLineList(aDomain.className());
1158 drawAsBoundingBox( display, aDomain );
1159 }else if( ( mode == "" ) || (mode == "Grid"))
1161 display.createNewLineList(aDomain.className());
1162 drawAsGrid( display, aDomain );
1164 else if ( mode == "Paving" )
1166 display.createNewCubeList( aDomain.className());
1170 ASSERT((Space::dimension==3)|| (Space::dimension==2));
1171 ASSERT((Space::dimension!=3) || (mode=="" || mode=="Grid" || mode=="Paving"|| mode=="PavingPoints"|| mode=="PavingGrids" ||
1172 mode=="BoundingBox")||
1173 ("DGtal::Display3DFactory<Space,KSpace>::draw( Display & display, const DGtal::HyperRectDomain<Space> & aDomain ): Unknown mode "+mode)=="");
1174 ASSERT((Space::dimension!=2) || (mode=="" || mode=="BoundingBox" || mode=="Grid") ||
1175 ("DGtal::Display3DFactory<Space,KSpace>::draw( Display & display, const DGtal::HyperRectDomain<Space> & aDomain ): Unknown mode "+mode)=="");
1177 if(Space::dimension == 2)
1181 }else if ( mode == "BoundingBox" )
1183 display.createNewLineList(aDomain.className());
1184 drawAsBoundingBox( display, aDomain );
1185 }else if(( mode == "" ) || (mode == "Grid"))
1187 display.createNewLineList(aDomain.className());
1188 drawAsGrid( display, aDomain );
1189 } else if ( mode == "Paving" )
1191 display.createNewCubeList();
1192 drawAsPaving( display, aDomain );
1193 } else if ( mode == "PavingPoints" )
1195 display.createNewBallList(aDomain.className());
1196 drawAsPavingBalls( display, aDomain );
1197 }else if ( mode == "PavingGrids" )
1199 display.createNewLineList(aDomain.className());
1200 display.createNewCubeList( );
1201 drawAsGrid( display, aDomain );
1202 drawAsPaving( display, aDomain );
1209 template <typename Space, typename KSpace>
1211 void DGtal::Display3DFactory<Space,KSpace>::draw( Display & display,
1212 const typename KSpace::Cell & k )
1214 ASSERT(Space::dimension == 3);
1215 DGtal::Color fillColorSave = display.getFillColor();
1216 std::string mode = display.getMode( k.className() );
1217 ASSERT((mode=="" || mode=="Highlighted" || mode=="Transparent"|| mode=="Basic"|| mode=="Illustration"||mode=="IllustrationCustomColor")||
1218 ("DGtal::Display3DFactory<Space,KSpace>::draw( Display & display, const DGtal::KhalimskyCell<dim, TInteger> & k ): Unknown mode "+mode)=="");
1219 // used to display surfels located at a same position.
1220 double factorVolSurfel=1.0;
1221 if(mode=="Highlighted")
1223 factorVolSurfel = 1.1;
1224 display.setFillColor(DGtal::Color(255, 50, 50, 255));
1225 }else if(mode=="Transparent")
1227 display.setFillColor(DGtal::Color(180, 180, 250, 25));
1230 DGtal::Z3i::RealPoint rp = display.embedK( k );
1231 bool xodd = ( NumberTraits<typename KSpace::Integer>::castToInt64_t(k.preCell().coordinates[ 0 ]) & 1 );
1232 bool yodd = ( NumberTraits<typename KSpace::Integer>::castToInt64_t(k.preCell().coordinates[ 1 ]) & 1 );
1233 bool zodd = ( NumberTraits<typename KSpace::Integer>::castToInt64_t(k.preCell().coordinates[ 2 ]) & 1 );
1234 unsigned int spaceDim= (xodd ? 1:0) + (yodd ? 1:0) + (zodd ? 1:0);
1239 if(mode!="" && mode!="Basic" && mode!="IllustrationCustomColor")
1241 display.setFillColor(DGtal::Color(200, 200, 20, 255));
1244 display.addBall(rp, 1.0/static_cast<double>(POINT_AS_BALL_RADIUS), POINT_AS_BALL_RES);
1247 if(mode!=""&& mode!="Basic" && mode!="IllustrationCustomColor")
1249 display.setFillColor(DGtal::Color(255, 255, 50, 255));
1253 display.addCylinder(DGtal::Z3i::RealPoint(rp[0]- (xodd? 0.5:0 ), rp[1]- (yodd? 0.5:0 ), rp[2]- (zodd? 0.5:0 )),
1254 DGtal::Z3i::RealPoint(rp[0]+ (xodd? 0.5:0 ), rp[1]+ (yodd? 0.5:0 ), rp[2]+ (zodd? 0.5:0 )));
1257 if(mode!="" && mode!="Basic" && mode!="IllustrationCustomColor")
1259 display.setFillColor(DGtal::Color(20, 200, 200, 255));
1263 display.addQuadFromSurfelCenter(DGtal::Z3i::RealPoint(rp[0]+(xodd? 0:0.5 ), rp[1]+(yodd? 0:0.5 ), rp[2]+(zodd? 0:0.5 )),
1264 ! xodd, !yodd, !zodd);
1267 display.addPrism(DGtal::Z3i::RealPoint(rp[0]+(xodd? 0:0.5 ), rp[1]+(yodd? 0:0.5 ), rp[2]+(zodd? 0:0.5 )),
1268 ! xodd, !yodd, !zodd, factorVolSurfel,1.0, false, false);
1271 if(mode!="" && mode!="Basic" && mode!="IllustrationCustomColor")
1273 display.setFillColor(DGtal::Color(255, 180, 250, 255));
1275 if(mode=="Illustration"|| mode=="IllustrationCustomColor")
1277 display.createNewCubeList();
1278 display.addCube(rp,0.80);
1280 display.createNewCubeList();
1281 display.addCube(rp,0.90);
1285 display.setFillColor(fillColorSave);
1290 template <typename Space, typename KSpace>
1292 void DGtal::Display3DFactory<Space,KSpace>::drawUnorientedSurfelWithNormal( Display & display,
1293 const typename KSpace::Cell & k ,
1294 const RealVector &normalVector,
1295 const bool enableDoubleFace)
1297 ASSERT(Space::dimension == 3);
1298 DGtal::Color fillColorSave = display.getFillColor();
1299 std::string mode = display.getMode( k.className() );
1300 ASSERT(( mode=="Basic")|| ( mode=="") ||
1301 ("DGtal::Display3DFactory<Space,KSpace>::drawUnorientedSurfelWithNormal( Display & display, const DGtal::KhalimskyCell<dim, TInteger> & k ): Unknown mode "+mode)=="");
1303 RealPoint rp = display.embedK( k );
1304 const KSpace& K = display.space();
1305 bool xodd = K.uIsOpen( k, 0 );
1306 bool yodd = K.uIsOpen( k, 1 );
1307 bool zodd = K.uIsOpen( k, 2 );
1308 display.addQuadFromSurfelCenterWithNormal
1309 ( RealPoint( rp[0]+(xodd? 0:0.5 ), rp[1]+(yodd? 0:0.5 ), rp[2]+(zodd? 0:0.5 ) ),
1310 ! xodd, ! yodd, ! zodd, normalVector,
1311 true, true, //reorientation enabled
1317 template <typename Space, typename KSpace>
1319 void DGtal::Display3DFactory<Space,KSpace>::drawOrientedSurfelWithNormal( Display & display,
1320 const typename KSpace::SCell & k ,
1321 const RealVector &normalVector,
1322 const bool enableDoubleFace)
1324 ASSERT(Space::dimension == 3);
1325 DGtal::Color fillColorSave = display.getFillColor();
1326 std::string mode = display.getMode( k.className() );
1327 ASSERT(( mode=="Basic")|| ( mode=="") ||
1328 ("DGtal::Display3DFactory<Space,KSpace>::drawOrientedSurfelWithNormal( Display & display, const DGtal::KhalimskyCell<dim, TInteger> & k ): Unknown mode "+mode)=="");
1330 RealPoint rp = display.embedKS( k );
1331 const KSpace& K = display.space();
1332 bool xodd = K.sIsOpen( k, 0 );
1333 bool yodd = K.sIsOpen( k, 1 );
1334 bool zodd = K.sIsOpen( k, 2 );
1335 bool sign = K.sDirect( k, K.sOrthDir( k ) ); // tells the direction toward the inside
1336 display.addQuadFromSurfelCenterWithNormal
1337 ( RealPoint( rp[0]+(xodd? 0:0.5 ), rp[1]+(yodd? 0:0.5 ), rp[2]+(zodd? 0:0.5 ) ),
1338 ! xodd, ! yodd, ! zodd, normalVector,
1339 false, !sign, enableDoubleFace );
1344 // SignedKhalimskyCell
1345 template <typename Space, typename KSpace>
1347 void DGtal::Display3DFactory<Space,KSpace>::draw( Display & display,
1348 const typename KSpace::SCell & sk )
1351 ASSERT(Space::dimension == 3);
1352 DGtal::Color fillColorSave = display.getFillColor();
1353 std::string mode = display.getMode( sk.className() );
1354 ASSERT((mode=="" || mode=="Highlighted" || mode=="Transparent" || mode=="Basic" || mode=="Illustration" || mode=="IllustrationCustomColor")||
1355 ("DGtal::Display3DFactory<Space,KSpace>::draw( Display & display, const DGtal::SignedKhalimskyCell<dim, TInteger> & sk ): Unknown mode "+mode)=="");
1356 // used to display surfels located at a same position.
1357 double factorVolSurfel=1.0;
1358 if(mode=="Highlighted")
1360 factorVolSurfel = 1.2;
1361 display.setFillColor(DGtal::Color(255, 50, 50, 255));
1362 }else if(mode=="Transparent")
1364 display.setFillColor(DGtal::Color(180, 180, 250, 25));
1367 DGtal::Z3i::RealPoint rps = display.embedKS( sk );
1368 bool xodd = ( sk.preCell().coordinates[ 0 ] & 1 );
1369 bool yodd = ( sk.preCell().coordinates[ 1 ] & 1 );
1370 bool zodd = ( sk.preCell().coordinates[ 2 ] & 1 );
1371 unsigned int spaceDim= (xodd ? 1:0) + (yodd ? 1:0) + (zodd ? 1:0);
1377 if(mode!="" && mode!="Basic" && mode!="IllustrationCustomColor")
1379 if( sk.preCell().positive)
1380 display.setFillColor(DGtal::Color(20, 20, 250, 255));
1382 display.setFillColor(DGtal::Color(20, 20, 150, 255));
1384 display.addBall(rps, 1.0/static_cast<double>( POINT_AS_BALL_RADIUS), POINT_AS_BALL_RES);
1387 if(mode!="" && mode!="Basic" && mode!="IllustrationCustomColor")
1389 display.setFillColor( DGtal::Color(255, 50, 50, 255));
1391 if (sk.preCell().positive)
1393 display.addCone(DGtal::Z3i::RealPoint(rps[0]- (xodd? 0.5:0 ), rps[1]- (yodd? 0.5:0 ), rps[2]- (zodd? 0.5:0 )),
1394 DGtal::Z3i::RealPoint(rps[0]+ (xodd? 0.5:0 ), rps[1]+ (yodd? 0.5:0 ), rps[2]+ (zodd? 0.5:0 )));
1398 display.addCone(DGtal::Z3i::RealPoint(rps[0]+ (xodd? 0.5:0 ), rps[1]+ (yodd? 0.5:0 ), rps[2]+ (zodd? 0.5:0 )),
1399 DGtal::Z3i::RealPoint(rps[0]- (xodd? 0.5:0 ),rps[1]- (yodd? 0.5:0 ), rps[2]- (zodd? 0.5:0 )));
1405 display.addQuadFromSurfelCenter(DGtal::Z3i::RealPoint(rps[0]+(xodd? 0:0.5 ), rps[1]+(yodd? 0:0.5 ), rps[2]+(zodd? 0:0.5 )),
1406 ! xodd, !yodd, !zodd );
1408 display.addPrism(DGtal::Z3i::RealPoint(rps[0]+(xodd? 0:0.5 ), rps[1]+(yodd? 0:0.5 ), rps[2]+(zodd? 0:0.5 )),
1409 ! xodd, !yodd, !zodd, factorVolSurfel,1.0, true, sk.preCell().positive );
1412 if(mode!="" && mode!="IllustrationCustomColor")
1414 if( sk.preCell().positive)
1416 display.setFillColor(DGtal::Color(200, 20, 20, 255));
1419 display.setFillColor(DGtal::Color(20, 200, 20, 255));
1422 if(mode=="Illustration"|| mode=="IllustrationCustomColor")
1425 display.createNewCubeList();
1426 display.addCube(rps, 0.80);
1429 display.createNewCubeList();
1430 display.addCube(rps, 0.90 );
1434 display.setFillColor(fillColorSave);
1436 // SignedKhalimskyCell
1441 template <typename Space, typename KSpace>
1442 template <typename TDigitalTopology, typename TDigitalSet>
1444 void DGtal::Display3DFactory<Space,KSpace>::drawWithAdjacencies( Display & display,
1445 const DGtal::Object<TDigitalTopology, TDigitalSet> & o )
1447 typedef typename TDigitalSet::Point Point;
1449 typedef typename TDigitalSet::Domain Domain;
1451 typename DigitalSetSelector < Domain,
1452 SMALL_DS + HIGH_ITER_DS >::Type SmallSet;
1453 typedef Object<TDigitalTopology, SmallSet> SmallObject;
1456 for (typename TDigitalSet::ConstIterator it = o.pointSet().begin();
1457 it != o.pointSet().end();
1460 //Brute-force scan of the neighborhood.
1461 SmallObject neig = o.properNeighborhood(*it);
1462 for (typename SmallObject::DigitalSet::ConstIterator it2 = neig.pointSet().begin();
1463 it2 != neig.pointSet().end();
1467 draw(display, p, (*it));
1472 template <typename Space, typename KSpace>
1473 template <typename TDigitalTopology, typename TDigitalSet>
1475 void DGtal::Display3DFactory<Space,KSpace>::draw( Display & display,
1476 const DGtal::Object<TDigitalTopology, TDigitalSet> & o )
1478 std::string mode = display.getMode( o.className() );
1479 if ( mode == "Basic" || mode == "" )
1480 draw( display, o.pointSet() );
1481 else if ( mode == "PavingTransp" )
1483 drawAsPavingTransparent( display, o.pointSet() );
1486 else if ( mode == "DrawAdjacencies" )
1488 draw( display, o.pointSet() );
1489 drawWithAdjacencies( display, o );
1492 ASSERT(false && (("DGtal::Display3DFactory<Space,KSpace>::draw( Display & display, const DGtal::Object<TDigitalTopology, TDigitalSet> & o ): Unknown mode " + mode) == ""));
1498 template <typename Space, typename KSpace>
1499 template<DGtal::Dimension dim, typename TComponent, typename TContainer>
1501 void DGtal::Display3DFactory<Space,KSpace>::drawAsGrid( Display & display,
1502 const DGtal::PointVector<dim, TComponent, TContainer> & p )
1504 DGtal::Color fillColorSave = display.getFillColor();
1506 DGtal::Z3i::RealPoint rp = display.embed( DGtal::Z3i::Point(p, functors::Round<>() ) );
1507 display.setFillColor(display.getLineColor());
1508 display.addBall(rp,1.0/static_cast<double>( POINT_AS_BALL_RADIUS), POINT_AS_BALL_RES);
1509 display.setFillColor(fillColorSave);
1512 template <typename Space, typename KSpace>
1513 template<DGtal::Dimension dim, typename TComponent, typename TContainer>
1515 void DGtal::Display3DFactory<Space,KSpace>::drawAsPaving( Display & display,
1516 const DGtal::PointVector<dim, TComponent, TContainer> & p )
1520 DGtal::Z3i::RealPoint rp = display.embed( DGtal::Z3i::Point(p, functors::Round<>() ) );
1521 display.addCube(rp);
1524 template <typename Space, typename KSpace>
1525 template<DGtal::Dimension dim, typename TComponent, typename TContainer>
1527 void DGtal::Display3DFactory<Space,KSpace>::drawAsPavingWired( Display & display,
1528 const DGtal::PointVector<dim, TComponent, TContainer> & p )
1530 DGtal::Color lineColorSave = display.getLineColor();
1533 DGtal::Z3i::RealPoint rp = display.embed( DGtal::Z3i::Point(p, functors::Round<>() ) );
1534 display.addCube(rp);
1535 display.setLineColor(DGtal::Color(0,0,0));
1536 display.addLine(DGtal::Z3i::RealPoint(rp[0]-0.5, rp[1]-0.5, rp[2]-0.5),
1537 DGtal::Z3i::RealPoint(rp[0]+0.5, rp[1]-0.5, rp[2]-0.5));
1538 display.addLine(DGtal::Z3i::RealPoint(rp[0]+0.5, rp[1]-0.5, rp[2]-0.5),
1539 DGtal::Z3i::RealPoint(rp[0]+0.5, rp[1]+0.5, rp[2]-0.5));
1540 display.addLine(DGtal::Z3i::RealPoint(rp[0]+0.5, rp[1]+0.5, rp[2]-0.5),
1541 DGtal::Z3i::RealPoint(rp[0]-0.5, rp[1]+0.5, rp[2]-0.5));
1542 display.addLine(DGtal::Z3i::RealPoint(rp[0]-0.5, rp[1]+0.5, rp[2]-0.5),
1543 DGtal::Z3i::RealPoint(rp[0]-0.5, rp[1]-0.5, rp[2]-0.5));
1545 display.addLine(DGtal::Z3i::RealPoint(rp[0]-0.5, rp[1]-0.5, rp[2]+0.5),
1546 DGtal::Z3i::RealPoint(rp[0]+0.5, rp[1]-0.5, rp[2]+0.5));
1547 display.addLine(DGtal::Z3i::RealPoint(rp[0]+0.5, rp[1]-0.5, rp[2]+0.5),
1548 DGtal::Z3i::RealPoint(rp[0]+0.5, rp[1]+0.5, rp[2]+0.5));
1549 display.addLine(DGtal::Z3i::RealPoint(rp[0]+0.5, rp[1]+0.5, rp[2]+0.5),
1550 DGtal::Z3i::RealPoint(rp[0]-0.5, rp[1]+0.5, rp[2]+0.5));
1551 display.addLine(DGtal::Z3i::RealPoint(rp[0]-0.5, rp[1]+0.5, rp[2]+0.5),
1552 DGtal::Z3i::RealPoint(rp[0]-0.5, rp[1]-0.5, rp[2]+0.5));
1554 display.addLine(DGtal::Z3i::RealPoint(rp[0]-0.5, rp[1]-0.5, rp[2]-0.5),
1555 DGtal::Z3i::RealPoint(rp[0]-0.5, rp[1]-0.5, rp[2]+0.5));
1556 display.addLine(DGtal::Z3i::RealPoint(rp[0]+0.5, rp[1]-0.5, rp[2]-0.5),
1557 DGtal::Z3i::RealPoint(rp[0]+0.5, rp[1]-0.5, rp[2]+0.5));
1558 display.addLine(DGtal::Z3i::RealPoint(rp[0]+0.5, rp[1]+0.5, rp[2]-0.5),
1559 DGtal::Z3i::RealPoint(rp[0]+0.5, rp[1]+0.5, rp[2]+0.5));
1560 display.addLine(DGtal::Z3i::RealPoint(rp[0]-0.5, rp[1]+0.5, rp[2]-0.5),
1561 DGtal::Z3i::RealPoint(rp[0]-0.5, rp[1]+0.5, rp[2]+0.5));
1562 display.setLineColor(lineColorSave);
1565 template <typename Space, typename KSpace>
1566 template<DGtal::Dimension dim, typename TComponent, typename TContainer>
1568 void DGtal::Display3DFactory<Space,KSpace>::draw( Display & display,
1569 const DGtal::PointVector<dim, TComponent, TContainer> & p )
1571 DGtal::Color fillColorSave = display.getFillColor();
1574 std::string mode = display.getMode( p.className() );
1575 ASSERT( (mode=="Paving" || mode=="Grid" || mode=="Both" || mode=="PavingWired"|| mode=="") );
1577 if ( mode == "Paving" || ( mode == "" ) )
1578 drawAsPaving( display, p );
1579 else if ( mode == "Grid" )
1580 drawAsGrid( display, p );
1581 else if ( ( mode == "Both" ) )
1583 drawAsPaving( display, p );
1584 drawAsGrid( display, p );
1586 else if( mode=="PavingWired")
1588 drawAsPavingWired( display, p );
1590 display.setFillColor(fillColorSave);
1593 template <typename Space, typename KSpace>
1594 template<DGtal::Dimension dim, typename TComponent1, typename TComponent2, typename TContainer1, typename TContainer2>
1596 void DGtal::Display3DFactory<Space,KSpace>::draw( Display & display,
1597 const DGtal::PointVector<dim, TComponent1, TContainer1> & p,
1598 const DGtal::PointVector<dim, TComponent2, TContainer2> & aPoint )
1602 DGtal::Z3i::RealPoint rp = display.embed(p );
1603 DGtal::Z3i::RealPoint rpa = display.embed(aPoint );
1604 display.addLine(rpa, DGtal::Z3i::RealPoint( rpa[0] + rp[0], rpa[1] + rp[1], rpa[2] + rp[2]));
1610 template <typename Space, typename KSpace>
1612 void DGtal::Display3DFactory<Space,KSpace>::draw( Display & display,
1613 const DGtal::GridCurve<KSpace> & gc)
1615 typedef typename DGtal::GridCurve<KSpace>::SCellsRange Range;
1616 Range r = gc.getSCellsRange();
1617 for ( typename Range::ConstIterator it = r.begin(), itEnd = r.end();
1620 draw( display, *it );
1626 template <typename Space, typename KSpace>
1627 template <typename TIterator, typename TSCell>
1629 void DGtal::Display3DFactory<Space,KSpace>::draw( Display & display,
1630 const DGtal::ConstRangeAdapter<TIterator, DGtal::functors::Identity, TSCell> & object )
1632 typedef DGtal::ConstRangeAdapter<TIterator, DGtal::functors::Identity, TSCell> Range;
1633 typedef typename Range::ConstIterator ConstIterator;
1635 ConstIterator it ( object.begin() );
1636 ConstIterator itEnd ( object.end() );
1637 for( ; it != itEnd; ++it)
1639 draw( display, *it);
1645 template <typename Space, typename KSpace>
1646 template <typename TIterator>
1648 void DGtal::Display3DFactory<Space,KSpace>::draw( Display & display,
1649 const DGtal::ConstRangeAdapter<TIterator, DGtal::functors::SCellToPoint<KSpace>, typename KSpace::Point> & object )
1651 typedef ConstRangeAdapter<TIterator, functors::SCellToPoint<KSpace>, typename KSpace::Point> Range;
1652 typedef typename Range::ConstIterator ConstIterator;
1654 ConstIterator it ( object.begin() );
1655 ConstIterator itEnd ( object.end() );
1656 for( ; it != itEnd; ++it)
1658 display << SetMode3D(it->className(),"Paving");
1665 template <typename Space, typename KSpace>
1666 template <typename TIterator>
1668 void DGtal::Display3DFactory<Space,KSpace>::draw( Display & display,
1669 const DGtal::ConstRangeAdapter<TIterator, CanonicSCellEmbedder<KSpace>,
1670 typename KSpace::Space::RealPoint> & object )
1672 typedef typename KSpace::Space::RealPoint RPoint;
1673 typedef ConstRangeAdapter<TIterator, CanonicSCellEmbedder<KSpace>, RPoint > Range;
1674 typedef typename Range::ConstIterator ConstIterator;
1676 ConstIterator it ( object.begin() );
1677 ConstIterator itEnd ( object.end() );
1678 for( ; it != itEnd; ++it)
1680 display << SetMode3D(it->className(),"Grid");
1687 template <typename TSpace, typename TKSpace>
1688 template <typename TIterator>
1690 void DGtal::Display3DFactory<TSpace,TKSpace>::draw( Display & display,
1691 const DGtal::ConstRangeAdapter<TIterator, functors::SCellToArrow<KSpace>,
1692 std::pair<typename KSpace::Point, typename KSpace::Vector> > & object )
1694 typedef typename KSpace::Point Point;
1695 typedef typename KSpace::Vector Vector;
1696 typedef std::pair<Point, Vector> Arrow;
1697 typedef ConstRangeAdapter<TIterator, functors::SCellToArrow<KSpace>, Arrow > Range;
1698 typedef typename Range::ConstIterator ConstIterator;
1700 ConstIterator it ( object.begin() );
1701 ConstIterator itEnd ( object.end() );
1702 for( ; it != itEnd; ++it)
1703 { //display the associated cell
1704 draw( display, *(it.base()) );
1710 template <typename Space, typename KSpace>
1711 template <typename TIterator>
1713 void DGtal::Display3DFactory<Space,KSpace>::draw( Display & display,
1714 const DGtal::ConstRangeAdapter<TIterator, DGtal::functors::SCellToInnerPoint<KSpace>, typename KSpace::Point> & object )
1716 typedef ConstRangeAdapter<TIterator, DGtal::functors::SCellToInnerPoint<KSpace>, typename KSpace::Point> Range;
1717 typedef typename Range::ConstIterator ConstIterator;
1719 ConstIterator it ( object.begin() );
1720 ConstIterator itEnd ( object.end() );
1721 for( ; it != itEnd; ++it)
1723 display << SetMode3D(it->className(),"Paving");
1724 display << CustomColors3D(Color(0, 0, 255,0),Color(0, 0, 200, 100));
1731 template <typename Space, typename KSpace>
1732 template <typename TIterator>
1734 void DGtal::Display3DFactory<Space,KSpace>::draw( Display & display,
1735 const DGtal::ConstRangeAdapter<TIterator, DGtal::functors::SCellToOuterPoint<KSpace>, typename KSpace::Point> & object )
1737 typedef ConstRangeAdapter<TIterator, DGtal::functors::SCellToOuterPoint<KSpace>, typename KSpace::Point> Range;
1738 typedef typename Range::ConstIterator ConstIterator;
1740 ConstIterator it ( object.begin() );
1741 ConstIterator itEnd ( object.end() );
1742 for( ; it != itEnd; ++it)
1744 display << SetMode3D(it->className(),"Paving");
1745 display << CustomColors3D(Color(0, 255, 0 ,0),Color(0, 200, 0, 100));
1751 // IncidentPointsRange
1752 template <typename Space, typename KSpace>
1753 template <typename TIterator>
1755 void DGtal::Display3DFactory<Space,KSpace>::draw( Display & display,
1756 const DGtal::ConstRangeAdapter<TIterator, functors::SCellToIncidentPoints<KSpace>,
1757 std::pair<typename KSpace::Point, typename KSpace::Point > > & object )
1759 typedef std::pair<typename KSpace::Point, typename KSpace::Point > Pair;
1760 typedef ConstRangeAdapter<TIterator, functors::SCellToIncidentPoints<KSpace>, Pair> Range;
1761 typedef typename Range::ConstIterator ConstIterator;
1763 ConstIterator it ( object.begin() );
1764 ConstIterator itEnd ( object.end() );
1765 for( ; it != itEnd; ++it)
1768 display << SetMode3D(pair.first.className(),"Paving");
1769 display << CustomColors3D(Color(0, 0, 255,0),Color(0, 0, 200, 100));
1770 display << pair.first;
1771 display << CustomColors3D(Color(0, 255, 0 ,0),Color(0, 200, 0, 100));
1772 display << pair.second;
1775 // IncidentPointsRange
1777 template <typename Space, typename KSpace>
1779 void DGtal::Display3DFactory<Space,KSpace>::draw( Display & display,
1780 const DGtal::SetMode3D & sm3d )
1782 if ( display.myModes[ sm3d.myClassname ] != sm3d.myMode )
1783 display.myModes[ sm3d.myClassname ] = sm3d.myMode;
1786 template< typename Space, typename KSpace>
1788 void DGtal::Display3DFactory<Space,KSpace>::draw( Display & display,
1789 const DGtal::CustomStyle3D & cs3d )
1791 if (display.myStyles[ cs3d.myClassname ] != cs3d.myStyle )
1792 display.myStyles[ cs3d.myClassname ] = cs3d.myStyle;
1795 template< typename Space, typename KSpace>
1797 void DGtal::Display3DFactory<Space,KSpace>::draw( Display & display, const DGtal::CustomColors3D & cc3d )
1799 display.setFillColor(cc3d.myFillColor);
1800 display.setLineColor(cc3d.myPenColor);
1804 template< typename Space, typename KSpace>
1806 void DGtal::Display3DFactory<Space,KSpace>::draw( Display & display,
1807 const DGtal::ClippingPlane & cl )
1809 display.addClippingPlane(cl.myA, cl.myB, cl.myC, cl.myD, cl.myDrawPlane);
1812 template< typename Space, typename KSpace>
1814 void DGtal::Display3DFactory<Space,KSpace>::draw( Display & display, const DGtal::TransformedPrism & aTransformedPrism)
1817 DGtal::Color fillColorSave = display.getFillColor();
1818 std::string mode = display.getMode( aTransformedPrism.mySurfel.className() );
1819 ASSERT((mode=="" || mode=="Highlighted" || mode=="Transparent" || mode=="Basic" || mode=="Illustration")||
1820 ("DGtal::Display3DFactory<Space,KSpace>::draw( Display & display, const DGtal::ShiftedKSSurfel & aTransformedPrism ): Unknown mode "+mode)=="");
1821 // used to display surfels located at a same position.
1822 double factorVolSurfel=1.0;
1823 if(mode=="Highlighted")
1825 factorVolSurfel = 1.2;
1826 display.setFillColor(DGtal::Color(255, 50, 50, 255));
1827 }else if(mode=="Transparent")
1829 display.setFillColor(DGtal::Color(180, 180, 250, 25));
1830 }else if(mode=="Basic")
1834 DGtal::Z3i::RealPoint rps = display.embedKS(aTransformedPrism );
1836 auto const& preSurfel = aTransformedPrism.mySurfel.preCell();
1838 bool xodd = ( preSurfel.coordinates[ 0 ] & 1 );
1839 bool yodd = ( preSurfel.coordinates[ 1 ] & 1 );
1840 bool zodd = ( preSurfel.coordinates[ 2 ] & 1 );
1842 unsigned int spaceDim= (xodd ? 1:0) + (yodd ? 1:0) + (zodd ? 1:0);
1843 ASSERT(spaceDim ==2 );
1844 boost::ignore_unused_variable_warning(spaceDim);
1846 //display.addSurfelPrism(rps[0], rps[1], rps[2],! xodd, !yodd, !zodd, factorVolSurfel, aTransformedSurfelPrism.mySizeFactor, true, aTransformedSurfelPrism.mySurfel.positive );
1847 display.addPrism(DGtal::Z3i::RealPoint(rps[0]+(xodd? 0:0.5 ), rps[1]+(yodd? 0:0.5 ), rps[2]+(zodd? 0:0.5 )),! xodd, !yodd, !zodd, factorVolSurfel,1.0, true, preSurfel.positive );
1848 display.setFillColor(fillColorSave);
1852 //-----------------------------------------------------------------------------
1853 template< typename Space, typename KSpace>
1856 DGtal::Display3DFactory<Space,KSpace>::
1857 draw( Display & display, const DGtal::SetName3D& aName3d )
1859 // Simply sets the "OpenGL name" of class Display3D, so that it
1860 // names the next graphical structures with it.
1861 display.setName3d( aName3d.name );
1863 //-----------------------------------------------------------------------------
1864 template< typename Space, typename KSpace>
1867 DGtal::Display3DFactory<Space,KSpace>::
1868 draw( Display & display, const DGtal::SetSelectCallback3D& aFct )
1870 display.setSelectCallback3D( aFct.myFct, aFct.myData, aFct.myMin, aFct.myMax );
1874 ///////////////////////////////////////////////////////////////////////////////