If you're reading this, we've just migrated servers! If anything looks broken please email dion@thinkmoult.com :)
BlenderBIM: vector based lines beyond the section cut
This discussion was created from comments split from: BlenderBIM: vector based lines beyond the section cut.
Comments
@JanF Correct, the BlenderBIM Add-on operates directly on the IFC, so it is possible to develop a standalone viewer ... with one issue which needs to be resolved: objects in the background (i.e. not cut) are rendered as raster. Currently, that uses the Blender OpenGL renderer, so a standalone one would have to recreate an OpenGL renderer... which is a bit of work, but not a huge amount, especially for someone who knows their C++ and OpenCASCADE.
It is certainly possible to store 2D plans. Maybe what the course on BIM meant was that most vendors don't support it - the BlenderBIM Add-on is an exception to the rule, but is not the only one, but they are certainly rare. I can think of three ways:
IfcAnnotation
elements for all annotation, associated byIfcGroup
and presentation layers (like CAD layers). This is how the BlenderBIM Add-on achieves it.IfcAnnotation
if you wish, or also separate to any arbitrary number of IFC elements, but as there is no need to associate with the 3D model, you do not need to store the Model context on any of these elements. This is a bit similar to your "Blender empty object" example, but it wouldn't be an empty - it'd be something a little advanced that contains a lot of vector and style info that I'm not quite sure how to represent in Blender's UI yet, but certainly is possible in IFC.Is the Blender Freestyle renderer suitable for generating these background objects?
@brunopostle in my tests half a year ago, the HLR calculation was too costly (i.e. took too long) to be practical with Freestyle.
Keep in mind that since it's simply a background layer created by Blender's render output, you could totally use freestyle if you wanted to. Nothing in the add-on forces you to only use a raster image as the background.
For those who have seen the Sverchok vector drawings, they simply pile 2D polygons on top of one another with Z layering, so although it's much faster to compute, you end up with SVGs with very huge filesizes. I've tested this approach too with OpenCASCADE but the drawing sizes were too huge to be convenient.
Tough nut to crack.
@Moult there are some 2D drawings where the 'background' is the drawing and the section cuts are secondary (elevations, reflected ceiling plans), in these cases we need to render the background as vector. I'm suprised that opencascade doesn't have some kind of efficient hidden line removal built-in. Obviously this is a hard problem, AutoCAD PDF output rasterises hidden line views too. [edit] the AutoCAD SOLPROF command does an almost perfect job with ACIS solids for orthogonal views, so it can be done.
@Moult I assume you are familiar with this paper?
It seems to be pretty exhaustive on the different methods of generating the curves.
@brunopostle yes - agreed. In fact, a lot of drawings are pure elevation, especially in fabrication stage. I'm still searching for a better solution. I'm unfortunately not an expert in this - I don't have a training in algorithms for computer graphics, or really much computer science at all, and a lot of this is usually in C++, which I don't know how to code in. I hope someone can help solve it, but until then, I do what I can with the best of my ability :)
As for OpenCASCADE, it does have a whole section on HLR: https://www.opencascade.com/doc/occt-7.4.0/refman/html/package_hlrbrep.html
I definitely investigated it many moons ago when I was starting to tackle this problem, but from memory (memory fades!) I think it only addressed lines, whereas I needed to know face areas - since in a lot of these elevation drawings, you often want to shade the surface, not just the lines. But there's a huge list on that page I linked to, and I think I only investigated a few, so I perhaps missed something. In fact, I hope I missed something and perhaps it's actually very easy :)
Also, I think the solution is much easier with solids, since there are rules around each type of solid - in IFC, where you get meshes, solids, and even parametric I-Beams as a primitive shape, things become a little be hairier.
@JanF - I'm not familiar with that paper unfortunately. I had a skim through and it looks excellent, and hopefully there is a solution buried there somewhere. I'm a little tied up at the moment, but hopefully I can revisit this thread in the future. However, if someone wants to jump in, the shopping list is as follows:
Heads up, blender will embed potrace for grease pencil soon (2.91) maybe this will help in getting vectors from pixels - don't know if a trace api will be exposed for addons.
Perhaps the 3d to 2d tool of grease pencil may be an option ?
Noobie question. Why not use Blender's Freestyle SVG plugin to create vector lines on objects that are beyond the section cut?
@theoryshaw when I tried it, it was too slow. Maybe I wasn't using it correctly, I'm not experienced enough in Freestyle to know what I don't know :)
Freestyle is painfully slow as vector generation rely on rendered pixels data and there are some "threshold" issues in the vectorization process.
The new approach (LANPR) use opengl display information instead, leading in near real-time vector generation - but the "threshold" issues will remains.
I assume this is what you were talking about?
This is about potrace
rumblings on vector based lines beyond the section cut: https://github.com/IfcOpenShell/IfcOpenShell/issues/1153#issuecomment-745370980