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 std::vector<std::string> scene_dirs =
vpIoTools::splitChain(std::string(VISP_SCENES_DIR), std::string(
";"));
527 bool sceneDirExists =
false;
528 for(
size_t i=0; i < scene_dirs.size(); i++)
530 scene_dir = scene_dirs[i];
531 sceneDirExists =
true;
534 if (! sceneDirExists) {
537 std::cout <<
"The simulator uses data from VISP_SCENES_DIR=" << scene_dir << std::endl;
540 std::cout <<
"Cannot get VISP_SCENES_DIR environment variable" << std::endl;
554 scene.bound.ptr = NULL;
575 free_Bound_scene (&(this->
scene));
577 free_Bound_scene (&(this->
camera));
603 char name_cam[FILENAME_MAX];
604 char name[FILENAME_MAX];
609 const char *scene_dir_ = scene_dir.c_str();
610 if (strlen(scene_dir_) >= FILENAME_MAX) {
612 "Not enough memory to intialize the camera name"));
615 strcpy(name_cam, scene_dir_);
618 strcat(name_cam,
"/camera.bnd");
623 strcat(name_cam,
"/tool.bnd");
624 set_scene(name_cam,&(this->
camera),1.0);
627 strcpy(name, scene_dir_);
630 case THREE_PTS : {strcat(name,
"/3pts.bnd");
break; }
631 case CUBE : { strcat(name,
"/cube.bnd");
break; }
632 case PLATE : { strcat(name,
"/plate.bnd");
break; }
633 case SMALL_PLATE : { strcat(name,
"/plate_6cm.bnd");
break; }
634 case RECTANGLE : { strcat(name,
"/rectangle.bnd");
break; }
635 case SQUARE_10CM : { strcat(name,
"/square10cm.bnd");
break; }
636 case DIAMOND : { strcat(name,
"/diamond.bnd");
break; }
637 case TRAPEZOID : { strcat(name,
"/trapezoid.bnd");
break; }
638 case THREE_LINES : { strcat(name,
"/line.bnd");
break; }
639 case ROAD : { strcat(name,
"/road.bnd");
break; }
640 case TIRE : { strcat(name,
"/circles2.bnd");
break; }
641 case PIPE : { strcat(name,
"/pipe.bnd");
break; }
642 case CIRCLE : { strcat(name,
"/circle.bnd");
break; }
643 case SPHERE : { strcat(name,
"/sphere.bnd");
break; }
644 case CYLINDER : { strcat(name,
"/cylinder.bnd");
break; }
645 case PLAN: { strcat(name,
"/plan.bnd");
break; }
646 case POINT_CLOUD: { strcat(name,
"/point_cloud.bnd");
break; }
648 set_scene(name,&(this->
scene),1.0);
650 scene_dir_ = scene_dir.c_str();
651 if (strlen(scene_dir_) >= FILENAME_MAX) {
653 "Not enough memory to intialize the desired object name"));
660 strcpy(name, scene_dir_);
661 strcat(name,
"/circle_sq2.bnd");
664 strcpy(name, scene_dir_);
665 strcat(name,
"/tool.bnd");
670 if (obj ==
PIPE) load_rfstack(IS_INSIDE);
671 else add_rfstack(IS_BACK);
673 add_vwstack (
"start",
"depth", 0.0, 100.0);
674 add_vwstack (
"start",
"window", -0.1,0.1,-0.1,0.1);
675 add_vwstack (
"start",
"type", PERSPECTIVE);
684 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
746 char name_cam[FILENAME_MAX];
747 char name[FILENAME_MAX];
752 const char *scene_dir_ = scene_dir.c_str();
753 if (strlen(scene_dir_) >= FILENAME_MAX) {
755 "Not enough memory to intialize the camera name"));
758 strcpy(name_cam, scene_dir_);
759 strcat(name_cam,
"/camera.bnd");
762 if (strlen(obj) >= FILENAME_MAX) {
764 "Not enough memory to intialize the name"));
769 model = getExtension(obj);
770 if (model == BND_MODEL)
771 set_scene(name,&(this->
scene),1.0);
772 else if (model == WRL_MODEL)
773 set_scene_wrl(name,&(this->
scene),1.0);
774 else if (model == UNKNOWN_MODEL)
779 if (strlen(desired_object) >= FILENAME_MAX) {
781 "Not enough memory to intialize the camera name"));
784 strcpy(name,desired_object);
785 model = getExtension(desired_object);
786 if (model == BND_MODEL)
788 else if (model == WRL_MODEL)
790 else if (model == UNKNOWN_MODEL)
795 add_rfstack(IS_BACK);
797 add_vwstack (
"start",
"depth", 0.0, 100.0);
798 add_vwstack (
"start",
"window", -0.1,0.1,-0.1,0.1);
799 add_vwstack (
"start",
"type", PERSPECTIVE);
807 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
866 char name_cam[FILENAME_MAX];
867 char name[FILENAME_MAX];
871 const char *scene_dir_ = scene_dir.c_str();
872 if (strlen(scene_dir_) >= FILENAME_MAX) {
874 "Not enough memory to intialize the camera name"));
877 strcpy(name_cam, scene_dir_);
878 strcat(name_cam,
"/camera.bnd");
881 strcpy(name, scene_dir_);
884 case THREE_PTS : {strcat(name,
"/3pts.bnd");
break; }
885 case CUBE : { strcat(name,
"/cube.bnd");
break; }
886 case PLATE : { strcat(name,
"/plate.bnd");
break; }
887 case SMALL_PLATE : { strcat(name,
"/plate_6cm.bnd");
break; }
888 case RECTANGLE : { strcat(name,
"/rectangle.bnd");
break; }
889 case SQUARE_10CM : { strcat(name,
"/square10cm.bnd");
break; }
890 case DIAMOND : { strcat(name,
"/diamond.bnd");
break; }
891 case TRAPEZOID : { strcat(name,
"/trapezoid.bnd");
break; }
892 case THREE_LINES : { strcat(name,
"/line.bnd");
break; }
893 case ROAD : { strcat(name,
"/road.bnd");
break; }
894 case TIRE : { strcat(name,
"/circles2.bnd");
break; }
895 case PIPE : { strcat(name,
"/pipe.bnd");
break; }
896 case CIRCLE : { strcat(name,
"/circle.bnd");
break; }
897 case SPHERE : { strcat(name,
"/sphere.bnd");
break; }
898 case CYLINDER : { strcat(name,
"/cylinder.bnd");
break; }
899 case PLAN: { strcat(name,
"/plan.bnd");
break; }
900 case POINT_CLOUD: { strcat(name,
"/point_cloud.bnd");
break; }
902 set_scene(name,&(this->
scene),1.0);
904 if (obj ==
PIPE) load_rfstack(IS_INSIDE);
905 else add_rfstack(IS_BACK);
907 add_vwstack (
"start",
"depth", 0.0, 100.0);
908 add_vwstack (
"start",
"window", -0.1,0.1,-0.1,0.1);
909 add_vwstack (
"start",
"type", PERSPECTIVE);
919 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
976 char name_cam[FILENAME_MAX];
977 char name[FILENAME_MAX];
981 const char *scene_dir_ = scene_dir.c_str();
982 if (strlen(scene_dir_) >= FILENAME_MAX) {
984 "Not enough memory to intialize the camera name"));
987 strcpy(name_cam, scene_dir_);
988 strcat(name_cam,
"/camera.bnd");
991 if (strlen(obj) >= FILENAME_MAX) {
993 "Not enough memory to intialize the name"));
998 model = getExtension(obj);
999 if (model == BND_MODEL)
1000 set_scene(name,&(this->
scene),1.0);
1001 else if (model == WRL_MODEL)
1002 set_scene_wrl(name,&(this->
scene),1.0);
1003 else if (model == UNKNOWN_MODEL)
1008 add_rfstack(IS_BACK);
1010 add_vwstack (
"start",
"depth", 0.0, 100.0);
1011 add_vwstack (
"start",
"window", -0.1,0.1,-0.1,0.1);
1012 add_vwstack (
"start",
"type", PERSPECTIVE);
1019 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
1094 float o44c[4][4],o44cd[4][4],x,y,z;
1095 Matrix
id = IDENTITY_MATRIX;
1114 add_vwstack (
"start",
"cop", o44c[3][0],o44c[3][1],o44c[3][2]);
1115 x = o44c[2][0] + o44c[3][0];
1116 y = o44c[2][1] + o44c[3][1];
1117 z = o44c[2][2] + o44c[3][2];
1118 add_vwstack (
"start",
"vrp", x,y,z);
1119 add_vwstack (
"start",
"vpn", o44c[2][0],o44c[2][1],o44c[2][2]);
1120 add_vwstack (
"start",
"vup", o44c[1][0],o44c[1][1],o44c[1][2]);
1121 add_vwstack (
"start",
"window", -u, u, -v, v);
1126 add_vwstack (
"start",
"cop", o44cd[3][0],o44cd[3][1],o44cd[3][2]);
1127 x = o44cd[2][0] + o44cd[3][0];
1128 y = o44cd[2][1] + o44cd[3][1];
1129 z = o44cd[2][2] + o44cd[3][2];
1130 add_vwstack (
"start",
"vrp", x,y,z);
1131 add_vwstack (
"start",
"vpn", o44cd[2][0],o44cd[2][1],o44cd[2][2]);
1132 add_vwstack (
"start",
"vup", o44cd[1][0],o44cd[1][1],o44cd[1][2]);
1133 add_vwstack (
"start",
"window", -u, u, -v, v);
1153 bool changed =
false;
1157 if (std::fabs(displacement[2][3]) > std::numeric_limits<double>::epsilon() )
1180 float w44o[4][4],w44cext[4][4],w44c[4][4],x,y,z;
1183 vp2jlc_matrix(
fMc,w44c);
1184 vp2jlc_matrix(
fMo,w44o);
1187 add_vwstack (
"start",
"cop", w44cext[3][0],w44cext[3][1],w44cext[3][2]);
1188 x = w44cext[2][0] + w44cext[3][0];
1189 y = w44cext[2][1] + w44cext[3][1];
1190 z = w44cext[2][2] + w44cext[3][2];
1191 add_vwstack (
"start",
"vrp", x,y,z);
1192 add_vwstack (
"start",
"vpn", w44cext[2][0],w44cext[2][1],w44cext[2][2]);
1193 add_vwstack (
"start",
"vup", w44cext[1][0],w44cext[1][1],w44cext[1][2]);
1194 add_vwstack (
"start",
"window", -u, u, -v, v);
1197 add_vwstack (
"start",
"type", PERSPECTIVE);
1232 std::list<vpHomogeneousMatrix>::const_iterator iter_poseList =
poseList.begin();
1233 std::list<vpHomogeneousMatrix>::const_iterator iter_fMoList =
fMoList.begin();
1235 while ((iter_poseList !=
poseList.end()) && (iter_fMoList !=
fMoList.end()))
1296 float w44o[4][4],w44cext[4][4],w44c[4][4],x,y,z;
1316 vp2jlc_matrix(camMft.
inverse(),w44cext);
1318 vp2jlc_matrix(
fMo,w44o);
1320 add_vwstack (
"start",
"cop", w44cext[3][0],w44cext[3][1],w44cext[3][2]);
1321 x = w44cext[2][0] + w44cext[3][0];
1322 y = w44cext[2][1] + w44cext[3][1];
1323 z = w44cext[2][2] + w44cext[3][2];
1324 add_vwstack (
"start",
"vrp", x,y,z);
1325 add_vwstack (
"start",
"vpn", w44cext[2][0],w44cext[2][1],w44cext[2][2]);
1326 add_vwstack (
"start",
"vup", w44cext[1][0],w44cext[1][1],w44cext[1][2]);
1327 add_vwstack (
"start",
"window", -u, u, -v, v);
1379 float o44c[4][4],o44cd[4][4],x,y,z;
1380 Matrix
id = IDENTITY_MATRIX;
1399 add_vwstack (
"start",
"cop", o44c[3][0],o44c[3][1],o44c[3][2]);
1400 x = o44c[2][0] + o44c[3][0];
1401 y = o44c[2][1] + o44c[3][1];
1402 z = o44c[2][2] + o44c[3][2];
1403 add_vwstack (
"start",
"vrp", x,y,z);
1404 add_vwstack (
"start",
"vpn", o44c[2][0],o44c[2][1],o44c[2][2]);
1405 add_vwstack (
"start",
"vup", o44c[1][0],o44c[1][1],o44c[1][2]);
1406 add_vwstack (
"start",
"window", -u, u, -v, v);
1411 add_vwstack (
"start",
"cop", o44cd[3][0],o44cd[3][1],o44cd[3][2]);
1412 x = o44cd[2][0] + o44cd[3][0];
1413 y = o44cd[2][1] + o44cd[3][1];
1414 z = o44cd[2][2] + o44cd[3][2];
1415 add_vwstack (
"start",
"vrp", x,y,z);
1416 add_vwstack (
"start",
"vpn", o44cd[2][0],o44cd[2][1],o44cd[2][2]);
1417 add_vwstack (
"start",
"vup", o44cd[1][0],o44cd[1][1],o44cd[1][2]);
1418 add_vwstack (
"start",
"window", -u, u, -v, v);
1438 bool changed =
false;
1442 if (std::fabs(displacement[2][3]) > std::numeric_limits<double>::epsilon() )
1465 float w44o[4][4],w44cext[4][4],w44c[4][4],x,y,z;
1468 vp2jlc_matrix(
fMc,w44c);
1469 vp2jlc_matrix(
fMo,w44o);
1472 add_vwstack (
"start",
"cop", w44cext[3][0],w44cext[3][1],w44cext[3][2]);
1473 x = w44cext[2][0] + w44cext[3][0];
1474 y = w44cext[2][1] + w44cext[3][1];
1475 z = w44cext[2][2] + w44cext[3][2];
1476 add_vwstack (
"start",
"vrp", x,y,z);
1477 add_vwstack (
"start",
"vpn", w44cext[2][0],w44cext[2][1],w44cext[2][2]);
1478 add_vwstack (
"start",
"vup", w44cext[1][0],w44cext[1][1],w44cext[1][2]);
1479 add_vwstack (
"start",
"window", -u, u, -v, v);
1482 add_vwstack (
"start",
"type", PERSPECTIVE);
1515 std::list<vpHomogeneousMatrix>::const_iterator iter_poseList =
poseList.begin();
1516 std::list<vpHomogeneousMatrix>::const_iterator iter_fMoList =
fMoList.begin();
1518 while ((iter_poseList!=
poseList.end()) && (iter_fMoList!=
fMoList.end()) )
1579 float w44o[4][4],w44cext[4][4],w44c[4][4],x,y,z;
1599 vp2jlc_matrix(camMft.
inverse(),w44cext);
1601 vp2jlc_matrix(
fMo,w44o);
1603 add_vwstack (
"start",
"cop", w44cext[3][0],w44cext[3][1],w44cext[3][2]);
1604 x = w44cext[2][0] + w44cext[3][0];
1605 y = w44cext[2][1] + w44cext[3][1];
1606 z = w44cext[2][2] + w44cext[3][2];
1607 add_vwstack (
"start",
"vrp", x,y,z);
1608 add_vwstack (
"start",
"vpn", w44cext[2][0],w44cext[2][1],w44cext[2][2]);
1609 add_vwstack (
"start",
"vup", w44cext[1][0],w44cext[1][1],w44cext[1][2]);
1610 add_vwstack (
"start",
"window", -u, u, -v, v);
1630 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
1731 if (list_cMo.size() != list_fMo.size())
1738 std::list<vpHomogeneousMatrix>::const_iterator it_cMo = list_cMo.begin();
1739 std::list<vpHomogeneousMatrix>::const_iterator it_fMo = list_fMo.begin();
1741 while ((it_cMo != list_cMo.end()) && (it_fMo != list_fMo.end()))
1771 if (list_cMo.size() != list_fMo.size())
1778 std::list<vpHomogeneousMatrix>::const_iterator it_cMo = list_cMo.begin();
1779 std::list<vpHomogeneousMatrix>::const_iterator it_fMo = list_fMo.begin();
1781 while ((it_cMo != list_cMo.end()) && (it_fMo != list_fMo.end()))
1807 bool clicked =
false;
1808 bool clickedUp =
false;
1861 anglei = diffi*360/width;
1862 anglej = diffj*360/width;
1882 mov.
buildFrom(diffj*0.01,diffi*0.01,0,0,0,0);
1901 bool clicked =
false;
1902 bool clickedUp =
false;
1957 anglei = diffi*360/width;
1958 anglej = diffj*360/width;
1978 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...