//=========================================================================== // 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. //=========================================================================== 00015 #ifndef RECTANGULARSURFACETESSELATOR_H 00016 #define RECTANGULARSURFACETESSELATOR_H 00017 00018 #include "GoTools/tesselator/Tesselator.h" 00019 #include "GoTools/tesselator/RegularMesh.h" 00020 #include "GoTools/tesselator/LineStrip.h" 00021 #include "GoTools/geometry/ParamSurface.h" 00022 #include "GoTools/utils/config.h" 00023 00024 namespace Go 00025 { 00026 00032 class GO_API RectangularSurfaceTesselator : public Tesselator 00033 { 00034 public: 00035 RectangularSurfaceTesselator(const ParamSurface& surf, 00036 int ures = 100, 00037 int vres = 100, 00038 bool iso = true, 00039 int uiso = 15, 00040 int viso = 15, 00041 int isores = 300) 00042 : surf_(surf), 00043 isolines_(iso), uiso_(uiso), viso_(viso), isores_(isores) 00044 { 00045 mesh_ = boost::shared_ptr<RegularMesh>(new RegularMesh(ures, vres, true, true)); 00046 } 00047 00048 virtual ~RectangularSurfaceTesselator(); 00049 00050 virtual void tesselate(); 00051 00052 boost::shared_ptr<RegularMesh> getMesh() 00053 { 00054 return mesh_; 00055 } 00056 00057 std::vector<LineStrip>& getIsolineStrips() 00058 { 00059 return isolinestrips_; 00060 } 00061 00062 // 00063 // 010430: I'm not sure if we're going to need these functions, an 00064 // alternative is to trigger these actions when asking for 00065 // pointers to the discretizations, which will be done by 00066 // the 'painter' when that one is requested to redraw the scene... 00067 // (jon) 00068 // 00069 00070 void changeRes(int m, int n) 00071 { 00072 mesh_->resize(m, n); 00073 tesselateSurface(); 00074 } 00075 void getRes(int& m, int& n) 00076 { 00077 n = mesh_->numStrips() + 1; 00078 m = mesh_->numVertices()/n; 00079 } 00080 00081 void changeIsolines(bool isolines) 00082 { 00083 isolines_ = isolines; 00084 if (isolines_) { 00085 tesselateIsolines(); 00086 } 00087 } 00088 00089 void getIsolines(bool& isolines) 00090 { 00091 isolines = isolines_; 00092 } 00093 00094 void changeIsolineNumRes(int m, int n, int res) 00095 { 00096 uiso_ = m; 00097 viso_ = n; 00098 isores_ = res; 00099 tesselateIsolines(); 00100 } 00101 void getIsolineNumRes(int& m, int& n, int& res) 00102 { 00103 n = uiso_; 00104 m = viso_; 00105 res = isores_; 00106 } 00107 00108 private: 00109 void tesselateSurface(); 00110 void tesselateIsolines(); 00111 00112 const ParamSurface& surf_; 00113 boost::shared_ptr<RegularMesh> mesh_; 00114 std::vector<LineStrip> isolinestrips_; 00115 bool isolines_; 00116 int uiso_; 00117 int viso_; 00118 int isores_; 00119 }; 00120 00121 } // namespace Go 00122 00123 00124 #endif // RECTANGULARSURFACETESSELATOR_H 00125