Index of the cell containing a point after 3D Delanay triangulation - cgal

I have done 3D Delaunay Triangulation with the help of CGAL and am trying to locate the cell containing a specified point in it. I am pretty sure that Delaunay_triangulation_3::Locate() is what I need. However, the Locate() function returns a Cell_handle and what I need is the index of the cell containing the given point.
How does one obtain the index of the cell from a Cell_handle or is there other direct way to obtain the index of the cell?

Cells have no index in CGAL.
From the Cell_handle, you can access the vertices or the neighboring cells
or any information you have previously stored in the cell
(your own index if you have put one).

Related

Everscale-Solidity. How to get hash from data encoded into cell? tvm.hash analogue?

Free TON Solidity. How to get hash from data encoded into cell?
tvm.hash() analogue?
Do You need hash of BOC? Check this function https://github.com/tonlabs/TON-SDK/blob/master/docs/mod_boc.md#get_boc_hash
BOC with one CELL equal to CELL itself.
In fact BOC starts from root CELL which point to other CELLs.

VBA-style range selection in Excel

In a spreadsheet formula, (namely SumIfs) I would like to be able to select a column range using its delimiters instead of a A1:A3456 style, like I would do in VBA [Range("A1:A3456")~Range(Cells(1,1),Cells(3456,1))].
If this is not possible, is there any workaround to use the result of a 'Match' function to get the column number where I want to apply certain criteria?
My function would look like
=Sumifs(A2:A10;*{range(cells(1,match(Z5;A1:T1)), cell(10,match(Z5;A1:T1))}*,"="&1)
...if only I could add vba formulas inside the spreadsheet.
You can use a combination of Address and Indirect, like this:
=SUM(INDIRECT(ADDRESS(1,1) & ":" & ADDRESS(3456,1)))
which is equivalent to =SUM(A1:A3456)
ADRESS transforms from style Cells(i,j) to style A1.
INDIRECT serves to interpret the resulting string as a range address.
SUM here is an example of usage.
Well It's a bit ugly, but if you want to do that occasionally and don't want to switch completely to RC-style, it's probably the easiest way.
Use Offset, which is much richer as a worksheet function than it is in VBA.
Syntax
OFFSET(reference, rows, cols, [height], [width])
The OFFSET function syntax has the following arguments:
Reference Required. The reference from which you want to base the
offset. Reference must refer to a cell or range of adjacent cells;
otherwise, OFFSET returns the #VALUE! error value.
Rows Required. The number of rows, up or down, that you want the
upper-left cell to refer to. Using 5 as the rows argument specifies
that the upper-left cell in the reference is five rows below
reference. Rows can be positive (which means below the starting
reference) or negative (which means above the starting reference).
Cols Required. The number of columns, to the left or right, that
you want the upper-left cell of the result to refer to. Using 5 as the
cols argument specifies that the upper-left cell in the reference is
five columns to the right of reference. Cols can be positive (which
means to the right of the starting reference) or negative (which means
to the left of the starting reference).
Height Optional. The height, in number of rows, that you want the
returned reference to be. Height must be a positive number.
Width Optional. The width, in number of columns, that you want the
returned reference to be. Width must be a positive number.
from https://support.office.com/en-us/article/OFFSET-function-c8de19ae-dd79-4b9b-a14e-b4d906d11b66

Visio shapesheet get Layer index from name

I have some defined shapes in a Visio 2010 stencil, and would like to set the layer depending on the value of a particular shape data field. I would like to do this within the shapesheet if at all possible, since my workplace is very limiting concerning the use of VisualBasic.
I can do the necessary look up to find a particular value, but need to translate this to the correct index in the page layers list.
Basically, I need to get the current index of a particular layer. For example, I know the name of the layer is "Remove" and need the index in ThePage!Layers so that I can set LayerMember accordingly. The index changes from page to page, so I need do this lookup in the context of the page after the shape has been dropped on the page.
How can I look up the index of an entry in ThePage!Layers, using the name of the layer as lookup index. A syntax like ThePage!Layers.Index["Remove"] doesn't work and I couldn't find any other information in the Microsoft documentation.
It is possible! My method
i add to my shape 3 sections: User-definded cells, Shape Data, Layer Membership.
In Shape Data section i create one row, which contain Layer Name selector
User-definded cells section contain two rows:
1. User.L_List store list of all layers on page. I prepare this list use MS Excel
In column A i fill row numbers, like as at this picture
In cell B1 i place formula - Concatenate("ThePage!Layers.Name";A1)
In cell B2 i place formula - Concatenate(B1;"&Listsep()&ThePage!Layers.Name[";A2;"]")
And pull down some rows as i need.
Select bottom cell in column B and copy that value
Paste this value in MS Visio's cell User.L_List
2. Next cell contain formula SETF(GetRef(LayerMember),LOOKUP(Prop.LayerName,User.L_List)),
which assign shape to layer according value in Prop.LayerName cell

Excel Cell reference that will go to the left

I am using an excel spreadsheet formula to add two cells together and I want to have it reference one row from left to right like it normally does, but I need it to reference the same row in another page in reverse, and then be able to drag the formula through the entire worksheet. I cannot seem to find anything like this when I look online. TLDR I need to know how to tell excel reference the cell to the left if I drag it to the right.
so I need to add A0 in page one and A9 in page two then when I copy the formula to the left I need it to grab A1 and A8, is there a way to get this?
Your question is not very clear; for example, you talk about a formula but have an Excel-VBA tag. However, I think I understand the effect you seek.
I have filled A1:I1 of the current sheet and A1:I1 of worksheet “Sheet3” with numbers.
I have typed the following formula into another cell within the current worksheet:
=A1+INDEX(Sheet3!$A$1:$I$1,,10-COLUMN(A1))
The target area for the INDEX function is Sheet3!$A$1:$I$1. This is a one row range so I do not need a row number. The column number is 10-COLUMN(A1) which is 9 so this formula is equivalent to:
=A1+Sheet3!I9
If I copy the formula one cell to the right I get:
=B1+INDEX(Sheet3!$A$1:$I$1,,10-COLUMN(B1))
This is the equivalent of:
=B1+Sheet3!H9
You can continue copying the formula to the right until you get:
=I1+INDEX(Sheet3!$A$1:$I$1,,10-COLUMN(I1))
Attempting to copy further gives an error because 10-COLUMN(J1) is zero and there is no column 0.
There are other methods of achieving this effect. The key feature of any such method is the expression N-X where N is a constant and X gets bigger as the formula is copied further to the right.

Polygon reduction while drawing on Map

Today we are drawing polygons on a MKMapView. We use the following pseudocode to draw polygons.
CGContextMoveToPoint
CGContextAddLineToPoint
CGContextAddLineToPoint
CGContextAddLineToPoint
CGContextClosePath
CGContextFillPath
The result could potentially look like this:
We get the data one row at a time, the colors are given to the cell based on the data we receive. Is there a way or polygon reduction algorithms that would group all the same colored polygons together (assuming they intersect) to give me one big polygon? So in this example all the reds would one big polygon.
CoreGraphics can handle concave polygons natively, so the main part of the problem is a flood fill to work out the boundaries of the filled area.
Thinking extemporaneously, a naive algorithm could be to associate edge flags with each cell. An edge flag is set if that edge is part of the exterior of the polygon. Flags are shared by the two cells that meet at that edge.
Pick any cell and set all four edge flags. Reset the edge flags on all other cells. Then write a recursive method that, for each cell:
tests in turn whether each edge flag is set;
if a flag is set, checks whether the cell that shares that edge is of the same colour;
if it is, inverts the edge flags of that cell and recurses to it.
The inversion is the same as saying "connect to any cells you're known to be next to, set any edges that are next to cells we haven't looked at yet to be part of the boundary".
The recursion could get hundreds of items deep, so it might be worth keeping a list of cells to consider and adding to that list rather than recursing, just as a matter of implementation. It shouldn't matter what order you visit the cells in, so the outcome should be the same.
Once you've run out of cells to visit, you can reconstruct the entire boundary by walking around it from any flagged edge. The only slight complexity will be when you get to a diagonal meeting of cells, like where the yellow and green cells touch between your fourth and fifth columns. You need to apply the logic that you move from the current edge to the next one with which it shares both a vertex and a cell of the correct colour.
This is a job for the rectangle drawing functions, not the path drawing functions. See CGContextFillRect(), CGContextStrokeRect() and CGContextFillRects(). They will be much faster.