mirror of https://github.com/CGAL/cgal
handle cases when plane contains an edge
This commit is contained in:
parent
38142dc101
commit
231e9f1b93
|
|
@ -97,6 +97,19 @@ intersection(
|
||||||
|
|
||||||
std::vector<std::array<int,2>> neighbor_ids(14, {-1,-1});
|
std::vector<std::array<int,2>> neighbor_ids(14, {-1,-1});
|
||||||
|
|
||||||
|
auto add_neighbor = [&neighbor_ids](int i, int j)
|
||||||
|
{
|
||||||
|
if (neighbor_ids[i][0] == -1 ) {
|
||||||
|
neighbor_ids[i][0] = j;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (neighbor_ids[i][0]!=j && neighbor_ids[i][1]==-1)
|
||||||
|
{
|
||||||
|
neighbor_ids[i][1] = j;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
int start_id = -1;
|
int start_id = -1;
|
||||||
int solo_id = -1;
|
int solo_id = -1;
|
||||||
// for each face of the bbox, we look for intersection of the plane with its edges
|
// for each face of the bbox, we look for intersection of the plane with its edges
|
||||||
|
|
@ -155,18 +168,8 @@ intersection(
|
||||||
case 2:
|
case 2:
|
||||||
{
|
{
|
||||||
if (start_id == -1) start_id = ids[0];
|
if (start_id == -1) start_id = ids[0];
|
||||||
if (neighbor_ids[ids[0]][0] == -1) {
|
add_neighbor(ids[0], ids[1]);
|
||||||
neighbor_ids[ids[0]][0] = ids[1];
|
add_neighbor(ids[1], ids[0]);
|
||||||
}
|
|
||||||
else {
|
|
||||||
neighbor_ids[ids[0]][1] = ids[1];
|
|
||||||
}
|
|
||||||
if (neighbor_ids[ids[1]][0] == -1) {
|
|
||||||
neighbor_ids[ids[1]][0] = ids[0];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
neighbor_ids[ids[1]][1] = ids[0];
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 1:
|
case 1:
|
||||||
|
|
|
||||||
|
|
@ -907,7 +907,7 @@ struct Test {
|
||||||
|
|
||||||
//edge
|
//edge
|
||||||
check_intersection (cub, Pl(P(1,1,1), P(1,2,1), P(1.5,0,0)),
|
check_intersection (cub, Pl(P(1,1,1), P(1,2,1), P(1.5,0,0)),
|
||||||
S(P(1,2,1), P(1,1,1)));
|
S(P(1,1,1), P(1,2,1)));
|
||||||
|
|
||||||
|
|
||||||
//face
|
//face
|
||||||
|
|
@ -924,6 +924,7 @@ struct Test {
|
||||||
assert(p.x() == 1);
|
assert(p.x() == 1);
|
||||||
}
|
}
|
||||||
res = CGAL::intersection(cub, Pl(P(1,1,1), P(1,2,1), P(2,2,2)));
|
res = CGAL::intersection(cub, Pl(P(1,1,1), P(1,2,1), P(2,2,2)));
|
||||||
|
|
||||||
poly = boost::get<std::vector<P> >(&*res);
|
poly = boost::get<std::vector<P> >(&*res);
|
||||||
assert(poly != nullptr);
|
assert(poly != nullptr);
|
||||||
assert(poly->size() == 4);
|
assert(poly->size() == 4);
|
||||||
|
|
@ -940,8 +941,8 @@ struct Test {
|
||||||
check_intersection (cub, Pl(P(2, 1.66, 2),
|
check_intersection (cub, Pl(P(2, 1.66, 2),
|
||||||
P(1.66,2,2),
|
P(1.66,2,2),
|
||||||
P(2,2,1.66)),
|
P(2,2,1.66)),
|
||||||
Tr(P(2, 2, 1.66),
|
Tr(P(1.66,2,2),
|
||||||
P(1.66,2,2),
|
P(2, 2, 1.66),
|
||||||
P(2,1.66,2)));
|
P(2,1.66,2)));
|
||||||
|
|
||||||
//other edge
|
//other edge
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue