Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Intersections

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Intersections


Chronological Thread 
  • From: Sebastien Loriot <>
  • To:
  • Subject: Re: [cgal-discuss] Intersections
  • Date: Tue, 9 May 2023 09:07:49 +0200
  • Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None ; spf=Pass ; spf=None
  • Ironport-data: A9a23:ZpmTfK0enm1gPIBrd/bD5Rp1kn2cJEfYwER7XKvMYLTBsI5bp2MGm mdODWGGaKuNYWShf413aty0/EMBvpLcmtZmSgQ53Hw8FHgiRejtVY3IdB+oV8+xBpSeFxw/t 512hv3odp1coqr0/0/1WlTZhSAgk/vOHNIQMcacUghpXwhoVSw9vhxqnu89k+ZAjMOwa++3k YqaT/b3ZRn0ilaYDkpOs/jY8E437ayr0N8llgVWic5j7Ae2e0Y9V8p3yZGZdxPQXoRSF+imc OfPpJnRErTxon/Bovv8+lrKWhViroz6ZWBiuVIKM0SWuSWukwRpukoN2FXwXm8M49mBt4gZJ NygLvVcQy9xVkHHsLx1vxW1j0iSlECJkVPKCSHXjCCd86HJW371hKk0V10rBLVb1b0wAWFwq 8wXcwlYO3hvh8ruqF66Yuxlh8BmM8yyeY1D4zdvyjbWCftgSpfGK0nIzYUAjXFg24YXR6aYO 5NxhTlHNHwsZzVUPlANCZUi2uKsrnb6ejxc7lmSoMLb5kCOkVAuiuC0aLI5fPSPbuBolFSY+ 1nBoXSgIjo7Bv/B8BmspyfEaujnxHunAur+DoaQ/fFjhBifx3cYFQYNfUCqpOGwzE+4QdNWb UIOkhfCtoA3/U2vC8b4Bli2/CfCsRkbVN5dVeY97Wlh15Y4/S6cHy9YFGVddeUe9+BtAjwq6 AG5kIjQUGkHXKKudVqR8bKdrDWXMCcTLHMfaSJscefjy4mzyG3UpkKeJuuPAJJZnfWuRm6tm 2HiQDwWwuRM3ZRShs1X6Hie22r0zqUlWDLZ8ek+Y45IxgZwZYrgeInxrFaHtLBPK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Sc6zFHkPRWZZGpSgzN2fcQW1I+Xl6C3I2ggfrNlrr73gUGvq52 BUxj1kmCdk=
  • Ironport-sdr: 6459f147_f3zWx4gVLJ6Cf6Qn6qhOy1fSe3IUmyj1qKrazhxAJ+fBgJa FGq0QyzonFm0y2/SPix1Rd5rlDgEex/LNRkkQRw==

Iterate over all the vertices of the c3t3 and compute the orientation with reference to the place and store the output in a hash mesh.

I don't know what output you want, if a polygon soup is enough then
simply iterate over all cells in the complex and look at all the edges
of the cell. If for an edge the orientation of endpoints are different
then it means you have an intersection point. Collecting all the
intersection points, you can get the intersection polygon with that
cell.

I don't think the AABB-tree is needed (except if you have a lot of planes maybe).

HTH,

Sebastien.

On 4/28/23 15:58, Maria Eduarda Veras Martins ( via cgal-discuss Mailing List) wrote:
I'm a little new with CGAL, do you have a link where I can study this suggestion?
Thanks

Em sex., 28 de abr. de 2023 às 04:41, "Sebastien Loriot (GeometryFactory)" < <>> escreveu:

I think the fastest solution is to do your intersection tests on the
set
of segments that is incident to a facet in the complex. That way you
don't compute too much.

It might need to be benchmarked but if you pre-compute in parallel the
position each vertex incident to that set of segments with reference
to the plane, then plane segment intersection predicate could be written
based on that precomputed orientation and no duplicated computation will
be done.

Best,

Sebastien.


On 4/27/23 22:58, Maria Eduarda Veras Martins (
<> via
cgal-discuss Mailing List) wrote:
> Hi!
> I need to intersect several planes with a volumetric mesh. I'm
making an
> aabb tree with the faces of the tetrahedron but I don't know how to
> efficiently intersect the planes.
> Here is my code so far (only one plane):
>
> #include<list>
> #include<CGAL/AABB_tree.h>
> #include<CGAL/AABB_traits.h>
> #include<CGAL/AABB_triangle_primitive.h>
> #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/Implicit_mesh_domain_3.h>
> #include<CGAL/make_mesh_3.h>
> #include<CGAL/iterator.h>
> #include<iostream>
> #include<fstream>
> #include<map>
> #include<vector>
> #include<string>
> #include<CGAL/utility.h>
>
> // Domain
> struct K: public
CGAL::Exact_predicates_inexact_constructions_kernel {};
> typedef K::FT FT;
> typedef K::Point_3 Point;
> typedef FT (Function)(const Point&);
> typedef CGAL::Implicit_mesh_domain_3<Function,K> Mesh_domain;
>
> // Triangulation
> typedef CGAL::Mesh_triangulation_3<Mesh_domain>::type Tr;
> typedef CGAL::Mesh_complex_3_in_triangulation_3<Tr> C3t3;
>
> // Criteria
> typedef CGAL::Mesh_criteria_3<Tr> Mesh_criteria;
> typedef Mesh_criteria::Facet_criteria Facet_criteria;
> typedef Mesh_criteria::Cell_criteria Cell_criteria;
>
> typedef C3t3::Triangulation Tr;
> typedef C3t3::Cell_handle Cell_handle;
> typedef Tr::Facet Facet;
> typedef Tr::Finite_facets_iterator Finite_facets_iterator;
> typedef Tr::Finite_vertices_iterator Finite_vertices_iterator;
> typedef Tr::Finite_cells_iterator Finite_cells_iterator;
> typedef Tr::Vertex_handle Vertex_handle;
>
>
> typedef K::Plane_3 Plane;
> typedef K::Line_3 Line;
> typedef K::Direction_3 Direction;
> typedef K::Triangle_3 Triangle;
> typedef K::Segment_3 Segment;
> typedef std::list<Triangle>::iterator Iterator;
> typedef CGAL::AABB_triangle_primitive<K,Iterator> Primitive;
> typedef CGAL::AABB_traits<K, Primitive> AABB_triangle_traits;
> typedef CGAL::AABB_tree<AABB_triangle_traits> Tree;
> typedef Tree::Object_and_primitive_id Object_and_primitive_id;
> typedef Tree::Primitive_id Primitive_id;
>
> // Function
> FT sphere_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();
>
> return x2+y2+z2-1;
> }
>
> int main() {
> // Domain
> Mesh_domain domain(sphere_function, K::Sphere_3(CGAL::ORIGIN, 1.));
>
> // Criteria
> Facet_criteria facet_criteria(30, 0.1, 0.01);// angle, size,
approximation
> Cell_criteria cell_criteria(3, 0.1);// radius-edge ratio, size
> Mesh_criteria criteria(facet_criteria, cell_criteria);
>
> // Mesh generation
> C3t3 c3t3 = CGAL::make_mesh_3<C3t3>(domain, criteria);
>
> // Output
> std::ofstream medit_file("outmatrix.mesh");
> c3t3.output_to_medit(medit_file);
>
> //std::cout<< "Number of verticesDT"<<" "<<
> c3t3.triangulation().number_of_vertices() << std::endl;
> //std::cout<< "Number of facetsDT"<<" "<<
> c3t3.triangulation().number_of_finite_facets() << std::endl;
> //std::cout<< "Number of facetsC3T3"<<"
"<<c3t3.number_of_facets() <<
> std::endl;
> //std::cout<< "Number of cellsC3T3"<<" "<<c3t3.number_of_cells() <<
> std::endl;
> //std::cout<< "Number of cellsDT"<<"
> "<<c3t3.triangulation().number_of_finite_cells() << std::endl;
>
>
> // for each facet build a triangle
> std::list<Triangle> triangles;
> for(Finite_facets_iterator fi =
> c3t3.triangulation().finite_facets_begin(); fi !=
> c3t3.triangulation().finite_facets_end(); fi++) {
>
> Cell_handle cell = fi->first;
> int opposite_vertex_index = fi->second;
> if(c3t3.is_in_complex(cell)) {
> Triangle t=c3t3.triangulation().triangle(cell,opposite_vertex_index);
> triangles.push_back(t);
> }
> else if (c3t3.is_in_complex(*fi)) {
> Triangle t=c3t3.triangulation().triangle(*fi);
> triangles.push_back(t);
> }
>
> }
>
> Tree tree(triangles.begin(),triangles.end());
>
> // set plane and count intersections
> Point p(0, 0, 0);
> Plane plane(p, K::Vector_3(1, 0, 0));
>
> std::list <Object_and_primitive_id> intersections;
> tree.all_intersections(plane, std::back_inserter(intersections));
>
> //how to do it with many planes?
> //I'm thinking of looping the plans, but I wanted something more
efficient
>
>
> return 0;
> }
>
> --
> You are currently subscribed to cgal-discuss.
> To unsubscribe or access the archives, go to
> https://sympa.inria.fr/sympa/info/cgal-discuss
<https://sympa.inria.fr/sympa/info/cgal-discuss>
>

-- You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss
<https://sympa.inria.fr/sympa/info/cgal-discuss>



--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss



  • Re: [cgal-discuss] Intersections, Sebastien Loriot, 05/09/2023

Archive powered by MHonArc 2.6.19+.

Top of Page