source: GTP/trunk/App/Demos/Illum/pathmap/WsubMesh.cpp @ 2197

Revision 2197, 2.0 KB checked in by szirmay, 18 years ago (diff)
RevLine 
[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
13WsubMesh::WsubMesh()
14{
15}
16
17WsubMesh::~WsubMesh()
18{
19
20}
21
22void 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
62void 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
82int WsubMesh::isEmpty()
83{
84        return( complete.empty() || incomplete.empty());
85}
86
87void WsubMesh::setInsider(Wsimplex *niro)
88{
89        insiders.push_back(niro);
90}
Note: See TracBrowser for help on using the repository browser.