MEPP2 Project
DataStructures_cgal_point_set.h
Go to the documentation of this file.
1 // Copyright (c) 2012-2019 University of Lyon and CNRS (France).
2 // All rights reserved.
3 //
4 // This file is part of MEPP2; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published
6 // by the Free Software Foundation; either version 3 of the License,
7 // or (at your option) any later version.
8 //
9 // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
10 // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
11 #pragma once
12 
13 
14 #if defined _MSC_VER
15 #pragma warning(push)
16 #pragma warning(disable : 4244) // for VS-2015
17 #endif
18 
19 
20 #include <CGAL/version_macros.h>
21 #include <CGAL/Cartesian.h>
22 #include <CGAL/Point_set_3.h>
23 #include <CGAL/IO/Color.h>
24 
25 
26 namespace FEVV {
27 
28 
29 using CGALPointSetKernel = CGAL::Cartesian< float >;
30 using CGALPointSetPoint = CGALPointSetKernel::Point_3;
31 using CGALPointSetVector = CGALPointSetKernel::Vector_3;
32 
33 // note:
34 // - CGAL::Color in CGAL 4.14 misses operator[] that is used in MEPP2
35 // so we define our own color type derived from CGAL::Color
36 // - starting from CGAL-5.0-beta1, CGAL::Color has everything needed
37 // by MEPP2 and we must then use it directly
38 //TODO-elo-CGAL-5.0-beta1 using CGALPointSetColor = CGAL::Color;
39 class CGALPointSetColor : public CGAL::Color
40 {
41 public:
42  // must redefine default constructor because
43  // constructor(r,g,b) is re-defined
45  {}
46 
47  // must redefine constructor(r,g,b) to use
48  // base class constructor(r,g,b)
49  CGALPointSetColor(unsigned char r, unsigned char g, unsigned char b)
50  : CGAL::Color(r, g, b)
51  {}
52 
53  // color must behave as a vector
54  unsigned char operator[](int i) const
55  {
56  if(i == 0)
57  return r();
58  else if(i == 1)
59  return g();
60  else if(i == 2)
61  return b();
62  else
63  {
64  throw std::runtime_error(
65  "FEVV::CGALPointSetColor: invalid index in operator[]");
66  return 0; // dummy return to avoid a warning
67  }
68  }
69 };
70 
71 using CGALPointSet = CGAL::Point_set_3< CGALPointSetPoint >;
72 
73 
74 } // namespace FEVV
75 
76 #if defined _MSC_VER
77 #pragma warning(pop)
78 #endif
FEVV::CGALPointSetColor::operator[]
unsigned char operator[](int i) const
Definition: DataStructures_cgal_point_set.h:54
FEVV::CGALPointSet
CGAL::Point_set_3< CGALPointSetPoint > CGALPointSet
Definition: DataStructures_cgal_point_set.h:71
FEVV::CGALPointSetColor::CGALPointSetColor
CGALPointSetColor(void)
Definition: DataStructures_cgal_point_set.h:44
FEVV::CGALPointSetKernel
CGAL::Cartesian< float > CGALPointSetKernel
Definition: DataStructures_cgal_point_set.h:29
FEVV::CGALPointSetPoint
CGALPointSetKernel::Point_3 CGALPointSetPoint
Definition: DataStructures_cgal_point_set.h:30
FEVV
Interfaces for plugins These interfaces will be used for different plugins.
Definition: Assert.h:16
CGAL
Definition: Graph_properties_cgal_point_set.h:32
FEVV::Color
Definition: Color.hpp:18
FEVV::CGALPointSetColor
Definition: DataStructures_cgal_point_set.h:40
FEVV::CGALPointSetVector
CGALPointSetKernel::Vector_3 CGALPointSetVector
Definition: DataStructures_cgal_point_set.h:31
FEVV::CGALPointSetColor::CGALPointSetColor
CGALPointSetColor(unsigned char r, unsigned char g, unsigned char b)
Definition: DataStructures_cgal_point_set.h:49