refactor addSource and prepare for goals

parent acb77351
......@@ -173,7 +173,9 @@ bool SaxParser::startElement(const QString & /* namespaceURI */,
ymax=at.value(i).toDouble()*FAKTOR;
}
}
_geometry->addSource(xmin,ymin,xmax,ymax);
_geometry->addRectangle(xmin,ymin,xmax,ymax, 0, 120.0, 150.0);
//@todo: here z=0. What about sources in the 2 floor?
// double CHT[3]= {_color,_height,_thickness};
// JPoint* pt1= new JPoint(xmin,ymin,z);
......@@ -1145,8 +1147,8 @@ bool SaxParser::getSourcesTXT(QString &filename)
float ymin = xmltof(e->Attribute("y_min"), 0);
float ymax = xmltof(e->Attribute("y_max"), 0);
bool dont_add = (xmin==0) && (xmax==0) && (ymin==0) && (ymax==0);
if(! dont_add)
_geometry->addSource(xmin,ymin,xmax,ymax);
// if(! dont_add)
// _geometry->addSource(xmin,ymin,xmax,ymax);
}//for
}
return true;
......@@ -1184,6 +1186,39 @@ QString SaxParser::extractSourceFileTXT(QString &filename)
return extracted_source_name;
}
QString SaxParser::extractGoalFileTXT(QString &filename)
{
QString extracted_goal_name="";
QFile file(filename);
QString line;
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
QTextStream in(&file);
while (!in.atEnd()) {
//look for a line with
line = in.readLine();
// std::cout << " >> " << line.toStdString().c_str() << endl;
if(line.split(":").size()==2)
{
if(line.split(":")[0].contains("goals",Qt::CaseInsensitive))
{
extracted_goal_name = line.split(":")[1].simplified().remove(' ');
break;
}
}
}// while
} // if open
if(extracted_goal_name=="")
{
Debug::Warning("Could not extract goal file!");
}
else
Debug::Messages("Extracted goal from TXT file <%s>", extracted_goal_name.toStdString().c_str());
return extracted_goal_name;
}
QString SaxParser::extractGeometryFilenameTXT(QString &filename)
{
QString extracted_geo_name="";
......
......@@ -84,6 +84,7 @@ public:
static QString extractGeometryFilename(QString& filename);
static QString extractGeometryFilenameTXT(QString &filename);
static QString extractSourceFileTXT(QString &filename);
static QString extractGoalFileTXT(QString &filename);
/// parse the txt file format
static bool ParseTxtFormat(const QString& fileName, SyncData* dataset, double * fps);
......
......@@ -575,7 +575,7 @@ void FacilityGeometry::addObstacles(vtkPolyData* polygonPolyData )
void FacilityGeometry::addSource(double x1, double y1, double x2, double y2, double z)
void FacilityGeometry::addRectangle(double x1, double y1, double x2, double y2, double z, double color1, double color2)
{
//if(z!=1)return;
const double cellSize=40; //cm
......@@ -589,8 +589,9 @@ void FacilityGeometry::addSource(double x1, double y1, double x2, double y2, dou
//vtkDoubleArray *scalars = vtkDoubleArray::New();
vtkDataArray* pData = vtkUnsignedCharArray::New();
pData->SetNumberOfComponents(3);
std::cout << "---- " << color1 << " " << color2 << "\n" ;
double color[2][3]= {{120, 120, 120},{150,150,150}};
double color[2][3]= {{color1, color1, color1},{color2,color2,color2}};
bool idx=0;
bool lastColorUsed=0;
for(int i=0; i<dimY-1; i++) {
......
......@@ -104,7 +104,7 @@ public:
/// draw a floor, divided in cells,
void addFloor(double x1, double y1, double x2, double y2, double z=0);
void addSource(double x1, double y1, double x2, double y2, double z=0);
void addRectangle(double x1, double y1, double x2, double y2, double z=0, double c1=120, double c2=150);
void addFloor(vtkPolyData* polygonPolyData);
///draw obstacles
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment