48 const std::vector<Point3df> & vert = mesh.
vertex();
49 const std::vector< AimsVector<uint,3> > & poly = mesh.
polygon();
50 unsigned i, n = vert.size();
57 std::map<unsigned, std::set<unsigned> > neighbours;
60 for( i=0; i<poly.size(); ++i )
68 neighbours[v1].insert( v2 );
69 neighbours[v2].insert( v1 );
74 neighbours[v1].insert( v3 );
75 neighbours[v3].insert( v1 );
80 neighbours[v2].insert( v3 );
81 neighbours[v3].insert( v2 );
89 if( inittex.
item(i) == 0 )
97 std::multimap<float,unsigned> front1, front2;
98 std::multimap<float,unsigned> *cfront = &front1, *nfront = &front2, *tmpf;
99 std::multimap<float,unsigned>::iterator iv, fv;
100 std::set<unsigned> neigh;
101 std::set<unsigned>::iterator in, fn;
108 if( tex.
item(i) == 0 )
109 front1.insert( std::pair<float,unsigned>( 0, i ) );
113 while( cfront->size() > 0 )
118 for( iv=cfront->begin(), fv=cfront->end(); iv!=fv; ++iv )
122 for( in=neighbours[i].begin(), fn=neighbours[i].end(); in!=fn; ++in )
124 d2 = tex.
item( *in );
125 pos = vert[i] - vert[*in];
126 l = sqrt( pos[0] * pos[0] + pos[1] * pos[1] + pos[2] * pos[2] );
129 tex.
item( *in ) = d + l;
135 for( in=neigh.begin(), fn=neigh.end(); in!=fn; ++in )
136 nfront->insert( std::pair<float,unsigned>( tex.
item( *in ), *in ) );
144 if( !allowUnreached )
146 if( tex.
item(i) == FLT_MAX )
const short MESHDISTANCE_FORBIDDEN
global variable...
const T & item(int n) const
Texture< float > MeshDistance(const AimsSurface< 3, Void > &mesh, const Texture< T > &inittex, bool allowUnreached)
const std::vector< Point3df > & vertex() const
void reserve(size_t size)
const std::vector< AimsVector< uint, D > > & polygon() const
const short MESHDISTANCE_UNREACHED
void push_back(const T &item)