43 #include <visp3/robot/vpWireFrameSimulator.h>
49 #include <visp3/core/vpException.h>
50 #include <visp3/core/vpPoint.h>
51 #include <visp3/core/vpCameraParameters.h>
52 #include <visp3/core/vpMeterPixelConversion.h>
53 #include <visp3/core/vpPoint.h>
54 #include <visp3/core/vpIoTools.h>
57 #if defined(VISP_HAVE_COIN3D)
58 #include <Inventor/nodes/SoSeparator.h>
59 #include <Inventor/VRMLnodes/SoVRMLIndexedFaceSet.h>
60 #include <Inventor/VRMLnodes/SoVRMLIndexedLineSet.h>
61 #include <Inventor/VRMLnodes/SoVRMLCoordinate.h>
62 #include <Inventor/actions/SoWriteAction.h>
63 #include <Inventor/actions/SoSearchAction.h>
64 #include <Inventor/misc/SoChildList.h>
65 #include <Inventor/actions/SoGetMatrixAction.h>
66 #include <Inventor/actions/SoGetPrimitiveCountAction.h>
67 #include <Inventor/actions/SoToVRML2Action.h>
68 #include <Inventor/VRMLnodes/SoVRMLGroup.h>
69 #include <Inventor/VRMLnodes/SoVRMLShape.h>
72 extern Point2i *point2i;
73 extern Point2i *listpoint2i;
82 Model_3D getExtension(
const char* file);
83 void set_scene_wrl (
const char* str, Bound_scene *sc,
float factor);
89 getExtension(
const char* file)
91 std::string sfilename(file);
93 size_t bnd = sfilename.find(
"bnd");
94 size_t BND = sfilename.find(
"BND");
95 size_t wrl = sfilename.find(
"wrl");
96 size_t WRL = sfilename.find(
"WRL");
98 size_t size = sfilename.size();
100 if ((bnd>0 && bnd<size ) || (BND>0 && BND<size))
102 else if ((wrl>0 && wrl<size) || ( WRL>0 && WRL<size))
104 #if defined(VISP_HAVE_COIN3D)
107 std::cout <<
"Coin not installed, cannot read VRML files" << std::endl;
108 throw std::string(
"Coin not installed, cannot read VRML files");
111 return UNKNOWN_MODEL;
117 void set_scene (
const char* str, Bound_scene *sc,
float factor)
122 if ((fd = fopen (str,
"r")) == NULL)
124 std::string error =
"The file " + std::string(str) +
" can not be opened";
128 open_keyword (keyword_tbl);
130 open_source (fd, str);
131 malloc_Bound_scene (sc, str,(Index)BOUND_NBR);
135 if (std::fabs(factor) > std::numeric_limits<double>::epsilon())
137 for (
int i = 0; i < sc->bound.nbr; i++)
139 for (
int j = 0; j < sc->bound.ptr[i].point.nbr; j++)
141 sc->bound.ptr[i].point.ptr[j].x = sc->bound.ptr[i].point.ptr[j].x*factor;
142 sc->bound.ptr[i].point.ptr[j].y = sc->bound.ptr[i].point.ptr[j].y*factor;
143 sc->bound.ptr[i].point.ptr[j].z = sc->bound.ptr[i].point.ptr[j].z*factor;
154 #if defined(VISP_HAVE_COIN3D)
156 #ifndef DOXYGEN_SHOULD_SKIP_THIS
157 typedef struct indexFaceSet
159 indexFaceSet() : nbPt(0), pt(), nbIndex(0), index() {};
161 std::vector<vpPoint> pt;
163 std::vector<int> index;
165 #endif // DOXYGEN_SHOULD_SKIP_THIS
167 void extractFaces(SoVRMLIndexedFaceSet*, indexFaceSet *ifs);
168 void ifsToBound (Bound*, std::list<indexFaceSet*> &);
169 void destroyIfs(std::list<indexFaceSet*> &);
172 void set_scene_wrl (
const char* str, Bound_scene *sc,
float factor)
177 SbBool ok = in.openFile(str);
178 SoSeparator *sceneGraph;
179 SoVRMLGroup *sceneGraphVRML2;
182 vpERROR_TRACE(
"can't open file \"%s\" \n Please check the Marker_Less.ini file", str);
186 if(!in.isFileVRML2())
188 sceneGraph = SoDB::readAll(&in);
189 if (sceneGraph == NULL) { }
192 SoToVRML2Action tovrml2;
193 tovrml2.apply(sceneGraph);
194 sceneGraphVRML2 =tovrml2.getVRML2SceneGraph();
195 sceneGraphVRML2->ref();
200 sceneGraphVRML2 = SoDB::readAllVRML(&in);
201 if (sceneGraphVRML2 == NULL) {
205 sceneGraphVRML2->ref();
210 int nbShapes = sceneGraphVRML2->getNumChildren();
214 malloc_Bound_scene (sc, str,(Index)BOUND_NBR);
217 for (
int i = 0; i < nbShapes; i++)
220 child = sceneGraphVRML2->getChild(i);
221 if (child->getTypeId() == SoVRMLShape::getClassTypeId())
223 std::list<indexFaceSet*> ifs_list;
224 SoChildList * child2list = child->getChildren();
225 for (
int j = 0; j < child2list->getLength(); j++)
227 if (((SoNode*)child2list->get(j))->getTypeId() == SoVRMLIndexedFaceSet::getClassTypeId())
229 indexFaceSet *ifs =
new indexFaceSet;
230 SoVRMLIndexedFaceSet * face_set;
231 face_set = (SoVRMLIndexedFaceSet*)child2list->get(j);
232 extractFaces(face_set,ifs);
233 ifs_list.push_back(ifs);
245 ifsToBound (&(sc->bound.ptr[iterShapes]), ifs_list);
246 destroyIfs(ifs_list);
252 if (std::fabs(factor) > std::numeric_limits<double>::epsilon())
254 for (
int i = 0; i < sc->bound.nbr; i++)
256 for (
int j = 0; j < sc->bound.ptr[i].point.nbr; j++)
258 sc->bound.ptr[i].point.ptr[j].x = sc->bound.ptr[i].point.ptr[j].x*factor;
259 sc->bound.ptr[i].point.ptr[j].y = sc->bound.ptr[i].point.ptr[j].y*factor;
260 sc->bound.ptr[i].point.ptr[j].z = sc->bound.ptr[i].point.ptr[j].z*factor;
268 extractFaces(SoVRMLIndexedFaceSet* face_set, indexFaceSet *ifs)
272 SoVRMLCoordinate *coord = (SoVRMLCoordinate *)(face_set->coord.getValue());
273 int coordSize = coord->point.getNum();
275 ifs->nbPt = coordSize;
276 for (
int i = 0; i < coordSize; i++)
278 SbVec3f point(0,0,0);
279 point[0]=coord->point[i].getValue()[0];
280 point[1]=coord->point[i].getValue()[1];
281 point[2]=coord->point[i].getValue()[2];
282 vpPoint pt(point[0],point[1],point[2]);
283 ifs->pt.push_back(pt);
286 SoMFInt32 indexList = face_set->coordIndex;
287 int indexListSize = indexList.getNum();
289 ifs->nbIndex = indexListSize;
290 for (
int i = 0; i < indexListSize; i++)
292 int index = face_set->coordIndex[i];
293 ifs->index.push_back(index);
297 void ifsToBound (Bound* bptr, std::list<indexFaceSet*> &ifs_list)
300 for(std::list<indexFaceSet*>::const_iterator it=ifs_list.begin(); it!=ifs_list.end(); ++it){
303 bptr->point.nbr = (Index)nbPt;
304 bptr->point.ptr = (Point3f *) malloc ((
unsigned int)nbPt *
sizeof (Point3f));
307 unsigned int iter = 0;
308 for (std::list<indexFaceSet*>::const_iterator it=ifs_list.begin(); it!=ifs_list.end(); ++it)
310 indexFaceSet* ifs = *it;
311 for (
unsigned int j = 0; j < (
unsigned int)ifs->nbPt; j++)
313 bptr->point.ptr[iter].x = (float)ifs->pt[j].get_oX();
314 bptr->point.ptr[iter].y = (float)ifs->pt[j].get_oY();
315 bptr->point.ptr[iter].z = (float)ifs->pt[j].get_oZ();
320 unsigned int nbFace = 0;
322 std::list<int> indSize;
324 for (std::list<indexFaceSet*>::const_iterator it=ifs_list.begin(); it!=ifs_list.end(); ++it)
326 indexFaceSet* ifs = *it;
327 for (
unsigned int j = 0; j < (
unsigned int)ifs->nbIndex; j++)
329 if(ifs->index[j] == -1)
332 indSize.push_back(indice);
339 bptr->face.nbr = (Index)nbFace;
340 bptr->face.ptr = (Face *) malloc (nbFace *
sizeof (Face));
343 std::list<int>::const_iterator iter_indSize = indSize.begin();
344 for (
unsigned int i = 0; i < indSize.size(); i++)
346 bptr->face.ptr[i].vertex.nbr = (Index)*iter_indSize;
347 bptr->face.ptr[i].vertex.ptr = (Index *) malloc ((
unsigned int)*iter_indSize *
sizeof (Index));
353 for (std::list<indexFaceSet*>::const_iterator it=ifs_list.begin(); it!=ifs_list.end(); ++it)
355 indexFaceSet* ifs = *it;
357 for (
unsigned int j = 0; j < (
unsigned int)ifs->nbIndex; j++)
359 if(ifs->index[j] != -1)
361 bptr->face.ptr[indice].vertex.ptr[iter] = (Index)(ifs->index[j] + offset);
374 void destroyIfs(std::list<indexFaceSet*> &ifs_list)
376 for(std::list<indexFaceSet*>::const_iterator it=ifs_list.begin(); it!=ifs_list.end(); ++it){
382 void set_scene_wrl (
const char* , Bound_scene* ,
float )
393 for (
unsigned int i = 0; i < 4; i++) {
394 for (
unsigned int j = 0; j < 4; j++)
395 jlcM[j][i] = (
float)vpM[i][j];
408 Byte b = (Byte) *get_rfstack ();
412 memmove((
char *) m, (
char *) mat,
sizeof (Matrix));
413 View_to_Matrix (get_vwstack (), *(get_tmstack ()));
414 postmult_matrix (m, *(get_tmstack ()));
416 bend = bp + sc.bound.nbr;
417 for (; bp < bend; bp++)
419 if ((clip = clipping_Bound (bp, m)) != NULL)
421 Face *fp = clip->face.ptr;
422 Face *fend = fp + clip->face.nbr;
424 set_Bound_face_display (clip, b);
426 point_3D_2D (clip->point.ptr, clip->point.nbr,(
int)I.
getWidth(),(int)I.
getHeight(),point2i);
427 for (; fp < fend; fp++)
431 wireframe_Face (fp, point2i);
432 Point2i *pt = listpoint2i;
433 for (
int i = 1; i < fp->vertex.nbr; i++)
438 if (fp->vertex.nbr > 2)
458 Byte b = (Byte) *get_rfstack ();
462 memmove((
char *) m, (
char *) mat,
sizeof (Matrix));
463 View_to_Matrix (get_vwstack (), *(get_tmstack ()));
464 postmult_matrix (m, *(get_tmstack ()));
466 bend = bp + sc.bound.nbr;
467 for (; bp < bend; bp++)
469 if ((clip = clipping_Bound (bp, m)) != NULL)
471 Face *fp = clip->face.ptr;
472 Face *fend = fp + clip->face.nbr;
474 set_Bound_face_display (clip, b);
476 point_3D_2D (clip->point.ptr, clip->point.nbr,(
int)I.
getWidth(),(int)I.
getHeight(),point2i);
477 for (; fp < fend; fp++)
481 wireframe_Face (fp, point2i);
482 Point2i *pt = listpoint2i;
483 for (
int i = 1; i < fp->vertex.nbr; i++)
488 if (fp->vertex.nbr > 2)
509 : scene(), desiredScene(), camera(), objectImage(), fMo(), fMc(), camMf(),
510 refMo(), cMo(), cdMo(), object(PLATE), desiredObject(D_STANDARD),
512 desColor(
vpColor::red), sceneInitialized(false), displayCameraTrajectory(true),
513 cameraTrajectory(), poseList(), fMoList(), nbrPtLimit(1000), old_iPr(), old_iPz(),
514 old_iPt(), blockedr(false), blockedz(false), blockedt(false), blocked(false),
515 camMf2(), f2Mf(), px_int(1), py_int(1), px_ext(1), py_ext(1), displayObject(false),
516 displayDesiredObject(false), displayCamera(false), displayImageSimulator(false),
517 cameraFactor(1.), camTrajType(CT_LINE), extCamChanged(false), rotz(), thickness_(1), scene_dir()
521 std::vector<std::string> scene_dirs =
vpIoTools::splitChain(std::string(VISP_SCENES_DIR), std::string(
";"));
522 bool sceneDirExists =
false;
523 for(
size_t i=0; i < scene_dirs.size(); i++)
525 scene_dir = scene_dirs[i];
526 sceneDirExists =
true;
529 if (! sceneDirExists) {
532 std::cout <<
"The simulator uses data from VISP_SCENES_DIR=" << scene_dir << std::endl;
535 std::cout <<
"Cannot get VISP_SCENES_DIR environment variable" << std::endl;
549 scene.bound.ptr = NULL;
570 free_Bound_scene (&(this->
scene));
572 free_Bound_scene (&(this->
camera));
598 char name_cam[FILENAME_MAX];
599 char name[FILENAME_MAX];
604 const char *scene_dir_ = scene_dir.c_str();
605 if (strlen(scene_dir_) >= FILENAME_MAX) {
607 "Not enough memory to intialize the camera name"));
610 strcpy(name_cam, scene_dir_);
613 strcat(name_cam,
"/camera.bnd");
618 strcat(name_cam,
"/tool.bnd");
619 set_scene(name_cam,&(this->
camera),1.0);
622 strcpy(name, scene_dir_);
625 case THREE_PTS : {strcat(name,
"/3pts.bnd");
break; }
626 case CUBE : { strcat(name,
"/cube.bnd");
break; }
627 case PLATE : { strcat(name,
"/plate.bnd");
break; }
628 case SMALL_PLATE : { strcat(name,
"/plate_6cm.bnd");
break; }
629 case RECTANGLE : { strcat(name,
"/rectangle.bnd");
break; }
630 case SQUARE_10CM : { strcat(name,
"/square10cm.bnd");
break; }
631 case DIAMOND : { strcat(name,
"/diamond.bnd");
break; }
632 case TRAPEZOID : { strcat(name,
"/trapezoid.bnd");
break; }
633 case THREE_LINES : { strcat(name,
"/line.bnd");
break; }
634 case ROAD : { strcat(name,
"/road.bnd");
break; }
635 case TIRE : { strcat(name,
"/circles2.bnd");
break; }
636 case PIPE : { strcat(name,
"/pipe.bnd");
break; }
637 case CIRCLE : { strcat(name,
"/circle.bnd");
break; }
638 case SPHERE : { strcat(name,
"/sphere.bnd");
break; }
639 case CYLINDER : { strcat(name,
"/cylinder.bnd");
break; }
640 case PLAN: { strcat(name,
"/plan.bnd");
break; }
641 case POINT_CLOUD: { strcat(name,
"/point_cloud.bnd");
break; }
643 set_scene(name,&(this->
scene),1.0);
645 scene_dir_ = scene_dir.c_str();
646 if (strlen(scene_dir_) >= FILENAME_MAX) {
648 "Not enough memory to intialize the desired object name"));
655 strcpy(name, scene_dir_);
656 strcat(name,
"/circle_sq2.bnd");
659 strcpy(name, scene_dir_);
660 strcat(name,
"/tool.bnd");
665 if (obj ==
PIPE) load_rfstack(IS_INSIDE);
666 else add_rfstack(IS_BACK);
668 add_vwstack (
"start",
"depth", 0.0, 100.0);
669 add_vwstack (
"start",
"window", -0.1,0.1,-0.1,0.1);
670 add_vwstack (
"start",
"type", PERSPECTIVE);
712 char name_cam[FILENAME_MAX];
713 char name[FILENAME_MAX];
718 const char *scene_dir_ = scene_dir.c_str();
719 if (strlen(scene_dir_) >= FILENAME_MAX) {
721 "Not enough memory to intialize the camera name"));
724 strcpy(name_cam, scene_dir_);
725 strcat(name_cam,
"/camera.bnd");
728 if (strlen(obj) >= FILENAME_MAX) {
730 "Not enough memory to intialize the name"));
735 model = getExtension(obj);
736 if (model == BND_MODEL)
737 set_scene(name,&(this->
scene),1.0);
738 else if (model == WRL_MODEL)
739 set_scene_wrl(name,&(this->
scene),1.0);
740 else if (model == UNKNOWN_MODEL)
745 if (strlen(desired_object) >= FILENAME_MAX) {
747 "Not enough memory to intialize the camera name"));
750 strcpy(name,desired_object);
751 model = getExtension(desired_object);
752 if (model == BND_MODEL)
754 else if (model == WRL_MODEL)
756 else if (model == UNKNOWN_MODEL)
761 add_rfstack(IS_BACK);
763 add_vwstack (
"start",
"depth", 0.0, 100.0);
764 add_vwstack (
"start",
"window", -0.1,0.1,-0.1,0.1);
765 add_vwstack (
"start",
"type", PERSPECTIVE);
804 char name_cam[FILENAME_MAX];
805 char name[FILENAME_MAX];
809 const char *scene_dir_ = scene_dir.c_str();
810 if (strlen(scene_dir_) >= FILENAME_MAX) {
812 "Not enough memory to intialize the camera name"));
815 strcpy(name_cam, scene_dir_);
816 strcat(name_cam,
"/camera.bnd");
819 strcpy(name, scene_dir_);
822 case THREE_PTS : {strcat(name,
"/3pts.bnd");
break; }
823 case CUBE : { strcat(name,
"/cube.bnd");
break; }
824 case PLATE : { strcat(name,
"/plate.bnd");
break; }
825 case SMALL_PLATE : { strcat(name,
"/plate_6cm.bnd");
break; }
826 case RECTANGLE : { strcat(name,
"/rectangle.bnd");
break; }
827 case SQUARE_10CM : { strcat(name,
"/square10cm.bnd");
break; }
828 case DIAMOND : { strcat(name,
"/diamond.bnd");
break; }
829 case TRAPEZOID : { strcat(name,
"/trapezoid.bnd");
break; }
830 case THREE_LINES : { strcat(name,
"/line.bnd");
break; }
831 case ROAD : { strcat(name,
"/road.bnd");
break; }
832 case TIRE : { strcat(name,
"/circles2.bnd");
break; }
833 case PIPE : { strcat(name,
"/pipe.bnd");
break; }
834 case CIRCLE : { strcat(name,
"/circle.bnd");
break; }
835 case SPHERE : { strcat(name,
"/sphere.bnd");
break; }
836 case CYLINDER : { strcat(name,
"/cylinder.bnd");
break; }
837 case PLAN: { strcat(name,
"/plan.bnd");
break; }
838 case POINT_CLOUD: { strcat(name,
"/point_cloud.bnd");
break; }
840 set_scene(name,&(this->
scene),1.0);
842 if (obj ==
PIPE) load_rfstack(IS_INSIDE);
843 else add_rfstack(IS_BACK);
845 add_vwstack (
"start",
"depth", 0.0, 100.0);
846 add_vwstack (
"start",
"window", -0.1,0.1,-0.1,0.1);
847 add_vwstack (
"start",
"type", PERSPECTIVE);
887 char name_cam[FILENAME_MAX];
888 char name[FILENAME_MAX];
892 const char *scene_dir_ = scene_dir.c_str();
893 if (strlen(scene_dir_) >= FILENAME_MAX) {
895 "Not enough memory to intialize the camera name"));
898 strcpy(name_cam, scene_dir_);
899 strcat(name_cam,
"/camera.bnd");
902 if (strlen(obj) >= FILENAME_MAX) {
904 "Not enough memory to intialize the name"));
909 model = getExtension(obj);
910 if (model == BND_MODEL)
911 set_scene(name,&(this->
scene),1.0);
912 else if (model == WRL_MODEL)
913 set_scene_wrl(name,&(this->
scene),1.0);
914 else if (model == UNKNOWN_MODEL)
919 add_rfstack(IS_BACK);
921 add_vwstack (
"start",
"depth", 0.0, 100.0);
922 add_vwstack (
"start",
"window", -0.1,0.1,-0.1,0.1);
923 add_vwstack (
"start",
"type", PERSPECTIVE);
978 float o44c[4][4],o44cd[4][4],x,y,z;
979 Matrix
id = IDENTITY_MATRIX;
998 add_vwstack (
"start",
"cop", o44c[3][0],o44c[3][1],o44c[3][2]);
999 x = o44c[2][0] + o44c[3][0];
1000 y = o44c[2][1] + o44c[3][1];
1001 z = o44c[2][2] + o44c[3][2];
1002 add_vwstack (
"start",
"vrp", x,y,z);
1003 add_vwstack (
"start",
"vpn", o44c[2][0],o44c[2][1],o44c[2][2]);
1004 add_vwstack (
"start",
"vup", o44c[1][0],o44c[1][1],o44c[1][2]);
1005 add_vwstack (
"start",
"window", -u, u, -v, v);
1010 add_vwstack (
"start",
"cop", o44cd[3][0],o44cd[3][1],o44cd[3][2]);
1011 x = o44cd[2][0] + o44cd[3][0];
1012 y = o44cd[2][1] + o44cd[3][1];
1013 z = o44cd[2][2] + o44cd[3][2];
1014 add_vwstack (
"start",
"vrp", x,y,z);
1015 add_vwstack (
"start",
"vpn", o44cd[2][0],o44cd[2][1],o44cd[2][2]);
1016 add_vwstack (
"start",
"vup", o44cd[1][0],o44cd[1][1],o44cd[1][2]);
1017 add_vwstack (
"start",
"window", -u, u, -v, v);
1037 bool changed =
false;
1041 if (std::fabs(displacement[2][3]) > std::numeric_limits<double>::epsilon() )
1064 float w44o[4][4],w44cext[4][4],w44c[4][4],x,y,z;
1067 vp2jlc_matrix(
fMc,w44c);
1068 vp2jlc_matrix(
fMo,w44o);
1071 add_vwstack (
"start",
"cop", w44cext[3][0],w44cext[3][1],w44cext[3][2]);
1072 x = w44cext[2][0] + w44cext[3][0];
1073 y = w44cext[2][1] + w44cext[3][1];
1074 z = w44cext[2][2] + w44cext[3][2];
1075 add_vwstack (
"start",
"vrp", x,y,z);
1076 add_vwstack (
"start",
"vpn", w44cext[2][0],w44cext[2][1],w44cext[2][2]);
1077 add_vwstack (
"start",
"vup", w44cext[1][0],w44cext[1][1],w44cext[1][2]);
1078 add_vwstack (
"start",
"window", -u, u, -v, v);
1081 add_vwstack (
"start",
"type", PERSPECTIVE);
1116 std::list<vpHomogeneousMatrix>::const_iterator iter_poseList =
poseList.begin();
1117 std::list<vpHomogeneousMatrix>::const_iterator iter_fMoList =
fMoList.begin();
1119 while ((iter_poseList !=
poseList.end()) && (iter_fMoList !=
fMoList.end()))
1180 float w44o[4][4],w44cext[4][4],w44c[4][4],x,y,z;
1200 vp2jlc_matrix(camMft.
inverse(),w44cext);
1202 vp2jlc_matrix(
fMo,w44o);
1204 add_vwstack (
"start",
"cop", w44cext[3][0],w44cext[3][1],w44cext[3][2]);
1205 x = w44cext[2][0] + w44cext[3][0];
1206 y = w44cext[2][1] + w44cext[3][1];
1207 z = w44cext[2][2] + w44cext[3][2];
1208 add_vwstack (
"start",
"vrp", x,y,z);
1209 add_vwstack (
"start",
"vpn", w44cext[2][0],w44cext[2][1],w44cext[2][2]);
1210 add_vwstack (
"start",
"vup", w44cext[1][0],w44cext[1][1],w44cext[1][2]);
1211 add_vwstack (
"start",
"window", -u, u, -v, v);
1263 float o44c[4][4],o44cd[4][4],x,y,z;
1264 Matrix
id = IDENTITY_MATRIX;
1283 add_vwstack (
"start",
"cop", o44c[3][0],o44c[3][1],o44c[3][2]);
1284 x = o44c[2][0] + o44c[3][0];
1285 y = o44c[2][1] + o44c[3][1];
1286 z = o44c[2][2] + o44c[3][2];
1287 add_vwstack (
"start",
"vrp", x,y,z);
1288 add_vwstack (
"start",
"vpn", o44c[2][0],o44c[2][1],o44c[2][2]);
1289 add_vwstack (
"start",
"vup", o44c[1][0],o44c[1][1],o44c[1][2]);
1290 add_vwstack (
"start",
"window", -u, u, -v, v);
1295 add_vwstack (
"start",
"cop", o44cd[3][0],o44cd[3][1],o44cd[3][2]);
1296 x = o44cd[2][0] + o44cd[3][0];
1297 y = o44cd[2][1] + o44cd[3][1];
1298 z = o44cd[2][2] + o44cd[3][2];
1299 add_vwstack (
"start",
"vrp", x,y,z);
1300 add_vwstack (
"start",
"vpn", o44cd[2][0],o44cd[2][1],o44cd[2][2]);
1301 add_vwstack (
"start",
"vup", o44cd[1][0],o44cd[1][1],o44cd[1][2]);
1302 add_vwstack (
"start",
"window", -u, u, -v, v);
1322 bool changed =
false;
1326 if (std::fabs(displacement[2][3]) > std::numeric_limits<double>::epsilon() )
1349 float w44o[4][4],w44cext[4][4],w44c[4][4],x,y,z;
1352 vp2jlc_matrix(
fMc,w44c);
1353 vp2jlc_matrix(
fMo,w44o);
1356 add_vwstack (
"start",
"cop", w44cext[3][0],w44cext[3][1],w44cext[3][2]);
1357 x = w44cext[2][0] + w44cext[3][0];
1358 y = w44cext[2][1] + w44cext[3][1];
1359 z = w44cext[2][2] + w44cext[3][2];
1360 add_vwstack (
"start",
"vrp", x,y,z);
1361 add_vwstack (
"start",
"vpn", w44cext[2][0],w44cext[2][1],w44cext[2][2]);
1362 add_vwstack (
"start",
"vup", w44cext[1][0],w44cext[1][1],w44cext[1][2]);
1363 add_vwstack (
"start",
"window", -u, u, -v, v);
1366 add_vwstack (
"start",
"type", PERSPECTIVE);
1399 std::list<vpHomogeneousMatrix>::const_iterator iter_poseList =
poseList.begin();
1400 std::list<vpHomogeneousMatrix>::const_iterator iter_fMoList =
fMoList.begin();
1402 while ((iter_poseList!=
poseList.end()) && (iter_fMoList!=
fMoList.end()) )
1463 float w44o[4][4],w44cext[4][4],w44c[4][4],x,y,z;
1483 vp2jlc_matrix(camMft.
inverse(),w44cext);
1485 vp2jlc_matrix(
fMo,w44o);
1487 add_vwstack (
"start",
"cop", w44cext[3][0],w44cext[3][1],w44cext[3][2]);
1488 x = w44cext[2][0] + w44cext[3][0];
1489 y = w44cext[2][1] + w44cext[3][1];
1490 z = w44cext[2][2] + w44cext[3][2];
1491 add_vwstack (
"start",
"vrp", x,y,z);
1492 add_vwstack (
"start",
"vpn", w44cext[2][0],w44cext[2][1],w44cext[2][2]);
1493 add_vwstack (
"start",
"vup", w44cext[1][0],w44cext[1][1],w44cext[1][2]);
1494 add_vwstack (
"start",
"window", -u, u, -v, v);
1528 if (list_cMo.size() != list_fMo.size())
1535 std::list<vpHomogeneousMatrix>::const_iterator it_cMo = list_cMo.begin();
1536 std::list<vpHomogeneousMatrix>::const_iterator it_fMo = list_fMo.begin();
1538 while ((it_cMo != list_cMo.end()) && (it_fMo != list_fMo.end()))
1568 if (list_cMo.size() != list_fMo.size())
1575 std::list<vpHomogeneousMatrix>::const_iterator it_cMo = list_cMo.begin();
1576 std::list<vpHomogeneousMatrix>::const_iterator it_fMo = list_fMo.begin();
1578 while ((it_cMo != list_cMo.end()) && (it_fMo != list_fMo.end()))
1604 bool clicked =
false;
1605 bool clickedUp =
false;
1658 anglei = diffi*360/width;
1659 anglej = diffj*360/width;
1679 mov.
buildFrom(diffj*0.01,diffi*0.01,0,0,0,0);
1698 bool clicked =
false;
1699 bool clickedUp =
false;
1754 anglei = diffi*360/width;
1755 anglej = diffj*360/width;
1775 mov.
buildFrom(diffj*0.01,diffi*0.01,0,0,0,0);
bool displayImageSimulator
The object displayed at the desired position is the same than the scene object defined in vpSceneObje...
A cylinder of 80cm length and 10cm radius.
A tire represented by 2 circles with radius 10cm and 15cm.
unsigned int getWidth() const
Three parallel lines with equation y=-5, y=0, y=5.
A plane represented by a 56cm by 56cm plate with a grid of 49 squares inside.
Implementation of an homogeneous matrix and operations on such kind of matrices.
A plate with 8 points at coordinates (0.05,0,0), (0.15,0.05,0), (0.2,0.2,0), (-0.05,0.2,0), (-0.15,-0.1,0), (-0.1,-0.1,0), (-0.05,0.05,0) and (0.5,0,0). ach point is represented by a circle with 2cm radius.
void getImage(vpImage< unsigned char > &I, const vpCameraParameters &cam)
A 40cm by 40cm plate with 4 points at coordinates (-0.1,-0.1,0), (0.1,-0.1,0), (0.1,0.1,0), (0.1,0.1,0). Each point is represented by a circle with 2cm radius.
static void convertPoint(const vpCameraParameters &cam, const double &x, const double &y, double &u, double &v)
Point coordinates conversion from normalized coordinates in meter to pixel coordinates ...
Class to define colors available for display functionnalities.
A cylindrical tool is attached to the camera.
virtual bool getClickUp(vpImagePoint &ip, vpMouseButton::vpMouseButtonType &button, bool blocking=true)=0
std::list< vpImageSimulator > objectImage
error that can be emited by ViSP classes.
std::list< vpImagePoint > cameraTrajectory
void track(const vpHomogeneousMatrix &cMo)
double get_y() const
Get the point y coordinate in the image plane.
A 40cm by 40cm plate with 4 points at coordinates (-0.05,0.05,0), (0.05,0.05,0), (0.05,-0.05,0), (-0.05,-0.05,0). Each point is represented by a circle with 2cm radius.
virtual ~vpWireFrameSimulator()
std::list< vpHomogeneousMatrix > fMoList
Class that defines what is a point.
static Type maximum(const Type &a, const Type &b)
4 points at coordinates (-0.03,-0.03,0), (0.03,-0.03,0), (0.03,0.03,0), (0.03,0.03,0). Each point is represented by a circle with 1cm radius.
vpCameraParameters getExternalCameraParameters(const vpImage< unsigned char > &I) const
void setCameraPosition(const vpHomogeneousMatrix &cMt)
virtual bool getPointerPosition(vpImagePoint &ip)=0
The object displayed at the desired position is a circle.
A 40cm by 40cm plate with 4 points at coordinates (-0.025,-0.05,0), (-0.075,0.05,0), (0.075,0.05,0), (0.025,-0.05,0). Each point is represented by a circle with 2cm radius.
static void display(const vpImage< unsigned char > &I)
Class which enables to project an image in the 3D space and get the view of a virtual camera...
void initScene(const vpSceneObject &obj, const vpSceneDesiredObject &desiredObject)
bool displayDesiredObject
double get_x() const
Get the point x coordinate in the image plane.
static Type minimum(const Type &a, const Type &b)
A 40cm by 40cm plate with 3 points at coordinates (0,0,0), (0.1,0,0), (0,0.1,0). Each point is repres...
void getExternalImage(vpImage< unsigned char > &I)
void buildFrom(const vpTranslationVector &t, const vpRotationMatrix &R)
vpCameraParameters getInternalCameraParameters(const vpImage< unsigned char > &I) const
static double rad(double deg)
void displayTrajectory(const vpImage< unsigned char > &I, const std::list< vpHomogeneousMatrix > &list_cMo, const std::list< vpHomogeneousMatrix > &list_fMo, const vpHomogeneousMatrix &camMf)
vpCameraTrajectoryDisplayType camTrajType
A 40cm by 40cm plate with 4 points at coordinates (-0.07,-0.05,0), (0.07,0.05,0), (0...
vpSceneDesiredObject desiredObject
A 40cm by 40cm plate with 4 points at coordinates (0,-0.1,0), (0.1,0,0), (0,0.1,0), (-0.1,0,0). Each point is represented by a circle with 2cm radius.
void getInternalImage(vpImage< unsigned char > &I)
void display_scene(Matrix mat, Bound_scene &sc, const vpImage< vpRGBa > &I, const vpColor &color)
bool displayCameraTrajectory
vpHomogeneousMatrix camMf
vpHomogeneousMatrix navigation(const vpImage< vpRGBa > &I, bool &changed)
Three parallel lines representing a road.
void setWorldCoordinates(const double oX, const double oY, const double oZ)
vpImagePoint projectCameraTrajectory(const vpImage< vpRGBa > &I, const vpHomogeneousMatrix &cMo, const vpHomogeneousMatrix &fMo)
vpHomogeneousMatrix inverse() const
A pipe represented by a cylinder of 25 cm length and 15cm radius.
unsigned int getHeight() const
virtual bool getClick(bool blocking=true)=0
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
virtual void displayLine(const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1)=0
virtual void displayPoint(const vpImagePoint &ip, const vpColor &color)=0
std::list< vpHomogeneousMatrix > poseList
vpHomogeneousMatrix camMf2