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 vtkPointPlacer;
00063 class vtkContourLineInterpolator;
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 };
00263
00264
00266
00268 vtkGetMacro( CurrentOperation, int );
00269 vtkSetClampMacro( CurrentOperation, int,
00270 vtkContourRepresentation::Inactive,
00271 vtkContourRepresentation::Translate );
00272 void SetCurrentOperationToInactive()
00273 { this->SetCurrentOperation( vtkContourRepresentation::Inactive ); }
00274 void SetCurrentOperationToTranslate()
00275 { this->SetCurrentOperation( vtkContourRepresentation::Translate ); }
00277
00278
00279
00280
00281
00282
00283 void SetPointPlacer( vtkPointPlacer * );
00284 vtkGetObjectMacro( PointPlacer, vtkPointPlacer );
00285
00287
00289 void SetLineInterpolator( vtkContourLineInterpolator *);
00290 vtkGetObjectMacro( LineInterpolator, vtkContourLineInterpolator );
00292
00294
00295 virtual void BuildRepresentation()=0;
00296 virtual int ComputeInteractionState(int X, int Y, int modified=0)=0;
00297 virtual void StartWidgetInteraction(double e[2])=0;
00298 virtual void WidgetInteraction(double e[2])=0;
00300
00302
00303 virtual void ReleaseGraphicsResources(vtkWindow *w)=0;
00304 virtual int RenderOverlay(vtkViewport *viewport)=0;
00305 virtual int RenderOpaqueGeometry(vtkViewport *viewport)=0;
00306 virtual int RenderTranslucentPolygonalGeometry(vtkViewport *viewport)=0;
00307 virtual int HasTranslucentPolygonalGeometry()=0;
00309
00311
00313 void SetClosedLoop( int val );
00314 vtkGetMacro( ClosedLoop, int );
00315 vtkBooleanMacro( ClosedLoop, int );
00317
00319
00320 virtual vtkPolyData * GetContourRepresentationAsPolyData() = 0;
00321
00323
00324 protected:
00325 vtkContourRepresentation();
00326 ~vtkContourRepresentation();
00327
00328
00329 int PixelTolerance;
00330 double WorldTolerance;
00331
00332 vtkPointPlacer *PointPlacer;
00333 vtkContourLineInterpolator *LineInterpolator;
00334
00335 int ActiveNode;
00336
00337 int CurrentOperation;
00338 int ClosedLoop;
00339
00340 vtkContourRepresentationInternals *Internal;
00341
00342 void AddNodeAtPositionInternal( double worldPos[3],
00343 double worldOrient[9], int displayPos[2] );
00344 void AddNodeAtPositionInternal( double worldPos[3],
00345 double worldOrient[9], double displayPos[2] );
00346 void SetNthNodeWorldPositionInternal( int n, double worldPos[3],
00347 double worldOrient[9] );
00348
00350
00352 void GetRendererComputedDisplayPositionFromWorldPosition( double worldPos[3],
00353 double worldOrient[9], int displayPos[2] );
00354 void GetRendererComputedDisplayPositionFromWorldPosition( double worldPos[3],
00355 double worldOrient[9], double displayPos[2] );
00357
00358 void UpdateLines( int index );
00359 void UpdateLine( int idx1, int idx2 );
00360
00361 virtual int FindClosestPointOnContour( int X, int Y,
00362 double worldPos[3],
00363 int *idx );
00364
00365 virtual void BuildLines()=0;
00366
00367
00368
00369
00370
00371
00372 virtual int UpdateContour();
00373 vtkTimeStamp ContourBuildTime;
00374
00375 void ComputeMidpoint( double p1[3], double p2[3], double mid[3] )
00376 {
00377 mid[0] = (p1[0] + p2[0])/2;
00378 mid[1] = (p1[1] + p2[1])/2;
00379 mid[2] = (p1[2] + p2[2])/2;
00380 }
00381
00388 virtual void Initialize( vtkPolyData * );
00389
00390 private:
00391 vtkContourRepresentation(const vtkContourRepresentation&);
00392 void operator=(const vtkContourRepresentation&);
00393 };
00394
00395 #endif
00396