2
votes

I made a Delaunay Triangulation using Matlab version 2013. I want to remove some of the triangles, meaning canceling their connectivity, for example triangle number 760. How can I make this change? When I tried to edit the connectivity list:

dt.ConnectivityList(760 , :) = [];

I got the message:

Cannot assign values to the triangulation.

I thought about maybe copying specific fields to a different structure, but:

a. I'm not familiar with structures so I don't know how to do it right.
b. After I copy the structure, how can I get my triangles?

dt contains 3 fields: Points, ConnectivityList and Constraints (empty field).

2
Welcome to Stack Overflow. Please add details of what you aldready achieve. Your question is too broad to be answered.Jean-Rémy Revy
You should consider selecting answers for your questions that work for you. That will remove your questions from the unanswered queue.Mad Physicist

2 Answers

4
votes

A brief note on MATLAB objects. When you access a field for reading, you are basically doing get(obj, fieldname);. When you try to set a field as you are doing, you are actually calling set(obj, fieldname, new_value). Objects do not necessarily allow you to do these operations.

The triangulation object is read-only, so you will have to make copies of all the fields. If, as you mentioned, you would like to make a structure with similar fields, you can do as follows:

dts = struct('Points', dt.Points, 'ConnectivityList', dt.ConnectivityList);

Now you can edit the fields.

dts.ConnectivityList(760) = [];

You may be able to plot the new structure, but the methods of the delaunayTriangulation class will not be available to you.

To plot the result, use trisurf:

trisurf(dts.ConnectivityList, dts.Points);
2
votes

I was facing same problem. I found another solution. Instead of creating a new struct just create an object of its super class i.e. triangulation class with edited connectivity list. Here is my code

P- list of points

C- Constraints (optional)

dt=delaunayTriangulation(P,C); %created triangulation but dt won't let you change connectivity list

list=dt.ConnectivityList;
%your changes here

x=triangulation(list,dt.Points);

Now you can use x as triangulation object

triplot(x)