Skip to content
Open
Show file tree
Hide file tree
Changes from 41 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
173ae7b
Creation of float_snap_rounding_2.h and its example .cpp
LeoValque Mar 7, 2025
012ec64
transform to same API as existing snap_rounding, remove duplicate, ef…
LeoValque Mar 17, 2025
d229e9f
Test of float snap rounding 2 and intense debug
LeoValque Mar 21, 2025
78b935d
Box_with_index has known explicit ID
LeoValque Mar 24, 2025
a35acd9
remove blank line unvolontary added to Subcruves_visitor
LeoValque Mar 24, 2025
ad3bde0
some cleaning
LeoValque Mar 24, 2025
717cd99
delete specific test from data
LeoValque Apr 2, 2025
1672576
hide include iostream behind debug macro
LeoValque Apr 2, 2025
829aba2
remove unused specialization of BOx_with_index
LeoValque Apr 2, 2025
c9df11e
replace size_t per std::size_t
LeoValque Apr 2, 2025
4a61d4b
add a reserve in the iteration of the snap
LeoValque Apr 2, 2025
cf25df0
Write float_snap_rounding_traits
LeoValque Apr 8, 2025
4f89066
add round in the traits
LeoValque Apr 8, 2025
0968471
Improve running time of compute_snap_rounding_2
LeoValque Aug 29, 2025
9f7f000
float_snap_rounding example
LeoValque Aug 29, 2025
39d3ade
rewrite test of Float_snap_rounding_2
LeoValque Oct 10, 2025
64922a6
Clean Float_2D_snap
LeoValque Oct 15, 2025
c380ad2
Snap of polygons
LeoValque Oct 16, 2025
443ed48
NamedParameter
LeoValque Oct 16, 2025
3df3151
Rewrite float_snap_rounding example
LeoValque Oct 16, 2025
cfa69d0
Reintroduce flag NO_TESTING to test_snap_rounding_2
LeoValque Oct 17, 2025
e8ea281
Use a one way scan instead of box_intersection_d
LeoValque Oct 23, 2025
134330e
bounding box filter and combinatorial to test to improve running time
LeoValque Oct 23, 2025
f82659b
cleaning and optimize Float_2D_snap
LeoValque Oct 27, 2025
92fd905
cleaning Float_snap_rounding.h
LeoValque Oct 28, 2025
58caea2
More cleaning of Float_snap_rounding_2
LeoValque Oct 28, 2025
ec7b77b
Enhance documentation of FLoat snap rounding 2
LeoValque Nov 3, 2025
fc83e54
change reference
LeoValque Nov 3, 2025
6918848
Fix error of the testsuite
LeoValque Nov 6, 2025
ec71e01
Fix documentation
LeoValque Nov 6, 2025
cb5893a
Fix documentation
LeoValque Nov 6, 2025
92807e9
Add a test with differents Kernels
LeoValque Nov 6, 2025
803ef35
Fix the example
LeoValque Nov 7, 2025
19c832b
Some additional test
LeoValque Nov 10, 2025
422338c
clean test
LeoValque Nov 10, 2025
e63869e
Solved invalid iterator after erased with MSVC
LeoValque Nov 12, 2025
b0388e4
Fix dangling reference warning of the testsuite
LeoValque Nov 18, 2025
4a2ebc5
workaround issue with MSVC2017
sloriot Nov 17, 2025
e7fe2e7
push the constexpr back
sloriot Nov 17, 2025
4c5b917
Use Simple_cartesian instead of Cartesian
LeoValque Nov 20, 2025
eec0ae3
Forget that do_curves_intersect does not work with EPICK
LeoValque Nov 20, 2025
14aba48
First path on the review
LeoValque Dec 9, 2025
acec954
Apply suggestions of the review
LeoValque Dec 9, 2025
b80ce2f
Fix error on MSVC
LeoValque Dec 10, 2025
161507b
Fix doc
LeoValque Dec 12, 2025
a8bbddf
add license
sloriot Dec 15, 2025
a8b60b5
tabs
sloriot Dec 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Arrangement_on_surface_2/include/CGAL/Arr_segment_traits_2.h
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,11 @@ class Arr_segment_traits_2 : public Kernel_ {
// Check if we have a single intersection point.
const Point_2* ip = std::get_if<Point_2>(&*res);
if (ip != nullptr) {
if(!(cv1.is_vertical() ?
m_traits.is_in_y_range_2_object()(cv1, *ip) :
m_traits.is_in_x_range_2_object()(cv1, *ip))){
std::cout << cv1 << std::endl;
}
CGAL_assertion(cv1.is_vertical() ?
m_traits.is_in_y_range_2_object()(cv1, *ip) :
m_traits.is_in_x_range_2_object()(cv1, *ip));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,9 @@ CGAL_add_named_parameter(do_not_modify_geometry_t, do_not_modify_geometry, do_no
CGAL_add_named_parameter_with_compatibility_ref_only(angles_param_t, angles_param, angles)
CGAL_add_named_parameter(maximum_height_t, maximum_height, maximum_height)

//List of named parameters used in Snap_rounding_2
CGAL_add_named_parameter(compute_intersection_t, compute_intersection, compute_intersection)

// List of named parameters used in the package 'Constrained_triangulation_3'
CGAL_add_named_parameter(plc_face_id_t, plc_face_id, plc_face_id)
CGAL_add_named_parameter(with_plc_face_id_t, with_plc_face_id, with_plc_face_id)
Original file line number Diff line number Diff line change
@@ -0,0 +1,228 @@

/*!
\ingroup PkgSnapRounding2Concepts
\cgalConcept
The concept `FloatSnapRoundingTraits_2` lists the set of requirements that must be fulfilled by
an instance of the `Traits` template-parameter of
the free functions of TODO.
The list includes the nested types of the geometric primitives used in this class and
some function object types for the required predicates on those primitives.
\cgalRefines{AosTraits_2}
\cgalHasModelsBegin
\cgalHasModels{CGAL::Float_snap_rounding_traits_2<Kernel>}
\cgalHasModelsEnd
*/

class FloatSnapRoundingTraits_2 {
public:

/// \name Types
/// @{

/*!
The number type. This type must fulfill the requirements on
`FieldNumberType`
*/
typedef unspecified_type FT;

/*!
Models the concept `ArrTraits::Point_2`.
*/
typedef unspecified_type Point_2;

/*!
Models the concept `ArrTraits::XMonotoneCurve_2`.
*/
typedef unspecified_type Segment_2;

/// @}

/// \name Functor Types
/// @{

/*!
Models the concept `Kernel::ConstructSource_2`.
*/
typedef unspecified_type Construct_source_2;

/*!
Models the concept `Kernel::ConstructTarget_2`.
*/
typedef unspecified_type Construct_target_2;

/*!
Models the concept `Kernel::ConstructSegment_2`.
*/
typedef unspecified_type Construct_segment_2;

/*!
Models the concept `Kernel::LessXY_2`.
*/
typedef unspecified_type Less_xy_2;

/*!
Models the concept `Kernel::LessY_2`.
*/
typedef unspecified_type Less_y_2;

/*!
Models the concept `Kernel::Equal_2`.
*/
typedef unspecified_type Equal_2;

/*!
Models the concept `FSRTraits_2::ConstructRoundPoint_2`.
*/
typedef unspecified_type Construct_round_point_2;

/*!
Models the concept `FSRTraits_2::SquaredRoundBound_2`.
*/
typedef unspecified_type Squared_round_bound_2;

/*!
Models the concept `FSRTraits_2::ConverterToExact`.
*/
typedef unspecified_type Converter_to_exact;

/*!
Models the concept `FSRTraits_2::ConverterFromExact`.
*/
typedef unspecified_type Converter_from_exact;

/// @}

/// \name Accessing Functor Objects
/// @{

/*!
*/
Construct_source_2 construct_source_2_object();

/*!
*/
Construct_target_2 construct_target_2_object();

/*!
*/
Construct_segment_2 construct_segment_2_object();

/*!
*/
Less_xy_2 less_xy_2_object();

/*!
*/
Less_y_2 less_y_2_object();

/*!
*/
Construct_round_point_2 construct_round_point_2_object();

/*!
*/
Squared_round_bound_2 squared_round_bound_2_object();

/*!
*/
Converter_to_exact converter_to_exact_object();

/*!
*/
Converter_from_exact converter_from_exact_object();


/// @}

}; /* end FloatSnapRoundingTraits_2 */


namespace FSRTraits_2{

/*!
\ingroup PkgSnapRounding2Concepts
\cgalConcept
\cgalHasModelsBegin
\cgalHasModelsBare{\link FloatSnapRoundingTraits_2::Construct_round_point_2 `Float_snap_rounding_traits_2::Construct_round_point_2` \endlink}
\cgalHasModelsEnd
*/
class ConstructRoundPoint_2
{
public:

/*!
Given a point, construct its rounded version
*/
Point_2 operator()(Point_2 p);
};

/*!
\ingroup PkgSnapRounding2Concepts
\cgalConcept
\cgalHasModelsBegin
\cgalHasModelsBare{\link FloatSnapRoundingTraits_2::Squared_round_bound_2 `Float_snap_rounding_traits_2::Squared_round_bound_2` \endlink}
\cgalHasModelsEnd
*/
class SquaredRoundBound_2
{
public:

/*!
Given a point, compute an upper bound of the squared distance between its exact coordinates and its rounded coordinates
*/
double operator()(Point_2 p);
};

/*!
\ingroup PkgSnapRounding2Concepts
\cgalConcept
\cgalHasModelsBegin
\cgalHasModelsBare{\link FloatSnapRoundingTraits_2::Converter_to_exact `Float_snap_rounding_traits_2::Convertex_to_exact` \endlink}
\cgalHasModelsEnd
*/
class ConverterToExact
{
public:
typedef unspecified_type InputPoint_2;
typedef unspecified_type InputSegment_2;
/*!
Convert input points (i.e. segments) into points (i.e. segments) of the type of the traits
*/
Point_2 operator()(InputPoint_2 p);
Segment_2 operator()(InputSegment_2 p);
};

/*!
\ingroup PkgSnapRounding2Concepts
\cgalConcept
\cgalHasModelsBegin
\cgalHasModelsBare{\link FloatSnapRoundingTraits_2::Converter_from_exact `Float_snap_rounding_traits_2::Convertex_to_exact` \endlink}
\cgalHasModelsEnd
*/
class ConverterFromExact
{
public:
typedef unspecified_type OutputPoint_2;
typedef unspecified_type OutputSegment_2;
/*!
Convert points (i.e. segments) of the type of the traits into points (i.e. segments) of the output
*/
OutputPoint_2 operator()(Point_2 p);
OutputSegment_2 operator()(Segment_2 p);
};



} /* end of namespace SRTraits_2 */
8 changes: 8 additions & 0 deletions Snap_rounding_2/doc/Snap_rounding_2/Doxyfile.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
@INCLUDE = ${CGAL_DOC_PACKAGE_DEFAULTS}

PROJECT_NAME = "CGAL ${CGAL_DOC_VERSION} - 2D Snap Rounding"

# custom options for this package
HIDE_UNDOC_CLASSES = true
WARN_IF_UNDOCUMENTED = false


INPUT += ${CGAL_PACKAGE_INCLUDE_DIR}/CGAL/Float_snap_rounding_2.h \
${CGAL_PACKAGE_INCLUDE_DIR}/CGAL/Float_snap_rounding_traits_2.h
8 changes: 8 additions & 0 deletions Snap_rounding_2/examples/Snap_rounding_2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,11 @@ file(
foreach(cppfile ${cppfiles})
create_single_source_cgal_program("${cppfile}")
endforeach()

find_package(TBB QUIET)
include(CGAL_TBB_support)
if(TARGET CGAL::TBB_support)
target_link_libraries(float_snap_rounding PRIVATE CGAL::TBB_support)
else()
message(STATUS "NOTICE: Intel TBB was not found. Sequential code will be used.")
endif()
68 changes: 68 additions & 0 deletions Snap_rounding_2/examples/Snap_rounding_2/float_snap_rounding.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Float_snap_rounding_2.h>
#include <CGAL/Arr_segment_traits_2.h>
#include <CGAL/Random.h>

typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
typedef CGAL::Exact_predicates_inexact_constructions_kernel Epick;
typedef Kernel::Segment_2 Segment_2;
typedef Kernel::Point_2 Point_2;
typedef Kernel::FT FT;
typedef std::vector<Point_2 > Polyline_2;

int main(int argc, char *argv[])
{
std::vector< Segment_2 > segs;

if(argc>1){
std::cout << "Read segments in " << argv[1] << std::endl;
std::ifstream in(argv[1]);

int n;
in >> n;
segs.reserve(n);
for (int i=0; i<n; ++i)
{
double x1,x2,y1,y2;
in >> x1 >> y1 >> x2 >> y2;
if(Point_2(x1,y1)!=Point_2(x2,y2))
segs.emplace_back(Point_2(x1, y1), Point_2(x2, y2));
}
} else {
//Example with a non-trivial rounding
FT e(std::pow(2, -60));

segs.emplace_back(Point_2(1-e, 1), Point_2(-1-e, -1+2*e));
segs.emplace_back(Point_2(e/2, e/2), Point_2(1, -1));
segs.emplace_back(Point_2(0, 2-e/2), Point_2(2, 0));
segs.emplace_back(Point_2(0, 2-e/2), Point_2(-2+e, -4));
segs.emplace_back(Point_2(-2, 2), Point_2(2, 2));
segs.emplace_back(Point_2(7, 7), Point_2(7+e, 7+e));
segs.emplace_back(Point_2(5, 7-e), Point_2(9, 7-e));
}

std::cout << "Computes the intersections and snaps the segments" << std::endl;
std::vector< Segment_2> out;
CGAL::compute_snapped_subcurves_2(segs.begin(), segs.end(), std::back_inserter(out));
std::cout << "Does the output intersect: " << CGAL::do_curves_intersect(out.begin(), out.end()) << std::endl;
std::cout << "Size of the output: " << out.size() << std::endl;

std::string out_path=(argc>2)?argv[2]:"out.segs";
std::cout << "Write the outputs in " << out_path << std::endl;
std::ofstream outf(out_path);
CGAL::Random r;

outf << std::setprecision(17);
outf << out.size() << std::endl;
for (auto &seg: out)
{
double x1 = CGAL::to_double(seg.source().x());
double y1 = CGAL::to_double(seg.source().y());
double x2 = CGAL::to_double(seg.target().x());
double y2 = CGAL::to_double(seg.target().y());
outf << x1 << " " << y1 << " " << x2 << " " << y2 << std::endl;
}

return 0;
}
Loading
Loading