Changeset 13041 for OpenSceneGraph/trunk/include/osgUtil/EdgeCollector
- Timestamp:
- 03/21/12 18:36:20 (14 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/include/osgUtil/EdgeCollector
r12139 r13041 1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield 1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield 2 2 * 3 * This library is open source and may be redistributed and/or modified under 4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 3 * This library is open source and may be redistributed and/or modified under 4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 5 5 * (at your option) any later version. The full license is in LICENSE file 6 6 * included with this distribution, and on the openscenegraph.org website. 7 * 7 * 8 8 * This library is distributed in the hope that it will be useful, 9 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 11 * OpenSceneGraph Public License for more details. 12 12 */ … … 63 63 { 64 64 public: 65 65 66 66 struct Triangle; 67 67 struct Edge; … … 70 70 71 71 typedef std::list<osg::ref_ptr<osg::UIntArray> > IndexArrayList; 72 72 73 73 ~EdgeCollector(); 74 74 … … 90 90 { 91 91 Point(): _protected(false), _index(0) {} 92 92 93 93 bool _protected; 94 94 … … 101 101 102 102 bool operator < ( const Point& rhs) const { return _vertex < rhs._vertex; } 103 103 104 104 bool isBoundaryPoint() const; 105 105 }; … … 111 111 osg::ref_ptr<Point> _p1; 112 112 osg::ref_ptr<Point> _p2; 113 113 114 114 osg::ref_ptr<Point> _op1; 115 115 osg::ref_ptr<Point> _op2; 116 116 117 117 TriangleSet _triangles; 118 118 119 119 120 120 bool operator < ( const Edge& rhs) const; 121 121 122 122 bool operator == ( const Edge& rhs) const; 123 123 124 124 bool operator != ( const Edge& rhs) const; 125 125 126 126 void setOrderedPoints(Point* p1, Point* p2); 127 127 128 128 void addTriangle(Triangle* triangle) { _triangles.insert(triangle); } 129 129 130 130 bool isBoundaryEdge() const { return _triangles.size()<=1; } 131 131 132 132 bool isAdjacentToBoundary() const { return isBoundaryEdge() || _p1->isBoundaryPoint() || _p2->isBoundaryPoint(); } 133 133 134 134 bool endConnected(const Edge& rhs) const { return (_op2 == rhs._op1); } 135 135 136 136 bool beginConnected(const Edge& rhs) const { return (_op1 == rhs._op2); } 137 137 }; … … 140 140 { 141 141 Triangle() {} 142 142 143 143 void clear(); 144 144 … … 146 146 147 147 void setOrderedPoints(Point* p1, Point* p2, Point* p3); 148 148 149 149 float distance(const osg::Vec3& vertex) const { return _plane.distance(vertex); } 150 150 151 151 bool isBoundaryTriangle() const 152 152 { return (_e1->isBoundaryEdge() || _e2->isBoundaryEdge() || _e3->isBoundaryEdge()); } 153 153 154 154 155 155 osg::ref_ptr<Point> _p1; 156 156 osg::ref_ptr<Point> _p2; 157 157 osg::ref_ptr<Point> _p3; 158 158 159 159 osg::ref_ptr<Point> _op1; 160 160 osg::ref_ptr<Point> _op2; 161 161 osg::ref_ptr<Point> _op3; 162 162 163 163 osg::ref_ptr<Edge> _e1; 164 164 osg::ref_ptr<Edge> _e2; 165 165 osg::ref_ptr<Edge> _e3; 166 167 osg::Plane _plane; 166 167 osg::Plane _plane; 168 168 }; 169 169 … … 171 171 { 172 172 typedef std::vector<osg::ref_ptr<Edge> > EdgeList; 173 173 174 174 bool isClosed() { return (_edgeList.back()->endConnected(*_edgeList.front().get())); } 175 175 176 176 osg::UIntArray * toIndexArray() const; 177 177 178 178 EdgeList _edgeList; 179 179 }; 180 180 181 181 182 182 183 183 Triangle* addTriangle(unsigned int p1, unsigned int p2, unsigned int p3); 184 184 Triangle* addTriangle(Point* p1, Point* p2, Point* p3); 185 185 186 186 Edge* addEdge(Triangle* triangle, Point* p1, Point* p2); 187 187 188 188 Point* addPoint(Triangle* triangle, unsigned int p1) { return addPoint(triangle,_originalPointList[p1].get()); } 189 189 Point* addPoint(Triangle* triangle, Point* point); 190 190 191 191 void getBoundaryEdgeList(EdgeList & el); 192 192 bool extractBoundaryEdgeloop(EdgeList & el, Edgeloop & edgeloop); 193 193 bool extractBoundaryEdgeloopList(EdgeList & el, EdgeloopList & edgeloopList); 194 194 195 195 void getEdgeloopIndexList(IndexArrayList & ial); 196 196 197 197 //protected: 198 198 199 199 osg::Geometry* _geometry; 200 200 201 201 EdgeSet _edgeSet; 202 202 TriangleSet _triangleSet; 203 203 PointSet _pointSet; 204 204 PointList _originalPointList; 205 205 206 206 }; 207 207
