-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Nef_3: Fix ID_support_handler logic error #9478
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
GilesBathgate
wants to merge
1
commit into
CGAL:main
Choose a base branch
from
GilesBathgate:Nef_3-fix_id_support_handler-GilesBathgate
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.
+96
−3
Open
Changes from all commits
Commits
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| #include <CGAL/Exact_predicates_exact_constructions_kernel.h> | ||
| #include <CGAL/Nef_3/SNC_indexed_items.h> | ||
| #include <CGAL/Nef_3/SNC_structure.h> | ||
| #include <CGAL/Nef_3/SNC_decorator.h> | ||
| #include <CGAL/Nef_3/ID_support_handler.h> | ||
| #include <cassert> | ||
|
|
||
| typedef CGAL::Exact_predicates_exact_constructions_kernel K; | ||
| typedef CGAL::SNC_indexed_items Items; | ||
| typedef CGAL::SNC_structure<K, Items, bool> SNC_structure; | ||
| typedef CGAL::SNC_decorator<SNC_structure> SNC_decorator; | ||
| typedef CGAL::SM_decorator<SNC_structure::Sphere_map> SM_decorator; | ||
| typedef CGAL::ID_support_handler<Items, SNC_decorator> ID_support_handler; | ||
|
|
||
| typedef SNC_structure::Vertex_handle Vertex_handle; | ||
| typedef SNC_structure::SHalfedge_handle SHalfedge_handle; | ||
| typedef SNC_structure::SHalfloop_handle SHalfloop_handle; | ||
| typedef SNC_structure::Sphere_circle Sphere_circle; | ||
|
|
||
| void run_test_case(int fw_id1, int bw_id1, int fw_id2, int bw_id2, bool test_loop) { | ||
| ID_support_handler handler; | ||
|
|
||
| handler.initialize_hash(fw_id1); | ||
| handler.initialize_hash(bw_id1); | ||
| handler.initialize_hash(fw_id2); | ||
| handler.initialize_hash(bw_id2); | ||
|
|
||
| SNC_structure snc; | ||
| Vertex_handle v = snc.new_vertex(); | ||
| SM_decorator SD(&*v); | ||
|
|
||
| SHalfedge_handle se = SD.new_shalfedge_pair(); | ||
| se->circle() = Sphere_circle(1,0,0); | ||
| se->twin()->circle() = se->circle().opposite(); | ||
|
|
||
| SHalfedge_handle se1 = SD.new_shalfedge_pair(); | ||
| se1->set_forward_index(fw_id1); | ||
| se1->set_backward_index(bw_id1); | ||
| se1->twin()->set_forward_index(bw_id1); | ||
| se1->twin()->set_backward_index(fw_id1); | ||
| se1->circle() = se->circle(); | ||
| se1->twin()->circle() = se->circle().opposite(); | ||
|
|
||
| if (test_loop) { | ||
|
|
||
| SHalfloop_handle sl2 = SD.new_shalfloop_pair(); | ||
| sl2->circle() = se->circle(); | ||
| sl2->twin()->circle() = se->circle().opposite(); | ||
| sl2->set_index(fw_id2); | ||
| sl2->twin()->set_index(bw_id2); | ||
|
|
||
| handler.handle_support(se, se1, sl2); | ||
|
|
||
| // fw_id1 is merged with fw_id2 | ||
| assert(handler.get_hash(fw_id1) == handler.get_hash(fw_id2)); | ||
|
|
||
| // bw_id1 is merged with bw_id2 | ||
| assert(handler.get_hash(bw_id1) == handler.get_hash(bw_id2)); | ||
| } else { | ||
|
|
||
| SHalfedge_handle se2 = SD.new_shalfedge_pair(); | ||
| se2->set_forward_index(fw_id2); | ||
| se2->set_backward_index(bw_id2); | ||
| se2->twin()->set_forward_index(bw_id2); | ||
| se2->twin()->set_backward_index(fw_id2); | ||
| se2->circle() = se->circle(); | ||
| se2->twin()->circle() = se->circle().opposite(); | ||
|
|
||
| handler.handle_support(se, se1, se2); | ||
|
|
||
| // fw_id1 is merged with fw_id2 | ||
| assert(handler.get_hash(fw_id1) == handler.get_hash(fw_id2)); | ||
|
|
||
| // bw_id1 is merged with bw_id2 | ||
| assert(handler.get_hash(bw_id1) == handler.get_hash(bw_id2)); | ||
| } | ||
| } | ||
|
|
||
| int main() { | ||
| const int id1 = 10; | ||
| const int id2 = 11; | ||
|
|
||
| const int id3 = 20; | ||
| const int id4 = 21; | ||
|
|
||
| // edge-edge | ||
| run_test_case(id1, id2, id3, id4, false); | ||
| run_test_case(id3, id4, id1, id2, false); | ||
|
|
||
| // edge-loop | ||
| run_test_case(id1, id2, id3, id4, true); | ||
| run_test_case(id3, id4, id1, id2, true); | ||
|
|
||
| return 0; | ||
| } | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@afabri The test case is already added. As mentioned in the summary, the test fails without the fix applied.