47 #include <visp/vpWireFrameSimulator.h>
53 #include <visp/vpSimulatorException.h>
54 #include <visp/vpPoint.h>
55 #include <visp/vpCameraParameters.h>
56 #include <visp/vpMeterPixelConversion.h>
57 #include <visp/vpPoint.h>
58 #include <visp/vpIoTools.h>
61 #if defined(VISP_HAVE_COIN)
62 #include <Inventor/nodes/SoSeparator.h>
63 #include <Inventor/VRMLnodes/SoVRMLIndexedFaceSet.h>
64 #include <Inventor/VRMLnodes/SoVRMLIndexedLineSet.h>
65 #include <Inventor/VRMLnodes/SoVRMLCoordinate.h>
66 #include <Inventor/actions/SoWriteAction.h>
67 #include <Inventor/actions/SoSearchAction.h>
68 #include <Inventor/misc/SoChildList.h>
69 #include <Inventor/actions/SoGetMatrixAction.h>
70 #include <Inventor/actions/SoGetPrimitiveCountAction.h>
71 #include <Inventor/actions/SoToVRML2Action.h>
72 #include <Inventor/VRMLnodes/SoVRMLGroup.h>
73 #include <Inventor/VRMLnodes/SoVRMLShape.h>
76 extern Point2i *point2i;
77 extern Point2i *listpoint2i;
86 Model_3D getExtension(
const char* file);
87 void set_scene_wrl (
const char* str, Bound_scene *sc,
float factor);
93 getExtension(
const char* file)
95 std::string sfilename(file);
97 size_t bnd = sfilename.find(
"bnd");
98 size_t BND = sfilename.find(
"BND");
99 size_t wrl = sfilename.find(
"wrl");
100 size_t WRL = sfilename.find(
"WRL");
102 size_t size = sfilename.size();
104 if ((bnd>0 && bnd<size ) || (BND>0 && BND<size))
106 else if ((wrl>0 && wrl<size) || ( WRL>0 && WRL<size))
108 #if defined(VISP_HAVE_COIN)
111 std::cout <<
"Coin not installed, cannot read VRML files" << std::endl;
112 throw std::string(
"Coin not installed, cannot read VRML files");
115 return UNKNOWN_MODEL;
121 void set_scene (
const char* str, Bound_scene *sc,
float factor)
126 if ((fd = fopen (str,
"r")) == NULL)
128 std::string error =
"The file " + std::string(str) +
" can not be opened";
132 open_keyword (keyword_tbl);
134 open_source (fd, str);
135 malloc_Bound_scene (sc, str,(Index)BOUND_NBR);
139 if (std::fabs(factor) > std::numeric_limits<double>::epsilon())
141 for (
int i = 0; i < sc->bound.nbr; i++)
143 for (
int j = 0; j < sc->bound.ptr[i].point.nbr; j++)
145 sc->bound.ptr[i].point.ptr[j].x = sc->bound.ptr[i].point.ptr[j].x*factor;
146 sc->bound.ptr[i].point.ptr[j].y = sc->bound.ptr[i].point.ptr[j].y*factor;
147 sc->bound.ptr[i].point.ptr[j].z = sc->bound.ptr[i].point.ptr[j].z*factor;
158 #if defined(VISP_HAVE_COIN)
160 #ifndef DOXYGEN_SHOULD_SKIP_THIS
161 typedef struct indexFaceSet
163 indexFaceSet() : nbPt(0), pt(), nbIndex(0), index() {};
165 std::vector<vpPoint> pt;
167 std::vector<int> index;
169 #endif // DOXYGEN_SHOULD_SKIP_THIS
171 void extractFaces(SoVRMLIndexedFaceSet*, indexFaceSet *ifs);
172 void ifsToBound (Bound*, std::list<indexFaceSet*> &);
173 void destroyIfs(std::list<indexFaceSet*> &);
176 void set_scene_wrl (
const char* str, Bound_scene *sc,
float factor)
181 SbBool ok = in.openFile(str);
182 SoSeparator *sceneGraph;
183 SoVRMLGroup *sceneGraphVRML2;
186 vpERROR_TRACE(
"can't open file \"%s\" \n Please check the Marker_Less.ini file", str);
190 if(!in.isFileVRML2())
192 sceneGraph = SoDB::readAll(&in);
193 if (sceneGraph == NULL) { }
196 SoToVRML2Action tovrml2;
197 tovrml2.apply(sceneGraph);
198 sceneGraphVRML2 =tovrml2.getVRML2SceneGraph();
199 sceneGraphVRML2->ref();
204 sceneGraphVRML2 = SoDB::readAllVRML(&in);
205 if (sceneGraphVRML2 == NULL) {
209 sceneGraphVRML2->ref();
214 int nbShapes = sceneGraphVRML2->getNumChildren();
218 malloc_Bound_scene (sc, str,(Index)BOUND_NBR);
221 for (
int i = 0; i < nbShapes; i++)
224 child = sceneGraphVRML2->getChild(i);
225 if (child->getTypeId() == SoVRMLShape::getClassTypeId())
227 std::list<indexFaceSet*> ifs_list;
228 SoChildList * child2list = child->getChildren();
229 for (
int j = 0; j < child2list->getLength(); j++)
231 if (((SoNode*)child2list->get(j))->getTypeId() == SoVRMLIndexedFaceSet::getClassTypeId())
233 indexFaceSet *ifs =
new indexFaceSet;
234 SoVRMLIndexedFaceSet * face_set;
235 face_set = (SoVRMLIndexedFaceSet*)child2list->get(j);
236 extractFaces(face_set,ifs);
237 ifs_list.push_back(ifs);
249 ifsToBound (&(sc->bound.ptr[iterShapes]), ifs_list);
250 destroyIfs(ifs_list);
256 if (std::fabs(factor) > std::numeric_limits<double>::epsilon())
258 for (
int i = 0; i < sc->bound.nbr; i++)
260 for (
int j = 0; j < sc->bound.ptr[i].point.nbr; j++)
262 sc->bound.ptr[i].point.ptr[j].x = sc->bound.ptr[i].point.ptr[j].x*factor;
263 sc->bound.ptr[i].point.ptr[j].y = sc->bound.ptr[i].point.ptr[j].y*factor;
264 sc->bound.ptr[i].point.ptr[j].z = sc->bound.ptr[i].point.ptr[j].z*factor;
272 extractFaces(SoVRMLIndexedFaceSet* face_set, indexFaceSet *ifs)
276 SoVRMLCoordinate *coord = (SoVRMLCoordinate *)(face_set->coord.getValue());
277 int coordSize = coord->point.getNum();
279 ifs->nbPt = coordSize;
280 for (
int i = 0; i < coordSize; i++)
282 SbVec3f point(0,0,0);
283 point[0]=coord->point[i].getValue()[0];
284 point[1]=coord->point[i].getValue()[1];
285 point[2]=coord->point[i].getValue()[2];
288 ifs->pt.push_back(pt);
291 SoMFInt32 indexList = face_set->coordIndex;
292 int indexListSize = indexList.getNum();
294 ifs->nbIndex = indexListSize;
295 for (
int i = 0; i < indexListSize; i++)
297 int index = face_set->coordIndex[i];
298 ifs->index.push_back(index);
302 void ifsToBound (Bound* bptr, std::list<indexFaceSet*> &ifs_list)
305 for(std::list<indexFaceSet*>::const_iterator it=ifs_list.begin(); it!=ifs_list.end(); ++it){
308 bptr->point.nbr = (Index)nbPt;
309 bptr->point.ptr = (Point3f *) malloc ((
unsigned int)nbPt *
sizeof (Point3f));
312 unsigned int iter = 0;
313 for (std::list<indexFaceSet*>::const_iterator it=ifs_list.begin(); it!=ifs_list.end(); ++it)
315 indexFaceSet* ifs = *it;
316 for (
unsigned int j = 0; j < (
unsigned int)ifs->nbPt; j++)
318 bptr->point.ptr[iter].x = (float)ifs->pt[j].get_oX();
319 bptr->point.ptr[iter].y = (float)ifs->pt[j].get_oY();
320 bptr->point.ptr[iter].z = (float)ifs->pt[j].get_oZ();
325 unsigned int nbFace = 0;
327 std::list<int> indSize;
329 for (std::list<indexFaceSet*>::const_iterator it=ifs_list.begin(); it!=ifs_list.end(); ++it)
331 indexFaceSet* ifs = *it;
332 for (
unsigned int j = 0; j < (
unsigned int)ifs->nbIndex; j++)
334 if(ifs->index[j] == -1)
337 indSize.push_back(indice);
344 bptr->face.nbr = (Index)nbFace;
345 bptr->face.ptr = (Face *) malloc (nbFace *
sizeof (Face));
348 std::list<int>::const_iterator iter_indSize = indSize.begin();
349 for (
unsigned int i = 0; i < indSize.size(); i++)
351 bptr->face.ptr[i].vertex.nbr = (Index)*iter_indSize;
352 bptr->face.ptr[i].vertex.ptr = (Index *) malloc ((
unsigned int)*iter_indSize *
sizeof (Index));
358 for (std::list<indexFaceSet*>::const_iterator it=ifs_list.begin(); it!=ifs_list.end(); ++it)
360 indexFaceSet* ifs = *it;
362 for (
unsigned int j = 0; j < (
unsigned int)ifs->nbIndex; j++)
364 if(ifs->index[j] != -1)
366 bptr->face.ptr[indice].vertex.ptr[iter] = (Index)(ifs->index[j] + offset);
379 void destroyIfs(std::list<indexFaceSet*> &ifs_list)
381 for(std::list<indexFaceSet*>::const_iterator it=ifs_list.begin(); it!=ifs_list.end(); ++it){
387 void set_scene_wrl (
const char* , Bound_scene* ,
float )
398 for (
unsigned int i = 0; i < 4; i++) {
399 for (
unsigned int j = 0; j < 4; j++)
400 jlcM[j][i] = (
float)vpM[i][j];
413 Byte b = (Byte) *get_rfstack ();
417 memmove((
char *) m, (
char *) mat,
sizeof (Matrix));
418 View_to_Matrix (get_vwstack (), *(get_tmstack ()));
419 postmult_matrix (m, *(get_tmstack ()));
421 bend = bp + sc.bound.nbr;
422 for (; bp < bend; bp++)
424 if ((clip = clipping_Bound (bp, m)) != NULL)
426 Face *fp = clip->face.ptr;
427 Face *fend = fp + clip->face.nbr;
429 set_Bound_face_display (clip, b);
431 point_3D_2D (clip->point.ptr, clip->point.nbr,I.
getWidth(),I.
getHeight(),point2i);
432 for (; fp < fend; fp++)
436 wireframe_Face (fp, point2i);
437 Point2i *pt = listpoint2i;
438 for (
int i = 1; i < fp->vertex.nbr; i++)
443 if (fp->vertex.nbr > 2)
463 Byte b = (Byte) *get_rfstack ();
467 memmove((
char *) m, (
char *) mat,
sizeof (Matrix));
468 View_to_Matrix (get_vwstack (), *(get_tmstack ()));
469 postmult_matrix (m, *(get_tmstack ()));
471 bend = bp + sc.bound.nbr;
472 for (; bp < bend; bp++)
474 if ((clip = clipping_Bound (bp, m)) != NULL)
476 Face *fp = clip->face.ptr;
477 Face *fend = fp + clip->face.nbr;
479 set_Bound_face_display (clip, b);
481 point_3D_2D (clip->point.ptr, clip->point.nbr,I.
getWidth(),I.
getHeight(),point2i);
482 for (; fp < fend; fp++)
486 wireframe_Face (fp, point2i);
487 Point2i *pt = listpoint2i;
488 for (
int i = 1; i < fp->vertex.nbr; i++)
493 if (fp->vertex.nbr > 2)
514 : scene(), desiredScene(), camera(), objectImage(), fMo(), fMc(), camMf(),
515 refMo(), cMo(), cdMo(), object(PLATE), desiredObject(D_STANDARD),
517 desColor(
vpColor::red), sceneInitialized(false), displayCameraTrajectory(true),
518 cameraTrajectory(), poseList(), fMoList(), nbrPtLimit(1000), old_iPr(), old_iPz(),
519 old_iPt(), blockedr(false), blockedz(false), blockedt(false), blocked(false),
520 camMf2(), f2Mf(), px_int(1), py_int(1), px_ext(1), py_ext(1), displayObject(false),
521 displayDesiredObject(false), displayCamera(false), displayImageSimulator(false),
522 cameraFactor(1.), camTrajType(CT_LINE), extCamChanged(false), rotz(), thickness_(1), scene_dir()
526 scene_dir = VISP_SCENES_DIR;
530 std::cout <<
"The simulator uses data from VISP_SCENES_DIR=" << scene_dir << std::endl;
533 std::cout <<
"Cannot get VISP_SCENES_DIR environment variable" << std::endl;
547 scene.bound.ptr = NULL;
568 free_Bound_scene (&(this->
scene));
570 free_Bound_scene (&(this->
camera));
596 char name_cam[FILENAME_MAX];
597 char name[FILENAME_MAX];
602 const char *scene_dir_ = scene_dir.c_str();
603 if (strlen(scene_dir_) >= FILENAME_MAX) {
605 "Not enough memory to intialize the camera name"));
608 strcpy(name_cam, scene_dir_);
611 strcat(name_cam,
"/camera.bnd");
616 strcat(name_cam,
"/tool.bnd");
617 set_scene(name_cam,&(this->
camera),1.0);
620 strcpy(name, scene_dir_);
623 case THREE_PTS : {strcat(name,
"/3pts.bnd");
break; }
624 case CUBE : { strcat(name,
"/cube.bnd");
break; }
625 case PLATE : { strcat(name,
"/plate.bnd");
break; }
626 case SMALL_PLATE : { strcat(name,
"/plate_6cm.bnd");
break; }
627 case RECTANGLE : { strcat(name,
"/rectangle.bnd");
break; }
628 case SQUARE_10CM : { strcat(name,
"/square10cm.bnd");
break; }
629 case DIAMOND : { strcat(name,
"/diamond.bnd");
break; }
630 case TRAPEZOID : { strcat(name,
"/trapezoid.bnd");
break; }
631 case THREE_LINES : { strcat(name,
"/line.bnd");
break; }
632 case ROAD : { strcat(name,
"/road.bnd");
break; }
633 case TIRE : { strcat(name,
"/circles2.bnd");
break; }
634 case PIPE : { strcat(name,
"/pipe.bnd");
break; }
635 case CIRCLE : { strcat(name,
"/circle.bnd");
break; }
636 case SPHERE : { strcat(name,
"/sphere.bnd");
break; }
637 case CYLINDER : { strcat(name,
"/cylinder.bnd");
break; }
638 case PLAN: { strcat(name,
"/plan.bnd");
break; }
639 case POINT_CLOUD: { strcat(name,
"/point_cloud.bnd");
break; }
641 set_scene(name,&(this->
scene),1.0);
643 scene_dir_ = scene_dir.c_str();
644 if (strlen(scene_dir_) >= FILENAME_MAX) {
646 "Not enough memory to intialize the desired object name"));
653 strcpy(name, scene_dir_);
654 strcat(name,
"/circle_sq2.bnd");
657 strcpy(name, scene_dir_);
658 strcat(name,
"/tool.bnd");
663 if (obj ==
PIPE) load_rfstack(IS_INSIDE);
664 else add_rfstack(IS_BACK);
666 add_vwstack (
"start",
"depth", 0.0, 100.0);
667 add_vwstack (
"start",
"window", -0.1,0.1,-0.1,0.1);
668 add_vwstack (
"start",
"type", PERSPECTIVE);
677 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
739 char name_cam[FILENAME_MAX];
740 char name[FILENAME_MAX];
745 const char *scene_dir_ = scene_dir.c_str();
746 if (strlen(scene_dir_) >= FILENAME_MAX) {
748 "Not enough memory to intialize the camera name"));
751 strcpy(name_cam, scene_dir_);
752 strcat(name_cam,
"/camera.bnd");
755 if (strlen(obj) >= FILENAME_MAX) {
757 "Not enough memory to intialize the name"));
762 model = getExtension(obj);
763 if (model == BND_MODEL)
764 set_scene(name,&(this->
scene),1.0);
765 else if (model == WRL_MODEL)
766 set_scene_wrl(name,&(this->
scene),1.0);
767 else if (model == UNKNOWN_MODEL)
772 if (strlen(desired_object) >= FILENAME_MAX) {
774 "Not enough memory to intialize the camera name"));
777 strcpy(name,desired_object);
778 model = getExtension(desired_object);
779 if (model == BND_MODEL)
781 else if (model == WRL_MODEL)
783 else if (model == UNKNOWN_MODEL)
788 add_rfstack(IS_BACK);
790 add_vwstack (
"start",
"depth", 0.0, 100.0);
791 add_vwstack (
"start",
"window", -0.1,0.1,-0.1,0.1);
792 add_vwstack (
"start",
"type", PERSPECTIVE);
800 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
859 char name_cam[FILENAME_MAX];
860 char name[FILENAME_MAX];
864 const char *scene_dir_ = scene_dir.c_str();
865 if (strlen(scene_dir_) >= FILENAME_MAX) {
867 "Not enough memory to intialize the camera name"));
870 strcpy(name_cam, scene_dir_);
871 strcat(name_cam,
"/camera.bnd");
874 strcpy(name, scene_dir_);
877 case THREE_PTS : {strcat(name,
"/3pts.bnd");
break; }
878 case CUBE : { strcat(name,
"/cube.bnd");
break; }
879 case PLATE : { strcat(name,
"/plate.bnd");
break; }
880 case SMALL_PLATE : { strcat(name,
"/plate_6cm.bnd");
break; }
881 case RECTANGLE : { strcat(name,
"/rectangle.bnd");
break; }
882 case SQUARE_10CM : { strcat(name,
"/square10cm.bnd");
break; }
883 case DIAMOND : { strcat(name,
"/diamond.bnd");
break; }
884 case TRAPEZOID : { strcat(name,
"/trapezoid.bnd");
break; }
885 case THREE_LINES : { strcat(name,
"/line.bnd");
break; }
886 case ROAD : { strcat(name,
"/road.bnd");
break; }
887 case TIRE : { strcat(name,
"/circles2.bnd");
break; }
888 case PIPE : { strcat(name,
"/pipe.bnd");
break; }
889 case CIRCLE : { strcat(name,
"/circle.bnd");
break; }
890 case SPHERE : { strcat(name,
"/sphere.bnd");
break; }
891 case CYLINDER : { strcat(name,
"/cylinder.bnd");
break; }
892 case PLAN: { strcat(name,
"/plan.bnd");
break; }
893 case POINT_CLOUD: { strcat(name,
"/point_cloud.bnd");
break; }
895 set_scene(name,&(this->
scene),1.0);
897 if (obj ==
PIPE) load_rfstack(IS_INSIDE);
898 else add_rfstack(IS_BACK);
900 add_vwstack (
"start",
"depth", 0.0, 100.0);
901 add_vwstack (
"start",
"window", -0.1,0.1,-0.1,0.1);
902 add_vwstack (
"start",
"type", PERSPECTIVE);
912 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
969 char name_cam[FILENAME_MAX];
970 char name[FILENAME_MAX];
974 const char *scene_dir_ = scene_dir.c_str();
975 if (strlen(scene_dir_) >= FILENAME_MAX) {
977 "Not enough memory to intialize the camera name"));
980 strcpy(name_cam, scene_dir_);
981 strcat(name_cam,
"/camera.bnd");
984 if (strlen(obj) >= FILENAME_MAX) {
986 "Not enough memory to intialize the name"));
991 model = getExtension(obj);
992 if (model == BND_MODEL)
993 set_scene(name,&(this->
scene),1.0);
994 else if (model == WRL_MODEL)
995 set_scene_wrl(name,&(this->
scene),1.0);
996 else if (model == UNKNOWN_MODEL)
1001 add_rfstack(IS_BACK);
1003 add_vwstack (
"start",
"depth", 0.0, 100.0);
1004 add_vwstack (
"start",
"window", -0.1,0.1,-0.1,0.1);
1005 add_vwstack (
"start",
"type", PERSPECTIVE);
1012 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
1087 float o44c[4][4],o44cd[4][4],x,y,z;
1088 Matrix
id = IDENTITY_MATRIX;
1107 add_vwstack (
"start",
"cop", o44c[3][0],o44c[3][1],o44c[3][2]);
1108 x = o44c[2][0] + o44c[3][0];
1109 y = o44c[2][1] + o44c[3][1];
1110 z = o44c[2][2] + o44c[3][2];
1111 add_vwstack (
"start",
"vrp", x,y,z);
1112 add_vwstack (
"start",
"vpn", o44c[2][0],o44c[2][1],o44c[2][2]);
1113 add_vwstack (
"start",
"vup", o44c[1][0],o44c[1][1],o44c[1][2]);
1114 add_vwstack (
"start",
"window", -u, u, -v, v);
1119 add_vwstack (
"start",
"cop", o44cd[3][0],o44cd[3][1],o44cd[3][2]);
1120 x = o44cd[2][0] + o44cd[3][0];
1121 y = o44cd[2][1] + o44cd[3][1];
1122 z = o44cd[2][2] + o44cd[3][2];
1123 add_vwstack (
"start",
"vrp", x,y,z);
1124 add_vwstack (
"start",
"vpn", o44cd[2][0],o44cd[2][1],o44cd[2][2]);
1125 add_vwstack (
"start",
"vup", o44cd[1][0],o44cd[1][1],o44cd[1][2]);
1126 add_vwstack (
"start",
"window", -u, u, -v, v);
1146 bool changed =
false;
1150 if (std::fabs(displacement[2][3]) > std::numeric_limits<double>::epsilon() )
1173 float w44o[4][4],w44cext[4][4],w44c[4][4],x,y,z;
1176 vp2jlc_matrix(
fMc,w44c);
1177 vp2jlc_matrix(
fMo,w44o);
1180 add_vwstack (
"start",
"cop", w44cext[3][0],w44cext[3][1],w44cext[3][2]);
1181 x = w44cext[2][0] + w44cext[3][0];
1182 y = w44cext[2][1] + w44cext[3][1];
1183 z = w44cext[2][2] + w44cext[3][2];
1184 add_vwstack (
"start",
"vrp", x,y,z);
1185 add_vwstack (
"start",
"vpn", w44cext[2][0],w44cext[2][1],w44cext[2][2]);
1186 add_vwstack (
"start",
"vup", w44cext[1][0],w44cext[1][1],w44cext[1][2]);
1187 add_vwstack (
"start",
"window", -u, u, -v, v);
1190 add_vwstack (
"start",
"type", PERSPECTIVE);
1225 std::list<vpHomogeneousMatrix>::const_iterator iter_poseList =
poseList.begin();
1226 std::list<vpHomogeneousMatrix>::const_iterator iter_fMoList =
fMoList.begin();
1228 while ((iter_poseList !=
poseList.end()) && (iter_fMoList !=
fMoList.end()))
1289 float w44o[4][4],w44cext[4][4],w44c[4][4],x,y,z;
1309 vp2jlc_matrix(camMft.
inverse(),w44cext);
1311 vp2jlc_matrix(
fMo,w44o);
1313 add_vwstack (
"start",
"cop", w44cext[3][0],w44cext[3][1],w44cext[3][2]);
1314 x = w44cext[2][0] + w44cext[3][0];
1315 y = w44cext[2][1] + w44cext[3][1];
1316 z = w44cext[2][2] + w44cext[3][2];
1317 add_vwstack (
"start",
"vrp", x,y,z);
1318 add_vwstack (
"start",
"vpn", w44cext[2][0],w44cext[2][1],w44cext[2][2]);
1319 add_vwstack (
"start",
"vup", w44cext[1][0],w44cext[1][1],w44cext[1][2]);
1320 add_vwstack (
"start",
"window", -u, u, -v, v);
1372 float o44c[4][4],o44cd[4][4],x,y,z;
1373 Matrix
id = IDENTITY_MATRIX;
1392 add_vwstack (
"start",
"cop", o44c[3][0],o44c[3][1],o44c[3][2]);
1393 x = o44c[2][0] + o44c[3][0];
1394 y = o44c[2][1] + o44c[3][1];
1395 z = o44c[2][2] + o44c[3][2];
1396 add_vwstack (
"start",
"vrp", x,y,z);
1397 add_vwstack (
"start",
"vpn", o44c[2][0],o44c[2][1],o44c[2][2]);
1398 add_vwstack (
"start",
"vup", o44c[1][0],o44c[1][1],o44c[1][2]);
1399 add_vwstack (
"start",
"window", -u, u, -v, v);
1404 add_vwstack (
"start",
"cop", o44cd[3][0],o44cd[3][1],o44cd[3][2]);
1405 x = o44cd[2][0] + o44cd[3][0];
1406 y = o44cd[2][1] + o44cd[3][1];
1407 z = o44cd[2][2] + o44cd[3][2];
1408 add_vwstack (
"start",
"vrp", x,y,z);
1409 add_vwstack (
"start",
"vpn", o44cd[2][0],o44cd[2][1],o44cd[2][2]);
1410 add_vwstack (
"start",
"vup", o44cd[1][0],o44cd[1][1],o44cd[1][2]);
1411 add_vwstack (
"start",
"window", -u, u, -v, v);
1431 bool changed =
false;
1435 if (std::fabs(displacement[2][3]) > std::numeric_limits<double>::epsilon() )
1458 float w44o[4][4],w44cext[4][4],w44c[4][4],x,y,z;
1461 vp2jlc_matrix(
fMc,w44c);
1462 vp2jlc_matrix(
fMo,w44o);
1465 add_vwstack (
"start",
"cop", w44cext[3][0],w44cext[3][1],w44cext[3][2]);
1466 x = w44cext[2][0] + w44cext[3][0];
1467 y = w44cext[2][1] + w44cext[3][1];
1468 z = w44cext[2][2] + w44cext[3][2];
1469 add_vwstack (
"start",
"vrp", x,y,z);
1470 add_vwstack (
"start",
"vpn", w44cext[2][0],w44cext[2][1],w44cext[2][2]);
1471 add_vwstack (
"start",
"vup", w44cext[1][0],w44cext[1][1],w44cext[1][2]);
1472 add_vwstack (
"start",
"window", -u, u, -v, v);
1475 add_vwstack (
"start",
"type", PERSPECTIVE);
1508 std::list<vpHomogeneousMatrix>::const_iterator iter_poseList =
poseList.begin();
1509 std::list<vpHomogeneousMatrix>::const_iterator iter_fMoList =
fMoList.begin();
1511 while ((iter_poseList!=
poseList.end()) && (iter_fMoList!=
fMoList.end()) )
1572 float w44o[4][4],w44cext[4][4],w44c[4][4],x,y,z;
1592 vp2jlc_matrix(camMft.
inverse(),w44cext);
1594 vp2jlc_matrix(
fMo,w44o);
1596 add_vwstack (
"start",
"cop", w44cext[3][0],w44cext[3][1],w44cext[3][2]);
1597 x = w44cext[2][0] + w44cext[3][0];
1598 y = w44cext[2][1] + w44cext[3][1];
1599 z = w44cext[2][2] + w44cext[3][2];
1600 add_vwstack (
"start",
"vrp", x,y,z);
1601 add_vwstack (
"start",
"vpn", w44cext[2][0],w44cext[2][1],w44cext[2][2]);
1602 add_vwstack (
"start",
"vup", w44cext[1][0],w44cext[1][1],w44cext[1][2]);
1603 add_vwstack (
"start",
"window", -u, u, -v, v);
1623 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
1724 if (list_cMo.size() != list_fMo.size())
1731 std::list<vpHomogeneousMatrix>::const_iterator it_cMo = list_cMo.begin();
1732 std::list<vpHomogeneousMatrix>::const_iterator it_fMo = list_fMo.begin();
1734 while ((it_cMo != list_cMo.end()) && (it_fMo != list_fMo.end()))
1764 if (list_cMo.size() != list_fMo.size())
1771 std::list<vpHomogeneousMatrix>::const_iterator it_cMo = list_cMo.begin();
1772 std::list<vpHomogeneousMatrix>::const_iterator it_fMo = list_fMo.begin();
1774 while ((it_cMo != list_cMo.end()) && (it_fMo != list_fMo.end()))
1800 bool clicked =
false;
1801 bool clickedUp =
false;
1854 anglei = diffi*360/width;
1855 anglej = diffj*360/width;
1875 mov.
buildFrom(diffj*0.01,diffi*0.01,0,0,0,0);
1894 bool clicked =
false;
1895 bool clickedUp =
false;
1950 anglei = diffi*360/width;
1951 anglej = diffj*360/width;
1971 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.
unsigned int nbElements(void)
return the number of element in the list
A tire represented by 2 circles with radius 10cm and 15cm.
bool outside(void) const
Test if the current element is outside the list (on the virtual element)
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.
The class provides a data structure for the homogeneous matrices as well as a set of operations on th...
Provide simple list management.
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
void next(void)
position the current element on the next one
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.
void front(void)
Position the current element on the first element of the list.
static void display(const vpImage< unsigned char > &I)
type & value(void)
return the value of the current element
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)
Construction from translation vector and rotation matrix.
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.
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
void setWorldCoordinates(const double ox, const double oy, const double oz)
Set the point world coordinates. We mean here the coordinates of the point in the object frame...