//=========================================================================== // GoTools Core - SINTEF Geometry Tools Core library, version 2.0.1 // // Copyright (C) 2000-2007, 2010 SINTEF ICT, Applied Mathematics, Norway. // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation version 2 of the License. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., // 59 Temple Place - Suite 330, // Boston, MA 02111-1307, USA. // // Contact information: E-mail: tor.dokken@sintef.no // SINTEF ICT, Department of Applied Mathematics, // P.O. Box 124 Blindern, // 0314 Oslo, Norway. // // Other licenses are also available for this software, notably licenses // for: // - Building commercial software. // - Building software whose source code you wish to keep private. //=========================================================================== 00017 #ifndef __POINTSEQUENCE_H 00018 #define __POINTSEQUENCE_H 00019 00020 00021 #include <vector> 00022 #include <algorithm> 00023 00024 00025 namespace Go 00026 { 00027 00028 00029 enum PointSequenceType 00030 { 00031 PSTPoint, // Each grid position holds a point 00032 PSTPointTangent, // Each grid position holds a point, then a tangent 00033 PSTScattered // Regard this an unordered point cloud 00034 }; 00035 00036 00037 class PointSequence 00038 { 00039 00040 public: 00041 00042 // Constructors 00043 PointSequence() 00044 : dim_(-1), type_(PSTPoint) 00045 { 00046 grid_length_.resize(0); 00047 } 00048 00049 00050 template <typename RandomIterator> PointSequence(int dim, 00051 int nmb_pts, 00052 RandomIterator coefs_start, 00053 PointSequenceType pst = PSTPoint) 00054 : dim_(dim), type_(pst) 00055 { 00056 grid_length_.resize(1); 00057 grid_length_[0] = nmb_pts; 00058 int coefs_size; 00059 switch (pst) 00060 { 00061 case PSTPoint: 00062 coefs_size = nmb_pts * dim; 00063 break; 00064 case PSTPointTangent: 00065 coefs_size = 2 * nmb_pts * dim; 00066 break; 00067 } 00068 coefs_.resize(coefs_size); 00069 copy(coefs_start, coefs_start + coefs_size, coefs_.begin()); 00070 } 00071 00072 00073 00074 template <typename RandomIterator> PointSequence(int dim, 00075 int nmb_pts_1, 00076 int nmb_pts_2, 00077 RandomIterator coefs_start, 00078 PointSequenceType pst = PSTPoint) 00079 : dim_(dim), type_(pst) 00080 { 00081 grid_length_.resize(2); 00082 grid_length_[0] = nmb_pts_1; 00083 grid_length_[1] = nmb_pts_2; 00084 int coefs_size; 00085 switch (pst) 00086 { 00087 case PSTPoint: 00088 coefs_size = nmb_pts_1 * nmb_pts_2 * dim; 00089 break; 00090 case PSTPointTangent: 00091 coefs_size = 2 * nmb_pts_1 * nmb_pts_2 * dim; 00092 break; 00093 } 00094 coefs_.resize(coefs_size); 00095 copy(coefs_start, coefs_start + coefs_size, coefs_.begin()); 00096 } 00097 00098 00099 00100 00101 template <typename RandomIterator> PointSequence(int dim, 00102 int nmb_pts_1, 00103 int nmb_pts_2, 00104 int nmb_pts_3, 00105 RandomIterator coefs_start, 00106 PointSequenceType pst = PSTPoint) 00107 : dim_(dim), type_(pst) 00108 { 00109 grid_length_.resize(3); 00110 grid_length_[0] = nmb_pts_1; 00111 grid_length_[1] = nmb_pts_2; 00112 grid_length_[2] = nmb_pts_3; 00113 int coefs_size; 00114 switch (pst) 00115 { 00116 case PSTPoint: 00117 coefs_size = nmb_pts_1 * nmb_pts_2 * nmb_pts_3 * dim; 00118 break; 00119 case PSTPointTangent: 00120 coefs_size = 2 * nmb_pts_1 * nmb_pts_2 * nmb_pts_3 * dim; 00121 break; 00122 } 00123 coefs_.resize(coefs_size); 00124 copy(coefs_start, coefs_start + coefs_size, coefs_.begin()); 00125 } 00126 00127 00128 // Destructor 00129 virtual ~PointSequence() { } 00130 00131 00132 int dimension() const; 00133 00134 int grid_dimension() const; 00135 00136 int grid_length(int i) const; 00137 00138 PointSequenceType type() const; 00139 00140 std::vector<double>::iterator coefs_begin() 00141 { return coefs_.begin(); } 00142 00143 std::vector<double>::iterator coefs_end() 00144 { return coefs_.end(); } 00145 00146 std::vector<double>::const_iterator coefs_begin() const 00147 { return coefs_.begin(); } 00148 00149 std::vector<double>::const_iterator coefs_end() const 00150 { return coefs_.end(); } 00151 00152 00153 private: 00154 00155 std::vector<double> coefs_; // The coordinates of the points 00156 int dim_; // The dimension of the space of points 00157 std::vector<int> grid_length_; // Number of points in each direction in grid. grid_length_.size() 00158 // gives the grid dimension (flat, 2D, 3D, etc) 00159 PointSequenceType type_; 00160 00161 }; // Class PointSequence 00162 00163 00164 } // namespace Go 00165 00166 00167 #endif // #ifndef __POINTSEQUENCE_H
Generated on Tue Sep 21 15:44:17 2010 for GoTools Core by  doxygen 1.6.3