How do CAD programs display parametric models? - cad

Softwares like Catia, SolidWorks or the like all can visualize complex models while designing.
Exporting such models to raster triangle meshes yields huge files that later need to be greatly simplified to be imported into 3D engines like Unreal Engine or equivalent.
My question is: how do they visualize such complex geometries without rasterization? How do they do it that fast?

GPUs can only deal with triangles, therefore they tessellate geometry exactly as for STL export. Tessellation tolerance may vary from display to STL export affecting the time required to compute it.

Exporting such models to raster triangle meshes yields huge files
Not entirely correct. When you ask solidworks for the mesh you also provide quality that will influence number of triangles you receive - can be millions, can be just a dozen.
CAD packages operate with most bodies/shapes analytically - they have a formula. My guess is any other 3D engine does the same, the thing is format of the analytical data that different engines use is not the same. So you need to convert from one to another using triangles, format that everybody understands.

Related

Why is a normal vector necessary for STL files?

STL is the most popular 3d model file format for 3d printing. It records triangular surfaces that makes up a 3d shape.
I read the specification the STL file format. It is a rather simple format. Each triangle is represented by 12 float point number. The first 3 define the normal vector, and the next 9 define three vertices. But here's one question. Three vertices are sufficient to define a triangle. The normal vector can be computed by taking the cross product of two vectors (each pointing from a vertex to another).
I know that a normal vector can be useful in rendering, and by including a normal vector, the program doesn't have to compute the normal vectors every time it loads the same model. But I wonder what would happen if the creation software include wrong normal vectors on purpose? Would it produce wrong results in the rendering software?
On the other hand, 3 vertices says everything about a triangle. Include normal vectors will allow logical conflicts in the information and increase the size of file by 33%. Normal vectors can be computed by the rendering software under reasonable amount of time if necessary. So why should the format include it? The format was created in 1987 for stereolithographic 3D printing. Was computing normal vectors to costly to computers back then?
I read in a thread that Autodesk Meshmixer would disregard the normal vector and graph triangles according to the vertices. Providing wrong normal vector doesn't seem to change the result.
Why do Stereolithography (.STL) files require each triangle to have a normal vector?
At least when using Cura to slice a model, the direction of the surface normal can make a difference. I have regularly run into STL files that look just find when rendered as solid objects in any viewer, but because some faces have the wrong direction of the surface normal, the slicer "thinks" that a region (typically concave) which should be empty is part of the interior, and the slicer creates a "top layer" covering up the details of the concave region. (And this was with an STL exported from a Meshmixer file that was imported from some SketchUp source).
FWIW, Meshmixer has a FlipSurfaceNormals tool to help deal with this.

3D visualization - rotating cube

I have many 3D vectors. I want to plot them in a cube so that each dimension is on a particular side of the cube.
Now, I am looking for some visualization/tool or library that lets me rotate this cube in 3D and see the vectors in various different angles.
Thanks
Abhishek S
Try Processing, it is somewhat intended for data visualization and in addition to simple control over 3D drawing, it also has the full power of Java programming language. You can see numerous works, done by other people on OpenProcessing.
However, if you are into anything serious, I would suggest you to use some ohter IDE than the default one. I use Eclipse for that, importing Processing as a library into my project. It requires a tiny boilerplate to work, but then you're happy!

Geometric/Shape Recognition ( Odd Shape )

I would like to do some odd geometric/odd shape recognition. But I'm not sure how to do it.
Here's what I have so far:
Convert RGB image to Monochrome.
Otsu Threshold
Hough Transform.
I'm not sure what to do next.
For geometric information, you could do a raster to vector conversion to convert your image into coordinated vectors (lines and points) and finite element analysis to look for known shapes. Not easy but libraries should be available for both.
Edit: Note that there are sometimes easier practical solutions, but they depend on the image and types of errors. For example, removing perspective, identifying a 3d object from a 2d image, significance of colour, etc... You often see registration markers added to the real world object to overcome
this and allow much easier identification. Looking up articles on feature extraction techniques might help.

Making tree-diagrams with pdf output without using graphviz

I usually like graphviz a lot for making graphs and trees and outputting them to pdf files. Right now I have a program that builds a tree with a large branching factor (up to 12, usually closer to 8 or 9). The problem is that graphviz cannot draw the tree more than two or three levels deep (and less if I use my fancy labels).
My train of thought is that this is a very simple graphic to generate. It's a very generic tree structure and no specialized placement algorithms are needed at all. I'm wondering if anybody knows of another software package that might get the job done. Here are the features I'm looking for:
Bare minimum:
Draws really wide trees with many vertices (perhaps a few million)
Outputs to pdf, postscript, svg, or some other common, portable graphics format
Good to have:
input format similar to graphviz
nodes that can be colored
html-style tables, similar to the awesome ones that graphviz has
Have you considered TikZ? http://www.texample.net/tikz/examples/tag/graphs/
I have not had to make graphs with millions of nodes, so I can't be sure this will work.
I originally suggested, in a comment, that graphviz provided facilities to produce multi-million node graphs. The rendering engine I was thinking of was sfdp, which is supplied as part of the graphviz package. An example is provided in the Graphviz gallery. As far as I am aware, this can be used with all the normal Graphviz output facilities.

Non-Affine image transformations in .NET

Are there any classes, methods in the .NET library, or any algorithms in general, to perform non-affine transformations? (i.e. transformations that involve more than just rotation, scale, translation and shear)
e.g.:
(source: last100.com)
Is there another term for non-affine transformations?
I am not aware of anything integrated in .Net letting you do non affine transforms.
I guess you are trying to have some sort of 3D texture mapping? If that's the case you need an homogenous affine transform, which is not available in .Net. I'm also not aware of any integrated way to make pixel displacement transforms in .Net.
However, the currently voted solution might be good for what you are trying to do, just be aware that it won't do perspective correction out of the box.
For instance:
The picture on the left was generated using the single quad distort library provided by Neil N. The picture on the right was generated using a single quad (two triangles actually) in DirectX.
This may not have any impact on what you are trying to do, but this is something to keep in mind if you want to do 3D stuff, it will look very weird without perspective correct mapping.
All of the example images you posted can be done with a Quadrilateral Distortion. Though I cant say for certain that a quad distort will cover ALL non affine transforms.
Heres a link to a not so good implementation of it in C#... it works, but is slow. Poke around Wikipedia for the many different optimizations available for these kinds of calculations
http://www.vcskicks.com/image-distortion.html
-Neil
You can do this in wpf using a the Viewport3d control and a non-affine transform matrix. Rendering this to a bitmap again may be interesting.... Which I "fixed" by including an invisible <image> control with the same image as on my textured plane... (Also, I've had to work around the max texture size issues by splitting up the plane and cropping images...)
http://www.charlespetzold.com/blog/2007/08/060605.html
In my case I wanted the reverse of this (transform so arbitrary points on the warped become the corners of my rectangular window), which is the Inverse of the matrix to do the opposite.

Resources