26 # pragma warning (disable: 4251) // STL MAP DLL warning noise (JW)
30 #include "ThreeDOut.hh"
31 #include <Base/Debug/TimeMeasure.hh>
32 #include <Base/Image/ImageIO.hh>
33 #include <Geometry/RMatrix.hh>
35 #if defined(BIAS_HAVE_OPENGL) && defined(BIAS_HAVE_FONTGL)
36 #include <Utils/DrawTextGL.hh>
39 #ifdef BIAS_HAVE_OPENGL
40 # include <Utils/StatekeeperGL.hh>
43 #define ASSERT_MAP_ELEMENT(themap, key) if (themap.find(key)==themap.end()) { \
44 BIASERR("Tried to access map with key " \
45 <<key<<". Undefined Element." \
46 <<" Aborting."); BIASABORT; }
48 #define DEGREE_PER_RAD (180.0/M_PI)
56 writeOutTexture(false), bbmin(0,0,0), bbmax(0,0,0)
63 #ifdef BIAS_HAVE_OPENGL
83 #ifdef BIAS_HAVE_OPENGL
125 for(GLsizei j=0; j<facetIndicesCountArray[i]; j++)
153 #ifdef BIAS_HAVE_OPENGL
183 #ifdef BIAS_HAVE_OPENGL
274 if(defstring.size()==0)
276 string result = defstring;
277 string::size_type posofinvalidchar = 0;
278 if( isdigit(result[0]) !=0) {
282 if (result.size()>0)
do {
284 posofinvalidchar = result.find(
'.', posofinvalidchar);
285 if (posofinvalidchar != string::npos) {
287 result.at(posofinvalidchar) =
'_';
289 }
while (posofinvalidchar != string::npos);
290 posofinvalidchar = 0;
291 if (result.size()>0)
do {
293 posofinvalidchar = result.find(
' ', posofinvalidchar);
294 if (posofinvalidchar != string::npos) {
296 result.at(posofinvalidchar) =
'_';
298 }
while (posofinvalidchar != string::npos);
307 double selectionRadius,
308 double r,
double g,
double b,
double transparency,
312 const std::string& name,
315 double PI_1 = 3.1415926;
316 double PI_2 = 6.2831852;
318 bool angle_too_big =
false;
319 if(angle > PI_1 && angle < PI_2){
320 angle_too_big =
true;
323 else if(angle > PI_2){
327 if (name.length()>0){
329 VRMLFile<<
"DEF "<<mod_name <<
" ";
332 double dist_x = sin(angle/2.0);
333 double dist_y = dist_x/(double)ratio;
335 double dist = sqrt(dist_y*dist_y + 1.0);
336 double k = (double)selectionRadius/dist;
338 double dist_z = cos(angle/2.0)*k;
343 VRMLFile<<
"Transform { "<<std::endl;
344 VRMLFile<<
" translation 0 0 0"<<std::endl;
346 VRMLFile<<
" scale "<<scale<<
" "<<scale
347 <<
" "<<scale<<
" "<<endl;
348 VRMLFile<<
" children ["<<std::endl;
350 VRMLFile<<
" DEF ViewPort Transform { "<<std::endl;
352 VRMLFile<<
" rotation 1 0 0 -1.57"<<std::endl;
353 VRMLFile<<
" translation 0 0 0"<<std::endl;
356 VRMLFile<<
" rotation 1 0 0 1.57"<<std::endl;
357 VRMLFile<<
" translation 0 0 0"<<std::endl;
359 VRMLFile<<
" children ["<<std::endl;
363 VRMLFile<<
" Shape { "<<std::endl;
364 VRMLFile<<
" geometry IndexedFaceSet {"<<std::endl;
366 VRMLFile<<
" "<<std::endl;
368 VRMLFile<<
" coord Coordinate {"<<std::endl;
369 VRMLFile<<
" point ["<<std::endl;
371 VRMLFile<<
" 0 0 0,"<<std::endl;
374 <<-dist_x<<
" "<< dist_z<<
" "<< dist_y<<
","<<std::endl;
376 << dist_x<<
" "<< dist_z<<
" "<< dist_y<<
","<<std::endl;
378 << dist_x<<
" "<< dist_z<<
" "<<-dist_y<<
","<<std::endl;
380 <<-dist_x<<
" "<< dist_z<<
" "<<-dist_y<<
","<<std::endl;
381 VRMLFile<<
" ]"<<std::endl;
382 VRMLFile<<
" }"<<std::endl;
384 VRMLFile<<
" coordIndex ["<<std::endl;
386 VRMLFile<<
" 1, 2, 3, 4, -1,"<<std::endl;
387 VRMLFile<<
" 0, 1, 2, -1,"<<std::endl;
388 VRMLFile<<
" 0, 2, 3, -1,"<<std::endl;
389 VRMLFile<<
" 0, 3, 4, -1,"<<std::endl;
390 VRMLFile<<
" 0, 4, 1, -1,"<<std::endl;
392 VRMLFile<<
" ]"<<std::endl;
394 VRMLFile<<
" }"<<std::endl;
395 VRMLFile<<
" appearance Appearance {"<<std::endl;
396 VRMLFile<<
" material Material {"<<std::endl;
397 VRMLFile<<
" emissiveColor "<<1.0<<
" "<<1.0<<
" "<<1.0<<std::endl;
398 VRMLFile<<
" transparency "<<transparency<<std::endl;
399 VRMLFile<<
" }"<<std::endl;
400 VRMLFile<<
" }"<<std::endl;
401 VRMLFile<<
" }"<<std::endl;
406 VRMLFile<<
" Shape { "<<std::endl;
407 VRMLFile<<
" geometry IndexedLineSet {"<<std::endl;
409 VRMLFile<<
" "<<std::endl;
411 VRMLFile<<
" coord Coordinate {"<<std::endl;
412 VRMLFile<<
" point ["<<std::endl;
414 VRMLFile<<
" 0 0 0,"<<std::endl;
417 <<-dist_x<<
" "<< dist_z<<
" "<< dist_y<<
","<<std::endl;
419 << dist_x<<
" "<< dist_z<<
" "<< dist_y<<
","<<std::endl;
421 << dist_x<<
" "<< dist_z<<
" "<<-dist_y<<
","<<std::endl;
423 <<-dist_x<<
" "<< dist_z<<
" "<<-dist_y<<
","<<std::endl;
424 VRMLFile<<
" ]"<<std::endl;
425 VRMLFile<<
" }"<<std::endl;
427 VRMLFile<<
" color Color {"<<std::endl;
428 VRMLFile<<
" color ["<<std::endl;
429 VRMLFile<<
" 255 255 255"<<std::endl;
431 VRMLFile<<
" ]"<<std::endl;
432 VRMLFile<<
" }"<<std::endl;
434 VRMLFile<<
" coordIndex ["<<std::endl;
435 VRMLFile<<
" 0, 1, -1,"<<std::endl;
436 VRMLFile<<
" 0, 2, -1,"<<std::endl;
437 VRMLFile<<
" 0, 3, -1,"<<std::endl;
438 VRMLFile<<
" 0, 4, -1,"<<std::endl;
439 VRMLFile<<
" ]"<<std::endl;
441 VRMLFile<<
" colorIndex ["<<std::endl;
442 VRMLFile<<
" 0, 0, 0, 0"<<std::endl;
443 VRMLFile<<
" ]"<<std::endl;
445 VRMLFile<<
" }"<<std::endl;
446 VRMLFile<<
" }"<<std::endl;
451 VRMLFile<<
" ]"<<std::endl;
452 VRMLFile<<
" }"<<std::endl;
453 VRMLFile<<
" ]"<<std::endl;
454 VRMLFile<<
"}"<<std::endl;
462 double selectionRadius,
463 double r,
double g,
double b,
double transparency,
466 const std::string& name)
468 double PI_1 = 3.1415926;
469 double PI_2 = 6.2831852;
471 bool angle_too_big =
false;
472 if(angle > PI_1 && angle < PI_2){
473 angle_too_big =
true;
476 else if(angle > PI_2){
477 BIASERR(
"angle too big");
481 if (name.length()>0){
483 VRMLFile<<
"DEF "<<mod_name <<
" ";
486 VRMLFile<<
"Transform { "<<std::endl;
487 VRMLFile<<
" translation 0 0 0"<<std::endl;
488 VRMLFile<<
" scale "<<scale<<
" "<<scale
489 <<
" "<<scale<<
" "<<endl;
490 VRMLFile<<
" children ["<<std::endl;
492 double radius = selectionRadius*sin(angle/2.0);
494 if(angle != 1.0 && angle != 0.0)
495 height = selectionRadius*cos(angle/2.0);
497 VRMLFile<<
" DEF ViewPort Transform { "<<std::endl;
499 VRMLFile<<
" rotation 1 0 0 1.57"<<std::endl;
500 VRMLFile<<
" translation 0 0 "<<-height/2.0<<std::endl;
503 VRMLFile<<
" rotation 1 0 0 -1.57"<<std::endl;
504 VRMLFile<<
" translation 0 0 "<<height/2.0<<std::endl;
506 VRMLFile<<
" children ["<<std::endl;
507 VRMLFile<<
" Shape { "<<std::endl;
508 VRMLFile<<
" geometry Cone{ bottomRadius "<<radius
509 <<
" height "<<height<<std::endl
510 <<
" side TRUE"<<std::endl
511 <<
" bottom FALSE"<<std::endl
513 VRMLFile<<
" appearance Appearance {"<<std::endl;
514 VRMLFile<<
" material Material {"<<std::endl;
515 VRMLFile<<
" emissiveColor "<<1.0<<
" "<<1.0<<
" "<<1.0<<std::endl;
516 VRMLFile<<
" transparency "<<transparency<<std::endl;
517 VRMLFile<<
" }"<<std::endl;
518 VRMLFile<<
" }"<<std::endl;
519 VRMLFile<<
" }"<<std::endl;
520 VRMLFile<<
" ]"<<std::endl;
521 VRMLFile<<
" }"<<std::endl;
524 VRMLFile<<
" ]"<<std::endl;
525 VRMLFile<<
"}"<<std::endl;
531 double selectionRadius,
532 double r,
double g,
double b,
536 const std::string& name,
540 PaintPyramid(VRMLFile, selectionRadius, r, g, b, 0.0, angle,
541 ratio, scale, name,
true);
544 PaintPyramid(VRMLFile, selectionRadius, r, g, b, 0.6, angle,
545 ratio, scale, name,
true);
549 int iterations = (int)(angle/(3.1415926/4.0));
551 for (
int j = 0; j < iterations; j++){
555 (3.1415926/4.0)*(
double)(j+1),
565 double selectionRadius,
566 double r,
double g,
double b,
569 const std::string& name,
571 cout<<
" trying to build conical camera rep:\n! ";
574 PaintCone(VRMLFile, selectionRadius, r, g, b, 0.0, angle,
578 PaintCone(VRMLFile, selectionRadius, r, g, b, 0.6, angle,
583 cout<<
"angle "<<angle<<endl;
584 int iterations = (int)(angle/(3.1415926/4.0));
585 cout<<
"iterations = "<<iterations<<endl;
587 for (
int j = 0; j < iterations; j++){
591 (3.1415926/4.0)*(
double)(j+1),
600 double selectionRadius,
601 double r,
double g,
double b,
double axeslength,
603 const std::string& name)
608 if (name.length()>0){
610 VRMLFile<<
"DEF "<<mod_name <<
" ";
613 VRMLFile<<
"Transform { "<<std::endl;
614 if (axeslength<=0.0) axeslength = 1.0;
615 VRMLFile<<
" scale "<<scale<<
" "<<scale
616 <<
" "<<scale<<
" "<<endl;
617 VRMLFile<<
" children [ "<<std::endl;
619 VRMLFile<<
" Shape { "<<std::endl;
624 VRMLFile<<
" geometry Box{ size 0.1 0.1 0.1 } "<<std::endl;
625 VRMLFile<<
" appearance Appearance {"<<std::endl;
626 VRMLFile<<
" material Material {"<<std::endl;
627 VRMLFile<<
" emissiveColor "<<r<<
" "<<g<<
" "<<b<<std::endl;
628 VRMLFile<<
" }"<<std::endl;
629 VRMLFile<<
" }"<<std::endl;
630 VRMLFile<<
" }"<<std::endl;
632 VRMLFile<<
" DEF ArrowBody Transform { "<<std::endl;
633 VRMLFile<<
" translation 0.5 0 0"<<std::endl;
634 VRMLFile<<
" children ["<<std::endl;
635 VRMLFile<<
" Shape { "<<std::endl;
636 VRMLFile<<
" geometry Box{ size "<<1.0<<
" "<<0.05<<
" "<<0.05<<
638 VRMLFile<<
" appearance Appearance {"<<std::endl;
639 VRMLFile<<
" material Material {"<<std::endl;
640 VRMLFile<<
" emissiveColor "<<r<<
" "<<g<<
" "<<b<<std::endl;
641 VRMLFile<<
" }"<<std::endl;
642 VRMLFile<<
" }"<<std::endl;
643 VRMLFile<<
" }"<<std::endl;
644 VRMLFile<<
" ]"<<std::endl;
645 VRMLFile<<
" }"<<std::endl;
647 VRMLFile<<
" Transform {"<<std::endl;
648 VRMLFile<<
" rotation 0 1 0 -1.57"<<std::endl;
649 VRMLFile<<
" children USE ArrowBody"<<std::endl;
650 VRMLFile<<
" }"<<std::endl;
652 VRMLFile<<
" Transform {"<<std::endl;
653 VRMLFile<<
" rotation 0 0 1 1.57"<<std::endl;
654 VRMLFile<<
" children USE ArrowBody"<<std::endl;
655 VRMLFile<<
" }"<<std::endl;
660 VRMLFile<<
" Transform {"<<std::endl;
661 VRMLFile<<
" translation 1 0 0"<<std::endl;
662 VRMLFile<<
" rotation 0 0 1 -1.57"<<std::endl;
663 VRMLFile<<
" children ["<<std::endl;
664 VRMLFile<<
" Shape {"<<std::endl;
665 VRMLFile<<
" geometry Cone{ "<<std::endl;
666 VRMLFile<<
" bottomRadius "<<bRad<<
" "<<std::endl;
667 VRMLFile<<
" height "<<hght<<std::endl;
668 VRMLFile<<
" }"<<std::endl;
669 VRMLFile<<
" appearance Appearance {"<<std::endl;
670 VRMLFile<<
" material Material {"<<std::endl;
671 VRMLFile<<
" emissiveColor 1.0 0.0 0.0"<<std::endl;
672 VRMLFile<<
" }"<<std::endl;
673 VRMLFile<<
" }"<<std::endl;
674 VRMLFile<<
" }"<<std::endl;
675 VRMLFile<<
" ]"<<std::endl;
676 VRMLFile<<
" }"<<std::endl;
678 VRMLFile<<
" Transform {"<<std::endl;
679 VRMLFile<<
" translation 0 1 0"<<std::endl;
680 VRMLFile<<
" children ["<<std::endl;
681 VRMLFile<<
" Shape {"<<std::endl;
682 VRMLFile<<
" geometry Cone{ "<<std::endl;
683 VRMLFile<<
" bottomRadius "<<bRad<<
" "<<std::endl;
684 VRMLFile<<
" height "<<hght<<std::endl;
685 VRMLFile<<
" }"<<std::endl;
686 VRMLFile<<
" appearance Appearance {"<<std::endl;
687 VRMLFile<<
" material Material {"<<std::endl;
688 VRMLFile<<
" emissiveColor 0.0 1.0 0.0"<<std::endl;
689 VRMLFile<<
" }"<<std::endl;
690 VRMLFile<<
" }"<<std::endl;
691 VRMLFile<<
" }"<<std::endl;
692 VRMLFile<<
" ]"<<std::endl;
693 VRMLFile<<
" }"<<std::endl;
695 VRMLFile<<
" Transform {"<<std::endl;
696 VRMLFile<<
" translation 0 0 1"<<std::endl;
697 VRMLFile<<
" rotation 1 0 0 1.57"<<std::endl;
698 VRMLFile<<
" children ["<<std::endl;
699 VRMLFile<<
" Shape {"<<std::endl;
700 VRMLFile<<
" geometry Cone{ "<<std::endl;
701 VRMLFile<<
" bottomRadius "<<bRad<<
" "<<std::endl;
702 VRMLFile<<
" height "<<hght<<std::endl;
703 VRMLFile<<
" }"<<std::endl;
704 VRMLFile<<
" appearance Appearance {"<<std::endl;
705 VRMLFile<<
" material Material {"<<std::endl;
706 VRMLFile<<
" emissiveColor 0.0 0.0 1.0"<<std::endl;
707 VRMLFile<<
" }"<<std::endl;
708 VRMLFile<<
" }"<<std::endl;
709 VRMLFile<<
" }"<<std::endl;
710 VRMLFile<<
" ]"<<std::endl;
711 VRMLFile<<
" }"<<std::endl;
713 VRMLFile<<
" ]"<<std::endl;
714 VRMLFile<<
"}"<<std::endl;
733 if (!v.
IsHomogenized()) BIASERR(
"Supplied unhomogenized point !");
742 const double& thesize,
774 if (!Start.
IsHomogenized()) BIASERR(
"Supplied unhomogenized start point !");
775 if (!End.
IsHomogenized()) BIASERR(
"Supplied unhomogenized end point !");
785 const double& dConfidenceRegionScale,
786 const bool CamEllipsoid)
792 int resPCA = cov.
GetPCA(S, VT);
798 }
else if (!VT.
IsZero(1e-8)) {
800 BIASWARN(
"Degenerated rotation matrix VT computed from covariance matrix "
801 "via PCA! Using default covariance ellipsoid alignment!" << endl
802 <<
"- degenerated matrix VT = " << VT);
805 Data.
s0 = sqrt(S[0]) * dConfidenceRegionScale;
806 Data.
s1 = sqrt(S[1]) * dConfidenceRegionScale;
807 Data.
s2 = sqrt(S[2]) * dConfidenceRegionScale;
826 const double &dConfidenceRegionScale,
827 const bool CamEllipsoid)
831 BIASERR(
"Supplied unhomogenized point!");
834 return AddEllipsoid(cov, Center, Color, dConfidenceRegionScale, CamEllipsoid);
841 const bool wireframe)
844 std::vector< Vector3<double> > corners;
848 for (
int i = 0; i < 4; i++)
849 corners[i] += translation;
854 for (
int i = 0; i < 3; i++)
855 for (
int j = i + 1; j < 4; j++)
856 AddLine(corners[i], corners[j], colour);
861 std::vector< Vector3<double> > vertexNormals(4);
862 std::vector< Vector4<unsigned char> > vertexColors(4);
863 for (
int i = 0; i < 4; i++) {
864 vertexNormals[i] = normal;
865 vertexColors[i] = colour;
867 std::vector< Vector<int> > triangleIndices(2);
869 triangleIndices[1] =
Vector<int>(Vector3<int>(2, 1, 3));
871 quad.
SetMesh(corners, vertexNormals, vertexColors, triangleIndices);
882 const double halfSize = size / 2.0;
887 const double optimalAngle = M_PI / 2.0;
897 const double diffAngleX = fabs(optimalAngle - angleX);
898 const double diffAngleY = fabs(optimalAngle - angleY);
899 const double diffAngleZ = fabs(optimalAngle - angleZ);
908 if (diffAngleX <= diffAngleY && diffAngleX <= diffAngleZ) {
911 p1[0] = 0.0; p1[1] = -halfSize; p1[2] = halfSize;
912 p2[0] = 0.0; p2[1] = halfSize; p2[2] = halfSize;
913 p3[0] = 0.0; p3[1] = -halfSize; p3[2] = -halfSize;
914 p4[0] = 0.0; p4[1] = halfSize; p4[2] = -halfSize;
916 else if (diffAngleY <= diffAngleZ) {
919 p1[0] = -halfSize; p1[1] = 0.0; p1[2] = halfSize;
920 p2[0] = halfSize; p2[1] = 0.0; p2[2] = halfSize;
921 p3[0] = -halfSize; p3[1] = 0.0; p3[2] = -halfSize;
922 p4[0] = halfSize; p4[1] = 0.0; p4[2] = -halfSize;
927 p1[0] = -halfSize; p1[1] = halfSize; p1[2] = 0.0;
928 p2[0] = halfSize; p2[1] = halfSize; p2[2] = 0.0;
929 p3[0] = -halfSize; p3[1] = -halfSize; p3[2] = 0.0;
930 p4[0] = halfSize; p4[1] = -halfSize; p4[2] = 0.0;
937 const RMatrix rotation(rotationAxis, -angle);
941 p1 = invRotation * p1;
942 p2 = invRotation * p2;
943 p3 = invRotation * p3;
944 p4 = invRotation * p4;
947 const double distance = -plane[3];
967 unsigned int Width,
unsigned int Height,
968 unsigned char* pData,
unsigned int channels,
969 const std::string& name,
973 if (Width>UINT_MAX/2) {
974 BIASERR(
"Width "<<Width<<
" is out of bounds !");
977 if (Height>UINT_MAX/2) {
978 BIASERR(
"Height "<<Height<<
" is out of bounds !");
981 if ((channels!=1)&&(channels!=3)) {
982 BIASERR(
"Unknown channel count:"<<channels);
987 unsigned int w(1), h(1);
988 while (w<Width) w<<=1;
989 while (h<Height) h<<=1;
996 unsigned char* pOrig = pData;
997 for (
unsigned int i=0; i<Height; i++) {
998 memcpy(pColRow[i], pOrig, channels*Width*
sizeof(
unsigned char));
999 pOrig += channels*Width;
1013 const unsigned int& width,
1014 const unsigned int& height,
1016 const double &dScale,
1030 const unsigned int& width,
1031 const unsigned int& height,
1033 const double &dScale,
1047 int ires = (K * R.
Transpose()).GetInverse(iKRt);
1048 if (ires!=0) BIASERR(
"error computing iKRt.");
1049 BIASDOUT(D_3DOUT_PDECOMP,
"Decomposing P="<<P<<
" into K="<<K<<
" R="
1050 <<R<<
" C="<<pd.
C<<
" A="<<A);
1051 for (
unsigned int i=0; i<5; i++){
1054 ThisCorner[0] = 0.0;
1055 ThisCorner[1] = 0.0;
1058 ThisCorner[0] = width-1;
1059 ThisCorner[1] = 0.0;
1062 ThisCorner[0] = width-1;
1063 ThisCorner[1] = height-1;
1066 ThisCorner[0] = 0.0;
1067 ThisCorner[1] = height-1;
1070 ThisCorner[0] = K[0][2];
1071 ThisCorner[1] = K[1][2];
1074 ThisCorner[2] = 1.0;
1076 iKRt.
Mult(ThisCorner,d);
1084 case 0: pd.
UL=d;
break;
1085 case 1: pd.
UR=d;
break;
1086 case 2: pd.
LR=d;
break;
1087 case 3: pd.
LL=d;
break;
1088 case 4: pd.
PP=d;
break;
1091 BIASDOUT(D_3DOUT_PDECOMP,
"Created points ul="<<pd.
UL<<
" ur="<<pd.
UR<<
" lr="
1092 <<pd.
LR<<
" ll="<<pd.
LL<<
" and principle point at "<<pd.
PP);
1096 pd.
Up *= -dScale /2.0;
1105 const std::string& name,
1106 const std::string& textureOutputName,
1107 bool writeOutTexture,
1135 #ifdef BIAS_HAVE_OPENGL
1146 for (
int i=0; i<Data.
CASize; i++)
1156 for (
unsigned int j=0; j<4; j++)
1160 #endif // BIAS_HAVE_OPENGL
1163 vector<Vector3<double> > normals;
1165 if (!normals.empty() && !calcNormals)
1168 #ifdef BIAS_HAVE_OPENGL
1174 for (
int i=0; i<Data.
VASize; i++)
1177 BIASASSERT(normals.size() == Data.
vertexSet.size());
1178 for (
size_t normalsCnt = 0; normalsCnt < normals.size(); ++normalsCnt) {
1179 Data.
NormalArray[3 * normalsCnt ] = normals[normalsCnt][0];
1180 Data.
NormalArray[3 * normalsCnt + 1] = normals[normalsCnt][1];
1181 Data.
NormalArray[3 * normalsCnt + 2] = normals[normalsCnt][2];
1185 else if (calcNormals) {
1187 #ifdef BIAS_HAVE_OPENGL
1193 for (
int i=0; i<Data.
VASize; i++)
1198 for (
unsigned int i=0; i<Data.
faceIndices.size(); i++) {
1205 double norm = v2.
NormL2();
1206 if (norm > 0.0) v2 /= norm;
1208 if (norm > 0.0) v3 /= norm;
1213 if (norm > 0.0) v1 /= norm;
1214 for (
unsigned int k=0; k<3; k++)
1216 for (
unsigned int k=0; k<3; k++)
1218 for (
unsigned int k=0; k<3; k++)
1222 for (
unsigned int i=0; i<Data.
vertexSet.size(); i++) {
1228 norm = 1.0 / sqrt(norm);
1239 BIASERR(
"Computed normal has norm " << norm <<
"!");
1245 #ifdef BIAS_HAVE_OPENGL
1253 for (
unsigned int v =0; v<Data.
vertexSet.size(); v++) {
1255 if (Data.
bbmin[0] > point[0]) Data.
bbmin[0] = point[0];
1256 if (Data.
bbmax[0] < point[0]) Data.
bbmax[0] = point[0];
1258 if (Data.
bbmin[1] > point[1]) Data.
bbmin[1] = point[1];
1259 if (Data.
bbmax[1] < point[1]) Data.
bbmax[1] = point[1];
1261 if (Data.
bbmin[2] > point[2]) Data.
bbmin[2] = point[2];
1262 if (Data.
bbmax[2] < point[2]) Data.
bbmax[2] = point[2];
1264 #ifdef BIAS_HAVE_OPENGL
1265 *(pCurVertex++) = (
float)point[0];
1266 *(pCurVertex++) = (
float)point[1];
1267 *(pCurVertex++) = (
float)point[2];
1271 #ifdef BIAS_HAVE_OPENGL
1273 unsigned int wold,hold,wnew,hnew;
1278 float sx=float(wold)/float(wnew);
1279 float sy=float(hold)/float(hnew);
1281 for (
unsigned int t =0; t<Data.
texCoordSet.size(); t++) {
1283 *(pCurTexture++) = texCoord[0] * sx;
1284 *(pCurTexture++) = texCoord[1] * sy;
1302 #endif // BIAS_HAVE_OPENGL
1309 const RGBAuc& colorSelection,
1310 const double radius,
1312 const std::string& identifier,
1313 const int camera_type)
1336 AddLine(C1, C, colorSelection);
1342 data.
Set(C, R, scale);
1349 data.
type = camera_type;
1408 const RGBAuc& colorSelection,
1409 const double radius,
1411 const int camera_type)
1417 data.
type = camera_type;
1450 if (!v.
IsHomogenized()) BIASERR(
"Supplied unhomogenized point !");
1458 const unsigned int& width,
1459 const unsigned int& height,
1461 const double& dScale)
1481 ASSERT_MAP_ELEMENT(
mapLines_, LineIndex);
1495 if (!Start.
IsHomogenized()) BIASERR(
"Supplied unhomogenized start point !");
1496 if (!End.
IsHomogenized()) BIASERR(
"Supplied unhomogenized end point !");
1508 const double &dConfidenceRegionScale)
1517 int resPCA = cov.
GetPCA(S, VT);
1523 }
else if (!VT.
IsZero(1e-8)) {
1525 BIASWARN(
"Degenerated rotation matrix VT computed from covariance matrix "
1526 "via PCA! Using default covariance ellipsoid alignment!" << endl
1527 <<
"- degenerated matrix VT = " << VT);
1530 Data.
s0 = sqrt(S[0]) * dConfidenceRegionScale;
1531 Data.
s1 = sqrt(S[1]) * dConfidenceRegionScale;
1532 Data.
s2 = sqrt(S[2]) * dConfidenceRegionScale;
1541 const double& dConfidenceRegionScale)
1544 if (!C.
IsHomogenized()) BIASERR(
"Supplied unhomogenized point !");
1564 ASSERT_MAP_ELEMENT(
mapLines_, LineIndex);
1614 map<unsigned int, PMatrix3DData>::iterator it =
mapPMatrices_.find(index);
1618 BIASERR(
"Tried to erase non-existing pmatrix:"<<index);
1629 #ifdef BIAS_HAVE_OPENGL
1639 glDisable(GL_TEXTURE_2D);
1640 glDisable(GL_LIGHTING);
1642 float linewidth = 0.0;
1643 glGetFloatv(GL_LINE_WIDTH,&linewidth);
1645 if ((linewidth>=1.0) && (linewidth<32.0))
1646 glLineWidth((GLfloat)linewidth);
1648 glLineWidth((GLfloat)1.0);
1650 #if defined(BIAS_HAVE_OPENGL) && defined(BIAS_HAVE_FONTGL)
1652 bool drawerInited =
false;
1654 drawerInited =
true;
1658 glColor4d(1.0, 0.0, 0.0, 0.0);
1660 glVertex3d(0.0, 0.0, 0.0);
1663 #if defined(BIAS_HAVE_OPENGL) && defined(BIAS_HAVE_FONTGL)
1669 glColor4d(0.0, 1.0, 0.0, 0.0);
1671 glVertex3d(0.0, 0.0, 0.0);
1674 #if defined(BIAS_HAVE_OPENGL) && defined(BIAS_HAVE_FONTGL)
1679 glColor4d(0.0, 0.0, 1.0, 0.0);
1681 glVertex3d(0.0, 0.0, 0.0);
1684 #if defined(BIAS_HAVE_OPENGL) && defined(BIAS_HAVE_FONTGL)
1697 map<unsigned int, Point3DData>::iterator it;
1702 glVertex3dv(it->second.Point.GetData());
1707 BIASERR(
"PointSprites not yet implemented");
1712 glTranslated(C[0],C[1], C[2]);
1715 glTranslated(-C[0], -C[1], -C[2]);
1719 BIASERR(
"Points as Box not yet implemented");
1729 map<unsigned int, Point3DData>::iterator it;
1753 glColor4ubv(it->second.Color.GetData());
1754 glVertex3dv(it->second.Point.GetData());
1776 BIASERR(
"PointSprites not yet implemented");
1781 glTranslated(C[0],C[1], C[2]);
1782 glColor4ubv(it->second.Color.GetData());
1784 glTranslated(-C[0], -C[1], -C[2]);
1788 BIASERR(
"Points as Box not yet implemented");
1800 unsigned int index=0;
1808 GLenum cap = GL_LINE_LOOP;
1810 glDisable(GL_TEXTURE_2D);
1817 map<unsigned int, PMatrix3DData>::iterator itP;
1822 glTranslated(it->
C[0], it->
C[1], it->
C[2]);
1824 glTranslated(-it->
C[0], -it->
C[1], -it->
C[2]);
1864 map<unsigned int, PMatrix3DData>::iterator itP;
1871 glTranslated(it->
C[0], it->
C[1], it->
C[2]);
1873 glTranslated(-it->
C[0], -it->
C[1], -it->
C[2]);
1875 glPushName(BIAS_SELECTION_OFFSET_PMATRIX +index);
1889 glVertex3dv( ((it->
Up) +(it->
C)).GetData() );
1901 float mat_diffuse[] = {Color[0]*0.7f, Color[1]*0.7f, Color[2]*0.7f, 1.0f};
1902 float mat_ambient[] = {Color[0]*0.1f, Color[1]*0.1f, Color[2]*0.1f, 1.0f};
1903 float mat_shininess[] = {8.0f };
1906 const GLenum cap = GL_POLYGON;
1907 glShadeModel(GL_FLAT);
1909 glCullFace(GL_BACK);
1910 glEnable(GL_CULL_FACE);
1911 glEnable(GL_NORMALIZE);
1912 glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS,mat_shininess);
1915 map<unsigned int, PMatrix3DData>::iterator itP;
1920 glTranslated(it->
C[0], it->
C[1], it->
C[2]);
1922 glTranslated(-it->
C[0], -it->
C[1], -it->
C[2]);
1924 glPushName(BIAS_SELECTION_OFFSET_PMATRIX +index);
1929 mat_diffuse[0] = Color[0]/255.0f*0.9f;
1930 mat_diffuse[1] = Color[1]/255.0f*0.9f;
1931 mat_diffuse[2] = Color[2]/255.0f*0.9f;
1932 mat_diffuse[3] = 1.0f;
1934 mat_ambient[0] = Color[0]/255.0f*0.2f;
1935 mat_ambient[1] = Color[1]/255.0f*0.2f;
1936 mat_ambient[2] = Color[2]/255.0f*0.2f;
1937 mat_ambient[3] = 1.0f;
1939 glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
1940 glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient);
1943 (it->
C - it->
UL).CrossProduct(it->
C - it->
UR, normal);
1944 glNormal3f((
float)normal[0], (
float)normal[1], (
float)normal[2]);
1951 (it->
C - it->
UR).CrossProduct(it->
C - it->
LR, normal);
1952 glNormal3f(-(
float)normal[0], -(
float)normal[1], -(
float)normal[2]);
1959 (it->
C - it->
LR).CrossProduct(it->
C - it->
LL, normal);
1960 glNormal3f(-(
float)normal[0], -(
float)normal[1], -(
float)normal[2]);
1967 (it->
C - it->
LL).CrossProduct(it->
C - it->
UL, normal);
1968 glNormal3f((
float)normal[0], (
float)normal[1], (
float)normal[2]);
1976 (it->
C - it->
LR).CrossProduct(it->
C - it->
UR, normal);
1977 glNormal3f((
float)normal[0], (
float)normal[1], (
float)normal[2]);
2002 myQuad = gluNewQuadric();
2003 map<unsigned int, Ellipsoid3DData>::iterator it;
2009 glTranslated(it->second.C[0], it->second.C[1], it->second.C[2]);
2010 glRotated(it->second.dAngle * DEGREE_PER_RAD,
2011 it->second.RotAxis[0], it->second.RotAxis[1],
2012 it->second.RotAxis[2]);
2019 glColor4ubv(it->second.Color.GetData());
2020 gluSphere(myQuad, 1, 20, 20);
2023 gluDeleteQuadric(myQuad);
2040 map<unsigned int, Image3DData>::iterator it=
mapImages_.begin();
2044 StatekeeperGL state(GL_ENABLE_BIT | GL_CURRENT_BIT | GL_TEXTURE_BIT);
2047 glGenTextures( 1, &texid ) ;
2048 glBindTexture( GL_TEXTURE_2D, texid) ;
2049 glEnable(GL_TEXTURE_2D);
2050 glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
2051 glDisable(GL_TEXTURE_GEN_S);
2052 glDisable(GL_TEXTURE_GEN_T);
2055 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
2056 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
2057 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
2058 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
2061 if (disableBlending)
2062 glDisable(GL_BLEND);
2067 double texX(1.0), texY(1.0);
2068 unsigned int x1, x2, y1, y2;
2069 it->second.ImageData.GetROI()->GetCorners(x1, y1, x2, y2);
2070 texX = (double)x2 / (
double)it->second.ImageData.GetWidth();
2071 texY = (double)y2 / (
double)it->second.ImageData.GetHeight();
2073 GLenum GLColorModel =
2074 (it->second.ImageData.GetChannelCount()==3)? GL_RGB : GL_LUMINANCE;
2076 glTexImage2D(GL_TEXTURE_2D, 0, GLColorModel,
2077 it->second.ImageData.GetWidth(),
2078 it->second.ImageData.GetHeight(), 0, GLColorModel,
2080 (GLvoid *) it->second.ImageData.GetImageData());
2084 glTexCoord2d(0.0, 0.0);
2085 glVertex3dv(it->second.UL.GetData());
2087 glTexCoord2d(0.0, texY);
2088 glVertex3dv(it->second.LL.GetData());
2090 glTexCoord2d(texX, texY);
2091 glVertex3dv(it->second.LR.GetData());
2093 glTexCoord2d(texX, 0.0);
2094 glVertex3dv(it->second.UR.GetData());
2098 glDeleteTextures(1, &texid);
2105 map<unsigned int, IndexedFaceSet>::iterator it;
2108 if(it->second.compiled_) {
2109 glCallList(it->second.displayList_);
2113 if (it->second.useTexture) {
2116 flippedImage.
Init(16,16,3);
2119 flippedImage.
Flip();
2124 glDeleteTextures(1, &it->second.textureObjectID_);
2125 glGenTextures(1, &it->second.textureObjectID_);
2126 glBindTexture( GL_TEXTURE_2D, it->second.textureObjectID_);
2127 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
2128 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
2129 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
2132 unsigned int width, height;
2136 GLenum textureFormat = GL_RGB;
2137 int channels = it->second.texture.GetChannelCount();
2141 textureFormat = GL_LUMINANCE;
2143 }
else if (channels==3) {
2144 textureFormat = GL_RGB;
2147 }
else if (channels==4) {
2148 textureFormat = GL_RGBA;
2150 glEnable (GL_BLEND);
2151 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2153 BIASERR(
"unsupported color model.");
2157 #ifdef BIAS_HAVE_GLEW
2158 if(GLEW_EXT_framebuffer_object) {
2159 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
2160 GL_LINEAR_MIPMAP_LINEAR);
2161 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height,
2162 0, textureFormat, GL_UNSIGNED_BYTE, 0);
2163 glTexParameteri(GL_TEXTURE_2D,GL_GENERATE_MIPMAP, GL_TRUE);
2165 glTexParameteri(GL_TEXTURE_2D,
2166 GL_TEXTURE_MIN_FILTER, GL_LINEAR);
2169 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
2172 glTexImage2D(GL_TEXTURE_2D, 0, textureFormat, width, height,
2173 0, textureFormat, GL_UNSIGNED_BYTE,
2176 glDeleteLists(it->second.displayList_, 1);
2177 it->second.displayList_ = glGenLists(1);
2179 glNewList(it->second.displayList_, GL_COMPILE_AND_EXECUTE);
2180 glPushAttrib(GL_TEXTURE_BIT | GL_ENABLE_BIT);
2181 glPushClientAttrib(GL_CLIENT_ALL_ATTRIB_BITS);
2183 glVertexPointer(3, GL_FLOAT, 0, it->second.VertArray);
2184 glTexCoordPointer(2, GL_FLOAT, 0, it->second.TextureCoordArray);
2186 if(it->second.useNormals)
2187 glNormalPointer(GL_FLOAT, 0, it->second.NormalArray);
2189 glEnable(GL_TEXTURE_2D);
2190 if(it->second.useNormals)
2191 glEnableClientState(GL_NORMAL_ARRAY);
2192 glEnableClientState(GL_VERTEX_ARRAY);
2193 glEnableClientState(GL_TEXTURE_COORD_ARRAY);
2195 glBindTexture( GL_TEXTURE_2D, it->second.textureObjectID_);
2197 else if(it->second.useColoredVertices){
2199 glDeleteLists(it->second.displayList_, 1);
2200 it->second.displayList_ = glGenLists(1);
2202 glNewList(it->second.displayList_, GL_COMPILE_AND_EXECUTE);
2203 glPushClientAttrib(GL_CLIENT_ALL_ATTRIB_BITS);
2205 glVertexPointer(3, GL_FLOAT, 0, it->second.VertArray);
2206 if(it->second.useNormals)
2207 glNormalPointer(GL_FLOAT, 0, it->second.NormalArray);
2208 glColorPointer(4, GL_UNSIGNED_BYTE, 0, it->second.ColorArray);
2209 glDisable(GL_TEXTURE_2D);
2210 glEnableClientState(GL_VERTEX_ARRAY);
2211 if(it->second.useNormals)
2212 glEnableClientState(GL_NORMAL_ARRAY);
2213 glEnableClientState(GL_COLOR_ARRAY);
2215 glEnable( GL_COLOR_MATERIAL );
2216 glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE );
2219 glDeleteLists(it->second.displayList_, 1);
2220 it->second.displayList_ = glGenLists(1);
2222 glNewList(it->second.displayList_, GL_COMPILE_AND_EXECUTE);
2223 glPushClientAttrib(GL_CLIENT_ALL_ATTRIB_BITS);
2225 glVertexPointer(3, GL_FLOAT, 0, it->second.VertArray);
2226 if(it->second.useNormals)
2227 glNormalPointer(GL_FLOAT, 0, it->second.NormalArray);
2229 glDisable(GL_TEXTURE_2D);
2230 glEnableClientState(GL_VERTEX_ARRAY);
2231 if(it->second.useNormals)
2232 glEnableClientState(GL_NORMAL_ARRAY);
2235 float white[4] = {0.8, 0.8, 0.8, 1.0};
2236 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, white);
2239 #ifdef BIAS_HAVE_GLEW
2240 if (GLEW_VERSION_1_4) {
2261 it->second.facetIndicesCountArray,
2263 (
const GLvoid**)it->second.facetArray,
2264 it->second.NumFacets);
2268 for(
int i=0; i<it->second.NumFacets;i++) {
2270 it->second.facetIndicesCountArray[i],
2272 (
const GLvoid*)it->second.facetArray[i]);
2274 #ifdef BIAS_HAVE_GLEW
2277 if (it->second.useTexture) {
2278 glPopClientAttrib();
2281 glPopClientAttrib();
2286 it->second.compiled_=
true;
2297 const GLenum cap = GL_LINE_LOOP;
2298 glDisable(GL_TEXTURE_2D);
2301 map<unsigned int, Line3DData>::iterator it;
2304 glVertex3dv(it->second.Start.GetData());
2305 glVertex3dv(it->second.End.GetData());
2314 const GLenum cap = GL_LINE_LOOP;
2315 glDisable(GL_TEXTURE_2D);
2316 map<unsigned int, Line3DData>::iterator it;
2319 glColor4ubv(it->second.Color.GetData());
2322 glVertex3dv(it->second.Start.GetData());
2323 glVertex3dv(it->second.End.GetData());
2334 glEnable (GL_BLEND);
2335 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2338 myQuad = gluNewQuadric();
2339 map<unsigned int, Ellipsoid3DData>::iterator it;
2343 glTranslated(it->second.C[0], it->second.C[1], it->second.C[2]);
2344 glRotated(it->second.dAngle * DEGREE_PER_RAD,
2345 it->second.RotAxis[0], it->second.RotAxis[1],
2346 it->second.RotAxis[2]);
2352 gluSphere(myQuad, 1, 20, 20);
2355 gluDeleteQuadric(myQuad);
2365 myQuad = gluNewQuadric();
2368 float white[] = {1.0, 1.0, 1.0, 1.0};
2370 float lightRed[] = {0.6, 0.0, 0.0, 1.0};
2373 float darkGreen[] = {0.0, 0.2, 0.0, 1.0};
2375 float lightBlue[] = {0.0, 0.0, 0.6, 1.0};
2378 float darkGrey[] = {0.2, 0.2, 0.2, 1.0};
2381 float position1_light[]= {1000.0, 1000.0, 3000.0, 1.0};
2382 glLightfv(GL_LIGHT4, GL_POSITION, position1_light);
2383 float position2_light[]= {-1000.0, -1000.0, 5000.0, 1.0};
2384 glLightfv(GL_LIGHT5, GL_POSITION, position2_light);
2385 float position3_light[]= {.0, .0, 4000.0, 1.0};
2386 glLightfv(GL_LIGHT6, GL_POSITION, position3_light);
2388 GLboolean hadLight[8][1];
2389 glGetBooleanv(GL_LIGHTING,hadLight[0]);
2390 glGetBooleanv(GL_LIGHT0,hadLight[1]);
2391 glGetBooleanv(GL_LIGHT1,hadLight[2]);
2392 glGetBooleanv(GL_LIGHT2,hadLight[3]);
2393 glGetBooleanv(GL_LIGHT3,hadLight[4]);
2394 glGetBooleanv(GL_LIGHT4,hadLight[5]);
2395 glGetBooleanv(GL_LIGHT5,hadLight[6]);
2396 glGetBooleanv(GL_LIGHT6,hadLight[7]);
2399 if(!hadLight[0][0]) glEnable(GL_LIGHTING);
2400 if( hadLight[1][0]) glDisable(GL_LIGHT0);
2401 if( hadLight[2][0]) glDisable(GL_LIGHT1);
2402 if( hadLight[3][0]) glDisable(GL_LIGHT2);
2403 if( hadLight[4][0]) glDisable(GL_LIGHT3);
2404 if(!hadLight[5][0]) glEnable(GL_LIGHT4);
2405 if(!hadLight[6][0]) glEnable(GL_LIGHT5);
2406 if(!hadLight[7][0]) glEnable(GL_LIGHT6);
2408 glLightfv(GL_LIGHT4, GL_DIFFUSE, lightBlue);
2409 glLightfv(GL_LIGHT4, GL_SPECULAR, white);
2410 glLightfv(GL_LIGHT4, GL_AMBIENT, darkGrey);
2411 glLightfv(GL_LIGHT5, GL_DIFFUSE, lightRed);
2412 glLightfv(GL_LIGHT5, GL_SPECULAR, white);
2413 glLightfv(GL_LIGHT5, GL_AMBIENT, darkGrey);
2414 glLightfv(GL_LIGHT6, GL_DIFFUSE, darkGreen);
2415 glLightfv(GL_LIGHT6, GL_SPECULAR, white);
2416 glLightfv(GL_LIGHT6, GL_AMBIENT, darkGrey);
2419 glCullFace(GL_BACK);
2420 glEnable(GL_CULL_FACE);
2421 glEnable(GL_NORMALIZE);
2423 glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, darkGrey);
2424 glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 50.0);
2426 glLightModelf(GL_LIGHT_MODEL_LOCAL_VIEWER,GL_TRUE);
2427 glShadeModel(GL_SMOOTH);
2429 map<unsigned int, Ellipsoid3DData>::iterator it;
2430 unsigned char *color;
float cf[4];
2433 color = it->second.Color.GetData();
2434 for(
int i=0;i<4;i++) cf[i] = (
float)(color[i])/255.0;
2436 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, cf);
2437 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR,cf);
2439 glMatrixMode(GL_MODELVIEW);
2442 glTranslated(it->second.C[0], it->second.C[1], it->second.C[2]);
2443 glRotated(it->second.dAngle * DEGREE_PER_RAD,
2444 it->second.RotAxis[0], it->second.RotAxis[1],
2445 it->second.RotAxis[2]);
2450 glColor4ubv(it->second.Color.GetData());
2453 gluSphere(myQuad, 1, 20, 20);
2458 if(!hadLight[0][0]) glDisable(GL_LIGHTING);
2459 if( hadLight[1][0]) glEnable(GL_LIGHT0);
2460 if( hadLight[2][0]) glEnable(GL_LIGHT1);
2461 if( hadLight[3][0]) glEnable(GL_LIGHT2);
2462 if( hadLight[4][0]) glEnable(GL_LIGHT3);
2463 if(!hadLight[5][0]) glDisable(GL_LIGHT4);
2464 if(!hadLight[6][0]) glDisable(GL_LIGHT5);
2465 if(!hadLight[7][0]) glDisable(GL_LIGHT6);
2467 gluDeleteQuadric(myQuad);
2497 #endif // BIAS_HAVE_OPENGL
2503 #ifdef BIAS_HAVE_OPENGL
2505 for(i = 0; i <= lats; i++) {
2506 double lat0 = M_PI * (-0.5 + (double) (i - 1) / lats);
2507 double z0 = sin(lat0);
2508 double zr0 = cos(lat0);
2510 double lat1 = M_PI * (-0.5 + (double) i / lats);
2511 double z1 = sin(lat1);
2512 double zr1 = cos(lat1);
2514 glBegin(GL_QUAD_STRIP);
2515 for(j = 0; j <= longs; j++) {
2516 double lng = 2 * M_PI * (double) (j - 1) / longs;
2517 double x = cos(lng);
2518 double y = sin(lng);
2520 glNormal3f(x * zr0, y * zr0, z0);
2521 glVertex3f(x * zr0, y * zr0, z0);
2522 glNormal3f(x * zr1, y * zr1, z1);
2523 glVertex3f(x * zr1, y * zr1, z1);
2535 map<unsigned int, Point3DData>::iterator it =
mapPoints_.begin();
2539 it->second.Color = Color;
2549 unsigned int numpointsets = numpoints /5000;
2550 unsigned int remainingpoints = numpoints % 5000;
2552 if (remainingpoints >0) numpointsets++;
2557 map<unsigned int, Point3DData>::iterator it1 =
mapPoints_.begin();
2558 map<unsigned int, Point3DData>::iterator it2 =
mapPoints_.begin();
2560 for (
unsigned int ps=0;ps<numpointsets; ps++)
2564 " geometry PointSet {"<<endl<<
2565 " color Color {"<<endl<<
2571 r = (double)Da.
Color[0] / 255.0;
2572 g = (
double)Da.
Color[1] / 255.0;
2573 b = (double)Da.
Color[2] / 255.0;
2575 VRMLFile<<
", "<<endl;
2576 VRMLFile <<
" "<< r <<
" " << g <<
" " << b;
2580 VRMLFile<<
" ] " << endl
2582 <<
" coord Coordinate { "<<endl
2583 <<
" point [ "<<endl;
2590 VRMLFile<<
", "<<endl;
2592 << setw(w) << Db.
Point[0] <<
" "
2593 << setw(w) << Db.
Point[1] <<
" "
2594 << setw(w) << Db.
Point[2];
2598 VRMLFile <<
" ] " << endl
2613 " geometry IndexedFaceSet {"<<endl<<
2614 " color Color {"<<endl<<
2618 map<unsigned int, Point3DData>::iterator it =
mapPoints_.begin();
2621 r = (double)Da.
Color[0] / 255.0;
2622 g = (
double)Da.
Color[1] / 255.0;
2623 b = (double)Da.
Color[2] / 255.0;
2625 VRMLFile<<
","<<endl;
2626 for (
unsigned int i=0;i<7;i++)
2628 " "<< r <<
" " << g <<
" " << b<<
","<<endl;
2630 " "<< r <<
" " << g <<
" " << b;
2637 " coord Coordinate {"<<endl<<
2647 VRMLFile<<
","<<endl<<endl;
2651 << setw(w) << Db.
Point[0]-size <<
" "
2652 << setw(w) << Db.
Point[1]+size <<
" "
2653 << setw(w) << Db.
Point[2]-size;
2654 VRMLFile<<
","<<endl;
2657 << setw(w) << Db.
Point[0]+size <<
" "
2658 << setw(w) << Db.
Point[1]+size <<
" "
2659 << setw(w) << Db.
Point[2]-size;
2660 VRMLFile<<
","<<endl;
2663 << setw(w) << Db.
Point[0]+size <<
" "
2664 << setw(w) << Db.
Point[1]+size <<
" "
2665 << setw(w) << Db.
Point[2]+size;
2666 VRMLFile<<
","<<endl;
2669 << setw(w) << Db.
Point[0]-size <<
" "
2670 << setw(w) << Db.
Point[1]+size <<
" "
2671 << setw(w) << Db.
Point[2]+size;
2672 VRMLFile<<
","<<endl;
2676 << setw(w) << Db.
Point[0]-size <<
" "
2677 << setw(w) << Db.
Point[1]-size <<
" "
2678 << setw(w) << Db.
Point[2]-size;
2679 VRMLFile<<
","<<endl;
2682 << setw(w) << Db.
Point[0]+size <<
" "
2683 << setw(w) << Db.
Point[1]-size <<
" "
2684 << setw(w) << Db.
Point[2]-size;
2685 VRMLFile<<
","<<endl;
2688 << setw(w) << Db.
Point[0]+size <<
" "
2689 << setw(w) << Db.
Point[1]-size <<
" "
2690 << setw(w) << Db.
Point[2]+size;
2691 VRMLFile<<
","<<endl;
2694 << setw(w) << Db.
Point[0]-size <<
" "
2695 << setw(w) << Db.
Point[1]-size <<
" "
2696 << setw(w) << Db.
Point[2]+size;
2703 " coordIndex ["<<endl;
2704 for (
unsigned int i=0;i<
mapPoints_.size();i++) {
2706 VRMLFile<<
","<<endl<<endl;
2708 i*8+0<<
", "<<i*8+1<<
", "<<i*8+2<<
", "<<i*8+3<<
", -1,"<<
2709 " # top side"<<endl<<
" "<<
2710 i*8+7<<
", "<<i*8+6<<
", "<<i*8+5<<
", "<<i*8+4<<
", -1,"<<
2711 " # bottom side"<<endl<<
" "<<
2712 i*8+4<<
", "<<i*8+5<<
", "<<i*8+1<<
", "<<i*8+0<<
", -1,"<<
2713 " # back side"<<endl<<
" "<<
2714 i*8+3<<
", "<<i*8+2<<
", "<<i*8+6<<
", "<<i*8+7<<
", -1,"<<
2715 " # front side"<<endl<<
" "<<
2716 i*8+0<<
", "<<i*8+3<<
", "<<i*8+7<<
", "<<i*8+4<<
", -1,"<<
2717 " # left side"<<endl<<
" "<<
2718 i*8+2<<
", "<<i*8+1<<
", "<<i*8+5<<
", "<<i*8+6<<
", -1";
2723 " ccw FALSE"<<endl<<
2724 " colorPerVertex TRUE"<<endl<<
2739 BIASERR(
"PointSprites not yet implemented");
2757 default: BIASERR(
"Not yet implmented");
break;
2761 map<unsigned int, Ellipsoid3DData>::iterator it;
2780 map<unsigned int, PMatrix3DData>::iterator itP;
2781 r = (double)Color[0] / 255.0;
2782 g = (double)Color[1] / 255.0;
2783 b = (double)Color[2] / 255.0;
2787 VRMLFile <<
"Shape {" << endl;
2789 VRMLFile <<
" geometry IndexedLineSet {" << endl;
2790 VRMLFile <<
" coord Coordinate {" << endl;
2791 VRMLFile <<
" point [ " << endl;
2795 <<
" "<<it->
C[0]<<
" "<<it->
C[1]<<
" "<<it->
C[2]<<
" , "<< endl
2796 <<
" "<<it->
UL[0]<<
" "<<it->
UL[1]<<
" "<<it->
UL[2] <<
" , " <<endl
2797 <<
" "<<it->
UR[0]<<
" "<<it->
UR[1]<<
" " <<it->
UR[2]<<
" , " << endl
2798 <<
" "<<it->
LR[0]<<
" "<<it->
LR[1]<<
" " <<it->
LR[2]<<
" , " << endl
2799 <<
" "<<it->
LL[0]<<
" "<<it->
LL[1]<<
" " <<it->
LL[2]<<
" , " << endl;
2802 VRMLFile<<
" ] " << endl;
2803 VRMLFile <<
" }" << std::endl;
2804 VRMLFile <<
" coordIndex [" << endl;
2805 for (
unsigned int i=0;i<num; i++) {
2807 VRMLFile <<
" "<<n<<
", "<<n+2<<
", "<<n+1<<
", -1" <<endl;
2808 VRMLFile <<
" "<<n<<
", "<<n+1<<
", "<<n+4<<
", -1" <<endl;
2809 VRMLFile <<
" "<<n<<
", "<<n+4<<
", "<<n+3<<
", -1" <<endl;
2810 VRMLFile <<
" "<<n<<
", "<<n+3<<
", "<<n+2<<
", -1" <<endl;
2812 VRMLFile <<
" ] " << endl;
2813 VRMLFile <<
" }" << endl;
2815 VRMLFile <<
" appearance Appearance { " << endl;
2816 VRMLFile <<
" material Material {"<<endl
2817 <<
" diffuseColor " <<
" "<<r<<
" "<<g<<
" "<<b<<endl
2818 <<
" emissiveColor " <<
" "<<r<<
" "<<g<<
" "<<b<<endl
2820 VRMLFile <<
" }" << endl;
2821 VRMLFile <<
"}" << endl;
2833 map<unsigned int, PMatrix3DData>::iterator itP;
2834 r = (double)Color[0] / 255.0;
2835 g = (double)Color[1] / 255.0;
2836 b = (double)Color[2] / 255.0;
2840 VRMLFile <<
"Shape {" << endl;
2841 VRMLFile <<
" geometry IndexedLineSet {" << endl;
2842 VRMLFile <<
" coord Coordinate {" << endl;
2843 VRMLFile <<
" point [" << endl;
2849 up = it->
C + it->
Up;
2851 <<
" " <<up[0]<<
" "<<up[1]<<
" "<<up[2] <<
", "<<endl
2852 <<
" " <<it->
C[0]<<
" "<<it->
C[1]<<
" "<<it->
C[2]<<
","<<endl
2853 <<
" " <<it->
PP[0]<<
" "<<it->
PP[1]<<
" "<<it->
PP[2] <<
", "<<endl;
2856 VRMLFile<<
" ]" << endl;
2857 VRMLFile <<
" }"<<endl;
2858 VRMLFile <<
" coordIndex [ "<<endl;
2859 for (
unsigned int i=0;i<num; i++)
2860 VRMLFile <<
" "<<i*3<<
" "<<i*3+1<<
" "<<i*3+2<<
" -1"<<endl;
2861 VRMLFile <<
" ]"<< endl;
2862 VRMLFile <<
" color Color {"<<endl;
2863 VRMLFile <<
" color [ "<<endl;
2864 for (
unsigned int i=0;i<num; i++)
2865 VRMLFile <<r<<
" "<<g<<
" "<<b<<
", " <<r<<
" "<<g<<
" "<<b<<
" ,"<<endl;
2866 VRMLFile <<
" ] "<<endl;
2867 VRMLFile <<
" }\n}\n}"<< endl;
2876 double transparency,
2877 bool CenterAsSphere){
2880 r = (double)it->
Color[0] / 255.0;
2881 g = (
double)it->
Color[1] / 255.0;
2882 b = (double)it->
Color[2] / 255.0;
2886 VRMLFile << std::endl;
2889 VRMLFile <<
" Shape {" << std::endl;
2892 if (it->
name.length()>0)
2895 VRMLFile <<
" geometry";
2896 VRMLFile <<
" IndexedFaceSet {" << std::endl;
2897 VRMLFile <<
" coord Coordinate {" << std::endl;
2898 VRMLFile <<
" point [ " << std::endl;
2899 VRMLFile <<
" "<<it->
C[0]<<
" "<<it->
C[1]<<
" "
2900 <<it->
C[2]<<
" , " << std::endl;
2901 VRMLFile <<
" "<<it->
UL[0]<<
" "<<it->
UL[1]
2902 <<
" "<<it->
UL[2] <<
" , " <<std:: endl;
2903 VRMLFile <<
" "<<it->
UR[0]<<
" "<<it->
UR[1]<<
" "
2904 <<it->
UR[2]<<
" , " << std::endl;
2905 VRMLFile <<
" "<<it->
LR[0]<<
" "<<it->
LR[1]<<
" "
2906 <<it->
LR[2]<<
" , " << std::endl;
2907 VRMLFile <<
" "<<it->
LL[0]<<
" "<<it->
LL[1]<<
" "
2908 <<it->
LL[2] <<
" ] " << std::endl;
2910 VRMLFile <<
" }" << std::endl;
2913 VRMLFile <<
" coordIndex [" << endl;
2914 VRMLFile <<
" 0, 2, 1, -1, " << std::endl;
2915 VRMLFile <<
" 0, 1, 4, -1, " << std::endl;
2916 VRMLFile <<
" 0, 4, 3, -1, " << std::endl;
2917 VRMLFile <<
" 0, 3, 2, -1, " << std::endl;
2918 VRMLFile <<
" 1, 2, 4, -1, " << std::endl;
2919 VRMLFile <<
" 4, 2, 3, -1 ]" << std::endl;
2921 VRMLFile <<
" }" << std::endl << std::endl;
2923 VRMLFile <<
" appearance Appearance { " << endl;
2925 VRMLFile <<
" material Material { diffuseColor "
2926 <<
" "<<r<<
" "<<g<<
" "<<b<< std::endl
2927 <<
" transparency "<< transparency
2929 VRMLFile <<
"} " << std::endl;
2930 VRMLFile <<
" }" << std::endl;
2936 r = (double)it->
Color[0] / 255.0;
2937 g = (
double)it->
Color[1] / 255.0;
2938 b = (double)it->
Color[2] / 255.0;
2942 VRMLFile <<
"Shape {" << endl;
2945 VRMLFile <<
" geometry IndexedLineSet {" << endl;
2946 VRMLFile <<
" coord Coordinate {" << endl;
2947 VRMLFile <<
" point [ " << endl;
2948 VRMLFile <<
" "<<it->
C[0]<<
" "<<it->
C[1]<<
" "
2949 <<it->
C[2]<<
" , " << endl;
2966 VRMLFile <<
" }" << std::endl;
2969 VRMLFile <<
" coordIndex [" << endl;
2970 VRMLFile <<
" 0, 2, 1, -1, " << endl;
2971 VRMLFile <<
" 0, 1, 4, -1, " << endl;
2972 VRMLFile <<
" 0, 4, 3, -1, " << endl;
2973 VRMLFile <<
" 0, 3, 2, -1] " << endl;
2974 VRMLFile <<
" }" << endl;
2977 VRMLFile <<
" appearance Appearance { " << endl;
2978 VRMLFile <<
" material Material {"<<endl
2979 <<
" diffuseColor " <<
" "<<r<<
" "<<g<<
" "<<b<<endl
2980 <<
" emissiveColor " <<
" "<<r<<
" "<<g<<
" "<<b<<endl
2982 VRMLFile <<
" }" << endl;
2983 VRMLFile <<
"}" << endl;
2986 r = (double)it->
Color[0] / 255.0;
2987 g = (
double)it->
Color[1] / 255.0;
2988 b = (double)it->
Color[2] / 255.0;
2990 if (CenterAsSphere) {
2991 VRMLFile <<
"Transform {"<<endl;
2992 VRMLFile <<
" translation "
2993 << it->
C[0] <<
" " <<it->
C[1] <<
" " <<it->
C[2]
2995 VRMLFile <<
" children ";
2996 VRMLFile <<
" Shape {"<<endl;
2997 VRMLFile <<
" appearance Appearance { " << endl;
2998 VRMLFile <<
" material Material { " << endl;
2999 VRMLFile <<
" transparency "
3001 VRMLFile <<
" diffuseColor " << r <<
" " << g <<
" "<<b << endl;
3002 VRMLFile <<
" }" << endl;
3003 VRMLFile <<
" }" << endl;
3004 VRMLFile <<
" geometry Sphere { radius "
3005 << 0.1*(it->
C-it->
PP).NormL2()<<
" }"
3007 VRMLFile <<
" }" << endl;
3008 VRMLFile <<
"}" << endl;
3011 VRMLFile <<
"Shape {" << endl;
3012 VRMLFile <<
" geometry PointSet {"<<endl;
3013 VRMLFile <<
" coord Coordinate {"<<endl;
3014 VRMLFile <<
" point ["<<it->
C[0]<<
" "<<it->
C[1]<<
" "<<it->
C[2]
3015 <<
"]" << endl <<
" }"<<endl;
3016 VRMLFile <<
" color Color { color [ 0 1 0, 0 1 0 ] }"<<endl;
3017 VRMLFile <<
" }\n}"<<endl;
3021 VRMLFile <<
"Shape {" << endl;
3022 VRMLFile <<
" geometry IndexedLineSet {" << endl;
3023 VRMLFile <<
" coord Coordinate {" << endl;
3024 VRMLFile <<
" point [" << endl;
3025 VRMLFile <<
" " <<it->
C[0]<<
" "<<it->
C[1]<<
" "
3026 <<it->
C[2]<<
","<<endl;
3027 VRMLFile <<
" " <<it->
PP[0]<<
" "<<it->
PP[1]<<
" "
3028 <<it->
PP[2] <<
" ]" << endl;
3029 VRMLFile <<
" }"<<endl;
3030 VRMLFile <<
" coordIndex [ 0 1 -1 ]"<< endl;
3031 VRMLFile <<
" color Color {"<<endl;
3032 VRMLFile <<
" color [ "<<r<<
" "<<g<<
" "<<b<<
", "
3033 <<r<<
" "<<g<<
" "<<b<<
" ] "<<endl;
3034 VRMLFile <<
" }\n}\n}"<< endl;
3037 default: BIASERR(
"Desired Camera drawing style is not implemented."
3038 <<
" Skipping Cameras.");
3048 double transparency = 0;
3049 bool CenterAsSphere =
true;
3050 map<unsigned int, PMatrix3DData>::iterator itP;
3056 transparency, CenterAsSphere) != 0)
3060 map<unsigned int, Ellipsoid3DData>::iterator mit;
3074 double r = (double)Color[0] / 255.0;
3075 double g = (double)Color[1] / 255.0;
3076 double b = (double)Color[2] / 255.0;
3080 for (map<unsigned int, Line3DData>::iterator it=
mapLines_.begin();
3082 VRMLFile << std::endl;
3083 VRMLFile <<
" Shape {" << std::endl;
3084 VRMLFile <<
" geometry IndexedLineSet {" << std::endl;
3085 VRMLFile <<
" coord Coordinate {" << std::endl;
3086 VRMLFile <<
" point [ " << std::endl;
3087 VRMLFile <<
" "<<it->second.Start[0]<<
" "
3088 << it->second.Start[1]<<
" " <<it->second.Start[2]<<
" , "
3090 VRMLFile <<
" "<<it->second.End[0]<<
" "
3091 <<it->second.End[1] <<
" "<<it->second.End[2] <<
" ] "<<std::endl;
3093 VRMLFile <<
" }" << std::endl;
3094 VRMLFile <<
" coordIndex [ 0, 1, -1 ]" << std::endl;
3095 VRMLFile <<
" color Color {" << std::endl;
3096 VRMLFile <<
" color [ "<<r<<
" "<<g<<
" "<<b<<
" ]"<<std::endl;
3097 VRMLFile <<
" } " <<std:: endl;
3098 VRMLFile <<
" colorPerVertex FALSE " << std::endl;
3099 VRMLFile <<
" }" << std::endl << std::endl;
3100 VRMLFile <<
" }" << std::endl;
3103 default: BIASERR(
"Unsupported LineStyle, line drawing disabled.");
return -1;
3111 map<unsigned int, Projection3DData>::iterator it;
3118 r = (double)it->second.ColorOfSelection[0] / 255.0;
3119 g = (
double)it->second.ColorOfSelection[1] / 255.0;
3120 b = (double)it->second.ColorOfSelection[2] / 255.0;
3121 VRMLFile <<
"\t Transform {"<<std::endl;
3122 VRMLFile <<
"\t translation "
3123 <<it->second.C[0]<<
" "<<it->second.C[1]<<
" "<<it->second.C[2]
3126 VRMLFile <<
"\t rotation "
3127 <<it->second.axis[0]<<
" "<<it->second.axis[1]
3128 <<
" "<<it->second.axis[2]<<
" "<<it->second.angle
3130 VRMLFile <<
"\t children ["<<std::endl;
3132 (
float)it->second.radiusSelection,
3133 (float)r, (
float)g, (float)b, 1.0f,
3135 it->second.identifier);
3141 if(it->second.type == 0){
3144 it->second.radiusSelection,
3149 it->second.identifier);
3153 if(it->second.type == 1){
3154 cout<<
" trying to build conical camera rep:\n! ";
3157 it->second.radiusSelection,
3161 it->second.identifier);
3167 if(it->second.type == 0){
3170 it->second.radiusSelection,
3175 it->second.identifier,
3180 if(it->second.type == 1){
3183 it->second.radiusSelection,
3187 it->second.identifier,
3192 VRMLFile <<
"\t ]"<<std::endl;
3193 VRMLFile <<
"\t }"<<std::endl;
3205 map<unsigned int, IndexedFaceSet>::iterator it;
3207 if (it->second.vertexSet.empty())
continue;
3208 VRMLFile << std::endl;
3209 VRMLFile <<
"Transform { scale 1 1 1"<<endl<<
" children [ "<<endl;
3210 VRMLFile <<
" Shape {" << std::endl;
3213 VRMLFile <<
" appearance Appearance { " << std::endl;
3214 if (it->second.texture.GetSize() == 0) {
3215 VRMLFile <<
" material Material { diffuseColor 0.8 0.8 0.8 } "<<endl;
3217 VRMLFile <<
"# enable this line and disable the texture below to see"
3218 <<
" an untextured model with normals "<<endl;
3219 VRMLFile <<
"# material Material { diffuseColor 0.8 0.8 0.8 } "<<endl;
3221 VRMLFile <<
"# enable this line to see a textured model "<<endl;
3222 VRMLFile <<
" texture ";
3223 if(it->second.textureName ==
"") {
3224 VRMLFile <<
"PixelTexture {" << std::endl;
3226 VRMLFile <<
" image "
3227 <<it->second.texture.GetWidth()<<
" "
3228 <<it->second.texture.GetHeight()<<
" "
3229 <<it->second.texture.GetChannelCount()<<std::endl;
3230 unsigned int channelColor;
3231 unsigned int writeCounter = 0;
3232 for (
int h=it->second.texture.GetHeight()-1; h>=0; h--) {
3234 for(
unsigned int w=0; w<it->second.texture.GetWidth(); w++) {
3236 for(
unsigned int c=0; c<it->second.texture.GetChannelCount(); c++) {
3237 channelColor= it->second.texture.PixelValue(w,h,(
unsigned short)c);
3238 VRMLFile.flags(ios_base::hex);
3241 VRMLFile<<channelColor;
3244 if(writeCounter>=8) {
3245 VRMLFile<<std::endl;
3248 VRMLFile.flags(ios_base::dec);
3251 VRMLFile<<std::endl;
3253 VRMLFile.flags(ios_base::dec);
3254 VRMLFile <<
" } " << endl;
3258 VRMLFile <<
"ImageTexture { url \""<<it->second.textureName;
3259 VRMLFile <<
"\" } " << endl;
3260 if(it->second.writeOutTexture)
3264 VRMLFile <<
" }" << endl;
3266 if (it->second.name.length()>0)
3269 VRMLFile <<
" geometry";
3270 VRMLFile <<
" IndexedFaceSet { " << std::endl;
3272 VRMLFile <<
" coord Coordinate {" << std::endl;
3273 VRMLFile <<
" point [ " << std::endl;
3275 const int vnum = int(it->second.vertexSet.size());
3276 for(
int i = 0; i < vnum; i++) {
3278 << it->second.vertexSet[i][0] <<
" "
3279 << it->second.vertexSet[i][1] <<
" "
3280 << it->second.vertexSet[i][2]
3281 << (((i+1) == vnum) ?
" ] " :
", ") << std::endl;
3284 VRMLFile <<
" } " << std::endl;
3286 if (it->second.texture.GetSize() != 0) {
3289 VRMLFile <<
" texCoord TextureCoordinate { " << std::endl;
3290 VRMLFile <<
" point [ " << std::endl;
3291 const int vnum = int(it->second.texCoordSet.size());
3292 for(
int i = 0; i < vnum; i++) {
3294 << it->second.texCoordSet[i][0] <<
" "
3295 << it->second.texCoordSet[i][1]
3296 << (((i+1) == vnum) ?
" ] " :
", ") << std::endl;
3298 VRMLFile <<
" }" << std::endl;
3300 #ifdef BIAS_HAVE_OPENGL
3302 if (it->second.NormalArray != NULL) {
3303 VRMLFile <<
" normal Normal {" << std::endl
3304 <<
" vector [ " << std::endl;
3305 float *pData = it->second.NormalArray;
3306 const int vnum = int(it->second.vertexSet.size());
3307 for(
int i = 0; i < vnum; i++) {
3308 VRMLFile <<
" " << *pData++;
3309 VRMLFile <<
" " << *pData++;
3310 VRMLFile <<
" " << *pData++;
3311 VRMLFile << (((i+1) == vnum) ?
" ] " :
", ") << std::endl;
3313 VRMLFile <<
" }" << endl;
3317 VRMLFile <<
" coordIndex [ " << std::endl;
3319 const int vnum = int(it->second.faceIndices.size());
3320 for(
int i = 0; i < vnum; i++) {
3322 for(
int j = 0; j < (it->second.faceIndices[i]).size(); j++)
3323 VRMLFile << it->second.faceIndices[i][j] <<
", ";
3324 VRMLFile <<
" -1 " << (((i+1) == vnum) ?
" ] " :
", ") << std::endl;
3328 VRMLFile <<
" }" << std::endl;
3329 VRMLFile <<
" }" << std::endl;
3330 VRMLFile <<
" ] "<<std:: endl <<
"} "<<std::endl;
3337 map<unsigned int, Image3DData>::iterator it;
3340 it->second.LL + it->second.UR));
3342 VRMLFile <<
"Transform { "<<endl;
3350 VRMLFile <<
" translation "<< Center[0]<<
" "<< Center[1]<<
" "<< Center[2] <<endl;
3351 VRMLFile <<
" children [ "<<endl;
3353 if (it->second.name !=
"") {
3354 VRMLFile <<
" Transform { "<<endl;
3358 VRMLFile <<
" rotation 1 0 0 -1.57 # [-1,1],(-,) "<<endl;
3362 VRMLFile <<
" children [ "<<endl;
3364 VRMLFile <<
" Text { "<<endl;
3365 VRMLFile <<
" string \"" <<it->second.name <<
"\" "<<endl;
3369 VRMLFile <<
" }"<<endl;
3370 VRMLFile<<
" ]"<<endl;
3371 VRMLFile <<
" }"<<endl;
3374 if (it->second.BillBoard)
3377 diag2(it->second.LL - it->second.UR);
3381 RotAx(diag1.CrossProduct(diag2).CrossProduct(
Vector3<double>(0,1,0)));
3383 if (RotAx.NormL2()>1e-8) {
3385 BIASERR(
"Billboard must lie in xz plane !!!");
3389 VRMLFile << std::endl;
3390 VRMLFile <<
"Billboard { "<<endl;
3392 VRMLFile <<
" axisOfRotation "<< AxisOfRotation1[0]<<
" "
3393 << AxisOfRotation1[1]<<
" "<< AxisOfRotation1[2]
3396 VRMLFile <<
" children [ "<<endl;
3399 VRMLFile << std::endl;
3400 VRMLFile <<
" Shape { " << std::endl;
3402 VRMLFile <<
" appearance Appearance { " << std::endl;
3403 VRMLFile <<
" material Material { "<<endl;
3404 VRMLFile <<
" diffuseColor 0.2 0.2 0.2 # MFColor"<<endl;
3405 VRMLFile <<
" specularColor 0 0 0 # MFColor"<<endl;
3406 VRMLFile <<
" emissiveColor 0.2 0.2 0.2 # MFColor"<<endl;
3407 VRMLFile <<
" shininess 0 # MFFloat"<<endl;
3408 VRMLFile <<
" transparency 0 # MFFloat "<<endl;
3409 VRMLFile <<
" } "<<endl;
3410 VRMLFile <<
" } " << std::endl;
3414 if (it->second.name.length()>0)
3416 <<
" IndexedFaceSet {"
3419 VRMLFile <<
" geometry IndexedFaceSet {" << std::endl;
3420 VRMLFile <<
" coord Coordinate {" << std::endl;
3421 VRMLFile <<
" point [ " << std::endl;
3425 unsigned int x1,y1,x2,y2;
3426 it->second.ImageData.GetROI()->GetCorners(x1,y1,x2,y2);
3427 const unsigned int width = x2;
3428 const unsigned int height = y2;
3429 for (
unsigned int y=0; y<=height; y++) {
3430 for (
unsigned int x=0; x<=width; x++) {
3432 const double xfrac = double(x) / double(width);
3433 const double yfrac = double(y) / double(height);
3438 xfrac*(it->second.UR-it->second.UL)+
3439 yfrac*( (1.0-xfrac) *
3440 (it->second.LL-it->second.UL)+
3441 xfrac*(it->second.LR-it->second.UR)));
3443 << CurPoint[0]-Center[0]<<
" "<<CurPoint[1]-Center[1]
3444 <<
" "<<CurPoint[2]-Center[2]
3445 << ((y == height && x == width) ?
" ] " :
", ")
3449 VRMLFile <<
" } " << std::endl;
3451 VRMLFile <<
" coordIndex [ " << endl;
3452 for (
unsigned int x=0; x<width;x++) {
3453 for (
unsigned int y=0; y<height;y++) {
3454 VRMLFile <<
" "<< (x+y*(width+1)) <<
", ";
3455 VRMLFile << (x+1+y*(width+1)) <<
", ";
3456 VRMLFile << (x+1+(y+1)*(width+1)) <<
", ";
3457 VRMLFile << (x+(y+1)*(width+1)) <<
", -1"
3458 << (((y+1) == height && (x+1) == width) ?
" ] " :
", ")
3464 VRMLFile <<
" color Color {" << std::endl;
3465 VRMLFile <<
" color [ " << std::endl;
3466 unsigned char** ppData = it->second.ImageData.GetImageDataArray();
3470 for (
unsigned int x=0; x<width; x++) {
3471 for (
unsigned int y=0; y<height; y++) {
3472 if (it->second.ImageData.GetChannelCount()==1) {
3473 r = g = b = ((double)ppData[y][x])/ 255.0;;
3474 }
else if (it->second.ImageData.GetChannelCount()==3) {
3475 r = (double)ppData[y][3*x] / 255.0;
3476 g = (double)*(&(ppData[y][3*x])+1) / 255.0;
3477 b = (double)*(&(ppData[y][3*x])+2) / 255.0;
3479 BIASERR(
"Not grey or rgb, cannot display !");
3481 VRMLFile <<
" "<<r<<
" "<<g<<
" "<<b
3482 << (((y+1) == height && (x+1) == width) ?
" ] " :
", ")
3486 VRMLFile <<
" } " <<std:: endl;
3487 VRMLFile <<
" colorPerVertex FALSE " <<std:: endl;
3488 VRMLFile <<
" } " << std::endl;
3489 VRMLFile <<
" } " << std::endl;
3490 if (it->second.BillBoard) {
3491 VRMLFile<<
" ] "<<endl;
3492 VRMLFile<<
"} " <<endl;
3495 VRMLFile<<
" ] "<<endl;
3496 VRMLFile <<
"} "<<endl;
3506 for (map<unsigned int, Line3DData>::iterator it=
mapLines_.begin();
3508 double r = (double)it->second.Color[0] / 255.0;
3509 double g = (
double)it->second.Color[1] / 255.0;
3510 double b = (double)it->second.Color[2] / 255.0;
3512 VRMLFile << std::endl;
3513 VRMLFile <<
"Shape { "<<endl;
3514 VRMLFile <<
" appearance Appearance { " << endl;
3515 VRMLFile <<
" material Material { " << endl;
3517 VRMLFile <<
" emissiveColor " << r <<
" "<< g<<
" "<<b << endl
3521 VRMLFile <<
" geometry IndexedLineSet { " << std::endl;
3522 VRMLFile <<
" coord Coordinate { " << std::endl;
3523 VRMLFile <<
" point [ " << std::endl;
3524 VRMLFile <<
" "<<it->second.Start[0]<<
" "
3525 << it->second.Start[1]<<
" " <<it->second.Start[2]<<
" , "
3527 VRMLFile <<
" "<<it->second.End[0]<<
" "
3528 <<it->second.End[1] <<
" "<<it->second.End[2] <<
" ] "<<std::endl;
3530 VRMLFile <<
" } " << std::endl;
3531 VRMLFile <<
" coordIndex [ 0, 1, -1 ] " << std::endl;
3532 VRMLFile <<
" color Color { " << std::endl;
3533 VRMLFile <<
" color [ "<<r<<
" "<<g<<
" "<<b<<
" ] "<<std::endl;
3534 VRMLFile <<
" } " <<std:: endl;
3536 VRMLFile <<
" colorPerVertex FALSE " << std::endl;
3537 VRMLFile <<
" } " << std::endl;
3538 VRMLFile <<
"} " << std::endl;
3542 BIASERR(
"Unsupported LineStyle, line drawing disabled.");
3552 VRMLFile <<
"Transform { "<<endl;
3553 VRMLFile <<
" scaleOrientation "<< E.
RotAxis[0] <<
" "
3558 VRMLFile <<
" translation "
3559 << E.
C[0] <<
" " << E.
C[1] <<
" " << E.
C[2] <<
" " << endl;
3560 VRMLFile <<
" children Shape { "<<endl;
3561 VRMLFile <<
" appearance Appearance { " << endl;
3562 VRMLFile <<
" material Material { " << endl;
3564 VRMLFile <<
" diffuseColor " << (double)Color[0]/255.0 <<
" "
3565 << (
double)Color[1]/255.0<<
" "
3566 << (double)Color[2]/255.0 << endl;
3567 VRMLFile <<
" }" << endl;
3568 VRMLFile <<
" }" << endl;
3569 VRMLFile <<
" geometry Sphere { radius 1.0 }" << endl;
3570 VRMLFile <<
" }" << endl;
3571 VRMLFile <<
"}" << endl;
3577 for (map<unsigned int, Ellipsoid3DData>::iterator it=
mapEllipsoids_.begin();
3590 for (map<unsigned int, Point3DData>::iterator it=
mapPoints_.begin();
3593 VRMLFile <<
"Transform {"<<endl;
3594 VRMLFile <<
" translation "
3596 VRMLFile <<
" children Shape {"<<endl;
3597 VRMLFile <<
" appearance Appearance { " << endl;
3598 VRMLFile <<
" material Material { " << endl;
3600 VRMLFile <<
" diffuseColor "
3601 << (double)E.
Color[0]/255.0 <<
" "
3602 << (
double)E.
Color[1]/255.0 <<
" "
3603 << (double)E.
Color[2]/255.0 << endl;
3604 VRMLFile <<
" emissiveColor "
3605 << (
double)E.
Color[0]/255.0 <<
" "
3606 << (double)E.
Color[1]/255.0 <<
" "
3607 << (
double)E.
Color[2]/255.0 << endl;
3608 VRMLFile <<
" }" << endl;
3609 VRMLFile <<
" }" << endl;
3610 VRMLFile <<
" geometry Sphere { radius "<<thesize<<
" }" << endl;
3611 VRMLFile <<
" }" << endl;
3612 VRMLFile <<
"}" << endl;
3620 for (map<unsigned int, Ellipsoid3DData>::iterator it=
mapEllipsoids_.begin();
3623 VRMLFile <<
"Transform {"<<endl;
3624 VRMLFile <<
" scaleOrientation "<< E.
RotAxis[0] <<
" "
3630 VRMLFile <<
" translation "
3631 << E.
C[0] <<
" " << E.
C[1] <<
" " << E.
C[2] << endl;
3632 VRMLFile <<
" children Shape { "<<endl;
3633 VRMLFile <<
" appearance Appearance { " << endl;
3634 VRMLFile <<
" material Material { " << endl;
3635 VRMLFile <<
" transparency "
3637 VRMLFile <<
" diffuseColor " << (double)E.
Color[0]/255.0 <<
" "
3638 << (
double)E.
Color[1]/255.0<<
" "
3639 << (double)E.
Color[2]/255.0 << endl;
3640 VRMLFile <<
" }" << endl;
3641 VRMLFile <<
" }" << endl;
3642 VRMLFile <<
" geometry Sphere { radius 1.0 }" << endl;
3643 VRMLFile <<
" }" << endl;
3644 VRMLFile <<
"}" << endl;
3652 VRMLFile.open(sFilename.c_str());
3654 BIASERR(
"Error opening VRML file for writing: "<<sFilename);
3672 VRMLFile.open(sFilename.c_str());
3674 BIASERR(
"Error opening VRML file for writing: "<<sFilename);
3697 vrml <<
"#VRML V2.0 utf8" << endl;
3698 vrml <<
"# File written by Basic Image AlgorithmS (BIAS) library" << endl;
3699 vrml <<
"# http://www.mip.informatik.uni-kiel.de"
3707 cout <<endl<<
"Dumping ThreeDOut object:"<<endl;
3708 cout <<
"Points: -----------------------------------------"<<endl;
3709 for(map<unsigned int, Point3DData>::iterator it =
mapPoints_.begin();
3711 cout <<
"["<<it->first<<
"] "<<it->second.Point<<endl;
3713 cout<<endl<<
"Lines: ------------------------------------------"<<endl;
3714 for(map<unsigned int, Line3DData>::iterator it =
mapLines_.begin();
3716 cout <<
"["<<it->first<<
"] "<<it->second.Start<<
" -> "
3717 <<it->second.End<<endl;
3719 cout<<endl<<
"PMatrices: -------------------------------------- "<<endl;
3721 for(map<unsigned int, PMatrix3DData>::iterator
3723 cout <<
"["<<(i++)<<
"] UL="<<it->second.UL<<
" UR="<<it->second.UR
3724 <<
" LL="<<it->second.LL<<
" LR="
3725 <<it->second.LR<<
" C="<<it->second.C<<endl;
3727 cout<<endl<<
"Ellipsoids: -------------------------------------"<<endl;
3728 for(map<unsigned int, Ellipsoid3DData>::iterator it =
mapEllipsoids_.begin();
3730 cout <<
"["<<it->first<<
"] Center at "<<it->second.C<<
3731 " size " <<it->second.s0<<
" " << it->second.s1<<
" " << it->second.s2 <<
3732 " color " << it->second.Color <<endl;
3742 unsigned int count=0;
3743 map<unsigned int, Point3DData>::iterator it;
3746 center += it->second.Point;
3749 center /= double(count);
3750 BIASWARN(
"The center of points cannot be determined, no points");
3758 for (
unsigned int i=0;i<3; i++) {
3763 map<unsigned int, Point3DData>::const_iterator it;
3765 for (
unsigned int i=0;i<3; i++) {
3766 if (it->second.Point[i] < min[i]) min[i] = it->second.Point[i];
3767 if (it->second.Point[i] > max[i]) max[i] = it->second.Point[i];
3772 map<unsigned int, PMatrix3DData >::const_iterator pit;
3774 for (
unsigned int i=0;i<3; i++) {
3775 if (pit->second.C[i] < min[i]) min[i] = pit->second.C[i];
3776 if (pit->second.C[i] > max[i]) max[i] = pit->second.C[i];
3780 map<unsigned int, IndexedFaceSet>::const_iterator fit;
3784 for (
unsigned int i=0;i<3; i++) {
3785 if (fmin[i] < min[i]) min[i] = fmin[i];
3786 if (fmax[i] > max[i]) max[i] = fmax[i];
3790 for (std::map<unsigned int, Image3DData>::iterator it=
mapImages_.begin();
3792 for (
unsigned int i=0;i<3; i++) {
3793 if (it->second.UL[i]<min[i]) min[i] = it->second.UL[i];
3794 if (it->second.UR[i]<min[i]) min[i] = it->second.UR[i];
3795 if (it->second.LL[i]<min[i]) min[i] = it->second.LL[i];
3796 if (it->second.LR[i]<min[i]) min[i] = it->second.LR[i];
3797 if (it->second.UL[i]>max[i]) max[i] = it->second.UL[i];
3798 if (it->second.UR[i]>max[i]) max[i] = it->second.UR[i];
3799 if (it->second.LL[i]>max[i]) max[i] = it->second.LL[i];
3800 if (it->second.LR[i]>max[i]) max[i] = it->second.LR[i];
3804 for (std::map<unsigned int, Line3DData>::iterator it=
mapLines_.begin();
3806 for (
unsigned int i=0;i<3; i++) {
3807 if (it->second.Start[i] < min[i]) min[i] = it->second.Start[i];
3808 if (it->second.Start[i] > max[i]) max[i] = it->second.Start[i];
3809 if (it->second.End[i] < min[i]) min[i] = it->second.End[i];
3810 if (it->second.End[i] > max[i]) max[i] = it->second.End[i];
3815 for (std::map<unsigned int, Ellipsoid3DData>::iterator pit=
3817 double isoscale = pit->second.s0;
3818 if (pit->second.s1>isoscale) isoscale=pit->second.s1;
3819 if (pit->second.s2>isoscale) isoscale=pit->second.s2;
3820 for (
unsigned int i=0;i<3; i++) {
3821 if (pit->second.C[i]-isoscale < min[i]) min[i] =
3822 pit->second.C[i]-isoscale;
3823 if (pit->second.C[i]+isoscale > max[i]) max[i] =
3824 pit->second.C[i]+isoscale;
3828 for (std::map<unsigned int, Ellipsoid3DData>::iterator pit=
3830 double isoscale = pit->second.s0;
3831 if (pit->second.s1>isoscale) isoscale=pit->second.s1;
3832 if (pit->second.s2>isoscale) isoscale=pit->second.s2;
3833 for (
unsigned int i=0;i<3; i++) {
3834 if (pit->second.C[i]-isoscale < min[i]) min[i] =
3835 pit->second.C[i]-isoscale;
3836 if (pit->second.C[i]+isoscale > max[i]) max[i] =
3837 pit->second.C[i]+isoscale;
3847 for (
unsigned int i=0;i<3; i++) {
3870 return double( (255.0-
double(alpha)) / 255.0 );
3885 vrml<<
"NavigationInfo {"<<endl;
3886 vrml<<
" avatarSize [0.1, 0.1, 0.1]"<<endl;
3887 vrml<<
" headlight TRUE"<<endl;
3888 vrml<<
" type [ \"EXAMINE\", \"ANY\" ]"<<endl;
3889 vrml<<
" visibilityLimit 0.0"<<endl;
3898 map<unsigned int, PMatrix3DData>::iterator itP =
mapPMatrices_.begin();
3907 u = (p->
UL +p->
UR)*0.5 - p->
C;
3909 BIASASSERT(u.
Length()!=0);
3910 BIASASSERT(v.
Length()!=0);
3912 double alpha = acos(cosAlpha);
3915 vrml<<
"Viewpoint {"<<endl;
3916 vrml<<
" position "<<p->
C[0]<<
" "<<p->
C[1]<<
" "<<p->
C[2]<<endl;
3919 vrml<<
" orientation 1 0 0 "<<M_PI<<endl;
3920 vrml<<
" fieldOfView "
3925 vrml<<
" jump TRUE"<<endl;
3926 vrml<<
" description \"camera P"<<counter<<
"\""<<endl;
3936 for (std::map<unsigned int, PMatrix3DData >::iterator it =
3938 it->second.C += movement;
3939 it->second.UL += movement;
3940 it->second.UR += movement;
3941 it->second.LL += movement;
3942 it->second.LR += movement;
3945 for (std::map<unsigned int, Image3DData>::iterator it=
mapImages_.begin();
3947 it->second.UL += movement;
3948 it->second.UR += movement;
3949 it->second.LL += movement;
3950 it->second.LR += movement;
3954 for (std::map<unsigned int, Point3DData>::iterator it=
mapPoints_.begin();
3956 it->second.Point += movement;
3960 for (std::map<unsigned int, Line3DData>::iterator it=
mapLines_.begin();
3962 it->second.Start += movement;
3963 it->second.End += movement;
3967 for (std::map<unsigned int, Ellipsoid3DData>::iterator it=
3969 it->second.C += movement;
3973 for (std::map<unsigned int, Ellipsoid3DData>::iterator it=
3975 it->second.C += movement;
3979 for (std::map<unsigned int, IndexedFaceSet>::iterator it =
3981 it->second.bbmin += movement;
3982 it->second.bbmax += movement;
3983 #ifdef BIAS_HAVE_OPENGL
3984 GLfloat *VertArray = it->second.VertArray;
3987 it->second.vertexSet.begin(); itp!=it->second.vertexSet.end();
3990 #ifdef BIAS_HAVE_OPENGL
3991 *VertArray++ += movement[0];
3992 *VertArray++ += movement[1];
3993 *VertArray++ += movement[2];
3996 #ifdef BIAS_HAVE_OPENGL
3998 if (it->second.compiled_ && it->second.displayList_ != 0) {
3999 glDeleteLists(it->second.displayList_, 1);
4000 glDeleteTextures(1, &it->second.textureObjectID_);
4001 it->second.compiled_ =
false;
4008 for (std::map<unsigned int, Projection3DData>::iterator it =
4010 it->second.C += movement;
Vector3< double > UR
upper right corner of image plane in wcs
void Release()
reimplemented from ImageBase
BIAS::Image< unsigned char > texture
double dAngle
rotation in radians around RotAxes
void GetRow(const unsigned int row, Vector3< T > &r) const
extract one row ('Zeile') from ths matrix (for convenience)
unsigned int AddPose(const PoseParametrization &p, const RGBAuc &colorSelection=RGBAuc_WHITE_OPAQUE, const double radius=0.1, const double scale=1.0, const int camera_type=-1)
GLsizei * facetIndicesCountArray
void Print3D(const std::string &text, const float &xpos, const float &ypos, const float &zpos) const
void RemoveEllipsoid(const unsigned int &EIndex)
completely removes the ellipsoid from the internal structures, there is no way to get it back ...
int VRMLOutPointsAsPointSet_(std::ostream &VRMLFile)
void RemoveLine(const unsigned int &LineIndex)
completely removes the line from the internal structures, there is no way to get it back ...
void OpenGLOutPMatrices_(const BIAS::RGBAuc &Color, bool UseOneColor)
unsigned int NextProjection3DIndex_
void RemoveImage(const unsigned int &EIndex)
completely removes the image from the internal structures, there is no way to get it back ...
const T * GetData() const
get the data pointer the member function itself is const (before {..}) because it doesn't change the ...
double s2
lengths of main axes
unsigned int AddTriangleMesh(const TriangleMesh &mesh, const std::string &name="", const std::string &textureOutputName="", bool writeOutTexture=true, bool calcNormals=false)
Adds triangle mesh as IndexedFaceSet to ThreeDOut mem.
static unsigned int PowerOfTwoSize(const unsigned int &val)
virtual ~ThreeDOut()
Destructor releases all memory used.
class HomgPoint2D describes a point with 2 degrees of freedom in projective coordinates.
std::map< unsigned int, Projection3DData > mapProjection3D_
void OpenGLOutLines()
draw all pmatrices with their own color
void UpdatePointColor(const unsigned int &PointIndex, const BIAS::RGBAuc &Color)
Vector3< double > LR
lower right corner of image plane in wcs
int VRMLOut(const std::string &sFilename)
flush all 3d objects to a vrml file with name sFilename, this is the function most users would call ...
stores important data for drawing 3d text
double Length() const
returns the Euclidean Length of the Vector
void GetVertexColors(std::vector< BIAS::Vector4< unsigned char > > &colors) const
std::map< unsigned int, Text3DData > mapTexts_
map of all point structures
int GetPCA(Vector3< COVMATRIX3X3_TYPE > &S, Matrix3x3< COVMATRIX3X3_TYPE > &VT)
void UpdatePoint(const unsigned int &PointIndex, const BIAS::Vector3< double > &v, const BIAS::RGBAuc &Color=RGBAuc_WHITE_OPAQUE)
bool IsEmpty() const
check if ImageData_ points to allocated image buffer or not
void UpdatePMatrixColor(const unsigned int &PIndex, const BIAS::RGBAuc &Color)
void SetParamsCameraStyle(CameraDrawingStyle cameraStyle)
BIAS::Vector3< double > End
unsigned int AddEllipsoid(BIAS::CovMatrix3x3 &cov, const BIAS::Vector3< double > &C, const BIAS::RGBAuc &Color=RGBAuc_WHITE_SEMI, const double &dConfidenceRegionScale=DEF_P_SCALE, const bool cameraCov=false)
ThreeDOut(const BIAS::ThreeDOutParameters ¶ms=BIAS::ThreeDOutParameters())
Constructor for empty 3D scene with given parameters.
unsigned int NextImageIndex_
counter for the next index, gaps (due to delete) are not reused by now
void SetParamsPointDrawingStyle(const PointDrawingStyle pointStyle)
std::map< unsigned int, Image3DData > mapImages_
map of all image structures
void AddPlane(const HomgPlane3D &plane, const RGBAuc &colour=RGBAuc_WHITE_SEMI, const double size=1.0, const Vector3< double > &translation=Vector3< double >(0.0, 0.0, 0.0), const bool wireframe=true)
Adds the given plane to the scene, visualising it with lines or with a colored quad.
void ScalarProduct(const Vector3< T > &argvec, T &result) const
scalar product (=inner product) of two vectors, storing the result in result
void SetColorModel(EColorModel Model)
int VRMLOutPMatricesRoutine(std::ostream &VRMLFile, const PMatrix3DData *it, double r=255.0, double g=255.0, double b=255.0, double transparency=0.0, bool CenterAsSphere=false)
only write camera into an open vrml file
BIAS::Vector3< double > LL
lower left corner of image plane in wcs
void Set(const BIAS::PoseParametrization &p, const double scale=1.0)
void PaintPyramid(std::ostream &VRMLFile, double selectionRadius, double r, double g, double b, double transparency, double angle, double ratio=4.0/3.0, double scale=1.0, const std::string &name="", bool paint_lines=false)
Write a parameterized pyramid into VRMLFile.
void SetParamsWCSAxesLength(double WCSAxesLength)
stores data for drawing a the extrinisc parameters of a projection.
BIAS::Vector3< double > Point
ThreeDOutParameters Params_
holds the params set by constructor or SetParams
void VRMLOutViewPortPyramidal(std::ostream &VRMLFile, double selectionRadius, double r, double g, double b, double angle, double ratio, double scale, const std::string &name, bool solid=false)
Write a projection of a PERSPECTIVE camera into VRML.
int VRMLOutProjection(std::ostream &VRMLFile)
only write previously stored projection objects into opened vrml file.
BIAS::RGBAuc ColorOfSelection
int VRMLOutEllipsoids(std::ostream &vrml, const BIAS::RGBAuc &Color)
only write (previously stored) ellipsoids to an open vrml file, override their individual colors with...
configuration struct for drawing styles of various 3d objects
void VRMLOutViewPortConical(std::ostream &VRMLFile, double selectionRadius, double r, double g, double b, double angle, double scale, const std::string &name, bool solid=false)
Write a projection of a NON-PERSPECTIVE camera into VRML.
void GetNormals(std::vector< BIAS::Vector3< double > > &normals) const
BIAS::RGBAuc Color
RGBA color+opacity, 255=opaque, 0=transp.
BIAS::Vector3< double > RotAxis
rot to get 1st mainaxis from (1,0,0)
std::map< unsigned int, Line3DData > mapLines_
map of all line structures
unsigned int AddImage(const Vector3< double > &UL, const Vector3< double > &UR, const Vector3< double > &LL, unsigned int Width, unsigned int Height, unsigned char *pData, unsigned int channels=1, const std::string &name="", bool billboard=false)
add a small rectangular image patch spanned by three 3d points small means really small (only a few p...
Vector3< double > bbmin
bounding box
int SetFromQuaternion(const Quaternion< ROTATION_MATRIX_TYPE > &q)
Set rotation matrix from a quaternion.
void SetParams(const ThreeDOutParameters ¶ms)
double WCSAxesLength
<=0 means no visual coordinate axes
Slim class bundeling pose parametrization and associated covariance matrix.
stores data for drawing a line
int GetR(Matrix3x3< double > &R)
void VRMLOutWCS(std::ostream &vrml)
write world coordinate system origin and axes
stores important data for drawing an el4000lipsoid
BIAS::Vector3< double > C
center of ellipsoid
unsigned int NextTextIndex_
counter for the next index, gaps (due to delete) are not reused by now
void GetTexCoords(std::vector< BIAS::Vector2< float > > &texCoo) const
unsigned int GetWidth() const
stores important data for drawing a camera
void PaintCone(std::ostream &VRMLFile, double selectionRadius, double r, double g, double b, double transparency, double angle, double scale=1.0, const std::string &name="")
Write a parameterized cone into VRMLFile.
void SetParamsDrawEllipse(bool drawEllipse)
std::map< unsigned int, Point3DData > mapPoints_
map of all point structures
void SetWriteViewpoints(const bool &val)
write VRML viewpoint nodes for some P matrices ?
Vector3< double > UL
upper left corner of image plane in wcs
std::vector< BIAS::Vector< int > > faceIndices
int VRMLOutImages(std::ostream &VRMLFile)
only write (previously stored) images into an open vrml file
CameraDrawingStyle CameraStyle
BIAS::Quaternion< double > GetQ(unsigned int cam=0) const
return rotation quaternion of camera with index cam if cam>0 this is a relative pose in the coordinat...
int InitFont(void *handleDC, const std::string theFontname=std::string(DrawTextGL_DEFAULT_FONTNAME), const int fontHeight=DrawTextGL_DEFAULT_FONTSIZE)
set the font up
unsigned int AddProjection(const Projection &p, const RGBAuc &colorSelection=RGBAuc_WHITE_OPAQUE, const double radius=0.1, const double scale=1.0, const std::string &identifier="", const int camera_type=-1)
Add a projection object to ThreeDOut mem.
bool DrawCameraUncertaintyEllipsoids
int VRMLOutPointsAsBoxes_(std::ostream &VRMLFile)
void UpdatePMatrix(const unsigned int &PIndex, BIAS::PMatrix &P, const unsigned int &width, const unsigned int &height, const BIAS::RGBAuc &Color=RGBAuc_WHITE_OPAQUE, const double &dScale=DEF_P_SCALE)
unsigned int NextEllipsoidIndex_
counter for the next ellipsoid index, gaps are not reused by now
void RemoveAllEllipsoids()
completely removes all ellipsoids from the internal structures, there is no way to get it back ...
BIAS::Vector3< double > UL
upper left corner of image plane in wcs
void Translation(const Vector3< double > &movement)
transfers the whole scene by this offset
void RemoveAllPMatrices()
completely removes all images from the internal structures, there is no way to get it back ...
Represents 3d pose transformations, parametrized as Euclidean translation and unit quaternion orienta...
void UpdateLine(const unsigned int &LineIndex, const BIAS::Vector3< double > &Start, const BIAS::Vector3< double > &End, const BIAS::RGBAuc &Color=RGBAuc_WHITE_OPAQUE)
void SetMesh(BIAS::Image< unsigned char > texture, std::vector< BIAS::Vector3< double > > meshVertices, std::vector< BIAS::Vector3< double > > vertexNormals, std::vector< BIAS::Vector2< float > > textureCoords, std::vector< BIAS::Vector< int > > triangleIndices)
void OpenGLOutIndexedFaceSets()
draw mesh into opengl
bool Greater(const T left, const T right, const T eps=std::numeric_limits< T >::epsilon())
comparison function for floating point values
void CrossProduct(const Vector3< T > &argvec, Vector3< T > &destvec) const
cross product of two vectors destvec = this x argvec
const ProjectionParametersBase * GetParameters(unsigned int cam=0) const
const parameter access function
void RemoveAllCamEllipsoids()
void Mult(const Vector3< T > &argvec, Vector3< T > &destvec) const
matrix - vector multiplicate this matrix with Vector3, storing the result in destvec calculates: dest...
bool DrawUncertaintyEllipsoids
void VRMLOutEllipsoid_(std::ostream &vrml, Ellipsoid3DData &E, const BIAS::RGBAuc &Color)
This class hides the underlying projection model, like projection matrix, spherical camera...
void CoordinateSystem(std::ostream &VRMLFile, double selectionRadius, double r, double g, double b, double axeslength, double scale=1.0, const std::string &name="")
Write a projection of a camera in COORDINATE-style into VRML.
void VRMLOutWriteNavigationInfo(std::ostream &vrml)
write VRML 2.0 navigation info node
void OpenGLOut()
render all entities (with the same color) using OpenGL Includes lines, points, pmatrices etc...
int VRMLOutPMatricesAsMesh_(std::ostream &vrml, const BIAS::RGBAuc &Color)
void SetParamsDrawCameraEllipse(bool drawEllipse)
void RemoveAllIndexedFaceSets()
void OpenGLOutWCS()
display the world coordinate system origin and axes
void OpenGLOutEllipsoids()
draw all ellipsoids with their own color:
stores datas for a textured plane
int GetInverse(Matrix3x3< T > &inv) const
Matrix inversion: inverts this and stores resulty in argument inv.
Create and represent a 3D triangle mesh.
color values, 3 channels, order: red,green,blue
void SetParamsLineDrawingStyle(const LineDrawingStyle lineStyle)
std::vector< BIAS::Vector2< float > > texCoordSet
Vector3< double > LL
lower left corner of image plane in wcs
GLenum IndexedFaceSetPrimitiveMode
unsigned int GetHeight() const
bool IsZero(const T eps=std::numeric_limits< T >::epsilon()) const
void GetNormalVector(Vector3< HOMGPLANE3D_TYPE > &normalv) const
returns normal vector
void RemovePoint(const unsigned int &PointIndex)
completely removes the point from the internal structures, there is no way to get it back ...
class for 3x3 covariance matrices
LineDrawingStyle LineStyle
void SetParamsPointSize(const double pointSize)
int VRMLOutIndexedFaceSets(std::ostream &VRMLFile)
only write (previously stored) face sets into an open vrml file Will include texture into VRML as Pix...
int VRMLOutPointsAsSpheres_(std::ostream &VRMLFile)
int VRMLOutLines(std::ostream &vrml, const BIAS::RGBAuc &Color)
only write (previously stored) lines into an open vrml file, override their individual colors with Co...
unsigned int AddLine(const BIAS::Vector3< double > &Start, const BIAS::Vector3< double > &End, const BIAS::RGBAuc &Color=RGBAuc_WHITE_OPAQUE)
std::vector< BIAS::Vector3< double > > vertexSet
static int Save(const std::string &filename, const ImageBase &img, const enum TFileFormat FileFormat=FF_auto, const bool sync=BIAS_DEFAULT_SYNC, const int c_jpeg_quality=BIAS_DEFAULT_IMAGE_QUALITY, const bool forceNewID=BIAS_DEFAULT_FORCENEWID, const bool &writeMetaData=true)
Export image as file using extrnal libs.
int SetROI(unsigned int UpperLeftX, unsigned int UpperLeftY, unsigned int LowerRightX, unsigned int LowerRightY)
deprecated, use SetROICorners()
BIAS::Vector3< double > Start
class HomgPoint3D describes a point with 3 degrees of freedom in projective coordinates.
BIAS::Vector3< double > Position
void SetParamsCameraScale(double cameraScale)
void OpenGLOutImages(const bool &disableBlending=true)
draw all image patches using OpenGL
void Init(unsigned int Width, unsigned int Height, unsigned int channels=1, enum EStorageType storageType=ST_unsignedchar, const bool interleaved=true)
calls Init from ImageBase storageType is ignored, just dummy argument
BIAS::Vector3< double > UR
upper right corner of image plane in wcs
bool Equal(const T left, const T right, const T eps)
comparison function for floating point values See http://www.boost.org/libs/test/doc/components/test_...
const StorageType * GetImageData() const
overloaded GetImageData() from ImageBase
RGBA, 4 channels, order: red,green,blue,alpha.
void RemoveAll()
removes all entites Essentially a clear on each entityt container.
PointDrawingStyle
different styles when drawing points, e.g.
static void ComputePlaneCorners(const HomgPlane3D &plane, const double size, std::vector< Vector3< double > > &corners)
Helper function computing the corners of a 3D plane.
stores data for drawing a point
void GetTriangleIndices(std::vector< BIAS::Vector< int > > &triangleIndices) const
push and pop GL states on constructor/destructor Helper class pop(save) OpenGL states on constructi...
unsigned int NextIndexedFaceSetIndex_
void GetBoundingBox(Vector3< double > &min, Vector3< double > &max)
Get the min and max vector of the smallest bounding box, which is drawn around the added points...
int GetC(Vector3< double > &C)
computes translation vector origin world coo -> origin camera coo (center), uses decomposition, which is cached
Matrix3x3< T > Transpose() const
returns transposed matrix tested 12.06.2002
const T * GetData() const
get the data pointer the member function itself is const (before {..}) because it doesn't change the...
std::string CorrectDefString_(const std::string &defstring)
replace invalid characters in def string and return corrected
void SetParamsLineWidth(const int lineWidth)
K describes the mapping from world coordinates (wcs) to pixel coordinates (pcs).
int GetA(Vector3< double > &A)
returns the unit vector A which is the normal vector to the image plane in world coordinates.
void RemoveAllPoints()
completely removes all points from the internal structures, there is no way to get them back ...
stores data for drawing a indexed face set.
void DrawSphere_(double radius, int lats, int longs)
unsigned int NextPIndex_
counter for the next index, gaps (due to delete) are not reused by now
static double VRMLtransparency(const unsigned char alpha)
get alpha opacity value as VRML transparency helper mapping, usually transparency = (1-alpha) ...
unsigned int NextLineIndex_
counter for the next line index, gaps (due to delete) arent reused
std::map< unsigned int, IndexedFaceSet > mapIndexedFaceSet_
unsigned int Size() const
Determine number of ProjectionParameterBase pointers in Projection.
int Flip()
flips the image vertically (row order is inverted) In place function return 0 in case of success...
unsigned int AddPMatrix(BIAS::PMatrix &P, const unsigned int &width, const unsigned int &height, const BIAS::RGBAuc &Color=RGBAuc_WHITE_OPAQUE, const double &dScale=DEF_P_SCALE, const std::string &name="")
decompose P and add to internal data structures.
int GetRotationAxisAngle(Vector3< ROTATION_MATRIX_TYPE > &axis, ROTATION_MATRIX_TYPE &angle) const
Calculates angle and rotation axis representation for this rotation matrix.
BIAS::Vector3< double > PP
principle point in wcs
std::vector< BIAS::Vector4< unsigned char > > vertexColorSet
void RemoveAllLines()
completely removes all lines from the internal structures JW
BIAS::Vector3< double > Up
Up-Vector (V)
describes a projective 3D -> 2D mapping in homogenous coordinates
PointDrawingStyle PointStyle
std::map< unsigned int, PMatrix3DData > mapPMatrices_
the cameras are saved in a vector for efficiency reasons
void GetVertices(std::vector< BIAS::Vector3< double > > &vertices) const
void VRMLOutWriteViewpoint(std::ostream &vrml)
write VRMl 2.0 viewpoint that can selecetd in vrml viewer
unsigned int AddPoint(const BIAS::Vector3< double > &v, const BIAS::RGBAuc &Color=RGBAuc_WHITE_OPAQUE)
Image< unsigned char > ImageData
data of texture image
std::map< unsigned int, Ellipsoid3DData > mapCamEllipsoids_
map of all ellipsoid structures
bool IsHomogenized() const
void RemoveAllImages()
completely removes all images from the internal structures, there is no way to get it back ...
void OpenGLOutPMatrices()
draw all pmatrices with their own color:
virtual const BIAS::Pose & GetPose() const
Return complete pose object.
Vector3< double > GetC(unsigned int cam=0) const
return Center of camera with index cam.
void Dump()
list all internal 3d objects on cout
void UpdateEllipsoid(const unsigned int &EIndex, BIAS::CovMatrix3x3 &cov, BIAS::Vector3< double > &C, const BIAS::RGBAuc &Color=RGBAuc_WHITE_SEMI, const double &dConfidenceRegionScale=DEF_P_SCALE)
void SetParamsEllipsoidScale(double ellipsoidScale)
CameraDrawingStyle
different styles when drawing cameras, e.g.
void OpenGLOutPoints()
draw all points with their own color:
void RemovePMatrix(int index)
removes the P-matrix index, there is no way to get it back
int VRMLOutPMatricesAsArrows_(std::ostream &vrml, const BIAS::RGBAuc &Color)
this is an optimized strategy to avoid hundred of shape nodes
unsigned int NextPointIndex_
counter for the next index, gaps (due to delete) are not reused by now
Vector3< T > & Normalize()
normalize this vector to length 1
int PadToPowerOfTwo(BIAS::ImageBase &dest, const int &padVal=0) const
increase the size of this image to next power of two (e.g.
Vector3< double > GetCenterOfPoints()
get center of gravity (mean of structure)
int VRMLOutPMatrices(std::ostream &vrml, const BIAS::RGBAuc &Color)
only write (previously stored) cameras into an open vrml file, override their individual colors with ...
unsigned int NextCamEllipsoidIndex_
counter for the next ellipsoid index, gaps are not reused by now
void GetTexture(Image< unsigned char > &img) const
int VRMLOutPoints(std::ostream &vrml, const BIAS::RGBAuc &Color)
only write (previously stored) points into an open vrml file, override their individual colors with C...
int VRMLOutWriteHeader(std::ostream &vrml)
write the VRML 2.0 header into an open file
GLfloat * TextureCoordArray
double NormL2() const
the L2 norm sqrt(a^2 + b^2 + c^2)
BIAS::Vector3< double > C
camera center in wcs
Draw text to OpenGL as 2D bitmap font.
BIAS::Vector3< double > LR
lower right corner of image plane in wcs
BIAS::Quaternion< double > Direction
std::map< unsigned int, Ellipsoid3DData > mapEllipsoids_
map of all ellipsoid structures
int GetK(KMatrix &K)
calibration matrix
unsigned int AddText(const std::string &thetext, const BIAS::Vector3< double > &position, const BIAS::Quaternion< double > &direction=BIAS::Quaternion< double >(0.0, 0.0, 0.0, 0.0), const double &thesize=-12.0, const BIAS::RGBAuc &Color=RGBAuc_WHITE_OPAQUE)
const StorageType ** GetImageDataArray() const
overloaded GetImageDataArray() from ImageBase
A homogeneous plane (in P^3) All points X on the plane p fulfill p ' * X = 0.