How can I fetch the label value of a mesh vertices?

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

How can I fetch the label value of a mesh vertices?

Shrabani Ghosh
Hi,

In a multi-label mesh, I need to know which vertex has what label value. I
tried with properties of vertex but I cannot fetch the existing label value.
How can I do that?

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: How can I fetch the label value of a mesh vertices?

Sebastien Loriot (GeometryFactory)
You need to give more details. What data structure of CGAL are you using
for your multi-label mesh?

If you are using property maps, the free function get(map, v) will
return the value associated to the vertex v.

Sebastien.

On 9/5/19 6:15 PM, Shrabani Ghosh wrote:

> Hi,
>
> In a multi-label mesh, I need to know which vertex has what label value. I
> tried with properties of vertex but I cannot fetch the existing label value.
> How can I do that?
>
> 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: How can I fetch the label value of a mesh vertices?

Shrabani Ghosh
Thank you for your reply.
I tried to do something like this. But it's not working.

#include <string>
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Surface_mesh.h>
#include <boost/foreach.hpp>
#include <fstream>
#include <list>
#include <iostream>
#include <CGAL/Polyhedron_items_with_id_3.h>
#include <boost/graph/kruskal_min_spanning_tree.hpp>
#include <boost/property_map/property_map.hpp>


typedef CGAL::Simple_cartesian<double> K;
typedef CGAL::Surface_mesh<K::Point_3> Mesh;
typedef Mesh::Vertex_index vertex_descriptor;
typedef boost::graph_traits<Mesh>::vertex_iterator   vertex_iterator;
typedef boost::graph_traits<Mesh>::vertex_descriptor vertex_descriptor;
typedef Mesh::Face_index face_descriptor;
typedef boost::graph_traits<Mesh>::edge_descriptor   edge_descriptor;
std::list<edge_descriptor> mst;

int main()
{


  Mesh m;
  std::ifstream is("../data/TwoBoxesEqualSideBySide_MM2M.off") ; is >> m ;
  if (!CGAL::is_triangle_mesh(m)){
    std::cerr << "Input geometry is not triangulated." << std::endl;
    return EXIT_FAILURE;

}


  // retrieve the point property for which exists a convenience function
 
  Mesh::Property_map<vertex_descriptor, std::int> label;
  BOOST_FOREACH( vertex_descriptor vd, m.vertices()) {
  std::cout <<  get(vd, label) << std:: endl;
   // std::cout << "point " << vd << " location " << location[vd] <<
std::endl;
  }

  return 0;
}



--
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: How can I fetch the label value of a mesh vertices?

Sebastien Loriot (GeometryFactory)
Should be: get(MAP, KEY) -->  get(label, vd)

Sebastien.

On 9/7/19 8:54 PM, Shrabani Ghosh wrote:

> Thank you for your reply.
> I tried to do something like this. But it's not working.
>
> #include <string>
> #include <CGAL/Simple_cartesian.h>
> #include <CGAL/Surface_mesh.h>
> #include <boost/foreach.hpp>
> #include <fstream>
> #include <list>
> #include <iostream>
> #include <CGAL/Polyhedron_items_with_id_3.h>
> #include <boost/graph/kruskal_min_spanning_tree.hpp>
> #include <boost/property_map/property_map.hpp>
>
>
> typedef CGAL::Simple_cartesian<double> K;
> typedef CGAL::Surface_mesh<K::Point_3> Mesh;
> typedef Mesh::Vertex_index vertex_descriptor;
> typedef boost::graph_traits<Mesh>::vertex_iterator   vertex_iterator;
> typedef boost::graph_traits<Mesh>::vertex_descriptor vertex_descriptor;
> typedef Mesh::Face_index face_descriptor;
> typedef boost::graph_traits<Mesh>::edge_descriptor   edge_descriptor;
> std::list<edge_descriptor> mst;
>
> int main()
> {
>
>
>    Mesh m;
>    std::ifstream is("../data/TwoBoxesEqualSideBySide_MM2M.off") ; is >> m ;
>    if (!CGAL::is_triangle_mesh(m)){
>      std::cerr << "Input geometry is not triangulated." << std::endl;
>      return EXIT_FAILURE;
>
> }
>
>
>    // retrieve the point property for which exists a convenience function
>  
>    Mesh::Property_map<vertex_descriptor, std::int> label;
>    BOOST_FOREACH( vertex_descriptor vd, m.vertices()) {
>    std::cout <<  get(vd, label) << std:: endl;
>     // std::cout << "point " << vd << " location " << location[vd] <<
> std::endl;
>    }
>
>    return 0;
> }
>
>
>
> --
> 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: How can I fetch the label value of a mesh vertices?

Shrabani Ghosh
Thank you for your response.

I am getting error even using (label,vd),
is this line correct?  
Mesh::Property_map<vertex_descriptor, std::int> label;
It showing error when I am using int but when I tried string it does not
show error but I am getting below output.

terminate called after throwing an instance of 'CGAL::Assertion_exception'
  what():  CGAL ERROR: assertion violation!
Expr: parray_ != NULL
File: /home/sghos003/CGAL-4.13.1/include/CGAL/Surface_mesh/Properties.h
Line: 518

I am not understanding what wrong I am doing. the label value should be an
int value, I tried to even use template. But nothing worked.

Regards
Shrabani



--
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: How can I fetch the label value of a mesh vertices?

Sebastien Loriot (GeometryFactory)
As documented, you need to create the property with

mesh.add_property_map<A,B>(default)

See https://doc.cgal.org/latest/Surface_mesh/#title7 for an example.

Sebastien.

On 9/9/19 6:41 AM, Shrabani Ghosh wrote:

> Thank you for your response.
>
> I am getting error even using (label,vd),
> is this line correct?
> Mesh::Property_map<vertex_descriptor, std::int> label;
> It showing error when I am using int but when I tried string it does not
> show error but I am getting below output.
>
> terminate called after throwing an instance of 'CGAL::Assertion_exception'
>    what():  CGAL ERROR: assertion violation!
> Expr: parray_ != NULL
> File: /home/sghos003/CGAL-4.13.1/include/CGAL/Surface_mesh/Properties.h
> Line: 518
>
> I am not understanding what wrong I am doing. the label value should be an
> int value, I tried to even use template. But nothing worked.
>
> Regards
> Shrabani
>
>
>
> --
> 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: How can I fetch the label value of a mesh vertices?

Shrabani Ghosh
But the voxel label value information is already in the triangular mesh. When
I generated the triangular surface mesh from the 3D image, I already kept
the vertex material information in the surface mesh. Now I just need to
fetch the material information. Do I again need to add property?

Regards
Shrabani



--
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: How can I fetch the label value of a mesh vertices?

Sebastien Loriot (GeometryFactory)
I think the error says that the property does not exist. If you already
created it then there is a pb somewhere. Maybe you operate on another
mesh, added the property on a temporary mesh (did you take the mesh by
copy instead of by reference?)...

Sebastien.

On 9/9/19 6:56 AM, Shrabani Ghosh wrote:

> But the voxel label value information is already in the triangular mesh. When
> I generated the triangular surface mesh from the 3D image, I already kept
> the vertex material information in the surface mesh. Now I just need to
> fetch the material information. Do I again need to add property?
>
> Regards
> Shrabani
>
>
>
> --
> 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
|

回复: [cgal-discuss] How can I fetch the label value of a meshvertices?

Davic



------------------ 原始邮件 ------------------
发件人: "Sebastien Loriot (GeometryFactory)"<[hidden email]>;
发送时间: 2019年9月9日(星期一) 中午1:03
收件人: "cgal-discuss"<[hidden email]>;
主题: Re: [cgal-discuss] How can I fetch the label value of a meshvertices?

I think the error says that the property does not exist. If you already
created it then there is a pb somewhere. Maybe you operate on another
mesh, added the property on a temporary mesh (did you take the mesh by
copy instead of by reference?)...

Sebastien.

On 9/9/19 6:56 AM, Shrabani Ghosh wrote:

> But the voxel label value information is already in the triangular mesh. When
> I generated the triangular surface mesh from the 3D image, I already kept
> the vertex material information in the surface mesh. Now I just need to
> fetch the material information. Do I again need to add property?
>
> Regards
> Shrabani
>
>
>
> --
> 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



AEA0F394@9568FA29.40FF755D.jpg (30K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: 回复: How can I fetch the label value of a meshvertices?

Shrabani Ghosh
Thank You for your response. Later I understood that I have to label
actually. Now it's working.



--
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: How can I fetch the label value of a mesh vertices?

Shrabani Ghosh
In reply to this post by Sebastien Loriot (GeometryFactory)
Thank You for your response. Later I understood that I have to label
actually. Now it's working.

I want to use color so that I can visualize different label values is
labeled properly. Is there anything in CGAL to visualize different colored
mesh?

Thanks in advance.


Regards
Shrabani  



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