Werner's Miscellanea
Sign in or create your account | Project List | Help
Werner's Miscellanea Git Source Tree
Root/
| 1 | Comparison of Free scripted 3D CAD systems, part 2 |
| 2 | ================================================== |
| 3 | |
| 4 | Werner Almesberger <werner@almesberger.net> |
| 5 | |
| 6 | This is the continuation of my evaluation of scripted 3D CAD systems. |
| 7 | It shows new findings and improvements since the last test. |
| 8 | |
| 9 | |
| 10 | Introduction |
| 11 | ============ |
| 12 | |
| 13 | This file and the sources of the models can be found in |
| 14 | http://projects.qi-hardware.com/index.php/p/wernermisc/source/tree/master/cad/test2/ |
| 15 | |
| 16 | |
| 17 | New findings and hypotheses |
| 18 | =========================== |
| 19 | |
| 20 | The first test revealed several problems in both OpenSCAD and |
| 21 | Cadmium. It turned out that most of them could be resolved by making |
| 22 | small changes to the models. |
| 23 | |
| 24 | |
| 25 | The road to hell is paved with good intentions |
| 26 | ---------------------------------------------- |
| 27 | |
| 28 | The original model tried to prevent the creation of artefacts through |
| 29 | rounding errors. It turned out that this isn't only unnecessary with |
| 30 | Cadmium, but it massively slows down the rendering. |
| 31 | |
| 32 | Also, after removing these preventions the bug the "noise" parameter |
| 33 | worked around no longer appeared. |
| 34 | |
| 35 | This is a comparison of run time (in seconds) and mesh size: |
| 36 | |
| 37 | real user system faces vertices |
| 38 | Before: 4901.0 4904.4 1.5 8362 3183 |
| 39 | After: 316.3 315.9 0.3 2942 1473 |
| 40 | |
| 41 | This makes Cadmium only about 4-5 times slower than OpenSCAD's CGAL |
| 42 | rendering, a marked improvement from the previous factor of 57. The |
| 43 | resulting mesh is now less than half the size of the mesh generated |
| 44 | by OpenSCAD. |
| 45 | |
| 46 | Furthermore, the model is much easier to design and more |
| 47 | understandable without these extra tolerances. |
| 48 | |
| 49 | |
| 50 | Background: preventing artefacts |
| 51 | -------------------------------- |
| 52 | |
| 53 | When subtracting volumes from each other, surfaces that coincide in |
| 54 | both the original volume and the one subtracted from it can remain |
| 55 | as arbitrarily thin artefacts. |
| 56 | |
| 57 | This 2D example illustrates the effect: |
| 58 | |
| 59 | - given an original shape like this |
| 60 | |
| 61 | +---------------+ |
| 62 | | | |
| 63 | | | |
| 64 | | | |
| 65 | | | |
| 66 | | | |
| 67 | +---------------+ |
| 68 | |
| 69 | - we want to subtract the following shape from it: |
| 70 | |
| 71 | +--------+ |
| 72 | | | |
| 73 | +--------+ |
| 74 | |
| 75 | - expecting this to result in something like |
| 76 | |
| 77 | +---------------+ |
| 78 | | | |
| 79 | | +--------+ |
| 80 | | | |
| 81 | | +--------+ |
| 82 | | | |
| 83 | +---------------+ |
| 84 | |
| 85 | - however, if the subtraction isn't perfectly exact, we may get this |
| 86 | instead: |
| 87 | |
| 88 | +---------------+ |
| 89 | | | |
| 90 | | +--------+ |
| 91 | | | |<--- very thin surface |
| 92 | | +---^----+ |
| 93 | | | | |
| 94 | +----------|----+ |
| 95 | | |
| 96 | empty space |
| 97 | |
| 98 | - to avoid this problem, we could enlarge the shape that is |
| 99 | subtracted: |
| 100 | |
| 101 | +---------+ |
| 102 | | | |
| 103 | +---------+ |
| 104 | |
| 105 | |
| 106 | Artefacts in OpenSCAD's mesh were rounding errors |
| 107 | ------------------------------------------------- |
| 108 | |
| 109 | The artefacts found in the mesh produced by OpenSCAD were also caused |
| 110 | by rounding errors. In this case, the problem were parts that were |
| 111 | fused along a common surface. As in the above example, this could be |
| 112 | solved by making the parts overlap a little. |
| 113 | |
| 114 | This change affected the rendering performance as follows: |
| 115 | |
| 116 | real user system faces vertices |
| 117 | Before: 85.5 85.0 0.4 7798 3351 |
| 118 | After: 68.8 65.4 0.5 6508 3258 |
| 119 | |
| 120 | The resulting mesh looks as good as the one generated by Cadmium. |
| 121 | |
| 122 | |
| 123 | OpenCSG problems may be an OpenGL compatibility issue |
| 124 | ----------------------------------------------------- |
| 125 | |
| 126 | It could be that OpenCSG showing volumes to be removed just with a |
| 127 | different color without actually removing them is caused by using |
| 128 | OpenGL emulation in Mesa. This needs further investigation. |
| 129 | |
| 130 | |
| 131 | Conclusion |
| 132 | ========== |
| 133 | |
| 134 | The model used in the first test contained constructs that were meant |
| 135 | to help avoid ambiguous situations. It turned out that Cadmium did |
| 136 | not need this "help" and removing the constructs substantially |
| 137 | increased the rendering speed. |
| 138 | |
| 139 | OpenSCAD is the exact opposite: it produces clearly visible |
| 140 | artefacts in ambiguous cases and rendering speed also benefits from |
| 141 | manual resolution of these issues. The cost of doing so is an |
| 142 | increase of the complexity of the model. |
| 143 | |
| 144 | Performance after the model changes (times are in seconds): |
| 145 | |
| 146 | real user system faces vertices |
| 147 | OpenSCAD: 68.8 65.4 0.5 6508 3258 |
| 148 | Cadmium: 316.3 315.9 0.3 2942 1473 |
| 149 | |
| 150 | The sources of the models used are in |
| 151 | http://projects.qi-hardware.com/index.php/p/wernermisc/source/tree/master/cad/test2/ |
| 152 | |
| 153 | The meshes can be downloaded from |
| 154 | http://downloads.qi-hardware.com/people/werner/cad/test2/ |
| 155 | |
| 156 | --------------------------------------------------------------------- |
| 157 |
Branches:
master
