diff --git a/src/Frame.cpp b/src/Frame.cpp index d98756b4834799baef205e61fba7bf838ce4355c..8003b00b045aff86eae06b652ed08a05a171e011 100644 --- a/src/Frame.cpp +++ b/src/Frame.cpp @@ -63,8 +63,8 @@ Frame::~Frame() } _framePoints.clear(); - //_polydata2D->Delete(); - //_polydata3D->Delete(); + _polydata2D->Delete(); + _polydata3D->Delete(); } int Frame::getSize() diff --git a/src/SaxParser.cpp b/src/SaxParser.cpp index df18dfd26b6aa892ae8baf070f30cbd74fe08194..2fdc72ac7aad5abbfbe315ce88a978332f9bb5a5 100644 --- a/src/SaxParser.cpp +++ b/src/SaxParser.cpp @@ -68,7 +68,8 @@ using namespace std; -OutputHandler* Log; +OutputHandler* Log=NULL; + /** * constructor @@ -558,11 +559,8 @@ void SaxParser::clearPoints() bool SaxParser::parseGeometryJPS(QString fileName, FacilityGeometry *geometry) { - //if(Log) - //{ - delete Log; + // if(Log) delete Log; Log = new FileHandler(SystemSettings::getLogfile().toStdString().c_str()); - //} double captionsColor=0;//red if(!fileName.endsWith(".xml",Qt::CaseInsensitive)) return false; diff --git a/src/ThreadVisualisation.cpp b/src/ThreadVisualisation.cpp index 78cb73d9f9ff2df6e95909f4c5b1f6c3c8382589..c72f596f674e439b7d32ebaba7de576c8f63036b 100644 --- a/src/ThreadVisualisation.cpp +++ b/src/ThreadVisualisation.cpp @@ -123,6 +123,7 @@ ThreadVisualisation::~ThreadVisualisation() if(extern_glyphs_pedestrians) extern_glyphs_pedestrians->Delete(); if(extern_glyphs_pedestrians_actor_2D) extern_glyphs_pedestrians_actor_2D->Delete(); if(extern_pedestrians_labels) extern_pedestrians_labels->Delete(); + } void ThreadVisualisation::setFullsreen(bool status) @@ -140,7 +141,7 @@ void ThreadVisualisation::run() { //deactivate the output windows - //vtkObject::GlobalWarningDisplayOff(); + vtkObject::GlobalWarningDisplayOff(); //emit signalStatusMessage("running"); @@ -189,6 +190,7 @@ void ThreadVisualisation::run() actor->SetMapper(mapper); mapper->Delete(); actor->GetProperty()->SetColor(.90,.90,0.0); + actor->Delete(); //renderer->AddActor(actor); } //add another big circle at null point @@ -207,6 +209,7 @@ void ThreadVisualisation::run() mapper->Delete(); actor->GetProperty()->SetColor(.90,.90,0.0); actor->SetPosition(5000,8000,0); + actor->Delete(); //renderer->AddActor(actor); } @@ -366,7 +369,11 @@ void ThreadVisualisation::run() renderWindow->Delete(); renderWinInteractor->Delete(); _topViewCamera->Delete(); + runningTime->Delete(); renderer=NULL; + + delete renderingTimer; + } @@ -467,11 +474,13 @@ void ThreadVisualisation::initGlyphs2D() // } //speed the rendering using triangles stripers - vtkTriangleFilter *tris = vtkTriangleFilter::New(); + //vtkTriangleFilter *tris = vtkTriangleFilter::New(); + VTK_CREATE(vtkTriangleFilter, tris); tris->SetInputConnection(agentShape->GetOutputPort()); //tris->GetOutput()->ReleaseData(); - vtkStripper *strip = vtkStripper::New(); + //vtkStripper *strip = vtkStripper::New(); + VTK_CREATE(vtkStripper, strip); strip->SetInputConnection(tris->GetOutputPort()); //strip->GetOutput()->ReleaseData(); @@ -736,6 +745,8 @@ void ThreadVisualisation::setGeometry(FacilityGeometry* geometry) FacilityGeometry* ThreadVisualisation::getGeometry() { //if(geometry==NULL){ + //delete the old object + delete geometry; geometry=new FacilityGeometry(); //} return geometry; diff --git a/src/geometry/FacilityGeometry.cpp b/src/geometry/FacilityGeometry.cpp index f62a37b64a5aa5d2919c4d8f794dad045ac848eb..543c98e8d7bb9be0afd41e9fe626ebb4d2d1c964 100644 --- a/src/geometry/FacilityGeometry.cpp +++ b/src/geometry/FacilityGeometry.cpp @@ -108,10 +108,20 @@ FacilityGeometry::FacilityGeometry() FacilityGeometry::~FacilityGeometry() { - if(assembly) - assembly->Delete(); + //if(assembly) + // assembly->Delete(); lookupTable->Delete(); + captions->Delete(); + + assembly->Delete(); + assembly2D->Delete(); + assemblyCaptions->Delete(); + + assemblyWalls3D->Delete(); + assemblyDoors3D->Delete(); + assembly3D->Delete(); + floorActor->Delete(); delete linesPlotter2D; } @@ -285,15 +295,15 @@ void FacilityGeometry::addWall(double x1, double y1, double z1, double x2, doubl JPoint *p1 = new JPoint(x1,y1,z1); JPoint *p2 = new JPoint(x2,y2,z2); - double *center = p1->centreCoordinatesWith(*p2); + JPoint p3 =p1->centreCoordinatesWith(*p2); + double centre[3]; p3.getXYZ(centre); double angle =p1->angleMadeWith(*p2); double length =p1->distanceTo(*p2)+wallThickness; - addNewElement(center, length, angle, WALL); + addNewElement(centre, length, angle, WALL); delete p1; delete p2; - delete center; } void FacilityGeometry::addStair(double x1, double y1, double z1, double x2, double y2, double z2,double thickness,double height,double color) @@ -335,15 +345,16 @@ void FacilityGeometry::addDoor(double x1, double y1, double z1, double x2, doubl JPoint *p1 = new JPoint(x1,y1,z1); JPoint *p2 = new JPoint(x2,y2,z2); - double *center = p1->centreCoordinatesWith(*p2); + JPoint p3 =p1->centreCoordinatesWith(*p2); + double centre[3]; p3.getXYZ(centre); double angle =p1->angleMadeWith(*p2); double length =p1->distanceTo(*p2)+wallThickness; - addNewElement(center, length, angle, DOOR); + addNewElement(centre, length, angle, DOOR); delete p1; delete p2; - delete center; + } void FacilityGeometry::addNavLine(double x1, double y1, double z1, double x2, double y2, double z2,double thickness ,double height, double color) @@ -379,15 +390,16 @@ void FacilityGeometry::addStep(double x1, double y1, double z1, double x2, doubl JPoint *p1 = new JPoint(x1,y1,z1); JPoint *p2 = new JPoint(x2,y2,z2); - double *center = p1->centreCoordinatesWith(*p2); + JPoint p3 =p1->centreCoordinatesWith(*p2); + double centre[3]; p3.getXYZ(centre); double angle =p1->angleMadeWith(*p2); double length =p1->distanceTo(*p2)+wallThickness; - addNewElement(center, length, angle, STEP); + addNewElement(centre, length, angle, STEP); delete p1; delete p2; - delete center; + } void FacilityGeometry::addStep(JPoint* p1, JPoint* p2) @@ -406,10 +418,11 @@ void FacilityGeometry::addStep(JPoint* p1, JPoint* p2) linesPlotter2D->PlotDoor(m,n,doorColor/255.0); - double *center = p1->centreCoordinatesWith(*p2); + JPoint p3 =p1->centreCoordinatesWith(*p2); + double centre[3]; p3.getXYZ(centre); double angle =p1->angleMadeWith(*p2); double length =p1->distanceTo(*p2)+wallThickness; - addNewElement( center, length, angle, STEP); + addNewElement(centre, length, angle, STEP); } @@ -437,10 +450,11 @@ void FacilityGeometry::addWall(JPoint* p1, JPoint* p2, string caption) addNewElementText(center,orientation,caption.c_str(),50); } - double *center = p1->centreCoordinatesWith(*p2); + JPoint p3 =p1->centreCoordinatesWith(*p2); + double centre[3]; p3.getXYZ(centre); double angle =p1->angleMadeWith(*p2); double length =p1->distanceTo(*p2)+wallThickness; - addNewElement( center, length, angle, WALL); + addNewElement( centre, length, angle, WALL); } void FacilityGeometry::addStair(JPoint* p1, JPoint* p2, string caption) @@ -503,10 +517,11 @@ void FacilityGeometry::addDoor(JPoint* p1, JPoint* p2, string caption) addNewElementText(center,orientation,caption.c_str(),0); } - double *center = p1->centreCoordinatesWith(*p2); + JPoint p3 =p1->centreCoordinatesWith(*p2); + double centre[3]; p3.getXYZ(centre); double angle =p1->angleMadeWith(*p2); double length =p1->distanceTo(*p2)+wallThickness; - addNewElement( center, length, angle, DOOR); + addNewElement( centre, length, angle, DOOR); } void FacilityGeometry::addNavLine(JPoint* p1, JPoint* p2, string caption) @@ -832,7 +847,7 @@ void FacilityGeometry::addNewElementText(double center[3], double orientation[3] //caption VTK_CREATE(vtkTextActor3D,caption); - caption = vtkTextActor3D ::New(); + //caption = vtkTextActor3D ::New(); //caption->SetVisibility(false); caption->SetInput(text.c_str()); diff --git a/src/geometry/JPoint.cpp b/src/geometry/JPoint.cpp index f892dc549a72ca097a66dbf99e58d354bc1cc7d7..484f4fb9b965850c10fab8466b2b7c9cdcf9ef72 100644 --- a/src/geometry/JPoint.cpp +++ b/src/geometry/JPoint.cpp @@ -93,15 +93,15 @@ void JPoint::getXYZ(double*xyz) /* * return the coordinates */ -double JPoint::getX() +double JPoint::getX() const { return x; } -double JPoint::getY() +double JPoint::getY() const { return y; } -double JPoint::getZ() +double JPoint::getZ() const { return z; } @@ -111,7 +111,7 @@ double JPoint::getZ() * @return the angle in degree * FIXME: why +90?? */ -double JPoint::angleMadeWith(JPoint& pt) +double JPoint::angleMadeWith(JPoint& pt) const { double dx=x-pt.x; double dy=y-pt.y; @@ -128,7 +128,7 @@ double JPoint::angleMadeWith(JPoint& pt) return vtkMath::DegreesFromRadians(atan2(dy,dx))+90 ; } -double JPoint::distanceTo(JPoint& pt) +double JPoint::distanceTo(JPoint& pt) const { double dx=x-pt.x; dx*=dx; @@ -139,24 +139,27 @@ double JPoint::distanceTo(JPoint& pt) return sqrt(dx+dy+dz); } -double * JPoint::centreCoordinatesWith(JPoint &pt) + +JPoint JPoint::centreCoordinatesWith(JPoint &pt) const { - double *res= new double[3]; - res[0]=(x+pt.getX())/2; - res[1]=(y+pt.getY())/2; - res[2]=(z+pt.getZ())/2; - return res; + + //centre[0]=(x+pt.getX())/2; + //centre[1]=(y+pt.getY())/2; + //centre[2]=(z+pt.getZ())/2; + return (*this +pt)*0.5; } double JPoint::distanceBetween(JPoint& pt1, JPoint& pt2) { return pt1.distanceTo(pt2); } + double JPoint::angleMadeBetween(JPoint& pt1, JPoint& pt2) { return pt1.angleMadeWith(pt2); } -double *JPoint::centreCoordinatesBetween(JPoint& pt1, JPoint& pt2) + +JPoint JPoint::centreCoordinatesBetween(JPoint& pt1, JPoint& pt2) { return pt1.centreCoordinatesWith(pt2); } @@ -191,3 +194,36 @@ void JPoint::getColorHeightThicknes(double *CHT) CHT[1]=height; CHT[2]=thickness; } + +// sum +const JPoint JPoint::operator+(const JPoint& p) const +{ + //return Point(_x + p.GetX(), _y + p.GetY()); + return JPoint(x + p.x, y + p.y, z+p.z); +} + +// sub +const JPoint JPoint::operator-(const JPoint& p) const +{ + // return Point(_x - p.GetX(), _y - p.GetY()); + return JPoint(x - p.x, y - p.y, z-p.z); +} + + +// multiplication with scalar +JPoint operator*(const JPoint& p, double f) +{ + return JPoint(p.getX() * f, p.getY() * f, p.getZ() * f); +} + +// divition with scalar +JPoint operator/(const JPoint& p, double f) +{ +// if (f>J_EPS*J_EPS) +// return JPoint(p._x / f, p._y / f); +// else { +// std::cout << "Warning: Point::/operator. dividand "<<f<< " is to small. Set it to 1 instead"<<std::endl; +// return JPoint(p._x, p._y); +// } + return JPoint(p.getX() / f, p.getY() / f, p.getZ()/f); +} diff --git a/src/geometry/JPoint.h b/src/geometry/JPoint.h index 64c558a6509c65bba92f3d49369710e56e631765..5caa19c9f01dfd7a6dfbf243a38e0e59753d6008 100644 --- a/src/geometry/JPoint.h +++ b/src/geometry/JPoint.h @@ -47,16 +47,16 @@ public: JPoint(double xyz[3], const char* col="abc"); virtual ~JPoint(); - double getX(); - double getY(); - double getZ(); - double distanceTo(JPoint& pt); - double angleMadeWith(JPoint &pt); - double* centreCoordinatesWith(JPoint &pt); + double getX() const; + double getY()const; + double getZ()const; + double distanceTo(JPoint& pt)const; + double angleMadeWith(JPoint &pt)const; + JPoint centreCoordinatesWith(JPoint &pt) const; static double distanceBetween(JPoint& pt1, JPoint& pt2); static double angleMadeBetween(JPoint& pt1, JPoint& pt2); - static double *centreCoordinatesBetween(JPoint& pt1, JPoint& pt2); + static JPoint centreCoordinatesBetween(JPoint& pt1, JPoint& pt2); void setColorRGB(unsigned char r, unsigned char g, unsigned char b); void getColorRGB(unsigned char *rgb); @@ -72,6 +72,18 @@ public: //this is the end point of a door/wall for instance void setColorHeightThicknes(double CHT[3]); void getColorHeightThicknes(double *CHT); + + // operators + /// addition + const JPoint operator+(const JPoint& p) const; + /// substraction + const JPoint operator-(const JPoint& p) const; + }; +/// multiplication +JPoint operator*(const JPoint& p, const double f); +/// division +JPoint operator/(const JPoint& p, const double f); + #endif /* POINT_H_ */ diff --git a/src/geometry/LinePlotter2D.cpp b/src/geometry/LinePlotter2D.cpp index c7cc41924180fa704c4850bb05b44d2b91a6d137..6db4b9facb66cf256a214ca32d0317a3f88034b5 100644 --- a/src/geometry/LinePlotter2D.cpp +++ b/src/geometry/LinePlotter2D.cpp @@ -100,7 +100,6 @@ LinePlotter2D::LinePlotter2D() LinePlotter2D::~LinePlotter2D() { - m_lookupTable->Delete(); assembly->Delete(); door_points->Delete(); @@ -113,6 +112,11 @@ LinePlotter2D::~LinePlotter2D() wall_lineScalars->Delete(); wall_mapper->Delete(); wall_actor->Delete(); + navline_points->Delete(); + navline_lines->Delete(); + navline_lineScalars->Delete(); + navline_mapper->Delete(); + navline_actor->Delete(); } void LinePlotter2D::SetAllLineWidth(int width)