Subject: CGAL users discussion list
List archive
- From: Bruno Manganelli <>
- To:
- Subject: Re: [cgal-discuss] Subtracting spheres from a mesh
- Date: Sun, 25 Apr 2021 11:12:54 +0200
- Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None ; spf=Pass ; spf=None
- Ironport-hdrordr: A9a23:qicvxKwxz7azW5OfE5mvKrPxcuskLtp033Aq2lEZdDV+dMuEm8ey2MkKzBOcskdpZFgMu/ClfJOBT3TV6IJv7eAqV4uKcQH6tAKTXeRfxKT4xTmIIVydysd80uNaf7F6GJnMCzFB/KXHyS2ZN/pl/9Wd6qCvgo7lrktFaQ1xcalv40NYJ2+gYylLbTJLD5Y4C5aQj/Avz1GdUE8aYcihCn4OU/Krnb32vaj7ah0LDQNP0njosRqU7tfBYn6l9yZbfTcK5bs562DKn0jC+62/v5iApiP05iv86ZJZndek5/liIIi3isYTIijxkQrAXulccozHkjYyruSirGwvjcCJmRE9JM5+gkm/QkiF5SDg0QXhzzoigkWN9WOl
- Ironport-phdr: A9a23:PMKQnhUBRlCQ8uAreHxOnIExzKvV8KxMUjF92vIco4ILSbyq+tHYBGea288FpGHAUYiT0f9Yke2e6/mmBTVRp8zY7jtaINRlbFwssY0uhQsuAcqIWwXQDcXBSGgEJvlET0Jv5HqhMEJYS47UblzWpWCuv3ZJQk2sfQV6Kf7oFYHMks+5y/69+4HJYwVPmTGxfa5+IA+5oAnMssQam5VuJrswxxfGvndFePldyH91K16Ugxvy/Nq78oR58yRXtfIh9spAXrv/cq8lU7FWDykoPn4s6sHzuhbNUQWA5n0HUmULiRVIGBTK7Av7XpjqrCT3sPd21TSAMs33SbA0Ximi77tuRRT1hioLKyI1/WfKgcF2kalVog+upwZnzoHbboGaNvpwcK3ec90HW2ROQt1cWDZdDo6mdYYDE/YNMOReooLgp1UOtxy+BQy0Ce7y0D9Im3n23aon2OomCw7G2gMgEMgIsHvKqNX1MKYSWv2ywabT1zXDcvVW2TDn5IjNaB8hp/6MUqh0fMfR0kQvGAbFgU+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z+Ujp0kcvYq1w1PMypXZv9zJcbKeR0VdPbTSdtbj/P7TWLi/5+xX9Msbr
Thanks for all your dedication to help :)
I have tried your method, and indeed it works. However it is still fairly slow, taking around 70 s to process 761 spheres (on a ryzen 5 3600). Do you think there are any optimizations that I could try or do you think it will be hard to significantly speed up this approach?
On Sat, Apr 24, 2021 at 2:50 PM Sebastien Loriot <> wrote:
With the following code (quick and dirty):
https://gist.github.com/sloriot/d563b5ce27d28fcfd73beb1b628d72b5
I could generate a mesh.
Best,
Sebastien.
PS: there might be some initialization issues if you have several
(small) connected components and initial points should be added.
If you need clean intersections then some extra work is also needed.
On 4/24/21 2:06 PM, Sebastien Loriot wrote:
> If you take the maximum radius, you can collect all the closest point
> to the query and stop when you exceed the maximum radius.
> You can associate the radius to each point like in this exemple:
>
> https://doc.cgal.org/latest/Spatial_searching/Spatial_searching_2searching_with_point_with_info_8cpp-example.html
>
>
> HTH,
>
> Sebastien.
>
> On 4/24/21 11:28 AM, Bruno Manganelli ( via
> cgal-discuss Mailing List) wrote:
>> Thanks for the reply Sebastien :)
>> Unfortunately I can't use a kd-tree because the spheres can have
>> different radii, so a point won't necessarily be inside the closest
>> sphere.
>> I have tried adapting an AABB tree to use spheres as primitives, but
>> it doesn't seem to work when querying for intersections with points.
>> I admittedly don't know how the bounding boxes are created or whether
>> querying for intersections is a valid thing to do.
>>
>> For reference, this is what I was doing with AABB trees:
>>
>> class AABBSpherePrimitive {
>> public:
>> using Point = Point_3;
>> using Datum = Sphere_3;
>> using Point_reference = Point;
>> using Datum_reference = Datum;
>> using Id = Datum;
>>
>> AABBSpherePrimitive(Sphere_3 sphere)
>> : m_sphere_datum(sphere)
>> {
>> m_reference_point = sphere.center();
>> m_reference_point +=
>> K::Vector_3{std::sqrt(sphere.squared_radius()), 0, 0};
>> }
>>
>> Datum_reference datum() const { return m_sphere_datum; }
>> Id id() const { return m_sphere_datum; }
>> Point_reference reference_point() const { return m_reference_point; }
>> private:
>> Datum m_sphere_datum;
>> Point m_reference_point;
>> };
>>
>> using SphereTreeTraits = CGAL::AABB_traits<K, AABBSpherePrimitive>;
>> using SphereTree = CGAL::AABB_tree<SphereTreeTraits>;
>>
>>
>> On Sat, Apr 24, 2021 at 7:42 AM Sebastien Loriot
>> < <mailto:>> wrote:
>>
>> What I would do is generate a mesh for the union of spheres by
>> adapting
>> this example:
>>
>>
>> https://doc.cgal.org/latest/Mesh_3/Mesh_3_2mesh_implicit_sphere_8cpp-example.html
>>
>>
>> <https://doc.cgal.org/latest/Mesh_3/Mesh_3_2mesh_implicit_sphere_8cpp-example.html>
>>
>>
>> to handle several spheres.
>>
>> To do that, I think the simplest way to do it is to use a kd-tree
>> [1] to
>> get the closest sphere center from the query point and then use the
>> existing formula with the selected sphere.
>>
>> Let us know if you could do it.
>>
>> Best,
>>
>> Sebastien.
>>
>> [1] https://doc.cgal.org/latest/Spatial_searching/index.html
>> <https://doc.cgal.org/latest/Spatial_searching/index.html>
>>
>>
>>
>> On 4/23/21 11:57 PM, bmanga (
>> <mailto:> via cgal-discuss
>> Mailing List) wrote:
>> > I have also tried to use
>> > PMP::experimental::autorefine_and_remove_self_intersections, but
>> it fails
>> > with the following:
>> >
>> > CGAL error: precondition violation!
>> > _expression_ : vaa != vbb
>> >
>> >
>> >
>> > --
>> > Sent from: http://cgal-discuss.949826.n4.nabble.com/
>> <http://cgal-discuss.949826.n4.nabble.com/>
>> >
>>
>> -- 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
>>
--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss
- [cgal-discuss] Subtracting spheres from a mesh, bmanga, 04/23/2021
- Re: [cgal-discuss] Subtracting spheres from a mesh, bmanga, 04/23/2021
- Re: [cgal-discuss] Subtracting spheres from a mesh, Sebastien Loriot, 04/24/2021
- Re: [cgal-discuss] Subtracting spheres from a mesh, Bruno Manganelli, 04/24/2021
- Re: [cgal-discuss] Subtracting spheres from a mesh, Sebastien Loriot, 04/24/2021
- Re: [cgal-discuss] Subtracting spheres from a mesh, Sebastien Loriot, 04/24/2021
- Re: [cgal-discuss] Subtracting spheres from a mesh, Bruno Manganelli, 04/25/2021
- Re: [cgal-discuss] Subtracting spheres from a mesh, Sebastien Loriot, 04/25/2021
- Re: [cgal-discuss] Subtracting spheres from a mesh, Sebastien Loriot, 04/26/2021
- Re: [cgal-discuss] Subtracting spheres from a mesh, Bruno Manganelli, 04/26/2021
- Re: [cgal-discuss] Subtracting spheres from a mesh, Sebastien Loriot, 04/26/2021
- Re: [cgal-discuss] Subtracting spheres from a mesh, Bruno Manganelli, 04/26/2021
- Re: [cgal-discuss] Subtracting spheres from a mesh, Sebastien Loriot, 04/26/2021
- Re: [cgal-discuss] Subtracting spheres from a mesh, Bruno Manganelli, 04/25/2021
- Re: [cgal-discuss] Subtracting spheres from a mesh, Sebastien Loriot, 04/24/2021
- Re: [cgal-discuss] Subtracting spheres from a mesh, Sebastien Loriot, 04/24/2021
- Re: [cgal-discuss] Subtracting spheres from a mesh, Bruno Manganelli, 04/24/2021
- Re: [cgal-discuss] Subtracting spheres from a mesh, Sebastien Loriot, 04/24/2021
- Re: [cgal-discuss] Subtracting spheres from a mesh, bmanga, 04/23/2021
Archive powered by MHonArc 2.6.19+.