Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Invalid TDS after inserting vertices and creating cells & neighbors

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Invalid TDS after inserting vertices and creating cells & neighbors


Chronological Thread 
  • From: Adam Getchell <>
  • To:
  • Subject: Re: [cgal-discuss] Invalid TDS after inserting vertices and creating cells & neighbors
  • Date: Thu, 7 May 2015 01:17:17 -0700


> On May 6, 2015, at 1:01 AM, Monique Teillaud
> <>
> wrote:
>
> Hi Adam,

Thank you Monique! Your answers were very useful!

I apologize, but I have two additional questions, the details of which are
below.

1. If a vertex is invalid, can this be due to incorrect adjacency relations
on cells it is a member of?
2. Is the a constructor for a Vertex that produces a Vertex_handle?
3. Which modifiers affect the validity of the TDS?

> It is correct, as long as you don't lose their neighbors, which will be
> neighbors of the new cells.

I store their neighbors before deleting them.

> However it might be more efficient not to delete them, but just modify
> them, and create only the 4 additional cells needed.
> You may want to have a look at how flips are implemented in
> Triangulation_data_structure_3.h

Yes, thank you, that code was very helpful. I noticed that flip_really()
makes use of set_adjacency(), but I haven’t found documentation for that
function. I looked at the source code and see that it makes use of
set_neighbor().

(Thanks for putting the source on GitHub! It is easy to search.)
>
>> 2. Is there a way to create a vertex without inserting it into the
>> Delaunay triangulation?
>
> You must certainly not insert a point in the Delaunay triangulation, in
> general it cannot give you what you want. You should only use and patch TDS.


Thank you! I now use:

// Insert new vertex
Point p = Point(center_of_X, center_of_Y, center_of_Z);
Vertex_handle v_center = D3->tds().create_vertex();
v_center->set_point(p);

This almost works correctly! All of my tests pass except:

CGAL_triangulation_postcondition(D3->tds().is_valid(v_center, true, 1));

This generates a referral to line 3438 of Triangulation_data_structure_3.h,
which when I looked at it has two tests:

template <class Vb, class Cb, class Ct>
bool
Triangulation_data_structure_3<Vb,Cb,Ct>::
is_valid(Vertex_handle v, bool verbose, int level) const
{
bool result = v->is_valid(verbose,level);
result = result && v->cell()->has_vertex(v);
if ( ! result ) {
if ( verbose )
std::cerr << "invalid vertex" << std::endl;
CGAL_triangulation_assertion(false);
}
return result;
}

I replicated the first test to see that there lies the problem ( I also
reproduced the second test, but it segfaults):

// Do all the cells have v_center as a vertex?
(top_31->has_vertex(v_center)) ? std::cout << "top31 has v_center" <<
std::endl : std::cout << "top31 doesn't have v_center" << std::endl;

(v_center->is_valid(true,1)) ? std::cout << "v_center->is_valid is true" <<
std::endl : std::cout << "v_center->is_valid is false" << std::endl;


Which produces:

Delaunay triangulation has 96245 cells.
There are 30034 (3,1) simplices and 35961 (2,2) simplices and 30250 (1,3)
simplices.
Number of vertices before = 15182
Random number is 13694
Neighbor 0 is of type 22
Neighbor 1 is of type 22
Neighbor 2 is of type 31
Neighbor 3 is of type 22
(1,3) simplex 13694 is movable.
The neighboring simplex 2 is of type 31
Vertex index 1 is 3 with coordinates of -2.89726 4.88869 -4.08738
Vertex index 2 is 0 with coordinates of -2.35044 4.7483 -4.57483
Vertex index 3 is 1 with coordinates of -2.78117 4.41555 -4.66561
Vertex v_bottom is 2 with coordinates of -2.59829 3.85396 -3.7942
Vertex v_top is 2 with coordinates of -2.85956 5.17301 -5.391
Average x-coord is -2.67629
Average y-coord is 4.68418
Average z-coord is -4.44261
It's a vertex in the TDS.
Timeslice is 7
Inserted vertex -2.67629 4.68418 -4.44261 with timeslice 7
top31 has v_center
v_center->is_valid is false
invalid vertex
CGAL error: assertion violation!

So it looks like my cells are valid, but the inserted vertex is not. Would
the adjacency relationships of the cells that the vertex is attached to cause
the vertex to be invalid?

I looked at the code for create_vertex() in
../include/CGAL/Triangulation_data_structure_3.h. The function appears to
have two signatures:


Vertex_handle create_vertex(const Vertex &v)
{
return vertices().insert(v);
}
Vertex_handle create_vertex()
{
return vertices().emplace();
}

The first signature requires that I already have a Vertex_handle. I have
looked for a Vertex constructor but have been unsuccessful.

The second signature doesn’t take arguments, but using set_point(p) to set
the associated point of the vertex is also unsuccessful.

Is there some way of initializing a vertex that can be passed to
tds().create_vertex()?

Thanks again!

> look for create_vertex in
> http://doc.cgal.org/latest/TDS_3/classTriangulationDataStructure__3.html
> Other modifiers
> The following modifiers can affect the validity of the triangulation data
> structure.

What modifiers?

>
> Best,
> --
> Monique Teillaud
> http://www.loria.fr/~teillaud/
> INRIA Nancy - Grand Est, LORIA
> Institut National de Recherche en Informatique et Automatique
>
> --
> 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.18.

Top of Page