Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Subtracting spheres from a mesh

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Subtracting spheres from a mesh


Chronological Thread 
  • From: Bruno Manganelli <>
  • To:
  • Subject: Re: [cgal-discuss] Subtracting spheres from a mesh
  • Date: Sat, 24 Apr 2021 11:28:22 +0200
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None ; spf=Pass ; spf=None
  • Ironport-hdrordr: A9a23:+xo8aapB0R034oYOXElBJiYaV5seL9V00zAX/kB9WHVpW+STncy2gbA/3Rj7lD4eVBgb6LW9EYOrKEmyybde544NMbC+GCzvv2W1JI9vhLGSpwHIMSv46+JbyONcY7FzYeeAd2RSoM7m7GCDYrUd6fad9qTAv4rj5lNMaS0vVK169Qd+DW+gYzBLbS1LH4AwGpbZxucvnUvDRV0tYs62BmYIUoH4zrWh/q7OWwIMBBIs9WC14w+A1b/gHxCUmjcYXj9fqI1DzUH5khf07qjmjvejyhW07Q7uxqlR8eGM9vJzQOi3zukcMHHFlxuhboUJYczkgBkF5MWUrGsMvPaJiRE6JMh3427WZQiO0H3Q8hil1Cxr527pyFeej3empcDiXjo1B9BMgp9DfgLD51Atu8x916xXz3uU3qAndC/ojWD4/ZzFRhtqnk27rT4+iuYVlWVYSpZbZ6RWqYAZ4UNJAJYNFC/38+kcYZFTJdCZ4u1Xf1OcZ23YuWcqwMXEZAVJIiu7
  • Ironport-phdr: A9a23:5fDZGxYNIqcxStZAlrwzn+3/LTH114qcDmYuwqpisKpHd+GZx7+nAna3zctkgFKBZ4jH8fUM07OQ7/mxHzZZut3e7jgrS99lb1c9k8IYnggtUoauKHbQC7rUVRE8B9lIT1R//nu2YgB/Ecf6YEDO8DXptWZBUhrwOhBoKevrB4Xck9q41/yo+53Ufg5EmCexbal9IRmrqQjdrNcajZZsJ6o+yBbEo2ZDdvhLy29vOV+dhQv36N2q/J5k/SRQuvYh+NBFXK7nYak2TqFWASo/PWwt68LlqRfMTQ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OM2OhwaVw/gyWC4/SmFiCjPWWcvEX0yfJsWuC1mGTp1pwUQhqUKyDU2pMSFHRqIHT/F7ESPeLALIoOw1MzcqDYv9AcMDvihNDTfHsMYWDS220kma0Qx2Pw+XfP8LRZ2wB0XCFWwA/mAcJ8CPeXSAOQxy5qmebNwRAUFfmYkfi6+57wFu0S0Y1y0eBaEgzjtKdylsunfWZDsgr8Pccoi5JgzpxFVe5mdnRDojYzyJROZ5EaNZ4229pkGLUswsVFpmpLqQnn0JHNgou4B+o2BJwBYFN18MtqSFypDc=

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 <> 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

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



On 4/23/21 11:57 PM, bmanga ( 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/
>

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





Archive powered by MHonArc 2.6.19+.

Top of Page