From c67bf086b43784c8fc79765a7a897a61e629bcee Mon Sep 17 00:00:00 2001
From: Ulrich Kemloh <kemlohulrich@gmail.com>
Date: Fri, 18 Jul 2014 19:06:24 +0200
Subject: [PATCH] Switching between 2D and 3d geo enabled

---
 src/MainWindow.cpp                |   1 +
 src/SaxParser.cpp                 |  10 +-
 src/ThreadVisualisation.cpp       |  38 ++-
 src/ThreadVisualisation.h         |   2 +
 src/TimerCallback.cpp             |   4 +-
 src/TimerCallback.h               |   2 +
 src/extern_var.h                  |  10 +-
 src/geometry/FacilityGeometry.cpp | 373 +++++++++++++++++++-----------
 src/geometry/FacilityGeometry.h   |  20 +-
 src/geometry/LinePlotter2D.cpp    |  29 ---
 10 files changed, 284 insertions(+), 205 deletions(-)

diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp
index 4575b2e..90efaf4 100644
--- a/src/MainWindow.cpp
+++ b/src/MainWindow.cpp
@@ -363,6 +363,7 @@ void MainWindow::slotStartPlaying() {
 
     //no matter what, the stop button should be enabled
     ui.BtStop->setEnabled(true);
+
 }
 
 void MainWindow::slotStopPlaying() {
diff --git a/src/SaxParser.cpp b/src/SaxParser.cpp
index e9748b8..e74dc1f 100644
--- a/src/SaxParser.cpp
+++ b/src/SaxParser.cpp
@@ -478,14 +478,6 @@ bool SaxParser::startElement(const QString & /* namespaceURI */,
         double ellipse[7]={el_x,el_y,el_z,dia_a,dia_b,el_angle,el_color};
         double para[2]={agent_color,el_angle};
 
-//        TrajectoryPoint * point = new TrajectoryPoint(id-1);
-//        point->setEllipse(ellipse);
-//        point->setPos(pos);
-//        point->setVel(vel);
-//        point->setAgentInfo(para);
-//        currentFrame.push_back(point);
-
-
         double pos[3]={xPos,yPos,zPos};
         double angle[3]={0,0,el_angle};
         double radius[3]={dia_a,dia_b,30.0};
@@ -697,7 +689,7 @@ void SaxParser::parseGeometryJPS(QString fileName, FacilityGeometry *geometry){
 	actor->GetProperty()->SetOpacity(0.5);
 	//actor->GetProperty()->SetLineWidth(5);
 
-	geometry->getActor()->AddPart(actor);
+    geometry->getActor2D()->AddPart(actor);
 
 	// free memory
 	delete building;
diff --git a/src/ThreadVisualisation.cpp b/src/ThreadVisualisation.cpp
index 0398c1a..d16a4a2 100644
--- a/src/ThreadVisualisation.cpp
+++ b/src/ThreadVisualisation.cpp
@@ -139,7 +139,7 @@ void ThreadVisualisation::slotSetFrameRate(float fps){
 void ThreadVisualisation::run(){
 
     //deactivate the output windows
-//    vtkObject::GlobalWarningDisplayOff();
+    vtkObject::GlobalWarningDisplayOff();
 
 	//emit signalStatusMessage("running");
 
@@ -148,11 +148,14 @@ void ThreadVisualisation::run(){
 	// set the background
 	//renderer->SetBackground(.00,.00,.00);
 	renderer->SetBackground(1.0,1.0,1.0);
-	//set the view port
-	//renderer->SetViewport(0,.5,1.0,1.0);
 	//add the geometry
-	renderer->AddActor(geometry->getActor());
+    renderer->AddActor(geometry->getActor2D());
+    renderer->AddActor(geometry->getActor3D());
 
+    if(SystemSettings::get2D()==true)
+    {
+        //Sh
+    }
 
 	//initialize the datasets
     //init();
@@ -340,6 +343,11 @@ void ThreadVisualisation::run(){
     //renderer->GetActiveCamera()->Modified();
     _topViewCamera->DeepCopy(renderer->GetActiveCamera());
 
+
+    //TODO: update all system settings
+    setGeometryVisibility2D(SystemSettings::get2D());
+    setGeometryVisibility3D(!SystemSettings::get2D());
+
     renderWinInteractor->Start();
 
 
@@ -443,11 +451,13 @@ void  ThreadVisualisation::initGlyphs2D()
     lut->Build();
     mapper->SetLookupTable(lut);
 
-    VTK_CREATE(vtkActor, actor);
-    actor->SetMapper(mapper);
-    actor->GetProperty()->BackfaceCullingOn();
-    //actor->Modified();
-    renderer->AddActor(actor);
+    extern_glyphs_pedestrians_actor_2D->SetMapper(mapper);
+    extern_glyphs_pedestrians_actor_2D->GetProperty()->BackfaceCullingOn();
+    renderer->AddActor(extern_glyphs_pedestrians_actor_2D);
+
+    //VTK_CREATE(vtkActor, actor);
+    //actor->SetMapper(mapper);
+    //renderer->AddActor(actor);
 
     // structure for the labels
     VTK_CREATE(vtkLabeledDataMapper, labelMapper);
@@ -516,9 +526,13 @@ void ThreadVisualisation::initGlyphs3D()
     lut->Build();
     mapper->SetLookupTable(lut);
 
-    VTK_CREATE(vtkActor, actor);
-    actor->SetMapper(mapper);
-    renderer->AddActor(actor);
+    extern_glyphs_pedestrians_actor_3D->SetMapper(mapper);
+    extern_glyphs_pedestrians_actor_3D->GetProperty()->BackfaceCullingOn();
+    renderer->AddActor(extern_glyphs_pedestrians_actor_3D);
+
+//    VTK_CREATE(vtkActor, actor);
+//    actor->SetMapper(mapper);
+//    renderer->AddActor(actor);
 }
 
 void  ThreadVisualisation::init(){
diff --git a/src/ThreadVisualisation.h b/src/ThreadVisualisation.h
index a2d7201..ffc4387 100644
--- a/src/ThreadVisualisation.h
+++ b/src/ThreadVisualisation.h
@@ -67,6 +67,8 @@ extern Pedestrian** extern_pedestrians_thirdSet;
 //extern vtkSmartPointer<vtkGlyph3D> extern_glyphs_pedestrians;
 extern vtkSmartPointer<vtkTensorGlyph> extern_glyphs_pedestrians;
 extern vtkSmartPointer<vtkTensorGlyph> extern_glyphs_pedestrians_3D;
+extern vtkSmartPointer<vtkActor> extern_glyphs_pedestrians_actor_2D;
+extern vtkSmartPointer<vtkActor> extern_glyphs_pedestrians_actor_3D;
 
 extern SyncData extern_trajectories_firstSet;
 extern SyncData extern_trajectories_secondSet;
diff --git a/src/TimerCallback.cpp b/src/TimerCallback.cpp
index 108f837..dd52dd9 100644
--- a/src/TimerCallback.cpp
+++ b/src/TimerCallback.cpp
@@ -128,7 +128,7 @@ void TimerCallback::Execute(vtkObject *caller, unsigned long eventId,
             if (iren && renderWindow && renderer)
             {
                 // very important
-                setAllPedestriansInvisible();
+                //setAllPedestriansInvisible();
 
                 //first pedestrian group
                 if(extern_first_dataset_loaded) {
@@ -324,6 +324,8 @@ void TimerCallback::updateSettings(vtkRenderWindow* renderWindow) {
     if(autoCaptionMode==false){ // tODO set the colour to auto mode
 
     }
+    extern_glyphs_pedestrians_actor_2D->SetVisibility(SystemSettings::get2D());
+    extern_glyphs_pedestrians_actor_3D->SetVisibility(!SystemSettings::get2D());
 
     if(extern_first_dataset_loaded){
         int pedColor[3];
diff --git a/src/TimerCallback.h b/src/TimerCallback.h
index f1e76f7..b732ba7 100644
--- a/src/TimerCallback.h
+++ b/src/TimerCallback.h
@@ -84,6 +84,8 @@ extern Pedestrian** extern_pedestrians_thirdSet;
 extern vtkSmartPointer<vtkActor2D> extern_pedestrians_labels;
 extern vtkSmartPointer<vtkTensorGlyph> extern_glyphs_pedestrians;
 extern vtkSmartPointer<vtkTensorGlyph> extern_glyphs_pedestrians_3D;
+extern vtkSmartPointer<vtkActor> extern_glyphs_pedestrians_actor_2D;
+extern vtkSmartPointer<vtkActor> extern_glyphs_pedestrians_actor_3D;
 
 
 extern SyncData extern_trajectories_firstSet;
diff --git a/src/extern_var.h b/src/extern_var.h
index 172bbd3..d216191 100644
--- a/src/extern_var.h
+++ b/src/extern_var.h
@@ -30,15 +30,20 @@
 #ifndef EXTERN_VAR_H_
 #define EXTERN_VAR_H_ 1
 
+#define vtkRenderingCore_AUTOINIT 4(vtkInteractionStyle,vtkRenderingFreeType,vtkRenderingFreeTypeOpenGL,vtkRenderingOpenGL)
+#define vtkRenderingVolume_AUTOINIT 1(vtkRenderingVolumeOpenGL)
+
 #include "SyncData.h"
 #include "Pedestrian.h"
 
 #include <vtkActor2D.h>
+#include <vtkActor.h>
 #include <vtkTensorGlyph.h>
 #include <vtkSmartPointer.h>
 #include <vtkPolyDataMapper.h>
 
 
+
 #define VTK_CREATE(type, name) \
 		vtkSmartPointer<type> name = vtkSmartPointer<type>::New()
 
@@ -82,11 +87,12 @@ Pedestrian** extern_pedestrians_thirdSet=NULL;
 
 
 VTK_CREATE (vtkTensorGlyph, extern_glyphs_pedestrians);
-
 VTK_CREATE (vtkTensorGlyph, extern_glyphs_pedestrians_3D);
-
 VTK_CREATE (vtkActor2D, extern_pedestrians_labels);
 
+VTK_CREATE (vtkActor, extern_glyphs_pedestrians_actor_2D);
+VTK_CREATE (vtkActor, extern_glyphs_pedestrians_actor_3D);
+
 
 // and here the corresponding dataset
 ///The first dataset
diff --git a/src/geometry/FacilityGeometry.cpp b/src/geometry/FacilityGeometry.cpp
index 6a1f8be..ce86efc 100644
--- a/src/geometry/FacilityGeometry.cpp
+++ b/src/geometry/FacilityGeometry.cpp
@@ -73,8 +73,11 @@ FacilityGeometry::FacilityGeometry() {
 	assembly2D = vtkAssembly::New();
 	assemblyCaptions= vtkAssembly::New();
 
-	captions=vtkActor2DCollection::New();
+    assemblyWalls3D = vtkAssembly::New();
+    assemblyDoors3D = vtkAssembly::New();
+    assembly3D = vtkAssembly::New();
 
+	captions=vtkActor2DCollection::New();
 	linesPlotter2D = new LinePlotter2D();
 
 	// initializing the lookup table for the colors
@@ -112,7 +115,7 @@ FacilityGeometry::~FacilityGeometry() {
 // each time this is called, the assemblies parts are added
 // very bad
 
-vtkAssembly* FacilityGeometry::getActor(){
+vtkAssembly* FacilityGeometry::getActor2D(){
 
 	assembly2D->AddPart(linesPlotter2D->createAssembly());
 	assembly2D->AddPart(assemblyCaptions);
@@ -120,6 +123,14 @@ vtkAssembly* FacilityGeometry::getActor(){
 	return assembly2D;
 }
 
+ vtkAssembly* FacilityGeometry::getActor3D()
+ {
+     assembly3D->AddPart(assemblyDoors3D);
+     assembly3D->AddPart(assemblyWalls3D);
+//    assembly3D->AddPart(assemblyObjects);
+//     assembly3D->AddPart(assemblyCaptions);
+     return assembly3D;
+ }
 
 //void FacilityGeometry::drawWall(Point *p1, Point *p2){
 //	double scale =1;
@@ -178,81 +189,80 @@ vtkAssembly* FacilityGeometry::getActor(){
  * This is the main build method and should be called by all functions
  * drawing a wall or a door. Important
  */
-//void FacilityGeometry::addNewElement(double center[3], double length, double orientation, ELEMENT_TYPE type){
-//
-//	vtkCubeSource* src = vtkCubeSource::New();
-//	src->SetCenter(center[0],center[1],center[2]);
-//	src->SetYLength(length);
-//
-//	vtkPolyDataMapper* mapper = vtkPolyDataMapper::New();
-//	mapper->SetInputConnection(src->GetOutputPort());
-//	src->Delete();
-//
-//	vtkActor* actor = vtkActor::New();
-//	actor->SetMapper(mapper);
-//	mapper->Delete();
-//	actor->GetProperty()->SetLighting(true);
-//	actor->SetOrigin(center[0],center[1],center[2]);
-//	actor->RotateZ(orientation);
-//	actor->GetProperty()->SetAmbient(0.2);
-//	actor->GetProperty()->SetDiffuse(0.8);
-//
-//	// 	double data[3];
-//	// 	actor->GetPosition(data);
-//	// 	actor->SetPosition(data[0],data[1],src->GetZLength()/2);
-//
-//	switch (type)
-//	{
-//	case DOOR:
-//	{
-//		double colorRGB[3];
-//		lookupTable->GetColor(doorColor, colorRGB);
-//		actor->GetProperty()->SetColor(colorRGB);
-//		src->SetXLength(doorThickness);
-//		src->SetZLength(doorHeight);
-//		//src->SetRadius(doorWidth);
-//		actor->GetProperty()->SetOpacity(1.00);
-//		assemblyDoors3D->AddPart(actor);
-//	}
-//	break;
-//	case WALL:
-//	{
-//		double colorRGB[3];
-//		lookupTable->GetColor(wallColor, colorRGB);
-//		actor->GetProperty()->SetColor(colorRGB);
-//		//actor->GetProperty()->SetSpecular(1);
-//		//actor->GetProperty()->SetDiffuse(1);
-//		//actor->GetProperty()->SetAmbient(1);
-//
-//		src->SetXLength(wallThickness);
-//		src->SetZLength(wallHeight);
-//		//src->SetRadius(wallWidth);
-//		assemblyWalls3D->AddPart(actor);
-//	}
-//	break;
-//	case STEP:
-//	{
-//		double colorRGB[3];
-//		lookupTable->GetColor(stepColor, colorRGB);
-//		actor->GetProperty()->SetColor(colorRGB);
-//		src->SetXLength(wallThickness); //FIXME, this is wrong
-//		src->SetZLength(stepHeight);
-//		assemblyDoors3D->AddPart(actor);
-//	}
-//	break;
-//
-//	//default behaviour not defined
-//	default:
-//		break;
-//	}
-//
-//	// now adjusting the z coordinates
-//	double data[3];
-//	actor->GetPosition(data);
-//	actor->SetPosition(data[0],data[1],src->GetZLength()/2);
-//
-//	actor->Delete();
-//}
+void FacilityGeometry::addNewElement(double center[3], double length, double orientation, ELEMENT_TYPE type){
+
+    vtkCubeSource* src = vtkCubeSource::New();
+    src->SetCenter(center[0],center[1],center[2]);
+    src->SetYLength(length);
+
+    vtkPolyDataMapper* mapper = vtkPolyDataMapper::New();
+    mapper->SetInputConnection(src->GetOutputPort());
+    src->Delete();
+
+    vtkActor* actor = vtkActor::New();
+    actor->SetMapper(mapper);
+    mapper->Delete();
+    actor->GetProperty()->SetLighting(true);
+    actor->SetOrigin(center[0],center[1],center[2]);
+    actor->RotateZ(orientation);
+    actor->GetProperty()->SetAmbient(0.2);
+    actor->GetProperty()->SetDiffuse(0.8);
+
+    // 	double data[3];
+    // 	actor->GetPosition(data);
+    // 	actor->SetPosition(data[0],data[1],src->GetZLength()/2);
+
+    switch (type)
+    {
+    case DOOR:
+    {
+        double colorRGB[3];
+        lookupTable->GetColor(doorColor, colorRGB);
+        actor->GetProperty()->SetColor(colorRGB);
+        src->SetXLength(doorThickness);
+        src->SetZLength(doorHeight);
+        //src->SetRadius(doorWidth);
+        actor->GetProperty()->SetOpacity(1.00);
+        assemblyDoors3D->AddPart(actor);
+    }
+    break;
+    case WALL:
+    {
+        double colorRGB[3];
+        lookupTable->GetColor(wallColor, colorRGB);
+        actor->GetProperty()->SetColor(colorRGB);
+        //actor->GetProperty()->SetSpecular(1);
+        //actor->GetProperty()->SetDiffuse(1);
+        //actor->GetProperty()->SetAmbient(1);
+
+        src->SetXLength(wallThickness);
+        src->SetZLength(wallHeight);
+        //src->SetRadius(wallWidth);
+        assemblyWalls3D->AddPart(actor);
+    }
+    break;
+    case STEP:
+    {
+        double colorRGB[3];
+        lookupTable->GetColor(stepColor, colorRGB);
+        actor->GetProperty()->SetColor(colorRGB);
+        src->SetXLength(wallThickness); //FIXME, this is wrong
+        src->SetZLength(stepHeight);
+        assemblyDoors3D->AddPart(actor);
+    }
+    break;
+
+    //default behaviour not defined
+    default:
+        break;
+    }
+
+    // now adjusting the z coordinates
+    double data[3];
+    actor->GetPosition(data);
+    actor->SetPosition(data[0],data[1],src->GetZLength()/2);
+    actor->Delete();
+}
 
 void FacilityGeometry::addWall(double x1, double y1, double z1, double x2, double y2, double z2,double thickness,double height,double color){
 
@@ -263,6 +273,19 @@ void FacilityGeometry::addWall(double x1, double y1, double z1, double x2, doubl
 	double m[]={x1,y1,z1};
 	double n[]={x2,y2,z2};
 	linesPlotter2D->PlotWall(m,n,wallColor/255.0);
+
+
+    JPoint *p1 = new JPoint(x1,y1,z1);
+    JPoint *p2 = new JPoint(x2,y2,z2);
+    double *center = p1->centreCoordinatesWith(*p2);
+    double angle =p1->angleMadeWith(*p2);
+    double length =p1->distanceTo(*p2)+wallThickness;
+
+    addNewElement(center, length, angle, WALL);
+
+    delete p1;
+    delete p2;
+    delete center;
 }
 
 void FacilityGeometry::addDoor(double x1, double y1, double z1, double x2, double y2, double z2,double thickness ,double height, double color){
@@ -274,11 +297,19 @@ void FacilityGeometry::addDoor(double x1, double y1, double z1, double x2, doubl
 	double m[]={x1,y1,z1};
 	double n[]={x2,y2,z2};
 
-	//double m[]={x1,y1,z+1};
-	//double n[]={x2,y2,z+1};
-	//printf("[%f %f %f]---[%f %f %f]\n",x1,y1,z,x2,y2,z);
-
 	linesPlotter2D->PlotDoor(m,n,doorColor/255.0);
+
+    JPoint *p1 = new JPoint(x1,y1,z1);
+    JPoint *p2 = new JPoint(x2,y2,z2);
+    double *center = p1->centreCoordinatesWith(*p2);
+    double angle =p1->angleMadeWith(*p2);
+    double length =p1->distanceTo(*p2)+wallThickness;
+
+    addNewElement(center, length, angle, DOOR);
+
+    delete p1;
+    delete p2;
+    delete center;
 }
 
 void FacilityGeometry::addStep(double x1, double y1, double z1, double x2, double y2, double z2)
@@ -286,6 +317,18 @@ void FacilityGeometry::addStep(double x1, double y1, double z1, double x2, doubl
 	double m[]={x1,y1,z1};
 	double n[]={x2,y2,z2};
 	linesPlotter2D->PlotDoor(m,n,doorColor/255.0);
+
+    JPoint *p1 = new JPoint(x1,y1,z1);
+    JPoint *p2 = new JPoint(x2,y2,z2);
+    double *center = p1->centreCoordinatesWith(*p2);
+    double angle =p1->angleMadeWith(*p2);
+    double length =p1->distanceTo(*p2)+wallThickness;
+
+    addNewElement(center, length, angle, STEP);
+
+    delete p1;
+    delete p2;
+    delete center;
 }
 
 void FacilityGeometry::addStep(JPoint* p1, JPoint* p2){
@@ -303,32 +346,40 @@ void FacilityGeometry::addStep(JPoint* p1, JPoint* p2){
 
 	linesPlotter2D->PlotDoor(m,n,doorColor/255.0);
 
+    double *center = p1->centreCoordinatesWith(*p2);
+    double angle =p1->angleMadeWith(*p2);
+    double length =p1->distanceTo(*p2)+wallThickness;
+    addNewElement( center,  length, angle,  STEP);
+
 }
 
 void FacilityGeometry::addWall(JPoint* p1, JPoint* p2, string caption){
-	double m[3];
-	double n[3];
-	double CHT[3];
-	p1->getXYZ(m);
-	p2->getXYZ(n);
-	p1->getColorHeightThicknes(CHT);
-
-	wallThickness = CHT[2];
-	wallHeight=CHT[1];
-	wallColor = CHT[0];
-	linesPlotter2D->PlotWall(m,n,wallColor/255.0);
-
-
-	if (caption.compare("") != 0){
-
-		double center[3];
-		center[0]=0.5*(m[0]+n[0]);
-		center[1]=0.5*(m[1]+n[1]);
-		center[2]=0.5*(m[2]+n[2]);
-		double orientation[3]={0,0,0};
-		addNewElementText(center,orientation,caption.c_str(),50);
-	}
-
+    double m[3];
+    double n[3];
+    double CHT[3];
+    p1->getXYZ(m);
+    p2->getXYZ(n);
+    p1->getColorHeightThicknes(CHT);
+
+    wallThickness = CHT[2];
+    wallHeight=CHT[1];
+    wallColor = CHT[0];
+    linesPlotter2D->PlotWall(m,n,wallColor/255.0);
+
+    if (caption.compare("") != 0){
+
+        double center[3];
+        center[0]=0.5*(m[0]+n[0]);
+        center[1]=0.5*(m[1]+n[1]);
+        center[2]=0.5*(m[2]+n[2]);
+        double orientation[3]={0,0,0};
+        addNewElementText(center,orientation,caption.c_str(),50);
+    }
+
+    double *center = p1->centreCoordinatesWith(*p2);
+    double angle =p1->angleMadeWith(*p2);
+    double length =p1->distanceTo(*p2)+wallThickness;
+    addNewElement( center,  length, angle,  WALL);
 }
 
 void FacilityGeometry::addDoor(JPoint* p1, JPoint* p2, string caption){
@@ -350,8 +401,6 @@ void FacilityGeometry::addDoor(JPoint* p1, JPoint* p2, string caption){
 
 	linesPlotter2D->PlotDoor(m,n,doorColor/255.0);
 
-
-
 	if (caption.compare("") != 0){
 
 		double center[3];
@@ -362,6 +411,10 @@ void FacilityGeometry::addDoor(JPoint* p1, JPoint* p2, string caption){
 		addNewElementText(center,orientation,caption.c_str(),0);
 	}
 
+    double *center = p1->centreCoordinatesWith(*p2);
+    double angle =p1->angleMadeWith(*p2);
+    double length =p1->distanceTo(*p2)+wallThickness;
+    addNewElement( center,  length, angle,  DOOR);
 }
 
 
@@ -530,16 +583,38 @@ void FacilityGeometry::addObjectBox(double center[3], double height,
 	}
 }
 
-void FacilityGeometry::changeWallsColor(double* color){
-
-	linesPlotter2D->changeWallsColor(color);
-	assembly2D->Modified();
+void FacilityGeometry::changeWallsColor(double* color)
+{
+    //2D part
+    linesPlotter2D->changeWallsColor(color);
+    assembly2D->Modified();
+
+    //3D parts
+    vtkProp3DCollection* col=assemblyWalls3D->GetParts();
+    assemblyWalls3D->GetActors(col);
+
+    int count = col->GetNumberOfItems();
+    for (int i=0;i<count;i++){
+        ((vtkActor*)col->GetItemAsObject(i))->GetProperty()->SetColor(color);
+    }
+    assemblyWalls3D->Modified();
 }
 
-void FacilityGeometry::changeExitsColor(double* color){
+void FacilityGeometry::changeExitsColor(double* color)
+{
+    //2D part
+    linesPlotter2D->changeDoorsColor(color);
+    assembly2D->Modified();
+
+    //3D part
+    vtkProp3DCollection* col=assemblyDoors3D->GetParts();
+    assemblyDoors3D->GetActors(col);
 
-	linesPlotter2D->changeDoorsColor(color);
-	assembly2D->Modified();
+    int count = col->GetNumberOfItems();
+    for (int i=0;i<count;i++){
+        ((vtkActor*)col->GetItemAsObject(i))->GetProperty()->SetColor(color);
+    }
+    assemblyDoors3D->Modified();
 
 }
 
@@ -548,12 +623,23 @@ void FacilityGeometry::set2D(bool status){
 }
 
 void FacilityGeometry::set3D(bool status){
+    if(assembly3D!=NULL)
+            assembly3D->SetVisibility(status);
 }
 
 void FacilityGeometry::showDoors(bool status){
 
-	linesPlotter2D->showDoors(status);
-	assembly2D->Modified();
+    linesPlotter2D->showDoors(status);
+    assembly2D->Modified();
+
+    vtkProp3DCollection* col=assemblyDoors3D->GetParts();
+    assemblyDoors3D->GetActors(col);
+
+    int count = col->GetNumberOfItems();
+    for (int i=0;i<count;i++){
+        ((vtkActor*)col->GetItemAsObject(i))->SetVisibility(status);
+    }
+    assemblyDoors3D->Modified();
 }
 
 void FacilityGeometry::showStairs(bool status){
@@ -561,8 +647,17 @@ void FacilityGeometry::showStairs(bool status){
 }
 
 void FacilityGeometry::showWalls(bool status){
-	linesPlotter2D->showWalls(status);
-	assembly2D->Modified();
+    linesPlotter2D->showWalls(status);
+    assembly2D->Modified();
+
+    vtkProp3DCollection* col=assemblyWalls3D->GetParts();
+    assemblyWalls3D->GetActors(col);
+
+    int count = col->GetNumberOfItems();
+    for (int i=0;i<count;i++){
+        ((vtkActor*)col->GetItemAsObject(i))->SetVisibility(status);
+    }
+    assemblyWalls3D->Modified();
 }
 
 void FacilityGeometry::addObjectLabel(double center[3], double orientation[3], std::string caption, double color){
@@ -574,36 +669,32 @@ vtkActor2DCollection* FacilityGeometry::getCaptions(){
 }
 // orientation and color ignored
 void FacilityGeometry::addNewElementText(double center[3], double orientation[3],
-		string text, double color) {
+string text, double color) {
 
-	//return ;
+    //return ;
 
-		{//caption
-			VTK_CREATE(vtkTextActor3D,caption);
-			caption = vtkTextActor3D ::New();
+    //caption
+    VTK_CREATE(vtkTextActor3D,caption);
+    caption = vtkTextActor3D ::New();
 
-			//caption->SetVisibility(false);
-			caption->SetInput(text.c_str());
-			// set the properties of the caption
-			//FARBE
-			vtkTextProperty* tprop = caption->GetTextProperty();
-			//tprop->SetFontFamilyToArial();
-			//tprop->BoldOn();
-			//tprop->ShadowOn();
-			//tprop->SetLineSpacing(1.0);
-            tprop->SetFontSize(SystemSettings::getPedestrianCaptionSize());
+    //caption->SetVisibility(false);
+    caption->SetInput(text.c_str());
+    // set the properties of the caption
+    //FARBE
+    vtkTextProperty* tprop = caption->GetTextProperty();
+    //tprop->SetFontFamilyToArial();
+    //tprop->BoldOn();
+    //tprop->ShadowOn();
+    //tprop->SetLineSpacing(1.0);
+    tprop->SetFontSize(SystemSettings::getPedestrianCaptionSize());
 
-			double colorRGB[3];
-			lookupTable->GetColor(color, colorRGB);
-			tprop->SetColor(colorRGB);
+    double colorRGB[3];
+    lookupTable->GetColor(color, colorRGB);
+    tprop->SetColor(colorRGB);
 
-			//cout<<"size:" <<tprop->GetFontSize()<<endl;
-			//tprop->SetColor(1,0,0);
+    caption->SetPosition(center);
+    assemblyCaptions->AddPart(caption);
 
-			caption->SetPosition(center);
-			assemblyCaptions->AddPart(caption);
-
-		}
 }
 
 void FacilityGeometry::showGeometryLabels(int status){
diff --git a/src/geometry/FacilityGeometry.h b/src/geometry/FacilityGeometry.h
index 7b567cc..1bf9d75 100644
--- a/src/geometry/FacilityGeometry.h
+++ b/src/geometry/FacilityGeometry.h
@@ -51,7 +51,7 @@ class FacilityGeometry{
 public:
 
 	/**
-	 * Building element types that are actually supported
+	 * Building element types that are actually supported
 	 */
 	enum ELEMENT_TYPE{
 		DOOR,    //!< DOOR defined by two coordinates points are needed.
@@ -66,7 +66,9 @@ public:
 	FacilityGeometry();
 	virtual ~FacilityGeometry();
 
-	vtkAssembly* getActor();
+    vtkAssembly* getActor2D();
+
+    vtkAssembly* getActor3D();
 
 	vtkActor2DCollection* getCaptions();
 
@@ -79,9 +81,9 @@ public:
 	void addDoor(double x1, double y1, double z1 ,double x2, double y2, double z2, double thickness=17, double height=250,double col=30);
 	//void addDoor(double center[3], double width, double orientation);
 	void addDoor(JPoint* p1, JPoint* p2, std::string caption="");
-
+
 	///draw a step
-	///todo: implement thickness and color
+	///todo: implement thickness and color
 	void addStep(double x1, double y1, double z1, double x2, double y2, double z2=0/*, double thickness=30, double height=10,double col=50*/);
 	//void addStep(double center[3], double width, double orientation);
 	void addStep(JPoint* p1, JPoint* p2);
@@ -136,17 +138,13 @@ private:
 
 //	// 3-d parts
 //	vtkAssembly* assemblyObjects;
-//	vtkAssembly* assemblyWalls3D;
-//	vtkAssembly* assemblyDoors3D;
-//	vtkAssembly* assembly3D;
+    vtkAssembly* assemblyWalls3D;
+    vtkAssembly* assemblyDoors3D;
+    vtkAssembly* assembly3D;
 
 	// other parts
 	vtkAssembly* assemblyCaptions;
-
 	vtkActor2DCollection* captions;
-
-
-
 };
 
 #endif /* FACILITYGEOMETRY_H_ */
diff --git a/src/geometry/LinePlotter2D.cpp b/src/geometry/LinePlotter2D.cpp
index f210724..44e35e8 100644
--- a/src/geometry/LinePlotter2D.cpp
+++ b/src/geometry/LinePlotter2D.cpp
@@ -114,35 +114,6 @@ void LinePlotter2D::SetScalarRange(double minval, double maxval)
 	m_scalarMax = maxval ;
 }
 
-//void LinePlotter2D::SetLookupTable(vtkLookupTable* table)
-//{
-//	m_lookupTable = table ;
-//}
-//void LinePlotter2D::PlotLine(double m[3], double n[3], double scalar)
-//{
-//
-//	m_lineScalars->SetNumberOfComponents(1);
-//	m_points->InsertNextPoint(m);
-//	m_lineScalars->InsertNextTuple1(scalar);
-//	m_points->InsertNextPoint(n);
-//	m_lineScalars->InsertNextTuple1(scalar);
-//
-//	m_lines->InsertNextCell(2);
-//	m_lines->InsertCellPoint(m_curPointID);
-//	m_lines->InsertCellPoint(m_curPointID+1);
-//
-//	m_curPointID+=2;
-//}
-//void LinePlotter2D::PlotLine(double x, double y, double z,
-//		double x2, double y2, double z2, double scalar)
-//{
-//	double m[3],n[3] ;
-//	m[0]=x; m[1]=y; m[2]=z;
-//	n[0]=x2; n[1]=y2; n[2]=z2;
-//	PlotLine(m,n,scalar);
-//
-//}
-
 
 void LinePlotter2D::SetAllLineWidth(int width)
 {
-- 
GitLab