GOFIGURE2  0.9.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ContourMeshStructure.cxx
Go to the documentation of this file.
1 /*=========================================================================
2  Authors: The GoFigure Dev. Team.
3  at Megason Lab, Systems biology, Harvard Medical school, 2009-11
4 
5  Copyright (c) 2009-11, President and Fellows of Harvard College.
6  All rights reserved.
7 
8  Redistribution and use in source and binary forms, with or without
9  modification, are permitted provided that the following conditions are met:
10 
11  Redistributions of source code must retain the above copyright notice,
12  this list of conditions and the following disclaimer.
13  Redistributions in binary form must reproduce the above copyright notice,
14  this list of conditions and the following disclaimer in the documentation
15  and/or other materials provided with the distribution.
16  Neither the name of the President and Fellows of Harvard College
17  nor the names of its contributors may be used to endorse or promote
18  products derived from this software without specific prior written
19  permission.
20 
21  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
23  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
25  BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
26  OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
27  OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
28  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
30  OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 
33 =========================================================================*/
34 
35 #include "ContourMeshStructure.h"
36 
37 #include <iostream>
38 #include "vtkPolyData.h"
39 #include "vtkProperty.h"
40 #include "vtkActor.h"
41 #include "vtkMapper.h"
42 #include "vtkDoubleArray.h"
43 #include "vtkPointData.h"
44 #include "vtkLookupTable.h"
45 
46 //--------------------------------------------------------------------------
48  TCoord(0)
49 {
50 }
51 
52 //--------------------------------------------------------------------------
53 
54 //--------------------------------------------------------------------------
55 ContourMeshStructure::ContourMeshStructure(const unsigned int & iTraceID,
56  const unsigned int & iCollectionID,
57  std::vector< vtkActor * > iActors,
58  vtkPolyData *iNodes,
59  const unsigned int & iT,
60  const bool & iHighlighted,
61  const bool & iVisible,
62  const double & r,
63  const double & g,
64  const double & b,
65  const double & alpha) :
66  TraceStructure(iTraceID, iCollectionID, iActors, iNodes, iHighlighted,
67  iVisible, r, g, b, alpha),
68  TCoord(iT)
69 {
70  if ( iActors.size() == 4 )
71  {
72  ActorXY = iActors[0];
73  ActorXZ = iActors[1];
74  ActorYZ = iActors[2];
75  ActorXYZ = iActors[3];
76  }
77  else
78  {
79  std::cerr << "iActors.size() != 4" << std::endl;
80  return;
81  }
82  this->rgba[0] = r;
83  this->rgba[1] = g;
84  this->rgba[2] = b;
85  this->rgba[3] = alpha;
86 }
87 
88 //--------------------------------------------------------------------------
89 
90 //--------------------------------------------------------------------------
91 ContourMeshStructure::ContourMeshStructure(const unsigned int & iTraceID,
92  const unsigned int & iCollectionID,
93  std::vector< vtkActor * > iActors,
94  vtkPolyData *iNodes,
95  const unsigned int & iT,
96  const bool & iHighlighted,
97  const bool & iVisible,
98  double iRgba[4]) :
99  TraceStructure(iTraceID, iCollectionID, iActors, iNodes, iHighlighted, iVisible, iRgba),
100  TCoord(iT)
101 {
102 }
103 
104 //--------------------------------------------------------------------------
105 
106 //--------------------------------------------------------------------------
107 ContourMeshStructure::ContourMeshStructure(const unsigned int & iTraceID,
108  const unsigned int & iCollectionID,
109  vtkActor *iActorXY,
110  vtkActor *iActorYZ,
111  vtkActor *iActorXZ,
112  vtkActor *iActorXYZ,
113  vtkPolyData *iNodes,
114  const unsigned int & iT,
115  const bool & iHighlighted,
116  const bool & iVisible,
117  const double & r,
118  const double & g,
119  const double & b,
120  const double & alpha) :
121  TraceStructure(iTraceID, iCollectionID, iActorXY, iActorYZ, iActorXZ, iActorXYZ, iNodes,
122  iHighlighted, iVisible, r, g, b, alpha),
123  TCoord(iT)
124 {
125 }
126 
127 //--------------------------------------------------------------------------
128 
129 //--------------------------------------------------------------------------
131  TraceStructure(iE),
132  TCoord(iE.TCoord)
133 {
134 }
135 
136 //--------------------------------------------------------------------------
137 
138 //--------------------------------------------------------------------------
140 {
141 }
142 
143 //--------------------------------------------------------------------------
144 
145 //--------------------------------------------------------------------------
147 {
148  return ( this->GetDirection() != -1 );
149 }
150 
151 //--------------------------------------------------------------------------
152 
153 //--------------------------------------------------------------------------
155 {
156  double bounds[6];
157 
158  this->Nodes->GetBounds(bounds);
159 
160  int oDir = -1;
161 
162  for ( int i = 0; i < 3; i++ )
163  {
164  if ( bounds[2 * i] == bounds[2 * i + 1] )
165  {
166  oDir = 2 - i;
167  }
168  }
169 
170  return oDir;
171 }
172 //--------------------------------------------------------------------------
173 
174 //--------------------------------------------------------------------------
175 void
177 ModifyCollectionID(unsigned int iCollectionID)
178 {
179  this->CollectionID = iCollectionID;
180 }
181 //--------------------------------------------------------------------------
int GetDirection()
Return the direction of a given contour iContour.
vtkActor * ActorXYZ
void ModifyCollectionID(unsigned int iCollectionID)
vtkActor * ActorYZ
vtkPolyData * Nodes
vtkActor * ActorXY
unsigned int CollectionID
Structure which represent a contour or a mesh, and used for interaction between Visualization and Tab...
vtkActor * ActorXZ
bool IsAContour()
Is it a contour or a mesh ?
double rgba[4]
Structure which represent a trace (contour, mesh, track, lineage), and used for interaction between V...