ParaView: How to decide which contour filter is on top? - paraview

I load two data files into paraview and use on both one contour filter. The resulting contour lines overlap. What I want and tried is the following:
load data file 1 into paraview, apply contour filter 1 on it.
load data file 2 into paraview and apply contour filter 2 on it.
Now I would expect that the contour filter 2 is on top of the first one at the overlapping area. But this is not the case.
Contour filter 2 contains only the black line. The first contour filter contains all the others. In the image the green-yellow-ish contour line is on top of the black one from filter 2.
Hopefully someone can help me.
Thank you!

ParaView mostly relies on distance from the camera to determine what objects are rendered "on top". Probably the best way to make sure that the lines of one of the objects are rendered over the other is to displace one or both in the z direction. You can do that by modifying the Translation under the Transforming parameters of the display properties. I see in your screenshot that you have a 2D projection, so shifting the data in the Z direction should have no visible effect other than the distance to the camera.
You can achieve the same effect using the Transform filter.

Related

How to draw a best fit mesh on a set of points in 2D

I have a problem where we have a grid of points and I'd like to fit a "deformed grid which would best fit the set of points.
The MatLab data can be found at:
https://drive.google.com/file/d/14fKKEC5BKGDOjzWupWFSmythqUrRXae4/view?usp=sharing
You will see that cenX and cenY are the x and y coordinates of these centroids.
Like on this image. To note is that there are points missing, and there are a few extra points. Moreover, You can see some lines are not one single line from left to right, however, we could safely assume that the fitting a line somewhat horizontally (+-5degrees) would properly link the points into a somewhat deformed grid.
The vertical lines are trivial because that is how we generated these dots. We can find the number of lines required through a mode of the count of points on each of the columns of the grid.
I'd like to be able to ensure that a point is only part of one line, as this is a grid.

How to fill colors in contour circles in paraview?

I have a triangulation surface, and there is a point data named rhoA on it. I plot rhoA in paraview and plot the contour with just one contour value. So you can see many circles on the surface.
But what I need is to fill red colors in the circles and don't show other parts. So how to do it in paraview?
Use the Clip filter and set the Clip Type to Scalar. Set the Scalars property to rhoA and set Value to your threshold value. This filter will cut cells, giving you a more precise surface than the Threshold filter will.
Here is an example of the results you can expect doing this:
You can either :
Use the banded countour filter from VTK, that you will need to expose with a XML only plugin first (hard but precise and efficient)
Use treshold filter (the cut will not be on the contour, whole cells will be extracted)

Extract contour from obj 3d object in Matlab

I have an .obj file representing a 3D object.
I need to extract from this 3D object the contour that is obtained by intersection with a plane. So for example, I have an object representing a cylinder oriented with vertical axis, then I want to extract a circle contour when the intersecting plane is horizontal or a rectangular contour when the intersection plane is vertical. Any suggestion about how to do it?
Since I didn't know how to visualise this obj file, I have converted to a patch with the following code (some function taken from loadawobj from Matlab file exchange).
modelname='file.obj';
S=loadawobj(modelname);
mtl=loadawmtl(['obj/' S.mtllib]);
p3=patch('Vertices',S.v','Faces',S.f3');
for ii=1:length(S.umat3)
mtlnum=S.umat3(ii);
fvcd3(ii,:)=mtl(1).Kd';
end
p3.FaceVertexCData=fvcd3;
p3.FaceColor='flat';
But I don't necessarily need to extract the contour from the resulting patch if this is too complex to accomplish. If there is an easier procedure starting from the obj file, it's also fine and acceptable. Thank you!
That's the way I solved the problem, after collecting information all around the web. I couldn't find anything ready on line so I had to implement an algorithm on my own. The basic idea is very simple but there are many steps required. I start from two info: one array containing the coordinates of the cloud point and another array containing a bunch of tuples about how the 3 vertex are connected to form a triangle.
First of all you need to find a representation of the plane you want to use for your cutting. That means you just use one point and the normal to the plane to represent it. That plane is required in order to identify the cutting point on the structure.
Second step is to identify the triangles on the plane. In few words you just need to scroll over all the triangles of the structure and find those having one corner above the cutting plane and another corner below the cutting plane. Also don't forget to account for the condition where one corner is on the plane or two are on the plane. All the other triangles are not needed, since they are totally above or below the cutting plane.
Now you have a subset of all your triangles. You need to extract points of the contour. So for each triangle you have 3 vertex: in general case you can imagine that one vertex is above the plane and the other two are below. Then you have two lines cutting the plane. You can extract two point by simply intersecting these lines with the cutting plane.
By repeating this operation you get a series of points on 2D space. But they have no order and if you plot them as a continuous plot, you get lines jumping up and down since the points you have extracted are randomly located in the array. So, it's required to order them in a proper way. The method I used is the very simple: start from one point and connect to the closest one. There are some bad situations where that doesn't work but you can probably avoid it by adding some more rules on the algorithm.

Image segmentation (OCT)

My image is something like below:
I want to be able to draw 2 layers: (1) red line on top of 1st layer, but (2) blue line in the middle of 2nd layer
I am using OpenCV. but any languages/advice are welcomed.
You can do the following:
Small closing in order to reconnect the small separated components/patterns.
Small opening in order to remove the small isolated components/patterns.
Skeletonize (or median axis)
Pruning in order to remove the small branches.
You will then get a skeleton for each pattern. It will be close to the lines you want to draw. But it will be a little bit irregular, so you can interpolate it.
[EDIT] if you need the red line on top of the edge, a solution is to:
Extract the pattern contour
Keep only the pixel on top.
Algorithmically, it can be achieved doing this: for each X coordinate on the top border, go down the image vertically until you meet the first non-null pixel. If your image is NxM, you must have N pixels in your solution.
If you want to regularize/smooth the result, you have two solutions:
Transform the contour as a parametric function and smooth it.
Do an interpolation (spline?)

Matlab multiple graph types inside one graph

I have a task to draw electrostatic field between
two electrodes( at given sizes and shape ),
what i have now is that i draw the electrodes with area plot (area(elect_x,elect_y))
the graph looks like this:
------------------.---
|..
.---. |..
|...| |..
.----....| |..
|........| |..
----------------------
and now i would need to draw inside this probably a mesh, showing the field.
Is there any way to do it, or i´m on a wrong way?
Thank you very much for every guide
First, if you want to overlay multiple plots in the same axes, type
hold on
before you plot the second graph (or set the 'NextPlot' property of the axes to 'add'), so that the first plot is not erased when the second one is drawn.
To show electrical field, you may want to have a look at quiver, so you can visualize both direction and strength of the fiels. Also check out is demo of quiver to get and idea how you could show field strength with colors.