-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Add Float 2d snap rounding #8797
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
LeoValque
wants to merge
47
commits into
CGAL:main
Choose a base branch
from
LeoValque:Float_2D_snap-GF
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
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 012ec64
transform to same API as existing snap_rounding, remove duplicate, ef…
LeoValque d229e9f
Test of float snap rounding 2 and intense debug
LeoValque 78b935d
Box_with_index has known explicit ID
LeoValque a35acd9
remove blank line unvolontary added to Subcruves_visitor
LeoValque ad3bde0
some cleaning
LeoValque 717cd99
delete specific test from data
LeoValque 1672576
hide include iostream behind debug macro
LeoValque 829aba2
remove unused specialization of BOx_with_index
LeoValque c9df11e
replace size_t per std::size_t
LeoValque 4a61d4b
add a reserve in the iteration of the snap
LeoValque cf25df0
Write float_snap_rounding_traits
LeoValque 4f89066
add round in the traits
LeoValque 0968471
Improve running time of compute_snap_rounding_2
LeoValque 9f7f000
float_snap_rounding example
LeoValque 39d3ade
rewrite test of Float_snap_rounding_2
LeoValque 64922a6
Clean Float_2D_snap
LeoValque c380ad2
Snap of polygons
LeoValque 443ed48
NamedParameter
LeoValque 3df3151
Rewrite float_snap_rounding example
LeoValque cfa69d0
Reintroduce flag NO_TESTING to test_snap_rounding_2
LeoValque e8ea281
Use a one way scan instead of box_intersection_d
LeoValque 134330e
bounding box filter and combinatorial to test to improve running time
LeoValque f82659b
cleaning and optimize Float_2D_snap
LeoValque 92fd905
cleaning Float_snap_rounding.h
LeoValque 58caea2
More cleaning of Float_snap_rounding_2
LeoValque ec7b77b
Enhance documentation of FLoat snap rounding 2
LeoValque fc83e54
change reference
LeoValque 6918848
Fix error of the testsuite
LeoValque ec71e01
Fix documentation
LeoValque cb5893a
Fix documentation
LeoValque 92807e9
Add a test with differents Kernels
LeoValque 803ef35
Fix the example
LeoValque 19c832b
Some additional test
LeoValque 422338c
clean test
LeoValque e63869e
Solved invalid iterator after erased with MSVC
LeoValque b0388e4
Fix dangling reference warning of the testsuite
LeoValque 4a2ebc5
workaround issue with MSVC2017
sloriot e7fe2e7
push the constexpr back
sloriot 4c5b917
Use Simple_cartesian instead of Cartesian
LeoValque eec0ae3
Forget that do_curves_intersect does not work with EPICK
LeoValque 14aba48
First path on the review
LeoValque acec954
Apply suggestions of the review
LeoValque b80ce2f
Fix error on MSVC
LeoValque 161507b
Fix doc
LeoValque a8bbddf
add license
sloriot a8b60b5
tabs
sloriot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
228 changes: 228 additions & 0 deletions
228
Snap_rounding_2/doc/Snap_rounding_2/Concepts/FloatSnapRoundingTraits_2.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. | ||
LeoValque marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 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; | ||
LeoValque marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| /*! | ||
| Models the concept `FSRTraits_2::SquaredRoundBound_2`. | ||
LeoValque marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| */ | ||
| typedef unspecified_type Squared_round_bound_2; | ||
LeoValque marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| /*! | ||
| 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 */ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
Snap_rounding_2/examples/Snap_rounding_2/float_snap_rounding.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.