📄 snc_decorator.h
字号:
// Copyright (c) 1997-2002 Max-Planck-Institute Saarbruecken (Germany).// All rights reserved.//// This file is part of CGAL (www.cgal.org); you may redistribute it under// the terms of the Q Public License version 1.0.// See the file LICENSE.QPL distributed with CGAL.//// Licensees holding a valid commercial license may use this file in// accordance with the commercial license agreement provided with the software.//// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE// WARRANTY OF DESISGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.//// $URL: svn+ssh://scm.gforge.inria.fr/svn/cgal/branches/CGAL-3.3-branch/Nef_3/include/CGAL/Nef_3/SNC_decorator.h $// $Id: SNC_decorator.h 39746 2007-08-07 20:10:09Z hachenb $// //// Author(s) : Michael Seel <seel@mpi-sb.mpg.de>// Miguel Granados <granados@mpi-sb.mpg.de>// Susan Hert <hert@mpi-sb.mpg.de>// Lutz Kettner <kettner@mpi-sb.mpg.de>#ifndef CGAL_SNC_DECORATOR_H#define CGAL_SNC_DECORATOR_H#include <CGAL/basic.h>#include <CGAL/Nef_S2/Normalizing.h>#include <CGAL/Unique_hash_map.h>#include <CGAL/Nef_3/SNC_iteration.h>#include <CGAL/Nef_3/SNC_const_decorator.h>#include <CGAL/Nef_S2/SM_decorator.h>#include <CGAL/Nef_S2/SM_point_locator.h>#include <CGAL/Nef_3/SNC_SM_overlayer.h>#include <CGAL/Nef_S2/SM_io_parser.h>#include <CGAL/Nef_3/SNC_constructor.h>#include <CGAL/Nef_3/SNC_external_structure.h>#include <CGAL/Nef_3/SNC_intersection.h>#include <CGAL/Nef_3/SNC_point_locator.h>#include <CGAL/Nef_3/SNC_simplify.h>#include <CGAL/Nef_3/binop_intersection_tests.h>#include <CGAL/Nef_3/SNC_decorator_traits.h>#include <CGAL/Nef_3/ID_support_handler.h>#include <CGAL/IO/Verbose_ostream.h>#ifdef CGAL_NEF3_SM_VISUALIZOR#include <CGAL/Nef_3/SNC_SM_visualizor.h>#endif // CGAL_NEF3_SM_VISUALIZOR#undef CGAL_NEF_DEBUG#define CGAL_NEF_DEBUG 19#include <CGAL/Nef_2/debug.h>CGAL_BEGIN_NAMESPACE#if defined (CGAL_NEF3_TIMER_OVERLAY) || defined(CGAL_NEF3_TIMER_INTERSECTION)CGAL::Timer timer_overlay;#endif#ifdef CGAL_NEF3_TIMER_POINT_LOCATIONint number_of_point_location_queries;int number_of_ray_shooting_queries;CGAL::Timer timer_point_location;CGAL::Timer timer_ray_shooting;#endif #ifdef CGAL_NEF3_TIMER_SPHERE_SWEEPSint number_of_edge_facet_overlays=0;int number_of_clones=0;int number_of_sphere_sweeps=0;CGAL::Timer timer_sphere_sweeps;#endif#ifdef CGAL_NEF3_TIMER_PLANE_SWEEPSint number_of_plane_sweeps=0;CGAL::Timer timer_plane_sweeps;#endif#ifdef CGAL_NEF3_DUMP_STATISTICSint number_of_intersections;int number_of_intersection_candidates;#endiftemplate <typename Map>class SNC_decorator : public SNC_const_decorator<Map> { public: typedef Map SNC_structure; typedef typename SNC_structure::Items Items; typedef typename Map::Sphere_map Sphere_map; typedef CGAL::SNC_decorator<SNC_structure> Self; typedef CGAL::SNC_const_decorator<SNC_structure> Base; typedef Base SNC_const_decorator; typedef CGAL::SNC_constructor<Items, SNC_structure> SNC_constructor; typedef CGAL::SNC_external_structure<Items, SNC_structure> SNC_external_structure; typedef CGAL::SM_decorator<Sphere_map> SM_decorator; typedef CGAL::SM_const_decorator<Sphere_map> SM_const_decorator; typedef CGAL::SNC_SM_overlayer<Items, SM_decorator> SM_overlayer; typedef CGAL::SM_point_locator<SM_decorator> SM_point_locator; typedef CGAL::SNC_intersection<SNC_structure> SNC_intersection; typedef CGAL::SNC_point_locator<SNC_decorator> SNC_point_locator; typedef CGAL::SNC_simplify<Items, SNC_structure> SNC_simplify; SNC_structure* sncp_; typedef SNC_decorator_traits<SNC_structure> Decorator_traits; typedef typename SNC_structure::Vertex_handle Vertex_handle; typedef typename SNC_structure::Halfedge_handle Halfedge_handle; typedef typename SNC_structure::Halffacet_handle Halffacet_handle; typedef typename SNC_structure::Volume_handle Volume_handle; typedef typename SNC_structure::SVertex_handle SVertex_handle; typedef typename SNC_structure::SHalfedge_handle SHalfedge_handle; typedef typename SNC_structure::SHalfloop_handle SHalfloop_handle; typedef typename SNC_structure::SFace_handle SFace_handle; typedef typename SNC_structure::Vertex_iterator Vertex_iterator; typedef typename SNC_structure::Halfedge_iterator Halfedge_iterator; typedef typename SNC_structure::Halffacet_iterator Halffacet_iterator; typedef typename SNC_structure::Volume_iterator Volume_iterator; typedef typename SNC_structure::SVertex_iterator SVertex_iterator; typedef typename SNC_structure::SHalfedge_iterator SHalfedge_iterator; typedef typename SNC_structure::SHalfloop_iterator SHalfloop_iterator; typedef typename SNC_structure::SFace_iterator SFace_iterator; typedef typename SNC_structure::SHalfedge_around_facet_circulator SHalfedge_around_facet_circulator; typedef typename SNC_structure::SFace_cycle_iterator SFace_cycle_iterator; typedef typename SNC_structure::Halffacet_cycle_iterator Halffacet_cycle_iterator; typedef typename SNC_structure::Shell_entry_iterator Shell_entry_iterator; typedef typename SNC_structure::Vertex Vertex; typedef typename SNC_structure::Halfedge Halfedge; typedef typename SNC_structure::Halffacet Halffacet; typedef typename SNC_structure::Volume Volume; typedef typename SNC_structure::SVertex SVertex; typedef typename SNC_structure::SHalfedge SHalfedge; typedef typename SNC_structure::SHalfloop SHalfloop; typedef typename SNC_structure::SFace SFace; typedef typename SNC_structure::Object_handle Object_handle; typedef typename SNC_structure::Object_iterator Object_iterator; typedef typename Base::Vertex_const_handle Vertex_const_handle; typedef typename Base::Halfedge_const_handle Halfedge_const_handle; typedef typename Base::Halffacet_const_handle Halffacet_const_handle; typedef typename Base::Volume_const_handle Volume_const_handle; typedef typename Base::SVertex_const_handle SVertex_const_handle; typedef typename Base::SHalfedge_const_handle SHalfedge_const_handle; typedef typename Base::SHalfloop_const_handle SHalfloop_const_handle; typedef typename Base::SFace_const_handle SFace_const_handle; typedef typename Base::Vertex_const_iterator Vertex_const_iterator; typedef typename Base::Halfedge_const_iterator Halfedge_const_iterator; typedef typename Base::Halffacet_const_iterator Halffacet_const_iterator; typedef typename Base::Volume_const_iterator Volume_const_iterator; typedef typename Base::SVertex_const_iterator SVertex_const_iterator; typedef typename Base::SHalfedge_const_iterator SHalfedge_const_iterator; typedef typename Base::SHalfloop_const_iterator SHalfloop_const_iterator; typedef typename Base::SFace_const_iterator SFace_const_iterator; typedef typename Base::SHalfedge_around_facet_const_circulator SHalfedge_around_facet_const_circulator; typedef typename Base::SFace_cycle_const_iterator SFace_cycle_const_iterator; typedef typename Base::Halffacet_cycle_const_iterator Halffacet_cycle_const_iterator; typedef typename Base::Shell_entry_const_iterator Shell_entry_const_iterator; typedef typename Base::Kernel Kernel; typedef typename Base::FT FT; typedef typename Base::RT RT; typedef typename Base::Point_3 Point_3; typedef typename Base::Segment_3 Segment_3; typedef typename Base::Ray_3 Ray_3; typedef typename Base::Line_3 Line_3; typedef typename Base::Plane_3 Plane_3; typedef typename Base::Vector_3 Vector_3; typedef typename Base::Sphere_kernel Sphere_kernel; typedef typename Base::Sphere_point Sphere_point; typedef typename Base::Sphere_segment Sphere_segment; typedef typename Base::Sphere_circle Sphere_circle; typedef typename Base::Sphere_direction Sphere_direction; typedef typename Base::Size_type Size_type; typedef typename Base::Mark Mark; typedef typename Base::Infi_box Infi_box; typedef typename Base::Aff_transformation_3 Aff_transformation_3; typedef typename SM_decorator::SHalfedge_around_svertex_circulator SHalfedge_around_svertex_circulator; typedef typename SM_decorator::SHalfedge_around_sface_circulator SHalfedge_around_sface_circulator; typedef CGAL::ID_support_handler<Items, SNC_decorator> Association; struct points_lt { bool operator()(Point_3& p1, Point_3& p2) const { return CGAL::lexicographically_xyz_smaller(p1,p2); } }; enum {NO_SNC, WITH_SNC}; public: typedef void* GenPtr; SNC_decorator() : Base(), sncp_() {} SNC_decorator(SNC_structure& W) : Base(W), sncp_(&W) {} SNC_decorator(const Self& S) : Base(*(S.sncp_)), sncp_(S.sncp_) {} SNC_structure* sncp() const { CGAL_assertion( sncp_ != NULL); return sncp_; } void set_snc(SNC_structure& W) { sncp_ = &W; } std::string debug(SHalfedge_handle e) const { std::stringstream os; set_pretty_mode(os); os << "sedge-use " << e->source()->source()->point() << e->twin()->source()->twin()->source()->point() <<'\0'; return os.str(); } SFace_handle adjacent_sface(Halffacet_handle f) const { Halffacet_cycle_iterator fc(f->facet_cycles_begin()); CGAL_assertion( fc != f->facet_cycles_end()); if ( fc.is_shalfedge() ) { SHalfedge_handle se(fc); CGAL_assertion( se->facet() == f); CGAL_assertion( se->incident_sface() != SFace_handle()); CGAL_assertion( se->twin()->incident_sface()->volume() == f->incident_volume()); return se->twin()->incident_sface(); } else CGAL_assertion_msg( 0, "Facet outer cycle entry point" "is not an SHalfedge? "); return SFace_handle(); // never reached } static Vector_3 to_vector(Halfedge_handle e) { // rename to to_vector return Vector_3(e->vector()-CGAL::ORIGIN); } static Segment_3 segment(Halfedge_handle e) { return Segment_3(e->source()->point(), e->twin()->source()->point()); } GenPtr& info(Vertex_handle v) const { return v->info(); } template <typename H> bool is_boundary_object(H h) const { return sncp()->is_boundary_object(h); } template <typename H> void store_boundary_object(H h, Halffacet_handle f) const { f->boundary_entry_objects().push_back(Object_handle(h)); sncp()->store_boundary_item(h, --(f->facet_cycles_end())); } template <typename H> void store_as_first_boundary_object(H h, Halffacet_handle f) const { f->boundary_entry_objects().push_front(Object_handle(h)); sncp()->store_boundary_item(h, --(f->facet_cycles_end())); } template <typename H> void undo_boundary_object(H h, Halffacet_handle f) const { CGAL_assertion(sncp()->is_boundary_object(h)); Halffacet_cycle_iterator it = sncp()->boundary_item(h); sncp()->undef_boundary_item(h); f->boundary_entry_objects().erase(it); } void link_as_facet_cycle(SHalfedge_handle e, Halffacet_handle f) const { SHalfedge_around_facet_circulator hfc(e), hend(hfc); CGAL_For_all(hfc,hend) hfc->facet() = f; store_boundary_object(e,f); } void link_as_interior_loop(SHalfloop_handle l, Halffacet_handle f) const { l->facet() = f; store_boundary_object(l,f); } template <typename H> void make_twins(H h1, H h2) const { h1->twin() = h2; h2->twin() = h1; } void link_as_prev_next_pair(SHalfedge_handle e1, SHalfedge_handle e2) const { e1->next() = e2; e2->prev() = e1; } template <typename H> void undo_boundary_object(H h, Volume_handle c) const { CGAL_assertion(sncp()->is_boundary_object(h)); Shell_entry_iterator it = sncp()->boundary_item(h); sncp()->undef_boundary_item(h); c->shell_entry_objects().erase(it); } template <typename H> void store_boundary_object(H h, Volume_handle c, bool at_front = false) const { if(at_front) { c->shell_entry_objects().push_front(Object_handle(h)); sncp()->store_boundary_item(h, c->shells_begin()); } else { c->shell_entry_objects().push_back(Object_handle(h)); sncp()->store_boundary_item(h, --(c->shells_end())); } } template<typename SNCD_> struct Shell_volume_setter { const SNCD_ D; Volume_handle c; typedef Unique_hash_map< SFace_handle, bool> SFace_map; SFace_map linked; Shell_volume_setter(const SNCD_& Di) : D(Di), linked(false) {} void visit(SFace_handle h) { CGAL_NEF_TRACEN(h->center_vertex()->point()); D.set_volume(h, c); linked[h] = true; } void visit(Vertex_handle ) { /* empty */ } void visit(Halfedge_handle ) { /* empty */ } void visit(Halffacet_handle h ) { D.set_volume(h, c); } void visit(SHalfedge_handle ) {} void visit(SHalfloop_handle ) {} void set_volume(Volume_handle ci) { c = ci; } bool is_linked(SFace_handle h) {return linked[h];} }; void link_as_outer_shell( SFace_handle f, Volume_handle c ) const { // CGAL_assertion(c->shell_entry_objects().size() == 0); Shell_volume_setter<SNC_decorator> Setter(*this); Setter.set_volume(c); visit_shell_objects( f, Setter ); CGAL_NEF_TRACEN("Volume "<<&*c<<", outer shell "<<&*f); store_boundary_object( f, c );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -