Visual Servoing Platform  version 3.0.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
vpMbHiddenFaces.h
1 /****************************************************************************
2  *
3  * This file is part of the ViSP software.
4  * Copyright (C) 2005 - 2017 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * ("GPL") version 2 as published by the Free Software Foundation.
9  * See the file LICENSE.txt at the root directory of this source
10  * distribution for additional information about the GNU GPL.
11  *
12  * For using ViSP with software that can not be combined with the GNU
13  * GPL, please contact Inria about acquiring a ViSP Professional
14  * Edition License.
15  *
16  * See http://visp.inria.fr for more information.
17  *
18  * This software was developed at:
19  * Inria Rennes - Bretagne Atlantique
20  * Campus Universitaire de Beaulieu
21  * 35042 Rennes Cedex
22  * France
23  *
24  * If you have questions regarding the use of this file, please contact
25  * Inria at visp@inria.fr
26  *
27  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
28  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29  *
30  * Description:
31  * Generic model based tracker. This class declares the methods to implement in
32  * order to have a model based tracker.
33  *
34  * Authors:
35  * Romain Tallonneau
36  * Aurelien Yol
37  *
38  *****************************************************************************/
39 #pragma once
40 
41 #ifndef vpMbHiddenFaces_HH
42 #define vpMbHiddenFaces_HH
43 
44 #include <visp3/core/vpHomogeneousMatrix.h>
45 #include <visp3/core/vpMeterPixelConversion.h>
46 #include <visp3/core/vpPixelMeterConversion.h>
47 #include <visp3/mbt/vpMbtPolygon.h>
48 #include <visp3/mbt/vpMbScanLine.h>
49 
50 #ifdef VISP_HAVE_OGRE
51  #include <visp3/ar/vpAROgre.h>
52 #endif
53 
54 #include <vector>
55 #include <limits>
56 
65 template<class PolygonType = vpMbtPolygon>
67 {
68  private:
70  std::vector<PolygonType *> Lpol ;
72  unsigned int nbVisiblePolygon;
73  vpMbScanLine scanlineRender;
74 
75 #ifdef VISP_HAVE_OGRE
76  vpImage<unsigned char> ogreBackground;
77  bool ogreInitialised;
78  unsigned int nbRayAttempts;
79  double ratioVisibleRay;
80  vpAROgre *ogre;
81  std::vector< Ogre::ManualObject* > lOgrePolygons;
82  bool ogreShowConfigDialog;
83 #endif
84 
85  unsigned int setVisiblePrivate(const vpHomogeneousMatrix &cMo, const double &angleAppears, const double &angleDisappears,
86  bool &changed,
87  bool useOgre = false, bool not_used = false,
89  const vpCameraParameters &cam = vpCameraParameters()) ;
90 
91  public :
92  vpMbHiddenFaces() ;
94 
95  void addPolygon(PolygonType *p) ;
96 
97  bool computeVisibility(const vpHomogeneousMatrix &cMo,
98  const double &angleAppears, const double &angleDisappears,
99  bool &changed, bool useOgre, bool not_used,
100  const vpImage<unsigned char> &I,
101  const vpCameraParameters &cam,
102  const vpTranslationVector &cameraPos,
103  unsigned int index);
104 
106 
107  void computeScanLineRender(const vpCameraParameters &cam, const unsigned int &w, const unsigned int &h);
108 
109  void computeScanLineQuery(const vpPoint &a, const vpPoint &b,
110  std::vector<std::pair<vpPoint, vpPoint> > &lines, const bool &displayResults = false);
111 
112  vpMbScanLine& getMbScanLineRenderer() { return scanlineRender; }
113 
114 #ifdef VISP_HAVE_OGRE
115  void displayOgre(const vpHomogeneousMatrix &cMo);
116 #endif
117 
123  std::vector<PolygonType*>& getPolygon() {return Lpol;}
124 
125 #ifdef VISP_HAVE_OGRE
126  void initOgre(const vpCameraParameters &cam = vpCameraParameters());
127 #endif
128 
134  unsigned int getNbVisiblePolygon() const {return nbVisiblePolygon;}
135 
136 #ifdef VISP_HAVE_OGRE
137 
145  unsigned int getNbRayCastingAttemptsForVisibility() { return nbRayAttempts; }
146 
152  vpAROgre* getOgreContext(){return ogre;}
153 
161  double getGoodNbRayCastingAttemptsRatio(){ return ratioVisibleRay; }
162 #endif
163 
164  bool isAppearing(const unsigned int i){ return Lpol[i]->isAppearing(); }
165 
166 
167 #ifdef VISP_HAVE_OGRE
168 
173  bool isOgreInitialised() { return ogreInitialised; }
174 #endif
175 
183  bool isVisible(const unsigned int i){ return Lpol[i]->isVisible(); }
184 
185 #ifdef VISP_HAVE_OGRE
186  bool isVisibleOgre(const vpTranslationVector &cameraPos, const unsigned int &index);
187 #endif
188 
190  inline PolygonType* operator[](const unsigned int i) { return Lpol[i];}
192  inline const PolygonType* operator[](const unsigned int i) const { return Lpol[i];}
193 
194  void reset();
195 
196 #ifdef VISP_HAVE_OGRE
197 
206  void setBackgroundSizeOgre(const unsigned int &h, const unsigned int &w) { ogreBackground = vpImage<unsigned char>(h, w, 0); }
207 
216  void setNbRayCastingAttemptsForVisibility(const unsigned int &attempts) { nbRayAttempts = attempts; }
217 
225  void setGoodNbRayCastingAttemptsRatio(const double &ratio) {ratioVisibleRay = ratio; if(ratioVisibleRay > 1.0) ratioVisibleRay = 1.0; if(ratioVisibleRay < 0.0) ratioVisibleRay = 0.0;}
236  inline void setOgreShowConfigDialog(const bool showConfigDialog){
237  ogreShowConfigDialog = showConfigDialog;
238  }
239 #endif
240 
241  unsigned int setVisible(const vpImage<unsigned char>& I, const vpCameraParameters &cam, const vpHomogeneousMatrix &cMo, const double &angle, bool &changed) ;
242  unsigned int setVisible(const vpImage<unsigned char>& I, const vpCameraParameters &cam, const vpHomogeneousMatrix &cMo, const double &angleAppears, const double &angleDisappears, bool &changed) ;
243  unsigned int setVisible(const vpHomogeneousMatrix &cMo, const double &angleAppears, const double &angleDisappears, bool &changed) ;
244 
245 #ifdef VISP_HAVE_OGRE
246  unsigned int setVisibleOgre(const vpImage<unsigned char>& I, const vpCameraParameters &cam, const vpHomogeneousMatrix &cMo, const double &angleAppears, const double &angleDisappears, bool &changed) ;
247  unsigned int setVisibleOgre(const vpHomogeneousMatrix &cMo, const double &angleAppears, const double &angleDisappears, bool &changed) ;
248 #endif
249 
254  inline unsigned int size() const { return (unsigned int)Lpol.size(); }
255 } ;
256 
260 template<class PolygonType>
262  : Lpol(), nbVisiblePolygon(0), scanlineRender()
263 {
264 #ifdef VISP_HAVE_OGRE
265  ogreInitialised = false;
266  nbRayAttempts = 1;
267  ratioVisibleRay = 1.0;
268  ogreShowConfigDialog = false;
269  ogre = new vpAROgre();
270  ogreBackground = vpImage<unsigned char>(480, 640, 0);
271 #endif
272 }
273 
277 template<class PolygonType>
279 {
280  for(unsigned int i = 0 ; i < Lpol.size() ; i++){
281  if (Lpol[i]!=NULL){
282  delete Lpol[i] ;
283  }
284  Lpol[i] = NULL ;
285  }
286  Lpol.resize(0);
287 
288 #ifdef VISP_HAVE_OGRE
289  if(ogre != NULL){
290  delete ogre;
291  ogre = NULL;
292  }
293 
294  // This is already done by calling "delete ogre"
295 // for(unsigned int i = 0 ; i < lOgrePolygons.size() ; i++){
296 // if (lOgrePolygons[i]!=NULL){
297 // delete lOgrePolygons[i] ;
298 // }
299 // lOgrePolygons[i] = NULL ;
300 // }
301 
302  lOgrePolygons.resize(0);
303 #endif
304 }
305 
311 template<class PolygonType>
312 void
314 {
315  PolygonType *p_new = new PolygonType;
316  p_new->index = p->index;
317  p_new->setNbPoint(p->nbpt);
318  p_new->isvisible = p->isvisible;
319  p_new->useLod = p->useLod;
320  p_new->minLineLengthThresh = p->minLineLengthThresh;
321  p_new->minPolygonAreaThresh = p->minPolygonAreaThresh;
322  p_new->setName(p->name);
323  p_new->hasOrientation = p->hasOrientation;
324 
325  for(unsigned int i = 0; i < p->nbpt; i++)
326  p_new->p[i]= p->p[i];
327  Lpol.push_back(p_new);
328 }
329 
333 template<class PolygonType>
334 void
336 {
337  nbVisiblePolygon = 0;
338  for(unsigned int i = 0 ; i < Lpol.size() ; i++){
339  if (Lpol[i]!=NULL){
340  delete Lpol[i] ;
341  }
342  Lpol[i] = NULL ;
343  }
344  Lpol.resize(0);
345 
346 #ifdef VISP_HAVE_OGRE
347  if(ogre != NULL){
348  delete ogre;
349  ogre = NULL;
350  }
351 
352  // This is already done by calling "delete ogre"
353 // for(unsigned int i = 0 ; i < lOgrePolygons.size() ; i++){
354 // if (lOgrePolygons[i]!=NULL){
355 // delete lOgrePolygons[i] ;
356 // }
357 // lOgrePolygons[i] = NULL ;
358 // }
359 
360  lOgrePolygons.resize(0);
361 
362  ogreInitialised = false;
363  nbRayAttempts = 1;
364  ratioVisibleRay = 1.0;
365  ogre = new vpAROgre();
366  ogreBackground = vpImage<unsigned char>(480, 640);
367 #endif
368 }
369 
376 template<class PolygonType>
377 void
379 {
380  for (unsigned int i = 0; i < Lpol.size(); i++){
381  // For fast result we could just clip visible polygons.
382  // However clipping all of them gives us the possibility to return more information in the scanline visibility results
383 // if(Lpol[i]->isVisible())
384  {
385  Lpol[i]->changeFrame(cMo);
386  Lpol[i]->computePolygonClipped(cam);
387  }
388  }
389 }
390 
398 template<class PolygonType>
399 void
400 vpMbHiddenFaces<PolygonType>::computeScanLineRender(const vpCameraParameters &cam, const unsigned int &w, const unsigned int &h){
401  std::vector<std::vector<std::pair<vpPoint, unsigned int> > > polyClipped(Lpol.size());
402  std::vector<std::vector<std::pair<vpPoint, unsigned int> > * > listPolyClipped;
403  std::vector<int> listPolyIndices;
404 
405  for (unsigned int i = 0; i < Lpol.size(); i++){
406  // For fast result we could just use visible polygons.
407  // However using all of them gives us the possibility to return more information in the scanline visibility results
408 // if(Lpol[i]->isVisible())
409  {
410  polyClipped[i].clear();
411  Lpol[i]->getPolygonClipped(polyClipped[i]);
412  if(polyClipped[i].size() != 0)
413  {
414  listPolyClipped.push_back(&polyClipped[i]);
415  listPolyIndices.push_back(Lpol[i]->getIndex());
416  }
417  }
418  }
419 
420  scanlineRender.drawScene(listPolyClipped, listPolyIndices, cam, w, h);
421 }
422 
433 template<class PolygonType>
434 void
436  std::vector<std::pair<vpPoint, vpPoint> > &lines,
437  const bool &displayResults)
438 {
439  scanlineRender.queryLineVisibility(a,b,lines,displayResults);
440 }
441 
456 template<class PolygonType>
457 unsigned int
459  const double &angleAppears, const double &angleDisappears,
460  bool &changed, bool useOgre, bool not_used,
461  const vpImage<unsigned char> &I,
462  const vpCameraParameters &cam)
463 {
464  nbVisiblePolygon = 0;
465  changed = false;
466 
467  vpTranslationVector cameraPos;
468 
469  if(useOgre){
470 #ifdef VISP_HAVE_OGRE
471  cMo.inverse().extract(cameraPos);
472  ogre->renderOneFrame(ogreBackground, cMo);
473 #else
474  vpTRACE("ViSP doesn't have Ogre3D, simple visibility test used");
475 #endif
476  }
477 
478  for (unsigned int i = 0; i < Lpol.size(); i++){
479  //std::cout << "Calling poly: " << i << std::endl;
480  if (computeVisibility(cMo, angleAppears, angleDisappears, changed, useOgre, not_used, I, cam, cameraPos, i))
481  nbVisiblePolygon ++;
482  }
483  return nbVisiblePolygon;
484 }
485 
502 template<class PolygonType>
503 bool
505  const double &angleAppears, const double &angleDisappears,
506  bool &changed, bool useOgre, bool not_used,
507  const vpImage<unsigned char> & I,
508  const vpCameraParameters & cam,
509  const vpTranslationVector &
510  cameraPos,
511  unsigned int index)
512 {
513  (void) not_used;
514  unsigned int i = index;
515  Lpol[i]->changeFrame(cMo);
516  Lpol[i]->isappearing = false;
517 
518  //Commented because we need to compute visibility
519  // even when dealing with line in level of detail case
520  /*if(Lpol[i]->getNbPoint() <= 2)
521  {
522  Lpol[i]->isvisible = true;
523  }
524  else*/{
525  if(Lpol[i]->isVisible())
526  {
527  bool testDisappear = false;
528  unsigned int nbCornerInsidePrev = 0;
529 
530  if(!testDisappear){
531  if(useOgre)
532 #ifdef VISP_HAVE_OGRE
533  testDisappear = ((!Lpol[i]->isVisible(cMo, angleDisappears, true, cam, I)) || !isVisibleOgre(cameraPos,i));
534 #else
535  {
536  (void)cameraPos; // Avoid warning
537  testDisappear = (!Lpol[i]->isVisible(cMo, angleDisappears, false, cam, I));
538  }
539 #endif
540  else
541  testDisappear = (!Lpol[i]->isVisible(cMo, angleDisappears, false, cam, I));
542  }
543 
544  // test if the face is still visible
545  if(testDisappear){
546 // std::cout << "Face " << i << " disappears" << std::endl;
547  changed = true;
548  Lpol[i]->isvisible = false;
549  }
550  else {
551  //nbVisiblePolygon++;
552  Lpol[i]->isvisible = true;
553 
554  if(nbCornerInsidePrev > Lpol[i]->getNbCornerInsidePrevImage())
555  changed = true;
556  }
557  }
558  else
559  {
560  bool testAppear = true;
561 
562  if(testAppear){
563  if(useOgre)
564 #ifdef VISP_HAVE_OGRE
565  testAppear = ((Lpol[i]->isVisible(cMo, angleAppears, true, cam, I)) && isVisibleOgre(cameraPos,i));
566 #else
567  testAppear = (Lpol[i]->isVisible(cMo, angleAppears, false, cam, I));
568 #endif
569  else
570  testAppear = (Lpol[i]->isVisible(cMo, angleAppears, false, cam, I));
571  }
572 
573  if(testAppear){
574 // std::cout << "Face " << i << " appears" << std::endl;
575  Lpol[i]->isvisible = true;
576  changed = true;
577  //nbVisiblePolygon++;
578  }
579  else{
580 // std::cout << "Problem" << std::endl;
581  Lpol[i]->isvisible = false;
582  }
583  }
584  }
585  // std::cout << "Nombre de polygones visibles: " << nbVisiblePolygon << std::endl;
586  return Lpol[i]->isvisible;
587 }
588 
600 template<class PolygonType>
601 unsigned int
602 vpMbHiddenFaces<PolygonType>::setVisible(const vpImage<unsigned char>& I, const vpCameraParameters &cam, const vpHomogeneousMatrix &cMo, const double &angle, bool &changed)
603 {
604  return setVisible(I, cam, cMo, angle, angle, changed);
605 }
606 
619 template<class PolygonType>
620 unsigned int
621 vpMbHiddenFaces<PolygonType>::setVisible(const vpImage<unsigned char>& I, const vpCameraParameters &cam, const vpHomogeneousMatrix &cMo, const double &angleAppears, const double &angleDisappears, bool &changed)
622 {
623  return setVisiblePrivate(cMo,angleAppears,angleDisappears,changed,false,true,I,cam);
624 }
625 
636 template<class PolygonType>
637 unsigned int
638 vpMbHiddenFaces<PolygonType>::setVisible(const vpHomogeneousMatrix &cMo, const double &angleAppears, const double &angleDisappears, bool &changed)
639 {
640  return setVisiblePrivate(cMo,angleAppears,angleDisappears,changed,false);
641 }
642 
643 #ifdef VISP_HAVE_OGRE
644 
649 template<class PolygonType>
650 void
652 {
653  ogreInitialised = true;
654  ogre->setCameraParameters(cam);
655  ogre->setShowConfigDialog(ogreShowConfigDialog);
656  ogre->init(ogreBackground, false, true);
657 
658  for(unsigned int n = 0 ; n < Lpol.size(); n++){
659  Ogre::ManualObject* manual = ogre->getSceneManager()->createManualObject(Ogre::StringConverter::toString(n));
660 
661  manual->begin("BaseWhiteNoLighting", Ogre::RenderOperation::OT_LINE_STRIP);
662  for(unsigned int i = 0; i < Lpol[n]->nbpt; i++){
663  manual->position( (Ogre::Real)Lpol[n]->p[i].get_oX(), (Ogre::Real)Lpol[n]->p[i].get_oY(), (Ogre::Real)Lpol[n]->p[i].get_oZ());
664  manual->colour(1.0, 1.0, 1.0);
665  manual->index(i);
666  }
667 
668  manual->index(0);
669  manual->end();
670 
671  ogre->getSceneManager()->getRootSceneNode()->createChildSceneNode()->attachObject(manual);
672 
673  lOgrePolygons.push_back(manual);
674  }
675 }
676 
682 template<class PolygonType>
683 void
685 {
686  if(ogreInitialised && !ogre->isWindowHidden()){
687  for(unsigned int i = 0 ; i < Lpol.size() ; i++){
688  if(Lpol[i]->isVisible()){
689  lOgrePolygons[i]->setVisible(true);
690  }
691  else
692  lOgrePolygons[i]->setVisible(false);
693  }
694  ogre->display(ogreBackground, cMo);
695  }
696 }
697 
710 template<class PolygonType>
711 unsigned int
712 vpMbHiddenFaces<PolygonType>::setVisibleOgre(const vpImage<unsigned char>& I, const vpCameraParameters &cam, const vpHomogeneousMatrix &cMo, const double &angleAppears, const double &angleDisappears, bool &changed)
713 {
714  return setVisiblePrivate(cMo,angleAppears,angleDisappears,changed,true,true,I,cam);
715 }
716 
727 template<class PolygonType>
728 unsigned int
729 vpMbHiddenFaces<PolygonType>::setVisibleOgre(const vpHomogeneousMatrix &cMo, const double &angleAppears, const double &angleDisappears, bool &changed)
730 {
731  return setVisiblePrivate(cMo,angleAppears,angleDisappears,changed,true);
732 }
733 
742 template<class PolygonType>
743 bool
744 vpMbHiddenFaces<PolygonType>::isVisibleOgre(const vpTranslationVector &cameraPos, const unsigned int &index)
745 {
746  Ogre::Vector3 camera((Ogre::Real)cameraPos[0],(Ogre::Real)cameraPos[1],(Ogre::Real)cameraPos[2]);
747  if(!ogre->getCamera()->isVisible(lOgrePolygons[index]->getBoundingBox())){
748  lOgrePolygons[index]->setVisible(false);
749  Lpol[index]->isvisible = false;
750  return false;
751  }
752 
753  //Get the center of gravity
754  bool visible = false;
755  unsigned int nbVisible = 0;
756 
757  for(unsigned int i = 0; i < nbRayAttempts; i++)
758  {
759  Ogre::Vector3 origin(0,0,0);
760  Ogre::Real totalFactor = 0.0f;
761 
762  for(unsigned int j = 0 ; j < Lpol[index]->getNbPoint() ; j++)
763  {
764  Ogre::Real factor = 1.0f;
765 
766  if(nbRayAttempts > 1){
767  int r = rand() % 101;
768 
769  if(r != 0)
770  factor = ((Ogre::Real)r)/100.0f;
771  }
772 
773  Ogre::Vector3 tmp((Ogre::Real)Lpol[index]->getPoint(j).get_oX(), (Ogre::Real)Lpol[index]->getPoint(j).get_oY(), (Ogre::Real)Lpol[index]->getPoint(j).get_oZ());
774  tmp *= factor;
775  origin += tmp;
776  totalFactor += factor;
777  }
778 
779  origin /= totalFactor;
780 
781  Ogre::Vector3 direction = origin - camera;
782  Ogre::Real distanceCollision = direction.length();
783 
784  direction.normalise();
785  Ogre::RaySceneQuery *mRaySceneQuery = ogre->getSceneManager()->createRayQuery(Ogre::Ray(camera, direction));
786  mRaySceneQuery->setSortByDistance(true);
787 
788  Ogre::RaySceneQueryResult &result = mRaySceneQuery->execute();
789  Ogre::RaySceneQueryResult::iterator it = result.begin();
790 
791 // while(it != result.end()){
792 // std::cout << it->movable->getName() << "(" << it->distance<< ") : " << std::flush;
793 // it++;
794 // }
795 // std::cout << std::endl;
796 // it = result.begin();
797 
798  if(it != result.end())
799  if(it->movable->getName().find("SimpleRenderable") != Ogre::String::npos) //Test if the ogreBackground is intersect in first
800  it++;
801 
802  double distance, distancePrev;
803  // In a case of a two-axis aligned segment, ray collision is not always working.
804  if(Lpol[index]->getNbPoint() == 2 &&
805  (((std::fabs(Lpol[index]->getPoint(0).get_oX() - Lpol[index]->getPoint(1).get_oX()) < std::numeric_limits<double>::epsilon()) +
806  (std::fabs(Lpol[index]->getPoint(0).get_oY() - Lpol[index]->getPoint(1).get_oY()) < std::numeric_limits<double>::epsilon()) +
807  (std::fabs(Lpol[index]->getPoint(0).get_oZ() - Lpol[index]->getPoint(1).get_oZ()) < std::numeric_limits<double>::epsilon())) >= 2 ))
808  {
809  if(it != result.end())
810  {
811  if(it->movable->getName() == Ogre::StringConverter::toString(index)){
812  nbVisible++;
813  }
814  else
815  {
816  distance = it->distance;
817  // Cannot use epsilon for comparison as ray lenght is slightly different from the collision distance returned by Ogre::RaySceneQueryResult.
818  if(distance > distanceCollision || std::fabs(distance - distanceCollision) < 1e-6 /*std::fabs(distance) * std::numeric_limits<double>::epsilon()*/)
819  nbVisible++;
820  }
821  }
822  else
823  nbVisible++; // Collision not detected but present.
824  }
825  else
826  {
827  if(it != result.end())
828  {
829  distance = it->distance;
830  distancePrev = distance;
831 
832  //std::cout << "For " << Ogre::StringConverter::toString(index) << ": " << it->movable->getName() << " / " << std::flush;
833 
834  if(it->movable->getName() == Ogre::StringConverter::toString(index)){
835  nbVisible++;
836  }
837  else
838  {
839  it++;
840  while(it != result.end())
841  {
842  distance = it->distance;
843 
844  if(std::fabs(distance - distancePrev) < 1e-6 /*std::fabs(distance) * std::numeric_limits<double>::epsilon()*/){
845  //std::cout << it->movable->getName() << " / " << std::flush;
846  if(it->movable->getName() == Ogre::StringConverter::toString(index)){
847  nbVisible++;
848  break;
849  }
850  it++;
851  distancePrev = distance;
852  }
853  else
854  break;
855  }
856  }
857  }
858  }
859 
860  ogre->getSceneManager()->destroyQuery(mRaySceneQuery);
861 
862  }
863 
864  if(((double)nbVisible)/((double)nbRayAttempts) > ratioVisibleRay ||
865  std::fabs(((double)nbVisible)/((double)nbRayAttempts) - ratioVisibleRay) < ratioVisibleRay * std::numeric_limits<double>::epsilon())
866  visible = true;
867  else
868  visible = false;
869 
870  if(visible){
871  lOgrePolygons[index]->setVisible(true);
872  Lpol[index]->isvisible = true;
873  }
874  else{
875  lOgrePolygons[index]->setVisible(false);
876  Lpol[index]->isvisible = false;
877  }
878 
879  return Lpol[index]->isvisible;
880 }
881 #endif //VISP_HAVE_OGRE
882 
883 #endif // vpMbHiddenFaces
884 
const PolygonType * operator[](const unsigned int i) const
operator[] as reader.
bool isAppearing(const unsigned int i)
Implementation of the polygons management for the model-based trackers.
Implementation of an homogeneous matrix and operations on such kind of matrices.
unsigned int getNbVisiblePolygon() const
void setBackgroundSizeOgre(const unsigned int &h, const unsigned int &w)
PolygonType * operator[](const unsigned int i)
operator[] as modifier.
void setOgreShowConfigDialog(const bool showConfigDialog)
vpMbScanLine & getMbScanLineRenderer()
Implementation of an augmented reality viewer using Ogre3D 3rd party.
Definition: vpAROgre.h:89
unsigned int setVisibleOgre(const vpImage< unsigned char > &I, const vpCameraParameters &cam, const vpHomogeneousMatrix &cMo, const double &angleAppears, const double &angleDisappears, bool &changed)
void setGoodNbRayCastingAttemptsRatio(const double &ratio)
Class that defines what is a point.
Definition: vpPoint.h:59
void computeClippedPolygons(const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam)
unsigned int setVisible(const vpImage< unsigned char > &I, const vpCameraParameters &cam, const vpHomogeneousMatrix &cMo, const double &angle, bool &changed)
void initOgre(const vpCameraParameters &cam=vpCameraParameters())
bool isVisibleOgre(const vpTranslationVector &cameraPos, const unsigned int &index)
vpAROgre * getOgreContext()
double getGoodNbRayCastingAttemptsRatio()
#define vpTRACE
Definition: vpDebug.h:414
void setNbRayCastingAttemptsForVisibility(const unsigned int &attempts)
Generic class defining intrinsic camera parameters.
void extract(vpRotationMatrix &R) const
void addPolygon(PolygonType *p)
unsigned int size() const
void computeScanLineQuery(const vpPoint &a, const vpPoint &b, std::vector< std::pair< vpPoint, vpPoint > > &lines, const bool &displayResults=false)
vpHomogeneousMatrix inverse() const
bool isVisible(const unsigned int i)
unsigned int getNbRayCastingAttemptsForVisibility()
void displayOgre(const vpHomogeneousMatrix &cMo)
void computeScanLineRender(const vpCameraParameters &cam, const unsigned int &w, const unsigned int &h)
Class that consider the case of a translation vector.
bool computeVisibility(const vpHomogeneousMatrix &cMo, const double &angleAppears, const double &angleDisappears, bool &changed, bool useOgre, bool not_used, const vpImage< unsigned char > &I, const vpCameraParameters &cam, const vpTranslationVector &cameraPos, unsigned int index)
std::vector< PolygonType * > & getPolygon()