Commit cce7daf979edbfc4304a6c648edb71b0a4eaa800

Authored by Pavel Govyadinov
1 parent 00eb6825

added glObj.h to stim/visualization/, basic rendering and creation, no advanced …

…features (will probably be implemented in another class). Has not been tested. Renamed all instances of mathvec.h with vector.h
stim/cuda/cost.h
... ... @@ -5,7 +5,7 @@
5 5 #include <stdio.h>
6 6 #include <stim/visualization/colormap.h>
7 7 #include <sstream>
8   -#include <stim/math/mathvec.h>
  8 +#include <stim/math/vector.h>
9 9 #include <stim/cuda/devices.h>
10 10 #include <stim/cuda/threads.h>
11 11  
... ... @@ -39,7 +39,7 @@ float get_sum(float *diff)
39 39 ret = cublasSetVector(20*10, sizeof(*diff), diff, 1, v_dif, 1);
40 40 float out;
41 41 ret = cublasSasum(handle, 20*10, v_dif, 1, &out);
42   - cublasDestroy(ret);
  42 +// cublasDestroy(ret);
43 43 cublasDestroy(handle);
44 44 return out;
45 45 }
... ... @@ -139,24 +139,27 @@ stim::vec&lt;int&gt; get_cost(cudaGraphicsResource_t src, int DIM_Y)
139 139 // cudaOccupancyMaxPotentialBlockSize(&minGridSize, &blockSize, get_diff, 0, 20*DIM_Y*10);
140 140 // std::cout << blockSize << std::endl;
141 141 // std::cout << minGridSize << std::endl;
  142 +// stringstream name; //for debugging
  143 +// name << "Test.bmp";
  144 +// dim3 block(4,4);
  145 +// dim3 grid(20/4, DIM_Y*10/4);
  146 +// int gridSize = (DIM_Y*10*20 + 1024 - 1)/1024;
  147 +// dim3 grid(26, 26);
  148 +// dim3 grid = GenGrid1D(DIM_Y*10*20);
  149 +// stim::gpu2image<float>(result, name.str(), 20,DIM_Y*10,0,1);
  150 +// name.clear();
  151 +// name << "sample_" << inter << "_" << idx << ".bmp";
  152 +// stim::gpu2image<float>(v_dif, name.str(), 20,10,0,1);
142 153  
143 154 float output[DIM_Y];
144 155 stim::vec<int> ret(0, 0);
145 156 float mini = 10000000000000000.0;
146 157 int idx;
147   - stringstream name; //for debugging
148   -// name << "Test.bmp";
149 158 initArray(src, DIM_Y*10);
150 159 dim3 grid(20/2, DIM_Y*10/2);
151   -// dim3 block(4,4);
152   -// dim3 grid(20/4, DIM_Y*10/4);
153   -// int gridSize = (DIM_Y*10*20 + 1024 - 1)/1024;
154   -// dim3 grid(26, 26);
155 160 dim3 block(2, 2);
156   -// dim3 grid = GenGrid1D(DIM_Y*10*20);
157 161  
158 162 get_diff <<< grid, block >>> (result);
159   -// stim::gpu2image<float>(result, name.str(), 20,DIM_Y*10,0,1);
160 163 for (int i = 0; i < DIM_Y; i++){
161 164 output[i] = get_sum(result+(20*10*i));
162 165 if(output[i] <= mini){
... ... @@ -165,10 +168,7 @@ stim::vec&lt;int&gt; get_cost(cudaGraphicsResource_t src, int DIM_Y)
165 168 }
166 169 }
167 170  
168   -// name.clear();
169   -// name << "sample_" << inter << "_" << idx << ".bmp";
170 171 output[idx] = get_sum(result+(20*10*idx));
171   -// stim::gpu2image<float>(v_dif, name.str(), 20,10,0,1);
172 172 cleanUP(src);
173 173 ret[0] = idx; ret[1] = (int) output[idx];
174 174 return ret;
... ...
stim/gl/gl_spider.h
... ... @@ -10,7 +10,7 @@
10 10 #include "stim/gl/gl_texture.h"
11 11 #include "stim/visualization/camera.h"
12 12 #include "stim/gl/error.h"
13   -#include "stim/math/mathvec.h"
  13 +#include "stim/math/vector.h"
14 14 #include "stim/math/rect.h"
15 15 #include "stim/math/matrix.h"
16 16 #include "stim/cuda/cost.h"
... ... @@ -144,7 +144,7 @@ class gl_spider
144 144 ///Method for populating the vector arrays with sampled vectors.
145 145 ///uses the default d vector <0,0,1>
146 146 void
147   - genDirectionVectors(float solidAngle = M_PI)
  147 + genDirectionVectors(float solidAngle = 5*M_PI/4)
148 148 {
149 149 //ofstream file;
150 150 //file.open("dvectors.txt");
... ...
stim/grids/grid.h
... ... @@ -7,7 +7,7 @@
7 7 #include <fstream>
8 8 #include <cstdarg>
9 9  
10   -#include "../math/mathvec.h"
  10 +#include <stim/math/vector.h>
11 11  
12 12 namespace stim{
13 13  
... ...
stim/math/matrix.h
... ... @@ -4,7 +4,7 @@
4 4 //#include "rts/vector.h"
5 5 #include <string.h>
6 6 #include <iostream>
7   -#include "mathvec.h"
  7 +#include <stim/math/vector.h>
8 8 #include "../cuda/callable.h"
9 9  
10 10 namespace stim{
... ...
stim/math/plane.h
... ... @@ -2,7 +2,7 @@
2 2 #define RTS_PLANE_H
3 3  
4 4 #include <iostream>
5   -#include "../math/vector.h"
  5 +#include <stim/math/vector.h>
6 6 #include "rts/cuda/callable.h"
7 7  
8 8  
... ...
stim/math/quad.h
... ... @@ -2,10 +2,10 @@
2 2 #define RTS_QUAD_H
3 3  
4 4 //enable CUDA_CALLABLE macro
5   -#include "../cuda/callable.h"
6   -#include "../math/vector.h"
7   -#include "../math/triangle.h"
8   -#include "../math/quaternion.h"
  5 +#include <stim/cuda/callable.h>
  6 +#include <stim/math/vector.h>
  7 +#include <stim/math/triangle.h>
  8 +#include <stim/math/quaternion.h>
9 9 #include <iostream>
10 10 #include <iomanip>
11 11 #include <algorithm>
... ...
stim/math/rect.h
... ... @@ -2,10 +2,10 @@
2 2 #define RTS_RECT_H
3 3  
4 4 //enable CUDA_CALLABLE macro
5   -#include "../cuda/callable.h"
6   -#include "../math/mathvec.h"
7   -#include "../math/triangle.h"
8   -#include "../math/quaternion.h"
  5 +#include <stim/cuda/callable.h>
  6 +#include <stim/math/vector.h>
  7 +#include <stim/math/triangle.h>
  8 +#include <stim/math/quaternion.h>
9 9 #include <iostream>
10 10 #include <iomanip>
11 11 #include <algorithm>
... ...
stim/math/spharmonics.h
1 1 #ifndef STIM_SPH_HARMONICS
2 2 #define STIM_SPH_HARMONICS
3 3  
4   -#include <stim/math/mathvec.h>
  4 +#include <stim/math/vector.h>
5 5 #include <boost/math/special_functions/spherical_harmonic.hpp>
6 6 #include <vector>
7 7  
... ...
stim/math/triangle.h
... ... @@ -2,8 +2,8 @@
2 2 #define RTS_TRIANGLE_H
3 3  
4 4 //enable CUDA_CALLABLE macro
5   -#include "../cuda/callable.h"
6   -#include "../math/mathvec.h"
  5 +#include <stim/cuda/callable.h>
  6 +#include <stim/math/vector.h>
7 7 #include <iostream>
8 8  
9 9 namespace stim{
... ...
stim/visualization/camera.h
1   -#include "../math/mathvec.h"
2   -#include "../math/quaternion.h"
3   -#include "../math/matrix.h"
  1 +#include <stim/math/vector.h>
  2 +#include <stim/math/quaternion.h>
  3 +#include <stim/math/matrix.h>
4 4  
5 5 #include <ostream>
6 6  
... ...
stim/visualization/glObj.h 0 → 100644
  1 +#ifndef STIM_GLOBJ_H
  2 +#define STIM_GLOBJ_H
  3 +
  4 +#include <stim/visualization/obj.h>
  5 +#include <GL/glew.h>
  6 +#include <GL/glut.h>
  7 +#include <stim/math/vector.h>
  8 +
  9 +
  10 +namespace stim
  11 +{
  12 +/** This class uses the loading functionality of the obj class in order to
  13 + * Assist with the visualization the segmented vessels.
  14 + * Uses
  15 +*/
  16 +
  17 +class objGl : public virtual stim::obj<T>
  18 +{
  19 +private:
  20 + using stim::obj<T>::L;
  21 + using stim::obj<T>::P;
  22 + using stim::obj<T>::F;
  23 + using vec<T>::size;
  24 + using vec<T>::at;
  25 + GLuint dList;
  26 +
  27 +
  28 + void
  29 + init
  30 + {
  31 + dList = glGenList(1);
  32 + glListBase(dList);
  33 + glMatrixMode(GL_PROJECTION);
  34 + glLoadIdentity;
  35 + glMatrixMode(GL_MODELVIEW);
  36 + glLoadIdentity;
  37 +
  38 + }
  39 +
  40 + void
  41 + Create()
  42 + {
  43 + int len = (int) numL();
  44 + std::vector< stim::vec<float> > line;
  45 + glNewList(dList, GL_COMPILE);
  46 + glColor3f(0.5, 1.0, 0.5);
  47 + for(int i = 0; i < len; i++){
  48 + line = getL_V(i);
  49 + glBegin(GL_LINES);
  50 + for(int j = 0; j < line.size(); j++){
  51 + glVectex3f(
  52 + line[j][0],
  53 + line[j][1],
  54 + line[j][2]
  55 + );
  56 + }
  57 + glEnd();
  58 + }
  59 + glEndList();
  60 + }
  61 +
  62 +public:
  63 + objGl(std::string filename)
  64 + {
  65 + stim::obj::load(filename);
  66 + glPopMatrix(); //Safety Operation to avoid changing the current matrix.
  67 + init();
  68 + Create();
  69 + glPushMatrix();
  70 + }
  71 +
  72 +
  73 + void
  74 + Render()
  75 + {
  76 + glCallList(dList);
  77 + }
  78 +
  79 +}
  80 +}
... ...