Is it convenient to change the surface_mesh_simplification a little?

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

Is it convenient to change the surface_mesh_simplification a little?

tdchen
I'm a newbie both to STL and CGAL.
I found that the CGAL surface_mash_simplification might be very helpful to
my work.
But I have to change it a little to suit my needs.
Specifically, I want to change the placement policy to that: the border edge
will be collapsed to one of its vertices and others to the Lindstrom-Turk
position.
I wonder if it is convenient in CGAL.
It seems there is no such a placement policy in curent version of CGAL.
Thanx.



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


Reply | Threaded
Open this post in threaded view
|

Re: Is it convenient to change the surface_mesh_simplification a little?

MaelRL

Hello,

With CGAL, you can pass any policy you want as long as it fits some requirements. The requirements on a placement class is very light and is defined there: https://doc.cgal.org/5.0/Surface_mesh_simplification/classGetPlacement.html. thus, your class  must provide the functor:

    boost::optional< Point > operator() (Profile const &edge_profile) const

The "edge profile" is a class that regroups all information useful during the collapse of an edge. Its interface is described there: https://doc.cgal.org/5.0/Surface_mesh_simplification/classEdgeProfile.html. In particular, you see that you can obtain the edge being collapse via v0_v1 (or v1_v0, since these are halfedges). You can use the function is_border_edge (https://doc.cgal.org/5.0/BGL/group__PkgBGLHelperFct.html#ga63695419c5ce7f68949ff2fb4f42d733) to know if your edge is on the border (check out https://doc.cgal.org/5.0/BGL/index.html for details on the graph API).

You can then simply derive a new policy from Lindstrom-Turk and do something like:

struct my_custom_placement
   : public lindstorm-turk placement
{
    boost::optional< Point > operator() (Profile const &edge_profile) const
   {
      if(is_border_edge(edge_profile.v0_v1()))
        return whichever extremity point you want;
      else
        return base::operator()(edge_profile);
   }  

};

Best,
Mael

On 13/10/2019 01:46, tdchen wrote:
I'm a newbie both to STL and CGAL.
I found that the CGAL surface_mash_simplification might be very helpful to
my work.
But I have to change it a little to suit my needs.
Specifically, I want to change the placement policy to that: the border edge
will be collapsed to one of its vertices and others to the Lindstrom-Turk
position.
I wonder if it is convenient in CGAL.
It seems there is no such a placement policy in curent version of CGAL.
Thanx.



--
Sent from: http://cgal-discuss.949826.n4.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: Is it convenient to change the surface_mesh_simplification a little?

tdchen
Thank you so much MaelRL for the so detailed suggestion!
I will try the way you guided me, but it will spend me some time.
There is a difference on my mesh border that:
It is composed of some(usually 4)polylines, and I have to ensure the joint
ends not to be removed.
So I think I have to send some extra message to the mesh as the vertex
property.
Is it right?
And if 2 ends of an edge are both on the border(border edge), I want to
collapse it to the end with lower cost.
I think I can call the cost function in my placement function to make
decision, can't I?
Thank you again.



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


Reply | Threaded
Open this post in threaded view
|

Re: Is it convenient to change the surface_mesh_simplification a little?

MaelRL
Hello,

You can constrain edges that you do not wish to be removed, see for
example the following example :
https://doc.cgal.org/latest/Surface_mesh_simplification/Surface_mesh_simplification_2edge_collapse_constrain_sharp_edges_8cpp-example.html.

For your second question, a cost is assigned to an edge, not a vertex.
But you can independently assign vertex costs to your mesh and look up
these cost in your placement. If you are using a Surface_mesh data
structure, you can add properties like described in the following
example :
https://doc.cgal.org/latest/Surface_mesh/Surface_mesh_2sm_properties_8cpp-example.html.

Best,
Mael

On 15/10/2019 11:36, tdchen wrote:

> Thank you so much MaelRL for the so detailed suggestion!
> I will try the way you guided me, but it will spend me some time.
> There is a difference on my mesh border that:
> It is composed of some(usually 4)polylines, and I have to ensure the joint
> ends not to be removed.
> So I think I have to send some extra message to the mesh as the vertex
> property.
> Is it right?
> And if 2 ends of an edge are both on the border(border edge), I want to
> collapse it to the end with lower cost.
> I think I can call the cost function in my placement function to make
> decision, can't I?
> Thank you again.
>
>
>
> --
> 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


Reply | Threaded
Open this post in threaded view
|

Re: Is it convenient to change the surface_mesh_simplification a little?

tdchen
Ok, I will try these.
Thank you.



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


Reply | Threaded
Open this post in threaded view
|

Re: Is it convenient to change the surface_mesh_simplification a little?

tdchen
Sorry for my poor english.
What I want to ask is that if I can call cost function in placement function
to finally decide the placement.
I mean in the placement function I will try several places and compare their
costs, finally set the placement in the place with the lowest cost.
I am new with STL, and now I just think a policy is a function.




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


Reply | Threaded
Open this post in threaded view
|

Re: Is it convenient to change the surface_mesh_simplification a little?

MaelRL
I see. No, you do not have access to the cost functor in the placement.

However, this is indeed often the case that the "placement" and "cost"
functors are going to do similar things. But you do not exactly need the
cost functor itself, you can simply do the same computations (code) that
you are doing in the "cost" functor, but in the placement "functor". On
CGAL side, this happens for a few simplification methods, and we simply
factorize this code into a class called "****_core.h" which the "cost"
and "placement" functors are then both using (see for example
Lindstrom-Turk, and the upcoming Garland-Heckbert methods).

Best,
Mael

On 15/10/2019 12:29, tdchen wrote:

> Sorry for my poor english.
> What I want to ask is that if I can call cost function in placement function
> to finally decide the placement.
> I mean in the placement function I will try several places and compare their
> costs, finally set the placement in the place with the lowest cost.
> I am new with STL, and now I just think a policy is a function.
>
>
>
>
> --
> 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


Reply | Threaded
Open this post in threaded view
|

Re: Is it convenient to change the surface_mesh_simplification a little?

tdchen
I think I know your meaning.
I have read the 2 articles many time.
What I need to do now is getting familiar with CGAL.
Your suggestion make me much clear where to look at.
Thank you so much MaelRL. I will told you my success.



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


Reply | Threaded
Open this post in threaded view
|

Re: Is it convenient to change the surface_mesh_simplification a little?

Shrabani Ghosh
In reply to this post by MaelRL
Hi MaelRL,

I had a question similar to this example. As in this example, it defined the
edges as a constrained edge that will not be removed in the simplification
process.

https://doc.cgal.org/latest/Surface_mesh_simplification/Surface_mesh_simplification_2edge_collapse_constrain_sharp_edges_8cpp-example.html

I have to do something opposite. I have to define some edges that has to be
removed in the simplification process. Is there any function that can define
the edges as removed?

Regards
Shrabani Ghosh



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


Reply | Threaded
Open this post in threaded view
|

Re: Is it convenient to change the surface_mesh_simplification a little?

Sebastien Loriot (GeometryFactory)
Maybe can directly call:

CGAL::Euler::collapse_edge()
https://doc.cgal.org/latest/BGL/group__PkgBGLEulerOperations.html#ga5d15eb83f797b8f91e23e8e9ceec78c9

if the edge satisfy the link condition

CGAL::Euler::does_satisfy_link_condition()

https://doc.cgal.org/latest/BGL/group__PkgBGLEulerOperations.html#ga2d19a3573640a9abb28885425bfd9f40 


Sebastien


On 10/15/19 6:03 PM, Shrabani Ghosh wrote:

> Hi MaelRL,
>
> I had a question similar to this example. As in this example, it defined the
> edges as a constrained edge that will not be removed in the simplification
> process.
>
> https://doc.cgal.org/latest/Surface_mesh_simplification/Surface_mesh_simplification_2edge_collapse_constrain_sharp_edges_8cpp-example.html
>
> I have to do something opposite. I have to define some edges that has to be
> removed in the simplification process. Is there any function that can define
> the edges as removed?
>
> Regards
> Shrabani Ghosh
>
>
>
> --
> 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


Reply | Threaded
Open this post in threaded view
|

Re: Is it convenient to change the surface_mesh_simplification a little?

Shrabani Ghosh
Hi  Sebastien,

Thank you for your response. In that case, can I check placement or cost before removing? Because after sequential edge remove I see that the edges look weird.  How to remove edges in this case organized way?


On Wed, Oct 16, 2019 at 3:04 AM Sebastien Loriot (GeometryFactory) <[hidden email]> wrote:
Maybe can directly call:

CGAL::Euler::collapse_edge()
https://doc.cgal.org/latest/BGL/group__PkgBGLEulerOperations.html#ga5d15eb83f797b8f91e23e8e9ceec78c9

if the edge satisfy the link condition

CGAL::Euler::does_satisfy_link_condition()

https://doc.cgal.org/latest/BGL/group__PkgBGLEulerOperations.html#ga2d19a3573640a9abb28885425bfd9f40


Sebastien


On 10/15/19 6:03 PM, Shrabani Ghosh wrote:
> Hi MaelRL,
>
> I had a question similar to this example. As in this example, it defined the
> edges as a constrained edge that will not be removed in the simplification
> process.
>
> https://doc.cgal.org/latest/Surface_mesh_simplification/Surface_mesh_simplification_2edge_collapse_constrain_sharp_edges_8cpp-example.html
>
> I have to do something opposite. I have to define some edges that has to be
> removed in the simplification process. Is there any function that can define
> the edges as removed?
>
> Regards
> Shrabani Ghosh
>
>
>
> --
> 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



Screenshot from 2019-10-23 13-59-05.png (205K) Download Attachment