- Timestamp:
- 09/28/05 18:11:32 (19 years ago)
- Location:
- trunk/VUT/GtpVisibilityPreprocessor/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/Polygon3.cpp
r298 r299 8 8 #define SIDE_TOLERANCE 0.002f // TODO: Test different values 9 9 #define SIDE_TOLERANCE_SQRD 0.000004f 10 #define AREA_LIMIT 0.0001f 10 11 11 12 Polygon3::Polygon3(): mMaterial(NULL), mParent(NULL) … … 108 109 float Polygon3::GetArea() const 109 110 { 110 float area = 0.0f; 111 112 VertexContainer vertXY; 111 VertexContainer vtx; 113 112 114 113 //-- rotate polygon to lie in xy plane … … 121 120 VertexContainer::const_iterator it, it_end = mVertices.end(); 122 121 123 Debug << "old: ";124 122 for (it = mVertices.begin(); it != it_end; ++it) 125 { 126 vertXY.push_back(rot * (*it)); 127 Debug << (*it).z << " "; 128 } 129 Debug << endl << "new: "; 130 for (it = vertXY.begin(); it != vertXY.end(); ++it) 131 Debug << (*it).z << " "; 132 Debug << endl << endl; 133 134 return area; 123 vtx.push_back(rot * (*it)); 124 125 Vector3 *cur = &vtx.back(); 126 127 float area = 0.0f; 128 for (it = vtx.begin(); it != vtx.end(); ++it) 129 { 130 area += cur->y * (*it).x - cur->x * (*it).y; 131 132 *cur = (*it); 133 } 134 135 return area * 0.5f; 135 136 } 136 137 … … 210 211 } 211 212 212 bool Polygon3:: CheckValid() const213 bool Polygon3::Valid() const 213 214 { 214 215 if (mVertices.size() < 3) 215 216 return false; 216 217 218 #if 1 219 // check if area exceeds certain size 220 if (AREA_LIMIT > GetArea()) 221 return false; 222 #else 217 223 Vector3 vtx = mVertices.back(); 218 224 VertexContainer::const_iterator it, it_end = mVertices.end(); … … 227 233 vtx = *it; 228 234 } 229 235 #endif 230 236 return true; 231 237 } -
trunk/VUT/GtpVisibilityPreprocessor/src/Polygon3.h
r298 r299 67 67 @returns true if polygon is valid. 68 68 */ 69 bool CheckValid() const;69 bool Valid() const; 70 70 71 71 /** Includes polygons to axis aligned box. -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp
r298 r299 193 193 194 194 // check if polygons still valid 195 if (front_piece-> mVertices.size() >= 3)195 if (front_piece->Valid()) 196 196 frontPolys->push_back(front_piece); 197 197 else 198 198 DEL_PTR(front_piece); 199 199 200 if (back_piece-> mVertices.size() >= 3)200 if (back_piece->Valid()) 201 201 backPolys->push_back(back_piece); 202 202 else … … 456 456 polys.push_back(poly); 457 457 458 if (!poly-> CheckValid())458 if (!poly->Valid()) 459 459 Debug << "Input polygon not valid: " << *poly << endl; 460 460 … … 829 829 830 830 if (sSplitPlaneStrategy & LARGEST_POLY_AREA) 831 { 832 Debug << "polygon area: " << (*it)->GetArea() << " "; 831 833 sumPolyArea += (*it)->GetArea(); 832 } 834 } 835 }Debug << "\n"; 833 836 } 834 837
Note: See TracChangeset
for help on using the changeset viewer.