On Tue, 27 Mar 2012 22:34:32 -0400, xiaoxian liu <liuxiaox(a)sas.upenn.edu> wrote:
> I know how to add "point_makers" now, but several questions remain
> unsolved to me:(1). How to obtain information of the area of each
> element? I tried "mesh.element_volumes.setup()", but it gives me some
> apparently wrong values like 1e-302.
If a,b,c are the vertices, this formula gives you the area:
|(b-a)x(c-a)| / 2
AFAIK, element_volumes is an input array, to be used with the -a
switch. It will impose area restrictions on triangles.
> (2). How to add attributes to
> points, elements? From the code of "meshpy.triangle", it seems to have
> to be done by the method "__setstate()__" in the class of
No, __setstate__ is internal. You shouldn't call that directly. (In
Python, stuff that starts with an underscore is generally not meant for
What do you mean by 'attribute'? For vertices, it sounds like you're
asking for markers, which you already know about.
For regions, you do
mesh_info.regions.resize(# of regions)
Then each entry of the regions array is
(x, y, region_attribute, max_area)
See meshpy/src/cpp/triangle.h for further documentation:
/* `regionlist': An array of regional attributes and area constraints. */
/* The first constraint's x and y coordinates are at indices  and , */
/* followed by the regional attribute at index , followed by the */
/* maximum area at index , followed by the remaining area constraints. */
/* Four REALs per area constraint. Note that each regional attribute is */
/* used only if you select the `A' switch, and each area constraint is */
/* used only if you select the `a' switch (with no number following), but */
/* omitting one of these switches does not change the memory layout. */
/* Input only, although the pointer is copied to the output structure for */
/* your convenience. */
> I guess I need to do the following:
> info = MeshInfo()info.__setstate__( (p_attr_count, e_attr_count, state) )
> where an example of state would be:
> state = [ ['point_attributes', [array of attributes]]
> ['element_attributes', [array of attributes]] ...
> ]but I just couldn't get it through...
> (3). How to add "regions" attribute? Judging from the ".poly" file
> formate, the "holes" are generated in the same way as "regions", but
> there's no corresponding method like "info.set_regions( coordinates of
> a point inside the region)" like "holes" are set in
> MeshPy.triangle. The geometry that I'm working on is very simple so
> far: a rectangular region devided by an interface in the middle; to
> the left is "region 0", and to the right is "region 1".