diff --git a/src/Frame.cpp b/src/Frame.cpp index de4c25a414beda97115f9f3eb6ae4d4e0eb52cf3..8d75c2a72a3a65877a03df2d06a3c1d7f8718057 100644 --- a/src/Frame.cpp +++ b/src/Frame.cpp @@ -344,7 +344,7 @@ void Frame::ComputePolyData3D() //double max_height=350; - pos[2]+=height_i/2.0; // slightly above ground + pos[2]+=height_i/2.0 - 30; // slightly above ground rad[0]/=20; rad[0]=1; rad[2]/=20; @@ -365,7 +365,7 @@ void Frame::ComputePolyData3D() //rotation matrix around x-axis - double roX[3][3] = {{1, 0, 0}, + double roX[3][3] = {{1, 0, 0}, {0, cos(rot[0]),-sin(rot[0])}, {0, sin(rot[0]), cos(rot[0])} }; diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index dbca30e1555c077a43676da67e4f02f18fd6d673..e0e97fc0fe5db21d18e464cbe3f661b12983e3a5 100755 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -344,7 +344,7 @@ void MainWindow::slotStartPlaying() //visualisationThread->moveToThread(QApplication::instance()->thread()); visualisationThread->run(); }); -#elif +#else visualisationThread->start(); #endif @@ -355,7 +355,7 @@ void MainWindow::slotStartPlaying() dispatch_async(main_q, ^(void){ dataTransferThread->run(); }); -#elif +#else dataTransferThread->start(); #endif diff --git a/src/SaxParser.cpp b/src/SaxParser.cpp index 83983cfce6180bd28694d3fd9d4d5a212c9a7385..9b3631cf4fc7e91942b4aba0e0c01ca4abe205d4 100644 --- a/src/SaxParser.cpp +++ b/src/SaxParser.cpp @@ -542,7 +542,7 @@ bool SaxParser::endElement(const QString & /* namespaceURI */, _currentFrame.clear(); } else if (qName == "agent") { - } else if (qName == "geometr dataset->addFrame(frame);y") { + } else if (qName == "geometry") { } else if (qName == "point") { } else if (qName == "shape") { _dataset->setInitialHeights(_initialPedestriansHeights); @@ -737,7 +737,6 @@ bool SaxParser::parseGeometryJPS(QString fileName, FacilityGeometry *geometry) //TODO:dirty hack for parsing the Hlines // free memory delete building; - return true; } diff --git a/src/ThreadVisualisation.cpp b/src/ThreadVisualisation.cpp index 129bff8a2e8cf53d3b324c4469af57820f7a73f1..6aa9e2ee214392359381768c0381a17da19e465f 100644 --- a/src/ThreadVisualisation.cpp +++ b/src/ThreadVisualisation.cpp @@ -90,28 +90,11 @@ #include "geometry/PointPlotter.h" #include "Debug.h" -#ifndef __APPLE__ -#include <thread> -#include <dispatch/dispatch.h> -#include "fix/osx_thread_fix.h" - -std::thread::id main_thread_id = std::this_thread::get_id(); -dispatch_queue_t main_q = dispatch_get_main_queue(); - -void is_main_thread() { - if ( main_thread_id == std::this_thread::get_id() ) - std::cout << "This is the main thread.\n"; - else - std::cout << "This is not the main thread.\n"; -} - -#endif #define VTK_CREATE(type, name) \ vtkSmartPointer<type> name = vtkSmartPointer<type>::New() - ThreadVisualisation::ThreadVisualisation(QObject *parent): QThread(parent) { @@ -158,7 +141,7 @@ void ThreadVisualisation::run() { //deactivate the output windows - //vtkObject::GlobalWarningDisplayOff(); + vtkObject::GlobalWarningDisplayOff(); //emit signalStatusMessage("running"); @@ -371,7 +354,7 @@ void ThreadVisualisation::run() setNavLinesColor(SystemSettings::getNavLinesColor()); - + renderWinInteractor->Start(); #ifdef __APPLE__ @@ -380,7 +363,7 @@ void ThreadVisualisation::run() //dispatch_async(main_q, ^(void){ // is_main_thread(); //Unfortunately not // std::cout << "now spinning the visualizer" << std::endl; - renderWinInteractor->Start(); +// renderWinInteractor->Start(); //}); //[[NSThread new] start]; @@ -392,17 +375,19 @@ void ThreadVisualisation::run() emit signal_controlSequences("CONTROL_RESET"); +// still debugging. TODO, check the source of the leak while using cocoa +#ifndef __APPLE__ //clear some stuffs //delete extern_trail_plotter; - //finalize(); - - //renderer->Delete(); - //renderWindow->Delete(); - //renderWinInteractor->Delete(); - //_topViewCamera->Delete(); - //renderer=NULL; + finalize(); - //delete renderingTimer; + renderer->Delete(); + renderWindow->Delete(); + renderWinInteractor->Delete(); + _topViewCamera->Delete(); + renderer=NULL; + delete renderingTimer; +#endif } @@ -607,7 +592,18 @@ void ThreadVisualisation::initGlyphs3D() agentShape->SetInputConnection(tris->GetOutputPort()); */ - extern_glyphs_pedestrians_3D->SetSourceConnection(agentShape->GetOutputPort()); + //speed the rendering using triangles stripers + //vtkTriangleFilter *tris = vtkTriangleFilter::New(); + VTK_CREATE(vtkTriangleFilter, tris); + tris->SetInputConnection(agentShape->GetOutputPort()); + //tris->GetOutput()->ReleaseData(); + + //vtkStripper *strip = vtkStripper::New(); + VTK_CREATE(vtkStripper, strip); + strip->SetInputConnection(tris->GetOutputPort()); + //strip->GetOutput()->ReleaseData(); + + extern_glyphs_pedestrians_3D->SetSourceConnection(strip->GetOutputPort()); //first frame Frame * frame = extern_trajectories_firstSet.GetFrames().begin()->second; @@ -615,10 +611,10 @@ void ThreadVisualisation::initGlyphs3D() if(frame) pData=frame->GetPolyData2D(); #if VTK_MAJOR_VERSION <= 5 - extern_glyphs_pedestrians_3D->SetSource(agentShape->GetOutput()); + extern_glyphs_pedestrians_3D->SetSource(strip->GetOutput()); if (frame )extern_glyphs_pedestrians_3D->SetInput(pData); #else - extern_glyphs_pedestrians_3D->SetInputConnection(agentShape->GetOutputPort()); + extern_glyphs_pedestrians_3D->SetInputConnection(strip->GetOutputPort()); if (frame )extern_glyphs_pedestrians_3D->SetInputData(pData); #endif @@ -639,22 +635,21 @@ void ThreadVisualisation::initGlyphs3D() mapper->SetLookupTable(lut); extern_glyphs_pedestrians_actor_3D->SetMapper(mapper); - //extern_glyphs_pedestrians_actor_3D->GetProperty()->BackfaceCullingOn(); + extern_glyphs_pedestrians_actor_3D->GetProperty()->BackfaceCullingOn(); //if(extern_trajectories_firstSet.getNumberOfAgents()>0) renderer->AddActor(extern_glyphs_pedestrians_actor_3D); extern_glyphs_pedestrians_actor_3D->SetVisibility(false); } -void ThreadVisualisation::init() {} - +void ThreadVisualisation::init() +{ +} void ThreadVisualisation::finalize() { } - - void ThreadVisualisation::QcolorToDouble(const QColor &col, double *rgb) { rgb[0]=(double)col.red()/255.0; @@ -664,7 +659,6 @@ void ThreadVisualisation::QcolorToDouble(const QColor &col, double *rgb) void ThreadVisualisation::initLegend(/*std::vector scalars*/) { - //lookup table vtkLookupTable* lut = vtkLookupTable::New(); lut->SetHueRange(0.0,0.566); diff --git a/src/TimerCallback.cpp b/src/TimerCallback.cpp index 803d5f39a6b187dd3cfec82c26db622d6f17f0ab..48b0916adcad4998dec5c2dd9339327ff3b0f346 100644 --- a/src/TimerCallback.cpp +++ b/src/TimerCallback.cpp @@ -445,7 +445,7 @@ void TimerCallback::takeScreenshot(vtkRenderWindow *renderWindow) static int imageID=0; vtkWindowToImageFilter * winToImFilter = vtkWindowToImageFilter::New(); winToImFilter->SetInput( renderWindow ); - //winToImFilter->SetMagnification(4); + winToImFilter->SetMagnification(4); //renderWindow->Delete(); //vtkPostScriptWriter * image = vtkPostScriptWriter::New(); vtkPNGWriter * image = vtkPNGWriter::New(); diff --git a/src/main.cpp b/src/main.cpp index 85aea743626c40aced70a942f855507e8e7dec8a..793a8fb8e434b8fd70f9b5f29ddc504353e7ca9b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -65,7 +65,9 @@ int main(int argc, char *argv[]) { +#ifdef __APPLE__ InitMultiThreading(); +#endif QApplication a(argc, argv); // To ensure that decimal numbers use a "point" instead of "colon" on some systems