Root/cad/test2/README

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

Archive Download this file

Branches:
master



interactive