VTK
dox/Graphics/vtkClipClosedSurface.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkClipClosedSurface.h
00005 
00006   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00007   All rights reserved.
00008   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012      PURPOSE.  See the above copyright notice for more information.
00013 
00014 =========================================================================*/
00042 #ifndef __vtkClipClosedSurface_h
00043 #define __vtkClipClosedSurface_h
00044 
00045 #include "vtkPolyDataAlgorithm.h"
00046 
00047 class vtkPlaneCollection;
00048 class vtkUnsignedCharArray;
00049 class vtkDoubleArray;
00050 class vtkIdTypeArray;
00051 class vtkCellArray;
00052 class vtkPointData;
00053 class vtkCellData;
00054 class vtkPolygon;
00055 class vtkIdList;
00056 class vtkCCSEdgeLocator;
00057 
00058 enum {
00059   VTK_CCS_SCALAR_MODE_NONE = 0,
00060   VTK_CCS_SCALAR_MODE_COLORS = 1,
00061   VTK_CCS_SCALAR_MODE_LABELS = 2
00062 };
00063 
00064 class VTK_GRAPHICS_EXPORT vtkClipClosedSurface : public vtkPolyDataAlgorithm
00065 {
00066 public:
00067   static vtkClipClosedSurface *New();
00068   vtkTypeMacro(vtkClipClosedSurface,vtkPolyDataAlgorithm);
00069   void PrintSelf(ostream& os, vtkIndent indent);
00070 
00072 
00073   virtual void SetClippingPlanes(vtkPlaneCollection *planes);
00074   vtkGetObjectMacro(ClippingPlanes,vtkPlaneCollection);
00076 
00078 
00081   vtkSetMacro(Tolerance, double);
00082   vtkGetMacro(Tolerance, double);
00084 
00086 
00088   vtkSetMacro(PassPointData, int);
00089   vtkBooleanMacro(PassPointData, int);
00090   vtkGetMacro(PassPointData, int);
00092 
00094 
00096   vtkSetMacro(GenerateOutline, int);
00097   vtkBooleanMacro(GenerateOutline, int);
00098   vtkGetMacro(GenerateOutline, int);
00100 
00102 
00104   vtkSetMacro(GenerateFaces, int);
00105   vtkBooleanMacro(GenerateFaces, int);
00106   vtkGetMacro(GenerateFaces, int);
00108 
00110 
00116   vtkSetClampMacro(ScalarMode, int,
00117     VTK_CCS_SCALAR_MODE_NONE, VTK_CCS_SCALAR_MODE_LABELS);
00118   void SetScalarModeToNone() {
00119     this->SetScalarMode(VTK_CCS_SCALAR_MODE_NONE); };
00120   void SetScalarModeToColors() {
00121     this->SetScalarMode(VTK_CCS_SCALAR_MODE_COLORS); };
00122   void SetScalarModeToLabels() {
00123     this->SetScalarMode(VTK_CCS_SCALAR_MODE_LABELS); };
00124   vtkGetMacro(ScalarMode, int);
00125   const char *GetScalarModeAsString();
00127 
00129 
00133   vtkSetVector3Macro(BaseColor, double);
00134   vtkGetVector3Macro(BaseColor, double);
00136 
00138 
00141   vtkSetVector3Macro(ClipColor, double);
00142   vtkGetVector3Macro(ClipColor, double);
00144 
00146 
00149   vtkSetMacro(ActivePlaneId, int);
00150   vtkGetMacro(ActivePlaneId, int);
00152 
00154 
00157   vtkSetVector3Macro(ActivePlaneColor, double);
00158   vtkGetVector3Macro(ActivePlaneColor, double);
00160 
00162 
00166   vtkSetMacro(TriangulationErrorDisplay, int);
00167   vtkBooleanMacro(TriangulationErrorDisplay, int);
00168   vtkGetMacro(TriangulationErrorDisplay, int);
00170 
00171   // Legacy methods, do not use.
00172   VTK_LEGACY(void SetGenerateColorScalars(int));
00173   VTK_LEGACY(int GetGenerateColorScalars());
00174   VTK_LEGACY(void GenerateColorScalarsOn());
00175   VTK_LEGACY(void GenerateColorScalarsOff());
00176 
00177 protected:
00178   vtkClipClosedSurface();
00179   ~vtkClipClosedSurface();
00180 
00181   vtkPlaneCollection *ClippingPlanes;
00182 
00183   double Tolerance;
00184 
00185   int PassPointData;
00186   int GenerateOutline;
00187   int GenerateFaces;
00188   int ActivePlaneId;
00189   int ScalarMode;
00190   double BaseColor[3];
00191   double ClipColor[3];
00192   double ActivePlaneColor[3];
00193 
00194   int TriangulationErrorDisplay;
00195 
00196   vtkIdList *IdList;
00197   vtkCellArray *CellArray;
00198   vtkPolygon *Polygon;
00199 
00200   virtual int ComputePipelineMTime(
00201     vtkInformation* request, vtkInformationVector** inputVector,
00202     vtkInformationVector* outputVector, int requestFromOutputPort,
00203     unsigned long* mtime);
00204 
00205   virtual int RequestData(
00206     vtkInformation* request, vtkInformationVector** inputVector,
00207     vtkInformationVector* outputVector);
00208 
00210 
00211   void ClipLines(
00212     vtkPoints *points, vtkDoubleArray *pointScalars,
00213     vtkPointData *pointData, vtkCCSEdgeLocator *edgeLocator,
00214     vtkCellArray *inputCells, vtkCellArray *outputLines,
00215     vtkCellData *inCellData, vtkCellData *outLineData);
00217 
00219 
00223   void ClipAndContourPolys(
00224     vtkPoints *points, vtkDoubleArray *pointScalars, vtkPointData *pointData,
00225     vtkCCSEdgeLocator *edgeLocator, int triangulate,
00226     vtkCellArray *inputCells, vtkCellArray *outputPolys,
00227     vtkCellArray *outputLines, vtkCellData *inPolyData,
00228     vtkCellData *outPolyData, vtkCellData *outLineData);
00230 
00232 
00236   static int InterpolateEdge(
00237     vtkPoints *points, vtkPointData *pointData,
00238     vtkCCSEdgeLocator *edgeLocator, double tol,
00239     vtkIdType i0, vtkIdType i1, double v0, double v1, vtkIdType &i);
00241 
00243 
00246   int TriangulatePolygon(
00247     vtkIdList *polygon, vtkPoints *points, vtkCellArray *triangles);
00249 
00251 
00258   void MakePolysFromContours(
00259     vtkPolyData *data, vtkIdType firstLine, vtkIdType numLines,
00260     vtkCellArray *outputPolys, const double normal[3]);
00262 
00264 
00268   static void BreakPolylines(
00269     vtkCellArray *inputLines, vtkCellArray *outputLines,
00270     vtkUnsignedCharArray *inputScalars, vtkIdType firstLineScalar,
00271     vtkUnsignedCharArray *outputScalars, const unsigned char color[3]);
00273 
00275 
00278   static void CopyPolygons(
00279     vtkCellArray *inputPolys, vtkCellArray *outputPolys,
00280     vtkUnsignedCharArray *inputScalars, vtkIdType firstPolyScalar,
00281     vtkUnsignedCharArray *outputScalars, const unsigned char color[3]);
00283 
00285 
00287   static void BreakTriangleStrips(
00288     vtkCellArray *inputStrips, vtkCellArray *outputPolys,
00289     vtkUnsignedCharArray *inputScalars, vtkIdType firstStripScalar,
00290     vtkUnsignedCharArray *outputScalars, const unsigned char color[3]);
00292 
00294 
00297   static void SqueezeOutputPoints(
00298     vtkPolyData *output, vtkPoints *points, vtkPointData *pointData,
00299     int outputPointDataType);
00301 
00303 
00304   static void CreateColorValues(
00305     const double color1[3], const double color2[3], const double color3[3],
00306     unsigned char colors[3][3]);
00308 
00309 private:
00310   vtkClipClosedSurface(const vtkClipClosedSurface&);  // Not implemented.
00311   void operator=(const vtkClipClosedSurface&);  // Not implemented.
00312 };
00313 
00314 #endif