MorphoGraphX
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ImageData.hpp
1 #ifndef IMAGE_DATA_H
2 
3 #define IMAGE_DATA_H
4 
5 #include <Config.hpp>
6 
7 #include <ClipRegion.hpp>
8 #include <ColorBar.hpp>
9 #include <Colors.hpp>
10 #include <Geometry.hpp>
11 #include <Mesh.hpp>
12 #include <MGXViewer/qglviewer.h>
13 #include <Misc.hpp>
14 #include <Parms.hpp>
15 #include <Process.hpp>
16 #include <ScaleBar.hpp>
17 #include <Shader.hpp>
18 #include <TransferFunctionDlg.hpp>
19 #include <TransferFunction.hpp>
20 
21 #include <CImg.h>
22 #include <QtGui>
23 #include <string>
24 #include <string.h>
25 
26 namespace mgx {
27 
28  class CutSurf;
29 
30  typedef util::Vector<4, vertex> Point4v;
31  typedef util::Vector<3, GLubyte> Point3GLub;
32 
33  struct UpdateImgDataEvent : public QEvent {
34  UpdateImgDataEvent() : QEvent(QEvent::User) {}
35  };
36 
37  class mgx_EXPORT ImgData : public QObject //, public ImplicitFunction
38  {
39  Q_OBJECT
40  public:
42 
43  static const uint RELOAD_NONE = 0x0;
44  static const uint RELOAD_MAIN = 0x1;
45  static const uint RELOAD_WORK = 0x2;
46  static const uint RELOAD_TRIS = 0x4;
47  static const uint RELOAD_LINES = 0x8;
48  static const uint RELOAD_POS = 0x10;
49  static const uint RELOAD_VBO = 0x20;
50  static const uint UPDATE_SELECTION = 0x40;
51 
52  int StackId;
53 
54  Stack* stack;
55  Mesh* mesh;
56 
57  // Main and stack paramters
58  bool Main16Bit, Work16Bit;
59 
60  // General
61  bool needUpdateLines;
62  bool needUpdateTris;
63 
64  gui::TransferFunctionDlg* workTransferDlg, *mainTransferDlg, *surfTransferDlg, *heatTransferDlg;
65  // Function defining the color of the pixels
66  std::vector<TransferFunction::Colorf> MainColorMap; // Color map for the main data
67  std::vector<TransferFunction::Colorf> WorkColorMap; // Color map for the work data
68  std::vector<TransferFunction::Colorf> SurfColorMap; // Color map for the surface
69  std::vector<TransferFunction::Colorf> HeatColorMap; // Color map for the heatmap
70  // If true, a new texture need to be sent for the colormap
71  bool newMainColorMap, newWorkColorMap, newSurfColorMap, newHeatColorMap;
72  std::vector<double> MainHist; // Histogram of the main data
73  std::vector<double> WorkHist; // Histogram of the working data
74  std::vector<double> SurfHist; // Histogram of the surface data
75  std::vector<double> HeatHist; // Histogram of the surface data
76  std::pair<double, double> mainBounds;
77  std::pair<double, double> workBounds;
78 
79  GLuint mainDataTexId; // 3D texture Id for main stack
80  GLuint workDataTexId; // 3D texture Id for work stack
81  GLuint dataTexColor; // 3D texture color
82  GLuint surfTexId; // 1D texture map for surface colors.
83  GLuint heatTexId; // 1D texture map for heatmap colors.
84  GLuint imgTexId; // 2D texture map for surface from an image
85  GLuint mcmapTexId, wcmapTexId; // 1D texture map for volume colors.
86  GLuint labelTexId; // 1D texture map to color indexed texture for labels
87  graph::vertex_identity_t lineId; // Last id when drawing lines
88  std::set<uint> selectV; // List of selected vertices
89 
90  Colors::ColorType MeshColor;
91  Colors::ColorType MeshBorderColor;
92  // Colors::ColorType MeshPointColor;
93  Colors::ColorType MeshSelectColor;
94 
95  int TCount; // Triangle count
96  int LCount; // Line count
97  int VCount; // Vertex count
98 
99  // Helper arrays for vertex buffer obejects
100  std::vector<vertex> idVA; // Vertex ids, used to find selection in triangle mode (!MeshSelect)
101  std::vector<vertex> pidVA; // Point vtx ids, used to find selection in point mode (MeshSelect)
102  std::unordered_map<vertex, uint> vMap; // Pointer into idVA by vertex
103 
104  // VBO arrays
105  std::vector<Point3f> posVA; // Vertex positions
106  std::vector<Point3f> nrmlVA; // Vertex normals
107  std::vector<Point3GLub> selVA; // Unique colors for triangle selection
108  std::vector<Point3f> texVA; // Mesh labels, signal, and heat
109  std::vector<Point2f> imgVA; // Image texture coordinates
110 
111  std::vector<uint> lineVA; // Indices for drawing lines
112  std::vector<uint> lbrdVA; // Indices for drawing border lines
113  std::vector<uint> lcellVA; // Indices for drawing cell border lines
114  std::vector<uint> lselVA; // Indices for drawing selected lines
115 
116  std::vector<uint> pbrdVA; // Indices for drawing border points
117  std::vector<uint> pcellVA; // Indices for drawing cell border points
118  std::vector<uint> pselVA; // Indices for drawing selected points
119  std::vector<Point3f> pntsVA; // Vertices for drawing points
120  std::vector<Point3GLub> pcolVA; // Colors for points
121  std::vector<Point3GLub> pselcolVA; // Selection colors for points
122 
123  GLuint posVAid; // VBO object ids
124  GLuint nrmlVAid;
125  GLuint selVAid;
126  GLuint texVAid;
127  GLuint imgVAid;
128 
129  GLuint pntsVAid;
130  GLuint pcolVAid;
131  GLuint pselVAid;
132 
133  GLubyte* texMap; // Texture map to memory
134 
135  // Parameters from stack file
136  QString Section;
137  std::vector<QString> ImageFiles;
138 
139  QWidget* parent; // Parent widget
140  float min, max;
141 
142  // Vectors to make heat maps
143  float labelWallBordMin;
144  float labelWallBordMax;
145  QString sigStr; // Description of heat map
146  IntPoint3fMap LabC; // Label Centers
147  Point3u clipDo; // Which clipping planes are selected
148  Point4f pn[6]; // Clip planes tranformed into frame coordinates
149  HVec4F Hpn; // Host vector for planes for cuda
150  Matrix4d frm; // Frame matrix
151  Matrix4d clm[3]; // Clip plane matrices
152  float pixelRadius; // Radius in frame coordinates of pixel edit tool
153  BoundingBox3f bBox; // Bounding box
154  BoundingBox3i bBoxTex; // Bounding box for texture update
155  int marchLabel; // Label for maching cubes on segmented stack
156 
157  bool LoadMeshAdd;
158  float meshShift; // Shift for the mesh, relative to the scene radius
159 
160  // Variables to marching cubes (for eval)
161  HVecUS* marchData;
162 
163  bool EnableRotate;
164 
165  bool readOnce; // Used for parameter loading
166 
167  // Parameters shared by all instances
168  static int ClearColor;
169  static uint Slices;
170  static uint TileCount;
171  static Point3u MaxTexSize;
172  static float ZOffset;
173 
174  static float DrawNormals;
175  static float DrawOffset;
176  static float DrawZeroLabels;
177  static float DrawNhbds;
178  static bool DeleteBadVertex;
179  static bool FillWorkData;
180  static bool SeedStack;
181  static int PixelEditRadius;
182  static int PixelEditMaxPix;
183  static std::vector<Colorf> LabelColors;
184  bool LabelColorsChanged;
185 
186  static bool MeshSelect;
187  static ScaleBar scaleBar;
188  static Colorbar colorBar;
189 
190  static float MeshPointSize;
191  static float MeshLineWidth;
192 
193  bool changed; // Has the stack (mesh) changed
194  bool pixelsChanged; // Changed flag for pixel editing
195 
196  public:
197  ImgData(int id, QWidget* _parent = 0);
198 
199  ~ImgData();
200 
201  void init(Stack* s, Mesh* m);
202 
203  // Set the internal format of the data
204  void setWork16Bit(bool val);
205  void setMain16Bit(bool val);
206 
207  // Set parameters for function
208  void readParms(util::Parms& parms, QString section);
209 
210  // Set parameters for function
211  void writeParms(QTextStream& pout, QString section);
212 
213  // Get the frame with or without additional transform
214  qglviewer::ManipulatedFrame& getFrame() {
215  return stack->getFrame();
216  }
217 
218  // Get the main frame
219  qglviewer::ManipulatedFrame& getMainFrame() {
220  return stack->frame();
221  }
222 
223  // Get the transform frame
224  qglviewer::ManipulatedFrame& getTransFrame() {
225  return stack->trans();
226  }
227 
228  // Marching cubes evaluation function
229  int eval(Point3f p);
230 
231  // Draw stack data
232  void drawStack(Shader* shader);
233 
234  // Set the file containing the current color map
235  void setColorMap(const QString& pth, bool work);
236 
237  // Update heat histogram
238  void updateHeatHistogram();
239  // Update surface histogram
240  void updateSurfHistogram();
241  // Update work histogram
242  void updateWorkHistogram();
243  // Update main histogram
244  void updateMainHistogram();
245 
246  // Edit the transfer function
247  void editMainTransferFunction(QWidget* parent = 0);
248  void editWorkTransferFunction(QWidget* parent = 0);
249  void editSurfTransferFunction(QWidget* parent = 0);
250  void editHeatTransferFunction(QWidget* parent = 0);
251 
252  // Update the color map texture
253  void updateSurfColorMap() {
254  updateColorMap(newSurfColorMap, SurfColorMap, mesh->surfFct());
255  }
256  void updateHeatColorMap() {
257  updateColorMap(newHeatColorMap, HeatColorMap, mesh->heatFct());
258  }
259  void updateWorkColorMap() {
260  updateColorMap(newWorkColorMap, WorkColorMap, stack->work()->transferFct());
261  }
262  void updateMainColorMap() {
263  updateColorMap(newMainColorMap, MainColorMap, stack->main()->transferFct());
264  }
265  void updateColorMap(bool& newColorMap, std::vector<TransferFunction::Colorf>& ColorMap,
266  const TransferFunction& transferFct);
267 
268  // Setup color map to use in draw
269  void setupSurfColorMap() {
270  setupColorMap(newSurfColorMap, surfTexId, SurfColorMap, Shader::AT_SURF_TEX);
271  }
272  void setupHeatColorMap() {
273  setupColorMap(newHeatColorMap, heatTexId, HeatColorMap, Shader::AT_HEAT_TEX);
274  }
275  void setupMainColorMap() {
276  setupColorMap(newMainColorMap, mcmapTexId, MainColorMap, Shader::AT_CMAP_TEX);
277  }
278  void setupMainColorMap2() {
279  setupColorMap(newMainColorMap, mcmapTexId, MainColorMap, Shader::AT_SECOND_CMAP_TEX);
280  }
281  void setupWorkColorMap() {
282  setupColorMap(newWorkColorMap, wcmapTexId, WorkColorMap, Shader::AT_CMAP_TEX);
283  }
284  void setupWorkColorMap2() {
285  setupColorMap(newWorkColorMap, wcmapTexId, WorkColorMap, Shader::AT_SECOND_CMAP_TEX);
286  }
287  void setupLabelColorMap()
288  {
289  std::vector<TransferFunction::Colorf> empty;
290  bool nonew = false;
291  setupColorMap(nonew, labelTexId, empty, Shader::AT_LABEL_TEX);
292  }
293  void setupColorMap(bool& newColorMap, GLuint& cmapTexId, const std::vector<TransferFunction::Colorf>& ColorMap,
294  Shader::ActiveTextures activeTex);
295 
296  // Draw mesh wireframe, select renders point only in AUX buffer
297  void drawMesh(bool select);
298 
299  // Draw lines joining corresponding vertices
300  void drawVertexVertexLine(ImgData* stack); // added by ALR
301 
302  // Draw cell axis
303  void drawCellAxis(); // added by ALR
304 
305  // Draw Bounding Box around the stack
306  void drawBBox();
307 
308  // Setup the uniforms and textures to render 3D data
309  void setup3DRenderingData(Shader* shader);
310 
311  // Draw mesh shaded, select renders unique colors in AUX buffer
312  void drawSurf(bool select, Shader* texture_shader = 0, Shader* label_shader = 0, Shader* volume_shader = 0);
313 
314  bool showOpaqueSurface() {
315  return mesh->isSurfaceVisible() and !mesh->blending();
316  }
317 
318  bool showTransparentSurface() {
319  return mesh->isSurfaceVisible() && mesh->blending() && (mesh->opacity() > 0.0);
320  }
321 
322  void setupVolumeShader(Shader& shader, int pos);
323 
324  // Mark margin vertices and border labels
325  void markMargin(std::set<vertex>& M, bool remborders);
326 
327  // Check if the graph has matching in-out edges
328  void chkGraph();
329 
330  // Subdivide bisect, recursively divide to prevent degenerate triangles
331  void subdivideBisect(vertex v1, vertex v2, vertex v3);
332 
333  // Get all vertices close to a set of border vertices
334  void markBorder(float borderSize);
335 
336  // Get signal and areas by label
337  void getLabelMaps(float borderSize);
338 
339  // Test if border triangle
340  bool isBordTriangle(int label, vertex v, vertex n, vertex m, IntIntPair& rp);
341 
342  // Setup data for clipping test
343  void getClipTestData(ClipRegion& clip1, ClipRegion& clip2, ClipRegion& clip3);
344 
345  // Test if a point (in image coordinates) is inside clipping planes
346  bool clipTest(const Point3i& ip);
347 
348  // Routine to connect neighborhoods when loading keyence data
349  void makeNhbd(std::vector<vertex>& vtxs);
350  void makeNhbd(vvgraph& S, vertex v, vertex n1, vertex n2, vertex n3, vertex n4);
351  void makeNhbd(vvgraph& S, vertex v, vertex n1, vertex n2, vertex n3, vertex n4, vertex n5, vertex n6);
352 
353  // Save surface for ICP
354  int getPointsICP(std::vector<Point3f>& pts, qglviewer::Frame& frame);
355 
356  // Reset stack data
357  void resetStack();
358 
359  // Reset mesh data
360  void resetMesh();
361 
362  // Initialize controls
363  void initControls(QWidget* viewer);
364 
365  // Determine if triangle is labeled, all vertices labelled and the same (or -1 = boundary)
366  int getLabel(vertex v1, vertex v2, vertex v3, bool useParentLabel = true) const;
367 
368  // Texture management
369  void unloadTex();
370  void loadTex();
371  void reloadLabelTex();
372  void reloadMainTex(const BoundingBox3i& bbox = BoundingBox3i());
373  void reloadWorkTex(const BoundingBox3i& bbox = BoundingBox3i());
374  void reloadTex(GLuint texId);
375  void updateTex(GLuint texId, BoundingBox3i bBox);
376  void initTex();
377  void bind3DTex(GLuint texId, Shader::ActiveTextures atexId = Shader::AT_TEX3D);
378  void bind2DTex(GLuint texId);
379  void unbind3DTex();
380  void unbind2DTex();
381  void loadImgTex(const QImage& image);
382 
383  // Fill selected color with current label (bucket icon)
384  void fillLabel(int label, int currlabel);
385 
386  // Set parent label
387  void setParent(int label, int parentLabel);
388 
389  // Select the vertices for given label
390  void selectLabel(int label, int repeat = 0);
391 
392  // Unselect the vertices for given label
393  void unselectLabel(int label);
394 
395  // Select the vertices for given parent
396  void selectParent(int label, int repeat = 0);
397 
398  // Unselect the vertices for given parent
399  void unselectParent(int label);
400 
401  // Select connected vertices
402  void selectConnected(std::vector<uint>& vlist, bool unselect);
403 
404  // Put label on a list of vertices (a triangle)
405  void addSeed(int label, std::vector<uint>& vlist);
406 
407  // Fill selection with current
408  void fillSelect(int label);
409 
410  // Delete selected vertices
411  void deleteLabel(int label);
412 
413  // void markLine(const vertex &s, const vertex &d);
414 
415  // Set margins and normals and count triangles for VBOs
416  void marginNormalsVBOs();
417 
418  // Update triangle texture coords
419  void updateTris();
420  void updateTris(vvgraph& T);
421 
422  // Update points and lines
423  void updateLines();
424 
425  // Update positions
426  void updatePos();
427 
428  // Fill the vertex array
429  void fillVBOs();
430 
431  // Correct the selection
432  void correctSelection(bool inclusive);
433 
434  // Update the selection array
435  void updateSelection();
436 
437  // Update Color and texture vertex array
438  void updColorVBOs();
439 
440  // Update VBO texture coordinate values
441  // RSS: Is this used?
442  // void updTexCoord();
443 
444  // Update a list of vertex positions in the VBO
445  void updPos(std::set<uint>& vlist, bool points);
446 
447  // Find selected triangle in triangle select mode (!MeshSelect)
448  void findSelectTriangle(uint x, uint y, std::vector<uint>& vlist, int& label, bool useParentLabel = true);
449 
450  // Find selected point in mesh select mode (MeshSelect)
451  int findSelectPoint(uint x, uint y);
452 
453  // Average a list of vertices to find select point
454  bool findSeedPoint(uint x, uint y, CutSurf& cutSurf, Point3f& p);
455 
456  // Clear mesh selection
457  void clearMeshSelect();
458 
459  // Add point to selection
460  void addSelect(const std::vector<uint>& vlist);
461 
462  // Remove points from selection
463  void removeSelect(const std::vector<uint>& vlist);
464 
465  // Update selection colors
466  void updColor(const std::vector<uint>& vlist);
467 
468  // Apply a single clip plane to the bounding box
469  void bBoxClip(BoundingBox3f& bBox, Point3f p, Point3f n);
470 
471  // Make a bounding box from the clipping planes
472  void bBoxFromClip();
473 
474  // Start pixel editing
475  void pixelEditStart(ClipRegion& clip1, ClipRegion& clip2, ClipRegion& clip3);
476 
477  // Pixel editing operations
478  // p, px, py and pz should be in world coordinates
479  void pixelEdit(float pixelRadius, const Point3f& p, const Point3f& px, const Point3f& py, const Point3f& pz,
480  bool doCut, int currentLabel);
481 
482  // Stop pixel editing
483  void pixelEditStop();
484 
485  bool isMainVisible() const {
486  return stack->main()->isVisible() and mainDataTexId;
487  }
488  bool isWorkVisible() const {
489  return stack->work()->isVisible() and workDataTexId;
490  }
491  bool isVisible() const {
492  return isMainVisible() or isWorkVisible();
493  }
494 
495  HVecUS& currentData()
496  {
497  if(stack->work()->isVisible())
498  return stack->work()->data();
499  return stack->main()->data();
500  }
501  const HVecUS& currentData() const
502  {
503  if(stack->work()->isVisible())
504  return stack->work()->data();
505  return stack->main()->data();
506  }
507  Point3f imageGradientW(Point3d worldpos);
508  Point3f imageGradientI(Point3i ipos);
509  uint imageLevel(Point3d worldpos);
510  Point2i imageMinMax();
511 
512  GLenum interpolation(GLuint texId)
513  {
514  if(texId == workDataTexId)
515  return stack->work()->labels() ? GL_NEAREST : GL_LINEAR;
516  else
517  return stack->main()->labels() ? GL_NEAREST : GL_LINEAR;
518  }
519 
520  GLenum internalFormat(GLuint texId)
521  {
522  if(texId == workDataTexId)
523  return Work16Bit ? GL_ALPHA16 : GL_ALPHA8;
524  else
525  return Main16Bit ? GL_ALPHA16 : GL_ALPHA8;
526  }
527 
528  GLenum swapTextureBytes(GLuint texId)
529  {
530  if(texId == workDataTexId)
531  return stack->work()->labels();
532  else
533  return stack->main()->labels();
534  }
535 
536  // Set stack sizes
537  void updateStackSize();
538 
539  // Change the texture scale of the stack
540  void setTexScale(float s);
541 
542  bool valid() const {
543  return stack->storeSize() > 0 and (mainDataTexId or workDataTexId);
544  }
545 
546  protected:
547  // Update a list of vertex labels
548  void updLabel(int label, std::vector<uint>& vlist);
549 
550  // Add a triangle to the VV mesh when converting from unoriented mesh (triangles must be oriented)
551  bool addTriangle(std::vector<vertex>& vertices, Point3i tri);
552 
553  // Create mesh from triangle and vertex lists
554  void meshFromTriangles(std::vector<vertex>& vertices, std::vector<Point3i>& triangles);
555 
556  // Project signal onto mesh vertices
557  void projSignal(HVecUS& data, vertex v, float mindist, float maxdist);
558 
559  // Load 3D texture data, possibly downsampling.
560  void load3DTexData(const GLuint texId, const Point3u size, const ushort* data);
561 
562  // Get step for texture decimation
563  Point3u getTexStep();
564 
565  public:
566  // Clip texture coordinates
567  float trimTex(const float val) {
568  return (trim(val, 0.0f, 1.0f));
569  }
570 
571  Point2f trimTex(const Point2f& val) {
572  return (Point2f(trimTex(val.x()), trimTex(val.y())));
573  }
574 
575  protected:
576  // Return unique triangles
577  static bool uniqueTri(const vvgraph& S, const vertex& v, const vertex& n, const vertex& m)
578  {
579  if(v.id() <= n.id() or v.id() <= m.id() or n.id() == m.id() or !S.edge(v, n) or !S.edge(v, m) or !S.edge(n, m))
580  return false;
581  else
582  return true;
583  }
584 
585  // Return unique lines
586  static bool uniqueLine(const vvgraph& S, const vertex& v, const vertex& n)
587  {
588  if(v.id() <= n.id() or !S.edge(v, n))
589  return false;
590  else
591  return true;
592  }
593 
594  // Test if quad out of bounds, used for clipping 3D data
595  bool testQuad(float a, float b, float c, float d, float x)
596  {
597  if(a > x and b > x and c > x and d > x)
598  return (true);
599  if(a < -x and b < -x and c < -x and d < -x)
600  return (true);
601  return (false);
602  }
603 
604  // See if point should be drawn
605  // bool pDraw(const vertex &v)
606  // {
607  // // Choose which vertices to draw
608  // if(MeshBorder and !v->margin)
609  // return false;
610  // if(MeshCell and v->label != -1)
611  // return false;
612  // return true;
613  // }
614 
615  // Get point color
616  Point3GLub pColor(const vertex& v)
617  {
618  // Get the color
619  Color3f c;
620  if(v->selected)
621  c = Colors::getColor(MeshSelectColor);
622  else if(v->minb != 0 or v->label < 0)
623  c = Colors::getColor(MeshBorderColor);
624  else
625  c = Colors::getColor(MeshColor);
626 
627  return (Point3GLub(255 * c.x(), 255 * c.y(), 255 * c.z()));
628  }
629 
630  // Get line color, and if it should be drawn
631  bool lDraw(const vertex& a, const vertex& b)
632  {
633  // Choose which line to draw
634  if((mesh->meshView() == Mesh::BORDER_MESH)and !(a->margin and b->margin))
635  return false;
636  if((mesh->meshView() == Mesh::CELL_MESH)and !(a->label == -1 and b->label == -1))
637  return false;
638  return true;
639  }
640 
641  // Compute offset for image data including border
642  size_t offset(uint x, uint y, uint z) {
643  return stack->offset(x, y, z);
644  }
645 
646  size_t offset(Point3i ipos) {
647  return stack->offset(ipos);
648  }
649 
650  // Check if in bounds
651  bool boundsOK(int x, int y, int z)
652  {
653  if(x < 0 or y < 0 or z < 0 or x >= int(stack->size().x()) or y >= int(stack->size().y())
654  or z >= int(stack->size().z()))
655  return (false);
656  else
657  return (true);
658  }
659 
660  public:
662  template <typename T> Point3f imageToWorld(const util::Vector<3, T>& img) const
663  {
664  return stack->imageToWorld<T>(img);
665  }
666 
668  template <typename T> util::Vector<3, T> worldToImage(Point3f wrld) const {
669  return stack->worldToImage<T>(wrld);
670  }
671 
672  Point3f worldToImagef(const Point3f& a) const {
673  return worldToImage<float>(a);
674  }
675  Point3i worldToImagei(const Point3f& a) const {
676  return worldToImage<int>(a);
677  }
678  Point3u worldToImageu(const Point3f& a) const {
679  return worldToImage<uint>(a);
680  }
681 
682  // Map scale slider values
683  int toSliderScale(float s);
684  float fromSliderScale(int i);
685 
686  protected:
687  void updateHistogram(std::vector<double>& hist, const HVecUS& data, std::pair<double, double>& minMaxValues,
688  int max_data = 1 << 16, int size = 512);
689  void invalidateHistogram(std::vector<double>& hist) {
690  hist.clear();
691  }
692 
693  // Clear 3D stack texture
694  void clearData(HVecUS& data)
695  {
696  data.resize(stack->storeSize());
697  memset(&data[0], 0, data.size() * sizeof(ushort));
698  }
699 
700  // Return texture info for a vertex (this version used to update color when drawing on mesh)
701  Point3f texCoord(int label, vertex v);
702 
703  // Return texture info for a vertex (this version used to fill VBOs and respects wall heatmap)
704  Point3f texCoord(int label, vertex v, vertex a, vertex b, vertex c);
705 
706  // Set label on triangle
707  bool setLabel(vertex v1, vertex v2, vertex v3, int label)
708  {
709  bool ok = true;
710  if(v1->label > 0 and v1->label != label)
711  ok = false;
712  if(v2->label > 0 and v2->label != label)
713  ok = false;
714  if(v3->label > 0 and v3->label != label)
715  ok = false;
716 
717  if(ok) {
718  if(v1->label == 0)
719  v1->label = label;
720  if(v2->label == 0)
721  v2->label = label;
722  if(v3->label == 0)
723  v3->label = label;
724  }
725  return (ok);
726  }
727 
728  signals:
729  void changedInterface();
730  // void changeSize(uint x, uint y, uint z, float xstep, float ystep, float zstep);
731  void changeSize(const Point3u& size, const Point3f& step, const Point3f& origin);
732  void stackUnloaded();
733 
734  public slots:
735  // Update the colors of all points in the mesh
736  void updColor();
737 
738  // Slots for controls
739  void MainShowSlot(bool val);
740  void MainBrightSlot(int val);
741  void MainOpacitySlot(int val);
742  void MainLabelsSlot(bool val);
743  void Main16BitSlot(bool val);
744 
745  void WorkShowSlot(bool val);
746  void WorkBrightSlot(int val);
747  void WorkOpacitySlot(int val);
748  void WorkLabelsSlot(bool val);
749  void Work16BitSlot(bool val);
750 
751  void SurfShowSlot(bool val);
752  void SurfBrightSlot(int val);
753  void SurfOpacitySlot(int val);
754  void SurfBlendSlot(bool val);
755  void SurfCullSlot(bool val);
756 
757  void SurfNormalSlot(bool val);
758  void SurfLabelSlot(bool val);
759  void SurfHeatSlot(bool val);
760  void SurfParentSlot(bool val);
761 
762  void SurfSignalSlot(bool val);
763  void SurfTextureSlot(bool val);
764  void SurfImageSlot(bool val);
765 
766  void MeshShowSlot(bool val);
767  void ChangeMeshViewModeSlot(int mode);
768  void MeshLinesSlot(bool val);
769  void MeshPointsSlot(bool val);
770 
771  void CellMapSlot(bool val);
772  void ShowTransSlot(bool val);
773  void ShowScaleSlot(bool val);
774  void ShowBBoxSlot(bool val);
775  void TieScalesSlot(bool val); // ALR
776  void ScaleSlotX(int val);
777  void ScaleSlotY(int val);
778  void ScaleSlotZ(int val);
779 
780  // Slots to change transfer functions
781  void setSurfColorMap(const TransferFunction& fct);
782  void setHeatColorMap(const TransferFunction& fct);
783  void setWorkColorMap(const TransferFunction& fct);
784  void setMainColorMap(const TransferFunction& fct);
785 
786  // Slots to detect changes in transfer fct dialog boxes
787  void updateSurfColorMap(const TransferFunction& fct);
788  void updateHeatColorMap(const TransferFunction& fct);
789  void updateWorkColorMap(const TransferFunction& fct);
790  void updateMainColorMap(const TransferFunction& fct);
791 
792  // Update lines or tris
793  void updateImgData();
794  void postUpdateImgData(bool lines, bool tris);
795 
796  signals:
797  void viewerUpdate();
798  void updateSliderScale();
799  void forceSurfHeat();
800  };
801 
802 }
803 #endif
identity_t id() const
Return the identifier of a vertex.
Definition: Vertex.hpp:281
MeshView
Enumeration of the possible visualisations for the Mesh.
Definition: Mesh.hpp:184
std::map< int, Point3f > IntPoint3fMap
Map of an integer to a 3D point.
Definition: Mesh.hpp:53
This file contains the definition of a clipping region.
Misc.
CU_HOST_DEVICE void x(const T &v)
Short access to the first element.
Definition: Vector.hpp:651
Definition: TransferFunctionDlg.hpp:15
Defines the util::Parms class.
mgx_EXPORT bool meshFromTriangles(vvgraph &S, std::vector< vertex > &vertices, std::vector< Point3i > &triangles)
This function creates a graph from a triangle soup.
Class to handle rotatable pair of clipping planes.
Definition: ClipRegion.hpp:28
Definition: Shader.hpp:269
Show only the mesh border.
Definition: Mesh.hpp:186
This class holds the actual mesh as a VV Graph and all sort of properties for it, including visualiza...
Definition: Mesh.hpp:167
Definition: ColorBar.hpp:18
vvgraph::vertex_t vertex
Type of a vertex.
Definition: Mesh.hpp:39
Common definitions and utilities for all geometry algorithms This file is shared by cuda...
util::Vector< 3, T > worldToImage(Point3f wrld) const
Go from world coordinates to image coordinates.
Definition: ImageData.hpp:668
CU_HOST_DEVICE void y(const T &v)
Short access to the second element.
Definition: Vector.hpp:660
Point3f imageToWorld(const util::Vector< 3, T > &img) const
Go from image coordinates to world coordinates.
Definition: ImageData.hpp:662
A utility class to parse L-Studio like parameter files.
Definition: Parms.hpp:105
mgxBase_EXPORT bool subdivideBisect(vvgraph &S, const vertex &v1, const vertex &v2, const vertex &v3, bool selected, std::vector< vertex > *vs=0)
Subdivide triangle by bi-sections.
File containing the definition of a Process.
mgxBase_EXPORT void markMargin(vvgraph &M, vvgraph &S, bool remborders)
Mark the cells and tissue margin vertices.
Definition: CutSurf.hpp:21
The Stack class represent the dimensions of the 3D data, and the frames transformations.
Definition: Stack.hpp:25
std::pair< int, int > IntIntPair
Element in IntIntMap.
Definition: Mesh.hpp:66
QEvent(Type type)
CU_HOST_DEVICE void z(const T &v)
Short access to the third element.
Definition: Vector.hpp:669
ColorType
Mesh1 and 2 must have the same order for their colors.
Definition: Colors.hpp:24
Definition: ScaleBar.hpp:21
Definition: ImageData.hpp:37
This files contains the definition of a mesh for the Process API.
Class defining a transfer function as linear interpolation between set values.
Definition: TransferFunction.hpp:23
Definition: ImageData.hpp:33
edge_t edge(const vertex_t &src, const vertex_t &tgt)
Returns the edge from src to tgt.
Definition: VVGraph.hpp:1954
Show only the cell borders (i.e. interface between labels)
Definition: Mesh.hpp:187