VTK smoothing with constraints - vtk

I'm trying to smooth a vtkPolyData mesh. The mesh has a lot of vertices that are exactly on the mesh's bounding box and I would like to preserve the location of those vertices. In further steps multiple smoothed meshes are stitched together, so the mesh has to have perfectly flat walls at its outer most limits, i.e. on the surface of its respective bounding box.
I have tried to use the vtkSmoothPolyDataFilter and defined a 'source' box as this seems to be the way to define constraints. But instead of preserving the location of the points that are on the box, the algorithm moves ALL the vertices of the mesh to their closest location on the box. So this is clearly not what I am looking for.
I'd appreciate any help or suggestions.
Thanks!
Nils

Related

How to choose a certain edge in Geometry Node (Blender 3.4.0 alpha)

two questions about Geometry Nodes.
To retopologize certain mesh, I'd like to subdivide a certain edge that both neighbors are triangle.
Questions:(https://i.stack.imgur.com/kG3Us.png)
1.How to find the edge with Geometry Node?
2.Is there a general strategy to find a specific elements(index of vertex, edge, and face)?
History:
I want to retopo the shape(=A) of being after Convex Hull Node because this is messy.
To do so, I chose a way that is of shrinking a simple shape onto A.
Bounding Box > Subdivide > Set Position is the order of the Nodes, but large areas still remain.
To fit the shape more precisely, I am trying to subdivide adittionaly only on the areas and then finally Set Position Node again to fit to the original messy A.
After I have tried some ideas (bellow), now I am trying to do a way of extruding the face, scaling the top selection to zero, merge the face and the set these new 'vertex' to the messy A.
And I find the edge between the face remain.🤣
This is my question above. How to fit these edges on to A?
Ideas I have tried:
Separate the large areas>Subdivide>Join Geometry>Set Position makes holes.
Separate the large areas>Subdivide>Convex Hull>Boolean Mesh makes messy topology
The way of not subdividing the large area, such as scaling the bounding box up enough to disappear the large area, will result overstretch to other mesh, which looks more difficult to solve, so I prefer to solve large flatten area If I can.
(https://i.stack.imgur.com/QzHKa.jpg)
I want to do retopology. I want to fit a new shape that has a clean topology onto the original messy shape.

BoundingBox Shape

In my Android mapping activity, I have a parallelogram shaped area that I want to tell if points (ie:LatLng) are inside. I've tried using the:
bounds = new LatLngBounds.Builder()
.include(latlngNW)
.include(latlngNE)
.include(latlngSW)
.include(latlngSE)
.build();
and later
if (bounds.contains(currentLatLng) {
.....
}
but it is not that accurate. Do I need to create equations for lines connecting the four corners?
Thanks in advance.
The LatLngBounds appears to create a box from the points included. Given the shape that I'm trying to monitor is a parallelogram, you do need to create equations for each of the edges of the shape and use if statements to determine which side of the line a point lies.
Not an easy solution!
If you wish to build a parallelogram-shaped bounding "box" from a collection of points, and you know the desired angles of the parallelogram's sides, your best bet is to probably define a 2d linear shear transform which will one of those angles to horizontal, and the other to vertical. One may then feed the transformed points into normal "bounding box" routines, and feed the corners of the resulting box through the inverse of the above transform to get a bounding parallelogram.
Note that this approach is generally only suitable for parallelograms, not trapezoids. There are a few special cases where it could be used to find bounding trapezoids [e.g. if the top and bottom were horizontal, and the sides were supposed to converge at a known point (x0-y0), one could map x' = (x-x0)/(y-y0)] but for many kinds of trapezoids, the trapezoid formed by inverse mapping the corners of a horizontal/vertical bounding rectangle may not properly bound the points that are supposed to be within it.

How to draw the heightmap onto the screen?

I'm using DirectX10 to simulate a water surface, and I'm now with a height map,which is a 2D array of the heights(y) at the points (x,z). But to draw it on the screen, I must turn it into a mesh or have a index to draw triangle topology.
But the data is too large to do it manually. Are there any methods for me to draw it on the screen. I hope it's easy to implement. If there is function included in DirectX10 which can make it, the it's the best one for me.
Create a mesh that format a grid of squares (each made of two triangles) and set all vertices y = 0. In the vertex shader sample the heightmap and add the value stored in the heightmap to the y of the vertice.
This might help you.
P.S: If the area you want it to cover is too big you should take a look at terrain LOD techniques (should work the same for water).
I'm sure you can make a mesh out of it. I doubt you can generate the heightmap for a water surface that is too large to "meshify".
Why are you looking at Diamond square. For a 512x512 heightmap all you need to do is define a set of point and then generate the triangles for it. Its really very simple.

Determine outer boundries of polygon from lat/lng point array

I have a large array of lat/lng points. Could be up to 20k points. I'm plotting them using KML. What I want to do is to take only the outter most points and use them to draw a polygon instead. I already know how to draw a polygon in kml, I just need to figure out how to select only the outer most points of the group.
Any ideas? I'd like to have at least 5 points to the polygon but no more than 25 points total.
So far i've come up with checking for top most and bottom most points (basically crearing a square) using < & > logic.
The points will be in america & canada only if that matters.
Thanks for any help.
EDIT: I've gotten the Convex Hull algorithm to work, but it isnt exactly what I need. I'm trying to map out zip codes. If a zip code has an L shape then the polygon is going to be a triangle shape and not an L shape. Any ideas?
You need to use a Convex Hull algorithm. It's not too hard to implement yourself if it's not available in whatever software package you're using.

Creating closed spatial polygons

I need to create a (large) set of spatial polygons for test purposes. Is there an algorithm that will create a randomly shaped polygon staying within a bounding envelope? I'm using OGC Simple stuff so a routine to create the well known text is the most useful, Language of choice is C# but it's not that important.
Here you can find two examples of how to generate random convex polygons. They both are in Java, but should be easy to rewrite them to C#:
Generate Polygon example from Sun
from JTS mailing list, post Minimum Area bounding box by Michael Bedward
Another possible approach based on generating set of random points and employ Delaunay tessellation.
Generally, problem of generating proper random polygons is not trivial.
Do they really need to be random, or would some real WKT do? Because if it will, just go to http://koordinates.com/ and download a few layers.
What shape is your bounding envelope ? If it's a rectangle, then generate your random polygon as a list of points within [0,1]x[0,1] and scale to the size of your rectangle.
If the envelope is not a rectangle things get a little more tricky. In this case you might get best performance simply by generating points inside the unit square and rejecting any which lie in the part of the unit square which does not scale to the bounding envelope of your choice.
HTH
Mark
Supplement
If you wanted only convex polygons you'd use one of the convex hull algorithms. Since you don't seem to want only convex polygons your suggestion of a circular sweep would work.
But you might find it simpler to sweep along a line parallel to either the x- or y-axis. Assume the x-axis.
Sort the points into x-order.
Select the leftmost (ie first) point. At the y-coordinate of this point draw an imaginary horizontal line across the unit square. Prepare to create a list of points along the boundary of the polygon above the imaginary line, and another list along the boundary below it.
Select the next point. Add it to the upper or lower boundary list as determined by it's y-coordinate.
Continue until you're out of points.
This will generate convex and non-convex polygons, but the non-convexity will be of a fairly limited form. No inlets or twists and turns.
Another Thought
To avoid edge crossings and to avoid a circular sweep after generating your random points inside the unit square you could:
Generate random points inside the unit circle in polar coordinates, ie (r, theta).
Sort the points in theta order.
Transform to cartesian coordinates.
Scale the unit circle to a bounding ellipse of your choice.
Off the top of my head, that seems to work OK

Resources