1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
|
#include "config.h"
#include "PlaneParam.h"
using namespace psurface;
template <class ctype>
typename PlaneParam<ctype>::DirectedEdgeIterator& PlaneParam<ctype>::DirectedEdgeIterator::operator++()
{
if (neighborIdx < (*nodes)[from()].degree()-1)
neighborIdx++;
else {
do{
fromNode++;
if (!isValid())
return *this;
}while (!(*nodes)[fromNode].degree());
neighborIdx = 0;
}
return *this;
}
template <class ctype>
void PlaneParam<ctype>::DirectedEdgeIterator::invert()
{
int other = to();
for (int i=0; i<(*nodes)[other].degree(); i++)
if ((*nodes)[other].neighbors(i)==fromNode)
neighborIdx = i;
fromNode = other;
}
template <class ctype>
typename PlaneParam<ctype>::UndirectedEdgeIterator& PlaneParam<ctype>::UndirectedEdgeIterator::operator++()
{
do{
//nextPseudoEdge(edge);
if (neighborIdx < (*nodes)[from()].degree()-1)
neighborIdx++;
else {
do{
fromNode++;
if (!isValid())
return *this;
}while (!(*nodes)[fromNode].degree());
neighborIdx = 0;
}
if (!isValid())
return *this;
}while (!isCorrectlyOriented());
return *this;
}
template <class ctype>
PlaneParam<ctype>::TriangleIterator::TriangleIterator(const DirectedEdgeIterator& firstEdge)
{
cE = firstEdge;
// regular handling
while (cE.isValid() && !isCorrectlyOriented())
++cE;
}
template <class ctype>
typename PlaneParam<ctype>::TriangleIterator& PlaneParam<ctype>::TriangleIterator::operator++()
{
do {
++cE;
} while (cE.isValid() && !isCorrectlyOriented());
return *this;
}
template <class ctype>
bool PlaneParam<ctype>::TriangleIterator::isCorrectlyOriented() const
{
if (cE.getONext().to()!=cE.getDPrev().from() ||
vertices(2) >= vertices(0) || vertices(2) >= vertices(1))
return false;
// if the plane graph contains isolated triangles these triangles
// appear twice each. The following code filters out the doubles.
// This can lead to inconsistent orientation
DirectedEdgeIterator cEInv = cE;
cEInv.invert();
return (PlaneParam::orientation((*cE.nodes)[vertices(0)].domainPos(),
(*cE.nodes)[vertices(1)].domainPos(),
(*cE.nodes)[vertices(2)].domainPos()) == 1);
// This is a topological test and not well thought out
// int i, j;
// for (i=0; i<3; i++) {
// const Node& p = (*cE.nodes)[vertices(i)];
// const Node& q = (*cE.nodes)[vertices((i+1)%3)];
// if (p.isINTERIOR_NODE() || q.isINTERIOR_NODE())
// continue;
// for (j=0; j<3; j++)
// if (p.isOnEdge(j) && q.isOnEdge(j))
// return q.getDomainEdgePosition(j) > p.getDomainEdgePosition(j);
// }
// if (cEInv.getONext().to()!=cE.getDPrev().from() || cEInv.getDPrev().from()!=cE.getONext().to())
// return true;
// return vertices(0) < vertices(1);
}
#ifndef __APPLE__
// ////////////////////////////////////////////////////////
// Explicit template instantiations.
// If you need more, you can add them here.
// ////////////////////////////////////////////////////////
namespace psurface {
template class PSURFACE_EXPORT PlaneParam<float>::DirectedEdgeIterator;
template class PSURFACE_EXPORT PlaneParam<double>::DirectedEdgeIterator;
template class PSURFACE_EXPORT PlaneParam<float>::UndirectedEdgeIterator;
template class PSURFACE_EXPORT PlaneParam<double>::UndirectedEdgeIterator;
template class PSURFACE_EXPORT PlaneParam<float>::TriangleIterator;
template class PSURFACE_EXPORT PlaneParam<double>::TriangleIterator;
}
#endif
|