summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--astra_vc09.sln22
-rw-r--r--astra_vc09.vcproj8
-rw-r--r--astra_vc11.sln22
-rw-r--r--astra_vc11.vcxproj5
-rw-r--r--astra_vc11.vcxproj.filters7
-rw-r--r--build/linux/Makefile.in4
-rw-r--r--build/msvc/gen.py38
-rw-r--r--cuda/2d/astra.cu7
-rw-r--r--cuda/2d/fft.cu45
-rw-r--r--cuda/2d/util.cu8
-rw-r--r--cuda/3d/util3d.cu12
-rw-r--r--include/astra/Logger.h72
-rw-r--r--include/astra/Logging.h159
-rw-r--r--include/astra/clog.h693
-rw-r--r--matlab/mex/astra_mex.cpp3
-rw-r--r--matlab/mex/astra_mex_algorithm_c.cpp3
-rw-r--r--matlab/mex/astra_mex_algorithm_vc09.vcproj8
-rw-r--r--matlab/mex/astra_mex_algorithm_vc11.vcxproj2
-rw-r--r--matlab/mex/astra_mex_c.cpp3
-rw-r--r--matlab/mex/astra_mex_data2d_c.cpp3
-rw-r--r--matlab/mex/astra_mex_data2d_vc09.vcproj8
-rw-r--r--matlab/mex/astra_mex_data2d_vc11.vcxproj2
-rw-r--r--matlab/mex/astra_mex_data3d_c.cpp3
-rw-r--r--matlab/mex/astra_mex_data3d_vc09.vcproj8
-rw-r--r--matlab/mex/astra_mex_data3d_vc11.vcxproj2
-rw-r--r--matlab/mex/astra_mex_log_c.cpp305
-rw-r--r--matlab/mex/astra_mex_log_vc09.vcproj612
-rw-r--r--matlab/mex/astra_mex_log_vc11.vcxproj306
-rw-r--r--matlab/mex/astra_mex_matrix_c.cpp3
-rw-r--r--matlab/mex/astra_mex_matrix_vc09.vcproj8
-rw-r--r--matlab/mex/astra_mex_matrix_vc11.vcxproj2
-rw-r--r--matlab/mex/astra_mex_projector3d_c.cpp3
-rw-r--r--matlab/mex/astra_mex_projector3d_vc09.vcproj8
-rw-r--r--matlab/mex/astra_mex_projector3d_vc11.vcxproj2
-rw-r--r--matlab/mex/astra_mex_projector_c.cpp3
-rw-r--r--matlab/mex/astra_mex_projector_vc09.vcproj8
-rw-r--r--matlab/mex/astra_mex_projector_vc11.vcxproj2
-rw-r--r--matlab/mex/astra_mex_vc09.vcproj8
-rw-r--r--matlab/mex/astra_mex_vc11.vcxproj2
-rw-r--r--matlab/mex/mexInitFunctions.cpp24
-rw-r--r--matlab/mex/mexInitFunctions.h6
-rw-r--r--matlab/tools/astra_mex_log.m33
-rw-r--r--python/astra/__init__.py1
-rw-r--r--python/astra/log.py153
-rw-r--r--python/astra/log_c.pyx96
-rw-r--r--src/ConeProjectionGeometry3D.cpp4
-rw-r--r--src/Config.cpp7
-rw-r--r--src/CudaFilteredBackProjectionAlgorithm.cpp16
-rw-r--r--src/CudaForwardProjectionAlgorithm.cpp4
-rw-r--r--src/CudaForwardProjectionAlgorithm3D.cpp4
-rw-r--r--src/CudaReconstructionAlgorithm2D.cpp4
-rw-r--r--src/FilteredBackProjectionAlgorithm.cpp4
-rw-r--r--src/Logger.cpp77
-rw-r--r--src/Logging.cpp184
54 files changed, 2827 insertions, 209 deletions
diff --git a/astra_vc09.sln b/astra_vc09.sln
index 691ad91..9b93a0f 100644
--- a/astra_vc09.sln
+++ b/astra_vc09.sln
@@ -43,6 +43,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "astra_mex_projector3d", "ma
{12926444-6723-46A8-B388-12E65E0577FA} = {12926444-6723-46A8-B388-12E65E0577FA}
EndProjectSection
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "astra_mex_log", "matlab\mex\astra_mex_log_vc09.vcproj", "{CA2840B3-DA68-41B5-AC57-F5DFD20ED8F8}"
+ ProjectSection(ProjectDependencies) = postProject
+ {12926444-6723-46A8-B388-12E65E0577FA} = {12926444-6723-46A8-B388-12E65E0577FA}
+ EndProjectSection
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug_CUDA|Win32 = Debug_CUDA|Win32
@@ -183,6 +188,22 @@ Global
{F94CCD79-AA11-42DF-AC8A-6C9D2238A883}.Release|Win32.Build.0 = Release|Win32
{F94CCD79-AA11-42DF-AC8A-6C9D2238A883}.Release|x64.ActiveCfg = Release|x64
{F94CCD79-AA11-42DF-AC8A-6C9D2238A883}.Release|x64.Build.0 = Release|x64
+ {CA2840B3-DA68-41B5-AC57-F5DFD20ED8F8}.Debug_CUDA|Win32.ActiveCfg = Debug_CUDA|Win32
+ {CA2840B3-DA68-41B5-AC57-F5DFD20ED8F8}.Debug_CUDA|Win32.Build.0 = Debug_CUDA|Win32
+ {CA2840B3-DA68-41B5-AC57-F5DFD20ED8F8}.Debug_CUDA|x64.ActiveCfg = Debug_CUDA|x64
+ {CA2840B3-DA68-41B5-AC57-F5DFD20ED8F8}.Debug_CUDA|x64.Build.0 = Debug_CUDA|x64
+ {CA2840B3-DA68-41B5-AC57-F5DFD20ED8F8}.Debug|Win32.ActiveCfg = Debug|Win32
+ {CA2840B3-DA68-41B5-AC57-F5DFD20ED8F8}.Debug|Win32.Build.0 = Debug|Win32
+ {CA2840B3-DA68-41B5-AC57-F5DFD20ED8F8}.Debug|x64.ActiveCfg = Debug|x64
+ {CA2840B3-DA68-41B5-AC57-F5DFD20ED8F8}.Debug|x64.Build.0 = Debug|x64
+ {CA2840B3-DA68-41B5-AC57-F5DFD20ED8F8}.Release_CUDA|Win32.ActiveCfg = Release_CUDA|Win32
+ {CA2840B3-DA68-41B5-AC57-F5DFD20ED8F8}.Release_CUDA|Win32.Build.0 = Release_CUDA|Win32
+ {CA2840B3-DA68-41B5-AC57-F5DFD20ED8F8}.Release_CUDA|x64.ActiveCfg = Release_CUDA|x64
+ {CA2840B3-DA68-41B5-AC57-F5DFD20ED8F8}.Release_CUDA|x64.Build.0 = Release_CUDA|x64
+ {CA2840B3-DA68-41B5-AC57-F5DFD20ED8F8}.Release|Win32.ActiveCfg = Release|Win32
+ {CA2840B3-DA68-41B5-AC57-F5DFD20ED8F8}.Release|Win32.Build.0 = Release|Win32
+ {CA2840B3-DA68-41B5-AC57-F5DFD20ED8F8}.Release|x64.ActiveCfg = Release|x64
+ {CA2840B3-DA68-41B5-AC57-F5DFD20ED8F8}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -195,5 +216,6 @@ Global
{9D041710-2119-4230-BCF2-5FBE753FDE49} = {33EF0AC5-B475-40BF-BAE5-67075B204D10}
{4DD6056F-8EEE-4C9A-B2A9-923F01A32E97} = {33EF0AC5-B475-40BF-BAE5-67075B204D10}
{F94CCD79-AA11-42DF-AC8A-6C9D2238A883} = {33EF0AC5-B475-40BF-BAE5-67075B204D10}
+ {CA2840B3-DA68-41B5-AC57-F5DFD20ED8F8} = {33EF0AC5-B475-40BF-BAE5-67075B204D10}
EndGlobalSection
EndGlobal
diff --git a/astra_vc09.vcproj b/astra_vc09.vcproj
index f84eaaf..a56e4bc 100644
--- a/astra_vc09.vcproj
+++ b/astra_vc09.vcproj
@@ -921,6 +921,10 @@
>
</File>
<File
+ RelativePath=".\include\astra\clog.h"
+ >
+ </File>
+ <File
RelativePath=".\include\astra\Config.h"
>
</File>
@@ -933,7 +937,7 @@
>
</File>
<File
- RelativePath=".\include\astra\Logger.h"
+ RelativePath=".\include\astra\Logging.h"
>
</File>
<File
@@ -989,7 +993,7 @@
>
</File>
<File
- RelativePath=".\src\Logger.cpp"
+ RelativePath=".\src\Logging.cpp"
>
</File>
<File
diff --git a/astra_vc11.sln b/astra_vc11.sln
index 0ff0ef8..2832eab 100644
--- a/astra_vc11.sln
+++ b/astra_vc11.sln
@@ -43,6 +43,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "astra_mex_projector3d", "ma
{BE9F1326-527C-4284-AE2C-D1E25D539CEA} = {BE9F1326-527C-4284-AE2C-D1E25D539CEA}
EndProjectSection
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "astra_mex_log", "matlab\mex\astra_mex_log_vc11.vcxproj", "{03B833F5-4FD6-4FBE-AAF4-E3305CD56D2E}"
+ ProjectSection(ProjectDependencies) = postProject
+ {BE9F1326-527C-4284-AE2C-D1E25D539CEA} = {BE9F1326-527C-4284-AE2C-D1E25D539CEA}
+ EndProjectSection
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug_CUDA|Win32 = Debug_CUDA|Win32
@@ -183,6 +188,22 @@ Global
{F94CCD79-AA11-42DF-AC8A-6C9D2238A883}.Release|Win32.Build.0 = Release|Win32
{F94CCD79-AA11-42DF-AC8A-6C9D2238A883}.Release|x64.ActiveCfg = Release|x64
{F94CCD79-AA11-42DF-AC8A-6C9D2238A883}.Release|x64.Build.0 = Release|x64
+ {03B833F5-4FD6-4FBE-AAF4-E3305CD56D2E}.Debug_CUDA|Win32.ActiveCfg = Debug_CUDA|Win32
+ {03B833F5-4FD6-4FBE-AAF4-E3305CD56D2E}.Debug_CUDA|Win32.Build.0 = Debug_CUDA|Win32
+ {03B833F5-4FD6-4FBE-AAF4-E3305CD56D2E}.Debug_CUDA|x64.ActiveCfg = Debug_CUDA|x64
+ {03B833F5-4FD6-4FBE-AAF4-E3305CD56D2E}.Debug_CUDA|x64.Build.0 = Debug_CUDA|x64
+ {03B833F5-4FD6-4FBE-AAF4-E3305CD56D2E}.Debug|Win32.ActiveCfg = Debug|Win32
+ {03B833F5-4FD6-4FBE-AAF4-E3305CD56D2E}.Debug|Win32.Build.0 = Debug|Win32
+ {03B833F5-4FD6-4FBE-AAF4-E3305CD56D2E}.Debug|x64.ActiveCfg = Debug|x64
+ {03B833F5-4FD6-4FBE-AAF4-E3305CD56D2E}.Debug|x64.Build.0 = Debug|x64
+ {03B833F5-4FD6-4FBE-AAF4-E3305CD56D2E}.Release_CUDA|Win32.ActiveCfg = Release_CUDA|Win32
+ {03B833F5-4FD6-4FBE-AAF4-E3305CD56D2E}.Release_CUDA|Win32.Build.0 = Release_CUDA|Win32
+ {03B833F5-4FD6-4FBE-AAF4-E3305CD56D2E}.Release_CUDA|x64.ActiveCfg = Release_CUDA|x64
+ {03B833F5-4FD6-4FBE-AAF4-E3305CD56D2E}.Release_CUDA|x64.Build.0 = Release_CUDA|x64
+ {03B833F5-4FD6-4FBE-AAF4-E3305CD56D2E}.Release|Win32.ActiveCfg = Release|Win32
+ {03B833F5-4FD6-4FBE-AAF4-E3305CD56D2E}.Release|Win32.Build.0 = Release|Win32
+ {03B833F5-4FD6-4FBE-AAF4-E3305CD56D2E}.Release|x64.ActiveCfg = Release|x64
+ {03B833F5-4FD6-4FBE-AAF4-E3305CD56D2E}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -195,5 +216,6 @@ Global
{9D041710-2119-4230-BCF2-5FBE753FDE49} = {5E99A109-374E-4102-BE9B-99BA1FA8AA30}
{4DD6056F-8EEE-4C9A-B2A9-923F01A32E97} = {5E99A109-374E-4102-BE9B-99BA1FA8AA30}
{F94CCD79-AA11-42DF-AC8A-6C9D2238A883} = {5E99A109-374E-4102-BE9B-99BA1FA8AA30}
+ {03B833F5-4FD6-4FBE-AAF4-E3305CD56D2E} = {5E99A109-374E-4102-BE9B-99BA1FA8AA30}
EndGlobalSection
EndGlobal
diff --git a/astra_vc11.vcxproj b/astra_vc11.vcxproj
index 0cedf20..bc11b23 100644
--- a/astra_vc11.vcxproj
+++ b/astra_vc11.vcxproj
@@ -530,7 +530,7 @@
<ClCompile Include="src\Fourier.cpp" />
<ClCompile Include="src\GeometryUtil3D.cpp" />
<ClCompile Include="src\Globals.cpp" />
- <ClCompile Include="src\Logger.cpp" />
+ <ClCompile Include="src\Logging.cpp" />
<ClCompile Include="src\ParallelBeamBlobKernelProjector2D.cpp" />
<ClCompile Include="src\ParallelBeamLineKernelProjector2D.cpp" />
<ClCompile Include="src\ParallelBeamLinearKernelProjector2D.cpp" />
@@ -640,7 +640,7 @@
<ClInclude Include="include\astra\GeometryUtil2D.h" />
<ClInclude Include="include\astra\GeometryUtil3D.h" />
<ClInclude Include="include\astra\Globals.h" />
- <ClInclude Include="include\astra\Logger.h" />
+ <ClInclude Include="include\astra\Logging.h" />
<ClInclude Include="include\astra\ParallelBeamBlobKernelProjector2D.h" />
<ClInclude Include="include\astra\ParallelBeamLineKernelProjector2D.h" />
<ClInclude Include="include\astra\ParallelBeamLinearKernelProjector2D.h" />
@@ -669,6 +669,7 @@
<ClInclude Include="include\astra\VolumeGeometry3D.h" />
<ClInclude Include="include\astra\XMLDocument.h" />
<ClInclude Include="include\astra\XMLNode.h" />
+ <ClInclude Include="include\astra\clog.h" />
</ItemGroup>
<ItemGroup>
<CudaCompile Include="cuda\2d\algo.cu">
diff --git a/astra_vc11.vcxproj.filters b/astra_vc11.vcxproj.filters
index c7e4db9..a597962 100644
--- a/astra_vc11.vcxproj.filters
+++ b/astra_vc11.vcxproj.filters
@@ -162,7 +162,7 @@
<ClCompile Include="src\Globals.cpp">
<Filter>Global &amp; Other\source</Filter>
</ClCompile>
- <ClCompile Include="src\Logger.cpp">
+ <ClCompile Include="src\Logging.cpp">
<Filter>Global &amp; Other\source</Filter>
</ClCompile>
<ClCompile Include="src\PlatformDepSystemCode.cpp">
@@ -395,6 +395,9 @@
<ClInclude Include="include\astra\AstraObjectManager.h">
<Filter>Global &amp; Other\headers</Filter>
</ClInclude>
+ <ClInclude Include="include\astra\clog.h">
+ <Filter>Global &amp; Other\headers</Filter>
+ </ClInclude>
<ClInclude Include="include\astra\Config.h">
<Filter>Global &amp; Other\headers</Filter>
</ClInclude>
@@ -404,7 +407,7 @@
<ClInclude Include="include\astra\Globals.h">
<Filter>Global &amp; Other\headers</Filter>
</ClInclude>
- <ClInclude Include="include\astra\Logger.h">
+ <ClInclude Include="include\astra\Logging.h">
<Filter>Global &amp; Other\headers</Filter>
</ClInclude>
<ClInclude Include="include\astra\PlatformDepSystemCode.h">
diff --git a/build/linux/Makefile.in b/build/linux/Makefile.in
index f647299..0dfa15a 100644
--- a/build/linux/Makefile.in
+++ b/build/linux/Makefile.in
@@ -123,7 +123,7 @@ BASE_OBJECTS=\
src/Fourier.lo \
src/GeometryUtil3D.lo \
src/Globals.lo \
- src/Logger.lo \
+ src/Logging.lo \
src/ParallelBeamBlobKernelProjector2D.lo \
src/ParallelBeamLinearKernelProjector2D.lo \
src/ParallelBeamLineKernelProjector2D.lo \
@@ -221,6 +221,7 @@ TEST_OBJECTS=\
MATLAB_CXX_OBJECTS=\
matlab/mex/mexHelpFunctions.o \
matlab/mex/mexCopyDataHelpFunctions.o \
+ matlab/mex/mexInitFunctions.o \
matlab/mex/mexDataManagerHelpFunctions.o
MATLAB_MEX=\
@@ -230,6 +231,7 @@ MATLAB_MEX=\
matlab/mex/astra_mex_matrix_c.$(MEXSUFFIX) \
matlab/mex/astra_mex_projector_c.$(MEXSUFFIX) \
matlab/mex/astra_mex_projector3d_c.$(MEXSUFFIX) \
+ matlab/mex/astra_mex_log_c.$(MEXSUFFIX) \
matlab/mex/astra_mex_data3d_c.$(MEXSUFFIX)
diff --git a/build/msvc/gen.py b/build/msvc/gen.py
index c770641..9f5e367 100644
--- a/build/msvc/gen.py
+++ b/build/msvc/gen.py
@@ -5,6 +5,10 @@ import os
vcppguid = "8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942" # C++ project
siguid = "2150E333-8FDC-42A3-9474-1A3956D46DE8" # project group
+# to generate a new uuid:
+#
+# import uuid
+# uuid.uuid4().__str__().upper()
def create_mex_project(name, uuid11, uuid09):
return { "type": vcppguid, "name": name, "file11": "matlab\\mex\\" + name + "_vc11.vcxproj", "file09": "matlab\\mex\\" + name + "_vc09.vcproj", "uuid11": uuid11, "uuid09": uuid09, "files": [] }
@@ -19,6 +23,7 @@ P3 = create_mex_project("astra_mex_data3d", "0BEC029B-0929-4BF9-BD8B-9C9806A5206
P4 = create_mex_project("astra_mex_matrix", "9D041710-2119-4230-BCF2-5FBE753FDE49", "9D041710-2119-4230-BCF2-5FBE753FDE49")
P5 = create_mex_project("astra_mex_projector", "4DD6056F-8EEE-4C9A-B2A9-923F01A32E97", "4DD6056F-8EEE-4C9A-B2A9-923F01A32E97")
P6 = create_mex_project("astra_mex_projector3d", "F94CCD79-AA11-42DF-AC8A-6C9D2238A883", "F94CCD79-AA11-42DF-AC8A-6C9D2238A883")
+P7 = create_mex_project("astra_mex_log", "03B833F5-4FD6-4FBE-AAF4-E3305CD56D2E", "CA2840B3-DA68-41B5-AC57-F5DFD20ED8F8")
F_astra_mex = { "type": siguid,
"name": "astra_mex",
@@ -26,18 +31,22 @@ F_astra_mex = { "type": siguid,
"file09": "astra_mex",
"uuid11": "5E99A109-374E-4102-BE9B-99BA1FA8AA30",
"uuid09": "33EF0AC5-B475-40BF-BAE5-67075B204D10",
- "entries": [ P0, P1, P2, P3, P4, P5, P6 ] }
+ "entries": [ P0, P1, P2, P3, P4, P5, P6, P7 ] }
P0["files"] = [
"astra_mex_c.cpp",
"mexHelpFunctions.cpp",
"mexHelpFunctions.h",
+"mexInitFunctions.cpp",
+"mexInitFunctions.h",
]
P1["files"] = [
"astra_mex_algorithm_c.cpp",
"mexHelpFunctions.cpp",
"mexHelpFunctions.h",
+"mexInitFunctions.cpp",
+"mexInitFunctions.h",
]
P2["files"] = [
"astra_mex_data2d_c.cpp",
@@ -47,6 +56,8 @@ P2["files"] = [
"mexCopyDataHelpFunctions.h",
"mexDataManagerHelpFunctions.cpp",
"mexDataManagerHelpFunctions.h",
+"mexInitFunctions.cpp",
+"mexInitFunctions.h",
]
P3["files"] = [
"astra_mex_data3d_c.cpp",
@@ -56,22 +67,38 @@ P3["files"] = [
"mexCopyDataHelpFunctions.h",
"mexDataManagerHelpFunctions.cpp",
"mexDataManagerHelpFunctions.h",
+"mexInitFunctions.cpp",
+"mexInitFunctions.h",
]
P4["files"] = [
"astra_mex_matrix_c.cpp",
"mexHelpFunctions.cpp",
"mexHelpFunctions.h",
+"mexInitFunctions.cpp",
+"mexInitFunctions.h",
]
P5["files"] = [
"astra_mex_projector_c.cpp",
"mexHelpFunctions.cpp",
"mexHelpFunctions.h",
+"mexInitFunctions.cpp",
+"mexInitFunctions.h",
]
P6["files"] = [
"astra_mex_projector3d_c.cpp",
"mexHelpFunctions.cpp",
"mexHelpFunctions.h",
+"mexInitFunctions.cpp",
+"mexInitFunctions.h",
]
+P7["files"] = [
+"astra_mex_log_c.cpp",
+"mexHelpFunctions.cpp",
+"mexHelpFunctions.h",
+"mexInitFunctions.cpp",
+"mexInitFunctions.h",
+]
+
P_astra["filter_names"] = [
@@ -168,7 +195,7 @@ P_astra["filters"]["Global &amp; Other\\source"] = [
"src\\Config.cpp",
"src\\Fourier.cpp",
"src\\Globals.cpp",
-"src\\Logger.cpp",
+"src\\Logging.cpp",
"src\\PlatformDepSystemCode.cpp",
"src\\Utilities.cpp",
"src\\XMLDocument.cpp",
@@ -295,10 +322,11 @@ P_astra["filters"]["Global &amp; Other\\headers"] = [
"1c52efc8-a77e-4c72-b9be-f6429a87e6d7",
"include\\astra\\AstraObjectFactory.h",
"include\\astra\\AstraObjectManager.h",
+"include\\astra\\clog.h",
"include\\astra\\Config.h",
"include\\astra\\Fourier.h",
"include\\astra\\Globals.h",
-"include\\astra\\Logger.h",
+"include\\astra\\Logging.h",
"include\\astra\\PlatformDepSystemCode.h",
"include\\astra\\Singleton.h",
"include\\astra\\TypeList.h",
@@ -379,7 +407,7 @@ for f in P_astra["filters"]:
P_astra["files"].extend(P_astra["filters"][f][1:])
P_astra["files"].sort()
-projects = [ P_astra, F_astra_mex, P0, P1, P2, P3, P4, P5, P6 ]
+projects = [ P_astra, F_astra_mex, P0, P1, P2, P3, P4, P5, P6, P7 ]
bom = "\xef\xbb\xbf"
@@ -1081,6 +1109,7 @@ if sys.argv[1] in ["vc11", "all"]:
write_mex_project11(P4)
write_mex_project11(P5)
write_mex_project11(P6)
+ write_mex_project11(P7)
if sys.argv[1] in ["vc09", "all"]:
# HACK
@@ -1095,3 +1124,4 @@ if sys.argv[1] in ["vc09", "all"]:
write_mex_project09(P4)
write_mex_project09(P5)
write_mex_project09(P6)
+ write_mex_project09(P7)
diff --git a/cuda/2d/astra.cu b/cuda/2d/astra.cu
index 0b5be06..2f72db0 100644
--- a/cuda/2d/astra.cu
+++ b/cuda/2d/astra.cu
@@ -42,12 +42,13 @@ $Id$
#include <fstream>
#include <cuda.h>
-#include "../../include/astra/Logger.h"
#include "../../include/astra/VolumeGeometry2D.h"
#include "../../include/astra/ParallelProjectionGeometry2D.h"
#include "../../include/astra/FanFlatProjectionGeometry2D.h"
#include "../../include/astra/FanFlatVecProjectionGeometry2D.h"
+#include "../../include/astra/Logging.h"
+
// For fan beam FBP weighting
#include "../3d/fdk.h"
@@ -538,7 +539,7 @@ bool AstraFBP::setFilter(E_FBPFILTER _eFilter, const float * _pfHostFilter /* =
int iMaxFilterIndex = iStartFilterIndex + iUsedFilterWidth;
int iFilterShiftSize = _iFilterWidth / 2;
-
+
for(int iDetectorIndex = iStartFilterIndex; iDetectorIndex < iMaxFilterIndex; iDetectorIndex++)
{
int iFFTInFilterIndex = (iDetectorIndex + iFFTRealDetCount - iFilterShiftSize) % iFFTRealDetCount;
@@ -563,7 +564,7 @@ bool AstraFBP::setFilter(E_FBPFILTER _eFilter, const float * _pfHostFilter /* =
}
default:
{
- fprintf(stderr, "AstraFBP::setFilter: Unknown filter type requested");
+ ASTRA_ERROR("AstraFBP::setFilter: Unknown filter type requested");
delete [] pHostFilter;
return false;
}
diff --git a/cuda/2d/fft.cu b/cuda/2d/fft.cu
index d105e29..2bfd493 100644
--- a/cuda/2d/fft.cu
+++ b/cuda/2d/fft.cu
@@ -34,7 +34,7 @@ $Id$
#include <cuda.h>
#include <fstream>
-#include "../../include/astra/Logger.h"
+#include "../../include/astra/Logging.h"
using namespace astra;
@@ -43,25 +43,22 @@ using namespace astra;
#define CHECK_ERROR(errorMessage) do { \
cudaError_t err = cudaThreadSynchronize(); \
if( cudaSuccess != err) { \
- fprintf(stderr, "Cuda error: %s in file '%s' in line %i : %s.\n", \
- errorMessage, __FILE__, __LINE__, cudaGetErrorString( err) );\
- CLogger::writeTerminalCUDAError(__FILE__, __LINE__, cudaGetErrorString( err)); \
+ ASTRA_ERROR("Cuda error %s : %s", \
+ errorMessage,cudaGetErrorString( err)); \
exit(EXIT_FAILURE); \
} } while (0)
#define SAFE_CALL( call) do { \
cudaError err = call; \
if( cudaSuccess != err) { \
- fprintf(stderr, "Cuda error in file '%s' in line %i : %s.\n", \
- __FILE__, __LINE__, cudaGetErrorString( err) ); \
- CLogger::writeTerminalCUDAError(__FILE__, __LINE__, cudaGetErrorString( err)); \
+ ASTRA_ERROR("Cuda error: %s ", \
+ cudaGetErrorString( err)); \
exit(EXIT_FAILURE); \
} \
err = cudaThreadSynchronize(); \
if( cudaSuccess != err) { \
- fprintf(stderr, "Cuda error in file '%s' in line %i : %s.\n", \
- __FILE__, __LINE__, cudaGetErrorString( err) ); \
- CLogger::writeTerminalCUDAError(__FILE__, __LINE__, cudaGetErrorString( err)); \
+ ASTRA_ERROR("Cuda error: %s : ", \
+ cudaGetErrorString( err)); \
exit(EXIT_FAILURE); \
} } while (0)
@@ -140,7 +137,7 @@ static bool invokeCudaFFT(int _iProjectionCount, int _iDetectorCount,
result = cufftPlan1d(&plan, _iDetectorCount, CUFFT_R2C, _iProjectionCount);
if(result != CUFFT_SUCCESS)
{
- std::cerr << "Failed to plan 1d r2c fft" << std::endl;
+ ASTRA_ERROR("Failed to plan 1d r2c fft");
return false;
}
@@ -149,7 +146,7 @@ static bool invokeCudaFFT(int _iProjectionCount, int _iDetectorCount,
if(result != CUFFT_SUCCESS)
{
- std::cerr << "Failed to exec 1d r2c fft" << std::endl;
+ ASTRA_ERROR("Failed to exec 1d r2c fft");
return false;
}
@@ -166,18 +163,18 @@ static bool invokeCudaIFFT(int _iProjectionCount, int _iDetectorCount,
result = cufftPlan1d(&plan, _iDetectorCount, CUFFT_C2R, _iProjectionCount);
if(result != CUFFT_SUCCESS)
{
- std::cerr << "Failed to plan 1d c2r fft" << std::endl;
+ ASTRA_ERROR("Failed to plan 1d c2r fft");
return false;
}
// todo: why do we have to get rid of the const qualifier?
result = cufftExecC2R(plan, (cufftComplex *)_pDevSourceComplex,
- (cufftReal *)_pfDevTarget);
+ (cufftReal *)_pfDevTarget);
cufftDestroy(plan);
if(result != CUFFT_SUCCESS)
{
- std::cerr << "Failed to exec 1d c2r fft" << std::endl;
+ ASTRA_ERROR("Failed to exec 1d c2r fft");
return false;
}
@@ -257,7 +254,7 @@ bool runCudaIFFT(int _iProjectionCount, const cufftComplex* _pDevSourceComplex,
}
rescaleInverseFourier(_iProjectionCount, _iFFTRealDetectorCount,
- pfDevRealFFTTarget);
+ pfDevRealFFTTarget);
SAFE_CALL(cudaMemset(_pfRealTarget, 0, sizeof(float) * _iProjectionCount * _iTargetPitch));
@@ -460,7 +457,7 @@ void genFilter(E_FBPFILTER _eFilter, float _fD, int _iProjectionCount,
const float fA1 = 0.48f;
const float fA2 = 0.38f;
float fNMinusOne = (float)(_iFFTFourierDetectorCount) - 1.0f;
-
+
for(int iDetectorIndex = 1; iDetectorIndex < _iFFTFourierDetectorCount; iDetectorIndex++)
{
float fSmallN = (float)iDetectorIndex;
@@ -633,7 +630,7 @@ void genFilter(E_FBPFILTER _eFilter, float _fD, int _iProjectionCount,
}
default:
{
- std::cerr << "Cannot serve requested filter" << std::endl;
+ ASTRA_ERROR("Cannot serve requested filter");
}
}
@@ -746,7 +743,7 @@ void testCudaFFT()
{
for(int iDetectorIndex = 0; iDetectorIndex < iDetectorCount; iDetectorIndex++)
{
-// int
+// int
// pfHostProj[iIndex] = (float)rand() / (float)RAND_MAX;
}
@@ -767,13 +764,13 @@ void testCudaFFT()
result = cufftPlan1d(&plan, iDetectorCount, CUFFT_R2C, iProjectionCount);
if(result != CUFFT_SUCCESS)
{
- cerr << "Failed to plan 1d r2c fft" << endl;
+ ASTRA_ERROR("Failed to plan 1d r2c fft");
}
result = cufftExecR2C(plan, pfDevProj, pDevFourProj);
if(result != CUFFT_SUCCESS)
{
- cerr << "Failed to exec 1d r2c fft" << endl;
+ ASTRA_ERROR("Failed to exec 1d r2c fft");
}
cufftDestroy(plan);
@@ -787,7 +784,7 @@ void testCudaFFT()
float * pfHostFourProjImaginary = new float[iTotalElementCount];
convertComplexToRealImg(pHostFourProj, iTotalElementCount, pfHostFourProjReal, pfHostFourProjImaginary);
-
+
writeToMatlabFile("proj_four_real.mat", pfHostFourProjReal, iProjectionCount, iDetectorCount);
writeToMatlabFile("proj_four_imaginary.mat", pfHostFourProjImaginary, iProjectionCount, iDetectorCount);
@@ -797,13 +794,13 @@ void testCudaFFT()
result = cufftPlan1d(&plan, iDetectorCount, CUFFT_C2R, iProjectionCount);
if(result != CUFFT_SUCCESS)
{
- cerr << "Failed to plan 1d c2r fft" << endl;
+ ASTRA_ERROR("Failed to plan 1d c2r fft");
}
result = cufftExecC2R(plan, pDevFourProj, pfDevInFourProj);
if(result != CUFFT_SUCCESS)
{
- cerr << "Failed to exec 1d c2r fft" << endl;
+ ASTRA_ERROR("Failed to exec 1d c2r fft");
}
cufftDestroy(plan);
diff --git a/cuda/2d/util.cu b/cuda/2d/util.cu
index 81e368f..a4f8f3e 100644
--- a/cuda/2d/util.cu
+++ b/cuda/2d/util.cu
@@ -30,6 +30,8 @@ $Id$
#include <cassert>
#include "util.h"
+#include "../../include/astra/Logging.h"
+
namespace astraCUDA {
bool copyVolumeToDevice(const float* in_data, unsigned int in_pitch,
@@ -91,7 +93,7 @@ bool allocateVolume(float*& ptr, unsigned int width, unsigned int height, unsign
cudaError_t ret = cudaMallocPitch((void**)&ptr, &p, sizeof(float)*width, height);
if (ret != cudaSuccess) {
reportCudaError(ret);
- fprintf(stderr, "Failed to allocate %dx%d GPU buffer\n", width, height);
+ ASTRA_ERROR("Failed to allocate %dx%d GPU buffer", width, height);
return false;
}
@@ -259,7 +261,7 @@ bool cudaTextForceKernelsCompletion()
cudaError_t returnedCudaError = cudaThreadSynchronize();
if(returnedCudaError != cudaSuccess) {
- fprintf(stderr, "Failed to force completion of cuda kernels: %d: %s.\n", returnedCudaError, cudaGetErrorString(returnedCudaError));
+ ASTRA_ERROR("Failed to force completion of cuda kernels: %d: %s.", returnedCudaError, cudaGetErrorString(returnedCudaError));
return false;
}
@@ -269,7 +271,7 @@ bool cudaTextForceKernelsCompletion()
void reportCudaError(cudaError_t err)
{
if(err != cudaSuccess)
- fprintf(stderr, "CUDA error %d: %s.\n", err, cudaGetErrorString(err));
+ ASTRA_ERROR("CUDA error %d: %s.", err, cudaGetErrorString(err));
}
diff --git a/cuda/3d/util3d.cu b/cuda/3d/util3d.cu
index d85a928..537ed69 100644
--- a/cuda/3d/util3d.cu
+++ b/cuda/3d/util3d.cu
@@ -31,6 +31,8 @@ $Id$
#include "util3d.h"
#include "../2d/util.h"
+#include "../../include/astra/Logging.h"
+
namespace astraCUDA3d {
@@ -46,7 +48,7 @@ cudaPitchedPtr allocateVolumeData(const SDimensions3D& dims)
cudaError err = cudaMalloc3D(&volData, extentV);
if (err != cudaSuccess) {
astraCUDA::reportCudaError(err);
- fprintf(stderr, "Failed to allocate %dx%dx%d GPU buffer\n", dims.iVolX, dims.iVolY, dims.iVolZ);
+ ASTRA_ERROR("Failed to allocate %dx%dx%d GPU buffer", dims.iVolX, dims.iVolY, dims.iVolZ);
volData.ptr = 0;
// TODO: return 0 somehow?
}
@@ -65,7 +67,7 @@ cudaPitchedPtr allocateProjectionData(const SDimensions3D& dims)
cudaError err = cudaMalloc3D(&projData, extentP);
if (err != cudaSuccess) {
astraCUDA::reportCudaError(err);
- fprintf(stderr, "Failed to allocate %dx%dx%d GPU buffer\n", dims.iProjU, dims.iProjAngles, dims.iProjV);
+ ASTRA_ERROR("Failed to allocate %dx%dx%d GPU buffer", dims.iProjU, dims.iProjAngles, dims.iProjV);
projData.ptr = 0;
// TODO: return 0 somehow?
}
@@ -303,7 +305,7 @@ cudaArray* allocateVolumeArray(const SDimensions3D& dims)
cudaError err = cudaMalloc3DArray(&cuArray, &channelDesc, extentA);
if (err != cudaSuccess) {
astraCUDA::reportCudaError(err);
- fprintf(stderr, "Failed to allocate %dx%dx%d GPU array\n", dims.iVolX, dims.iVolY, dims.iVolZ);
+ ASTRA_ERROR("Failed to allocate %dx%dx%d GPU array", dims.iVolX, dims.iVolY, dims.iVolZ);
return 0;
}
@@ -321,7 +323,7 @@ cudaArray* allocateProjectionArray(const SDimensions3D& dims)
if (err != cudaSuccess) {
astraCUDA::reportCudaError(err);
- fprintf(stderr, "Failed to allocate %dx%dx%d GPU array\n", dims.iProjU, dims.iProjAngles, dims.iProjV);
+ ASTRA_ERROR("Failed to allocate %dx%dx%d GPU array", dims.iProjU, dims.iProjAngles, dims.iProjV);
return 0;
}
@@ -397,7 +399,7 @@ bool cudaTextForceKernelsCompletion()
cudaError_t returnedCudaError = cudaThreadSynchronize();
if(returnedCudaError != cudaSuccess) {
- fprintf(stderr, "Failed to force completion of cuda kernels: %d: %s.\n", returnedCudaError, cudaGetErrorString(returnedCudaError));
+ ASTRA_ERROR("Failed to force completion of cuda kernels: %d: %s.", returnedCudaError, cudaGetErrorString(returnedCudaError));
return false;
}
diff --git a/include/astra/Logger.h b/include/astra/Logger.h
deleted file mode 100644
index 34fd364..0000000
--- a/include/astra/Logger.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
------------------------------------------------------------------------
-Copyright: 2010-2015, iMinds-Vision Lab, University of Antwerp
- 2014-2015, CWI, Amsterdam
-
-Contact: astra@uantwerpen.be
-Website: http://sf.net/projects/astra-toolbox
-
-This file is part of the ASTRA Toolbox.
-
-
-The ASTRA Toolbox is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-The ASTRA Toolbox is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>.
-
------------------------------------------------------------------------
-$Id$
-*/
-
-#ifndef _INC_ASTRA_LOGGER
-#define _INC_ASTRA_LOGGER
-
-#include <cstdio>
-
-namespace astra
-{
-
-/**
- * This is the first stab at a decent logger. If the file "astra_logger.txt", it will be replaced
- * with the text sent to this logger. If the file doesn't exist when the app starts, nothing is written.
- */
-class CLogger
-{
- static std::FILE * m_pOutFile;
- static bool m_bInitialized;
-
- static void _assureIsInitialized();
-
- CLogger();
-
-public:
-
- /**
- * Writes a line to the log file (newline is added). Ignored if logging is turned off.
- *
- * @param _text char pointer to text in line
- */
- static void writeLine(const char * _text);
-
- /**
- * Formats and writes a CUDA error to the log file. Ignored if logging is turned off.
- *
- * @param _fileName filename where error occurred (typically __FILE__)
- * @param _line line in file (typically __LINE__)
- * @param _errString string describing the error, can be output of cudaGetErrorString
- */
- static void writeTerminalCUDAError(const char * _fileName, int _iLine, const char * _errString);
-};
-
-}
-
-#endif /* _INC_ASTRA_LOGGER */
-
diff --git a/include/astra/Logging.h b/include/astra/Logging.h
new file mode 100644
index 0000000..8e19ea4
--- /dev/null
+++ b/include/astra/Logging.h
@@ -0,0 +1,159 @@
+/*
+-----------------------------------------------------------------------
+Copyright: 2010-2015, iMinds-Vision Lab, University of Antwerp
+ 2014-2015, CWI, Amsterdam
+
+Contact: astra@uantwerpen.be
+Website: http://sf.net/projects/astra-toolbox
+
+This file is part of the ASTRA Toolbox.
+
+
+The ASTRA Toolbox is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+The ASTRA Toolbox is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>.
+
+-----------------------------------------------------------------------
+$Id$
+*/
+
+#ifndef _INC_ASTRA_LOGGING
+#define _INC_ASTRA_LOGGING
+
+#include "astra/Globals.h"
+
+#define ASTRA_DEBUG(...) astra::CLogger::debug(__FILE__,__LINE__, __VA_ARGS__)
+#define ASTRA_INFO(...) astra::CLogger::info(__FILE__,__LINE__, __VA_ARGS__)
+#define ASTRA_WARN(...) astra::CLogger::warn(__FILE__,__LINE__, __VA_ARGS__)
+#define ASTRA_ERROR(...) astra::CLogger::error(__FILE__,__LINE__, __VA_ARGS__)
+
+namespace astra
+{
+
+enum log_level {
+ LOG_DEBUG,
+ LOG_INFO,
+ LOG_WARN,
+ LOG_ERROR
+};
+
+class _AstraExport CLogger
+{
+ CLogger();
+ ~CLogger();
+ static bool m_bEnabledFile;
+ static bool m_bEnabledScreen;
+ static bool m_bFileProvided;
+ static bool m_bInitialized;
+ static void _assureIsInitialized();
+ static void _setLevel(int id, log_level m_eLevel);
+
+public:
+
+ /**
+ * Writes a line to the log file (newline is added). Ignored if logging is turned off.
+ *
+ * @param sfile
+ * The name of the source file making this log call (e.g. __FILE__).
+ *
+ * @param sline
+ * The line number of the call in the source code (e.g. __LINE__).
+ *
+ * @param id
+ * The id of the logger to write to.
+ *
+ * @param fmt
+ * The format string for the message (printf formatting).
+ *
+ * @param ...
+ * Any additional format arguments.
+ */
+ static void debug(const char *sfile, int sline, const char *fmt, ...);
+ static void info(const char *sfile, int sline, const char *fmt, ...);
+ static void warn(const char *sfile, int sline, const char *fmt, ...);
+ static void error(const char *sfile, int sline, const char *fmt, ...);
+
+ /**
+ * Sets the file to log to, with logging level.
+ *
+ * @param filename
+ * File to log to.
+ *
+ * @param m_eLevel
+ * Logging level (LOG_DEBUG, LOG_WARN, LOG_INFO, LOG_ERROR).
+ *
+ */
+ static void setOutputFile(const char *filename, log_level m_eLevel);
+
+ /**
+ * Sets the screen to log to, with logging level.
+ *
+ * @param screen_fd
+ * Screen file descriptor (1 for stdout, 2 for stderr)
+ *
+ * @param m_eLevel
+ * Logging level (LOG_DEBUG, LOG_WARN, LOG_INFO, LOG_ERROR).
+ *
+ */
+ static void setOutputScreen(int fd, log_level m_eLevel);
+
+ /**
+ * Set the format string for log messages. Here are the substitutions you may
+ * use:
+ *
+ * %f: Source file name generating the log call.
+ * %n: Source line number where the log call was made.
+ * %m: The message text sent to the logger (after printf formatting).
+ * %d: The current date, formatted using the logger's date format.
+ * %t: The current time, formatted using the logger's time format.
+ * %l: The log level (one of "DEBUG", "INFO", "WARN", or "ERROR").
+ * %%: A literal percent sign.
+ *
+ * The default format string is "%d %t %f(%n): %l: %m\n".
+ *
+ * @param fmt
+ * The new format string, which must be less than 256 bytes.
+ * You probably will want to end this with a newline (\n).
+ *
+ */
+ static void setFormatFile(const char *fmt);
+ static void setFormatScreen(const char *fmt);
+
+
+ /**
+ * Enable logging.
+ *
+ */
+ static void enable();
+ static void enableScreen();
+ static void enableFile();
+
+ /**
+ * Disable logging.
+ *
+ */
+ static void disable();
+ static void disableScreen();
+ static void disableFile();
+
+ /**
+ * Set callback function for logging to screen.
+ * @return whether callback was set succesfully.
+ *
+ */
+ static bool setCallbackScreen(void (*cb)(const char *msg, size_t len));
+
+};
+
+}
+
+#endif /* _INC_ASTRA_LOGGING */
diff --git a/include/astra/clog.h b/include/astra/clog.h
new file mode 100644
index 0000000..6ffb660
--- /dev/null
+++ b/include/astra/clog.h
@@ -0,0 +1,693 @@
+/* clog: Extremely simple logger for C.
+ *
+ * Features:
+ * - Implemented purely as a single header file.
+ * - Create multiple loggers.
+ * - Four log levels (debug, info, warn, error).
+ * - Custom formats.
+ * - Fast.
+ *
+ * Dependencies:
+ * - Should conform to C89, C++98 (but requires vsnprintf, unfortunately).
+ * - POSIX environment.
+ *
+ * USAGE:
+ *
+ * Include this header in any file that wishes to write to logger(s). In
+ * exactly one file (per executable), define CLOG_MAIN first (e.g. in your
+ * main .c file).
+ *
+ * #define CLOG_MAIN
+ * #include "clog.h"
+ *
+ * This will define the actual objects that all the other units will use.
+ *
+ * Loggers are identified by integers (0 - 15). It's expected that you'll
+ * create meaningful constants and then refer to the loggers as such.
+ *
+ * Example:
+ *
+ * const int MY_LOGGER = 0;
+ *
+ * int main() {
+ * int r;
+ * r = clog_init_path(MY_LOGGER, "my_log.txt");
+ * if (r != 0) {
+ * fprintf(stderr, "Logger initialization failed.\n");
+ * return 1;
+ * }
+ * clog_info(CLOG(MY_LOGGER), "Hello, world!");
+ * clog_free(MY_LOGGER);
+ * return 0;
+ * }
+ *
+ * The CLOG macro used in the call to clog_info is a helper that passes the
+ * __FILE__ and __LINE__ parameters for you, so you don't have to type them
+ * every time. (It could be prettier with variadic macros, but that requires
+ * C99 or C++11 to be standards compliant.)
+ *
+ * Errors encountered by clog will be printed to stderr. You can suppress
+ * these by defining a macro called CLOG_SILENT before including clog.h.
+ *
+ * License: Do whatever you want. It would be nice if you contribute
+ * improvements as pull requests here:
+ *
+ * https://github.com/mmueller/clog
+ *
+ * Copyright 2013 Mike Mueller <mike@subfocal.net>.
+ *
+ * As is; no warranty is provided; use at your own risk.
+ */
+
+#ifndef __CLOG_H__
+#define __CLOG_H__
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <time.h>
+#ifndef _MSC_VER
+#include <unistd.h>
+#else
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#include <io.h>
+#define open _open
+#define close _close
+#define write _write
+#define snprintf _snprintf
+#endif
+
+/* Number of loggers that can be defined. */
+#define CLOG_MAX_LOGGERS 16
+
+/* Format strings cannot be longer than this. */
+#define CLOG_FORMAT_LENGTH 256
+
+/* Formatted times and dates should be less than this length. If they are not,
+ * they will not appear in the log. */
+#define CLOG_DATETIME_LENGTH 256
+
+/* Default format strings. */
+#define CLOG_DEFAULT_FORMAT "%d %t %f(%n): %l: %m\n"
+#define CLOG_DEFAULT_DATE_FORMAT "%Y-%m-%d"
+#define CLOG_DEFAULT_TIME_FORMAT "%H:%M:%S"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum clog_level {
+ CLOG_DEBUG,
+ CLOG_INFO,
+ CLOG_WARN,
+ CLOG_ERROR
+};
+
+struct clog;
+
+/**
+ * Create a new logger writing to the given file path. The file will always
+ * be opened in append mode.
+ *
+ * @param id
+ * A constant integer between 0 and 15 that uniquely identifies this logger.
+ *
+ * @param path
+ * Path to the file where log messages will be written.
+ *
+ * @return
+ * Zero on success, non-zero on failure.
+ */
+int clog_init_path(int id, const char *const path);
+
+/**
+ * Create a new logger writing to a file descriptor.
+ *
+ * @param id
+ * A constant integer between 0 and 15 that uniquely identifies this logger.
+ *
+ * @param fd
+ * The file descriptor where log messages will be written.
+ *
+ * @return
+ * Zero on success, non-zero on failure.
+ */
+int clog_init_fd(int id, int fd);
+
+/**
+ * Destroy (clean up) a logger. You should do this at the end of execution,
+ * or when you are done using the logger.
+ *
+ * @param id
+ * The id of the logger to destroy.
+ */
+void clog_free(int id);
+
+#define CLOG(id) __FILE__, __LINE__, id
+
+/**
+ * Log functions (one per level). Call these to write messages to the log
+ * file. The first three arguments can be replaced with a call to the CLOG
+ * macro defined above, e.g.:
+ *
+ * clog_debug(CLOG(MY_LOGGER_ID), "This is a log message.");
+ *
+ * @param sfile
+ * The name of the source file making this log call (e.g. __FILE__).
+ *
+ * @param sline
+ * The line number of the call in the source code (e.g. __LINE__).
+ *
+ * @param id
+ * The id of the logger to write to.
+ *
+ * @param fmt
+ * The format string for the message (printf formatting).
+ *
+ * @param ...
+ * Any additional format arguments.
+ */
+void clog_debug(const char *sfile, int sline, int id, const char *fmt, va_list ap);
+void clog_info(const char *sfile, int sline, int id, const char *fmt, va_list ap);
+void clog_warn(const char *sfile, int sline, int id, const char *fmt, va_list ap);
+void clog_error(const char *sfile, int sline, int id, const char *fmt, va_list ap);
+
+/**
+ * Set the minimum level of messages that should be written to the log.
+ * Messages below this level will not be written. By default, loggers are
+ * created with level == CLOG_DEBUG.
+ *
+ * @param id
+ * The identifier of the logger.
+ *
+ * @param level
+ * The new minimum log level.
+ *
+ * @return
+ * Zero on success, non-zero on failure.
+ */
+int clog_set_level(int id, enum clog_level level);
+
+/**
+ * Set the format string used for times. See strftime(3) for how this string
+ * should be defined. The default format string is CLOG_DEFAULT_TIME_FORMAT.
+ *
+ * @param fmt
+ * The new format string, which must be less than CLOG_FORMAT_LENGTH bytes.
+ *
+ * @return
+ * Zero on success, non-zero on failure.
+ */
+int clog_set_time_fmt(int id, const char *fmt);
+
+/**
+ * Set the format string used for dates. See strftime(3) for how this string
+ * should be defined. The default format string is CLOG_DEFAULT_DATE_FORMAT.
+ *
+ * @param fmt
+ * The new format string, which must be less than CLOG_FORMAT_LENGTH bytes.
+ *
+ * @return
+ * Zero on success, non-zero on failure.
+ */
+int clog_set_date_fmt(int id, const char *fmt);
+
+/**
+ * Set the format string for log messages. Here are the substitutions you may
+ * use:
+ *
+ * %f: Source file name generating the log call.
+ * %n: Source line number where the log call was made.
+ * %m: The message text sent to the logger (after printf formatting).
+ * %d: The current date, formatted using the logger's date format.
+ * %t: The current time, formatted using the logger's time format.
+ * %l: The log level (one of "DEBUG", "INFO", "WARN", or "ERROR").
+ * %%: A literal percent sign.
+ *
+ * The default format string is CLOG_DEFAULT_FORMAT.
+ *
+ * @param fmt
+ * The new format string, which must be less than CLOG_FORMAT_LENGTH bytes.
+ * You probably will want to end this with a newline (\n).
+ *
+ * @return
+ * Zero on success, non-zero on failure.
+ */
+int clog_set_fmt(int id, const char *fmt);
+
+/**
+ * Set the callback function.
+ *
+ * @param cb
+ * The new callback function.
+ *
+ * @return
+ * Zero on success, non-zero on failure.
+ */
+int clog_set_cb(int id, void (*cb)(const char *msg, size_t len));
+
+/**
+ * Set the file descriptor.
+ *
+ * @param id
+ * The identifier of the logger.
+ *
+ * @param fd
+ * The new file descriptor.
+ *
+ * @return
+ * Zero on success, non-zero on failure.
+ */
+int clog_set_fd(int id, int fd);
+
+
+/*
+ * No need to read below this point.
+ */
+
+/**
+ * The C logger structure.
+ */
+struct clog {
+
+ /* The current level of this logger. Messages below it will be dropped. */
+ enum clog_level level;
+
+ /* The file being written. */
+ int fd;
+
+ /* The format specifier. */
+ char fmt[CLOG_FORMAT_LENGTH];
+
+ /* Date format */
+ char date_fmt[CLOG_FORMAT_LENGTH];
+
+ /* Time format */
+ char time_fmt[CLOG_FORMAT_LENGTH];
+
+ /* Tracks whether the fd needs to be closed eventually. */
+ int opened;
+
+ /* Callback function for each log message. */
+ void (*cb)(const char *msg, size_t len);
+};
+
+void _clog_err(const char *fmt, ...);
+
+#ifdef CLOG_MAIN
+struct clog *_clog_loggers[CLOG_MAX_LOGGERS] = { 0 };
+#else
+extern struct clog *_clog_loggers[CLOG_MAX_LOGGERS];
+#endif
+
+#ifdef CLOG_MAIN
+
+const char *const CLOG_LEVEL_NAMES[] = {
+ "Debug",
+ "Info",
+ "Warning",
+ "Error",
+};
+
+int
+clog_init_path(int id, const char *const path)
+{
+ int fd = open(path, O_CREAT | O_WRONLY | O_APPEND, 0666);
+ if (fd == -1) {
+ _clog_err("Unable to open %s: %s\n", path, strerror(errno));
+ return 1;
+ }
+ if (clog_init_fd(id, fd)) {
+ close(fd);
+ return 1;
+ }
+ _clog_loggers[id]->opened = 1;
+ return 0;
+}
+
+int
+clog_init_fd(int id, int fd)
+{
+ struct clog *logger;
+
+ if (_clog_loggers[id] != NULL) {
+ _clog_err("Logger %d already initialized.\n", id);
+ return 1;
+ }
+
+ logger = (struct clog *) malloc(sizeof(struct clog));
+ if (logger == NULL) {
+ _clog_err("Failed to allocate logger: %s\n", strerror(errno));
+ return 1;
+ }
+
+ logger->level = CLOG_DEBUG;
+ logger->fd = fd;
+ logger->opened = 0;
+ strcpy(logger->fmt, CLOG_DEFAULT_FORMAT);
+ strcpy(logger->date_fmt, CLOG_DEFAULT_DATE_FORMAT);
+ strcpy(logger->time_fmt, CLOG_DEFAULT_TIME_FORMAT);
+ logger->cb = NULL;
+
+ _clog_loggers[id] = logger;
+ return 0;
+}
+
+void
+clog_free(int id)
+{
+ if (_clog_loggers[id]) {
+ if (_clog_loggers[id]->opened) {
+ close(_clog_loggers[id]->fd);
+ }
+ free(_clog_loggers[id]);
+ _clog_loggers[id]=NULL;
+ }
+}
+
+int
+clog_set_level(int id, enum clog_level level)
+{
+ if (_clog_loggers[id] == NULL) {
+ return 1;
+ }
+ if ((unsigned) level > CLOG_ERROR) {
+ return 1;
+ }
+ _clog_loggers[id]->level = level;
+ return 0;
+}
+
+int
+clog_set_fd(int id, int fd)
+{
+ if (_clog_loggers[id] == NULL) {
+ return 1;
+ }
+ _clog_loggers[id]->fd = fd;
+ return 0;
+}
+
+int
+clog_set_time_fmt(int id, const char *fmt)
+{
+ struct clog *logger = _clog_loggers[id];
+ if (logger == NULL) {
+ _clog_err("clog_set_time_fmt: No such logger: %d\n", id);
+ return 1;
+ }
+ if (strlen(fmt) >= CLOG_FORMAT_LENGTH) {
+ _clog_err("clog_set_time_fmt: Format specifier too long.\n");
+ return 1;
+ }
+ strcpy(logger->time_fmt, fmt);
+ return 0;
+}
+
+int
+clog_set_date_fmt(int id, const char *fmt)
+{
+ struct clog *logger = _clog_loggers[id];
+ if (logger == NULL) {
+ _clog_err("clog_set_date_fmt: No such logger: %d\n", id);
+ return 1;
+ }
+ if (strlen(fmt) >= CLOG_FORMAT_LENGTH) {
+ _clog_err("clog_set_date_fmt: Format specifier too long.\n");
+ return 1;
+ }
+ strcpy(logger->date_fmt, fmt);
+ return 0;
+}
+
+int
+clog_set_fmt(int id, const char *fmt)
+{
+ struct clog *logger = _clog_loggers[id];
+ if (logger == NULL) {
+ _clog_err("clog_set_fmt: No such logger: %d\n", id);
+ return 1;
+ }
+ if (strlen(fmt) >= CLOG_FORMAT_LENGTH) {
+ _clog_err("clog_set_fmt: Format specifier too long.\n");
+ return 1;
+ }
+ strcpy(logger->fmt, fmt);
+ return 0;
+}
+
+int
+clog_set_cb(int id, void (*cb)(const char *msg, size_t len))
+{
+ struct clog *logger = _clog_loggers[id];
+ if (logger == NULL) {
+ _clog_err("clog_set_cb: No such logger: %d\n", id);
+ return 1;
+ }
+ logger->cb = cb;
+ return 0;
+}
+
+/* Internal functions */
+
+size_t
+_clog_append_str(char **dst, char *orig_buf, const char *src, size_t cur_size)
+{
+ size_t new_size = cur_size;
+
+ while (strlen(*dst) + strlen(src) >= new_size) {
+ new_size *= 2;
+ }
+ if (new_size != cur_size) {
+ if (*dst == orig_buf) {
+ *dst = (char *) malloc(new_size);
+ strcpy(*dst, orig_buf);
+ } else {
+ *dst = (char *) realloc(*dst, new_size);
+ }
+ }
+
+ strcat(*dst, src);
+ return new_size;
+}
+
+size_t
+_clog_append_int(char **dst, char *orig_buf, long int d, size_t cur_size)
+{
+ char buf[40]; /* Enough for 128-bit decimal */
+ if (snprintf(buf, 40, "%ld", d) >= 40) {
+ return cur_size;
+ }
+ return _clog_append_str(dst, orig_buf, buf, cur_size);
+}
+
+size_t
+_clog_append_time(char **dst, char *orig_buf, struct tm *lt,
+ const char *fmt, size_t cur_size)
+{
+ char buf[CLOG_DATETIME_LENGTH];
+ size_t result = strftime(buf, CLOG_DATETIME_LENGTH, fmt, lt);
+
+ if (result > 0) {
+ return _clog_append_str(dst, orig_buf, buf, cur_size);
+ }
+
+ return cur_size;
+}
+
+const char *
+_clog_basename(const char *path)
+{
+ const char *slash = strrchr(path, '/');
+ if (slash) {
+ path = slash + 1;
+ }
+#ifdef _WIN32
+ slash = strrchr(path, '\\');
+ if (slash) {
+ path = slash + 1;
+ }
+#endif
+ return path;
+}
+
+char *
+_clog_format(const struct clog *logger, char buf[], size_t buf_size,
+ const char *sfile, int sline, const char *level,
+ const char *message)
+{
+ size_t cur_size = buf_size;
+ char *result = buf;
+ enum { NORMAL, SUBST } state = NORMAL;
+ size_t fmtlen = strlen(logger->fmt);
+ size_t i;
+ time_t t = time(NULL);
+ struct tm *lt = localtime(&t);
+
+ sfile = _clog_basename(sfile);
+ result[0] = 0;
+ for (i = 0; i < fmtlen; ++i) {
+ if (state == NORMAL) {
+ if (logger->fmt[i] == '%') {
+ state = SUBST;
+ } else {
+ char str[2] = { 0 };
+ str[0] = logger->fmt[i];
+ cur_size = _clog_append_str(&result, buf, str, cur_size);
+ }
+ } else {
+ switch (logger->fmt[i]) {
+ case '%':
+ cur_size = _clog_append_str(&result, buf, "%", cur_size);
+ break;
+ case 't':
+ cur_size = _clog_append_time(&result, buf, lt,
+ logger->time_fmt, cur_size);
+ break;
+ case 'd':
+ cur_size = _clog_append_time(&result, buf, lt,
+ logger->date_fmt, cur_size);
+ break;
+ case 'l':
+ cur_size = _clog_append_str(&result, buf, level, cur_size);
+ break;
+ case 'n':
+ cur_size = _clog_append_int(&result, buf, sline, cur_size);
+ break;
+ case 'f':
+ cur_size = _clog_append_str(&result, buf, sfile, cur_size);
+ break;
+ case 'm':
+ cur_size = _clog_append_str(&result, buf, message,
+ cur_size);
+ break;
+ }
+ state = NORMAL;
+ }
+ }
+
+ return result;
+}
+
+void
+_clog_log(const char *sfile, int sline, enum clog_level level,
+ int id, const char *fmt, va_list ap)
+{
+ /* For speed: Use a stack buffer until message exceeds 4096, then switch
+ * to dynamically allocated. This should greatly reduce the number of
+ * memory allocations (and subsequent fragmentation). */
+ char buf[4096];
+ size_t buf_size = 4096;
+ char *dynbuf = buf;
+ char *message;
+ int result;
+ struct clog *logger = _clog_loggers[id];
+
+ if (!logger) {
+ _clog_err("No such logger: %d\n", id);
+ return;
+ }
+
+ if (level < logger->level) {
+ return;
+ }
+
+ /* Format the message text with the argument list. */
+ result = vsnprintf(dynbuf, buf_size, fmt, ap);
+ if ((size_t) result >= buf_size) {
+ buf_size = result + 1;
+ dynbuf = (char *) malloc(buf_size);
+ result = vsnprintf(dynbuf, buf_size, fmt, ap);
+ if ((size_t) result >= buf_size) {
+ /* Formatting failed -- too large */
+ _clog_err("Formatting failed (1).\n");
+ free(dynbuf);
+ return;
+ }
+ }
+
+ /* Format according to log format and write to log */
+ {
+ char message_buf[4096];
+ message = _clog_format(logger, message_buf, 4096, sfile, sline,
+ CLOG_LEVEL_NAMES[level], dynbuf);
+ if (!message) {
+ _clog_err("Formatting failed (2).\n");
+ if (dynbuf != buf) {
+ free(dynbuf);
+ }
+ return;
+ }
+ result = write(logger->fd, message, strlen(message));
+ if (logger->cb) logger->cb(message,strlen(message));
+ if (result == -1) {
+ _clog_err("Unable to write to log file: %s\n", strerror(errno));
+ }
+ if (message != message_buf) {
+ free(message);
+ }
+ if (dynbuf != buf) {
+ free(dynbuf);
+ }
+#ifndef _MSC_VER
+ fsync(logger->fd);
+#else
+ HANDLE h = (HANDLE) _get_osfhandle(logger->fd);
+ if (h != INVALID_HANDLE_VALUE) {
+ // This call will fail on a console fd, but that's ok.
+ FlushFileBuffers(h);
+ }
+#endif
+ }
+}
+
+void
+clog_debug(const char *sfile, int sline, int id, const char *fmt, va_list ap)
+{
+ _clog_log(sfile, sline, CLOG_DEBUG, id, fmt, ap);
+}
+
+void
+clog_info(const char *sfile, int sline, int id, const char *fmt, va_list ap)
+{
+ _clog_log(sfile, sline, CLOG_INFO, id, fmt, ap);
+}
+
+void
+clog_warn(const char *sfile, int sline, int id, const char *fmt, va_list ap)
+{
+ _clog_log(sfile, sline, CLOG_WARN, id, fmt, ap);
+}
+
+void
+clog_error(const char *sfile, int sline, int id, const char *fmt, va_list ap)
+{
+ _clog_log(sfile, sline, CLOG_ERROR, id, fmt, ap);
+}
+
+void
+_clog_err(const char *fmt, ...)
+{
+#ifdef CLOG_SILENT
+ (void) fmt;
+#else
+ va_list ap;
+
+ va_start(ap, fmt);
+ vfprintf(stderr, fmt, ap);
+#endif
+}
+
+#endif /* CLOG_MAIN */
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* __CLOG_H__ */
diff --git a/matlab/mex/astra_mex.cpp b/matlab/mex/astra_mex.cpp
index 0eb5662..4bf42dd 100644
--- a/matlab/mex/astra_mex.cpp
+++ b/matlab/mex/astra_mex.cpp
@@ -28,6 +28,7 @@ $Id$
#include <mex.h>
#include "mexHelpFunctions.h"
+#include "mexInitFunctions.h"
#include "astra/Globals.h"
@@ -104,6 +105,8 @@ void mexFunction(int nlhs, mxArray* plhs[],
return;
}
+ initASTRAMex();
+
// SWITCH (MODE)
if (sMode == std::string("version")) {
astra_mex_version(nlhs, plhs, nrhs, prhs);
diff --git a/matlab/mex/astra_mex_algorithm_c.cpp b/matlab/mex/astra_mex_algorithm_c.cpp
index 669af8c..e4afa63 100644
--- a/matlab/mex/astra_mex_algorithm_c.cpp
+++ b/matlab/mex/astra_mex_algorithm_c.cpp
@@ -32,6 +32,7 @@ $Id$
*/
#include <mex.h>
#include "mexHelpFunctions.h"
+#include "mexInitFunctions.h"
#include "astra/Globals.h"
#define USE_MATLAB_UNDOCUMENTED
@@ -325,6 +326,8 @@ void mexFunction(int nlhs, mxArray* plhs[],
return;
}
+ initASTRAMex();
+
// SWITCH (MODE)
if (sMode == "create") {
astra_mex_algorithm_create(nlhs, plhs, nrhs, prhs);
diff --git a/matlab/mex/astra_mex_algorithm_vc09.vcproj b/matlab/mex/astra_mex_algorithm_vc09.vcproj
index 40fcf62..d5cebc0 100644
--- a/matlab/mex/astra_mex_algorithm_vc09.vcproj
+++ b/matlab/mex/astra_mex_algorithm_vc09.vcproj
@@ -598,6 +598,14 @@
RelativePath=".\mexHelpFunctions.h"
>
</File>
+ <File
+ RelativePath=".\mexInitFunctions.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\mexInitFunctions.h"
+ >
+ </File>
</Files>
<Globals>
</Globals>
diff --git a/matlab/mex/astra_mex_algorithm_vc11.vcxproj b/matlab/mex/astra_mex_algorithm_vc11.vcxproj
index a297e6d..c133e26 100644
--- a/matlab/mex/astra_mex_algorithm_vc11.vcxproj
+++ b/matlab/mex/astra_mex_algorithm_vc11.vcxproj
@@ -294,9 +294,11 @@
<ItemGroup>
<ClCompile Include="astra_mex_algorithm_c.cpp" />
<ClCompile Include="mexHelpFunctions.cpp" />
+ <ClCompile Include="mexInitFunctions.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="mexHelpFunctions.h" />
+ <ClInclude Include="mexInitFunctions.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
diff --git a/matlab/mex/astra_mex_c.cpp b/matlab/mex/astra_mex_c.cpp
index 760bd51..4a331f5 100644
--- a/matlab/mex/astra_mex_c.cpp
+++ b/matlab/mex/astra_mex_c.cpp
@@ -33,6 +33,7 @@ $Id$
#include <mex.h>
#include "mexHelpFunctions.h"
+#include "mexInitFunctions.h"
#include "astra/Globals.h"
@@ -128,6 +129,8 @@ void mexFunction(int nlhs, mxArray* plhs[],
return;
}
+ initASTRAMex();
+
// SWITCH (MODE)
if (sMode == std::string("version")) {
astra_mex_version(nlhs, plhs, nrhs, prhs);
diff --git a/matlab/mex/astra_mex_data2d_c.cpp b/matlab/mex/astra_mex_data2d_c.cpp
index 5f79e98..9576896 100644
--- a/matlab/mex/astra_mex_data2d_c.cpp
+++ b/matlab/mex/astra_mex_data2d_c.cpp
@@ -32,6 +32,7 @@ $Id$
*/
#include <mex.h>
#include "mexHelpFunctions.h"
+#include "mexInitFunctions.h"
#include <list>
@@ -635,6 +636,8 @@ void mexFunction(int nlhs, mxArray* plhs[],
return;
}
+ initASTRAMex();
+
// SWITCH (MODE)
if (sMode == std::string("get")) {
astra_mex_data2d_get(nlhs, plhs, nrhs, prhs);
diff --git a/matlab/mex/astra_mex_data2d_vc09.vcproj b/matlab/mex/astra_mex_data2d_vc09.vcproj
index 5611ccc..2c8a63f 100644
--- a/matlab/mex/astra_mex_data2d_vc09.vcproj
+++ b/matlab/mex/astra_mex_data2d_vc09.vcproj
@@ -614,6 +614,14 @@
RelativePath=".\mexDataManagerHelpFunctions.h"
>
</File>
+ <File
+ RelativePath=".\mexInitFunctions.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\mexInitFunctions.h"
+ >
+ </File>
</Files>
<Globals>
</Globals>
diff --git a/matlab/mex/astra_mex_data2d_vc11.vcxproj b/matlab/mex/astra_mex_data2d_vc11.vcxproj
index 0ecc6ce..636780a 100644
--- a/matlab/mex/astra_mex_data2d_vc11.vcxproj
+++ b/matlab/mex/astra_mex_data2d_vc11.vcxproj
@@ -296,11 +296,13 @@
<ClCompile Include="mexHelpFunctions.cpp" />
<ClCompile Include="mexCopyDataHelpFunctions.cpp" />
<ClCompile Include="mexDataManagerHelpFunctions.cpp" />
+ <ClCompile Include="mexInitFunctions.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="mexHelpFunctions.h" />
<ClInclude Include="mexCopyDataHelpFunctions.h" />
<ClInclude Include="mexDataManagerHelpFunctions.h" />
+ <ClInclude Include="mexInitFunctions.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
diff --git a/matlab/mex/astra_mex_data3d_c.cpp b/matlab/mex/astra_mex_data3d_c.cpp
index 0a3f85d..32b0ba7 100644
--- a/matlab/mex/astra_mex_data3d_c.cpp
+++ b/matlab/mex/astra_mex_data3d_c.cpp
@@ -32,6 +32,7 @@ $Id$
*/
#include <mex.h>
#include "mexHelpFunctions.h"
+#include "mexInitFunctions.h"
#include "mexCopyDataHelpFunctions.h"
#include "mexDataManagerHelpFunctions.h"
@@ -371,6 +372,8 @@ void mexFunction(int nlhs, mxArray* plhs[],
return;
}
+ initASTRAMex();
+
// 3D data
if (sMode == std::string("create")) {
astra_mex_data3d_create(nlhs, plhs, nrhs, prhs);
diff --git a/matlab/mex/astra_mex_data3d_vc09.vcproj b/matlab/mex/astra_mex_data3d_vc09.vcproj
index 74a35f4..fd861a3 100644
--- a/matlab/mex/astra_mex_data3d_vc09.vcproj
+++ b/matlab/mex/astra_mex_data3d_vc09.vcproj
@@ -614,6 +614,14 @@
RelativePath=".\mexDataManagerHelpFunctions.h"
>
</File>
+ <File
+ RelativePath=".\mexInitFunctions.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\mexInitFunctions.h"
+ >
+ </File>
</Files>
<Globals>
</Globals>
diff --git a/matlab/mex/astra_mex_data3d_vc11.vcxproj b/matlab/mex/astra_mex_data3d_vc11.vcxproj
index 8ac6f7c..1c3c620 100644
--- a/matlab/mex/astra_mex_data3d_vc11.vcxproj
+++ b/matlab/mex/astra_mex_data3d_vc11.vcxproj
@@ -296,11 +296,13 @@
<ClCompile Include="mexHelpFunctions.cpp" />
<ClCompile Include="mexCopyDataHelpFunctions.cpp" />
<ClCompile Include="mexDataManagerHelpFunctions.cpp" />
+ <ClCompile Include="mexInitFunctions.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="mexHelpFunctions.h" />
<ClInclude Include="mexCopyDataHelpFunctions.h" />
<ClInclude Include="mexDataManagerHelpFunctions.h" />
+ <ClInclude Include="mexInitFunctions.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
diff --git a/matlab/mex/astra_mex_log_c.cpp b/matlab/mex/astra_mex_log_c.cpp
new file mode 100644
index 0000000..ea4621e
--- /dev/null
+++ b/matlab/mex/astra_mex_log_c.cpp
@@ -0,0 +1,305 @@
+/*
+-----------------------------------------------------------------------
+Copyright: 2010-2015, iMinds-Vision Lab, University of Antwerp
+ 2014-2015, CWI, Amsterdam
+
+Contact: astra@uantwerpen.be
+Website: http://sf.net/projects/astra-toolbox
+
+This file is part of the ASTRA Toolbox.
+
+
+The ASTRA Toolbox is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+The ASTRA Toolbox is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>.
+
+-----------------------------------------------------------------------
+$Id$
+*/
+
+/** \file astra_mex_log_c.cpp
+ *
+ * \brief Manages astra logging
+ */
+#include <mex.h>
+#include "mexHelpFunctions.h"
+#include "mexInitFunctions.h"
+
+#include "astra/Logging.h"
+
+using namespace std;
+using namespace astra;
+//-----------------------------------------------------------------------------------------
+/** astra_mex_log('debug', file, line, message);
+ *
+ * Log a debug message.
+ * file: Originating file name
+ * line: Originating line number
+ * message: Log message.
+ */
+void astra_mex_log_debug(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[])
+{
+ if (nrhs < 4) {
+ mexErrMsgTxt("Not enough arguments. See the help document for a detailed argument list. \n");
+ return;
+ }
+ string filename = mexToString(prhs[1]);
+ int linenumber = (int)mxGetScalar(prhs[2]);
+ string message = mexToString(prhs[3]);
+ astra::CLogger::debug(filename.c_str(),linenumber,message.c_str());
+}
+
+//-----------------------------------------------------------------------------------------
+/** astra_mex_log('info', file, line, message);
+ *
+ * Log an info message.
+ * file: Originating file name
+ * line: Originating line number
+ * message: Log message.
+ */
+void astra_mex_log_info(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[])
+{
+ if (nrhs < 4) {
+ mexErrMsgTxt("Not enough arguments. See the help document for a detailed argument list. \n");
+ return;
+ }
+ string filename = mexToString(prhs[1]);
+ int linenumber = (int)mxGetScalar(prhs[2]);
+ string message = mexToString(prhs[3]);
+ astra::CLogger::info(filename.c_str(),linenumber,message.c_str());
+}
+
+//-----------------------------------------------------------------------------------------
+/** astra_mex_log('warn', file, line, message);
+ *
+ * Log a warning message.
+ * file: Originating file name
+ * line: Originating line number
+ * message: Log message.
+ */
+void astra_mex_log_warn(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[])
+{
+ if (nrhs < 4) {
+ mexErrMsgTxt("Not enough arguments. See the help document for a detailed argument list. \n");
+ return;
+ }
+ string filename = mexToString(prhs[1]);
+ int linenumber = (int)mxGetScalar(prhs[2]);
+ string message = mexToString(prhs[3]);
+ astra::CLogger::warn(filename.c_str(),linenumber,message.c_str());
+}
+
+//-----------------------------------------------------------------------------------------
+/** astra_mex_log('error', file, line, message);
+ *
+ * Log an error message.
+ * file: Originating file name
+ * line: Originating line number
+ * message: Log message.
+ */
+void astra_mex_log_error(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[])
+{
+ if (nrhs < 4) {
+ mexErrMsgTxt("Not enough arguments. See the help document for a detailed argument list. \n");
+ return;
+ }
+ string filename = mexToString(prhs[1]);
+ int linenumber = (int)mxGetScalar(prhs[2]);
+ string message = mexToString(prhs[3]);
+ astra::CLogger::error(filename.c_str(),linenumber,message.c_str());
+}
+
+//-----------------------------------------------------------------------------------------
+/** astra_mex_log('enable', type);
+ *
+ * Enable logging.
+ * type: which output to enable ('all', 'file', 'screen')
+ */
+void astra_mex_log_enable(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[])
+{
+ if (nrhs < 2) {
+ mexErrMsgTxt("Not enough arguments. See the help document for a detailed argument list. \n");
+ return;
+ }
+ string sType = mexToString(prhs[1]);
+ if(sType == "all"){
+ astra::CLogger::enable();
+ }else if(sType == "file"){
+ astra::CLogger::enableFile();
+ }else if(sType == "screen"){
+ astra::CLogger::enableScreen();
+ } else {
+ mexErrMsgTxt("Specify which output to enable ('all', 'file', or 'screen')");
+ }
+}
+
+//-----------------------------------------------------------------------------------------
+/** astra_mex_log('disable', type);
+ *
+ * Disable logging.
+ * type: which output to disable ('all', 'file', 'screen')
+ */
+void astra_mex_log_disable(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[])
+{
+ if (nrhs < 2) {
+ mexErrMsgTxt("Not enough arguments. See the help document for a detailed argument list. \n");
+ return;
+ }
+ string sType = mexToString(prhs[1]);
+ if(sType == "all"){
+ astra::CLogger::disable();
+ }else if(sType == "file"){
+ astra::CLogger::disableFile();
+ }else if(sType == "screen"){
+ astra::CLogger::disableScreen();
+ } else {
+ mexErrMsgTxt("Specify which output to disable ('all', 'file', or 'screen')");
+ }
+}
+
+//-----------------------------------------------------------------------------------------
+/** astra_mex_log('format', type, fmt);
+ *
+ * Enable logging.
+ * type: which output to format ('file', 'screen')
+ * fmt: format string
+ * Here are the substitutions you may use:
+ * %f: Source file name generating the log call.
+ * %n: Source line number where the log call was made.
+ * %m: The message text sent to the logger (after printf formatting).
+ * %d: The current date, formatted using the logger's date format.
+ * %t: The current time, formatted using the logger's time format.
+ * %l: The log level (one of "DEBUG", "INFO", "WARN", or "ERROR").
+ * %%: A literal percent sign.
+ * The default format string is "%d %t %f(%n): %l: %m\n".
+ */
+void astra_mex_log_format(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[])
+{
+ if (nrhs < 3) {
+ mexErrMsgTxt("Not enough arguments. See the help document for a detailed argument list. \n");
+ return;
+ }
+ string sType = mexToString(prhs[1]);
+ string sFormat = mexToString(prhs[2]);
+ if (!sFormat.empty())
+ {
+ char lastChar = *sFormat.rbegin();
+ if (lastChar!='\n'){
+ sFormat += '\n';
+ }
+ }else{
+ sFormat += '\n';
+ }
+ if(sType == "file"){
+ astra::CLogger::setFormatFile(sFormat.c_str());
+ }else if(sType == "screen"){
+ astra::CLogger::setFormatScreen(sFormat.c_str());
+ } else {
+ mexErrMsgTxt("Specify which output to format ('file' or 'screen')");
+ }
+}
+
+//-----------------------------------------------------------------------------------------
+/** astra_mex_log('output', type, output, level);
+ *
+ * Set output file / output screen.
+ * type: which output to set ('file', 'screen')
+ * output: which output file / screen to use:
+ * 'file': filename
+ * 'screen': 'stdout' or 'stderr'
+ * level: logging level to use ('debug', 'info', 'warn', or 'error')
+ */
+void astra_mex_log_output(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[])
+{
+ if (nrhs < 4) {
+ mexErrMsgTxt("Not enough arguments. See the help document for a detailed argument list. \n");
+ return;
+ }
+ string sType = mexToString(prhs[1]);
+ string sOutput = mexToString(prhs[2]);
+ string sLevel = mexToString(prhs[3]);
+ log_level eLevel;
+ if(sLevel == "debug"){
+ eLevel = LOG_DEBUG;
+ }else if(sLevel == "info"){
+ eLevel = LOG_INFO;
+ }else if(sLevel == "warn"){
+ eLevel = LOG_WARN;
+ }else if(sLevel == "error"){
+ eLevel = LOG_ERROR;
+ }else{
+ mexErrMsgTxt("Specify which log level to use ('debug', 'info', 'warn', or 'error')");
+ }
+ if(sType == "file"){
+ astra::CLogger::setOutputFile(sOutput.c_str(),eLevel);
+ }else if(sType == "screen"){
+ int fd;
+ if(sOutput == "stdout"){
+ fd=1;
+ }else if(sOutput == "stderr"){
+ fd=2;
+ }else{
+ mexErrMsgTxt("Specify which screen to output to ('stdout' or 'stderr')");
+ }
+ astra::CLogger::setOutputScreen(fd,eLevel);
+ } else {
+ mexErrMsgTxt("Specify which output to set ('file' or 'screen')");
+ }
+}
+
+//-----------------------------------------------------------------------------------------
+static void printHelp()
+{
+ mexPrintf("Please specify a mode of operation.\n");
+ mexPrintf("Valid modes: debug, info, warn, error, enable, disable, format, output\n");
+}
+
+//-----------------------------------------------------------------------------------------
+/**
+ * ... = astra_mex_log(mode, ...);
+ */
+void mexFunction(int nlhs, mxArray* plhs[],
+ int nrhs, const mxArray* prhs[])
+{
+ // INPUT: Mode
+ string sMode = "";
+ if (1 <= nrhs) {
+ sMode = mexToString(prhs[0]);
+ } else {
+ printHelp();
+ return;
+ }
+
+ initASTRAMex();
+
+ // SWITCH (MODE)
+ if (sMode == "debug") {
+ astra_mex_log_debug(nlhs, plhs, nrhs, prhs);
+ }else if (sMode == "info") {
+ astra_mex_log_info(nlhs, plhs, nrhs, prhs);
+ }else if (sMode == "warn") {
+ astra_mex_log_warn(nlhs, plhs, nrhs, prhs);
+ }else if (sMode == "error") {
+ astra_mex_log_error(nlhs, plhs, nrhs, prhs);
+ }else if (sMode == "enable") {
+ astra_mex_log_enable(nlhs, plhs, nrhs, prhs);
+ }else if (sMode == "disable") {
+ astra_mex_log_disable(nlhs, plhs, nrhs, prhs);
+ }else if (sMode == "format") {
+ astra_mex_log_format(nlhs, plhs, nrhs, prhs);
+ }else if (sMode == "output") {
+ astra_mex_log_output(nlhs, plhs, nrhs, prhs);
+ } else {
+ printHelp();
+ }
+ return;
+}
diff --git a/matlab/mex/astra_mex_log_vc09.vcproj b/matlab/mex/astra_mex_log_vc09.vcproj
new file mode 100644
index 0000000..0e0d469
--- /dev/null
+++ b/matlab/mex/astra_mex_log_vc09.vcproj
@@ -0,0 +1,612 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9.00"
+ Name="astra_mex_log"
+ ProjectGUID="{CA2840B3-DA68-41B5-AC57-F5DFD20ED8F8}"
+ RootNamespace="astraMatlab"
+ TargetFrameworkVersion="131072"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ <Platform
+ Name="x64"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug_CUDA|Win32"
+ OutputDirectory="$(SolutionDir)bin\$(PlatformName)\$(ConfigurationName)"
+ IntermediateDirectory="$(OutDir)\obj\$(ProjectName)"
+ ConfigurationType="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="$(MATLAB_ROOT)\extern\include\;&quot;$(CUDA_INC_PATH)&quot;;..\..\lib\include;..\..\include"
+ PreprocessorDefinitions="ASTRA_CUDA;__SSE2__"
+ Optimization="0"
+ RuntimeLibrary="3"
+ EnableEnhancedInstructionSet="2"
+ OpenMP="true"
+ AdditionalOptions="/MP"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="AstraCuda32D.lib libmex.lib libmx.lib libut.lib"
+ OutputFile="$(OutDir)\$(ProjectName)_c.mexw32"
+ AdditionalLibraryDirectories="..\..\bin\win32;$(MATLAB_ROOT)\extern\lib\win32\microsoft;..\..\lib\win32"
+ ModuleDefinitionFile="mex.def"
+ GenerateDebugInformation="true"
+ TargetMachine="1"
+ />
+ </Configuration>
+ <Configuration
+ Name="Debug_CUDA|x64"
+ OutputDirectory="$(SolutionDir)bin\$(PlatformName)\$(ConfigurationName)"
+ IntermediateDirectory="$(OutDir)\obj\$(ProjectName)"
+ ConfigurationType="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="$(MATLAB_ROOT)\extern\include\;&quot;$(CUDA_INC_PATH)&quot;;..\..\lib\include;..\..\include"
+ PreprocessorDefinitions="ASTRA_CUDA;__SSE2__"
+ Optimization="0"
+ RuntimeLibrary="3"
+ OpenMP="true"
+ AdditionalOptions="/MP"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="AstraCuda64D.lib libmex.lib libmx.lib libut.lib"
+ OutputFile="$(OutDir)\$(ProjectName)_c.mexw64"
+ AdditionalLibraryDirectories="..\..\bin\x64;$(MATLAB_ROOT)\extern\lib\win64\microsoft;..\..\lib\x64"
+ ModuleDefinitionFile="mex.def"
+ GenerateDebugInformation="true"
+ TargetMachine="17"
+ />
+ </Configuration>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)bin\$(PlatformName)\$(ConfigurationName)"
+ IntermediateDirectory="$(OutDir)\obj\$(ProjectName)"
+ ConfigurationType="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="$(MATLAB_ROOT)\extern\include\;..\..\lib\include;..\..\include"
+ PreprocessorDefinitions="__SSE2__"
+ Optimization="0"
+ RuntimeLibrary="3"
+ EnableEnhancedInstructionSet="2"
+ OpenMP="true"
+ AdditionalOptions="/MP"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="Astra32D.lib libmex.lib libmx.lib libut.lib"
+ OutputFile="$(OutDir)\$(ProjectName)_c.mexw32"
+ AdditionalLibraryDirectories="..\..\bin\win32;$(MATLAB_ROOT)\extern\lib\win32\microsoft;..\..\lib\win32"
+ ModuleDefinitionFile="mex.def"
+ GenerateDebugInformation="true"
+ TargetMachine="1"
+ />
+ </Configuration>
+ <Configuration
+ Name="Debug|x64"
+ OutputDirectory="$(SolutionDir)bin\$(PlatformName)\$(ConfigurationName)"
+ IntermediateDirectory="$(OutDir)\obj\$(ProjectName)"
+ ConfigurationType="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="$(MATLAB_ROOT)\extern\include\;..\..\lib\include;..\..\include"
+ PreprocessorDefinitions="__SSE2__"
+ Optimization="0"
+ RuntimeLibrary="3"
+ OpenMP="true"
+ AdditionalOptions="/MP"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="Astra64D.lib libmex.lib libmx.lib libut.lib"
+ OutputFile="$(OutDir)\$(ProjectName)_c.mexw64"
+ AdditionalLibraryDirectories="..\..\bin\x64;$(MATLAB_ROOT)\extern\lib\win64\microsoft;..\..\lib\x64"
+ ModuleDefinitionFile="mex.def"
+ GenerateDebugInformation="true"
+ TargetMachine="17"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release_CUDA|Win32"
+ OutputDirectory="$(SolutionDir)bin\$(PlatformName)\$(ConfigurationName)"
+ IntermediateDirectory="$(OutDir)\obj\$(ProjectName)"
+ ConfigurationType="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="$(MATLAB_ROOT)\extern\include\;&quot;$(CUDA_INC_PATH)&quot;;..\..\lib\include;..\..\include"
+ PreprocessorDefinitions="ASTRA_CUDA;__SSE2__"
+ Optimization="2"
+ RuntimeLibrary="2"
+ EnableEnhancedInstructionSet="2"
+ OpenMP="true"
+ AdditionalOptions="/MP"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="AstraCuda32.lib libmex.lib libmx.lib libut.lib"
+ OutputFile="$(OutDir)\$(ProjectName)_c.mexw32"
+ AdditionalLibraryDirectories="..\..\bin\win32;$(MATLAB_ROOT)\extern\lib\win32\microsoft;..\..\lib\win32"
+ ModuleDefinitionFile="mex.def"
+ GenerateDebugInformation="false"
+ TargetMachine="1"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release_CUDA|x64"
+ OutputDirectory="$(SolutionDir)bin\$(PlatformName)\$(ConfigurationName)"
+ IntermediateDirectory="$(OutDir)\obj\$(ProjectName)"
+ ConfigurationType="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="$(MATLAB_ROOT)\extern\include\;&quot;$(CUDA_INC_PATH)&quot;;..\..\lib\include;..\..\include"
+ PreprocessorDefinitions="ASTRA_CUDA;__SSE2__"
+ Optimization="2"
+ RuntimeLibrary="2"
+ OpenMP="true"
+ AdditionalOptions="/MP"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="AstraCuda64.lib libmex.lib libmx.lib libut.lib"
+ OutputFile="$(OutDir)\$(ProjectName)_c.mexw64"
+ AdditionalLibraryDirectories="..\..\bin\x64;$(MATLAB_ROOT)\extern\lib\win64\microsoft;..\..\lib\x64"
+ ModuleDefinitionFile="mex.def"
+ GenerateDebugInformation="false"
+ TargetMachine="17"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)bin\$(PlatformName)\$(ConfigurationName)"
+ IntermediateDirectory="$(OutDir)\obj\$(ProjectName)"
+ ConfigurationType="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="$(MATLAB_ROOT)\extern\include\;..\..\lib\include;..\..\include"
+ PreprocessorDefinitions="__SSE2__"
+ Optimization="2"
+ RuntimeLibrary="2"
+ EnableEnhancedInstructionSet="2"
+ OpenMP="true"
+ AdditionalOptions="/MP"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="Astra32.lib libmex.lib libmx.lib libut.lib"
+ OutputFile="$(OutDir)\$(ProjectName)_c.mexw32"
+ AdditionalLibraryDirectories="..\..\bin\win32;$(MATLAB_ROOT)\extern\lib\win32\microsoft;..\..\lib\win32"
+ ModuleDefinitionFile="mex.def"
+ GenerateDebugInformation="false"
+ TargetMachine="1"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|x64"
+ OutputDirectory="$(SolutionDir)bin\$(PlatformName)\$(ConfigurationName)"
+ IntermediateDirectory="$(OutDir)\obj\$(ProjectName)"
+ ConfigurationType="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="$(MATLAB_ROOT)\extern\include\;..\..\lib\include;..\..\include"
+ PreprocessorDefinitions="__SSE2__"
+ Optimization="2"
+ RuntimeLibrary="2"
+ OpenMP="true"
+ AdditionalOptions="/MP"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="Astra64.lib libmex.lib libmx.lib libut.lib"
+ OutputFile="$(OutDir)\$(ProjectName)_c.mexw64"
+ AdditionalLibraryDirectories="..\..\bin\x64;$(MATLAB_ROOT)\extern\lib\win64\microsoft;..\..\lib\x64"
+ ModuleDefinitionFile="mex.def"
+ GenerateDebugInformation="false"
+ TargetMachine="17"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <File
+ RelativePath=".\astra_mex_log_c.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\mexHelpFunctions.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\mexHelpFunctions.h"
+ >
+ </File>
+ <File
+ RelativePath=".\mexInitFunctions.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\mexInitFunctions.h"
+ >
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/matlab/mex/astra_mex_log_vc11.vcxproj b/matlab/mex/astra_mex_log_vc11.vcxproj
new file mode 100644
index 0000000..0a939cf
--- /dev/null
+++ b/matlab/mex/astra_mex_log_vc11.vcxproj
@@ -0,0 +1,306 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug_CUDA|Win32">
+ <Configuration>Debug_CUDA</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug_CUDA|x64">
+ <Configuration>Debug_CUDA</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release_CUDA|Win32">
+ <Configuration>Release_CUDA</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release_CUDA|x64">
+ <Configuration>Release_CUDA</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectName>astra_mex_log</ProjectName>
+ <ProjectGuid>{03B833F5-4FD6-4FBE-AAF4-E3305CD56D2E}</ProjectGuid>
+ <RootNamespace>astraMatlab</RootNamespace>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug_CUDA|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <PlatformToolset>v110</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug_CUDA|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <PlatformToolset>v110</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <PlatformToolset>v110</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <PlatformToolset>v110</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_CUDA|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <PlatformToolset>v110</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_CUDA|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <PlatformToolset>v110</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <PlatformToolset>v110</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <PlatformToolset>v110</PlatformToolset>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug_CUDA|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug_CUDA|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release_CUDA|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release_CUDA|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>11.0.60610.1</_ProjectFileVersion>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug_CUDA|Win32'">
+ <OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\</OutDir>
+ <IntDir>$(OutDir)obj\$(ProjectName)\</IntDir>
+ <TargetName>$(ProjectName)_c</TargetName>
+ <TargetExt>.mexw32</TargetExt>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug_CUDA|x64'">
+ <OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\</OutDir>
+ <IntDir>$(OutDir)obj\$(ProjectName)\</IntDir>
+ <TargetName>$(ProjectName)_c</TargetName>
+ <TargetExt>.mexw64</TargetExt>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\</OutDir>
+ <IntDir>$(OutDir)obj\$(ProjectName)\</IntDir>
+ <TargetName>$(ProjectName)_c</TargetName>
+ <TargetExt>.mexw32</TargetExt>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\</OutDir>
+ <IntDir>$(OutDir)obj\$(ProjectName)\</IntDir>
+ <TargetName>$(ProjectName)_c</TargetName>
+ <TargetExt>.mexw64</TargetExt>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_CUDA|Win32'">
+ <OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\</OutDir>
+ <IntDir>$(OutDir)obj\$(ProjectName)\</IntDir>
+ <TargetName>$(ProjectName)_c</TargetName>
+ <TargetExt>.mexw32</TargetExt>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_CUDA|x64'">
+ <OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\</OutDir>
+ <IntDir>$(OutDir)obj\$(ProjectName)\</IntDir>
+ <TargetName>$(ProjectName)_c</TargetName>
+ <TargetExt>.mexw64</TargetExt>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\</OutDir>
+ <IntDir>$(OutDir)obj\$(ProjectName)\</IntDir>
+ <TargetName>$(ProjectName)_c</TargetName>
+ <TargetExt>.mexw32</TargetExt>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\</OutDir>
+ <IntDir>$(OutDir)obj\$(ProjectName)\</IntDir>
+ <TargetName>$(ProjectName)_c</TargetName>
+ <TargetExt>.mexw64</TargetExt>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug_CUDA|Win32'">
+ <ClCompile>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <AdditionalIncludeDirectories>$(MATLAB_ROOT)\extern\include\;$(CUDA_PATH)\include;..\..\lib\include;..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <OpenMPSupport>true</OpenMPSupport>
+ <EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>ASTRA_CUDA;__SSE2__;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MultiProcessorCompilation>true</MultiProcessorCompilation>
+ </ClCompile>
+ <Link>
+ <OutputFile>$(OutDir)$(ProjectName)_c.mexw32</OutputFile>
+ <AdditionalDependencies>AstraCuda32D.lib;libmex.lib;libmx.lib;libut.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalLibraryDirectories>..\..\lib\win32\;..\..\bin\win32\Debug_CUDA;$(MATLAB_ROOT)\extern\lib\win32\microsoft;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <ModuleDefinitionFile>mex.def</ModuleDefinitionFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug_CUDA|x64'">
+ <ClCompile>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <AdditionalIncludeDirectories>$(MATLAB_ROOT)\extern\include\;$(CUDA_PATH)\include;..\..\lib\include;..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <OpenMPSupport>true</OpenMPSupport>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>ASTRA_CUDA;__SSE2__;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MultiProcessorCompilation>true</MultiProcessorCompilation>
+ </ClCompile>
+ <Link>
+ <OutputFile>$(OutDir)$(ProjectName)_c.mexw64</OutputFile>
+ <AdditionalDependencies>AstraCuda64D.lib;libmex.lib;libmx.lib;libut.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalLibraryDirectories>..\..\lib\x64\;..\..\bin\x64\Debug_CUDA;$(MATLAB_ROOT)\extern\lib\win64\microsoft;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <ModuleDefinitionFile>mex.def</ModuleDefinitionFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <AdditionalIncludeDirectories>$(MATLAB_ROOT)\extern\include\;$(CUDA_PATH)\include;..\..\lib\include;..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <OpenMPSupport>true</OpenMPSupport>
+ <EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>__SSE2__;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MultiProcessorCompilation>true</MultiProcessorCompilation>
+ </ClCompile>
+ <Link>
+ <OutputFile>$(OutDir)$(ProjectName)_c.mexw32</OutputFile>
+ <AdditionalDependencies>Astra32D.lib;libmex.lib;libmx.lib;libut.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalLibraryDirectories>..\..\lib\win32\;..\..\bin\win32\Debug;$(MATLAB_ROOT)\extern\lib\win32\microsoft;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <ModuleDefinitionFile>mex.def</ModuleDefinitionFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <AdditionalIncludeDirectories>$(MATLAB_ROOT)\extern\include\;$(CUDA_PATH)\include;..\..\lib\include;..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <OpenMPSupport>true</OpenMPSupport>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>__SSE2__;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MultiProcessorCompilation>true</MultiProcessorCompilation>
+ </ClCompile>
+ <Link>
+ <OutputFile>$(OutDir)$(ProjectName)_c.mexw64</OutputFile>
+ <AdditionalDependencies>Astra64D.lib;libmex.lib;libmx.lib;libut.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalLibraryDirectories>..\..\lib\x64\;..\..\bin\x64\Debug;$(MATLAB_ROOT)\extern\lib\win64\microsoft;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <ModuleDefinitionFile>mex.def</ModuleDefinitionFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_CUDA|Win32'">
+ <ClCompile>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <AdditionalIncludeDirectories>$(MATLAB_ROOT)\extern\include\;$(CUDA_PATH)\include;..\..\lib\include;..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <OpenMPSupport>true</OpenMPSupport>
+ <EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
+ <Optimization>MaxSpeed</Optimization>
+ <PreprocessorDefinitions>ASTRA_CUDA;__SSE2__;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MultiProcessorCompilation>true</MultiProcessorCompilation>
+ </ClCompile>
+ <Link>
+ <OutputFile>$(OutDir)$(ProjectName)_c.mexw32</OutputFile>
+ <AdditionalDependencies>AstraCuda32.lib;libmex.lib;libmx.lib;libut.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalLibraryDirectories>..\..\lib\win32\;..\..\bin\win32\Release_CUDA;$(MATLAB_ROOT)\extern\lib\win32\microsoft;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <ModuleDefinitionFile>mex.def</ModuleDefinitionFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_CUDA|x64'">
+ <ClCompile>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <AdditionalIncludeDirectories>$(MATLAB_ROOT)\extern\include\;$(CUDA_PATH)\include;..\..\lib\include;..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <OpenMPSupport>true</OpenMPSupport>
+ <Optimization>MaxSpeed</Optimization>
+ <PreprocessorDefinitions>ASTRA_CUDA;__SSE2__;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MultiProcessorCompilation>true</MultiProcessorCompilation>
+ </ClCompile>
+ <Link>
+ <OutputFile>$(OutDir)$(ProjectName)_c.mexw64</OutputFile>
+ <AdditionalDependencies>AstraCuda64.lib;libmex.lib;libmx.lib;libut.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalLibraryDirectories>..\..\lib\x64\;..\..\bin\x64\Release_CUDA;$(MATLAB_ROOT)\extern\lib\win64\microsoft;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <ModuleDefinitionFile>mex.def</ModuleDefinitionFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <AdditionalIncludeDirectories>$(MATLAB_ROOT)\extern\include\;$(CUDA_PATH)\include;..\..\lib\include;..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <OpenMPSupport>true</OpenMPSupport>
+ <EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
+ <Optimization>MaxSpeed</Optimization>
+ <PreprocessorDefinitions>__SSE2__;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MultiProcessorCompilation>true</MultiProcessorCompilation>
+ </ClCompile>
+ <Link>
+ <OutputFile>$(OutDir)$(ProjectName)_c.mexw32</OutputFile>
+ <AdditionalDependencies>Astra32.lib;libmex.lib;libmx.lib;libut.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalLibraryDirectories>..\..\lib\win32\;..\..\bin\win32\Release;$(MATLAB_ROOT)\extern\lib\win32\microsoft;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <ModuleDefinitionFile>mex.def</ModuleDefinitionFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <AdditionalIncludeDirectories>$(MATLAB_ROOT)\extern\include\;$(CUDA_PATH)\include;..\..\lib\include;..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <OpenMPSupport>true</OpenMPSupport>
+ <Optimization>MaxSpeed</Optimization>
+ <PreprocessorDefinitions>__SSE2__;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MultiProcessorCompilation>true</MultiProcessorCompilation>
+ </ClCompile>
+ <Link>
+ <OutputFile>$(OutDir)$(ProjectName)_c.mexw64</OutputFile>
+ <AdditionalDependencies>Astra64.lib;libmex.lib;libmx.lib;libut.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalLibraryDirectories>..\..\lib\x64\;..\..\bin\x64\Release;$(MATLAB_ROOT)\extern\lib\win64\microsoft;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <ModuleDefinitionFile>mex.def</ModuleDefinitionFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="astra_mex_log_c.cpp" />
+ <ClCompile Include="mexHelpFunctions.cpp" />
+ <ClCompile Include="mexInitFunctions.cpp" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="mexHelpFunctions.h" />
+ <ClInclude Include="mexInitFunctions.h" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/matlab/mex/astra_mex_matrix_c.cpp b/matlab/mex/astra_mex_matrix_c.cpp
index 01ad08b..aa31383 100644
--- a/matlab/mex/astra_mex_matrix_c.cpp
+++ b/matlab/mex/astra_mex_matrix_c.cpp
@@ -32,6 +32,7 @@ $Id$
*/
#include <mex.h>
#include "mexHelpFunctions.h"
+#include "mexInitFunctions.h"
#include <list>
@@ -412,6 +413,8 @@ void mexFunction(int nlhs, mxArray* plhs[],
return;
}
+ initASTRAMex();
+
// SWITCH (MODE)
if (sMode == std::string("get")) {
astra_mex_matrix_get(nlhs, plhs, nrhs, prhs);
diff --git a/matlab/mex/astra_mex_matrix_vc09.vcproj b/matlab/mex/astra_mex_matrix_vc09.vcproj
index e4b57e9..3aa17a5 100644
--- a/matlab/mex/astra_mex_matrix_vc09.vcproj
+++ b/matlab/mex/astra_mex_matrix_vc09.vcproj
@@ -598,6 +598,14 @@
RelativePath=".\mexHelpFunctions.h"
>
</File>
+ <File
+ RelativePath=".\mexInitFunctions.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\mexInitFunctions.h"
+ >
+ </File>
</Files>
<Globals>
</Globals>
diff --git a/matlab/mex/astra_mex_matrix_vc11.vcxproj b/matlab/mex/astra_mex_matrix_vc11.vcxproj
index 91e32bd..abf86a7 100644
--- a/matlab/mex/astra_mex_matrix_vc11.vcxproj
+++ b/matlab/mex/astra_mex_matrix_vc11.vcxproj
@@ -294,9 +294,11 @@
<ItemGroup>
<ClCompile Include="astra_mex_matrix_c.cpp" />
<ClCompile Include="mexHelpFunctions.cpp" />
+ <ClCompile Include="mexInitFunctions.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="mexHelpFunctions.h" />
+ <ClInclude Include="mexInitFunctions.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
diff --git a/matlab/mex/astra_mex_projector3d_c.cpp b/matlab/mex/astra_mex_projector3d_c.cpp
index 5381cf6..c3b547f 100644
--- a/matlab/mex/astra_mex_projector3d_c.cpp
+++ b/matlab/mex/astra_mex_projector3d_c.cpp
@@ -33,6 +33,7 @@ $Id$
#include <mex.h>
#include "mexHelpFunctions.h"
+#include "mexInitFunctions.h"
#include "astra/Globals.h"
@@ -403,6 +404,8 @@ void mexFunction(int nlhs, mxArray* plhs[],
return;
}
+ initASTRAMex();
+
// SWITCH (MODE)
if (sMode == "create") {
astra_mex_projector3d_create(nlhs, plhs, nrhs, prhs);
diff --git a/matlab/mex/astra_mex_projector3d_vc09.vcproj b/matlab/mex/astra_mex_projector3d_vc09.vcproj
index 09fa3c6..b9464a2 100644
--- a/matlab/mex/astra_mex_projector3d_vc09.vcproj
+++ b/matlab/mex/astra_mex_projector3d_vc09.vcproj
@@ -598,6 +598,14 @@
RelativePath=".\mexHelpFunctions.h"
>
</File>
+ <File
+ RelativePath=".\mexInitFunctions.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\mexInitFunctions.h"
+ >
+ </File>
</Files>
<Globals>
</Globals>
diff --git a/matlab/mex/astra_mex_projector3d_vc11.vcxproj b/matlab/mex/astra_mex_projector3d_vc11.vcxproj
index b8e8001..42eb0f1 100644
--- a/matlab/mex/astra_mex_projector3d_vc11.vcxproj
+++ b/matlab/mex/astra_mex_projector3d_vc11.vcxproj
@@ -294,9 +294,11 @@
<ItemGroup>
<ClCompile Include="astra_mex_projector3d_c.cpp" />
<ClCompile Include="mexHelpFunctions.cpp" />
+ <ClCompile Include="mexInitFunctions.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="mexHelpFunctions.h" />
+ <ClInclude Include="mexInitFunctions.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
diff --git a/matlab/mex/astra_mex_projector_c.cpp b/matlab/mex/astra_mex_projector_c.cpp
index 58cd953..204ba8e 100644
--- a/matlab/mex/astra_mex_projector_c.cpp
+++ b/matlab/mex/astra_mex_projector_c.cpp
@@ -34,6 +34,7 @@ $Id$
#include <mex.h>
#include "mexHelpFunctions.h"
+#include "mexInitFunctions.h"
#include "astra/AstraObjectManager.h"
#include "astra/Projector2D.h"
@@ -476,6 +477,8 @@ void mexFunction(int nlhs, mxArray* plhs[],
return;
}
+ initASTRAMex();
+
// SWITCH (MODE)
if (sMode == "create") {
astra_mex_projector_create(nlhs, plhs, nrhs, prhs);
diff --git a/matlab/mex/astra_mex_projector_vc09.vcproj b/matlab/mex/astra_mex_projector_vc09.vcproj
index c0a5cd8..05c207f 100644
--- a/matlab/mex/astra_mex_projector_vc09.vcproj
+++ b/matlab/mex/astra_mex_projector_vc09.vcproj
@@ -598,6 +598,14 @@
RelativePath=".\mexHelpFunctions.h"
>
</File>
+ <File
+ RelativePath=".\mexInitFunctions.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\mexInitFunctions.h"
+ >
+ </File>
</Files>
<Globals>
</Globals>
diff --git a/matlab/mex/astra_mex_projector_vc11.vcxproj b/matlab/mex/astra_mex_projector_vc11.vcxproj
index 03a574d..e944949 100644
--- a/matlab/mex/astra_mex_projector_vc11.vcxproj
+++ b/matlab/mex/astra_mex_projector_vc11.vcxproj
@@ -294,9 +294,11 @@
<ItemGroup>
<ClCompile Include="astra_mex_projector_c.cpp" />
<ClCompile Include="mexHelpFunctions.cpp" />
+ <ClCompile Include="mexInitFunctions.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="mexHelpFunctions.h" />
+ <ClInclude Include="mexInitFunctions.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
diff --git a/matlab/mex/astra_mex_vc09.vcproj b/matlab/mex/astra_mex_vc09.vcproj
index 9615f53..e4d7d07 100644
--- a/matlab/mex/astra_mex_vc09.vcproj
+++ b/matlab/mex/astra_mex_vc09.vcproj
@@ -598,6 +598,14 @@
RelativePath=".\mexHelpFunctions.h"
>
</File>
+ <File
+ RelativePath=".\mexInitFunctions.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\mexInitFunctions.h"
+ >
+ </File>
</Files>
<Globals>
</Globals>
diff --git a/matlab/mex/astra_mex_vc11.vcxproj b/matlab/mex/astra_mex_vc11.vcxproj
index 04df41c..f1324b4 100644
--- a/matlab/mex/astra_mex_vc11.vcxproj
+++ b/matlab/mex/astra_mex_vc11.vcxproj
@@ -294,9 +294,11 @@
<ItemGroup>
<ClCompile Include="astra_mex_c.cpp" />
<ClCompile Include="mexHelpFunctions.cpp" />
+ <ClCompile Include="mexInitFunctions.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="mexHelpFunctions.h" />
+ <ClInclude Include="mexInitFunctions.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
diff --git a/matlab/mex/mexInitFunctions.cpp b/matlab/mex/mexInitFunctions.cpp
new file mode 100644
index 0000000..d8a50d7
--- /dev/null
+++ b/matlab/mex/mexInitFunctions.cpp
@@ -0,0 +1,24 @@
+#include <mex.h>
+#include "astra/Logging.h"
+
+bool mexIsInitialized=false;
+
+/**
+ * Callback to print log message to Matlab window.
+ *
+ */
+void logCallBack(const char *msg, size_t len){
+ mexPrintf(msg);
+}
+
+/**
+ * Initialize mex functions.
+ *
+ */
+void initASTRAMex(){
+ if(mexIsInitialized) return;
+ if(!astra::CLogger::setCallbackScreen(&logCallBack)){
+ mexErrMsgTxt("Error initializing mex functions.");
+ }
+ mexIsInitialized=true;
+}
diff --git a/matlab/mex/mexInitFunctions.h b/matlab/mex/mexInitFunctions.h
new file mode 100644
index 0000000..f16e9c9
--- /dev/null
+++ b/matlab/mex/mexInitFunctions.h
@@ -0,0 +1,6 @@
+#ifndef _INC_ASTRA_MEX_INITFUNCTIONS
+#define _INC_ASTRA_MEX_INITFUNCTIONS
+
+void initASTRAMex();
+
+#endif \ No newline at end of file
diff --git a/matlab/tools/astra_mex_log.m b/matlab/tools/astra_mex_log.m
new file mode 100644
index 0000000..28cfa18
--- /dev/null
+++ b/matlab/tools/astra_mex_log.m
@@ -0,0 +1,33 @@
+function [varargout] = astra_mex_log(varargin)
+%------------------------------------------------------------------------
+% Reference page in Help browser
+% <a href="matlab:docsearch('astra_mex_log' )">astra_mex_log</a>.
+%------------------------------------------------------------------------
+%------------------------------------------------------------------------
+% This file is part of the ASTRA Toolbox
+%
+% Copyright: 2010-2015, iMinds-Vision Lab, University of Antwerp
+% 2014-2015, CWI, Amsterdam
+% License: Open Source under GPLv3
+% Contact: astra@uantwerpen.be
+% Website: http://sf.net/projects/astra-toolbox
+%------------------------------------------------------------------------
+% $Id$
+if size(varargin,2)==2 && (strcmp(varargin{1},'debug') || strcmp(varargin{1},'info') || strcmp(varargin{1},'warn') || strcmp(varargin{1},'error'))
+ d = dbstack(1);
+ if size(d,1)==0
+ astra_mex_log_c(varargin{1},'Unknown',0,varargin{2})
+ else
+ astra_mex_log_c(varargin{1},d(1).file,d(1).line,varargin{2})
+ end
+else
+ if nargout == 0
+ astra_mex_log_c(varargin{:});
+ if exist('ans','var')
+ varargout{1} = ans;
+ end
+ else
+ varargout = cell(1,nargout);
+ [varargout{:}] = astra_mex_log_c(varargin{:});
+ end
+end \ No newline at end of file
diff --git a/python/astra/__init__.py b/python/astra/__init__.py
index c249c01..063dc16 100644
--- a/python/astra/__init__.py
+++ b/python/astra/__init__.py
@@ -35,6 +35,7 @@ from . import algorithm
from . import projector
from . import projector3d
from . import matrix
+from . import log
import os
try:
diff --git a/python/astra/log.py b/python/astra/log.py
new file mode 100644
index 0000000..3ec0df5
--- /dev/null
+++ b/python/astra/log.py
@@ -0,0 +1,153 @@
+#-----------------------------------------------------------------------
+#Copyright 2013 Centrum Wiskunde & Informatica, Amsterdam
+#
+#Author: Daniel M. Pelt
+#Contact: D.M.Pelt@cwi.nl
+#Website: http://dmpelt.github.io/pyastratoolbox/
+#
+#
+#This file is part of the Python interface to the
+#All Scale Tomographic Reconstruction Antwerp Toolbox ("ASTRA Toolbox").
+#
+#The Python interface to the ASTRA Toolbox is free software: you can redistribute it and/or modify
+#it under the terms of the GNU General Public License as published by
+#the Free Software Foundation, either version 3 of the License, or
+#(at your option) any later version.
+#
+#The Python interface to the ASTRA Toolbox is distributed in the hope that it will be useful,
+#but WITHOUT ANY WARRANTY; without even the implied warranty of
+#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+#GNU General Public License for more details.
+#
+#You should have received a copy of the GNU General Public License
+#along with the Python interface to the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>.
+#
+#-----------------------------------------------------------------------
+
+from . import log_c as l
+
+import inspect
+
+def debug(message):
+ """Log a debug message.
+
+ :param message: Message to log.
+ :type message: :class:`string`
+ """
+ prev_f = inspect.getframeinfo(inspect.currentframe().f_back)
+ l.log_debug(prev_f.filename,prev_f.lineno,message)
+
+def info(message):
+ """Log an info message.
+
+ :param message: Message to log.
+ :type message: :class:`string`
+ """
+ prev_f = inspect.getframeinfo(inspect.currentframe().f_back)
+ l.log_info(prev_f.filename,prev_f.lineno,message)
+
+def warn(message):
+ """Log a warning message.
+
+ :param message: Message to log.
+ :type message: :class:`string`
+ """
+ prev_f = inspect.getframeinfo(inspect.currentframe().f_back)
+ l.log_warn(prev_f.filename,prev_f.lineno,message)
+
+def error(message):
+ """Log an error message.
+
+ :param message: Message to log.
+ :type message: :class:`string`
+ """
+ prev_f = inspect.getframeinfo(inspect.currentframe().f_back)
+ l.log_error(prev_f.filename,prev_f.lineno,message)
+
+def enable():
+ """Enable logging to screen and file."""
+ l.log_enable()
+
+def enableScreen():
+ """Enable logging to screen."""
+ l.log_enableScreen()
+
+def enableFile():
+ """Enable logging to file (note that a file has to be set)."""
+ l.log_enableFile()
+
+def disable():
+ """Disable all logging."""
+ l.log_disable()
+
+def disableScreen():
+ """Disable logging to screen."""
+ l.log_disableScreen()
+
+def disableFile():
+ """Disable logging to file."""
+ l.log_disableFile()
+
+def setFormatFile(fmt):
+ """Set the format string for log messages. Here are the substitutions you may use:
+
+ %f: Source file name generating the log call.
+ %n: Source line number where the log call was made.
+ %m: The message text sent to the logger (after printf formatting).
+ %d: The current date, formatted using the logger's date format.
+ %t: The current time, formatted using the logger's time format.
+ %l: The log level (one of "DEBUG", "INFO", "WARN", or "ERROR").
+ %%: A literal percent sign.
+
+ The default format string is "%d %t %f(%n): %l: %m\n".
+
+ :param fmt: Format to use, end with "\n".
+ :type fmt: :class:`string`
+ """
+ l.log_setFormatFile(fmt)
+
+def setFormatScreen(fmt):
+ """Set the format string for log messages. Here are the substitutions you may use:
+
+ %f: Source file name generating the log call.
+ %n: Source line number where the log call was made.
+ %m: The message text sent to the logger (after printf formatting).
+ %d: The current date, formatted using the logger's date format.
+ %t: The current time, formatted using the logger's time format.
+ %l: The log level (one of "DEBUG", "INFO", "WARN", or "ERROR").
+ %%: A literal percent sign.
+
+ The default format string is "%d %t %f(%n): %l: %m\n".
+
+ :param fmt: Format to use, end with "\n".
+ :type fmt: :class:`string`
+ """
+ l.log_setFormatScreen(fmt)
+
+STDOUT=1
+STDERR=2
+
+DEBUG=0
+INFO=1
+WARN=2
+ERROR=3
+
+def setOutputScreen(fd, level):
+ """Set which screen to output to, and which level to use.
+
+ :param fd: File descriptor of output screen (STDOUT or STDERR).
+ :type fd: :class:`int`
+ :param level: Logging level to use (DEBUG, INFO, WARN, or ERROR).
+ :type level: :class:`int`
+ """
+ l.log_setOutputScreen(fd, level)
+
+def setOutputFile(filename, level):
+ """Set which file to output to, and which level to use.
+
+ :param filename: File name of output file.
+ :type filename: :class:`string`
+ :param level: Logging level to use (DEBUG, INFO, WARN, or ERROR).
+ :type level: :class:`int`
+ """
+ l.log_setOutputFile(filename, level) \ No newline at end of file
diff --git a/python/astra/log_c.pyx b/python/astra/log_c.pyx
new file mode 100644
index 0000000..969cc06
--- /dev/null
+++ b/python/astra/log_c.pyx
@@ -0,0 +1,96 @@
+#-----------------------------------------------------------------------
+#Copyright 2013 Centrum Wiskunde & Informatica, Amsterdam
+#
+#Author: Daniel M. Pelt
+#Contact: D.M.Pelt@cwi.nl
+#Website: http://dmpelt.github.io/pyastratoolbox/
+#
+#
+#This file is part of the Python interface to the
+#All Scale Tomographic Reconstruction Antwerp Toolbox ("ASTRA Toolbox").
+#
+#The Python interface to the ASTRA Toolbox is free software: you can redistribute it and/or modify
+#it under the terms of the GNU General Public License as published by
+#the Free Software Foundation, either version 3 of the License, or
+#(at your option) any later version.
+#
+#The Python interface to the ASTRA Toolbox is distributed in the hope that it will be useful,
+#but WITHOUT ANY WARRANTY; without even the implied warranty of
+#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+#GNU General Public License for more details.
+#
+#You should have received a copy of the GNU General Public License
+#along with the Python interface to the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>.
+#
+#-----------------------------------------------------------------------
+# distutils: language = c++
+# distutils: libraries = astra
+
+import six
+
+cdef extern from "astra/Logging.h" namespace "astra":
+ cdef enum log_level:
+ LOG_DEBUG
+ LOG_INFO
+ LOG_WARN
+ LOG_ERROR
+
+cdef extern from "astra/Logging.h" namespace "astra::CLogger":
+ void debug(const char *sfile, int sline, const char *fmt, ...)
+ void info(const char *sfile, int sline, const char *fmt, ...)
+ void warn(const char *sfile, int sline, const char *fmt, ...)
+ void error(const char *sfile, int sline, const char *fmt, ...)
+ void setOutputScreen(int fd, log_level m_eLevel)
+ void setOutputFile(const char *filename, log_level m_eLevel)
+ void enable()
+ void enableScreen()
+ void enableFile()
+ void disable()
+ void disableScreen()
+ void disableFile()
+ void setFormatFile(const char *fmt)
+ void setFormatScreen(const char *fmt)
+
+def log_debug(sfile, sline, message):
+ debug(six.b(sfile),sline,six.b(message))
+
+def log_info(sfile, sline, message):
+ info(six.b(sfile),sline,six.b(message))
+
+def log_warn(sfile, sline, message):
+ warn(six.b(sfile),sline,six.b(message))
+
+def log_error(sfile, sline, message):
+ error(six.b(sfile),sline,six.b(message))
+
+def log_enable():
+ enable()
+
+def log_enableScreen():
+ enableScreen()
+
+def log_enableFile():
+ enableFile()
+
+def log_disable():
+ disable()
+
+def log_disableScreen():
+ disableScreen()
+
+def log_disableFile():
+ disableFile()
+
+def log_setFormatFile(fmt):
+ setFormatFile(six.b(fmt))
+
+def log_setFormatScreen(fmt):
+ setFormatScreen(six.b(fmt))
+
+enumList = [LOG_DEBUG,LOG_INFO,LOG_WARN,LOG_ERROR]
+
+def log_setOutputScreen(fd, level):
+ setOutputScreen(fd, enumList[level])
+
+def log_setOutputFile(filename, level):
+ setOutputFile(six.b(filename), enumList[level]) \ No newline at end of file
diff --git a/src/ConeProjectionGeometry3D.cpp b/src/ConeProjectionGeometry3D.cpp
index eb9adcf..1976901 100644
--- a/src/ConeProjectionGeometry3D.cpp
+++ b/src/ConeProjectionGeometry3D.cpp
@@ -28,6 +28,8 @@ $Id$
#include "astra/ConeProjectionGeometry3D.h"
+#include "astra/Logging.h"
+
#include <boost/lexical_cast.hpp>
#include <cstring>
@@ -257,7 +259,7 @@ void CConeProjectionGeometry3D::projectPoint(float32 fX, float32 fY, float32 fZ,
// Scale fS to detector plane
fU = detectorOffsetXToColIndexFloat( (fS * (m_fOriginSourceDistance + m_fOriginDetectorDistance)) / fD );
- fprintf(stderr, "alpha: %f, D: %f, V: %f, S: %f, U: %f\n", alpha, fD, fV, fS, fU);
+ ASTRA_DEBUG("alpha: %f, D: %f, V: %f, S: %f, U: %f", alpha, fD, fV, fS, fU);
}
diff --git a/src/Config.cpp b/src/Config.cpp
index 653935e..d860638 100644
--- a/src/Config.cpp
+++ b/src/Config.cpp
@@ -37,6 +37,9 @@ $Id$
#include "astra/Projector2D.h"
#include "astra/Projector3D.h"
+#include "astra/Logging.h"
+#include <sstream>
+
using namespace astra;
using namespace std;
@@ -144,7 +147,9 @@ bool ConfigStackCheck<T>::stopParsing()
nodes.clear();
if (!errors.empty()) {
- cout << "Warning: " << name << ": unused configuration options: " << errors << std::endl;
+ ostringstream os;
+ os << name << ": unused configuration options: " << errors;
+ ASTRA_WARN(os.str().c_str());
return false;
}
diff --git a/src/CudaFilteredBackProjectionAlgorithm.cpp b/src/CudaFilteredBackProjectionAlgorithm.cpp
index fcdf860..0badc20 100644
--- a/src/CudaFilteredBackProjectionAlgorithm.cpp
+++ b/src/CudaFilteredBackProjectionAlgorithm.cpp
@@ -34,7 +34,7 @@ $Id$
#include "astra/AstraObjectManager.h"
#include "../cuda/2d/astra.h"
-#include <astra/Logger.h>
+#include "astra/Logging.h"
using namespace std;
using namespace astra;
@@ -105,7 +105,7 @@ bool CCudaFilteredBackProjectionAlgorithm::initialize(const Config& _cfg)
}
CC.markNodeParsed("FilterType");
ASTRA_DELETE(node);
-
+
// filter
node = _cfg.self->getSingleNode("FilterSinogramId");
if(node != NULL)
@@ -168,7 +168,7 @@ bool CCudaFilteredBackProjectionAlgorithm::initialize(const Config& _cfg)
CC.markOptionParsed("ShortScan");
}
-
+
m_pFBP = new AstraFBP;
@@ -186,7 +186,7 @@ bool CCudaFilteredBackProjectionAlgorithm::initialize(CFloat32ProjectionData2D *
{
clear();
}
-
+
// required classes
m_pSinogram = _pSinogram;
m_pReconstruction = _pReconstruction;
@@ -326,7 +326,7 @@ void CCudaFilteredBackProjectionAlgorithm::run(int _iNrIterations /* = 0 */)
const CVolumeGeometry2D& volgeom = *m_pReconstruction->getGeometry();
ok &= m_pFBP->getReconstruction(m_pReconstruction->getData(), volgeom.getGridColCount());
-
+
ASTRA_ASSERT(ok);
}
@@ -335,7 +335,7 @@ bool CCudaFilteredBackProjectionAlgorithm::check()
// check pointers
ASTRA_CONFIG_CHECK(m_pSinogram, "FBP_CUDA", "Invalid Projection Data Object.");
ASTRA_CONFIG_CHECK(m_pReconstruction, "FBP_CUDA", "Invalid Reconstruction Data Object.");
-
+
if((m_eFilter == FILTER_PROJECTION) || (m_eFilter == FILTER_SINOGRAM) || (m_eFilter == FILTER_RPROJECTION) || (m_eFilter == FILTER_RSINOGRAM))
{
ASTRA_CONFIG_CHECK(m_pfFilter, "FBP_CUDA", "Invalid filter pointer.");
@@ -387,7 +387,7 @@ static bool stringCompareLowerCase(const char * _stringA, const char * _stringB)
#else
iCmpReturn = strcasecmp(_stringA, _stringB);
#endif
-
+
return (iCmpReturn == 0);
}
@@ -485,7 +485,7 @@ E_FBPFILTER CCudaFilteredBackProjectionAlgorithm::_convertStringToFilter(const c
}
else
{
- cerr << "Failed to convert \"" << _filterType << "\" into a filter." << endl;
+ ASTRA_ERROR("Failed to convert \"%s\" into a filter.",_filterType);
}
return output;
diff --git a/src/CudaForwardProjectionAlgorithm.cpp b/src/CudaForwardProjectionAlgorithm.cpp
index ab0d643..95abb62 100644
--- a/src/CudaForwardProjectionAlgorithm.cpp
+++ b/src/CudaForwardProjectionAlgorithm.cpp
@@ -42,6 +42,8 @@ $Id$
#include "astra/FanFlatVecProjectionGeometry2D.h"
#include "astra/CudaProjector2D.h"
+#include "astra/Logging.h"
+
using namespace std;
namespace astra {
@@ -104,7 +106,7 @@ bool CCudaForwardProjectionAlgorithm::initialize(const Config& _cfg)
id = boost::lexical_cast<int>(node->getContent());
CProjector2D *projector = CProjector2DManager::getSingleton().get(id);
if (!dynamic_cast<CCudaProjector2D*>(projector)) {
- cout << "Warning: non-CUDA Projector2D passed to FP_CUDA" << std::endl;
+ ASTRA_WARN("non-CUDA Projector2D passed to FP_CUDA");
}
delete node;
}
diff --git a/src/CudaForwardProjectionAlgorithm3D.cpp b/src/CudaForwardProjectionAlgorithm3D.cpp
index bb122e0..8e6bab5 100644
--- a/src/CudaForwardProjectionAlgorithm3D.cpp
+++ b/src/CudaForwardProjectionAlgorithm3D.cpp
@@ -40,6 +40,8 @@ $Id$
#include "astra/ParallelVecProjectionGeometry3D.h"
#include "astra/ConeVecProjectionGeometry3D.h"
+#include "astra/Logging.h"
+
#include "../cuda/3d/astra3d.h"
using namespace std;
@@ -265,7 +267,7 @@ void CCudaForwardProjectionAlgorithm3D::run(int)
for (int k = 0; k < 2; ++k) {
float fU, fV;
projgeom->projectPoint(fX[i], fY[j], fZ[k], a, fU, fV);
- fprintf(stderr, "%3d %c1,%c1,%c1 -> %12f %12f\n", a, i ? ' ' : '-', j ? ' ' : '-', k ? ' ' : '-', fU, fV);
+ ASTRA_DEBUG("%3d %c1,%c1,%c1 -> %12f %12f", a, i ? ' ' : '-', j ? ' ' : '-', k ? ' ' : '-', fU, fV);
}
}
#endif
diff --git a/src/CudaReconstructionAlgorithm2D.cpp b/src/CudaReconstructionAlgorithm2D.cpp
index d3dedc5..1c6b763 100644
--- a/src/CudaReconstructionAlgorithm2D.cpp
+++ b/src/CudaReconstructionAlgorithm2D.cpp
@@ -37,6 +37,8 @@ $Id$
#include "astra/FanFlatVecProjectionGeometry2D.h"
#include "astra/CudaProjector2D.h"
+#include "astra/Logging.h"
+
#include "../cuda/2d/algo.h"
#include <ctime>
@@ -176,7 +178,7 @@ bool CCudaReconstructionAlgorithm2D::initialize(const Config& _cfg)
id = boost::lexical_cast<int>(node->getContent());
CProjector2D *projector = CProjector2DManager::getSingleton().get(id);
if (!dynamic_cast<CCudaProjector2D*>(projector)) {
- cout << "Warning: non-CUDA Projector2D passed" << std::endl;
+ ASTRA_WARN("non-CUDA Projector2D passed");
}
delete node;
}
diff --git a/src/FilteredBackProjectionAlgorithm.cpp b/src/FilteredBackProjectionAlgorithm.cpp
index 50cf939..4a8e5ac 100644
--- a/src/FilteredBackProjectionAlgorithm.cpp
+++ b/src/FilteredBackProjectionAlgorithm.cpp
@@ -39,6 +39,8 @@ $Id$
#include "astra/Fourier.h"
#include "astra/DataProjector.h"
+#include "astra/Logging.h"
+
using namespace std;
namespace astra {
@@ -133,7 +135,7 @@ bool CFilteredBackProjectionAlgorithm::initialize(const Config& _cfg)
for (int i = 0; i < angleCount; i ++) {
if (projectionIndex[i] > m_pProjector->getProjectionGeometry()->getProjectionAngleCount() -1 )
{
- cout << "Invalid Projection Index" << endl;
+ ASTRA_ERROR("Invalid Projection Index");
return false;
} else {
int orgIndex = (int)projectionIndex[i];
diff --git a/src/Logger.cpp b/src/Logger.cpp
deleted file mode 100644
index 148e18c..0000000
--- a/src/Logger.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
------------------------------------------------------------------------
-Copyright: 2010-2015, iMinds-Vision Lab, University of Antwerp
- 2014-2015, CWI, Amsterdam
-
-Contact: astra@uantwerpen.be
-Website: http://sf.net/projects/astra-toolbox
-
-This file is part of the ASTRA Toolbox.
-
-
-The ASTRA Toolbox is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-The ASTRA Toolbox is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>.
-
------------------------------------------------------------------------
-$Id$
-*/
-
-#include <astra/Logger.h>
-
-using namespace astra;
-
-const char * g_loggerFileName = "astra_logger.txt";
-
-void CLogger::_assureIsInitialized()
-{
- if(!m_bInitialized)
- {
- m_pOutFile = fopen(g_loggerFileName, "r");
- if(m_pOutFile != NULL)
- {
- // file exists, users wants to log
- fclose(m_pOutFile);
- m_pOutFile = fopen(g_loggerFileName, "w");
- }
-
- m_bInitialized = true;
- }
-}
-
-void CLogger::writeLine(const char * _text)
-{
- _assureIsInitialized();
-
- if(m_pOutFile != NULL)
- {
- fprintf(m_pOutFile, "%s\n", _text);
- fflush(m_pOutFile);
- }
-}
-
-void CLogger::writeTerminalCUDAError(const char * _fileName, int _iLine, const char * _errString)
-{
- char buffer[256];
-
- sprintf(buffer, "Cuda error in file '%s' in line %i : %s.", _fileName, _iLine, _errString);
-
- writeLine(buffer);
-}
-
-CLogger::CLogger()
-{
- ;
-}
-
-FILE * CLogger::m_pOutFile = NULL;
-bool CLogger::m_bInitialized = false;
diff --git a/src/Logging.cpp b/src/Logging.cpp
new file mode 100644
index 0000000..8290ca0
--- /dev/null
+++ b/src/Logging.cpp
@@ -0,0 +1,184 @@
+/*
+-----------------------------------------------------------------------
+Copyright: 2010-2015, iMinds-Vision Lab, University of Antwerp
+ 2014-2015, CWI, Amsterdam
+
+Contact: astra@uantwerpen.be
+Website: http://sf.net/projects/astra-toolbox
+
+This file is part of the ASTRA Toolbox.
+
+
+The ASTRA Toolbox is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+The ASTRA Toolbox is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>.
+
+-----------------------------------------------------------------------
+$Id$
+*/
+
+#define CLOG_MAIN
+#include <astra/clog.h>
+
+#include <astra/Logging.h>
+
+#include <cstdio>
+
+using namespace astra;
+
+void CLogger::enableScreen()
+{
+ m_bEnabledScreen = true;
+}
+
+void CLogger::enableFile()
+{
+ m_bEnabledFile = true;
+}
+
+void CLogger::enable()
+{
+ enableScreen();
+ enableFile();
+}
+
+void CLogger::disableScreen()
+{
+ m_bEnabledScreen = false;
+}
+
+void CLogger::disableFile()
+{
+ m_bEnabledFile = false;
+}
+
+void CLogger::disable()
+{
+ disableScreen();
+ disableFile();
+}
+
+void CLogger::debug(const char *sfile, int sline, const char *fmt, ...)
+{
+ _assureIsInitialized();
+ va_list ap;
+ va_start(ap, fmt);
+ if(m_bEnabledScreen) clog_debug(sfile,sline,0,fmt,ap);
+ if(m_bEnabledFile && m_bFileProvided) clog_debug(sfile,sline,1,fmt,ap);
+}
+
+void CLogger::info(const char *sfile, int sline, const char *fmt, ...)
+{
+ _assureIsInitialized();
+ va_list ap;
+ va_start(ap, fmt);
+ if(m_bEnabledScreen) clog_info(sfile,sline,0,fmt,ap);
+ if(m_bEnabledFile && m_bFileProvided) clog_info(sfile,sline,1,fmt,ap);
+}
+
+void CLogger::warn(const char *sfile, int sline, const char *fmt, ...)
+{
+ _assureIsInitialized();
+ va_list ap;
+ va_start(ap, fmt);
+ if(m_bEnabledScreen) clog_warn(sfile,sline,0,fmt,ap);
+ if(m_bEnabledFile && m_bFileProvided) clog_warn(sfile,sline,1,fmt,ap);
+}
+
+void CLogger::error(const char *sfile, int sline, const char *fmt, ...)
+{
+ _assureIsInitialized();
+ va_list ap;
+ va_start(ap, fmt);
+ if(m_bEnabledScreen) clog_error(sfile,sline,0,fmt,ap);
+ if(m_bEnabledFile && m_bFileProvided) clog_error(sfile,sline,1,fmt,ap);
+}
+
+void CLogger::_setLevel(int id, log_level m_eLevel)
+{
+ switch(m_eLevel){
+ case LOG_DEBUG:
+ clog_set_level(id,CLOG_DEBUG);
+ break;
+ case LOG_INFO:
+ clog_set_level(id,CLOG_INFO);
+ break;
+ case LOG_WARN:
+ clog_set_level(id,CLOG_WARN);
+ break;
+ case LOG_ERROR:
+ clog_set_level(id,CLOG_ERROR);
+ break;
+ }
+}
+
+void CLogger::setOutputScreen(int fd, log_level m_eLevel)
+{
+ _assureIsInitialized();
+ if(fd==1||fd==2){
+ clog_set_fd(0, fd);
+ }else{
+ error(__FILE__,__LINE__,"Invalid file descriptor");
+ }
+ _setLevel(0,m_eLevel);
+}
+
+void CLogger::setOutputFile(const char *filename, log_level m_eLevel)
+{
+ if(m_bFileProvided){
+ clog_free(1);
+ m_bFileProvided=false;
+ }
+ if(!clog_init_path(1,filename)){
+ m_bFileProvided=true;
+ _setLevel(1,m_eLevel);
+ }
+}
+
+void CLogger::_assureIsInitialized()
+{
+ if(!m_bInitialized)
+ {
+ clog_init_fd(0, 2);
+ clog_set_level(0, CLOG_INFO);
+ clog_set_fmt(0, "%l: %m\n");
+ m_bInitialized = true;
+ }
+}
+
+void CLogger::setFormatFile(const char *fmt)
+{
+ if(m_bFileProvided){
+ clog_set_fmt(1,fmt);
+ }else{
+ error(__FILE__,__LINE__,"No log file specified");
+ }
+}
+void CLogger::setFormatScreen(const char *fmt)
+{
+ clog_set_fmt(0,fmt);
+}
+
+CLogger::CLogger()
+{
+ ;
+}
+
+bool CLogger::setCallbackScreen(void (*cb)(const char *msg, size_t len)){
+ _assureIsInitialized();
+ return clog_set_cb(0,cb)==0;
+}
+
+bool CLogger::m_bEnabledScreen = true;
+bool CLogger::m_bEnabledFile = true;
+bool CLogger::m_bFileProvided = false;
+bool CLogger::m_bInitialized = false;