Merge remote-tracking branch 'mine/Stream_support-Enhance_color-GF' into Stream_support-Enhance_color-GF

This commit is contained in:
Simon Giraudot 2019-04-09 15:00:56 +02:00
commit d314711eaf
54 changed files with 457 additions and 1281 deletions

View File

@ -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);

View File

@ -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<Arr, CGAL::Postscript_file_stream> 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);

View File

@ -36,7 +36,6 @@
#endif
#include <CGAL/Classification/Cluster.h>
#include <CGAL/Classification/Color.h>
#include <CGAL/Classification/Evaluation.h>
#include <CGAL/Classification/Feature_base.h>
#include <CGAL/Classification/Feature_set.h>

View File

@ -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 <CGAL/license/Classification.h>
#include <CGAL/number_utils.h>
#include <CGAL/int.h>
#include <CGAL/array.h>
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<unsigned char, 3> 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<float, 3> 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

View File

@ -25,8 +25,8 @@
#include <vector>
#include <CGAL/Classification/Color.h>
#include <CGAL/Classification/Feature_base.h>
#include <CGAL/array.h>
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 <typename GeomTraits, typename PointRange, typename ColorMap>
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<double, 3> c = get(color_map, *(input.begin()+pt_index)).to_hsv();
return float(c[std::size_t(m_channel)]);
}
/// \endcond
};

View File

@ -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 <CGAL/license/Classification.h>
#include <vector>
#include <CGAL/Classification/Feature_base.h>
#include <CGAL/Classification/Local_eigen_analysis.h>
/// \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<float> attrib;
#else
const Classification::Local_eigen_analysis& eigen;
#endif
public:
template <typename InputRange>
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 <typename InputRange>
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 <typename InputRange>
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 <typename InputRange>
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 <typename InputRange>
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 <typename InputRange>
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 <typename InputRange>
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 <typename InputRange>
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

View File

@ -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 <CGAL/license/Classification.h>
#include <vector>
#include <CGAL/Classification/Color.h>
#include <CGAL/Classification/Feature_base.h>
/// \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
<center><em>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).</em></center>
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 <typename GeomTraits, typename PointRange, typename ColorMap>
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<float> 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

View File

@ -152,8 +152,6 @@ public:
typedef Classification::Feature::Verticality
<GeomTraits> Verticality;
typedef Classification::Feature::Eigenvalue Eigenvalue;
typedef typename Classification::RGB_Color RGB_Color;
/// \endcond
private:

View File

@ -153,8 +153,6 @@ public:
typedef Classification::Feature::Gradient_of_feature
<PointRange, PointMap, Neighbor_query> 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 <typename VectorMap = Default,
typename ColorMap = Default,
typename EchoMap = Default>
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<PointMap>(m_point_map)),
boost::make_transform_iterator (m_input.end(), CGAL::Property_map_to_unary_function<PointMap>(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<VectorMap, typename GeomTraits::Vector_3 >::type
Vmap;
typedef typename Default::Get<ColorMap, RGB_Color >::type
Cmap;
typedef typename Default::Get<EchoMap, std::size_t >::type
Emap;
generate_point_based_features (features);
generate_normal_based_features (features, get_parameter<Vmap>(normal_map));
generate_color_based_features (features, get_parameter<Cmap>(color_map));
generate_echo_based_features (features, get_parameter<Emap>(echo_map));
}
// Functions to remove when deprecated constructor is removed
void generate_normal_based_features(const CGAL::Constant_property_map<Iterator, typename GeomTraits::Vector_3>&) { }
void generate_color_based_features(const CGAL::Constant_property_map<Iterator, RGB_Color>&) { }
void generate_echo_based_features(const CGAL::Constant_property_map<Iterator, std::size_t>&) { }
#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).

View File

@ -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})

View File

@ -1,136 +0,0 @@
#include <CGAL/internal/disable_deprecation_warnings_and_errors.h>
#if defined (_MSC_VER) && !defined (_WIN64)
#pragma warning(disable:4244) // boost::number_distance::distance()
// converts 64 to 32 bits integers
#endif
#include <cstdlib>
#include <fstream>
#include <iostream>
#include <string>
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Classification.h>
#include <CGAL/Point_set_3.h>
#include <CGAL/Random.h>
typedef CGAL::Simple_cartesian<double> Kernel;
typedef Kernel::Point_3 Point;
typedef Kernel::Vector_3 Vector;
typedef CGAL::Point_set_3<Point> 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<Kernel, Point_set, Point_map> Feature_generator;
typedef Point_set::Property_map<std::size_t> Size_t_map;
typedef Point_set::Property_map<Classification::RGB_Color> 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<std::size_t> ("echo");
assert (map_added);
boost::tie (color_map, map_added) = pts.add_property_map<Classification::RGB_Color> ("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<int> 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<CGAL::Sequential_tag> (training_set, 800);
#ifdef CGAL_LINKED_WITH_TBB
classifier.train<CGAL::Parallel_tag> (training_set, 800);
#endif
std::vector<int> label_indices(pts.size(), -1);
Classification::classify<CGAL::Sequential_tag>
(pts, labels, classifier, label_indices);
Classification::classify_with_local_smoothing<CGAL::Sequential_tag>
(pts, pts.point_map(), labels, classifier,
generator.neighborhood().sphere_neighbor_query(0.01f),
label_indices);
Classification::classify_with_graphcut<CGAL::Sequential_tag>
(pts, pts.point_map(), labels, classifier,
generator.neighborhood().k_neighbor_query(12),
0.2f, 10, label_indices);
#ifdef CGAL_LINKED_WITH_TBB
Classification::classify<CGAL::Sequential_tag>
(pts, labels, classifier, label_indices);
Classification::classify_with_local_smoothing<CGAL::Sequential_tag>
(pts, pts.point_map(), labels, classifier,
generator.neighborhood().sphere_neighbor_query(0.01f),
label_indices);
Classification::classify_with_graphcut<CGAL::Sequential_tag>
(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;
}

View File

@ -37,7 +37,7 @@ typedef Classification::Point_set_feature_generator<Kernel, Point_set, Point_map
typedef Point_set::Vector_map Vector_map;
typedef Point_set::Property_map<std::size_t> Size_t_map;
typedef Point_set::Property_map<Classification::RGB_Color> Color_map;
typedef Point_set::Property_map<CGAL::Color> 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<std::size_t> ("echo");
assert (map_added);
boost::tie (color_map, map_added) = pts.add_property_map<Classification::RGB_Color> ("color");
boost::tie (color_map, map_added) = pts.add_property_map<CGAL::Color> ("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;

View File

@ -67,7 +67,7 @@ void draw_points_and_hull(const std::vector<Point_3>& points,
std::vector<Point_3>::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<Point_3>& 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) )

View File

@ -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);

View File

@ -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));

View File

@ -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)

View File

@ -173,9 +173,9 @@ SegmentDelaunayGraphGraphicsItem<T>::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()));

View File

@ -208,9 +208,9 @@ SegmentDelaunayGraphLinfGraphicsItem<T>::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()));

View File

@ -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;
}

View File

@ -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++;
}

View File

@ -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.

View File

@ -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 <CGAL/IO/Color.h>
#include <CGAL/Random.h>
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);
}

View File

@ -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 <<CGAL::RED;
gv <<CGAL::red();
gv << Segment_3(Point_3(h/3,h/3,w),Point_3(h/3,h/3,w)+ Vector_3(-g,-g,0));
gv << Segment_3(Point_3(-h/3,h/3,w),Point_3(-h/3,h/3,w)+Vector_3(g,-g,0));
gv << Segment_3(Point_3(-h/3,-h/3,w),Point_3(-h/3,-h/3,w)+Vector_3(g,g,0));

View File

@ -217,21 +217,21 @@ int main()
}
char ch;
gv << CGAL::VIOLET;
gv << CGAL::violet();
visu_points(gv,points);
gv << CGAL::RED << Segment(p, p+ 0.3*normal);
gv << CGAL::ORANGE <<p;
gv << CGAL::red() << Segment(p, p+ 0.3*normal);
gv << CGAL::orange() <<p;
std::cout << "Visualizing the intersection of "
<< "3D Voronoi diagram with tangent plane at "
<< p << "." << std::endl;
gv << CGAL::BLUE;
gv << CGAL::blue();
T.draw_dual(gv);
Face_iterator fit = T.finite_faces_begin(),
fend = T.finite_faces_end();
for(;fit != fend;fit++)
gv <<CGAL::BLACK<<T.dual(fit);
gv <<CGAL::black()<<T.dual(fit);
std::cout << "Enter any character to quit" << std::endl;
std::cin >> ch;

View File

@ -174,7 +174,7 @@ void output_distribution_to_png(std::vector<double>& 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;k<number_of_classes;k++)
if(distribution[k]>0)
@ -184,12 +184,12 @@ void output_distribution_to_png(std::vector<double>& 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();

View File

@ -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());
}

View File

@ -99,7 +99,7 @@ bool process_aux_2(const std::vector<Qualities>& 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";

View File

@ -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;k<number_of_classes;k++)
// if(distribution[k]>0)
@ -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();

View File

@ -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 ); }
};

View File

@ -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 ); }
};

View File

@ -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 ); }
};

View File

@ -254,7 +254,7 @@ class Sphere_point : public VPoint, public Gen_object {
public:
Sphere_point() {}
Sphere_point(const CGAL::Sphere_point<R>& p,
CGAL::Color c = CGAL::BLACK, unsigned w = 10) :
CGAL::Color c = CGAL::black(), unsigned w = 10) :
VPoint(Approximator<R>::approximate(p)), p_(p), c_(c), w_(w) {}
Sphere_point(const Sphere_point<R>& 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<R>& s,
CGAL::Color c = CGAL::BLACK, unsigned w = 2)
CGAL::Color c = CGAL::black(), unsigned w = 2)
: VSegment(Approximator<R>::approximate(s)), s_(s), c_(c), w_(w) {}
Sphere_segment(const Sphere_segment<R>& 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<R>& s,
CGAL::Color c = CGAL::BLACK, unsigned w = 2)
CGAL::Color c = CGAL::black(), unsigned w = 2)
: VSegment(Approximator<R>::approximate(s)), s_(s), c_(c), w_(w) {}
Sphere_circle(const Sphere_circle<R>& 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 <typename R>
void push_back(const CGAL::Sphere_point<R>& p,
CGAL::Color c = CGAL::YELLOW, unsigned w = 5)
CGAL::Color c = CGAL::yellow(), unsigned w = 5)
{ objects_.push_back(new Sphere_point<R>(p,c,w)); }
template <typename R>
void push_back(const CGAL::Sphere_segment<R>& s,
CGAL::Color c = CGAL::BLACK, unsigned w = 1)
CGAL::Color c = CGAL::black(), unsigned w = 1)
{ objects_.push_back(new Sphere_segment<R>(s,c,w)); }
template <typename R>
void push_back(const CGAL::Sphere_circle<R>& s,
CGAL::Color c = CGAL::BLACK, unsigned w = 1)
CGAL::Color c = CGAL::black(), unsigned w = 1)
{ objects_.push_back(new Sphere_circle<R>(s,c,w)); }
template <typename R>
void push_back(const CGAL::Sphere_triangle<R>& t,
CGAL::Color c = CGAL::WHITE)
CGAL::Color c = CGAL::white())
{ triangles_.push_back(new Sphere_triangle<R>(t,c)); }
template <typename R>
void push_back_triangle_edge(const CGAL::Sphere_segment<R>& s,
CGAL::Color c = CGAL::BLUE, unsigned w = 1)
CGAL::Color c = CGAL::blue(), unsigned w = 1)
{ triangle_edges_.push_back(new Sphere_segment<R>(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 ); }
};

View File

@ -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;
}

View File

@ -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();
}
}

View File

@ -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<Color>("real_color").first;
m_color = m_points->point_set()->add_property_map<CGAL::Color>("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<Color>())
if (m_color == Point_set::Property_map<CGAL::Color>())
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<Color>())
if (out == 0 && m_color == Point_set::Property_map<CGAL::Color>())
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<Color>());
bool colors = (m_color != Point_set::Property_map<CGAL::Color>());
Point_set::Property_map<boost::uint8_t> echo_map;
bool echo;

View File

@ -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<Cluster> m_clusters;
Point_set::Property_map<Color> m_color;
Point_set::Property_map<unsigned char> m_red;
Point_set::Property_map<unsigned char> m_green;
Point_set::Property_map<unsigned char> m_blue;
Point_set::Property_map<CGAL::Color> m_color;
Point_set::Property_map<int> m_cluster_id;
Point_set::Property_map<int> m_training;
Point_set::Property_map<int> m_classif;

View File

@ -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<Color>("real_color").first;
m_color = m_points->point_set()->add_property_map<CGAL::Color>("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<Color>())
if (m_color == Point_set::Property_map<CGAL::Color>())
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<Color>())
if (out == 0 && m_color == Point_set::Property_map<CGAL::Color>())
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<Color>());
bool colors = (m_color != Point_set::Property_map<CGAL::Color>());
Point_set::Property_map<boost::uint8_t> echo_map;
bool echo;

View File

@ -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<Cluster> m_clusters;
Point_set::Property_map<unsigned char> m_red;
Point_set::Property_map<unsigned char> m_green;
Point_set::Property_map<unsigned char> m_blue;
Point_set::Property_map<CGAL::Color> m_color;
std::vector<std::vector<float> > m_label_probabilities;
Point_set::Property_map<Color> m_color;
Point_set::Property_map<int> m_training;
Point_set::Property_map<int> m_classif;

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;

View File

@ -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);
}
};

View File

@ -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);
}

View File

@ -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 <I>rgb-value</I> 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 */

View File

@ -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

View File

@ -23,32 +23,108 @@
//
// Author(s) : Andreas Fabri
#include <CGAL/config.h>
#ifndef CGAL_COLOR_H
#define CGAL_COLOR_H
#include <CGAL/config.h>
#include <CGAL/array.h>
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 <I>rgba-value</I> 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 <I>rgb-value</I> of the color.
\sa `CGAL::Geomview_stream`
*/
class Color
{
private:
cpp11::array<unsigned char, 4> 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()) &&
@ -61,36 +137,226 @@ public:
return !( (*this) == c);
}
private:
unsigned char _red;
unsigned char _green;
unsigned char _blue;
unsigned char _alpha;
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<unsigned char, 4>& to_rgba() const { return m_data; }
/*!
returns the array with rgb values.
*/
const cpp11::array<unsigned char, 3>& to_rgb() const
{
return reinterpret_cast<const cpp11::array<unsigned char, 3>&>(m_data);
}
/*!
computes the hsv (hue, saturation, value) values and returns an
array representing them as float values between 0 and 1.
*/
cpp11::array<double, 3> 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;
}
/// @}
};
#ifndef CGAL_HEADER_ONLY
CGAL_EXPORT extern const Color BLACK ;
CGAL_EXPORT extern const Color WHITE ;
CGAL_EXPORT extern const Color GRAY ;
/*!
CGAL_EXPORT extern const Color RED ;
CGAL_EXPORT extern const Color GREEN ;
Constructs Color(0,0,0).
\relates Color
*/
inline Color black() { return Color(0,0,0); }
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(0,0,255).
\relates Color
*/
inline Color blue() { return Color(0,0,255); }
CGAL_EXPORT extern const Color ORANGE ;
CGAL_EXPORT extern const Color YELLOW ;
/*!
Constructs Color(10,0,100).
\relates Color
*/
inline Color deep_blue() { return Color(10,0,100); }
/*!
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 <CGAL/IO/Color_impl.h>
#endif // CGAL_HEADER_ONLY
#endif // CGAL_COLOR_H

View File

@ -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

View File

@ -393,39 +393,45 @@ std::ostream& operator<<( std::ostream& out, const Color& col)
switch(get_mode(out)) {
case IO::ASCII :
return out << static_cast<int>(col.red()) << ' '
<< static_cast<int>(col.green()) << ' '
<< static_cast<int>(col.blue());
<< static_cast<int>(col.green()) << ' '
<< static_cast<int>(col.blue()) << ' '
<< static_cast<int>(col.alpha());
case IO::BINARY :
write(out, static_cast<int>(col.red()));
write(out, static_cast<int>(col.green()));
write(out, static_cast<int>(col.blue()));
out.write(reinterpret_cast<const char*>(col.to_rgba().data()), 4);
return out;
default:
return out << "Color(" << static_cast<int>(col.red()) << ", "
<< static_cast<int>(col.green()) << ", "
<< static_cast<int>(col.blue()) << ')';
<< static_cast<int>(col.green()) << ", "
<< static_cast<int>(col.blue()) << ", "
<< static_cast<int>(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;
}

View File

@ -26,6 +26,5 @@
#ifndef CGAL_HEADER_ONLY
#include <CGAL/IO/Color.h>
#include <CGAL/IO/Color_impl.h>
#endif // CGAL_HEADER_ONLY

View File

@ -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;
}

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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;
}