00001 00011 // .NAME vtkQuadrilateralSubdivision - implementation of the Kobbelt subdivision method. 00012 // .SECTION Description 00013 // This class implements the paper "Interpolatory Subdivision on Open Quadrilateral Nets 00014 // with Arbitrary Topology". It provides methods to convert an arbitrary net into a 00015 // quadrilateral net and implements the Kobbelt-subdivision algorithm. 00016 // .SECTION Caveats 00017 // Nothing known 00018 // .SECTION see also 00019 // vtk3DSImporter vtkPolyData 00020 00021 #ifndef __vtkQuadrilateralSubdivision_h 00022 #define __vtkQuadrilateralSubdivision_h 00023 00024 // C/C++ includes 00025 #include <iostream> 00026 #include <vector> 00027 00028 // VTK includes 00029 #include "vtkObjectFactory.h" 00030 #include "vtkPolyData.h" 00031 #include "vtkCellArray.h" 00032 #include "vtkIdList.h" 00033 #include "vtkPointData.h" 00034 #include "vtkEdgeTable.h" 00035 #include "vtk3DSOurImporter.h" 00036 00037 using namespace std; 00038 00039 class VTK_EXPORT vtkQuadrilateralSubdivision : public vtkObject 00040 { 00041 public: 00042 static vtkQuadrilateralSubdivision *New(); 00043 vtkTypeMacro(vtkQuadrilateralSubdivision,vtkObject); 00044 //void PrintSelf(ostream& os, vtkIndent indent); 00045 00046 // Description: 00047 // Set which serial port to use, 1 through 4. Default: 1. 00048 // user calls SetSerialPort(int portNumber) 00049 vtkSetMacro(SerialPort, int); // you call SetSerialPort(int PortNumber) 00050 vtkGetMacro(SerialPort, int); // you call GetSerialPort() 00051 00052 // Description: 00053 // Due to the Kobbelt algorithm can handle only quadrilateral nets, it 00054 // is a conversion provided that convert arbitrary nets into quadrilateral ones. 00055 // The Geometry is given by vtkPolyData. 00056 void ConvertCatmullClark(vtkPolyData *polyData); 00057 00058 // Description: 00059 // Due to the Kobbelt algorithm can handle only quadrilateral nets, it 00060 // is a conversion provided that convert arbitrary nets into quadrilateral ones. 00061 // The Geometry is given by vtk3DSMesh, because more meshes can be loaded by 00062 // the vtk3DSImporter class. 00063 void ConvertCatmullClark(vtk3DSMesh *meshList); 00064 00065 // Description: 00066 // The weight specified here is needed to define the precision of the interpolation. 00067 // It ranges from > 0 to < 2(sqrt(5)-1). By default it is set to 1, which leads to 00068 // a cubix presision. 00069 void SetWeight(double w); 00070 00071 // Description: 00072 // This method does one subdivision step, explained in the paper. 00073 // The Geometry is given by vtkPolyData. 00074 void KobbeltSubdivision(vtkPolyData *polyData); 00075 00076 // Description: 00077 // This method does one subdivision step, explained in the paper. 00078 // The Geometry is given by vtk3DSMesh, because more meshes can be loaded by 00079 // the vtk3DSImporter class. 00080 void KobbeltSubdivision(vtk3DSMesh *meshList); 00081 00082 00083 void buildLinks(vtk3DSMesh *meshList); 00084 00085 00086 //BTX 00087 // This section does not get wrapped, use btx, etx syntax to 00088 // prevent the wrapping of methods you don't want wrapped. 00089 // This is usefull when debugging the wrapping portion of the 00090 // process. 00091 // ... 00092 // ... 00093 // ... 00094 //ETX 00095 00096 private: 00097 vtkQuadrilateralSubdivision(); // constructor 00098 ~vtkQuadrilateralSubdivision(); // destructor 00099 vtkQuadrilateralSubdivision(const vtkQuadrilateralSubdivision&) {}; // copy constructor 00100 void operator=(const vtkQuadrilateralSubdivision&) {}; // copy assignment 00101 00102 00103 vtkIdType FetchPointForLKi(vtkPolyData *polyData, vtkIdType cellId, 00104 vtkIdType point, vtkIdType edgePoint, vtkIdType &nextCellId); 00105 00106 protected: 00107 int SerialPort; 00108 00109 double m_dWeight; 00110 00111 double m_dAlpha; 00112 double m_dBeta; 00113 double m_dGamma; 00114 double m_dDelta; 00115 00116 00117 // Description: 00118 // All input-parameters have to be initialized x[3] float arrays. The return value 00119 // then will be also x[3] and the new edgepoint, calculated by the 4-point rule, 00120 // described in the Kobbelt-paper. The points have to be consecutive points, whereas 00121 // the new interpolated point will be on the edge between p2 and p3. 00122 float *Regular4PointRule(float *p1, float *p2, float *p3, float *p4); 00123 float *NonRegular4PointRule(float *p1, float *p2, float *p3, float *p4); 00124 00125 // Description: 00126 // If we have a edge between p1 and p2 and are interested in the edge-intperpolation-point, 00127 // then pPointIDs is filled with all need ki and li (see formula in the paper. 00128 // The new virtual point is returned. 00129 // For ordering in the pPointIDs see GetSurroundingLKiPoints. 00130 float *GetVirtualPoint3(vtkPoints *points, vtkIdType *pPointIDs); 00131 float *GetVirtualPoint5(vtkPoints *points, vtkIdType *pPointIDs); 00132 00133 00134 // Description: 00135 // ask tron 00136 // parameters: 00137 // pointer to a vtkPolyData 00138 // the cell id of the cell 00139 // the point id of p 00140 // the point id of l(i) 00141 // return order: l(i), k(i-1), l(i-1), k(i-2), k(i), l(i+1), 00142 // k(i+1), l(i+2), k(i+2) 00143 vtkIdType *GetSurroundingLKiPoints(vtkPolyData *polyData, 00144 vtkIdType cellId, vtkIdType p, vtkIdType li); 00145 00146 // Description: 00147 // We have a face with the points i-1, i, i+1, i+2, then we want to calculate the edgepoint 00148 // between i and i+1: this methods returns the point before i successive with i and i+1. 00149 // Therefore we nee the previous point i-1 and its neighbouring faces!! 00150 vtkIdType GetRegularPointInLine(vtkPolyData *polyData,vtkIdType cellId, 00151 vtkIdType point, vtkIdType prevPoint); 00152 vtkIdType GetRegularPointInLineIdx(vtkPolyData *polyData,vtkCellArray* edgePolys, 00153 vtkIdType cellId, vtkIdType point, vtkIdType prevPoint); 00154 00155 // Description: 00156 // Calculate the edgepoints for a whole polyData and store the points and faces, whereas 00157 // the faces are only temporal. 00158 void GenerateEdgePoints(vtkPolyData *polyData, vtkPoints* &newPoints, vtkCellArray* &edgePolys); 00159 00160 void GenerateFacePoints(vtkPolyData *polyData, vtkPoints* &newPoints, vtkPoints* &allPoints, vtkCellArray* edgePolys, vtkCellArray* &newPolys); 00161 }; 00162 00163 00164 #endif //#ifndef __vtkQuadrilateralSubdivision_h