Subject: CGAL users discussion list
List archive
- From: "Sebastien Loriot (GeometryFactory)" <>
- To:
- Subject: Re: [cgal-discuss] Problems with Sharp Features in 3d Mesh Generation
- Date: Tue, 8 Sep 2020 09:18:11 +0200
- Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None ; spf=Pass ; spf=None
- Ironport-phdr: 9a23:0OIgRB/kSydfNP9uRHKM819IXTAuvvDOBiVQ1KB22ukcTK2v8tzYMVDF4r011RmVBNudsqgYwLqP+4nbGkU4qa6bt34DdJEeHzQksu4x2zIaPcieFEfgJ+TrZSFpVO5LVVti4m3peRMNQJW2aFLduGC94iAPERvjKwV1Ov71GonPhMiryuy+4ZLebxhJiTanfL9+Mhq7oQrSu8ULnIBvNrs/xhzVr3VSZu9Y33loJVWdnxb94se/4ptu+DlOtvwi6sBNT7z0c7w3QrJEAjsmNXs15NDwuhnYUQSP/HocXX4InRdOHgPI8Qv1Xpb1siv9q+p9xCyXNtD4QLwoRTiv6bpgRRn1gykFKjE56nnahNFugqJVoByvpBJxzIDbb46XKPVzZabdcc8ASGdbQspcWS5MD4WhZIUPFeoBOuNYopHzq1UTsxSxHhOjBPjzyj9JmHD227Ax3eImEQHc3QwgGM4Ou2nQoNv0KqgSVuW1w7fUzTXZb/JY2S3y55TUchAmu/GNXbd8fcTMwkQoDAPFilKQqZbkPzOSyuQBqW2b7+57WOKgjm4osQBxojy1ysgwjYnJg5sYx1bZ/ip23Ig7P8e3SFJnYdG6CptQsTmXO5d5T888QWxlpSk3xL0atJOmfCYG1ZYqywDcZvGDc4WE/w/vWfiMLTp4hHxod7GyiRmv/UW81+DxSMa63lZJoydDj9LCuHcN1xnJ5ciGTPtw5kGh1iyU2A/I7uFLP1o4mrbcK54kxLM7i5kdsVzbEyPohEn7iLWae0Yk9+Sy9ujrfLbrqoWTOoJ7kg3yLL4hltCiDek9LAcCQ3KU9OGi2LH/4EH0RbtHgeconqXFtZ3WO8cWq62lDAJQ3Yss8QywAjOj3dgFk3QKL0hKdReJj4XrOVzDIvb1BuqljVu2ijdk3fXGM6XhAprTKnjDl6/sfbNn5E5dzAo/1N5e55dJBr0YLvL+VUD8uMbXDh8+NAy0zOLnB8tn2owCXmKPB7eVMKLUsVCW+uIiO/eAaJMRtTrnKPUo5+TigWInlVIeZ6Wk0pQaZGi9Hvt8IkWZZXTsgs0GEWcPpgc+V+jqiFqYUT5SYHayQ7gw5jQ/CI+9AofDQ5qigL2F3CuhApJWYWVGBkiWEXj0b4WER+sMaCWKL8B9nTwLT7yhR5Y82hGvrw/116dnLvHP+iADrpLi1N115/XJmh0o9Dx0Cd6d02CXQG1ukGMIXWx+4KcqqkN0zhKP0LNznudDPd1V/fJAFAkgZrDGyOkvQev/UAvaYtaETh6CRc+nBi15Dv08xNoDf1xsNdypkhfZzmvgS+sOk7uRBZsotKfY93f0Lsd5jX3B0f9y3BEdXsJTODj+1eZE/A/JCtuRyhTLp+ORba0ZmRX12iKGxGuKsltfVVcpA6rAVHEbIEDRqIagvx6Qf/qVEb0idzB554uCJ69NMIC7iFxHQLL8PY2bbT7t3Wi3AhmMy/WHa4+4IzxBjhWYM1ANlkUoxVjDLRI3X37zrGfXDTgoHlXqMRvh
Except if I made a mistake dumping your polylines, they are not what you expect them to be as you can see in the attached screenshot. If you have 2 very close (or identical polylines) then the protection algorithm will
try to seperate them which is not possible.
Could you please check them?
Thanks,
Sebastien.
PS: Code used to dump them in a format readable by CGAL the polyhedron demo
int ggg=0;
for (auto p : polylines)
{
std::ofstream outpol("poly_"+std::to_string(ggg)+".polylines.txt");
outpol << p.size();
for (auto oo : p)
outpol << " " << oo;
outpol << "\n";
++ggg;
}
On 9/7/20 10:04 AM, MariusZeinhofer wrote:
Of course.
And thank you very much for your help!
Cheers Marius
#include <vector>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Mesh_triangulation_3.h>
#include <CGAL/Mesh_complex_3_in_triangulation_3.h>
#include <CGAL/Mesh_criteria_3.h>
#include <CGAL/Labeled_mesh_domain_3.h>
#include <CGAL/Mesh_domain_with_polyline_features_3.h>
#include <CGAL/make_mesh_3.h>
#include <cmath>
// Kernel
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
// Domain
typedef K::FT FT;
typedef K::Point_3 Point;
typedef FT(Function)(const Point&);
typedef
CGAL::Mesh_domain_with_polyline_features_3<CGAL::Labeled_mesh_domain_3<K>
Mesh_domain;
// Polyline
typedef std::vector<Point> Polyline_3;
typedef std::list<Polyline_3> Polylines;
#ifdef CGAL_CONCURRENT_MESH_3
typedef CGAL::Parallel_tag Concurrency_tag;
#else
typedef CGAL::Sequential_tag Concurrency_tag;
#endif
// Triangulation
typedef CGAL::Mesh_triangulation_3<Mesh_domain, CGAL::Default,
Concurrency_tag>::type Tr;
typedef CGAL::Mesh_complex_3_in_triangulation_3<Tr,
Mesh_domain::Corner_index, Mesh_domain::Curve_index> C3t3;
// Criteria
typedef CGAL::Mesh_criteria_3
Mesh_criteria;
// To avoid verbose function and named parameters call
using namespace CGAL::parameters;
// Functions
// describes cylinder: \{ (x,y,z) \in \mathbb{R}^3 \mid |(y,z)|_euclid <=
10, -15 <= x <= 15 \}
FT cylinder_function(const Point& p)
{
const FT x2 = p.x() * p.x();
const FT y2 = p.y() * p.y();
const FT z2 = p.z() * p.z();
FT aux = y2 + z2 - 100;
if (p.x() > 15 && aux < 0)
aux = -aux;
if (p.x() < -15 && aux < 0)
aux = -aux;
return aux;
}
// section of cylinder of larger radius: \{ (x,y,z) \in \mathbb{R}^3 \mid
|(y,z)|_euclid <= 12, -15 <= x <= 15, angle in (y,z) plane between 0 and
\pi/6 \}
FT cylinder_section_function(const Point& p)
{
const FT x2 = p.x() * p.x();
const FT y2 = p.y() * p.y();
const FT z2 = p.z() * p.z();
FT aux = y2 + z2 - 144;
if (p.x() > 15 && aux < 0)
aux = -aux;
if (p.x() < -15 && aux < 0)
aux = -aux;
if ( (aux < 0 && !(0 < std::atan(p.z() / p.y()) && std::atan(p.z() /
p.y())
< CGAL_PI / 6.) ) || p.y() < 0 || p.z() < 0 )
aux = 1;
return aux;
}
FT set_union(const Point& p)
{
if (cylinder_section_function(p) < 0 || cylinder_function(p) < 0)
return -1;
else
return 1;
}
int main(int argc, char* argv[])
{
//---------------------------------------------------------------------generate-.mesh-file-----------------------------------------------------------------------------------------------------------//
// Domain (Warning: Sphere_3 constructor uses squared radius !)
Mesh_domain domain =
Mesh_domain::create_implicit_mesh_domain(set_union,
K::Sphere_3(CGAL::ORIGIN, 400));
// Mesh criteria
Mesh_criteria criteria(edge_size = 0.29, facet_angle = 25, facet_size
=
0.3, cell_radius_edge_ratio = 3.5, cell_size = .5, facet_distance = 0.4);
// Create edge that we want to preserve
Polylines polylines;
//Polyline_3& polyline = polylines.front();
//Polyline_3& polyline2 = polylines.back();
Polyline_3 polyline;
Polyline_3 polyline2;
Polyline_3 polyline3;
Polyline_3 polyline4;
Polyline_3 polyline5;
Polyline_3 polyline6;
Polyline_3 polyline7;
Polyline_3 polyline8;
//top of cylinder
for (int i = 0; i < 360; ++i)
{
Point p(15.0, 10 * std::cos(i * CGAL_PI / 180), 10 *
std::sin(i * CGAL_PI
/ 360));
polyline.push_back(p);
}
polyline.push_back(polyline.front()); // close the line
polylines.push_back(polyline);
//bottom of cylinder
for (int i = 0; i < 360; ++i)
{
Point p(-15.0, 10 * std::cos(i * CGAL_PI / 180), 10 *
std::sin(i * CGAL_PI
/ 360));
polyline2.push_back(p);
}
polyline2.push_back(polyline2.front()); // close the line
polylines.push_back(polyline2);
//fixateur line: (-15 < x < 15, y = 12, z = 0)
for (int i = 0; i < 100; ++i)
{
Point p(-15.0 + i * (30.) / 99., 12., 0.);
polyline3.push_back(p);
}
polylines.push_back(polyline3);
//fixateur line: (-15 < x < 15, y = 10, z = 0)
for (int i = 0; i < 100; ++i)
{
Point p(-15.0 + i * ((30.) / 99.), 10., 0.);
polyline4.push_back(p);
}
polylines.push_back(polyline4);
//fixateur line: (-15 < x < 15, y = 12 * cos(pi/6), z = 12 *
sin(pi/6) )
for (int i = 0; i < 100; ++i)
{
Point p(-15.0 + i * ((30.) / 99.), 12 * std::cos(CGAL_PI /
6), 12 *
std::sin(CGAL_PI / 6));
polyline5.push_back(p);
}
polylines.push_back(polyline5);
//fixateur line: (-15 < x < 15, y = 10 * cos(pi/6), z = 10 *
sin(pi/6) )
for (int i = 0; i < 100; ++i)
{
Point p(-15.0 + i * ((30.) / 99.), 10 * std::cos(CGAL_PI /
6), 10 *
std::sin(CGAL_PI / 6));
polyline6.push_back(p);
}
polylines.push_back(polyline6);
//top of cylinder segment
for (int i = 0; i < 61; ++i)
{
Point p(15.0, 12. * std::cos(i * CGAL_PI / 360), 12. *
std::sin(i *
CGAL_PI / 360));
polyline7.push_back(p);
}
polylines.push_back(polyline7);
//bottom of cylinder segment
for (int i = 0; i < 61; ++i)
{
Point p(-15.0, 12. * std::cos(i * CGAL_PI / 360), 12. *
std::sin(i *
CGAL_PI / 360));
polyline8.push_back(p);
}
polylines.push_back(polyline8);
// Insert edge in domain
domain.add_features(polylines.begin(), polylines.end());
// Mesh generation without feature preservation
C3t3 c3t3 = CGAL::make_mesh_3<C3t3>(domain, criteria,
CGAL::parameters::no_features());
// Output
std::ofstream medit_file("out-no-protection.mesh");
c3t3.output_to_medit(medit_file);
medit_file.close();
c3t3.clear();
// Mesh generation with feature preservation
c3t3 = CGAL::make_mesh_3<C3t3>(domain, criteria);
// Output
medit_file.open("out.mesh");
c3t3.output_to_medit(medit_file);
medit_file.close();
return 0;
}
--
Sent from: http://cgal-discuss.949826.n4.nabble.com/
Attachment:
Screenshot from 2020-09-08 09-14-05.png
Description: PNG image
- [cgal-discuss] Problems with Sharp Features in 3d Mesh Generation, MariusZeinhofer, 09/07/2020
- Re: [cgal-discuss] Problems with Sharp Features in 3d Mesh Generation, Sebastien Loriot (GeometryFactory), 09/07/2020
- Re: [cgal-discuss] Problems with Sharp Features in 3d Mesh Generation, Andreas Fabri, 09/07/2020
- Re: [cgal-discuss] Problems with Sharp Features in 3d Mesh Generation, MariusZeinhofer, 09/07/2020
- Re: [cgal-discuss] Problems with Sharp Features in 3d Mesh Generation, Sebastien Loriot (GeometryFactory), 09/08/2020
- Re: [cgal-discuss] Problems with Sharp Features in 3d Mesh Generation, MariusZeinhofer, 09/08/2020
- Re: [cgal-discuss] Problems with Sharp Features in 3d Mesh Generation, Sebastien Loriot (GeometryFactory), 09/08/2020
- Re: [cgal-discuss] Problems with Sharp Features in 3d Mesh Generation, MariusZeinhofer, 09/08/2020
- Re: [cgal-discuss] Problems with Sharp Features in 3d Mesh Generation, Sebastien Loriot (GeometryFactory), 09/08/2020
- Re: [cgal-discuss] Problems with Sharp Features in 3d Mesh Generation, Sebastien Loriot (GeometryFactory), 09/07/2020
Archive powered by MHonArc 2.6.19+.