00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef ACLVIS_TOOL_H
00012 #define ACLVIS_TOOL_H
00013
00014 #ifdef IPPL_USE_STANDARD_HEADERS
00015 #include <iostream>
00016 using namespace std;
00017 #else
00018 #include <iostream.h>
00019 #endif
00020
00021 #include <vtk.h>
00022 #include <vtkXRenderWindow.h>
00023
00024 #define NUM_OF_TOOL_TYPES 10
00025 enum ToolType {ReadField, ReadParticle, Slice, Iso, MIso, Point, Sphere, Render, \
00026 VectorField, VectorParticle, Axes, LineTrace, Empty};
00027
00028 #define XY 2
00029 #define YZ 0
00030 #define XZ 1
00031
00033 class vizStructuredFieldDataType;
00034 class vizParticleDataType;
00035
00037 #define NUM_OF_UPDATE_POLICY_TYPES 4
00038 enum UpdatePolicyType {Zero, Once, Al, UpdateEmpty};
00039
00040 class Tool {
00041 public:
00042 Tool();
00043 virtual ~Tool();
00044
00045 void SetUpdatePolicy(UpdatePolicyType);
00046 UpdatePolicyType GetUpdatePolicy();
00047 int UpdateTestAndSet();
00048
00049 void SetLocalDimensions(int *);
00050 void SetLocalOrigin(float *);
00051 void SetLocalAspectRatio(float *);
00052 void SetRange(float *);
00053 void SetAllValues(int *, float *, float *, float *);
00054
00055 void GetLocalDimensions(int *);
00056 void GetLocalOrigin(float *);
00057 void GetLocalAspectRatio(float *);
00058 void GetRange(float *);
00059 void GetAllValues(int *, float *, float *, float *);
00060
00061
00062 private:
00063 UpdatePolicyType updatePolicy;
00064 int updateCount;
00065
00066 int dims[3];
00067 float origin[3];
00068 float aspect[3];
00069 float range[2];
00070 };
00071
00072
00074 class ReadParticleTool : public vtkPolySource, public Tool {
00075 public:
00076 ReadParticleTool();
00077 virtual ~ReadParticleTool();
00078
00079 vizParticleDataType *GetVizData();
00080 int PrepareFinishedData();
00081
00082 void UpdateRange();
00083
00084 private:
00085 vizParticleDataType *vizData;
00086 void Execute();
00087 };
00088
00089
00091 class ReadFieldTool : public vtkStructuredPointsSource, public Tool {
00092 public:
00093 ReadFieldTool();
00094 virtual ~ReadFieldTool();
00095
00096 void UpdateAllValues();
00097 void UpdateDimensions();
00098 void UpdateOrigin();
00099 void UpdateAspect();
00100 void UpdateRange();
00101
00102 void SetDimensions(int dims[3]);
00103 void SetAspectRatio(float aspr[3]);
00104 void SetOrigin(float orig[3]);
00105
00106 vizStructuredFieldDataType *GetVizData();
00107 int PrepareFinishedData();
00108
00109 private:
00110 vizStructuredFieldDataType *vizData;
00111 void Execute();
00112 };
00113
00114
00116 class RenderTool : public Tool {
00117 public:
00118 RenderTool();
00119 void SetRenderer(vtkRenderer *);
00120 void SetRenderWindow(vtkXRenderWindow *);
00121
00122 vtkRenderer* GetRenderer();
00123 vtkRenderWindow* GetRenderWindow();
00124
00125 void ResetCamera();
00126 void AddActors(vtkActor *);
00127 void RemoveActors(vtkActor *);
00128 void Render();
00129
00130 private:
00131 int number_of_actors;
00132
00133
00134 vtkRenderWindowInteractor *iren;
00135 vtkRenderMaster *render_master;
00136 vtkRenderWindow *render_window;
00137
00138 vtkRenderer *renderer;
00139 };
00140
00141
00143 class FilterTool : public Tool {
00144 public:
00145 FilterTool();
00146 ~FilterTool();
00147 void FilterToolInit(void *, RenderTool *);
00148
00149 void SetReadTool(void *);
00150 void SetRenderTool(RenderTool *);
00151
00152 void* GetReadTool();
00153 RenderTool* GetRenderTool();
00154 vtkActor* GetActor();
00155 vtkPolyMapper* GetPolyMapper();
00156
00157 private:
00158 void *readtool;
00159 RenderTool *rendertool;
00160 ToolType readtool_type;
00161 vtkActor *actor;
00162 vtkPolyMapper *polyMapper;
00163 };
00164
00165
00167 class SliceTool : public FilterTool {
00168 public:
00169 SliceTool(void *, RenderTool *);
00170 ~SliceTool();
00171
00172 void SetSliceType(int param_sliceType);
00173 void SetSliceValue(float param_sliceValue);
00174 void SetExtent();
00175
00176 int GetSliceType();
00177 float GetSliceValue();
00178 float GetLowerBound();
00179 float GetUpperBound();
00180 float GetValueRange();
00181
00182 vtkStructuredPointsGeometryFilter* GetStructuredPointsGeometryFilter();
00183
00184
00185 private:
00186 vtkStructuredPointsGeometryFilter *p1;
00187
00188 int sliceType;
00189 int sliceValue;
00190 };
00191
00192
00194 class IsoSurfaceTool : public FilterTool {
00195 public:
00196 IsoSurfaceTool(void *, RenderTool *);
00197 ~IsoSurfaceTool();
00198
00199 void SetNumContours(int param_numContours);
00200 void SetContourSubRange(float *param_srange);
00201
00202 int GetNumContours();
00203 void GetContourSubRange(float *param_srange);
00204
00205 vtkContourFilter* GetContourFilter();
00206
00207 private:
00208 vtkContourFilter *isoF;
00209 int numContours;
00210 float srange[2];
00211 };
00212
00213
00215 class PointTool : public FilterTool {
00216 public:
00217 PointTool(void *, RenderTool *);
00218 ~PointTool();
00219 };
00220
00221
00223 class vizTraceTool : public FilterTool {
00224 public:
00225 vizTraceTool();
00226 vizTraceTool(void *, RenderTool *);
00227 virtual ~vizTraceTool();
00228
00229 int SetTraceNumber(int num);
00230 int SetTraceIter(int iter);
00231
00232 int GetTraceNumber() const;
00233 int GetTraceIter() const;
00234 vtkCollection* GetTraceCollection();
00235 vtkAppendPolyData* Getapd();
00236
00237
00238
00239
00240
00241
00242 int AppendPolyData(vtkPolyData *newPolyData);
00243
00244
00245
00246 int CullStalePolyData(int fromSetFlag=0);
00247
00248
00249 int IterateTraceIter(int amt = 1);
00250
00251 protected:
00252 vtkAppendPolyData *apd;
00253 vtkCollection *traceCollection;
00254 int traceNumber;
00255 int traceIter;
00256 };
00257
00258
00260 class SphereTool : public vizTraceTool {
00261 public:
00262 SphereTool(void *, RenderTool *);
00263 virtual ~SphereTool();
00264
00265 vtkSphereSource* GetSphereSource();
00266
00267 private:
00268 vtkGlyph3D *glyph;
00269 vtkSphereSource *sphere;
00270 };
00271
00272
00274 class vizVectorTool : public vizTraceTool {
00275 public:
00276 vizVectorTool();
00277 virtual ~vizVectorTool();
00278
00279 void SetScaleFactor(float scaleFact);
00280 void SetScaleByValue(int togle);
00281 void FlipTubeArrowFlag();
00282
00283 void SetArrowTubeRadius(float rad);
00284 void SetNumberOfTubeFacets(int numFacets);
00285
00286 float GetScaleFactor() const;
00287 int GetScaleByValue() const;
00288 int GetTubeArrowFlag() const;
00289 float GetArrowTubeRadius() const;
00290 int GetNumberOfTubeFacets() const;
00291
00292
00293 void MakeUnitArrowPolyData(vtkPolyData *&arrowPolyData);
00294
00295
00296
00297
00298
00299 protected:
00300 vtkPolyData *vectorRepPolyData;
00301 vtkGlyph3D *vectGlyph;
00302 float scaleFactor;
00303 int scaleByValue;
00304
00305
00306 int tubeArrow;
00307 float arrowTubeRadius;
00308 int numTubeFacets;
00309 };
00310
00311
00313 class vizVectorFieldTool : public vizVectorTool {
00314 public:
00315 vizVectorFieldTool();
00316 vizVectorFieldTool(void *, RenderTool *);
00317 virtual ~vizVectorFieldTool();
00318 };
00319
00320
00322 class vizVectorParticleTool : public vizVectorTool {
00323 public:
00324 vizVectorParticleTool();
00325 vizVectorParticleTool(void *, RenderTool *);
00326 virtual ~vizVectorParticleTool();
00327 };
00328
00329
00331 class vizAxesTool : public FilterTool {
00332 public:
00333 vizAxesTool();
00334 vizAxesTool(void *param_readtool, RenderTool *param_rendertool);
00335 virtual ~vizAxesTool();
00336
00337 int SetScaleFactor(float scaleFact);
00338
00339 float GetScaleFactor() const;
00340 int GetMaxSideLenOfGlobalBoundingBox(RenderTool *ren, float& maxSide);
00341 int GetGlobalBoundingBox(RenderTool *ren, float allBounds[6]);
00342
00343 private:
00344 vtkAxes *axes;
00345 float scaleFactor;
00346 };
00347
00348
00350 class vizParticleLineTraceTool : public vizTraceTool {
00351 public:
00352 vizParticleLineTraceTool();
00353 vizParticleLineTraceTool(void *param_readtool, RenderTool *param_rendertool);
00354 ~vizParticleLineTraceTool();
00355
00356 void MakeAndAppendNewLines(vtkPolyData *newPD);
00357 void TubeIt(vtkPolyData* polyLines);
00358 void FlipTubeLinesFlag();
00359 private:
00360 vtkPolyData *currentPolyData;
00361 vtkPolyData *newPolyData;
00362 vtkTubeFilter *tubeFilter;
00363 int tubeLines;
00364 };
00365
00366
00368 class vizPointData : public vtkUserDefined
00369 {
00370 public:
00371 vizPointData();
00372 virtual ~vizPointData();
00373
00374 vtkIntScalars *GetIds();
00375
00376 private:
00377 vtkIntScalars *ids;
00378 };
00379
00381
00382 class vizStructuredFieldDataType {
00383 public:
00384
00385 enum {ACLVIS_UNKNOWN, ACLVIS_SCALAR, ACLVIS_VECTOR, ACLVIS_TENSOR};
00386
00387 vizStructuredFieldDataType();
00388 vizStructuredFieldDataType(unsigned numPts, int ptDataType = ACLVIS_UNKNOWN);
00389 virtual ~vizStructuredFieldDataType();
00390
00391 int InitData(unsigned numPts, int ptDataType = ACLVIS_UNKNOWN);
00392
00393
00394
00395
00396
00397 int InitPointDataType(int pdType);
00398
00399
00400 int AddScalar(float sc);
00401 int AddScalar(int index, float sc);
00402 int AddVector(float vect[3]);
00403 int AddVector(int index, float vect[3]);
00404
00405 int InsertFieldData(vtkDataSet *dataSet);
00406
00407
00408
00409 int SetPointData(vtkDataSet *dataSet);
00410
00411
00412 int GetPointDataType() const;
00413
00414 void* GetPointData();
00415
00416 protected:
00417
00418 int type;
00419 union {
00420 vtkFloatScalars *scalars;
00421 vtkFloatVectors *vectors;
00422 vtkFloatTensors *tensors;
00423 };
00424
00425 int isPointData;
00426 int numPoints;
00427
00428
00429 };
00430
00431
00433 class vizParticleDataType : public vizStructuredFieldDataType
00434 {
00435 public:
00436 vizParticleDataType();
00437 vizParticleDataType(unsigned numPts, int ptDataType = ACLVIS_UNKNOWN,
00438 int isIds = 1);
00439 virtual ~vizParticleDataType();
00440
00441 int InitData(unsigned numPts, int ptDataType = ACLVIS_UNKNOWN,
00442 int isIds = 1);
00443
00444
00445
00446
00447
00448
00449
00450
00451 int InitIdInfo();
00452
00453 int AddPoint(float pt[3]);
00454 int AddPoint(int index, float pt[3]);
00455 int AddIdInfoVal(int idInf);
00456 int AddIdInfoVal(int index, int idInf);
00457
00458
00459 int InsertParticleData(vtkPolyData *polyData);
00460
00461
00462 int SetPoints(vtkPolyData *polyData);
00463
00464
00465 int SetIdInfo(vtkDataSet *dataSet);
00466
00467 int GetIsIdInfoFlag() const;
00468 private:
00469 vtkFloatPoints *points;
00470 vtkCellArray *cellArray;
00471
00472 vizPointData *idInfo;
00473
00474
00475
00476 int isIdInfo;
00477 };
00478
00479 #endif // ACLVIS_TOOL_H
00480
00481
00482
00483
00484
00485