[2197] | 1 | // WsubMesh.cpp: implementation of the WsubMesh class.
|
---|
| 2 | //
|
---|
| 3 | //////////////////////////////////////////////////////////////////////
|
---|
| 4 |
|
---|
| 5 | #include "dxstdafx.h"
|
---|
| 6 | #include "WsubMesh.h"
|
---|
| 7 | #include "Wsimplex.h"
|
---|
| 8 |
|
---|
| 9 | //////////////////////////////////////////////////////////////////////
|
---|
| 10 | // Construction/Destruction
|
---|
| 11 | //////////////////////////////////////////////////////////////////////
|
---|
| 12 |
|
---|
| 13 | WsubMesh::WsubMesh()
|
---|
| 14 | {
|
---|
| 15 | }
|
---|
| 16 |
|
---|
| 17 | WsubMesh::~WsubMesh()
|
---|
| 18 | {
|
---|
| 19 |
|
---|
| 20 | }
|
---|
| 21 |
|
---|
| 22 | void WsubMesh::add(Wsimplex *newbie)
|
---|
| 23 | {
|
---|
| 24 | if(newbie->isComplete())
|
---|
| 25 | complete.push_back(newbie);
|
---|
| 26 | else
|
---|
| 27 | {
|
---|
| 28 | if(incomplete.empty())
|
---|
| 29 | {
|
---|
| 30 | incomplete.push_back(newbie);
|
---|
| 31 | return;
|
---|
| 32 | }
|
---|
| 33 |
|
---|
| 34 | ::std::vector<Wsimplex*>::iterator a = incomplete.begin();
|
---|
| 35 | while(a < incomplete.end())
|
---|
| 36 | {
|
---|
| 37 | switch((*a)->join(newbie))
|
---|
| 38 | {
|
---|
| 39 | //no join, none complete
|
---|
| 40 | case -1: a++; break;
|
---|
| 41 | //successfull join, none complete
|
---|
| 42 | case 0: a++; break;
|
---|
| 43 | //successfull join, a complete
|
---|
| 44 | case 1: complete.push_back(*a);
|
---|
| 45 | incomplete.erase(a);
|
---|
| 46 | break;
|
---|
| 47 | //successfull join, newbie complete
|
---|
| 48 | case 2: complete.push_back(newbie);
|
---|
| 49 | return;
|
---|
| 50 | //successfull join, both complete
|
---|
| 51 | case 3: complete.push_back(*a);
|
---|
| 52 | complete.push_back(newbie);
|
---|
| 53 | incomplete.erase(a);
|
---|
| 54 | return;
|
---|
| 55 | }
|
---|
| 56 | }
|
---|
| 57 | //list end reached, newbie is not complete, and may be inserted into the incomplete list at last
|
---|
| 58 | incomplete.push_back(newbie);
|
---|
| 59 | }
|
---|
| 60 | }
|
---|
| 61 |
|
---|
| 62 | void WsubMesh::merge(WsubMesh *other)
|
---|
| 63 | {
|
---|
| 64 | //WARNING this add called here could skip isComplete testing
|
---|
| 65 | //added triangle is always incomplete,
|
---|
| 66 |
|
---|
| 67 | ::std::vector<Wsimplex*>::const_iterator a = other->incomplete.begin();
|
---|
| 68 | while(a != other->incomplete.end())
|
---|
| 69 | {
|
---|
| 70 | add(*a);
|
---|
| 71 | a++;
|
---|
| 72 | }
|
---|
| 73 | other->incomplete.clear();
|
---|
| 74 |
|
---|
| 75 | //WARN could use a lastComplete pointer here
|
---|
| 76 | complete.insert(complete.end(), other->complete.begin(), other->complete.end());
|
---|
| 77 | other->complete.clear();
|
---|
| 78 |
|
---|
| 79 | delete other;
|
---|
| 80 | }
|
---|
| 81 |
|
---|
| 82 | int WsubMesh::isEmpty()
|
---|
| 83 | {
|
---|
| 84 | return( complete.empty() || incomplete.empty());
|
---|
| 85 | }
|
---|
| 86 |
|
---|
| 87 | void WsubMesh::setInsider(Wsimplex *niro)
|
---|
| 88 | {
|
---|
| 89 | insiders.push_back(niro);
|
---|
| 90 | }
|
---|