41 #include <visp3/core/vpConfig.h>
47 #include <visp3/gui/vpDisplayD3D.h>
48 #include <visp3/gui/vpDisplayGDI.h>
49 #include <visp3/gui/vpDisplayGTK.h>
50 #include <visp3/gui/vpDisplayOpenCV.h>
51 #include <visp3/gui/vpDisplayX.h>
53 #include <visp3/io/vpParseArgv.h>
55 #include <visp3/core/vpHomogeneousMatrix.h>
56 #include <visp3/core/vpImage.h>
57 #include <visp3/core/vpPoseVector.h>
59 #include <visp3/ustk_needle_modeling/usNeedleInsertionModelRayleighRitzSpline.h>
60 #include <visp3/ustk_needle_modeling/usNeedleModelingDisplayTools.h>
63 #define GETOPTARGS "hlt:cd"
65 typedef enum { vpX11, vpGTK, vpGDI, vpD3D, vpCV } vpDisplayType;
67 void usage(
const char *name,
const char *badparam, vpDisplayType &dtype);
68 bool getOptions(
int argc,
const char **argv, vpDisplayType &dtype,
bool &list,
bool &display);
80 void usage(
const char *name,
const char *badparam, vpDisplayType &dtype)
83 Test the class usNeedleInsertionModelRayleighRitzSpline.\n\
86 %s [-t <type of video device>] [-l] [-d] [-h]\n\
111 -t <type of video device> \"%s\"\n\
112 String specifying the video device to use.\n\
114 \"X11\": only on UNIX platforms,\n\
115 \"GTK\": on all plaforms,\n\
116 \"GDI\": only on Windows platform (Graphics Device Interface),\n\
117 \"D3D\": only on Windows platform (Direct3D).\n\
118 \"CV\" : (OpenCV).\n\
121 Print the list of video-devices available and exit.\n\
124 Turn off the display.\n\
127 Print the help.\n\n",
display.c_str());
130 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
149 bool getOptions(
int argc,
const char **argv, vpDisplayType &dtype,
bool &list,
bool &display)
153 std::string sDisplayType;
154 while((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1)
164 sDisplayType = optarg_;
166 if(sDisplayType.compare(
"X11") == 0) dtype = vpX11;
167 else if (sDisplayType.compare(
"GTK") == 0) dtype = vpGTK;
168 else if (sDisplayType.compare(
"GDI") == 0) dtype = vpGDI;
169 else if (sDisplayType.compare(
"D3D") == 0) dtype = vpD3D;
170 else if (sDisplayType.compare(
"CV") == 0) dtype = vpCV;
174 usage(argv[0], NULL, dtype);
186 usage(argv[0], optarg_, dtype);
192 if((c == 1) || (c == -1))
195 usage(argv[0], NULL, dtype);
196 std::cerr <<
"ERROR: " << std::endl;
197 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
206 int main(
int argc,
const char **argv)
208 bool opt_list =
false;
209 vpDisplayType opt_dtype;
210 bool opt_display =
true;
213 #if defined VISP_HAVE_GTK
215 #elif defined VISP_HAVE_X11
217 #elif defined VISP_HAVE_GDI
219 #elif defined VISP_HAVE_D3D9
221 #elif defined VISP_HAVE_OPENCV
226 if(!getOptions(argc, argv, opt_dtype, opt_list, opt_display)) exit(-1);
230 unsigned nbDevices = 0;
231 std::cout <<
"List of video-devices available: \n";
232 #if defined VISP_HAVE_GTK
233 std::cout <<
" GTK (use \"-t GTK\" option to use it)\n";
236 #if defined VISP_HAVE_X11
237 std::cout <<
" X11 (use \"-t X11\" option to use it)\n";
240 #if defined VISP_HAVE_GDI
241 std::cout <<
" GDI (use \"-t GDI\" option to use it)\n";
244 #if defined VISP_HAVE_D3D9
245 std::cout <<
" D3D (use \"-t D3D\" option to use it)\n";
248 #if defined VISP_HAVE_OPENCV
249 std::cout <<
" CV (use \"-t CV\" option to use it)\n";
253 std::cout <<
" No display is available\n";
258 vpImage<unsigned char> I(700, 500, 255);
267 std::cout <<
"Requested X11 display functionnalities..." << std::endl;
268 #if defined VISP_HAVE_X11
271 std::cout <<
" Sorry, X11 video device is not available.\n";
272 std::cout <<
"Use \"" << argv[0] <<
" -l\" to print the list of available devices.\n";
277 std::cout <<
"Requested GTK display functionnalities..." << std::endl;
278 #if defined VISP_HAVE_GTK
281 std::cout <<
" Sorry, GTK video device is not available.\n";
282 std::cout <<
"Use \"" << argv[0] <<
" -l\" to print the list of available devices.\n";
287 std::cout <<
"Requested GDI display functionnalities..." << std::endl;
288 #if defined VISP_HAVE_GDI
291 std::cout <<
" Sorry, GDI video device is not available.\n";
292 std::cout <<
"Use \"" << argv[0] <<
" -l\" to print the list of available devices.\n";
297 std::cout <<
"Requested D3D display functionnalities..." << std::endl;
298 #if defined VISP_HAVE_D3D9
301 std::cout <<
" Sorry, D3D video device is not available.\n";
302 std::cout <<
"Use \"" << argv[0] <<
" -l\" to print the list of available devices.\n";
307 std::cout <<
"Requested OpenCV display functionnalities..." << std::endl;
308 #if defined(VISP_HAVE_OPENCV)
311 std::cout <<
" Sorry, OpenCV video device is not available.\n";
312 std::cout <<
"Use \"" << argv[0] <<
" -l\" to print the list of available devices.\n";
319 if(opt_display)
display->init(I);
351 n1.moveBaseWorldFrame(0.01,0,0,0,0,0);
353 for(
int i=0 ; i<300 ; i++)
355 if(i > 50 && i < 100)
357 n1.accessNeedle().setFullLength(n1.accessNeedle().getFullLength()+0.0002);
369 n1.moveBase(0,0,0.001,0,0,0.1);
373 vpDisplay::display(I);
const usPolynomialCurve3D & accessSegment(int i) const
bool moveBase(const vpColVector &v, double time)
void loadPreset(const ModelPreset preset)
Parameters saving and loading.
bool setStiffnessPerUnitLength(int i, double K)
usNeedleTip const & accessNeedleTip() const
bool setBasePose(const vpPoseVector &p)
The following methods should be redefined in the derived classes.
const usTissueModelSpline & accessTissue() const
Tissue parameters.
const usNeedleModelSpline & accessNeedle() const
Parameters setters and getters.
void setNeedleTipType(NeedleTipType type)
void setSolvingMethod(SolvingMethod method)
void setPathUpdateLengthThreshold(double length)
void setPathUpdateType(PathUpdateType type)
Model behavior.
virtual bool updateState()
vpColVector getTipDirection() const
vpColVector getTipPosition() const
void setFullLength(double length)
Parameters setters and getters.
void setNeedleYoungModulus(double E)
double getOuterDiameter() const
void setInsideDiameter(double diameter)
void setOuterDiameter(double diameter)
void setDirection(const vpColVector &D)
void setPosition(const vpColVector &P)
void setOrder(unsigned int order)
const usOrientedPlane3D & accessSurface() const
Parameters setters and getters.