Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Assign z-coordinate as extra information in a point

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Assign z-coordinate as extra information in a point


Chronological Thread 
  • From: Adam Getchell <>
  • To:
  • Subject: Re: [cgal-discuss] Assign z-coordinate as extra information in a point
  • Date: Fri, 2 May 2014 18:56:42 -0700

Solved!

With CGAL/number_utils and CGAL::to_double() --

/// Store the timeslice as an integer in each vertex's info field
  Delaunay::Finite_vertices_iterator vit;
  for (vit = S3->finite_vertices_begin(); vit != S3->finite_vertices_end(); ++vit) {
    int timeslice = (int) CGAL::to_double(vit->point().z());
    vit->info() = timeslice;
  }




On Fri, May 2, 2014 at 1:40 PM, Adam Getchell <> wrote:
Sebastien,

Thank you.

Is there a way to convert this output to an int? I looked at:

http://doc.cgal.org/latest/Kernel_23/classCGAL_1_1Point__3.html


If I'm reading it correctly, the coordinate value is a Kernel::FT, which is a Lazy_exact_nt< ..> for which I've searched for conversion functions.

I'm using:

typedef CGAL::Triangulation_vertex_base_with_info_3<int, K>   Vb;

and:


/// Store the timeslice number in each vertex
  Delaunay::Finite_vertices_iterator vit;
  for (vit = S3->finite_vertices_begin(); vit != S3->finite_vertices_end(); ++vit)
    vit->info() = (int) vit->point().z();

Produces:

┌─[getchell][Hapkido][±][master ✗][~/CDT-plusplus]
└─▪ make
Scanning dependencies of target cdt
[100%] Building CXX object CMakeFiles/cdt.dir/cdt.cpp.o
In file included from /Users/getchell/CDT-plusplus/cdt.cpp:20:
/Users/getchell/CDT-plusplus/spherical_3_complex.h:96:19: error: cannot convert 'typename cpp11::result_of<typename
      R::Compute_z_3 (Point_3<Epeck>)>::type' (aka 'Lazy_exact_nt<typename boost::remove_cv<typename
      boost::remove_reference<typename cpp11::result_of<Compute_z_3<Simple_cartesian<Gmpq> >
      (E0)>::type>::type>::type>') to 'int' without a conversion operator
    vit->info() = (int) vit->point().z();
                  ^~~~~~~~~~~~~~~~~~~~~~
1 error generated.
make[2]: *** [CMakeFiles/cdt.dir/cdt.cpp.o] Error 1
make[1]: *** [CMakeFiles/cdt.dir/all] Error 2
make: *** [all] Error 2

Thank you very much for all of the help you have provided!



On Fri, May 2, 2014 at 12:12 AM, Sebastien Loriot (GeometryFactory) <> wrote:
vit->point().z()

Sebastien.


On 05/02/2014 08:53 AM, Adam Getchell wrote:
Hello all,

I would like to assign the z-coordinate of a point inserted into a
Delaunay triangulation as an extra bit of information, the timeslice number.

In brief, I have:

template <typename T>
void make_S3_simplicial_complex(T* S3, int number_of_simplices, int
number_of_timeslices) {
   /// Start with a 3D sphere with two simplices
   S3->insert(typename T::Point(0,0,0));
   S3->insert(typename T::Point(1, 0, 0));
   S3->insert(typename T::Point(0, 1, 0));
   S3->insert(typename T::Point(0, 0, 1));
   S3->insert(typename T::Point(0, 0, -1));

   /// Store the timeslice number in each vertex
   Delaunay::Finite_vertices_iterator vit;
   for (vit = S3->finite_vertices_begin(); vit !=
S3->finite_vertices_end(); ++vit)
     vit->info() = 1;

   /// Debugging: print out each vertex and the timeslice number associated
   for (vit = S3->finite_vertices_begin(); vit !=
S3->finite_vertices_end(); ++vit)
     std::cout << '(' << vit->point() << ") (timeslice = " <<
vit->info() << ")" << std::endl;

   assert(S3->dimension() == 3);

Where I'd like to use:

vit->info() = vit->z()

or

vit->info() = vit->point()::cartesian(2)

or the appropriate member function.

Here's the full code listing:

https://github.com/acgetchell/CDT-plusplus/blob/master/spherical_3_complex.h

Which currently compiles.

Any pointers greatly appreciated!

Thank you!

--
Adam Getchell
about.me/adamgetchell <http://about.me/adamgetchell>

"Invincibility is in oneself, vulnerability in the opponent." -- Sun Tzu


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





--
Adam Getchell
"Invincibility is in oneself, vulnerability in the opponent." -- Sun Tzu



--
Adam Getchell
"Invincibility is in oneself, vulnerability in the opponent." -- Sun Tzu



Archive powered by MHonArc 2.6.18.

Top of Page