Database Preprocessing for Indoor IRT

Detailed Description

This is an example of how to use the WinProp API to preprocess an indoor database for IRT. The full example is distributed with the installation.
#include <stdio.h>
#include <string>
#include <iostream>

#include "IRT_preprocess.h"

#ifndef API_DATA_FOLDER
#define API_DATA_FOLDER "../../api/winprop/data/"
#endif // !API_DATA_FOLDER

int main(int argc, char** argv)
{
	int Error = 0;
	WinProp_PrePro      PreproPara;
	WinProp_Callback    Callback;

    /* ---------------------------- Initialisations -------------------------- */
    WinProp_Structure_Init_Callback(&Callback);
	WinProp_Structure_Init_PrePro(&PreproPara);
	Callback.Percentage = CallbackProgress;
	Callback.Message = CallbackMessage;
	Callback.Error = CallbackError;

	/* ----------------- Definition of parameters for preprocessing ---------- */
	PreproPara.NrHeights = 1;
	PreproPara.Heights = (double*)malloc(sizeof(double) * PreproPara.NrHeights);
	PreproPara.Heights[0] = 1.5;
	PreproPara.Resolution = 2.0;
	PreproPara.AdaptiveResolution = 1;
	PreproPara.AdaptiveResolutionFactor = 2;
	PreproPara.MultipleInteractions = 0;
	PreproPara.ExcludeDiffractions = 1;
	PreproPara.OnlyPixelsInsideBuilding = 1;
	PreproPara.TileLength = 10.0;
	PreproPara.SegmentLength = 10.0;
	PreproPara.TimeVariantMode = 1;
	PreproPara.TimeVariantStart = 0.0;
	PreproPara.TimeVariantStop = 2.0;
	PreproPara.TimeVariantInterval = 0.5;
	PreproPara.TimeVariantNrSteps = 2;
	PreproPara.TimeVariantSteps = (double*)malloc(sizeof(double) * PreproPara.TimeVariantNrSteps);
	PreproPara.TimeVariantSteps[0] = 1.0;
	PreproPara.TimeVariantSteps[1] = 2.0;

	Error = WinProp_PreProcessIndoor(
		// specify full path with extension
		API_DATA_FOLDER  "/indoor/IndoorVectordatabase.ida",
		// no extension here
		API_DATA_FOLDER "/indoor/IRT_Preprocessed_database",
		&PreproPara,
		&Callback
	);


	return 0;
}

int _STD_CALL CallbackMessage(const char * Text)
{
	if (Text == nullptr)
		return 0;

	std::cout << "\n" << Text;

	return(0);
}

int _STD_CALL CallbackError(const char * Text, int Error)
{
	if (Text == nullptr)
		return 0;

	std::cout << "\n";

#ifdef __LINUX
	std::cout << "\033[31m" << "Error (" << Error << "): "; // highlight error in red color
#else
	HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
	SetConsoleTextAttribute(hConsole, FOREGROUND_RED);
	std::cout << "Error (" << Error << "): ";
#endif // __LINUX
	std::cout << Text;

#ifdef __LINUX
	std::cout << "\033[0m"; // highlight error in red color
#else
	SetConsoleTextAttribute(hConsole, FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN);
#endif // __LINUX

	return 0;
}

int _STD_CALL CallbackProgress(int value, const char* text)
{
	char Line[200];

	sprintf(Line, "\n%d%% %s", value, text);
	std::cout << Line;

	return(0);
}