// WsubMesh.cpp: implementation of the WsubMesh class. // ////////////////////////////////////////////////////////////////////// #include "dxstdafx.h" #include "WsubMesh.h" #include "Wsimplex.h" ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// WsubMesh::WsubMesh() { } WsubMesh::~WsubMesh() { } void WsubMesh::add(Wsimplex *newbie) { if(newbie->isComplete()) complete.push_back(newbie); else { if(incomplete.empty()) { incomplete.push_back(newbie); return; } ::std::vector::iterator a = incomplete.begin(); while(a < incomplete.end()) { switch((*a)->join(newbie)) { //no join, none complete case -1: a++; break; //successfull join, none complete case 0: a++; break; //successfull join, a complete case 1: complete.push_back(*a); incomplete.erase(a); break; //successfull join, newbie complete case 2: complete.push_back(newbie); return; //successfull join, both complete case 3: complete.push_back(*a); complete.push_back(newbie); incomplete.erase(a); return; } } //list end reached, newbie is not complete, and may be inserted into the incomplete list at last incomplete.push_back(newbie); } } void WsubMesh::merge(WsubMesh *other) { //WARNING this add called here could skip isComplete testing //added triangle is always incomplete, ::std::vector::const_iterator a = other->incomplete.begin(); while(a != other->incomplete.end()) { add(*a); a++; } other->incomplete.clear(); //WARN could use a lastComplete pointer here complete.insert(complete.end(), other->complete.begin(), other->complete.end()); other->complete.clear(); delete other; } int WsubMesh::isEmpty() { return( complete.empty() || incomplete.empty()); } void WsubMesh::setInsider(Wsimplex *niro) { insiders.push_back(niro); }