[Jderobot-admin] jderobot-r939 - trunk/src/libs/geometry/collada
ahcorde en jderobot.org
ahcorde en jderobot.org
Jue Jul 11 14:48:25 CEST 2013
Author: ahcorde
Date: 2013-07-11 14:47:25 +0200 (Thu, 11 Jul 2013)
New Revision: 939
Modified:
trunk/src/libs/geometry/collada/colladaparser.cpp
trunk/src/libs/geometry/collada/colladaparser.h
Log:
[ahcorde]
Modified: trunk/src/libs/geometry/collada/colladaparser.cpp
===================================================================
--- trunk/src/libs/geometry/collada/colladaparser.cpp 2013-07-09 10:07:04 UTC (rev 938)
+++ trunk/src/libs/geometry/collada/colladaparser.cpp 2013-07-11 12:47:25 UTC (rev 939)
@@ -1,7 +1,7 @@
#include "colladaparser.h"
namespace files_3D {
- ColladaParser::ColladaParser(std::string filename, int scale)
+ ColladaParser::ColladaParser(std::string filename, bool to2D, double scalemap, double scale)
{
TiXmlDocument xmlDoc;
@@ -40,7 +40,13 @@
mesh->Scale(this->meter*scale);
- worldTo2D();
+ if(to2D){
+ mesh->Scale(scalemap);
+
+ worldTo2D();
+
+ mesh->Scale(1/scalemap);
+ }
}
int ite = 0;
@@ -1343,13 +1349,14 @@
void ColladaParser::worldTo2D()
{
+
std::vector<Segmento> listaSegmentos;
for(int i = 0; i < this->mesh->getSubMeshCount();i++){
SubMalla* submalla = this->mesh->getSubMesh(i);
- Plano plano1(0, 0, 1, -0.5);
+ Plano plano1(0, 0, 1, -10);
Plano plano2(0, 0, 1, 400.0);
Plano p_proyeccion(0, 0, 1, 0);
@@ -1438,19 +1445,28 @@
math::Vector3 max = mesh->getMax();
math::Vector3 min = mesh->getMin();
- image.create(max.getY() - min.getY(), max.getX() - min.getY(), CV_8UC3);
+ image.create((max.getY() - min.getY()),
+ (max.getX() - min.getY()),
+ CV_8UC3);
image = cv::Scalar(255, 255, 255);
+ FILE* fp;
+ fp = fopen("lineas.txt", "w");
+
for(int i = 0; i < listaSegmentos.size(); i++){
cv::line(image,
- cv::Point2f(listaSegmentos[i].x1 - min.getX(), listaSegmentos[i].y1 - min.getY()),
- cv::Point2f(listaSegmentos[i].x2 - min.getX(), listaSegmentos[i].y2 - min.getY()),
+ cv::Point2f((listaSegmentos[i].x1 - min.getX()), (listaSegmentos[i].y1 - min.getY())),
+ cv::Point2f((listaSegmentos[i].x2 - min.getX()), (listaSegmentos[i].y2 - min.getY())),
cv::Scalar(0, 0, 0),
3);
+ fprintf(fp, "%.2f %.2f %.2f %.2f\n", listaSegmentos[i].x1, listaSegmentos[i].y1,
+ listaSegmentos[i].x2, listaSegmentos[i].y2);
}
cv::imwrite("mapa.jpg", image);
+ fclose(fp);
+
}
cv::Mat ColladaParser::getWorld2D()
Modified: trunk/src/libs/geometry/collada/colladaparser.h
===================================================================
--- trunk/src/libs/geometry/collada/colladaparser.h 2013-07-09 10:07:04 UTC (rev 938)
+++ trunk/src/libs/geometry/collada/colladaparser.h 2013-07-11 12:47:25 UTC (rev 939)
@@ -29,7 +29,7 @@
class ColladaParser
{
public:
- ColladaParser(std::string filename, int scale=1);
+ ColladaParser(std::string filename, bool to2D=false, double scalemap=1, double scale=1);
void worldTo2D();
cv::Mat getWorld2D();
More information about the Jderobot-admin
mailing list