File: bbox_restriction.cpp

package info (click to toggle)
cgal 6.1.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 144,952 kB
  • sloc: cpp: 811,597; ansic: 208,576; sh: 493; python: 411; makefile: 286; javascript: 174
file content (89 lines) | stat: -rw-r--r-- 2,238 bytes parent folder | download | duplicates (4)
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
// Copyright (c) 2009  INRIA Sophia-Antipolis (France).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org)
//
// $URL$
// $Id$
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
//
//
// Author(s)     : Sebastien Loriot

#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>



#include <CGAL/CGAL_Ipelet_base.h>

// --------------------------------------------------------------------


namespace CGAL_bbox_restriction{

typedef CGAL::Exact_predicates_inexact_constructions_kernel               Kernel;

const std::string sublabel[] ={
  "Bounding box restriction", "Help"
};

const std::string helpmsg[] = {
  "Restrict a set of objects to the bounding box of a set of points."
};

struct hilbertsortIpelet
  : CGAL::Ipelet_base<Kernel,2>
{
  hilbertsortIpelet()
    : CGAL::Ipelet_base<Kernel,2>("Bounding box restriction",sublabel, helpmsg) {}

  void protected_run(int);
};


void hilbertsortIpelet::protected_run(int fn)
{
  if (fn==1) {
    show_help();
    return;
  }



  std::vector<Circle_2> cir_list;
  std::vector<Circular_arc_2> arc_list;
  std::vector<Polygon_2> poly_list;
  std::vector<Segment_2> seg_list;
  std::vector<Point_2>  pt_list;

  read_active_objects(
      CGAL::dispatch_or_drop_output<Point_2,Circle_2,Polygon_2,Circular_arc_2,Segment_2>(
                       std::back_inserter(pt_list),std::back_inserter(cir_list),
                       std::back_inserter(poly_list),std::back_inserter(arc_list),
                       std::back_inserter(seg_list)
      ),true,true
  );


  if (pt_list.size()<2) {
    print_error_message("No point selected to define a bounding box");
    return;
  }

  CGAL::Bbox_2 bbox_2=pt_list.begin()->bbox();
  for (std::vector<Point_2>::iterator it=pt_list.begin();it!=pt_list.end();++it)
    bbox_2=bbox_2+it->bbox();
  Iso_rectangle_2 bbox(bbox_2.xmin(),bbox_2.ymin(),bbox_2.xmax(),bbox_2.ymax());


  draw_in_ipe(bbox);
  draw_in_ipe(cir_list.begin(),cir_list.end(),bbox,false);
  draw_in_ipe(seg_list.begin(),seg_list.end(),bbox,false);
  draw_in_ipe(arc_list.begin(),arc_list.end(),bbox,false);
  draw_in_ipe(poly_list.begin(),poly_list.end(),bbox,false);

}

}

CGAL_IPELET(CGAL_bbox_restriction::hilbertsortIpelet)