27 #ifndef MPBLOCKS_CLARKSON93_DYNAMIC_TRIANGULATION_HPP_
28 #define MPBLOCKS_CLARKSON93_DYNAMIC_TRIANGULATION_HPP_
33 namespace clarkson93 {
38 template <
class Traits>
49 template <
class Traits>
55 template <
class Traits>
58 m_antiOrigin = setup.antiOrigin();
59 m_deref = setup.deref();
60 m_ndim = setup.ndim();
62 m_x_visible .reserve( setup.xVisiblePrealloc() );
63 m_xv_queue .reserve( setup.xVisiblePrealloc() );
64 m_xv_walked .reserve( setup.xVisiblePrealloc() );
65 m_xv_walk .reserve( setup.xVisiblePrealloc() );
67 m_ridges. reserve( setup.horizonPrealloc() );
69 setup.setupAlloc( m_sAlloc );
72 template <
class Traits>
73 template <
class Iterator>
75 Iterator begin, Iterator end)
78 std::vector<Simplex*> S(m_ndim+1);
82 Simplex* S_0 = m_sAlloc.create();
83 for( Iterator ipRef = begin; ipRef != end; ++ipRef )
85 S_0->vertices[i++] = ipRef;
87 S_0->calculateConstraint( m_ndim, m_deref );
88 S_0->orientConstraint( m_deref( S_0->vertices[0] ),
93 for(
int i=0; i < m_ndim+1; i++)
95 S[i] = m_sAlloc.create();
96 S[i]->vertices[0] = m_antiOrigin;
97 S[i]->neighbors[0] = S_0;
99 S_0->neighbors[i] = S[i];
102 for(
int j=0; j < m_ndim+1; j++)
110 S[i]->vertices[k] = S_0->vertices[j];
115 S[i]->calculateConstraint( m_ndim, m_deref );
116 S[i]->orientConstraint( m_deref(S_0->vertices[i]),
121 for(
int i=0; i < m_ndim+1; i++)
160 for(
int j=1; j < m_ndim+1; j++)
162 int k = (j <= i ) ? j-1 : j;
163 S[i]->neighbors[j] = S[k];
172 m_hullSimplex = S[0];
176 template <
class Traits>
185 template <
class Traits>
193 template <
class Traits>
219 if( !S->isVisible( m_deref(x) ) )
223 assert( S->isVisible( m_deref(x) ) );
226 m_xv_walked.push( S );
227 m_xv_walk.push(
PQ_Key( 0, S ) );
234 while( m_xv_walk.size() > 0 )
236 Simplex* pop = m_xv_walk.pop().val;
240 for(
int i=1; i < m_ndim+1; i++)
242 Simplex* N = pop->neighbors[i];
244 if( N->isVisible( m_deref(x) )
245 && !m_xv_walked.isMember(N) )
248 if(N->isInfinite(m_antiOrigin) )
256 ( m_deref(x) - m_deref(N->vertices[0]) ).squaredNorm();
258 m_xv_walk.push(
PQ_Key(d,N) );
272 while( m_xv_queue.size() > 0 )
281 for(
int i=1; i < m_ndim+1; i++ )
287 if( N->isVisible( m_deref(x) )
288 && N->isInfinite( m_antiOrigin )
289 && !m_x_visible.isMember( N )
290 && !m_xv_queue.isMember( N ) )
292 m_xv_queue.push( N );
355 template <
class Traits>
363 size_t nVisible = m_x_visible.size();
364 for(
size_t i=0; i < nVisible; ++i)
375 for(
size_t i=0; i < nVisible; ++i)
381 for(
int i=1; i < m_ndim+1; i++)
387 if( !m_x_visible.isMember( S->neighbors[i] ) )
397 size_t nHorizon = m_ridges.size();
398 for(
size_t i=0; i < nHorizon; i++ )
403 Simplex* simplex = m_sAlloc.create();
404 ridge.generatedSimplex = simplex;
411 Simplex* N = V->neighbors[ridge.iExcluded];
416 simplex->vertices[0] = m_antiOrigin;
417 simplex->neighbors[0] = V;
426 simplex->vertices[ridge.iExcluded] =
x;
427 simplex->neighbors[ridge.iExcluded] = N;
438 for(
int i=0; i < m_ndim+1; i++)
440 if( N->neighbors[i] == V )
442 N->neighbors[i] = simplex;
449 V->neighbors[ridge.iExcluded] = simplex;
455 for(
int i = 1; i < m_ndim+1; i++)
459 if( i == ridge.iExcluded )
466 simplex->vertices[i] = V->vertices[i];
477 PointRef p_excluded = V->vertices[ridge.iExcluded];
478 simplex->calculateConstraint( m_ndim, m_deref );
479 simplex->orientConstraint( m_deref(p_excluded),
486 for(
size_t i=0; i < nHorizon; i++ )
489 Simplex* simplex = ridge.generatedSimplex;
495 for(
int i=1; i < m_ndim+1; i++)
496 vertices_f.insert( simplex->vertices[i] );
500 for(
int i=1; i < m_ndim+1; i++)
502 if( i == ridge.iExcluded )
523 for(
int j=0; j < m_ndim+1; j++)
525 Simplex* candidate = S->neighbors[j];
526 if( candidate != from
527 && candidate->vertices[0] == x)
532 for(
int k=1; k < m_ndim+1; k++)
534 if( vertices_f.find(candidate->vertices[k])
535 == vertices_f.end() )
568 for(
int j=1; j < m_ndim+1; j++)
570 Simplex* neighbor = S->neighbors[j];
585 for(
int j=1; j < m_ndim+1; j++)
587 Simplex* neighbor = S->neighbors[j];
591 if( neighbor == from )
596 if( vertices_f.find(vertex) == vertices_f.end() )
607 simplex->neighbors[i] = S->neighbors[iy1];
610 vertices_f.insert(q);
627 #endif // TRIANGULATION_HPP_
has been queued during the x-visible walk
void insert(const PointRef x, Simplex *S=0)
insert a new point into the triangulation and update the convex hull (if necessary) ...
void alter_x_visible(PointRef x)
VertexSurrogate< ArrayLike > vertex(const ArrayLike &v)
Traits::PointRef PointRef
void find_x_visible(PointRef x, Simplex *S=0)
find the set of facets and put them in x_visible
is queued for expansion in x-visible search
std::set< PointRef > PointSet
void init(Iterator begin, Iterator end)
builds the initial triangulation from the first NDim + 1 points inserted
void setup(Setup &setup)
set's up the triangulation by helping it construct it's allocators and preallocate it's sets ...
A horizon ridge is a d-2 dimensional facet (i.e. a facet of a facet),.
void clear()
destroys all simplex objects that have been generated and clears all lists/ sets