void VoronoiSlabGenerator::Slab::SlabData::generatePeriodicImages() { K::Vector_2 a, dr; for(Delaunay::Vertex_iterator it = dg.vertices_begin(), end = dg.vertices_end(); it != end; ++it) vertices.push_back(it); if(unitCell) { BOOST_FOREACH(const Delaunay::Vertex_handle vtx, vertices) { for(int i = -1; i <= 1; ++i) { a = toCgalVec2< K>(static_cast< double>(i) * unitCell->getAVec()); for(int j = -1; j <= 1; ++j) { if(!(i == 0 && j == 0)) { dr = a + toCgalVec2< K>(static_cast< double>(j) * unitCell->getBVec()); const Delaunay::Vertex_handle image = dg.insert(vtx->point() + dr); image->info() = vtx->info(); image->info().isImage = true; periodicImages.insert( PeriodicImages::value_type(vtx, std::make_pair(dr, image))); } } } } } }
int main() { Delaunay dt; Delaunay::Vertex_handle vh; vh = dt.insert(Point(0,0,0)); vh->info() = "Paris"; vh = dt.insert(Point(1,0,0.1)); vh->info() = "London"; vh = dt.insert(Point(0,1,0.2)); vh->info() = "New York"; return 0; }
void VoronoiCgal_Patch::insert_polygon(Delaunay& cdt, ImageSpline& m_ImageSpline, int idx) { PatchSpline& ps = m_ImageSpline.m_PatchSplines[idx]; LineIndex start_idx = ps.m_LineIndexs.front(); CgalPoint last; if (start_idx.m_Forward) { Vector2 v = m_ImageSpline.m_LineFragments[start_idx.m_id].m_Points.front(); last = CgalPoint(v.x, v.y); } else { Vector2 v = m_ImageSpline.m_LineFragments[start_idx.m_id].m_Points.back(); last = CgalPoint(v.x, v.y); } CgalPoint start = last; Delaunay::Vertex_handle v_prev = cdt.insert(last); v_prev->info().nesting_level = idx; for (auto it = ps.m_LineIndexs.begin(); it != ps.m_LineIndexs.end(); ++it) { Line pts = m_ImageSpline.m_LineFragments[it->m_id].m_Points; if (it->m_Forward) { for (auto it2 = pts.begin(); it2 != pts.end(); ++it2) { CgalPoint now(it2->x, it2->y); if (now != last) { Delaunay::Vertex_handle vh = cdt.insert(now); if (vh->info().nesting_level == -1 || vh->info().nesting_level == idx) { vh->info().nesting_level = idx; cdt.insert_constraint(v_prev, vh); v_prev = vh; last = now; } } } } else { for (auto it2 = pts.rbegin(); it2 != pts.rend(); ++it2) { CgalPoint now(it2->x, it2->y); if (now != last) { Delaunay::Vertex_handle vh = cdt.insert(now); if (vh->info().nesting_level == -1 || vh->info().nesting_level == idx) { vh->info().nesting_level = idx; cdt.insert_constraint(v_prev, vh); v_prev = vh; last = now; } } } } } }
void VoronoiCgal_Patch::insert_polygonInter2(Delaunay& cdt, ImageSpline& is, PatchSpline& ps) { const int NESTING_LEVEL = TRIANGLE_TRANSPARENT; if (ps.m_LineIndexs.empty()) { return; } LineIndex start_idx = ps.m_LineIndexs.front(); CgalPoint last; if (start_idx.m_Forward) { Vector2 v = is.m_LineFragments[start_idx.m_id].m_Points.front(); last = CgalPoint(v.x, v.y); } else { Vector2 v = is.m_LineFragments[start_idx.m_id].m_Points.back(); last = CgalPoint(v.x, v.y); } CgalPoint start = last; Delaunay::Vertex_handle v_prev = cdt.insert(last); v_prev->info().nesting_level = NESTING_LEVEL; for (auto it = ps.m_LineIndexs.begin(); it != ps.m_LineIndexs.end(); ++it) { Line pts = is.m_LineFragments[it->m_id].m_Points; if (it->m_Forward) { for (auto it2 = pts.begin(); it2 != pts.end(); ++it2) { CgalPoint now(it2->x, it2->y); if (now != last) { Delaunay::Vertex_handle vh = m_Delaunay.insert(now); if (vh->info().nesting_level == -1 || vh->info().nesting_level == NESTING_LEVEL) { vh->info().nesting_level = NESTING_LEVEL; cdt.insert_constraint(v_prev, vh); v_prev = vh; last = now; } } } } else { for (auto it2 = pts.rbegin(); it2 != pts.rend(); ++it2) { CgalPoint now(it2->x, it2->y); if (now != last) { Delaunay::Vertex_handle vh = m_Delaunay.insert(now); if (vh->info().nesting_level == -1 || vh->info().nesting_level == NESTING_LEVEL) { vh->info().nesting_level = NESTING_LEVEL; cdt.insert_constraint(v_prev, vh); v_prev = vh; last = now; } } } } } }