00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00056 #ifndef __vtkContourRepresentation_h
00057 #define __vtkContourRepresentation_h
00058
00059 #include "vtkWidgetRepresentation.h"
00060 #include <vtkstd/vector>
00061
00062 class vtkContourLineInterpolator;
00063 class vtkPointPlacer;
00064 class vtkPolyData;
00065
00066
00067
00068 class vtkContourRepresentationPoint
00069 {
00070 public:
00071 double WorldPosition[3];
00072 double NormalizedDisplayPosition[2];
00073 };
00074
00075 class vtkContourRepresentationNode
00076 {
00077 public:
00078 double WorldPosition[3];
00079 double WorldOrientation[9];
00080 double NormalizedDisplayPosition[2];
00081 vtkstd::vector<vtkContourRepresentationPoint*> Points;
00082 };
00083
00084 class vtkContourRepresentationInternals
00085 {
00086 public:
00087 vtkstd::vector<vtkContourRepresentationNode*> Nodes;
00088 };
00089
00090
00091 class VTK_WIDGETS_EXPORT vtkContourRepresentation : public vtkWidgetRepresentation
00092 {
00093
00094 friend class vtkContourWidget;
00095
00096 public:
00098
00099 vtkTypeRevisionMacro(vtkContourRepresentation,vtkWidgetRepresentation);
00100 void PrintSelf(ostream& os, vtkIndent indent);
00102
00104
00106 virtual int AddNodeAtWorldPosition( double worldPos[3] );
00107 virtual int AddNodeAtWorldPosition( double worldPos[3],
00108 double worldOrient[9] );
00110
00112
00115 virtual int AddNodeAtDisplayPosition( double displayPos[2] );
00116 virtual int AddNodeAtDisplayPosition( int displayPos[2] );
00117 virtual int AddNodeAtDisplayPosition( int X, int Y );
00119
00121
00124 virtual int ActivateNode( double displayPos[2] );
00125 virtual int ActivateNode( int displayPos[2] );
00126 virtual int ActivateNode( int X, int Y );
00128
00129
00130
00131
00132
00133
00134 virtual int SetActiveNodeToWorldPosition( double pos[3] );
00135 virtual int SetActiveNodeToWorldPosition( double pos[3],
00136 double orient[9] );
00137
00139
00143 virtual int SetActiveNodeToDisplayPosition( double pos[2] );
00144 virtual int SetActiveNodeToDisplayPosition( int pos[2] );
00145 virtual int SetActiveNodeToDisplayPosition( int X, int Y );
00147
00150 virtual int GetActiveNodeWorldPosition( double pos[3] );
00151
00154 virtual int GetActiveNodeWorldOrientation( double orient[9] );
00155
00158 virtual int GetActiveNodeDisplayPosition( double pos[2] );
00159
00161 virtual int GetNumberOfNodes();
00162
00165 virtual int GetNthNodeDisplayPosition( int n, double pos[2] );
00166
00169 virtual int GetNthNodeWorldPosition( int n, double pos[3] );
00170
00173 virtual int GetNthNodeWorldOrientation( int n, double orient[9] );
00174
00176
00181 virtual int SetNthNodeDisplayPosition( int n, int X, int Y );
00182 virtual int SetNthNodeDisplayPosition( int n, int pos[2] );
00183 virtual int SetNthNodeDisplayPosition( int n, double pos[2] );
00185
00187
00190 virtual int SetNthNodeWorldPosition( int n, double pos[3] );
00191 virtual int SetNthNodeWorldPosition( int n, double pos[3],
00192 double orient[9] );
00194
00197 virtual int GetNthNodeSlope( int idx, double slope[3] );
00198
00199
00200
00201
00202
00203
00204
00205
00206 virtual int GetNumberOfIntermediatePoints( int n );
00207
00209
00212 virtual int GetIntermediatePointWorldPosition( int n,
00213 int idx, double point[3] );
00215
00217
00220 virtual int AddIntermediatePointWorldPosition( int n,
00221 double point[3] );
00223
00226 virtual int DeleteLastNode();
00227
00230 virtual int DeleteActiveNode();
00231
00233 virtual int DeleteNthNode( int n );
00234
00237 virtual int AddNodeOnContour( int X, int Y );
00238
00240
00242 vtkSetClampMacro(PixelTolerance,int,1,100);
00243 vtkGetMacro(PixelTolerance,int);
00245
00247
00249 vtkSetClampMacro(WorldTolerance, double, 0.0, VTK_DOUBLE_MAX);
00250 vtkGetMacro(WorldTolerance, double);
00252
00253
00254 enum {
00255 Outside=0,
00256 Nearby
00257 };
00258
00259 enum {
00260 Inactive = 0,
00261 Translate,
00262 Shift,
00263 Scale
00264 };
00265
00266
00268
00270 vtkGetMacro( CurrentOperation, int );
00271 vtkSetClampMacro( CurrentOperation, int,
00272 vtkContourRepresentation::Inactive,
00273 vtkContourRepresentation::Scale );
00274 void SetCurrentOperationToInactive()
00275 { this->SetCurrentOperation( vtkContourRepresentation::Inactive ); }
00276 void SetCurrentOperationToTranslate()
00277 { this->SetCurrentOperation( vtkContourRepresentation::Translate ); }
00278 void SetCurrentOperationToShift()
00279 {this->SetCurrentOperation( vtkContourRepresentation::Shift ); }
00280 void SetCurrentOperationToScale()
00281 {this->SetCurrentOperation( vtkContourRepresentation::Scale ); }
00283
00284
00285
00286
00287
00288
00289 void SetPointPlacer( vtkPointPlacer * );
00290 vtkGetObjectMacro( PointPlacer, vtkPointPlacer );
00291
00293
00295 void SetLineInterpolator( vtkContourLineInterpolator *);
00296 vtkGetObjectMacro( LineInterpolator, vtkContourLineInterpolator );
00298
00300
00301 virtual void BuildRepresentation()=0;
00302 virtual int ComputeInteractionState(int X, int Y, int modified=0)=0;
00303 virtual void StartWidgetInteraction(double e[2])=0;
00304 virtual void WidgetInteraction(double e[2])=0;
00306
00308
00309 virtual void ReleaseGraphicsResources(vtkWindow *w)=0;
00310 virtual int RenderOverlay(vtkViewport *viewport)=0;
00311 virtual int RenderOpaqueGeometry(vtkViewport *viewport)=0;
00312 virtual int RenderTranslucentPolygonalGeometry(vtkViewport *viewport)=0;
00313 virtual int HasTranslucentPolygonalGeometry()=0;
00315
00317
00319 void SetClosedLoop( int val );
00320 vtkGetMacro( ClosedLoop, int );
00321 vtkBooleanMacro( ClosedLoop, int );
00323
00325
00326 virtual vtkPolyData* GetContourRepresentationAsPolyData() = 0;
00327
00329
00332 void GetNodePolyData( vtkPolyData* poly );
00333
00334 protected:
00335 vtkContourRepresentation();
00336 ~vtkContourRepresentation();
00337
00338
00339 int PixelTolerance;
00340 double WorldTolerance;
00341
00342 vtkPointPlacer *PointPlacer;
00343 vtkContourLineInterpolator *LineInterpolator;
00344
00345 int ActiveNode;
00346
00347 int CurrentOperation;
00348 int ClosedLoop;
00349
00350 vtkContourRepresentationInternals *Internal;
00351
00352 void AddNodeAtPositionInternal( double worldPos[3],
00353 double worldOrient[9], int displayPos[2] );
00354 void AddNodeAtPositionInternal( double worldPos[3],
00355 double worldOrient[9], double displayPos[2] );
00356 void SetNthNodeWorldPositionInternal( int n, double worldPos[3],
00357 double worldOrient[9] );
00358
00360
00362 void GetRendererComputedDisplayPositionFromWorldPosition( double worldPos[3],
00363 double worldOrient[9], int displayPos[2] );
00364 void GetRendererComputedDisplayPositionFromWorldPosition( double worldPos[3],
00365 double worldOrient[9], double displayPos[2] );
00367
00368 void UpdateLines( int index );
00369 void UpdateLine( int idx1, int idx2 );
00370
00371 virtual int FindClosestPointOnContour( int X, int Y,
00372 double worldPos[3],
00373 int *idx );
00374
00375 virtual void BuildLines()=0;
00376
00377
00378
00379
00380
00381
00382 virtual int UpdateContour();
00383 vtkTimeStamp ContourBuildTime;
00384
00385 void ComputeMidpoint( double p1[3], double p2[3], double mid[3] )
00386 {
00387 mid[0] = (p1[0] + p2[0])/2;
00388 mid[1] = (p1[1] + p2[1])/2;
00389 mid[2] = (p1[2] + p2[2])/2;
00390 }
00391
00398 virtual void Initialize( vtkPolyData * );
00399
00400 private:
00401 vtkContourRepresentation(const vtkContourRepresentation&);
00402 void operator=(const vtkContourRepresentation&);
00403 };
00404
00405 #endif
00406