omdl
v0.9.5
OpenSCAD Mechanical Design Library
operation_cs.scad
Go to the documentation of this file.
1
//! Conditional version of standard transformations and operations.
2
/***************************************************************************/
/**
3
\file
4
\author Roy Allen Sutton
5
\date 2019-2024
6
7
\copyright
8
9
This file is part of [omdl] (https://github.com/royasutton/omdl),
10
an OpenSCAD mechanical design library.
11
12
The \em omdl is free software; you can redistribute it and/or modify
13
it under the terms of the [GNU Lesser General Public License]
14
(http://www.gnu.org/licenses/lgpl.html) as published by the Free
15
Software Foundation; either version 2.1 of the License, or (at
16
your option) any later version.
17
18
The \em omdl is distributed in the hope that it will be useful,
19
but WITHOUT ANY WARRANTY; without even the implied warranty of
20
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21
Lesser General Public License for more details.
22
23
You should have received a copy of the GNU Lesser General Public
24
License along with the \em omdl; if not, write to the Free Software
25
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26
02110-1301, USA; or see <http://www.gnu.org/licenses/>.
27
28
\details
29
30
\amu_define group_name (Conditional Operations)
31
\amu_define group_brief (Conditional transformations and operations.)
32
33
\amu_include (include/amu/pgid_path_pstem_pg.amu)
34
*******************************************************************************/
35
36
//----------------------------------------------------------------------------//
37
// group.
38
//----------------------------------------------------------------------------//
39
40
/***************************************************************************/
/**
41
\amu_include (include/amu/group_in_parent_start.amu)
42
\amu_include (include/amu/includes_required.amu)
43
*******************************************************************************/
44
45
//----------------------------------------------------------------------------//
46
47
//
48
// Transformations
49
//
50
51
//! Conditionally apply the convex hull transformation.
52
/***************************************************************************/
/**
53
\param c <boolean> conditional.
54
\param s <integer|integer-list|range> child object selection(s).
55
56
\details
57
58
When \p c is \b true, apply the transformation to the children
59
objects, otherwise return the children unmodified. When a child
60
object selection is specified, only the selected children are
61
returned irrespective of \p c.
62
*******************************************************************************/
63
module
hull_cs
64
(
65
c =
true
,
66
s
67
)
68
{
69
if
(
is_defined
(s) )
70
children(s);
71
else
if
( c )
72
hull()
73
{
74
children();
75
}
76
else
77
children();
78
}
79
80
//! Conditionally apply the minkowski sum transformation.
81
/***************************************************************************/
/**
82
\param c <boolean> conditional.
83
\param s <integer|integer-list|range> child object selection(s).
84
\param convexity <integer> The maximum number of front sides (or back
85
sides) a ray intersection the object might penetrate..
86
87
\details
88
89
When \p c is \b true, apply the transformation to the children
90
objects, otherwise return the children unmodified. When a child
91
object selection is specified, only the selected children are
92
returned irrespective of \p c.
93
*******************************************************************************/
94
module
minkowski_cs
95
(
96
c =
true
,
97
s,
98
convexity
99
)
100
{
101
if
(
is_defined
(s) )
102
children(s);
103
else
if
( c )
104
minkowski(convexity)
105
{
106
children(0);
107
children([1:$children-1]);
108
}
109
else
110
children();
111
}
112
113
//
114
// Boolean operations
115
//
116
117
//! Conditionally apply the union boolean operation.
118
/***************************************************************************/
/**
119
\param c <boolean> conditional.
120
\param s <integer|integer-list|range> child object selection(s).
121
122
\details
123
124
When \p c is \b true, apply the operation on the children objects,
125
otherwise return the children unmodified. When a child object
126
selection is specified, only the selected children are returned
127
irrespective of \p c.
128
*******************************************************************************/
129
module
union_cs
130
(
131
c =
true
,
132
s
133
)
134
{
135
if
(
is_defined
(s) )
136
children(s);
137
else
if
( c )
138
union
()
139
{
140
children();
141
}
142
else
143
children();
144
}
145
146
//! Conditionally apply the difference boolean operation.
147
/***************************************************************************/
/**
148
\param c <boolean> conditional.
149
\param s <integer|integer-list|range> child object selection(s).
150
151
\details
152
153
When \p c is \b true, apply the operation on the children objects,
154
otherwise return the children unmodified. When a child object
155
selection is specified, only the selected children are returned
156
irrespective of \p c.
157
*******************************************************************************/
158
module
difference_cs
159
(
160
c =
true
,
161
s
162
)
163
{
164
if
(
is_defined
(s) )
165
children(s);
166
else
if
( c && $children > 1 )
167
difference()
168
{
169
children(0);
170
children([1:$children-1]);
171
}
172
else
173
children();
174
}
175
176
//! Conditionally apply the difference intersection operation.
177
/***************************************************************************/
/**
178
\param c <boolean> conditional.
179
\param s <integer|integer-list|range> child object selection(s).
180
181
\details
182
183
When \p c is \b true, apply the operation on the children objects,
184
otherwise return the children unmodified. When a child object
185
selection is specified, only the selected children are returned
186
irrespective of \p c.
187
*******************************************************************************/
188
module
intersection_cs
189
(
190
c =
true
,
191
s
192
)
193
{
194
if
(
is_defined
(s) )
195
children(s);
196
else
if
( c && $children > 1 )
197
intersection()
198
{
199
children(0);
200
children([1:$children-1]);
201
}
202
else
203
children();
204
}
205
206
//! @}
207
//! @}
208
209
//----------------------------------------------------------------------------//
210
// end of file
211
//----------------------------------------------------------------------------//
is_defined
function is_defined(v)
Test if a value is defined.
difference_cs
module difference_cs(c=true, s)
Conditionally apply the difference boolean operation.
Definition:
operation_cs.scad:264
union_cs
module union_cs(c=true, s)
Conditionally apply the union boolean operation.
Definition:
operation_cs.scad:235
minkowski_cs
module minkowski_cs(c=true, s, convexity)
Conditionally apply the minkowski sum transformation.
Definition:
operation_cs.scad:200
intersection_cs
module intersection_cs(c=true, s)
Conditionally apply the difference intersection operation.
Definition:
operation_cs.scad:294
hull_cs
module hull_cs(c=true, s)
Conditionally apply the convex hull transformation.
Definition:
operation_cs.scad:169
tools
operation_cs.scad
Generated on Thu Nov 14 2024 11:12:08 for omdl by
doxygen
with
openscad-amu