diff --git a/Arrangement_on_surface_2/archive/demo/Arr_algebraic_segment_traits_2/xalci/misc.cpp b/Arrangement_on_surface_2/archive/demo/Arr_algebraic_segment_traits_2/xalci/misc.cpp index 5641b3e6296..453a43b5e6a 100644 --- a/Arrangement_on_surface_2/archive/demo/Arr_algebraic_segment_traits_2/xalci/misc.cpp +++ b/Arrangement_on_surface_2/archive/demo/Arr_algebraic_segment_traits_2/xalci/misc.cpp @@ -479,7 +479,7 @@ void xAlci_main_window::setup(int w, int h) tab_widget->addTab(cad_tab,"cad"); tab_widget->addTab(arr_tab,"arrangement"); - *widget << CGAL::LineWidth(2) << CGAL::BackgroundColor(CGAL::WHITE); + *widget << CGAL::LineWidth(2) << CGAL::BackgroundColor(CGAL::white()); resize(w,h); double ratio = 1.0;//(double)h/w; widget->set_window(-1, 1, -ratio, ratio, true); diff --git a/Arrangement_on_surface_2/benchmark/Arrangement_on_surface_2/arr_bench.cpp b/Arrangement_on_surface_2/benchmark/Arrangement_on_surface_2/arr_bench.cpp index 86e299c27ad..903fc5a1b90 100644 --- a/Arrangement_on_surface_2/benchmark/Arrangement_on_surface_2/arr_bench.cpp +++ b/Arrangement_on_surface_2/benchmark/Arrangement_on_surface_2/arr_bench.cpp @@ -277,11 +277,11 @@ inline std::ostream & operator<<(std::ostream & os, const Arr::Vertex & vertex) inline Window_stream & operator<<(Window_stream & ws, Arr & arr) { Arr::Edge_iterator ei; - ws << CGAL::BLUE; + ws << CGAL::blue(); for (ei = arr.edges_begin(); ei != arr.edges_end(); ++ei) ws << (*ei).curve(); Arr::Vertex_iterator vi; - ws << CGAL::RED; + ws << CGAL::red(); for (vi = arr.vertices_begin(); vi != arr.vertices_end(); ++vi) ws << (*vi).point(); return ws; @@ -474,7 +474,7 @@ public: m_window->flush(); #else m_window->lock(); - *m_window << CGAL::BackgroundColor(CGAL::WHITE) << CGAL::RED; + *m_window << CGAL::BackgroundColor(CGAL::white()) << CGAL::red(); (*m_window) << arr; m_window->unlock(); App->flush(); @@ -490,9 +490,9 @@ public: ps_stream.set_line_width(1); CGAL::Arr_drawer drawer(ps_stream); // drawer.draw_faces(arr.faces_begin(), arr.faces_end()); - ps_stream << CGAL::BLUE; + ps_stream << CGAL::blue(); drawer.draw_halfedges(arr.halfedges_begin(), arr.halfedges_end()); - ps_stream << CGAL::RED; + ps_stream << CGAL::red(); drawer.draw_vertices(arr.vertices_begin(), arr.vertices_end()); // draw_arr(arr, drawer, ps_stream); diff --git a/Classification/include/CGAL/Classification.h b/Classification/include/CGAL/Classification.h index 6be192f22b8..fea4a0c044c 100644 --- a/Classification/include/CGAL/Classification.h +++ b/Classification/include/CGAL/Classification.h @@ -36,7 +36,6 @@ #endif #include -#include #include #include #include diff --git a/Classification/include/CGAL/Classification/Color.h b/Classification/include/CGAL/Classification/Color.h deleted file mode 100644 index d0e03e94b40..00000000000 --- a/Classification/include/CGAL/Classification/Color.h +++ /dev/null @@ -1,140 +0,0 @@ -// Copyright (c) 2017 GeometryFactory Sarl (France). -// All rights reserved. -// -// This file is part of CGAL (www.cgal.org). -// You can redistribute it and/or modify it under the terms of the GNU -// General Public License as published by the Free Software Foundation, -// either version 3 of the License, or (at your option) any later version. -// -// 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 DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -// -// $URL$ -// $Id$ -// SPDX-License-Identifier: GPL-3.0+ -// -// Author(s) : Simon Giraudot - -#ifndef CGAL_CLASSIFICATION_COLOR_H -#define CGAL_CLASSIFICATION_COLOR_H - -#include -#include -#include -#include - -namespace CGAL { -namespace Classification { - - /*! - \ingroup PkgClassificationColor - - %Color described in red/green/blue space. Each component is stored - as an unsigned char ranging from 0 (no color) to 255 (full color). - */ -typedef std::array RGB_Color; - /*! - \ingroup PkgClassificationColor - - %Color described in hue/saturation/value space. Each component is stored - as a float: - - - `hue` ranges from 0° to 360° (corresponding to the color tint) - - `saturation` ranges from 0.0 (gray) to 100.0 (full saturation) - - `value` ranges from 0.0 (black) to 100.0 (white) - */ -typedef std::array HSV_Color; - - - /// \cond SKIP_IN_MANUAL -inline HSV_Color rgb_to_hsv (const RGB_Color& c) -{ - double r = (double)(c[0]) / 255.; - double g = (double)(c[1]) / 255.; - double b = (double)(c[2]) / 255.; - double Cmax = (std::max) (r, (std::max) (g, b)); - double Cmin = (std::min) (r, (std::min) (g, b)); - double delta = Cmax - Cmin; - double H = 0.; - - if (delta != 0.) - { - if (Cmax == r) - H = 60. * ((g - b) / delta); - else if (Cmax == g) - H = 60. * (((b - r) / delta) + 2.); - else - H = 60. * (((r - g) / delta) + 4.); - } - if (H < 0.) H += 360.; - double S = (Cmax == 0. ? 0. : 100. * (delta / Cmax)); - double V = 100. * Cmax; - HSV_Color out = {{ float(H), float(S), float(V) }}; - return out; -} - -inline RGB_Color hsv_to_rgb (const HSV_Color& c) -{ - double h = c[0]; - double s = c[1]; - double v = c[2]; - - s /= 100.; - v /= 100.; - double C = v*s; - int hh = (int)(h/60.); - double X = C * (1-CGAL::abs (hh % 2 - 1)); - double r = 0, g = 0, b = 0; - - if( hh>=0 && hh<1 ) - { - r = C; - g = X; - } - else if( hh>=1 && hh<2 ) - { - r = X; - g = C; - } - else if( hh>=2 && hh<3 ) - { - g = C; - b = X; - } - else if( hh>=3 && hh<4 ) - { - g = X; - b = C; - } - else if( hh>=4 && hh<5 ) - { - r = X; - b = C; - } - else - { - r = C; - b = X; - } - double m = v-C; - r += m; - g += m; - b += m; - r *= 255.0; - g *= 255.0; - b *= 255.0; - - RGB_Color out = {{ (unsigned char)r, (unsigned char)g, (unsigned char)b }}; - return out; -} - /// \endcond - -} // namespace Classification -} // namespace CGAL - - - -#endif // CGAL_CLASSIFICATION_COLOR_H diff --git a/Classification/include/CGAL/Classification/Feature/Color_channel.h b/Classification/include/CGAL/Classification/Feature/Color_channel.h index 73ff155f5b8..6c5778548c2 100644 --- a/Classification/include/CGAL/Classification/Feature/Color_channel.h +++ b/Classification/include/CGAL/Classification/Feature/Color_channel.h @@ -25,8 +25,8 @@ #include -#include #include +#include namespace CGAL { @@ -65,7 +65,7 @@ namespace Feature { `ColorMap`. \tparam ColorMap model of `ReadablePropertyMap` whose key type is the value type of the iterator of `PointRange` and value type - is `CGAL::Classification::RGB_Color`. + is `CGAL::Color`. */ template class Color_channel : public Feature_base @@ -82,9 +82,6 @@ public: private: - typedef typename Classification::RGB_Color RGB_Color; - typedef typename Classification::HSV_Color HSV_Color; - const PointRange& input; ColorMap color_map; Channel m_channel; @@ -111,8 +108,8 @@ public: /// \cond SKIP_IN_MANUAL virtual float value (std::size_t pt_index) { - HSV_Color c = Classification::rgb_to_hsv (get(color_map, *(input.begin()+pt_index))); - return c[std::size_t(m_channel)]; + cpp11::array c = get(color_map, *(input.begin()+pt_index)).to_hsv(); + return float(c[std::size_t(m_channel)]); } /// \endcond }; diff --git a/Classification/include/CGAL/Classification/Feature/Eigen.h b/Classification/include/CGAL/Classification/Feature/Eigen.h deleted file mode 100644 index 793e3433449..00000000000 --- a/Classification/include/CGAL/Classification/Feature/Eigen.h +++ /dev/null @@ -1,431 +0,0 @@ -// Copyright (c) 2017 GeometryFactory Sarl (France). -// All rights reserved. -// -// This file is part of CGAL (www.cgal.org). -// You can redistribute it and/or modify it under the terms of the GNU -// General Public License as published by the Free Software Foundation, -// either version 3 of the License, or (at your option) any later version. -// -// 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 DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -// -// $URL$ -// $Id$ -// SPDX-License-Identifier: GPL-3.0+ -// -// Author(s) : Simon Giraudot - -#ifndef CGAL_CLASSIFICATION_FEATURES_EIGEN_H -#define CGAL_CLASSIFICATION_FEATURES_EIGEN_H - -#include - -#include -#include -#include - -/// \cond SKIP_IN_MANUAL -#ifndef CGAL_NO_DEPRECATED_CODE - -namespace CGAL { - -namespace Classification { - -namespace Feature { - -class Eigen_feature : public Feature_base -{ -protected: -#ifdef CGAL_CLASSIFICATION_PRECOMPUTE_FEATURES - std::vector attrib; -#else - const Classification::Local_eigen_analysis& eigen; -#endif - -public: - template - Eigen_feature (const InputRange&, - const Classification::Local_eigen_analysis& eigen) -#ifndef CGAL_CLASSIFICATION_PRECOMPUTE_FEATURES - : eigen (eigen) -#endif - { - } - -#ifdef CGAL_CLASSIFICATION_PRECOMPUTE_FEATURES - virtual void init (std::size_t size, const Classification::Local_eigen_analysis& eigen) - { - attrib.reserve (size); - for (std::size_t i = 0; i < size; ++ i) - attrib.push_back (get_value (eigen, i)); - } -#else - virtual void init (std::size_t, const Classification::Local_eigen_analysis&) - { - } -#endif - - virtual float get_value (const Classification::Local_eigen_analysis& eigen, std::size_t i) = 0; - virtual float value (std::size_t pt_index) - { -#ifdef CGAL_CLASSIFICATION_PRECOMPUTE_FEATURES - return attrib[pt_index]; -#else - return get_value(eigen, pt_index); -#endif - } - -}; - - /*! - \ingroup PkgClassificationFeatures - - %Feature based on the eigenvalues of the covariance matrix of a - local neighborhood. Linearity is defined, for the 3 eigenvalues - \f$\lambda_1 \ge \lambda_2 \ge \lambda_3 \ge 0\f$, as: - - \f[ - \frac{\lambda_1 - \lambda_2}{\lambda_1} - \f] - - Its default name is "linearity". - */ -CGAL_DEPRECATED_MSG("you are using the deprecated feature Linearity, please update your code with Eigenvalue instead") -class Linearity -#ifdef DOXYGEN_RUNNING - : public Feature_base -#else - : public Eigen_feature -#endif -{ -public: - /*! - Constructs the feature. - - \tparam Input model of `ConstRange`. Its iterator type - is `RandomAccessIterator`. - \param input point range. - \param eigen class with precomputed eigenvectors and eigenvalues. - */ - template - Linearity (const InputRange& input, - const Local_eigen_analysis& eigen) : Eigen_feature (input, eigen) - { - this->set_name("linearity"); - this->init(input.size(), eigen); - } - - virtual float get_value (const Local_eigen_analysis& eigen, std::size_t i) - { - const Local_eigen_analysis::Eigenvalues& ev = eigen.eigenvalue(i); - if (ev[2] < 1e-15) - return 0.; - else - return ((ev[2] - ev[1]) / ev[2]); - } -}; - - /*! - \ingroup PkgClassificationFeatures - - %Feature based on the eigenvalues of the covariance matrix of a - local neighborhood. Planarity is defined, for the 3 eigenvalues - \f$\lambda_1 \ge \lambda_2 \ge \lambda_3 \ge 0\f$, as: - - \f[ - \frac{\lambda_2 - \lambda_3}{\lambda_1} - \f] - - Its default name is "planarity". - */ -CGAL_DEPRECATED_MSG("you are using the deprecated feature Planarity, please update your code with Eigenvalue instead") -class Planarity -#ifdef DOXYGEN_RUNNING - : public Feature_base -#else - : public Eigen_feature -#endif -{ -public: - /*! - Constructs the feature. - - \param input point range. - \param eigen class with precomputed eigenvectors and eigenvalues. - */ - template - Planarity (const InputRange& input, - const Local_eigen_analysis& eigen) - : Eigen_feature(input, eigen) - { - this->set_name("planarity"); - this->init(input.size(), eigen); - } - - virtual float get_value (const Local_eigen_analysis& eigen, std::size_t i) - { - const Local_eigen_analysis::Eigenvalues& ev = eigen.eigenvalue(i); - if (ev[2] < 1e-15) - return 0.; - else - return ((ev[1] - ev[0]) / ev[2]); - } - -}; - - /*! - \ingroup PkgClassificationFeatures - - %Feature based on the eigenvalues of the covariance matrix of a - local neighborhood. Sphericity is defined, for the 3 eigenvalues - \f$\lambda_1 \ge \lambda_2 \ge \lambda_3 \ge 0\f$, as: - - \f[ - \frac{\lambda_3}{\lambda_1} - \f] - - Its default name is "sphericity". - */ -CGAL_DEPRECATED_MSG("you are using the deprecated feature Sphericity, please update your code with Eigenvalue instead") -class Sphericity -#ifdef DOXYGEN_RUNNING - : public Feature_base -#else - : public Eigen_feature -#endif -{ -public: - /*! - Constructs the feature. - - \param input point range. - \param eigen class with precomputed eigenvectors and eigenvalues. - */ - template - Sphericity (const InputRange& input, - const Local_eigen_analysis& eigen) - : Eigen_feature(input, eigen) - { - this->set_name("sphericity"); - this->init(input.size(), eigen); - } - - virtual float get_value (const Local_eigen_analysis& eigen, std::size_t i) - { - const Local_eigen_analysis::Eigenvalues& ev = eigen.eigenvalue(i); - if (ev[2] < 1e-15) - return 0.; - else - return (ev[0] / ev[2]); - } - -}; - - /*! - \ingroup PkgClassificationFeatures - - %Feature based on the eigenvalues of the covariance matrix of a - local neighborhood. Omnivariance is defined, for the 3 eigenvalues - \f$\lambda_1 \ge \lambda_2 \ge \lambda_3 \ge 0\f$, as: - - \f[ - (\lambda_1 \times \lambda_2 \times \lambda_3)^{\frac{1}{3}} - \f] - - Its default name is "omnivariance". - */ -CGAL_DEPRECATED_MSG("you are using the deprecated feature Omnivariance, please update your code with Eigenvalue instead") -class Omnivariance -#ifdef DOXYGEN_RUNNING - : public Feature_base -#else - : public Eigen_feature -#endif -{ -public: - /*! - Constructs the feature. - - \param input point range. - \param eigen class with precomputed eigenvectors and eigenvalues. - */ - template - Omnivariance (const InputRange& input, - const Local_eigen_analysis& eigen) - : Eigen_feature(input, eigen) - { - this->set_name("omnivariance"); - this->init(input.size(), eigen); - } - - virtual float get_value (const Local_eigen_analysis& eigen, std::size_t i) - { - const Local_eigen_analysis::Eigenvalues& ev = eigen.eigenvalue(i); - return (std::pow (CGAL::abs(ev[0] * ev[1] * ev[2]), 0.333333333f)); - } - -}; - - /*! - \ingroup PkgClassificationFeatures - - %Feature based on the eigenvalues of the covariance matrix of a - local neighborhood. Anisotropy is defined, for the 3 eigenvalues - \f$\lambda_1 \ge \lambda_2 \ge \lambda_3 \ge 0\f$, as: - - \f[ - \frac{\lambda_1 - \lambda_3}{\lambda_1} - \f] - - Its default name is "anisotropy". - */ -CGAL_DEPRECATED_MSG("you are using the deprecated feature Anisotropy, please update your code with Eigenvalue instead") -class Anisotropy -#ifdef DOXYGEN_RUNNING - : public Feature_base -#else - : public Eigen_feature -#endif -{ -public: - /*! - Constructs the feature. - - \param input point range. - \param eigen class with precomputed eigenvectors and eigenvalues. - */ - template - Anisotropy (const InputRange& input, - const Local_eigen_analysis& eigen) - : Eigen_feature(input, eigen) - { - this->set_name("anisotropy"); - this->init(input.size(), eigen); - } - - virtual float get_value (const Local_eigen_analysis& eigen, std::size_t i) - { - const Local_eigen_analysis::Eigenvalues& ev = eigen.eigenvalue(i); - if (ev[2] < 1e-15) - return 0.; - else - return ((ev[2] - ev[0]) / ev[2]); - } - -}; - - /*! - \ingroup PkgClassificationFeatures - - %Feature based on the eigenvalues of the covariance matrix of a - local neighborhood. Eigentropy is defined, for the 3 eigenvalues - \f$\lambda_1 \ge \lambda_2 \ge \lambda_3 \ge 0\f$, as: - - \f[ - - \sum_{i=1}^3 \lambda_i \times \log{\lambda_i} - \f] - - Its default name is "eigentropy". - */ -CGAL_DEPRECATED_MSG("you are using the deprecated feature Eigentropy, please update your code with Eigenvalue instead") -class Eigentropy -#ifdef DOXYGEN_RUNNING - : public Feature_base -#else - : public Eigen_feature -#endif -{ -public: - /*! - Constructs the feature. - - \param input point range. - \param eigen class with precomputed eigenvectors and eigenvalues. - */ - template - Eigentropy (const InputRange& input, - const Local_eigen_analysis& eigen) - : Eigen_feature(input, eigen) - { - this->set_name("eigentropy"); - this->init(input.size(), eigen); - } - - virtual float get_value (const Local_eigen_analysis& eigen, std::size_t i) - { - const Local_eigen_analysis::Eigenvalues& ev = eigen.eigenvalue(i); - if (ev[0] < 1e-15 - || ev[1] < 1e-15 - || ev[2] < 1e-15) - return 0.; - else - return (- ev[0] * std::log(ev[0]) - - ev[1] * std::log(ev[1]) - - ev[2] * std::log(ev[2])); - } - -}; - - - /*! - \ingroup PkgClassificationFeatures - - %Feature based on the eigenvalues of the covariance - matrix of a local neighborhood. Surface variation is defined, for - the 3 eigenvalues \f$\lambda_1 \ge \lambda_2 \ge \lambda_3 \ge - 0\f$, as: - - \f[ - \frac{\lambda_3}{\lambda_1 + \lambda_2 + \lambda_3} - \f] - - Its default name is "surface_variation". - */ -CGAL_DEPRECATED_MSG("you are using the deprecated feature Surface_variation, please update your code with Eigenvalue instead") -class Surface_variation -#ifdef DOXYGEN_RUNNING - : public Feature_base -#else - : public Eigen_feature -#endif -{ -public: - /*! - Constructs the feature. - - \param input point range. - \param eigen class with precomputed eigenvectors and eigenvalues. - */ - template - Surface_variation (const InputRange& input, - const Local_eigen_analysis& eigen) - : Eigen_feature(input, eigen) - { - this->set_name("surface_variation"); - this->init(input.size(), eigen); - } - - virtual float get_value (const Local_eigen_analysis& eigen, std::size_t i) - { - const Local_eigen_analysis::Eigenvalues& ev = eigen.eigenvalue(i); - if (ev[0] + ev[1] + ev[2] < 1e-15) - return 0.; - else - return (ev[0] / (ev[0] + ev[1] + ev[2])); - } - -}; - -} // namespace Feature - -} // namespace Classification - -} // namespace CGAL - -#endif -/// \endcond - -#endif // CGAL_CLASSIFICATION_FEATURES_EIGEN_H diff --git a/Classification/include/CGAL/Classification/Feature/Hsv.h b/Classification/include/CGAL/Classification/Feature/Hsv.h deleted file mode 100644 index 536d6aaa5b0..00000000000 --- a/Classification/include/CGAL/Classification/Feature/Hsv.h +++ /dev/null @@ -1,175 +0,0 @@ -// Copyright (c) 2017 GeometryFactory Sarl (France). -// All rights reserved. -// -// This file is part of CGAL (www.cgal.org). -// You can redistribute it and/or modify it under the terms of the GNU -// General Public License as published by the Free Software Foundation, -// either version 3 of the License, or (at your option) any later version. -// -// 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 DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -// -// $URL$ -// $Id$ -// SPDX-License-Identifier: GPL-3.0+ -// -// Author(s) : Simon Giraudot - -#ifndef CGAL_CLASSIFICATION_FEATURE_HSV_H -#define CGAL_CLASSIFICATION_FEATURE_HSV_H - -#include - -#include - -#include -#include - -/// \cond SKIP_IN_MANUAL -#ifndef CGAL_NO_DEPRECATED_CODE - -namespace CGAL { - -namespace Classification { - -namespace Feature { - - /*! - \ingroup PkgClassificationFeatures - - %Feature based on HSV colorimetric information. If the input - point cloud has colorimetric information, it can be used for - classification purposes. This feature is based on a Gaussian - probabilistic model on one of the three HSV channels (hue, - saturation or value). It computes the probability of the color of - the input point to match this specific color channel defined by a - mean and a standard deviation. - - The HSV channels are defined this way: - - - Hue ranges from 0 to 360 and measures the general "tint" of the - color (green, blue, pink, etc.) - - - Saturation ranges from 0 to 100 and measures the "strength" of the - color (0 is gray and 100 is the fully saturated color) - - - Value ranges from 0 to 100 and measures the "brightness" of the - color (0 is black and 100 is the fully bright color) - - For example, such an feature using the channel 0 (hue) with a - mean of 90 (which corresponds to a green hue) can help to identify - trees. - - \image html trees.png - -
Left: input point set with colors. Right: HSV feature on hue with - a mean of 90 (from low values in white to high values in dark - red).
- - Its default name is the channel followed by the mean value (for - example: "hue_180", "saturation_20" or "value_98"). - - \note The user only needs to provide a map to standard (and more common) - RGB colors, the conversion to HSV is done internally. - - \tparam GeomTraits model of \cgal Kernel. - \tparam PointRange model of `ConstRange`. Its iterator type - is `RandomAccessIterator` and its value type is the key type of - `ColorMap`. - \tparam ColorMap model of `ReadablePropertyMap` whose key - type is the value type of the iterator of `PointRange` and value type - is `CGAL::Classification::RGB_Color`. - */ -template -CGAL_DEPRECATED_MSG("you are using the deprecated feature Hsv, please update your code with Color_channel instead") -class Hsv : public Feature_base -{ -public: - - /// Selected channel. - enum Channel - { - HUE = 0, ///< 0 - SATURATION = 1, ///< 1 - VALUE = 2 ///< 2 - }; - -private: - - typedef typename Classification::RGB_Color RGB_Color; - typedef typename Classification::HSV_Color HSV_Color; - -#ifdef CGAL_CLASSIFICATION_PRECOMPUTE_FEATURES - std::vector color_feature; -#else - const PointRange& input; - ColorMap color_map; - Channel m_channel; - float m_mean; - float m_sd; -#endif - -public: - - /*! - - \brief Constructs a feature based on the given color channel, - mean and standard deviation. - - \param input point range. - \param color_map property map to access the colors of the input points. - \param channel chosen HSV channel. - \param mean mean value of the specified channel. - \param sd standard deviation of the specified channel. - */ - Hsv (const PointRange& input, - ColorMap color_map, - Channel channel, - float mean, float sd) -#ifndef CGAL_CLASSIFICATION_PRECOMPUTE_FEATURES - : input(input), color_map(color_map), m_channel(channel), m_mean(mean), m_sd(sd) -#endif - { - -#ifdef CGAL_CLASSIFICATION_PRECOMPUTE_FEATURES - for(std::size_t i = 0; i < input.size();i++) - { - HSV_Color c = Classification::rgb_to_hsv (get(color_map, *(input.begin()+i))); - color_feature.push_back (std::exp (-(c[std::size_t(channel)] - mean) - * (c[std::size_t(channel)] - mean) / (2. * sd * sd))); - } -#endif - std::ostringstream oss; - if (channel == HUE) oss << "hue"; - else if (channel == SATURATION) oss << "saturation"; - else if (channel == VALUE) oss << "value"; - oss << "_" << mean; - this->set_name (oss.str()); - } - - virtual float value (std::size_t pt_index) - { -#ifdef CGAL_CLASSIFICATION_PRECOMPUTE_FEATURES - return color_feature[pt_index]; -#else - HSV_Color c = Classification::rgb_to_hsv (get(color_map, *(input.begin()+pt_index))); - return std::exp (-(c[std::size_t(m_channel)] - m_mean) - * (c[std::size_t(m_channel)] - m_mean) / (2.f * m_sd * m_sd)); -#endif - } - -}; - -} // namespace Feature - -} // namespace Classification - -} // namespace CGAL - -#endif -/// \endcond - -#endif // CGAL_CLASSIFICATION_FEATURE_HSV_H diff --git a/Classification/include/CGAL/Classification/Mesh_feature_generator.h b/Classification/include/CGAL/Classification/Mesh_feature_generator.h index 94962088df2..6212b4d0aff 100644 --- a/Classification/include/CGAL/Classification/Mesh_feature_generator.h +++ b/Classification/include/CGAL/Classification/Mesh_feature_generator.h @@ -152,8 +152,6 @@ public: typedef Classification::Feature::Verticality Verticality; typedef Classification::Feature::Eigenvalue Eigenvalue; - - typedef typename Classification::RGB_Color RGB_Color; /// \endcond private: diff --git a/Classification/include/CGAL/Classification/Point_set_feature_generator.h b/Classification/include/CGAL/Classification/Point_set_feature_generator.h index 78a09e8b0a1..478de14227e 100644 --- a/Classification/include/CGAL/Classification/Point_set_feature_generator.h +++ b/Classification/include/CGAL/Classification/Point_set_feature_generator.h @@ -153,8 +153,6 @@ public: typedef Classification::Feature::Gradient_of_feature Gradient_of_feature; #endif - - typedef typename Classification::RGB_Color RGB_Color; /// \endcond private: @@ -294,64 +292,6 @@ public: /// @} /// \cond SKIP_IN_MANUAL - -#ifndef CGAL_NO_DEPRECATED_CODE - // deprecated - template - CGAL_DEPRECATED_MSG("you are using a deprecated constructor of CGAL::Classification::Point_set_feature_generator, please update your code") - Point_set_feature_generator(Feature_set& features, - const PointRange& input, - PointMap point_map, - std::size_t nb_scales, - VectorMap normal_map = VectorMap(), - ColorMap color_map = ColorMap(), - EchoMap echo_map = EchoMap(), - float voxel_size = -1.f) - : m_input (input), m_point_map (point_map) - { - m_bbox = CGAL::bounding_box - (boost::make_transform_iterator (m_input.begin(), CGAL::Property_map_to_unary_function(m_point_map)), - boost::make_transform_iterator (m_input.end(), CGAL::Property_map_to_unary_function(m_point_map))); - - CGAL::Real_timer t; t.start(); - - m_scales.reserve (nb_scales); - - m_scales.push_back (new Scale (m_input, m_point_map, m_bbox, voxel_size)); - - if (voxel_size == -1.f) - voxel_size = m_scales[0]->grid_resolution(); - - for (std::size_t i = 1; i < nb_scales; ++ i) - { - voxel_size *= 2; - m_scales.push_back (new Scale (m_input, m_point_map, m_bbox, voxel_size, m_scales[i-1]->grid)); - } - t.stop(); - CGAL_CLASSIFICATION_CERR << "Scales computed in " << t.time() << " second(s)" << std::endl; - t.reset(); - - typedef typename Default::Get::type - Vmap; - typedef typename Default::Get::type - Cmap; - typedef typename Default::Get::type - Emap; - - generate_point_based_features (features); - generate_normal_based_features (features, get_parameter(normal_map)); - generate_color_based_features (features, get_parameter(color_map)); - generate_echo_based_features (features, get_parameter(echo_map)); - } - - // Functions to remove when deprecated constructor is removed - void generate_normal_based_features(const CGAL::Constant_property_map&) { } - void generate_color_based_features(const CGAL::Constant_property_map&) { } - void generate_echo_based_features(const CGAL::Constant_property_map&) { } -#endif - virtual ~Point_set_feature_generator() { clear(); @@ -434,7 +374,7 @@ public: \tparam ColorMap model of `ReadablePropertyMap` whose key type is the value type of the iterator of `PointRange` and value type is - `CGAL::Classification::RGB_Color`. + `CGAL::Color`. \param features the feature set where the features are instantiated. \param color_map property map to access the colors of the input points (if any). diff --git a/Classification/test/Classification/CMakeLists.txt b/Classification/test/Classification/CMakeLists.txt index fd5d89785b2..f6967a11db1 100644 --- a/Classification/test/Classification/CMakeLists.txt +++ b/Classification/test/Classification/CMakeLists.txt @@ -89,14 +89,6 @@ if(TARGET test_classification_point_set) endif() endif() -create_single_source_cgal_program( "deprecated_test_classification_point_set.cpp" CXX_FEATURES ${needed_cxx_features} ) -if(TARGET deprecated_test_classification_point_set) - target_link_libraries(deprecated_test_classification_point_set PUBLIC ${classification_linked_libraries}) - if (TBB_FOUND) - CGAL_target_use_TBB( deprecated_test_classification_point_set ) - endif() -endif() - create_single_source_cgal_program( "test_classification_io.cpp" CXX_FEATURES ${needed_cxx_features} ) if(TARGET test_classification_io) target_link_libraries(test_classification_io PUBLIC ${classification_linked_libraries}) diff --git a/Classification/test/Classification/deprecated_test_classification_point_set.cpp b/Classification/test/Classification/deprecated_test_classification_point_set.cpp deleted file mode 100644 index 46dc85b46a5..00000000000 --- a/Classification/test/Classification/deprecated_test_classification_point_set.cpp +++ /dev/null @@ -1,136 +0,0 @@ -#include - -#if defined (_MSC_VER) && !defined (_WIN64) -#pragma warning(disable:4244) // boost::number_distance::distance() - // converts 64 to 32 bits integers -#endif - -#include -#include -#include -#include - -#include -#include -#include -#include - -typedef CGAL::Simple_cartesian Kernel; -typedef Kernel::Point_3 Point; -typedef Kernel::Vector_3 Vector; - -typedef CGAL::Point_set_3 Point_set; -typedef Point_set::Point_map Point_map; - -typedef Kernel::Iso_cuboid_3 Iso_cuboid_3; - -namespace Classification = CGAL::Classification; - -typedef Classification::Label_handle Label_handle; -typedef Classification::Feature_handle Feature_handle; -typedef Classification::Label_set Label_set; -typedef Classification::Feature_set Feature_set; - -typedef Classification::Sum_of_weighted_features_classifier Classifier; - -typedef Classification::Point_set_feature_generator Feature_generator; - -typedef Point_set::Property_map Size_t_map; -typedef Point_set::Property_map Color_map; - - - -int main (int, char**) -{ - Point_set pts; - - pts.add_normal_map(); - - bool map_added = false; - Size_t_map echo_map; - Color_map color_map; - - boost::tie (echo_map, map_added) = pts.add_property_map ("echo"); - assert (map_added); - boost::tie (color_map, map_added) = pts.add_property_map ("color"); - assert (map_added); - - for (std::size_t i = 0; i < 1000; ++ i) - { - Point_set::iterator it - = pts.insert (Point (CGAL::get_default_random().get_double(), - CGAL::get_default_random().get_double(), - CGAL::get_default_random().get_double()), - Vector (CGAL::get_default_random().get_double(), - CGAL::get_default_random().get_double(), - CGAL::get_default_random().get_double())); - echo_map[*it] = std::size_t(CGAL::get_default_random().get_int(0, 4)); - color_map[*it] = CGAL::make_array ((unsigned char)(CGAL::get_default_random().get_int(0, 255)), - (unsigned char)(CGAL::get_default_random().get_int(0, 255)), - (unsigned char)(CGAL::get_default_random().get_int(0, 255))); - } - - Feature_set features; - Feature_generator generator (features, pts, pts.point_map(), - 5, // using 5 scales - pts.normal_map(), - color_map, echo_map); - - assert (generator.number_of_scales() == 5); - assert (features.size() == 59); - - Label_set labels; - - std::vector training_set (pts.size(), -1); - for (std::size_t i = 0; i < 20; ++ i) - { - std::ostringstream oss; - oss << "label_" << i; - Label_handle lh = labels.add(oss.str().c_str()); - - for (std::size_t j = 0; j < 10; ++ j) - training_set[std::size_t(CGAL::get_default_random().get_int(0, int(training_set.size())))] = int(i); - } - assert (labels.size() == 20); - - Classifier classifier (labels, features); - - classifier.train (training_set, 800); -#ifdef CGAL_LINKED_WITH_TBB - classifier.train (training_set, 800); -#endif - - std::vector label_indices(pts.size(), -1); - - Classification::classify - (pts, labels, classifier, label_indices); - - Classification::classify_with_local_smoothing - (pts, pts.point_map(), labels, classifier, - generator.neighborhood().sphere_neighbor_query(0.01f), - label_indices); - - Classification::classify_with_graphcut - (pts, pts.point_map(), labels, classifier, - generator.neighborhood().k_neighbor_query(12), - 0.2f, 10, label_indices); - -#ifdef CGAL_LINKED_WITH_TBB - Classification::classify - (pts, labels, classifier, label_indices); - - Classification::classify_with_local_smoothing - (pts, pts.point_map(), labels, classifier, - generator.neighborhood().sphere_neighbor_query(0.01f), - label_indices); - - Classification::classify_with_graphcut - (pts, pts.point_map(), labels, classifier, - generator.neighborhood().k_neighbor_query(12), - 0.2f, 10, label_indices); -#endif - - Classification::Evaluation evaluation (labels, training_set, label_indices); - - return EXIT_SUCCESS; -} diff --git a/Classification/test/Classification/test_classification_point_set.cpp b/Classification/test/Classification/test_classification_point_set.cpp index 4636e07913b..3890533b608 100644 --- a/Classification/test/Classification/test_classification_point_set.cpp +++ b/Classification/test/Classification/test_classification_point_set.cpp @@ -37,7 +37,7 @@ typedef Classification::Point_set_feature_generator Size_t_map; -typedef Point_set::Property_map Color_map; +typedef Point_set::Property_map Color_map; @@ -55,7 +55,7 @@ int main (int, char**) normal_map = pts.normal_map(); boost::tie (echo_map, map_added) = pts.add_property_map ("echo"); assert (map_added); - boost::tie (color_map, map_added) = pts.add_property_map ("color"); + boost::tie (color_map, map_added) = pts.add_property_map ("color"); assert (map_added); for (std::size_t i = 0; i < 1000; ++ i) @@ -68,9 +68,9 @@ int main (int, char**) CGAL::get_default_random().get_double(), CGAL::get_default_random().get_double())); echo_map[*it] = std::size_t(CGAL::get_default_random().get_int(0, 4)); - color_map[*it] = CGAL::make_array ((unsigned char)(CGAL::get_default_random().get_int(0, 255)), - (unsigned char)(CGAL::get_default_random().get_int(0, 255)), - (unsigned char)(CGAL::get_default_random().get_int(0, 255))); + color_map[*it] = CGAL::Color ((unsigned char)(CGAL::get_default_random().get_int(0, 255)), + (unsigned char)(CGAL::get_default_random().get_int(0, 255)), + (unsigned char)(CGAL::get_default_random().get_int(0, 255))); } Feature_set features; diff --git a/Convex_hull_3/demo/Convex_hull_3/quickhull_3_demo.cpp b/Convex_hull_3/demo/Convex_hull_3/quickhull_3_demo.cpp index dbea2a29a87..629c594da5a 100644 --- a/Convex_hull_3/demo/Convex_hull_3/quickhull_3_demo.cpp +++ b/Convex_hull_3/demo/Convex_hull_3/quickhull_3_demo.cpp @@ -67,7 +67,7 @@ void draw_points_and_hull(const std::vector& points, std::vector::const_iterator p_it; CGAL::Geomview_stream geomview; - geomview << CGAL::RED; + geomview << CGAL::red(); for (p_it = points.begin(); p_it != points.end(); p_it++) { geomview << *p_it; @@ -78,7 +78,7 @@ void draw_points_and_hull(const std::vector& points, Point_3 point; Polyhedron_3 polyhedron; - geomview << CGAL::BLUE; + geomview << CGAL::blue(); if ( CGAL::assign(point, object) ) geomview << point; else if ( CGAL::assign(segment, object) ) diff --git a/Geomview/demo/Geomview/gv_terrain.cpp b/Geomview/demo/Geomview/gv_terrain.cpp index 27ce828d30c..bed8f15171a 100644 --- a/Geomview/demo/Geomview/gv_terrain.cpp +++ b/Geomview/demo/Geomview/gv_terrain.cpp @@ -57,13 +57,13 @@ int main() // use different colors, and put a few sleeps/clear. - gv << CGAL::BLUE; + gv << CGAL::blue(); std::cout << "Drawing 2D Delaunay triangulation in wired mode.\n"; gv.set_wired(true); gv << D; #if 1 // It's too slow ! Needs to use OFF for that. - gv << CGAL::RED; + gv << CGAL::red(); std::cout << "Drawing its Voronoi diagram.\n"; gv.set_wired(true); D.draw_dual(gv); diff --git a/Geomview/demo/Geomview/kernel.cpp b/Geomview/demo/Geomview/kernel.cpp index e496e59a311..0fe909a05fc 100644 --- a/Geomview/demo/Geomview/kernel.cpp +++ b/Geomview/demo/Geomview/kernel.cpp @@ -50,25 +50,25 @@ int main() gv.clear(); // remove the pickplane. gv << K::Point_2 (200, 100); - gv << CGAL::BLUE; + gv << CGAL::blue(); gv << K::Point_3 (200, 100, 100); - gv << CGAL::RED; + gv << CGAL::red(); gv << K::Segment_2 (K::Point_2(200, 100), K::Point_2(300, 100)); - gv << CGAL::GREEN; + gv << CGAL::green(); gv << K::Segment_3 (K::Point_3(200, 100, 100), K::Point_3(300, 100, 200)); - gv << CGAL::DEEPBLUE; + gv << CGAL::deep_blue(); gv << K::Sphere_3 (K::Point_3(100, 100, 100), 1000); - gv << CGAL::VIOLET; + gv << CGAL::violet(); gv << K::Triangle_2 (K::Point_2(200, 200), K::Point_2(220, 220), K::Point_2(180, 220)); - gv << CGAL::ORANGE; + gv << CGAL::orange(); gv << K::Triangle_3 (K::Point_3(200, 200, 50), K::Point_3(220, 220, 80), K::Point_3(180, 220, 100)); - gv << CGAL::PURPLE; + gv << CGAL::purple(); gv << K::Tetrahedron_3 (K::Point_3(100, 100, 180), K::Point_3(120, 70, 220), K::Point_3(100, 100, 220), @@ -76,7 +76,7 @@ int main() gv << CGAL::Bbox_2(10, 10, 30, 30); gv << CGAL::Bbox_3(10, 10, 10, 30, 30, 30); - gv << CGAL::RED; + gv << CGAL::red(); gv << K::Ray_2(K::Point_2(205,205), K::Point_2(500,500)); gv << K::Ray_3(K::Point_3(250,250,250), K::Point_3(500,500,500)); gv << K::Line_2(K::Point_2(195,195), K::Point_2(500,500)); diff --git a/Geomview/include/CGAL/IO/Geomview_stream_impl.h b/Geomview/include/CGAL/IO/Geomview_stream_impl.h index b322c32652e..2f69d81cb44 100644 --- a/Geomview/include/CGAL/IO/Geomview_stream_impl.h +++ b/Geomview/include/CGAL/IO/Geomview_stream_impl.h @@ -49,7 +49,7 @@ CGAL_INLINE_FUNCTION Geomview_stream::Geomview_stream(const Bbox_3 &bbox, const char *machine, const char *login) - : bb(bbox), vertex_color(BLACK), edge_color(BLACK), face_color(BLACK), + : bb(bbox), vertex_color(black()), edge_color(black()), face_color(black()), wired_flag(false), echo_flag(true), raw_flag(false), trace_flag(false), binary_flag(false), line_width(1) diff --git a/GraphicsView/include/CGAL/Qt/SegmentDelaunayGraphGraphicsItem.h b/GraphicsView/include/CGAL/Qt/SegmentDelaunayGraphGraphicsItem.h index d9fb9e6b5e0..71a52459805 100644 --- a/GraphicsView/include/CGAL/Qt/SegmentDelaunayGraphGraphicsItem.h +++ b/GraphicsView/include/CGAL/Qt/SegmentDelaunayGraphGraphicsItem.h @@ -173,9 +173,9 @@ SegmentDelaunayGraphGraphicsItem::drawAll(QPainter *painter, const QStyleOpti vit != t->finite_vertices_end(); ++vit) { typename T::Site_2 s = vit->site(); if ( s.is_input() ) { - //*widget << CGAL::RED; + //*widget << CGAL::red(); } else { - //*widget << CGAL::YELLOW; + //*widget << CGAL::yellow(); } if ( s.is_point() ) { QPointF point = matrix.map(convert(s.point())); diff --git a/GraphicsView/include/CGAL/Qt/SegmentDelaunayGraphLinfGraphicsItem.h b/GraphicsView/include/CGAL/Qt/SegmentDelaunayGraphLinfGraphicsItem.h index 43ba00ccbf6..1542ff69acf 100644 --- a/GraphicsView/include/CGAL/Qt/SegmentDelaunayGraphLinfGraphicsItem.h +++ b/GraphicsView/include/CGAL/Qt/SegmentDelaunayGraphLinfGraphicsItem.h @@ -208,9 +208,9 @@ SegmentDelaunayGraphLinfGraphicsItem::drawAll(QPainter *painter, const QStyle vit != t->finite_vertices_end(); ++vit) { typename T::Site_2 s = vit->site(); if ( s.is_input() ) { - //*widget << CGAL::RED; + //*widget << CGAL::red(); } else { - //*widget << CGAL::YELLOW; + //*widget << CGAL::yellow(); } if ( s.is_point() ) { QPointF point = matrix.map(convert(s.point())); diff --git a/HalfedgeDS/examples/HalfedgeDS/hds_prog_color.cpp b/HalfedgeDS/examples/HalfedgeDS/hds_prog_color.cpp index 35300c92bab..6b294fefe5c 100644 --- a/HalfedgeDS/examples/HalfedgeDS/hds_prog_color.cpp +++ b/HalfedgeDS/examples/HalfedgeDS/hds_prog_color.cpp @@ -28,8 +28,8 @@ typedef HDS::Face_handle Face_handle; int main() { HDS hds; - Face_handle f = hds.faces_push_back( Face( CGAL::RED)); - f->color = CGAL::BLUE; - CGAL_assertion( f->color == CGAL::BLUE); + Face_handle f = hds.faces_push_back( Face( CGAL::red())); + f->color = CGAL::blue(); + CGAL_assertion( f->color == CGAL::blue()); return 0; } diff --git a/Hyperbolic_triangulation_2/examples/Hyperbolic_triangulation_2/ht2_example_color.cpp b/Hyperbolic_triangulation_2/examples/Hyperbolic_triangulation_2/ht2_example_color.cpp index bbdd6bc4b67..59c1bec4a73 100644 --- a/Hyperbolic_triangulation_2/examples/Hyperbolic_triangulation_2/ht2_example_color.cpp +++ b/Hyperbolic_triangulation_2/examples/Hyperbolic_triangulation_2/ht2_example_color.cpp @@ -49,7 +49,7 @@ int main(int argc, char** argv) { if(fit->has_vertex(vo)) { - fit->info() = CGAL::RED; + fit->info() = CGAL::red(); origin_faces++; } } @@ -57,7 +57,7 @@ int main(int argc, char** argv) int red_faces = 0; for(fit = dt.hyperbolic_faces_begin(); fit != dt.hyperbolic_faces_end(); ++fit) { - if(fit->info() == CGAL::RED) + if(fit->info() == CGAL::red()) { red_faces++; } diff --git a/Installation/CHANGES.md b/Installation/CHANGES.md index 7bf8f7d7e16..89038a7c836 100644 --- a/Installation/CHANGES.md +++ b/Installation/CHANGES.md @@ -1,6 +1,13 @@ Release History =============== +Release 5.0 +------------ + +### IO Streams + + - **Breaking change:** The API of `CGAL::Color` has been cleaned up. + Release 4.14 ------------ @@ -37,7 +44,7 @@ Release date: March 2019 to approximate an input surface triangle mesh by a simpler surface triangle mesh. -### Polygon Mesh Processing package +### Polygon Mesh Processing - Added the following new functions to detect and repair issues in polygon soups: @@ -71,7 +78,7 @@ Release date: March 2019 detect intersections between meshes and volumes undergoing affine transformations. -### Regularized Boolean Set Operations in 2D package +### Regularized Boolean Set Operations in 2D - Fixed the validation of orientation of relative simple polygons. diff --git a/Installation/test/Installation/link_to_CGAL.cpp b/Installation/test/Installation/link_to_CGAL.cpp index 0638aa6db6e..3cb2755535d 100644 --- a/Installation/test/Installation/link_to_CGAL.cpp +++ b/Installation/test/Installation/link_to_CGAL.cpp @@ -1,10 +1,9 @@ // Use something defined not in headers but in the CGAL library to test that is was indeed properly built and linked to, -#include +#include int main() { - volatile const CGAL::Color* c = &CGAL::BLACK; - - return (c != 0) ? 0 : 1; + volatile const CGAL::Random* r = &CGAL::get_default_random(); + return int(r != 0); } diff --git a/Interpolation/demo/Interpolation/interpolation_2_demo.cpp b/Interpolation/demo/Interpolation/interpolation_2_demo.cpp index 2ed7aa06b07..d3d0a5136e6 100644 --- a/Interpolation/demo/Interpolation/interpolation_2_demo.cpp +++ b/Interpolation/demo/Interpolation/interpolation_2_demo.cpp @@ -287,14 +287,14 @@ int main(int , char** ) std::cout << "The data points are displayed in blue in the geomview" << " application." << std::endl; - gv << CGAL::BLUE; + gv << CGAL::blue(); visu_points(gv,sample_3); //show the gradients if(method>0){ std::cout << "The function gradients are displayed by red lines " <<" in the geomview application." << std::endl; - gv <> ch; diff --git a/Mesh_3/archive/applications/display_distribution.cpp b/Mesh_3/archive/applications/display_distribution.cpp index 838b3bb595a..547ff00693e 100644 --- a/Mesh_3/archive/applications/display_distribution.cpp +++ b/Mesh_3/archive/applications/display_distribution.cpp @@ -174,7 +174,7 @@ void output_distribution_to_png(std::vector& elements, const double scale = double_options["scale"]; - *widget << CGAL::FillColor(CGAL::BLACK); + *widget << CGAL::FillColor(CGAL::black()); // *widget << Segment_2(Point_2(0., 0.), Point_2(1., 0.)); for(int k=0;k0) @@ -184,12 +184,12 @@ void output_distribution_to_png(std::vector& elements, height = ( (distribution[k]+0.)/number_of_cells ) * scale; else height = ( std::log(distribution[k]+0.)/std::log(number_of_cells) ) * (-scale); - *widget << CGAL::BLACK + *widget << CGAL::black() << Rectangle_2(Point_2(k*width, 0), Point_2((k+1)*width, height)); } else - *widget << CGAL::RED << Segment_2(Point_2(k*width, 0), + *widget << CGAL::red() << Segment_2(Point_2(k*width, 0), Point_2((k+1)*width, 0)); widget->unlock(); diff --git a/Mesh_3/archive/applications/distribution.cpp b/Mesh_3/archive/applications/distribution.cpp index 42fb5678dde..4a7d44f780e 100644 --- a/Mesh_3/archive/applications/distribution.cpp +++ b/Mesh_3/archive/applications/distribution.cpp @@ -34,10 +34,10 @@ void display_distribution(Distribution_displayer* display, const double height = ( distribution[k]+0. ) * echelle; display->fill_rectangle(k * width, 0, (k+1)* width, height, - CGAL::BLACK); + CGAL::black()); } else display->segment(k * width, 0., (k+1) * width, 0., - CGAL::RED); + CGAL::red()); } diff --git a/Mesh_3/archive/applications/lanteri_process_results.cpp b/Mesh_3/archive/applications/lanteri_process_results.cpp index 982e18c5201..b7403c49f09 100644 --- a/Mesh_3/archive/applications/lanteri_process_results.cpp +++ b/Mesh_3/archive/applications/lanteri_process_results.cpp @@ -99,7 +99,7 @@ bool process_aux_2(const std::vector& qualities, displays[i]->segment(x_position_of_length_bound, 0.0, x_position_of_length_bound, -0.05, - CGAL::BLUE); + CGAL::blue()); } *out_stream << "saving " << filename.c_str() << "...\n"; diff --git a/Mesh_3/archive/applications/output_distribution_to_stdout.cpp b/Mesh_3/archive/applications/output_distribution_to_stdout.cpp index 4b7a586eba6..6ceef9c3ca0 100644 --- a/Mesh_3/archive/applications/output_distribution_to_stdout.cpp +++ b/Mesh_3/archive/applications/output_distribution_to_stdout.cpp @@ -180,7 +180,7 @@ void parse_argv(int argc, char** argv, int extra_args = 0) // // const double scale = double_options["scale"]; // -//// *widget << CGAL::FillColor(CGAL::BLACK); +//// *widget << CGAL::FillColor(CGAL::black()); // // *widget << Segment_2(Point_2(0., 0.), Point_2(1., 0.)); // for(int k=0;k0) @@ -190,12 +190,12 @@ void parse_argv(int argc, char** argv, int extra_args = 0) // height = ( (distribution[k]+0.)/number_of_cells ) * scale; // else // height = ( std::log(distribution[k]+0.)/std::log(number_of_cells) ) * (-scale); -//// *widget << CGAL::BLACK +//// *widget << CGAL::black() //// << Rectangle_2(Point_2(k*width, 0), //// Point_2((k+1)*width, height)); // } // else -//// *widget << CGAL::RED << Segment_2(Point_2(k*width, 0), +//// *widget << CGAL::red() << Segment_2(Point_2(k*width, 0), //// Point_2((k+1)*width, 0)); // // // widget->unlock(); diff --git a/Nef_3/include/CGAL/Nef_3/SM_visualizor.h b/Nef_3/include/CGAL/Nef_3/SM_visualizor.h index a8c6c67512b..0423db7b476 100644 --- a/Nef_3/include/CGAL/Nef_3/SM_visualizor.h +++ b/Nef_3/include/CGAL/Nef_3/SM_visualizor.h @@ -48,11 +48,11 @@ class SNC_SM_BooleColor typedef typename Refs_::Mark Mark; public: Color color(SVertex_const_handle, Mark m) const - { return ( m ? CGAL::BLACK : CGAL::WHITE ); } + { return ( m ? CGAL::black() : CGAL::white() ); } Color color(SHalfedge_const_handle, Mark m) const - { return ( m ? CGAL::BLACK : CGAL::WHITE ); } + { return ( m ? CGAL::black() : CGAL::white() ); } Color color(SHalfloop_const_handle, Mark m) const - { return ( m ? CGAL::BLACK : CGAL::WHITE ); } + { return ( m ? CGAL::black() : CGAL::white() ); } Color color(SFace_const_handle, Mark m) const { return ( m ? CGAL_NEF3_DGREY : CGAL_NEF3_LGREY ); } }; diff --git a/Nef_3/include/CGAL/Nef_3/SNC_SM_visualizor.h b/Nef_3/include/CGAL/Nef_3/SNC_SM_visualizor.h index 25330ad7501..b2d18c43130 100644 --- a/Nef_3/include/CGAL/Nef_3/SNC_SM_visualizor.h +++ b/Nef_3/include/CGAL/Nef_3/SNC_SM_visualizor.h @@ -48,11 +48,11 @@ class SNC_SM_BooleColor typedef typename Map_::Mark Mark; public: Color color(SVertex_const_handle, Mark m) const - { return ( m ? CGAL::BLACK : CGAL::WHITE ); } + { return ( m ? CGAL::black() : CGAL::white() ); } Color color(SHalfedge_const_handle, Mark m) const - { return ( m ? CGAL::BLACK : CGAL::WHITE ); } + { return ( m ? CGAL::black() : CGAL::white() ); } Color color(SHalfloop_const_handle, Mark m) const - { return ( m ? CGAL::BLACK : CGAL::WHITE ); } + { return ( m ? CGAL::black() : CGAL::white() ); } Color color(SFace_const_handle, Mark m) const { return ( m ? CGAL_NEF_DGREY : CGAL_NEF_LGREY ); } }; diff --git a/Nef_S2/include/CGAL/Nef_S2/SM_visualizor.h b/Nef_S2/include/CGAL/Nef_S2/SM_visualizor.h index 51ee7fe9917..a007e6a9338 100644 --- a/Nef_S2/include/CGAL/Nef_S2/SM_visualizor.h +++ b/Nef_S2/include/CGAL/Nef_S2/SM_visualizor.h @@ -44,11 +44,11 @@ class SM_BooleColor typedef typename Map_::Mark Mark; public: Color color(SVertex_const_handle, Mark m) const - { return ( m ? CGAL::BLACK : CGAL::WHITE ); } + { return ( m ? CGAL::black() : CGAL::white() ); } Color color(SHalfedge_const_handle, Mark m) const - { return ( m ? CGAL::BLACK : CGAL::WHITE ); } + { return ( m ? CGAL::black() : CGAL::white() ); } Color color(SHalfloop_const_handle, Mark m) const - { return ( m ? CGAL::BLACK : CGAL::WHITE ); } + { return ( m ? CGAL::black() : CGAL::white() ); } Color color(SFace_const_handle, Mark m) const { return ( m ? CGAL_NEF_DGREY : CGAL_NEF_LGREY ); } }; diff --git a/Nef_S2/include/CGAL/Nef_S2/Sphere_geometry_OGL.h b/Nef_S2/include/CGAL/Nef_S2/Sphere_geometry_OGL.h index f0527bb932b..34fecb1aa9f 100644 --- a/Nef_S2/include/CGAL/Nef_S2/Sphere_geometry_OGL.h +++ b/Nef_S2/include/CGAL/Nef_S2/Sphere_geometry_OGL.h @@ -254,7 +254,7 @@ class Sphere_point : public VPoint, public Gen_object { public: Sphere_point() {} Sphere_point(const CGAL::Sphere_point& p, - CGAL::Color c = CGAL::BLACK, unsigned w = 10) : + CGAL::Color c = CGAL::black(), unsigned w = 10) : VPoint(Approximator::approximate(p)), p_(p), c_(c), w_(w) {} Sphere_point(const Sphere_point& p) : VPoint(p), Gen_object() { p_ = p.p_; c_ = p.c_; w_ = p.w_; } @@ -297,7 +297,7 @@ class Sphere_segment : public VSegment, public Gen_object { public: Sphere_segment() {} Sphere_segment(const CGAL::Sphere_segment& s, - CGAL::Color c = CGAL::BLACK, unsigned w = 2) + CGAL::Color c = CGAL::black(), unsigned w = 2) : VSegment(Approximator::approximate(s)), s_(s), c_(c), w_(w) {} Sphere_segment(const Sphere_segment& s) : VSegment(s), Gen_object() { s_ = s.s_; c_ = s.c_; w_ = s.w_; } @@ -350,7 +350,7 @@ class Sphere_circle : public VSegment, public Gen_object { public: Sphere_circle() {} Sphere_circle(const CGAL::Sphere_circle& s, - CGAL::Color c = CGAL::BLACK, unsigned w = 2) + CGAL::Color c = CGAL::black(), unsigned w = 2) : VSegment(Approximator::approximate(s)), s_(s), c_(c), w_(w) {} Sphere_circle(const Sphere_circle& s) : VSegment(s), Gen_object() { s_ = s.s_; c_ = s.c_; w_ = s.w_; } @@ -539,27 +539,27 @@ Unit_sphere& operator=(const Unit_sphere& S) template void push_back(const CGAL::Sphere_point& p, - CGAL::Color c = CGAL::YELLOW, unsigned w = 5) + CGAL::Color c = CGAL::yellow(), unsigned w = 5) { objects_.push_back(new Sphere_point(p,c,w)); } template void push_back(const CGAL::Sphere_segment& s, - CGAL::Color c = CGAL::BLACK, unsigned w = 1) + CGAL::Color c = CGAL::black(), unsigned w = 1) { objects_.push_back(new Sphere_segment(s,c,w)); } template void push_back(const CGAL::Sphere_circle& s, - CGAL::Color c = CGAL::BLACK, unsigned w = 1) + CGAL::Color c = CGAL::black(), unsigned w = 1) { objects_.push_back(new Sphere_circle(s,c,w)); } template void push_back(const CGAL::Sphere_triangle& t, - CGAL::Color c = CGAL::WHITE) + CGAL::Color c = CGAL::white()) { triangles_.push_back(new Sphere_triangle(t,c)); } template void push_back_triangle_edge(const CGAL::Sphere_segment& s, - CGAL::Color c = CGAL::BLUE, unsigned w = 1) + CGAL::Color c = CGAL::blue(), unsigned w = 1) { triangle_edges_.push_back(new Sphere_segment(s,c,w)); } void set_style(int style) { @@ -718,11 +718,11 @@ class SM_BooleColor typedef typename Map_::Mark Mark; public: Color color(SVertex_const_handle, Mark m) const - { return ( m ? CGAL::BLACK : CGAL::WHITE ); } + { return ( m ? CGAL::black() : CGAL::white() ); } Color color(SHalfedge_const_handle, Mark m) const - { return ( m ? CGAL::BLACK : CGAL::WHITE ); } + { return ( m ? CGAL::black() : CGAL::white() ); } Color color(SHalfloop_const_handle, Mark m) const - { return ( m ? CGAL::BLACK : CGAL::WHITE ); } + { return ( m ? CGAL::black() : CGAL::white() ); } Color color(SFace_const_handle, Mark m) const { return ( m ? CGAL_NEF_DGREY : CGAL_NEF_LGREY ); } }; diff --git a/Periodic_2_triangulation_2/examples/Periodic_2_triangulation_2/p2t2_colored_vertices.cpp b/Periodic_2_triangulation_2/examples/Periodic_2_triangulation_2/p2t2_colored_vertices.cpp index 63097b27e00..aeed55bfdd3 100644 --- a/Periodic_2_triangulation_2/examples/Periodic_2_triangulation_2/p2t2_colored_vertices.cpp +++ b/Periodic_2_triangulation_2/examples/Periodic_2_triangulation_2/p2t2_colored_vertices.cpp @@ -32,7 +32,7 @@ int main() PDT::Vertex_iterator vit; for (vit = T.vertices_begin(); vit != T.vertices_end(); ++vit) if (T.degree(vit) == 6) - vit->info() = CGAL::RED; + vit->info() = CGAL::red(); return 0; } diff --git a/Periodic_3_triangulation_3/examples/Periodic_3_triangulation_3/colored_vertices.cpp b/Periodic_3_triangulation_3/examples/Periodic_3_triangulation_3/colored_vertices.cpp index aa9cd4e4225..989b702679a 100644 --- a/Periodic_3_triangulation_3/examples/Periodic_3_triangulation_3/colored_vertices.cpp +++ b/Periodic_3_triangulation_3/examples/Periodic_3_triangulation_3/colored_vertices.cpp @@ -36,7 +36,7 @@ int main(int, char**) P3DT3::Vertex_iterator vit; for (vit = T.vertices_begin(); vit != T.vertices_end(); ++vit) { if (T.degree(vit) == 16) { - vit->info() = CGAL::RED; + vit->info() = CGAL::red(); } } diff --git a/Polyhedron/demo/Polyhedron/Plugins/Classification/Cluster_classification.cpp b/Polyhedron/demo/Polyhedron/Plugins/Classification/Cluster_classification.cpp index a8ed8358285..516c56bbed4 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Classification/Cluster_classification.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Classification/Cluster_classification.cpp @@ -396,12 +396,12 @@ void Cluster_classification::backup_existing_colors_and_add_new() { if (m_points->point_set()->has_colors()) { - m_color = m_points->point_set()->add_property_map("real_color").first; + m_color = m_points->point_set()->add_property_map("real_color").first; for (Point_set::const_iterator it = m_points->point_set()->begin(); it != m_points->point_set()->first_selected(); ++ it) - m_color[*it] = {{ (unsigned char)(255 * m_points->point_set()->red(*it)), - (unsigned char)(255 * m_points->point_set()->green(*it)), - (unsigned char)(255 * m_points->point_set()->blue(*it)) }}; + m_color[*it] = CGAL::Color ((unsigned char)(255 * m_points->point_set()->red(*it)), + (unsigned char)(255 * m_points->point_set()->green(*it)), + (unsigned char)(255 * m_points->point_set()->blue(*it))); m_points->point_set()->remove_colors(); } @@ -411,7 +411,7 @@ void Cluster_classification::backup_existing_colors_and_add_new() void Cluster_classification::reset_colors() { - if (m_color == Point_set::Property_map()) + if (m_color == Point_set::Property_map()) m_points->point_set()->remove_colors(); else { @@ -606,7 +606,7 @@ int Cluster_classification::real_index_color() const { int out = m_index_color; - if (out == 0 && m_color == Point_set::Property_map()) + if (out == 0 && m_color == Point_set::Property_map()) out = -1; return out; } @@ -642,7 +642,7 @@ void Cluster_classification::compute_features (std::size_t nb_scales, float voxe if (normals) normal_map = m_points->point_set()->normal_map(); - bool colors = (m_color != Point_set::Property_map()); + bool colors = (m_color != Point_set::Property_map()); Point_set::Property_map echo_map; bool echo; diff --git a/Polyhedron/demo/Polyhedron/Plugins/Classification/Cluster_classification.h b/Polyhedron/demo/Polyhedron/Plugins/Classification/Cluster_classification.h index 53753e7cbbb..fd88c9e7507 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Classification/Cluster_classification.h +++ b/Polyhedron/demo/Polyhedron/Plugins/Classification/Cluster_classification.h @@ -27,7 +27,6 @@ class Cluster_classification : public Item_classification_base public: typedef Kernel::Point_3 Point_3; typedef Kernel::Vector_3 Vector_3; - typedef CGAL::Classification::RGB_Color Color; typedef Point_set::Point_map Point_map; typedef Point_set::Vector_map Vector_map; @@ -382,7 +381,10 @@ class Cluster_classification : public Item_classification_base std::vector m_clusters; - Point_set::Property_map m_color; + Point_set::Property_map m_red; + Point_set::Property_map m_green; + Point_set::Property_map m_blue; + Point_set::Property_map m_color; Point_set::Property_map m_cluster_id; Point_set::Property_map m_training; Point_set::Property_map m_classif; diff --git a/Polyhedron/demo/Polyhedron/Plugins/Classification/Point_set_item_classification.cpp b/Polyhedron/demo/Polyhedron/Plugins/Classification/Point_set_item_classification.cpp index 2b64ea7349a..aee56b923e6 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Classification/Point_set_item_classification.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Classification/Point_set_item_classification.cpp @@ -327,12 +327,12 @@ void Point_set_item_classification::backup_existing_colors_and_add_new() { if (m_points->point_set()->has_colors()) { - m_color = m_points->point_set()->add_property_map("real_color").first; + m_color = m_points->point_set()->add_property_map("real_color").first; for (Point_set::const_iterator it = m_points->point_set()->begin(); it != m_points->point_set()->first_selected(); ++ it) - m_color[*it] = {{ (unsigned char)(255 * m_points->point_set()->red(*it)), - (unsigned char)(255 * m_points->point_set()->green(*it)), - (unsigned char)(255 * m_points->point_set()->blue(*it)) }}; + m_color[*it] = CGAL::Color((unsigned char)(255 * m_points->point_set()->red(*it)), + (unsigned char)(255 * m_points->point_set()->green(*it)), + (unsigned char)(255 * m_points->point_set()->blue(*it))); m_points->point_set()->remove_colors(); } @@ -342,7 +342,7 @@ void Point_set_item_classification::backup_existing_colors_and_add_new() void Point_set_item_classification::reset_colors() { - if (m_color == Point_set::Property_map()) + if (m_color == Point_set::Property_map()) m_points->point_set()->remove_colors(); else { @@ -493,7 +493,7 @@ int Point_set_item_classification::real_index_color() const { int out = m_index_color; - if (out == 0 && m_color == Point_set::Property_map()) + if (out == 0 && m_color == Point_set::Property_map()) out = -1; return out; } @@ -532,7 +532,7 @@ void Point_set_item_classification::compute_features (std::size_t nb_scales, flo if (normals) normal_map = m_points->point_set()->normal_map(); - bool colors = (m_color != Point_set::Property_map()); + bool colors = (m_color != Point_set::Property_map()); Point_set::Property_map echo_map; bool echo; diff --git a/Polyhedron/demo/Polyhedron/Plugins/Classification/Point_set_item_classification.h b/Polyhedron/demo/Polyhedron/Plugins/Classification/Point_set_item_classification.h index 3dc0ba57af9..4de6fce22fc 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Classification/Point_set_item_classification.h +++ b/Polyhedron/demo/Polyhedron/Plugins/Classification/Point_set_item_classification.h @@ -30,7 +30,6 @@ class Point_set_item_classification : public Item_classification_base public: typedef Kernel::Point_3 Point_3; typedef Kernel::Vector_3 Vector_3; - typedef CGAL::Classification::RGB_Color Color; typedef Point_set::Point_map Point_map; typedef Point_set::Vector_map Vector_map; @@ -398,9 +397,12 @@ class Point_set_item_classification : public Item_classification_base std::vector m_clusters; + Point_set::Property_map m_red; + Point_set::Property_map m_green; + Point_set::Property_map m_blue; + Point_set::Property_map m_color; std::vector > m_label_probabilities; - Point_set::Property_map m_color; Point_set::Property_map m_training; Point_set::Property_map m_classif; diff --git a/Polyhedron/examples/Polyhedron/polyhedron_prog_color.cpp b/Polyhedron/examples/Polyhedron/polyhedron_prog_color.cpp index 57fba3f5d8e..13a5569c3d0 100644 --- a/Polyhedron/examples/Polyhedron/polyhedron_prog_color.cpp +++ b/Polyhedron/examples/Polyhedron/polyhedron_prog_color.cpp @@ -23,6 +23,6 @@ typedef Polyhedron::Halfedge_handle Halfedge_handle; int main() { Polyhedron P; Halfedge_handle h = P.make_tetrahedron(); - h->facet()->color = CGAL::RED; + h->facet()->color = CGAL::red(); return 0; } diff --git a/Polyhedron/examples/Polyhedron/polyhedron_prog_vertex_color.cpp b/Polyhedron/examples/Polyhedron/polyhedron_prog_vertex_color.cpp index 1a29a2674e9..63abfbc9b2a 100644 --- a/Polyhedron/examples/Polyhedron/polyhedron_prog_vertex_color.cpp +++ b/Polyhedron/examples/Polyhedron/polyhedron_prog_vertex_color.cpp @@ -29,6 +29,6 @@ typedef Polyhedron::Halfedge_handle Halfedge_handle; int main() { Polyhedron P; Halfedge_handle h = P.make_tetrahedron(); - h->vertex()->color = CGAL::RED; + h->vertex()->color = CGAL::red(); return 0; } diff --git a/Polyhedron_IO/demo/Polyhedron_IO/geomview_demo.cpp b/Polyhedron_IO/demo/Polyhedron_IO/geomview_demo.cpp index 1b806c21fa4..7ab19eccca2 100644 --- a/Polyhedron_IO/demo/Polyhedron_IO/geomview_demo.cpp +++ b/Polyhedron_IO/demo/Polyhedron_IO/geomview_demo.cpp @@ -47,7 +47,7 @@ int main() { Polyhedron P; P.make_tetrahedron( p,q,r,s); CGAL::Geomview_stream geo; - geo << CGAL::GREEN << P; + geo << CGAL::green() << P; // wait for a mouse click. Point click; diff --git a/Straight_skeleton_2/include/CGAL/IO/Dxf_stream.h b/Straight_skeleton_2/include/CGAL/IO/Dxf_stream.h index abc61e587a6..86fa9b55da1 100644 --- a/Straight_skeleton_2/include/CGAL/IO/Dxf_stream.h +++ b/Straight_skeleton_2/include/CGAL/IO/Dxf_stream.h @@ -112,7 +112,7 @@ public: mWriter (out) ,mDefaultDxfColor (255) ,mDxfColor (255) - ,mCgalColor (WHITE) + ,mCgalColor (white()) ,mLayer ("0") { setup_initial_color_table(); @@ -305,15 +305,15 @@ protected: void setup_initial_color_table() { - define_color(BLACK,0); - define_color(RED,1); - define_color(YELLOW,2); - define_color(GREEN,3); - define_color(PURPLE,4); - define_color(BLUE,5); - define_color(VIOLET,6); - define_color(WHITE,7); - define_color(GRAY,8); + define_color(black(),0); + define_color(red(),1); + define_color(yellow(),2); + define_color(green(),3); + define_color(purple(),4); + define_color(blue(),5); + define_color(violet(),6); + define_color(white(),7); + define_color(gray(),8); } }; diff --git a/Straight_skeleton_2/test/Straight_skeleton_2/test_sls.cpp b/Straight_skeleton_2/test/Straight_skeleton_2/test_sls.cpp index a8051bead6b..b4868d33acc 100644 --- a/Straight_skeleton_2/test/Straight_skeleton_2/test_sls.cpp +++ b/Straight_skeleton_2/test/Straight_skeleton_2/test_sls.cpp @@ -547,25 +547,25 @@ void dump_to_dxf ( TestCase const& aCase ) { if ( sVerbose ) cout << " Dumping input region. " << endl ; - dump_region_to_dxf(*aCase.Inner.Input,BLUE,"Input",lDxf); + dump_region_to_dxf(*aCase.Inner.Input,blue(),"Input",lDxf); } if ( aCase.Inner.PartialSkeleton ) { if ( sVerbose ) cout << " Dumping inner skeleton." << endl ; - dump_skeleton_to_dxf(*aCase.Inner.PartialSkeleton,YELLOW,GREEN,PURPLE,GRAY,"InnerSkeleton",lDxf); + dump_skeleton_to_dxf(*aCase.Inner.PartialSkeleton,yellow(),green(),purple(),gray(),"InnerSkeleton",lDxf); } if ( aCase.Outer.PartialSkeleton ) { if ( sVerbose ) cout << " Dumping outer skeleton." << endl ; - dump_skeleton_to_dxf(*aCase.Outer.PartialSkeleton,YELLOW,GREEN,PURPLE,GRAY,"OuterSkeleton",lDxf); + dump_skeleton_to_dxf(*aCase.Outer.PartialSkeleton,yellow(),green(),purple(),gray(),"OuterSkeleton",lDxf); } - dump_region_to_dxf(aCase.Inner.Contours,GRAY,"InnerOffset",lDxf); - dump_region_to_dxf(aCase.Outer.Contours,GRAY,"OuterOffset",lDxf); + dump_region_to_dxf(aCase.Inner.Contours,gray(),"InnerOffset",lDxf); + dump_region_to_dxf(aCase.Outer.Contours,gray(),"OuterOffset",lDxf); } diff --git a/Stream_support/doc/Stream_support/CGAL/IO/Color.h b/Stream_support/doc/Stream_support/CGAL/IO/Color.h deleted file mode 100644 index bf800b4a7a4..00000000000 --- a/Stream_support/doc/Stream_support/CGAL/IO/Color.h +++ /dev/null @@ -1,107 +0,0 @@ - -namespace CGAL { - -/*! -\ingroup PkgStreamSupportRef - -An object of the class `Color` is a color available -for drawing operations in many \cgal output streams. -Each color is defined by a triple of unsigned chars `(r,g,b)` with -0 \f$\le\f$ r,g,b \f$ \le \f$ 255, the so-called rgb-value of the color. - -\sa `CGAL::Geomview_stream` - -*/ - -class Color { -public: - -/// \name Creation -/// @{ - -/*! -creates a color with rgb-value `(0,0,0)`, i.e.\ black. -*/ -Color(); - -/*! -creates a color with rgb-value `(red,green,blue)`. -*/ -Color(unsigned char red, unsigned char green, unsigned char blue); - -/// @} - -/// \name Operations -/// @{ - -/*! -Test for equality: Two colors are equal, iff their -rgb-values are equal. -*/ -bool operator==(const Color &q) const; - -/*! -Test for inequality. -*/ -bool operator!=(const Color &q) const; - -/*! -returns the red component of `c`. -*/ -unsigned char red() const; - -/*! -returns the green component of `c`. -*/ -unsigned char green() const; - -/*! -returns the blue component of `c`. -*/ -unsigned char blue() const; - -/// @} - -/// \name Constants -/// The following constants are predefined: -/// @{ - -/*! -Black. -*/ -const Color BLACK = Color(0, 0, 0); - -/*! -White. -*/ -const Color WHITE = Color(255, 255, 255); - -/*! -Red. -*/ -const Color RED = Color(255, 0, 0); - -/*! -Green. -*/ -const Color GREEN = Color(0, 255, 0); - -/*! -Blue. -*/ -const Color BLUE = Color(0, 0, 255); - -/*! -Violet. -*/ -const Color VIOLET = Color(255, 0, 255); - -/*! -Orange. -*/ -const Color ORANGE = Color(255, 170, 0); - -/// @} - -}; /* end Color */ -} /* end namespace CGAL */ diff --git a/Stream_support/doc/Stream_support/Doxyfile.in b/Stream_support/doc/Stream_support/Doxyfile.in index 1f49650958f..f742dc367d0 100644 --- a/Stream_support/doc/Stream_support/Doxyfile.in +++ b/Stream_support/doc/Stream_support/Doxyfile.in @@ -1,4 +1,5 @@ @INCLUDE = ${CGAL_DOC_PACKAGE_DEFAULTS} PROJECT_NAME = "CGAL ${CGAL_DOC_VERSION} - IO Streams" +INPUT += ${CGAL_PACKAGE_INCLUDE_DIR}/CGAL/IO/Color.h diff --git a/Stream_support/include/CGAL/IO/Color.h b/Stream_support/include/CGAL/IO/Color.h index a9cfdb57f25..1d0087cf9dd 100644 --- a/Stream_support/include/CGAL/IO/Color.h +++ b/Stream_support/include/CGAL/IO/Color.h @@ -23,32 +23,108 @@ // // Author(s) : Andreas Fabri -#include - #ifndef CGAL_COLOR_H #define CGAL_COLOR_H +#include +#include + namespace CGAL { -class Color { + +/*! + \ingroup PkgStreamSupportRef + + An object of the class `Color` is a color available for drawing + operations in many \cgal output streams. Each color is defined by a + 4 unsigned chars `(r,g,b,a)` with 0 \f$\le\f$ r,g,b,a \f$ \le \f$ + 255, the so-called rgba-value of the color. + + The alpha parameter (representing transparency) is often ignored and + left to its default value (255 = no transparency), which is why we + often refer to the rgb-value of the color. + + \sa `CGAL::Geomview_stream` + +*/ + +class Color +{ +private: + + cpp11::array m_data; + public: - Color(): _red(120), _green(120), _blue(120), _alpha(120) {} + + /// \name Creation + /// @{ + + /*! + creates a color with rgba-value `(0,0,0,255)`, i.e.\ black. + */ + Color() + { + set_rgb (0, 0, 0, 255); + } + + /*! + creates a color with rgba-value `(red,green,blue,alpha)`. + */ Color(unsigned char red, - unsigned char green, - unsigned char blue, - unsigned char alpha = 120) - : _red(red), _green(green), _blue(blue), _alpha(alpha) - {} + unsigned char green, + unsigned char blue, + unsigned char alpha = 255) + { + set_rgb (red, green, blue, alpha); + } - unsigned char r() const {return _red;} - unsigned char g() const {return _green;} - unsigned char b() const {return _blue;} + /// @} + + /// \name Component Access + /// @{ + + /*! + returns the red component. + */ + unsigned char red() const { return m_data[0]; } + + /*! + returns a reference on the red component. + */ + unsigned char& red() { return m_data[0]; } + + /*! + returns the green component. + */ + unsigned char green() const { return m_data[1]; } + + /*! + returns a reference on the green component. + */ + unsigned char& green() { return m_data[1]; } + + /*! + returns the blue component. + */ + unsigned char blue() const { return m_data[2]; } + + /*! + returns a reference on the blue component. + */ + unsigned char& blue() { return m_data[2]; } + + /*! + returns the alpha component. + */ + unsigned char alpha() const { return m_data[3]; } + + /*! + returns a reference on the alpha component. + */ + unsigned char& alpha() { return m_data[3]; } + + /// \cond SKIP_IN_MANUAL - unsigned char red() const {return _red;} - unsigned char green() const {return _green;} - unsigned char blue() const {return _blue;} - unsigned char alpha() const {return _alpha;} - void set_alpha(unsigned char a) {_alpha=a;} bool operator==(const Color &c) const { return ( (red() == c.red()) && @@ -60,37 +136,227 @@ public: { return !( (*this) == c); } + + unsigned char r() const { return red(); } + unsigned char g() const { return green(); } + unsigned char b() const { return blue(); } + unsigned char a() const { return alpha(); } + /// \endcond + + /// @} + + /// \name Array Access + /// @{ + + /*! + returns the \f$i^{th}\f$ component of the rgb color (the + \f$0^{th}\f$ is red, the \f$1^{st}\f$ is blue, etc.). + */ + unsigned char operator[] (std::size_t i) const { return m_data[i]; } + + /*! + returns a reference on the \f$i^{th}\f$ component of `c` (the + \f$0^{th}\f$ is red, the \f$1^{st}\f$ is blue, etc.). + */ + unsigned char& operator[] (std::size_t i) { return m_data[i]; } + + /*! + returns the array with rgba values. + */ + const cpp11::array& to_rgba() const { return m_data; } + + /*! + returns the array with rgb values. + */ + const cpp11::array& to_rgb() const + { + return reinterpret_cast&>(m_data); + } + + /*! + computes the hsv (hue, saturation, value) values and returns an + array representing them as float values between 0 and 1. + */ + cpp11::array to_hsv() const + { + double r = (double)(m_data[0]) / 255.; + double g = (double)(m_data[1]) / 255.; + double b = (double)(m_data[2]) / 255.; + double Cmax = (std::max) (r, (std::max) (g, b)); + double Cmin = (std::min) (r, (std::min) (g, b)); + double delta = Cmax - Cmin; + double H = 0.; + + if (delta != 0.) + { + if (Cmax == r) + H = 60. * ((g - b) / delta); + else if (Cmax == g) + H = 60. * (((b - r) / delta) + 2.); + else + H = 60. * (((r - g) / delta) + 4.); + } + + if (H < 0.) H += 360.; + + double S = (Cmax == 0. ? 0. : 100. * (delta / Cmax)); + double V = 100. * Cmax; + + return make_array(H,S,V); + } + + /// \name Modification + /// @{ + + /*! + replaces the rgb values of the colors by the one given as parameters. + */ + void set_rgb (unsigned char red, + unsigned char green, + unsigned char blue, + unsigned char alpha = 255) + { + m_data[0] = red; + m_data[1] = green; + m_data[2] = blue; + m_data[3] = alpha; + } + + /*! + replaces the rgb values of the colors by the conversion to rgb of + the hsv values given as parameters. + + Double values given as parameters should take range between 0 and 1. + */ + void set_hsv (double hue, + double saturation, + double value, + unsigned char alpha = 255) + { + saturation /= 100.; + value /= 100.; + double C = value*saturation; + int hh = (int)(hue/60.); + double X = C * (1-std::abs (hh % 2 - 1)); + double r = 0, g = 0, b = 0; + + if( hh>=0 && hh<1 ) + { + r = C; + g = X; + } + else if( hh>=1 && hh<2 ) + { + r = X; + g = C; + } + else if( hh>=2 && hh<3 ) + { + g = C; + b = X; + } + else if( hh>=3 && hh<4 ) + { + g = X; + b = C; + } + else if( hh>=4 && hh<5 ) + { + r = X; + b = C; + } + else + { + r = C; + b = X; + } + double m = value-C; + r += m; + g += m; + b += m; + r *= 255.0; + g *= 255.0; + b *= 255.0; + + m_data[0] = (unsigned char)r; + m_data[1] = (unsigned char)g; + m_data[2] = (unsigned char)b; + m_data[3] = alpha; + } + + /// @} -private: - unsigned char _red; - unsigned char _green; - unsigned char _blue; - unsigned char _alpha; }; + -#ifndef CGAL_HEADER_ONLY +/*! -CGAL_EXPORT extern const Color BLACK ; -CGAL_EXPORT extern const Color WHITE ; -CGAL_EXPORT extern const Color GRAY ; + Constructs Color(0,0,0). + \relates Color +*/ +inline Color black() { return Color(0,0,0); } -CGAL_EXPORT extern const Color RED ; -CGAL_EXPORT extern const Color GREEN ; +/*! + Constructs Color(0,0,255). + \relates Color +*/ +inline Color blue() { return Color(0,0,255); } -CGAL_EXPORT extern const Color DEEPBLUE; -CGAL_EXPORT extern const Color BLUE ; -CGAL_EXPORT extern const Color PURPLE ; -CGAL_EXPORT extern const Color VIOLET ; +/*! + Constructs Color(10,0,100). + \relates Color +*/ +inline Color deep_blue() { return Color(10,0,100); } -CGAL_EXPORT extern const Color ORANGE ; -CGAL_EXPORT extern const Color YELLOW ; +/*! + Constructs Color(100,100,100). + \relates Color +*/ +inline Color gray() { return Color(100,100,100); } + +/*! + Constructs Color(0,255,0). + \relates Color +*/ +inline Color green() { return Color(0,255,0); } + +/*! + Constructs Color(235,150,0). + \relates Color +*/ +inline Color orange() { return Color(235,150,0); } + +/*! + Constructs Color(100,0,70). + \relates Color +*/ +inline Color purple() { return Color(100,0,70); } + +/*! + Constructs Color(255,0,0). + \relates Color +*/ +inline Color red() { return Color(255,0,0); } + +/*! + Constructs Color(255,0,255). + \relates Color +*/ +inline Color violet() { return Color(255,0,255); } + +/*! + Constructs Color(255,255,255). + \relates Color +*/ +inline Color white() { return Color(255,255,255); } + +/*! + Constructs Color(255,255,0). + \relates Color +*/ +inline Color yellow() { return Color(255,255,0); } -#endif // CGAL_HEADER_ONLY } //namespace CGAL -#ifdef CGAL_HEADER_ONLY -#include -#endif // CGAL_HEADER_ONLY - #endif // CGAL_COLOR_H diff --git a/Stream_support/include/CGAL/IO/Color_impl.h b/Stream_support/include/CGAL/IO/Color_impl.h deleted file mode 100644 index 340facebed0..00000000000 --- a/Stream_support/include/CGAL/IO/Color_impl.h +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) 1997 -// Utrecht University (The Netherlands), -// ETH Zurich (Switzerland), -// INRIA Sophia-Antipolis (France), -// Max-Planck-Institute Saarbruecken (Germany), -// and Tel-Aviv University (Israel). All rights reserved. -// -// This file is part of CGAL (www.cgal.org); you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public License as -// published by the Free Software Foundation; either version 3 of the License, -// or (at your option) any later version. -// -// 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 DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -// -// $URL$ -// $Id$ -// SPDX-License-Identifier: LGPL-3.0+ -// -// -// Author(s) : Andreas Fabri, Hervé Brönnimann - -namespace CGAL { - -const Color BLACK = Color(0, 0, 0); -const Color WHITE = Color(255, 255, 255); -const Color GRAY = Color(100,100,100); - -const Color GREEN = Color(0, 255, 0); - -const Color DEEPBLUE = Color(10, 0, 100); -const Color BLUE = Color(0, 0, 255); -const Color VIOLET = Color(255, 0, 255); -const Color PURPLE = Color(100, 0, 70); - -const Color RED = Color(255, 0, 0); -const Color ORANGE = Color(235, 150, 0); -const Color YELLOW = Color(255, 255, 0); - -} //namespace CGAL diff --git a/Stream_support/include/CGAL/IO/io.h b/Stream_support/include/CGAL/IO/io.h index 679565c8480..eb67fd391aa 100644 --- a/Stream_support/include/CGAL/IO/io.h +++ b/Stream_support/include/CGAL/IO/io.h @@ -393,39 +393,45 @@ std::ostream& operator<<( std::ostream& out, const Color& col) switch(get_mode(out)) { case IO::ASCII : return out << static_cast(col.red()) << ' ' - << static_cast(col.green()) << ' ' - << static_cast(col.blue()); + << static_cast(col.green()) << ' ' + << static_cast(col.blue()) << ' ' + << static_cast(col.alpha()); case IO::BINARY : - write(out, static_cast(col.red())); - write(out, static_cast(col.green())); - write(out, static_cast(col.blue())); + out.write(reinterpret_cast(col.to_rgba().data()), 4); return out; default: return out << "Color(" << static_cast(col.red()) << ", " - << static_cast(col.green()) << ", " - << static_cast(col.blue()) << ')'; + << static_cast(col.green()) << ", " + << static_cast(col.blue()) << ", " + << static_cast(col.alpha()) << ")"; } } inline std::istream &operator>>(std::istream &is, Color& col) { - int r = 0, g = 0, b = 0; + unsigned char r = 0, g = 0, b = 0, a = 0; + int ir = 0, ig = 0, ib = 0, ia = 0; switch(get_mode(is)) { case IO::ASCII : - is >> r >> g >> b; + is >> ir >> ig >> ib >> ia; + r = (unsigned char)ir; + g = (unsigned char)ig; + b = (unsigned char)ib; + a = (unsigned char)ia; break; case IO::BINARY : read(is, r); read(is, g); read(is, b); + read(is, a); break; default: std::cerr << "" << std::endl; std::cerr << "Stream must be in ascii or binary mode" << std::endl; break; } - col = Color((unsigned char)r,(unsigned char)g,(unsigned char)b); + col = Color(r,g,b,a); return is; } diff --git a/Stream_support/src/CGAL/Color.cpp b/Stream_support/src/CGAL/Color.cpp index 0dd475dfd09..a707f53375b 100644 --- a/Stream_support/src/CGAL/Color.cpp +++ b/Stream_support/src/CGAL/Color.cpp @@ -26,6 +26,5 @@ #ifndef CGAL_HEADER_ONLY #include -#include #endif // CGAL_HEADER_ONLY diff --git a/Triangulation_2/examples/Triangulation_2/colored_face.cpp b/Triangulation_2/examples/Triangulation_2/colored_face.cpp index cbee32c63ed..84392cd820b 100644 --- a/Triangulation_2/examples/Triangulation_2/colored_face.cpp +++ b/Triangulation_2/examples/Triangulation_2/colored_face.cpp @@ -22,11 +22,11 @@ int main() { t.insert(Point(2,2)); Finite_faces_iterator fc = t.finite_faces_begin(); - for( ; fc != t.finite_faces_end(); ++fc) fc->info() = CGAL::BLUE; + for( ; fc != t.finite_faces_end(); ++fc) fc->info() = CGAL::blue(); Point p(0.5,0.5); Face_handle fh = t.locate(p); - fh->info() = CGAL::RED; + fh->info() = CGAL::red(); return 0; } diff --git a/Triangulation_3/demo/Triangulation_3_Geomview_demos/Triangulation_3_color_demo.cpp b/Triangulation_3/demo/Triangulation_3_Geomview_demos/Triangulation_3_color_demo.cpp index c718b0bb087..8d3615ad60b 100644 --- a/Triangulation_3/demo/Triangulation_3_Geomview_demos/Triangulation_3_color_demo.cpp +++ b/Triangulation_3/demo/Triangulation_3_Geomview_demos/Triangulation_3_color_demo.cpp @@ -66,7 +66,7 @@ int main() Delaunay::Finite_vertices_iterator vit; for (vit = T.finite_vertices_begin(); vit != T.finite_vertices_end(); ++vit) if (T.degree(vit) == 6) - vit->info() = CGAL::RED; + vit->info() = CGAL::red(); std::cout << " Visualization of T" << std::endl; gv.set_wired(true); diff --git a/Triangulation_3/demo/Triangulation_3_Geomview_demos/Triangulation_3_demo.cpp b/Triangulation_3/demo/Triangulation_3_Geomview_demos/Triangulation_3_demo.cpp index b7f14bf3808..206531e09c2 100644 --- a/Triangulation_3/demo/Triangulation_3_Geomview_demos/Triangulation_3_demo.cpp +++ b/Triangulation_3/demo/Triangulation_3_Geomview_demos/Triangulation_3_demo.cpp @@ -136,7 +136,7 @@ int main() std::cout <<" Locating point (1,1,1) :" << std::endl; Point p(1,1,1); - gv.set_vertex_color(CGAL::ORANGE); + gv.set_vertex_color(CGAL::orange()); gv << p; Locate_type lt; int li, lj; @@ -144,7 +144,7 @@ int main() sleep(3); - gv << CGAL::VIOLET; + gv << CGAL::violet(); if ( lt == Triangulation::CELL ) { std::cout <<" CELL" << std::endl; visu_cell(gv,T,c); diff --git a/Triangulation_3/demo/Triangulation_3_Geomview_demos/Triangulation_3_voronoi_demo.cpp b/Triangulation_3/demo/Triangulation_3_Geomview_demos/Triangulation_3_voronoi_demo.cpp index e3fe523bcb2..383285ab01a 100644 --- a/Triangulation_3/demo/Triangulation_3_Geomview_demos/Triangulation_3_voronoi_demo.cpp +++ b/Triangulation_3/demo/Triangulation_3_Geomview_demos/Triangulation_3_voronoi_demo.cpp @@ -74,7 +74,7 @@ int main() gv << T; std::cout <<" Visualizing the Voronoi edges" << std::endl; - gv << CGAL::RED; + gv << CGAL::red(); T.draw_dual(gv); char ch; diff --git a/Triangulation_3/examples/Triangulation_3/color.cpp b/Triangulation_3/examples/Triangulation_3/color.cpp index c1e769c8875..1dbd7bdeb75 100644 --- a/Triangulation_3/examples/Triangulation_3/color.cpp +++ b/Triangulation_3/examples/Triangulation_3/color.cpp @@ -30,7 +30,7 @@ int main() Delaunay::Finite_vertices_iterator vit; for (vit = T.finite_vertices_begin(); vit != T.finite_vertices_end(); ++vit) if (T.degree(vit) == 6) - vit->info() = CGAL::RED; + vit->info() = CGAL::red(); return 0; }