Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
* Remove dead code
* Remove commented code
* Use pramga once
  • Loading branch information
Ozaq committed Sep 28, 2021
1 parent a2f5503 commit a001877
Show file tree
Hide file tree
Showing 54 changed files with 123 additions and 3,058 deletions.
4 changes: 1 addition & 3 deletions jpsvis/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ set(SRCS
src/Frame.cpp
src/FrameElement.cpp
src/IO/OutputHandler.cpp
src/IO/TraVisToClient.cpp
src/InteractorStyle.cpp
src/Log.cpp
src/MainWindow.cpp
Expand Down Expand Up @@ -184,7 +183,6 @@ set(HDR
src/Frame.h
src/FrameElement.h
src/IO/OutputHandler.h
src/IO/TraVisToClient.h
src/InteractorStyle.h
src/Log.h
src/MainWindow.h
Expand Down Expand Up @@ -219,7 +217,7 @@ set(HDR
src/geometry/Transition.h
src/geometry/Wall.h
src/myqtreeview.h
src/train.h
src/trains/train.h
)

set(UIS
Expand Down
133 changes: 0 additions & 133 deletions jpsvis/src/Frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,134 +77,14 @@ void Frame::addElement(FrameElement * point)
_framePoints.push_back(point);
}

// void Frame::clear()
//{
// while (!_framePoints.empty()) {
// delete _framePoints.back();
// _framePoints.pop_back();
// }
// _framePoints.clear();

// _elementCursor=0;
//}

FrameElement * Frame::getNextElement()
{
if(_elementCursor >= _framePoints.size()) {
return NULL;

} else {
// return _framePoints.at(_elementCursor++);
return _framePoints[_elementCursor++];
}
// next test
}


/*
vtkPolyData* Frame::GetPolyData(bool is_ellipse)
{
VTK_CREATE (vtkPoints, points);
VTK_CREATE (vtkFloatArray, colors);
VTK_CREATE (vtkFloatArray, tensors);
colors->SetName("color");
colors->SetNumberOfComponents(1);
tensors->SetName("tensors");
tensors->SetNumberOfComponents(9);
for (unsigned int i=0;i<_framePoints.size();i++)
{
double pos[3]={0,0,0};
double rad[3]={1.0,1.0,1.0};
double rot[3];
double color;
_framePoints[i]->GetPos(pos); //pos[2]=90;
_framePoints[i]->GetOrientation(rot);
_framePoints[i]->GetColor(&color);
_framePoints[i]->GetRadius(rad);
//only scale the ellipse 2D
if(is_ellipse)
{
rad[0]/=30;rad[1]/=30;rad[2]/=120;
}
else
{
double height_i=170;
rot[0]=vtkMath::RadiansFromDegrees(90.0);
rot[1]=vtkMath::RadiansFromDegrees(00.0);
pos[2]=height_i/2.0; // slightly above ground
rad[0]/=30;
rad[2]/=30;
//?height default to 30 in SaxParser and 160 in Renderingengine
rad[1]=height_i/160.0;
}
points->InsertNextPoint(pos);
rot[2]=vtkMath::RadiansFromDegrees(rot[2]);
//scaling matrix
double sc[3][3] = {{rad[0],0,0},
{0,rad[1],0},
{0,0,rad[2]}};
//rotation matrix around x-axis
double roX[3][3] = {{1, 0, 0},
{0, cos(rot[0]),-sin(rot[0])},
{0, sin(rot[0]), cos(rot[0])}};
//rotation matrix around y-axis
double roY[3][3] = {{cos(rot[1]), 0,sin(rot[1])},
{0, 1, 0},
{-sin(rot[1]),0,cos(rot[1])}};
//rotation matrix around z-axis
double roZ[3][3] = {{cos(rot[2]),sin(rot[2]),0.0},
{-sin(rot[2]),cos(rot[2]),0.0},
{0.0,0.0,1.0}};
//final rotation matrix
double ro[3][3];
vtkMath::Multiply3x3(roX,roY,ro);
vtkMath::Multiply3x3(ro,roZ,ro);
//final transformation matrix
double rs[3][3];
vtkMath::Multiply3x3(sc,ro,rs);
tensors->InsertNextTuple9(rs[0][0],rs[0][1],rs[0][2],
rs[1][0],rs[1][1],rs[1][2],
rs[2][0],rs[2][1],rs[2][2]);
if(color==-1){
colors->InsertNextValue(NAN);
}
else{
colors->InsertNextValue(color/255.0);
}
}
// setting the colors
_polydata->SetPoints(points);
_polydata->GetPointData()->AddArray(colors);
_polydata->GetPointData()->SetActiveScalars("color");
// setting the scaling and rotation
_polydata->GetPointData()->SetTensors(tensors);
_polydata->GetPointData()->SetActiveTensors("tensors");
return _polydata;
}
*/

void Frame::ComputePolyData()
{
Expand Down Expand Up @@ -325,38 +205,25 @@ void Frame::ComputePolyData3D()
_framePoints[i]->GetColor(&color);
_framePoints[i]->GetRadius(rad);


// values for cylindar
double height_i = 170;
double max_height = 160;
rot[0] = vtkMath::RadiansFromDegrees(90.0);
rot[1] = vtkMath::RadiansFromDegrees(00.0);
int angle_offset = 0;

// values for charlie
// rot[0]=vtkMath::RadiansFromDegrees(00.0);
// rot[1]=vtkMath::RadiansFromDegrees(00.0);
// int angle_offset=90;
// double max_height=350;


pos[2] += height_i / 2.0 - 30; // slightly above ground
rad[0] /= 20;
rad[0] = 1;
rad[2] /= 20;
rad[2] = 1;
//?height default to 30 in SaxParser and 160 in Renderingengine
// rad[1]=height_i/160.0;
rad[1] = height_i / max_height;


points->InsertNextPoint(pos);
rot[2] = vtkMath::RadiansFromDegrees(rot[2] + angle_offset);

// scaling matrix
double sc[3][3] = {{rad[0], 0, 0}, {0, rad[1], 0}, {0, 0, rad[2]}};


// rotation matrix around x-axis
double roX[3][3] = {
{1, 0, 0}, {0, cos(rot[0]), -sin(rot[0])}, {0, sin(rot[0]), cos(rot[0])}};
Expand Down
8 changes: 1 addition & 7 deletions jpsvis/src/Frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@
* Created on: 10.07.2009
*
*/

#ifndef Frame_H_
#define Frame_H_
#pragma once

#include <vector>

Expand Down Expand Up @@ -66,8 +64,6 @@ class Frame
/// reset the position of the cursor for reading the data
void resetCursor();

// vtkPolyData *GetSclarData();

/// return the 3D polydata set
vtkPolyData * GetPolyData3D();

Expand Down Expand Up @@ -99,5 +95,3 @@ class Frame
// the frame id
int _id;
};

#endif /* Frame_H_ */
4 changes: 0 additions & 4 deletions jpsvis/src/FrameElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@
* along with OpenPedSim. If not, see <http://www.gnu.org/licenses/>.
*
* @section DESCRIPTION
*
* \brief
*
*
*/


Expand Down
12 changes: 1 addition & 11 deletions jpsvis/src/FrameElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,8 @@
* along with OpenPedSim. If not, see <http://www.gnu.org/licenses/>.
*
* @section DESCRIPTION
*
* \brief
*
*
*/


#ifndef FRAME_ELEMENT_H_
#define FRAME_ELEMENT_H_
#pragma once

class FrameElement
{
Expand All @@ -44,7 +37,6 @@ class FrameElement
void SetMinFrame(int minframe);
int GetMinFrame();


/// set/get the position of the point/agent
void GetPos(double pos[3]);
/// set/get the position of the point/agent
Expand All @@ -70,5 +62,3 @@ class FrameElement
double _color;
int _minFrame;
};

#endif /* FRAME_ELEMENT_H_ */
32 changes: 0 additions & 32 deletions jpsvis/src/IO/OutputHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,35 +174,3 @@ void FileHandler::Write(const char * str_msg, ...)
incrementWarnings();
}
}

#ifdef _SIMULATOR

SocketHandler::SocketHandler(const string & host, int port)
{
client = new TraVisToClient(host, port);
brokentags.push_back("<trajectories>");
brokentags.push_back("</trajectories>");
brokentags.push_back("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
}

SocketHandler::~SocketHandler()
{
delete client;
}

void SocketHandler::Write(const string & stringRef)
{
vector<string>::iterator str_it;
string str = stringRef;

// There are a few broken tags which need to be checked for and removed.
for(str_it = brokentags.begin(); str_it != brokentags.end(); ++str_it) {
int tagstart = str.find(*str_it);
if(tagstart != (int) string::npos) {
str.erase(str.begin() + tagstart, str.begin() + tagstart + (*str_it).size());
}
}
client->sendData(str.c_str());
}

#endif
29 changes: 1 addition & 28 deletions jpsvis/src/IO/OutputHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,14 @@
*
*
**/


#ifndef OUTPUT_HANDLER_H_
#define OUTPUT_HANDLER_H_
#pragma once

#include "../general/Macros.h"

#include <fstream>
#include <iostream>
#include <vector>

#ifdef _SIMULATOR
#include "../IO/TraVisToClient.h"
#endif


class OutputHandler
{
Expand Down Expand Up @@ -81,23 +74,3 @@ class FileHandler : public OutputHandler
void Write(const std::string & str);
void Write(const char * string, ...);
};

#ifdef _SIMULATOR

class SocketHandler : public OutputHandler
{
private:
TraVisToClient * client;

public:
SocketHandler(const std::string & host, int port);
virtual ~SocketHandler();
void Write(const std::string & str);

// Some tags are broken
std::vector<std::string> brokentags;
};

#endif

#endif /*OUTPUT_HANDLER_H_*/
Loading

0 comments on commit a001877

Please sign in to comment.