mirror of https://github.com/CGAL/cgal
Merge pull request #2944 from sloriot/PMP-coref_coplanar_fix
Fix a coplanar triangle intersection
This commit is contained in:
commit
45d2b95202
|
|
@ -79,7 +79,7 @@ struct Intersect_coplanar_faces_3{
|
|||
//constructor for intersection of edges. prev and curr are two points on an edge of the first facet (preserving the
|
||||
//orientation of the facet). This edge is intersected by h2 from the second facet.
|
||||
//
|
||||
//The rational is the following: we first check whether curr and prev are on the same edge. I so we create
|
||||
//The rational is the following: we first check whether curr and prev are on the same edge. If so we create
|
||||
//an intersection point between two edges. Otherwise, the point is a vertex of the second facet included into
|
||||
//the first facet.
|
||||
//
|
||||
|
|
@ -102,9 +102,25 @@ struct Intersect_coplanar_faces_3{
|
|||
res.info_2=h2;
|
||||
|
||||
if (ipt_prev.type_1==ON_VERTEX && next(ipt_prev.info_1, tm1) == ipt_curr.info_1){
|
||||
CGAL_assertion(ipt_curr.type_1!=ON_FACE);
|
||||
res.type_1=ON_EDGE;
|
||||
res.info_1=ipt_curr.info_1;
|
||||
if(ipt_curr.type_1!=ON_FACE)
|
||||
{
|
||||
res.type_1=ON_EDGE;
|
||||
res.info_1=ipt_curr.info_1;
|
||||
}
|
||||
else
|
||||
{
|
||||
CGAL_assertion( ipt_curr.type_2==ON_VERTEX);
|
||||
res.type_1=ON_FACE;
|
||||
res.info_1=h1;
|
||||
res.type_2=ON_VERTEX;
|
||||
typename Exact_kernel::Collinear_3 is_collinear = Exact_kernel().collinear_3_object();
|
||||
if ( !is_collinear(ipt_prev.point,ipt_curr.point,to_exact(get(vpm2,target(res.info_2,tm2)) ) ) ){
|
||||
res.info_2=prev(res.info_2,tm2);
|
||||
CGAL_assertion( is_collinear(ipt_prev.point,ipt_curr.point,to_exact(get(vpm2,target(res.info_2,tm2))) ) );
|
||||
}
|
||||
res.point = to_exact( get(vpm2, target(res.info_2,tm2)) );
|
||||
return res;
|
||||
}
|
||||
}
|
||||
else{
|
||||
if(ipt_curr.type_1==ON_VERTEX && ipt_prev.info_1 == ipt_curr.info_1){
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
OFF
|
||||
3 1 0
|
||||
0 5310 100
|
||||
0 5400 100
|
||||
0 5310 150
|
||||
3 0 2 1
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
OFF
|
||||
3 1 0
|
||||
0 5375 105
|
||||
0 5350 110
|
||||
0 5375 110
|
||||
3 1 2 0
|
||||
|
|
@ -64,6 +64,7 @@ data-coref/coplanar_triangles/all_cases/deg/tr15-1.off data-coref/coplanar_trian
|
|||
data-coref/coplanar_triangles/all_cases/deg/tr16-1.off data-coref/coplanar_triangles/all_cases/deg/tr16-2.off
|
||||
data-coref/coplanar_triangles/all_cases/deg/tr17-1.off data-coref/coplanar_triangles/all_cases/deg/tr17-2.off
|
||||
data-coref/coplanar_triangles/all_cases/bugreport/tr1-1.off data-coref/coplanar_triangles/all_cases/bugreport/tr1-2.off
|
||||
data-coref/coplanar_triangles/all_cases/bugreport/tr2-1.off data-coref/coplanar_triangles/all_cases/bugreport/tr2-2.off
|
||||
data-coref/coplanar_triangles/all_cases/tr1-1.off data-coref/coplanar_triangles/all_cases/tr1-2.off
|
||||
data-coref/coplanar_triangles/all_cases/tr2-1.off data-coref/coplanar_triangles/all_cases/tr2-2.off
|
||||
data-coref/coplanar_triangles/all_cases/tr3-1.off data-coref/coplanar_triangles/all_cases/tr3-2.off
|
||||
|
|
|
|||
|
|
@ -10,42 +10,48 @@ typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
|
|||
typedef CGAL::Surface_mesh<K::Point_3> Surface_mesh;
|
||||
typedef CGAL::Polyhedron_3<K> Polyhedron_3;
|
||||
|
||||
|
||||
void test(const char* f1, const char* f2)
|
||||
{
|
||||
std::cout << "Corefining " << f1
|
||||
<< " and " << f2 << "\n";
|
||||
|
||||
std::cout << " with Surface_mesh\n";
|
||||
Surface_mesh sm1, sm2;
|
||||
std::ifstream input(f1);
|
||||
assert(input);
|
||||
input >> sm1;
|
||||
input.close();
|
||||
input.open(f2);
|
||||
assert(input);
|
||||
input >> sm2;
|
||||
input.close();
|
||||
|
||||
CGAL::Polygon_mesh_processing::corefine(sm1, sm2);
|
||||
|
||||
assert(sm1.is_valid());
|
||||
assert(sm2.is_valid());
|
||||
|
||||
std::cout << " with Polyhedron_3\n";
|
||||
Polyhedron_3 P, Q;
|
||||
input.open(f1);
|
||||
assert(input);
|
||||
input >> P;
|
||||
input.close();
|
||||
input.open(f2);
|
||||
assert(input);
|
||||
input >> Q;
|
||||
|
||||
CGAL::Polygon_mesh_processing::corefine(P, Q);
|
||||
|
||||
assert(P.is_valid());
|
||||
assert(Q.is_valid());
|
||||
}
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
for(int i=0; i< (argc-1)/2;++i)
|
||||
{
|
||||
std::cout << "Corefining " << argv[2*i+1]
|
||||
<< " and " << argv[2*(i+1)] << "\n";
|
||||
|
||||
std::cout << " with Surface_mesh\n";
|
||||
Surface_mesh sm1, sm2;
|
||||
std::ifstream input(argv[2*i+1]);
|
||||
assert(input);
|
||||
input >> sm1;
|
||||
input.close();
|
||||
input.open(argv[2*(i+1)]);
|
||||
assert(input);
|
||||
input >> sm2;
|
||||
input.close();
|
||||
|
||||
CGAL::Polygon_mesh_processing::corefine(sm1, sm2);
|
||||
|
||||
assert(sm1.is_valid());
|
||||
assert(sm2.is_valid());
|
||||
|
||||
std::cout << " with Polyhedron_3\n";
|
||||
Polyhedron_3 P, Q;
|
||||
input.open(argv[2*i+1]);
|
||||
assert(input);
|
||||
input >> P;
|
||||
input.close();
|
||||
input.open(argv[2*(i+1)]);
|
||||
assert(input);
|
||||
input >> Q;
|
||||
|
||||
CGAL::Polygon_mesh_processing::corefine(P, Q);
|
||||
|
||||
assert(P.is_valid());
|
||||
assert(Q.is_valid());
|
||||
test(argv[2*i+1], argv[2*(i+1)]);
|
||||
test(argv[2*(i+1)], argv[2*i+1]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue