Problem Image: http://imgur.com/Bfe978i
For some reason when I try to mesh these points, the meshing API is connecting one side to the other instead of connecting to the nearest vertex. The points are all laid out at approx 5 foot intervals.
I have tried all sorts of values for the expansionFraction, I have also tried the basic mdlMesh_newPolyfaceFromXYTriangulation call, same results.
MSElementDescrP mesh = NULL;
if(meshPoints.size() >= 3){
if (SUCCESS != mdlMesh_newPolyfaceFromExpandedXYTriangulation(&mesh, &meshPoints.at(0), meshPoints.size(), 0.1, true)) { return; }
}
Any ideas?
This is a 2D triangulation applied on a 3D dataset. This is what "XY" in function name conveys.
It will only work if your point set is distributed close to a planar, possibly undulating surface.
There is no telling how your dataset looks like when looking in direction which is parallell to Z-axis (because this is exactly how the triangulating engine "sees" your points, cheerfully disregarding their z-coordinates).
If you want to triangulate a point set which looks crazy in such direction, you may rotate it prior to triangulating and unrotate the result afterwards.
Cheers,
/Chris Z.
Chris, I understand that. I rotated the view to isometric so that you could better see the strangely connected triangles..
All of the points I am meshing are spaced out in a 5x5 foot XY grid
iifuzz,
Do you have the points so that I can see how the play with a sample that I wrote way back when to test with? I know in that code I was finding text elements and using the origin of them so I had to sort the data before sending off to the mesh code.
thanks,
mark anderson [Bentley]
Visit me at https://communities.bentley.com/communities/other_communities/bentley_innovation/default.aspx
Answer Verified By: iifuzz
Here you go mark. Thanks for taking a look.
http://www.filedropper.com/mark_2
I just tried sorting the points before the triangulation. It seems to have fixed the problem.
iifuzz said:I just tried sorting the points before the triangulation
What kind of sort do you apply to your points? Presumably some kind of spatial sort?
Regards, Jon Summers LA Solutions
// sort points
inline bool sortPnts(const DPoint3d p1, const DPoint3d p2) {
return (p1.x < p2.x) || (p1.x == p2.x && p1.y < p2.y);
};
std::sort(meshPoints.begin(), meshPoints.end(), sortPnts);
if (SUCCESS != mdlMesh_newPolyfaceFromExpandedXYTriangulation(&mesh, &meshPoints[0], meshPoints.size(), 0.01, true))
{
printf("Unable to generate mesh.. Area too large?");
mesh = NULL;
iifuzz said:std::sort(meshPoints.begin(), meshPoints.end(), sortPnts)
Excellent: a practical demonstration of the C++ standard library sort algorithm!
You can avoid having your predicate function copy its parameters if you pass-by-const-reference …
inline bool sortPnts(const DPoint3d& p1, const DPoint3d& p2) { return (p1.x < p2.x) || (p1.x == p2.x && p1.y < p2.y); }
Thanks Jon. forgot about that.