Commits

Suyang Dong  committed 72128ef

Change the data path specification

  • Participants
  • Parent commits 1262b65

Comments (0)

Files changed (13)

File Aurora/Aurora.cpp

 
 
 void *loadFile(const char *file);
-extern std::string gCurPath;
-extern std::string getCurrentPath();
+extern std::string gDataPath;
+extern std::string getDataPath();
 int main(int argc, char** argv)
 {
+	////////////////////////////////////////////////////////////////////////
+	//// initialization
+	////////////////////////////////////////////////////////////////////////
+	if(argc <= 2) {
+		std::cout << "Usage: \n\tAurora <dataPath> <UseExistingModel> [Opt: Shaking Interval] [Opt: Show Third Person View] [Opt: Play Speed]\n";
+		std::cout << "Example: \n\tAurora .\..\data 1 0.04 1 7\n";
+		exit(1);
+	}
+
 	osg::setNotifyLevel(osg::WARN);
 	////////////////////////////////////////////////////////////////////////
 	//// get and save the current working directory 
 	////////////////////////////////////////////////////////////////////////
-	char* buffer_path;
-	if((buffer_path = _getcwd(NULL, 0)) == NULL){
-		std::cout << "_getcwd get current directory error" << endl;
-		exit(1);
-	}
-	else {
-		gCurPath = buffer_path;
-		free(buffer_path);
-	}
-	////////////////////////////////////////////////////////////////////////
-	//// initialization
-	////////////////////////////////////////////////////////////////////////
-	if(argc <= 1) {
-		std::cout << "Usage: \n\tAurora <UseExistingModel> [Opt: Shaking Interval] [Opt: Show Third Person View] [Opt: Play Speed]\n";
-		std::cout << "Example: \n\tAurora 1 0.04 1 7\n";
-		exit(1);
-	}
-	std::string readme = getCurrentPath() + std::string("\\data\\helper\\aurora_readme.txt");
+	//char* buffer_path;
+	//if((buffer_path = _getcwd(NULL, 0)) == NULL){
+	//	std::cout << "_getcwd get current directory error" << endl;
+	//	exit(1);
+	//}
+	//else {
+	//	gDataPath = buffer_path;
+	//	free(buffer_path);
+	//}
+	gDataPath = argv[1];
+
+	std::string readme = getDataPath() + std::string("\\helper\\aurora_readme.txt");
 	char* statement = (char*)loadFile(readme.c_str());
 	std::cout << statement << std::endl;
 	delete[] statement;
 
-	if(argc == 2) {
-		CViewOrganizer viewer(bool(atoi(argv[1])));
-		return viewer.run();
-	} else if (argc == 3) {
-		CViewOrganizer viewer(bool(atoi(argv[1])), atof(argv[2]));
+	if(argc == 3) {
+		CViewOrganizer viewer(bool(atoi(argv[2])));
 		return viewer.run();
 	} else if (argc == 4) {
-		CViewOrganizer viewer(bool(atoi(argv[1])), atof(argv[2]), atof(argv[3]));
+		CViewOrganizer viewer(bool(atoi(argv[2])), atof(argv[3]));
+		return viewer.run();
+	} else if (argc == 5) {
+		CViewOrganizer viewer(bool(atoi(argv[2])), atof(argv[3]), atof(argv[4]));
 		return viewer.run();
 	} else {
-		CViewOrganizer viewer(bool(atoi(argv[1])), atof(argv[2]), atof(argv[3]), atof(argv[4]));
+		CViewOrganizer viewer(bool(atoi(argv[2])), atof(argv[3]), atof(argv[4]), atof(argv[5]));
 		return viewer.run();		
 	}
 
     char *buffer;
 
     fp = fopen ( file , "rb" );
-    if( !fp ) perror(file),exit(1);
+	    if( !fp ) perror(file),exit(1);
 
     fseek( fp , 0L , SEEK_END);
     lSize = ftell( fp );

File Aurora/Aurora.vcproj

 				>
 			</File>
 		</Filter>
-		<Filter
-			Name="Resource Files"
-			Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
-			UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
-			>
-			<File
-				RelativePath="..\Debug\Detected 3D reconstructed corner.txt"
-				>
-			</File>
-			<File
-				RelativePath="..\Debug\edge endpoints.txt"
-				>
-			</File>
-			<File
-				RelativePath="..\Debug\model\TripodPosition.txt"
-				>
-			</File>
-			<File
-				RelativePath="..\Debug\model\VertAfterDamage.txt"
-				>
-			</File>
-		</Filter>
 	</Files>
 	<Globals>
 	</Globals>

File Aurora/BuildingDamage.cpp

 
 extern bool gShaking;
 // the current path should be the folder where the program starts
-std::string gCurPath;
-std::string getCurrentPath()
+std::string gDataPath;
+std::string getDataPath()
 {
-	size_t found = gCurPath.find_last_of("/\\");
-	return gCurPath.substr(0, found);
+	//size_t found = gDataPath.find_last_of("/\\");
+	//return gDataPath.substr(0, found);
+	return gDataPath;
 }
 
 CBuildingDamage::CBuildingDamage(bool useModel, float shakeDev):
 		m_projMatVec.push_back(tmp);
 	}
 	
-	string projectionFile = getCurrentPath() + "\\data\\observation\\perspective projection matrix.txt";
+	string projectionFile = getDataPath() + "\\observation\\perspective projection matrix.txt";
 	std::ifstream in(projectionFile.c_str());
 	std::string line;
 	for (int i = 0; i < 8; i++) 
 			m_detectedEdge.push_back(edges);
 		}
 	
-	string edgeFile = getCurrentPath() + "\\data\\observation\\edge endpoints.txt";
+	string edgeFile = getDataPath() + "\\observation\\edge endpoints.txt";
 	std::ifstream in1(edgeFile.c_str());
 	for (int i = 0; i < 8; i++) 
 		for (int j = 0; j < STORY_NUM; j++) 
 	//////////////////////////////////////////////////////////////////////////
 	//// reading the tripod setting position
 	//////////////////////////////////////////////////////////////////////////
-	string tripodPosFile = getCurrentPath() + "\\data\\model\\TripodPosition.txt";
+	string tripodPosFile = getDataPath() + "\\model\\TripodPosition.txt";
 	FILE* fp;
 	fp = fopen(tripodPosFile.c_str(), "r");
 	if(fp == NULL){
 	//////////////////////////////////////////////////////////////////////////
 	//// output the projection matrix and the selected 2D building corner point
 	//////////////////////////////////////////////////////////////////////////
-	std::string projectionFile = getCurrentPath() + "\\data\\observation\\perspective projection matrix.txt";
+	std::string projectionFile = getDataPath() + "\\observation\\perspective projection matrix.txt";
 	std::ofstream out1(projectionFile.c_str());
 	out1 << "Perspective Projection Matrix for Each Observation Point:\n";
 	// release all the projection matrix
 	//////////////////////////////////////////////////////////////////////////
 	//// output the detected corner in 2D image coordinate 
 	//////////////////////////////////////////////////////////////////////////
-	std::string corner_2dFile = getCurrentPath() + "\\data\\observation\\Detected 2D image corner.txt";
+	std::string corner_2dFile = getDataPath() + "\\observation\\Detected 2D image corner.txt";
 	std::ofstream out2(corner_2dFile.c_str());
 	out2 << "Detected Corner of 2D Image Coordinate\n";
 	if(!m_detectedCorner2D.empty()) 
 	//////////////////////////////////////////////////////////////////////////
 	//// output the detected corner in 3D image coordinate
 	//////////////////////////////////////////////////////////////////////////
-	std::string corner_3dFile = getCurrentPath() + "\\data\\observation\\Detected 3D reconstructed corner.txt";
+	std::string corner_3dFile = getDataPath() + "\\observation\\Detected 3D reconstructed corner.txt";
 	std::ofstream out3(corner_3dFile.c_str());
 #ifdef USE_UNIFIED_SHIFT
 	for (int i = 0; i < STORY_NUM; i++) {
 	//////////////////////////////////////////////////////////////////////////
 	//// output the detected edge endpoints  
 	//////////////////////////////////////////////////////////////////////////
-	std::string edgeFile = getCurrentPath() + "\\data\\observation\\edge endpoints.txt";
+	std::string edgeFile = getDataPath() + "\\observation\\edge endpoints.txt";
 	std::ofstream out4(edgeFile.c_str());
 	out4 << "Detected Edge Endpoints:\n";
 	// release all the projection matrix

File Aurora/BuildingModel.cpp

 \*********************************************************************************************************/
 #include "BuildingModel.h"
 #include <osg/CullFace>
-extern std::string getCurrentPath();
+extern std::string getDataPath();
 
 // shake the model / cause damage
 bool gShaking;
 		////////////////////////////////////////////////////////////////////////
 		//// Load in the existing model
 		////////////////////////////////////////////////////////////////////////
-		std::string beforeDamageFile = getCurrentPath() + "\\data\\model\\beforeDamageModel.osg";
+		std::string beforeDamageFile = getDataPath() + "\\model\\beforeDamageModel.osg";
 		osg::Node* beforeDamageBuilding = osgDB::readNodeFile(beforeDamageFile.c_str());
-		std::string afterDamageFile = getCurrentPath() + "\\data\\model\\afterDamageModel.osg";
+		std::string afterDamageFile = getDataPath() + "\\model\\afterDamageModel.osg";
 		osg::Node* afterDamageBuilding = osgDB::readNodeFile(afterDamageFile.c_str());
 		if(beforeDamageBuilding && afterDamageBuilding) {
 			m_buildingModelBeforeDamage->addChild(beforeDamageBuilding);
 		}
 
 		// reading the vertex file
-		std::string vertexBeforeDamageFile = getCurrentPath() + "\\data\\model\\VertBeforeDamage.txt";
-		std::string vertexAfterDamageFile = getCurrentPath() + "\\data\\model\\VertAfterDamage.txt";
+		std::string vertexBeforeDamageFile = getDataPath() + "\\model\\VertBeforeDamage.txt";
+		std::string vertexAfterDamageFile = getDataPath() + "\\model\\VertAfterDamage.txt";
 
 		FILE* fp;
 		fp = fopen(vertexBeforeDamageFile.c_str(), "r");
 		////////////////////////////////////////////////////////////////////////
 		//// writing node to file
 		////////////////////////////////////////////////////////////////////////
-		std::string beforeDamageFile = getCurrentPath() + "\\data\\model\\beforeDamageModel.osg";
-		std::string afterDamageFile = getCurrentPath() + "\\data\\model\\afterDamageModel.osg";
+		std::string beforeDamageFile = getDataPath() + "\\model\\beforeDamageModel.osg";
+		std::string afterDamageFile = getDataPath() + "\\model\\afterDamageModel.osg";
 		
 		if ( !osgDB::writeNodeFile(*((osg::Node*)m_buildingModelBeforeDamage), beforeDamageFile) ) {
 			char error[128];
 	////////////////////////////////////////////////////////////////////////
 	//// North and South share the same texture coordinate.
 	////////////////////////////////////////////////////////////////////////
-	string filePath = getCurrentPath() + string("\\data\\texture\\NorthSouth.tex");
+	string filePath = getDataPath() + string("\\texture\\NorthSouth.tex");
 	fp = fopen(filePath.c_str(), "r");
 	if(fp== NULL){
 		char error[128];
 	//// East and West share the same texture coordinate.
 	////////////////////////////////////////////////////////////////////////
 	
-	filePath = getCurrentPath() + string("\\data\\texture\\EastWest.tex");
+	filePath = getDataPath() + string("\\texture\\EastWest.tex");
 	fp = fopen(filePath.c_str(), "r");
 	if(fp== NULL){
 		char error[128];
 	////////////////////////////////////////////////////////////////////////
 	//// North and South share the same texture image.
 	////////////////////////////////////////////////////////////////////////
-	std::string texPath = getCurrentPath() + string("\\data\\texture\\NorthSouth.jpg");
+	std::string texPath = getDataPath() + string("\\texture\\NorthSouth.jpg");
 	osg::Image* nsWallSurface = osgDB::readImageFile(texPath);
 	if(nsWallSurface == NULL) 
 		throw("File doesn't exist: %s", texPath.c_str());
 	////////////////////////////////////////////////////////////////////////
 	//// East and West share the same texture coordinate.
 	////////////////////////////////////////////////////////////////////////
-	texPath = getCurrentPath() + string("\\data\\texture\\EastWest.jpg");
+	texPath = getDataPath() + string("\\texture\\EastWest.jpg");
 	osg::Image* ewWallSurface = osgDB::readImageFile(texPath);
 	if(ewWallSurface == NULL) 
 		throw("File doesn't exist: %s", texPath.c_str());
 	m_buildingVerticesBeforeDamage.clear();
 	m_buildingVerticesAfterDamage.clear();
 	float elevation = 0.f;
-	string beforeDamageFilePath = getCurrentPath() + "\\data\\model\\VertBeforeDamage.txt";
+	string beforeDamageFilePath = getDataPath() + "\\model\\VertBeforeDamage.txt";
 	fstream fileVertexBeforeDamage(beforeDamageFilePath.c_str(),ios::out);
 	// must add this line
 	fileVertexBeforeDamage.close();
 	
 	fileVertexBeforeDamage << fixed << setprecision(3);
 	
-	string afterDamageFilePath = getCurrentPath() + "\\data\\model\\VertAfterDamage.txt";
+	string afterDamageFilePath = getDataPath() + "\\model\\VertAfterDamage.txt";
 	fstream fileVertexAfterDamage(afterDamageFilePath.c_str(), ios::out);
 	// must add this line
 	fileVertexAfterDamage.close();
 	tcoords->push_back(osg::Vec2d(1.f, 1.f));
 	tcoords->push_back(osg::Vec2d(0.f, 1.f));
 	
-	string terrainFile = getCurrentPath() + "\\data\\texture\\terrain.jpg";
+	string terrainFile = getDataPath() + "\\texture\\terrain.jpg";
 	osg::Image* terrainImg = osgDB::readImageFile(terrainFile.c_str());
 	if(terrainImg == NULL) {
 		throw("File doesn't exist: %s", terrainFile.c_str());
 	tcoords->push_back(osg::Vec2d(1.f, 1.f));
 	tcoords->push_back(osg::Vec2d(0.f, 1.f));
 	
-	string roofFile = getCurrentPath() + "\\data\\texture\\roof.jpg";
+	string roofFile = getDataPath() + "\\texture\\roof.jpg";
 	osg::Image* roofImg = osgDB::readImageFile(roofFile.c_str());
 	if(roofImg == NULL) {
 				throw("File doesn't exist: %s", roofFile.c_str());
 	tcoords->push_back(osg::Vec2d(1.f, 1.f));
 	tcoords->push_back(osg::Vec2d(0.f, 1.f));
 	
-	string roofFile = getCurrentPath() + "\\data\\texture\\roof.jpg";
+	string roofFile = getDataPath() + "\\texture\\roof.jpg";
 	osg::Image* roofImg = osgDB::readImageFile(roofFile.c_str());
 	if(roofImg == NULL) {
 				throw("File doesn't exist: %s", roofFile.c_str());
 	if (m_tripod == NULL) {
 		m_tripod = new osg::PositionAttitudeTransform;
 		m_tripod->setName("tripod");
-		string modelPath = getCurrentPath() + "\\data\\model\\tripod.dae";
+		string modelPath = getDataPath() + "\\model\\tripod.dae";
 		osg::Node* tripodModel = osgDB::readNodeFile(modelPath.c_str());
 		if(tripodModel == NULL) 
 			throw("File doesn't exist: %s", modelPath.c_str());
 	if (m_camera == NULL) {
 		m_tripod->setName("camera");
 		m_camera = new osg::PositionAttitudeTransform;
-		string modelPath = getCurrentPath() + "\\data\\model\\camera.dae";
+		string modelPath = getDataPath() + "\\model\\camera.dae";
 		osg::Node* cameraModel = osgDB::readNodeFile(modelPath.c_str());
 		if(cameraModel == NULL) 
 			throw("File doesn't exist: %s", modelPath.c_str());

File Aurora/FirstPersonViewHandler.cpp

 #include <osg/PolygonMode>
 #include "mathHelper.h"
 extern bool gShaking;
-extern std::string getCurrentPath();
+extern std::string getDataPath();
 extern void *loadFile(const char *file);
 using namespace CV2CG;
 //   Source snippt online 
 					case 'h':
 					case 'H':
 						{
-							std::string readme = getCurrentPath() + std::string("\\data\\helper\\firstperson_readme.txt");
+							std::string readme = getDataPath() + std::string("\\helper\\firstperson_readme.txt");
 							char* statement = (char*)loadFile(readme.c_str());
 							std::cout << statement << std::endl;
 							delete[] statement;

File Aurora/FirstPersonViewHandler.h

 #include <osgViewer/View>
 #include "BuildingDamage.h"
 #include "../third_party/CImg.h"
-extern std::string getCurrentPath();
+extern std::string getDataPath();
 using namespace cimg_library;
 class CViewOrganizer;
 //! Take snapshot of the first person view

File Aurora/PhotoViewHandler.cpp

 #include "../third_party/lsd.h"
 #include <osg/Math>
 extern bool gShaking;
-extern std::string getCurrentPath();
+extern std::string getDataPath();
 extern void *loadFile(const char *file);
 
 using namespace LSD;
 	////////////////////////////////////////////////////////////////////////
 	//// output the viewport dimension for sensitivity analysis to instrument uncertainty
 	////////////////////////////////////////////////////////////////////////
-	string vpFile = getCurrentPath() + "\\data\\observation\\ViewportAndShakeInterval.txt";
+	string vpFile = getDataPath() + "\\observation\\ViewportAndShakeInterval.txt";
 	std::ofstream out(vpFile.c_str());
 	out <<  "Width	" << "	Height" << endl;
 	out << m_preViewportWidth << "\t" << m_preViewportHeight << endl;
 					case 'h':
 					case 'H':
 						{
-							std::string readme = getCurrentPath() + std::string("\\data\\helper\\photoview_readme.txt");
+							std::string readme = getDataPath() + std::string("\\helper\\photoview_readme.txt");
 							char* statement = (char*)loadFile(readme.c_str());
 							std::cout << statement << std::endl;
 							delete[] statement;

File Aurora/ThirdPersonViewHandler.cpp

 #include "ThirdPersonViewHandler.h"
 #include <iostream>
 extern bool gShaking;
-extern std::string getCurrentPath();
+extern std::string getDataPath();
 extern void *loadFile(const char *file);
 
 CThirdPersonViewHandler::CThirdPersonViewHandler(){}
 					case 'h':
 					case 'H':
 						{
-							std::string readme = getCurrentPath() + std::string("\\data\\helper\\thirdperson_readme.txt");
+							std::string readme = getDataPath() + std::string("\\helper\\thirdperson_readme.txt");
 							char* statement = (char*)loadFile(readme.c_str());
 							std::cout << statement << std::endl;
 							delete[] statement;

File Aurora/ViewOrganizer.cpp

Binary file modified.

File data/observation/Detected 2D image corner.txt

 Detected Corner of 2D Image Coordinate
 
 Observation Point: 0	Story Index: 	0
-X: 553.3	Y: 371.816
+X: 0	Y: 0
 
 Observation Point: 0	Story Index: 	1
 X: 0	Y: 0
 X: 0	Y: 0
 
 Observation Point: 1	Story Index: 	0
-X: 554.58	Y: 376.252
+X: 0	Y: 0
 
 Observation Point: 1	Story Index: 	1
 X: 0	Y: 0

File data/observation/Detected 3D reconstructed corner.txt

-1 floor:	<0>	1	<1>	0	<2>	0	<3>	1	
+1 floor:	<0>	0	<1>	0	<2>	0	<3>	0	
 2 floor:	<0>	0	<1>	0	<2>	0	<3>	0	
 3 floor:	<0>	0	<1>	0	<2>	0	<3>	0	
 4 floor:	<0>	0	<1>	0	<2>	0	<3>	0	
 10 floor:	<0>	0	<1>	0	<2>	0	<3>	0	
 Detected Corner of 3D reconstructed Coordinate
 Corner Point:	0	Story Index:	0
-Estimated:	X: 0.0309538	Y: -0.027433	Z: 5.33023
+Estimated:	X: 0	Y: 0	Z: 0
 Actual:	X: 0.03064	Y: -0.02845	Z: 5.33
-Error in	XY:0.00106431	X:	0.000313767	Y:	0.00101701	Z:	0.000225251
+Error in	XY:0.0418116	X:	0.03064	Y:	0.02845	Z:	5.33
 
 Corner Point:	0	Story Index:	1
 Estimated:	X: 0	Y: 0	Z: 0
 
 /**********************************************************/
 Corner Point:	1	Story Index:	0
-Estimated:	X: 45.731	Y: 0	Z: 0
+Estimated:	X: 0	Y: 0	Z: 0
 Actual:	X: 45.7306	Y: 0.01463	Z: 5.33
-Error in	XY:0.0146334	X:	0.000314119	Y:	0.01463	Z:	5.33
+Error in	XY:45.7306	X:	45.7306	Y:	0.01463	Z:	5.33
 
 Corner Point:	1	Story Index:	1
 Estimated:	X: 0	Y: 0	Z: 0
 
 /**********************************************************/
 Corner Point:	3	Story Index:	0
-Estimated:	X: 0	Y: 30.4726	Z: 0
+Estimated:	X: 0	Y: 0	Z: 0
 Actual:	X: -0.02849	Y: 30.4715	Z: 5.33
-Error in	XY:0.0285081	X:	0.02849	Y:	0.00101702	Z:	5.33
+Error in	XY:30.4716	X:	0.02849	Y:	30.4715	Z:	5.33
 
 Corner Point:	3	Story Index:	1
 Estimated:	X: 0	Y: 0	Z: 0
 /**********************************************************/
 Error Statistics:
 MAX	XY: 54.9788	Z: 43.13
-MIN	XY: 0.00106431	Z: 0.000225251
-AVG	XY: 30.8873	Z: 24.0968
-STDEV	XY: 21.9009	Z: 12.2987
+MIN	XY: 0.0192733	Z: 5.33
+AVG	XY: 32.7923	Z: 24.23
+STDEV	XY: 20.8288	Z: 12.0636

File errorAna/errorAna.vcproj

 			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
 			>
 		</Filter>
-		<Filter
-			Name="Resource Files"
-			Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
-			UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
-			>
-		</Filter>
 	</Files>
 	<Globals>
 	</Globals>

File errorAna/errorAnalysis.cpp

 	}
 }
 
-extern std::string gCurPath;
-extern std::string getCurrentPath();
+extern std::string gDataPath;
+extern std::string getDataPath();
 extern bool gShaking;
 int main(int argc, char** argv)
 {
 		throw("_getcwd get current directory error");
 	}
 	else {
-		gCurPath = buffer_path;
+		gDataPath = buffer_path;
 		free(buffer_path);
 	}
 	//// Read viewport and shake interval information, record from AURORA.exe 
-	string viewportFile = getCurrentPath() + "\\data\\observation\\ViewportAndShakeInterval.txt";
+	string viewportFile = getDataPath() + "\\observation\\ViewportAndShakeInterval.txt";
 	std::ifstream in1(viewportFile.c_str());
 	std::string line;
 	helper::readValidLine(in1, line);