OpenShapeFactory Manual
OpenShapeFactory Manual
Architectural Design
OpenShapeFactory Manual
Author:
a de Leo
n
Alexander Pen
Contents
1 Introduction
2 Boundary Representation
Interface
3 The
3.1
3.2
3.3
II
Application
Code Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Menus and Toolbars . . . . . . . . . . . . . . . . . . . . . . . . .
ViewPort Manipulations . . . . . . . . . . . . . . . . . . . . . . .
4
5
5
5
4 Sliders
4.1 getval(position,minval,maxval) . . . . . . . . . . . . . . . . . . .
7
7
5 File
5.1
5.2
5.3
5.4
5.5
5.6
.
.
.
.
.
.
7
7
7
7
7
7
8
6 Viewport
6.1 fitall . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.2 vis(objectname) . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.3 viscurvature(objectname) . . . . . . . . . . . . . . . . . . . . . .
8
8
8
8
7 Point Geometry
7.1 makepoint(x,y,z) . . . . . . . . . . . . . . . . .
7.1.1 makepointfromlist(list) . . . . . . . . . .
7.2 makepointmovebyvector(point,vector,distance)
7.3 makepointoncurve(curve,ratio) . . . . . . . . .
.
.
.
.
8
8
9
9
9
features
makeuvpt(srf,u,v) . . . . . . . . . . . . . . . . . . . . . . . . . . .
makeuvvec(srf,u,v) . . . . . . . . . . . . . . . . . . . . . . . . . .
getcoord(point,subparmposition) . . . . . . . . . . . . . . . . . .
9
9
10
10
8 UV
8.1
8.2
8.3
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
9 Vectors
9.1 makeuvvec(srf,u,v) . . . . . . . . . . .
9.2 makevector(u,v,w) . . . . . . . . . . .
9.3 makevectortangenttocurve(curve,ratio)
9.4 crossproduct(v1,v2) . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
10
10
10
10
10
10 Planes
10
10.1 makeplane(point,vector) . . . . . . . . . . . . . . . . . . . . . . . 10
11 Curve Geometry
11.1 makelineptdir(p1,v1,length1,length2)
11.2 makelineptpt(p1,p2) . . . . . . . . .
11.3 makebspline(pointlist) . . . . . . . .
11.3.1 makebspline Example: . . . .
11.4 makecircle(point,vector,radius) . . .
11.4.1 makecircle Example: . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
11
11
11
11
11
11
12
12 Surfaces
12
12.1 makefillsrf(shapelist) . . . . . . . . . . . . . . . . . . . . . . . . . 12
12.2 makeloft(shapelist) . . . . . . . . . . . . . . . . . . . . . . . . . . 12
12.3 makeoffsetsurface(surface,offsetval) . . . . . . . . . . . . . . . . . 12
13 Import / Export
12
13.1 importigs(filepath) . . . . . . . . . . . . . . . . . . . . . . . . . . 12
13.2 importstp(filepath) . . . . . . . . . . . . . . . . . . . . . . . . . . 12
14 Lists
14.1 addpointtolist(pointlist,point) .
14.2 addshapetolist(shapelist,object)
14.3 makeshapelist . . . . . . . . . .
14.4 makepointlist . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
12
12
13
13
13
15 Measure
13
15.1 getdistance(p1,p2) . . . . . . . . . . . . . . . . . . . . . . . . . . 13
16 Operations
13
16.1 makerotate(obj,vector,angle) . . . . . . . . . . . . . . . . . . . . 13
16.2 makesymmetry(obj,plane) . . . . . . . . . . . . . . . . . . . . . . 13
16.3 maketranslatebylength(obj,vector,distance) . . . . . . . . . . . . 13
17 Math
13
17.1 mcosh(parameter) . . . . . . . . . . . . . . . . . . . . . . . . . . 14
17.2 msinh(parameter) . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
18 utility
14
18.1 panelize(srf,u,v,panelfunc(p1,p2,p3,p4)) . . . . . . . . . . . . . . 14
3
19 Debug
14
19.1 print(msg); . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
19.2 printlist(list); . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
III
OpenShapeFactory Examples
14
15
15
15
23 Kilian Roof
15
18
IV
19
ECMAscript-262
25 ECMAScript Reference
25.1 The Global Object . .
25.2 Constructor Properties
25.3 Other Properties . . .
25.4 Array Objects . . . . .
25.5 Number Objects . . .
25.6 The Math Object . . .
25.7 Date Objects . . . . .
25.8 RegExp Objects . . .
25.9 Error Objects . . . . .
25.10The JSON Object . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
19
19
20
20
20
21
22
22
23
23
23
Introduction
Boundary Representation
The Geometry in OpenShapeFactory is represented using Boundary Representation, Boundary representation models are composed of two parts: topology
and geometry (surfaces, curves and points). The main topological items are:
faces, edges and vertices. A face is a bounded portion of a surface; an edge is a
bounded piece of a curve and a vertex lies at a point. Other elements are the
shell (a set of connected faces), the loop (a circuit of edges bounding a face) and
loop-edge links (also known as winged edge links or half-edges) which are used
to create the edge circuits. The edges are like the edges of a table, bounding a
surface portion.[from Wikipedia]
Part I
Interface
3
The Application
3d view port, any change to the code that results from a visible shape will be
immediately visible in the 3d view port.
3.1
Code Editor
3.2
3.3
ViewPort Manipulations
basic 2d manipulations:
1. panning : right-click and drag on 2d panel background
2. zoomming : use the scroll-wheel on your mouse, or the right side of your
touch pad on a laptop
3. moving widgets : left-click and drag on the gray area around any widget
7
Part II
Sliders
getval(position,minval,maxval)
creates a slider in the front end of the scriptwidget, position is the order in
which you would like to display the slider in the front end, if you specify 0 as
the position it will be the first.
Minvalue is the left limit of the slider, Maxvalue is the right limit of the
slider
5
5.1
Displays a filesystem dialog to locate a file and returns the filepath of the file
selected.
5.2
getfileonce(filenamepath)
same as getfile except forces the system to load the file only once, notice how
check shows on the interface allowing the user to select whether they want to
respect the single execution of the operation.
5.3
getdir
5.4
getdironce(dirpath)
same as getdir except forces the system to load the directory only once, notice
how check shows on the interface allowing the user to select whether they want
to respect the single execution of the operation.
5.5
readcsv(filename);
Load a comma seperated file as list: every row in the file is a list item every
item contains a subitem for every comma seperated element
9
5.6
watchfile(filepath)
link the evaluation of the script to execute, for every change in the file specified by filepath. if for instance you watch an igs file and that file is afterwards
modified by Rhino or Catia, simply by overriding the file, the code in OpenShapefactory will re-evaluate.
6
6.1
Viewport
fitall
fits the view to the bounding box of the geometry content of the script
6.2
vis(objectname)
Display the object in the viewport Any object that is created and is not visualized will be created in memory, but will no show on the viewport
6.3
viscurvature(objectname)
Display the object in the viewport with curvature information Any object that
is created and is not visualized will be created in memory, but will no show on
the viewport
7
7.1
Point Geometry
makepoint(x,y,z)
creates a point by the x y z coordinate note you must call the vis command and
pass the point to visualize it.
10
7.1.1
makepointfromlist(list)
7.2
makepointmovebyvector(point,vector,distance)
move a point in the direction of a vector using the distance as the amount of
units you want the point to move in the direction of the vector.
7.3
makepointoncurve(curve,ratio)
create a point on a curve as a percentage of the curve length, the ratio should
be a value from 0 to 1, 0 represents the start of the curve and 1 represents the
end of the curve, for example 0.5 would be the middle of the curve.
UV features
8.1
makeuvpt(srf,u,v)
create a point on the surface at the u and v coordinates, both the u and v values
requires a value between 0 and 1 on a parametrized surface.
if importing your geometry from rhino make sure to call the reparametrize
command on the surface, and specify the start parameter as 0 and the end
parameter as 1.
11
8.2
makeuvvec(srf,u,v)
create a vector normal to the surface at the u and v coordinates, both the u and
v values requires a value between 0 and 1 on a parametrized surface.
if importing your geometry from rhino make sure to call the reparametrize
command on the surface, and specify the start parameter as 0 and the end
parameter as 1.
8.3
getcoord(point,subparmposition)
gets the subcoordinate value of a point, for example if you had a point named p1
and you wanted to extract the z coordinate of the point you would so by calling
the function requesting the 3rd subcoordinate this way: z = getcoord(p1,3)
9
9.1
Vectors
makeuvvec(srf,u,v)
create a vector normal to the surface at the u and v coordinates, both the u and
v values requires a value between 0 and 1 on a parametrized surface.
if importing your geometry from rhino make sure to call the reparametrize
command on the surface, and specify the start parameter as 0 and the end
parameter as 1.
9.2
makevector(u,v,w)
9.3
makevectortangenttocurve(curve,ratio)
9.4
crossproduct(v1,v2)
Calculates the cross product of two vectors, v1 is the first vector and v2 is the
vector located to the right of vector2
10
10.1
Planes
makeplane(point,vector)
create a plane by using a point to locate the centre of the plane and a vector to
represent the direction perpendicular to the plane
12
11
Curve Geometry
11.1
makelineptdir(p1,v1,length1,length2)
create a line on the point in the direction specified by v1, extending length1
amounts in the negative direction and length2 amounts in the positive direciton
11.2
makelineptpt(p1,p2)
11.3
makebspline(pointlist)
Creates a B-Spline curve from a list of points, create a point list using the
makepointlist command and afterwards add the points using the addpointtolist
command.
11.3.1
p1
p2
p3
p4
=
=
=
=
makebspline Example:
makepoint(0,0,0)
makepoint(10,0,30)
makepoint(10,10,30)
makepoint(0,10,0)
mypointlist
mypointlist
mypointlist
mypointlist
mypointlist
=
=
=
=
=
makepointlist()
addpointtolist(mypointlist,p1)
addpointtolist(mypointlist,p2)
addpointtolist(mypointlist,p3)
addpointtolist(mypointlist,p4)
mybspline = makebspline(mypointlist)
11.4
makecircle(point,vector,radius)
creates a circle from its center point , a vector determining its perpendicular
direction , and it radius
13
11.4.1
makecircle Example:
12
12.1
Surfaces
makefillsrf(shapelist)
Create Coons surface, this surface fills the content of a curve or series of curves
given by the list.
12.2
makeloft(shapelist)
Create a Loft surface that passes through a list of curves, specified as crosssections
12.3
makeoffsetsurface(surface,offsetval)
Create an offset surface from the given surface using the offsetval as the amount
of units you want the offset surface to be away from the original reference surface.
13
13.1
Import / Export
importigs(filepath)
Imports an igs file and returns the brep of the file as a single shape
13.2
importstp(filepath)
Imports an step file and returns the brep of the file as a single shape
14
14.1
Lists
addpointtolist(pointlist,point)
14.2
addshapetolist(shapelist,object)
14.3
makeshapelist
creates a blank shape list, after using this command, normally you would invoke the addshapetolist(listname,objectotadd) in order to populate the list with
shapes.
this list can then be given as the input to a function such as makeloft.
14.4
makepointlist
creates a blank point list, after using this command, normally you would invoke
the addpointtolist(listname,pointtoadd) in order to populate the list with points.
this list can then be given as the input to a function such as makebspline.
15
15.1
Measure
getdistance(p1,p2)
16
16.1
Operations
makerotate(obj,vector,angle)
Rotate an object using the vector as the rotation axis and the angles as the
amount of angles to rotate in relation to its current location.
16.2
makesymmetry(obj,plane)
create a symmetry object of the object specified using the plane as the plane of
symmetry
16.3
maketranslatebylength(obj,vector,distance)
17
Math
to invoke Math Functions call Math.functionname for the case of the hyperbolic
cosine we had to forward the c++ version to the script. for the case of the
hyperbolic sine we had to forward the c++ version to the script.
15
17.1
mcosh(parameter)
hyperbolic cosine
17.2
msinh(parameter)
hyperbolic sine
18
18.1
utility
panelize(srf,u,v,panelfunc(p1,p2,p3,p4))
This function creates a grid scaffold around the surface, the function creates
as many panels specified by the u and v parameters, the user must create a
panelfunction with four points as inputs:
function
{
mypanel(p1,p2,p3,p4)
vis(p1)
vis(p3)
//vis(p2)
diag1 = makelineptpt(p1,p3)
diag2 = makelineptpt(p2,p4)
midp1 = makepointoncurve(diag1,0.5)
vis(midp1)
vis(diag1)
vis(diag2)
}
19
19.1
Debug
print(msg);
19.2
printlist(list);
16
Part III
OpenShapeFactory Examples
In this section we will introduce, examples to illustrate the use of OpenShapeFactory.
20
Type the following code in the code editor and see the geometry update as you
type.
p1 = makepoint(0,0,0) // create a point
vis(p1) // showpoint on viewport
21
Type the following code in the code editor and see the geometry update as you
type.
for(i = 1 ; i < 100 ; i++)
{
p1 = makepoint(i*i,i*10,0) // create a point
vis(p1) // showpoint on viewport
}
22
Type the following code in the code editor and see the geometry update as you
type.
p1 = makepoint(0,0,0) // create a point
vis(p1) // showpoint on viewport
p2 = makepoint(0,30,0) // create a point
vis(p2) // showpoint on viewport
l1 = makelineptpt(p1,p2) // make a line between 2 points
vis(l1) //show the line in the viewport
23
Kilian Roof
=
=
=
getval(3,minval,maxval)
getval(4,minval,maxval)
getval(5,0,maxval)
x3
y3
=
=
getval(6,minval,maxval)
getval(7,minval,maxval)
18
z3
getval(8,0,maxval)
x4
y4
z4
=
=
=
getval(9,minval,maxval)
getval(10,minval,maxval)
getval(11,0,maxval)
p1
p2
p3
p4
=
=
=
=
makepoint(x1,y1,0)
makepoint(x2,y2,0)
makepoint(x3,y3,0)
makepoint(x4,y4,0)
splineset = makepointlist()
splineset = addpointtolist(splineset,p1)
splineset = addpointtolist(splineset,p2)
splineset = addpointtolist(splineset,p3)
splineset = addpointtolist(splineset,p4)
spline1 = makebspline(splineset)
vis(spline1)
crs1
crs2
crs3
crs4
=
=
=
=
loftlist=
loftlist
loftlist
loftlist
loftlist
loft1 =
crossection(spline1,0,z1,z1)
crossection(spline1,0.25,z2,z2)
crossection(spline1,0.75,z3,z3)
crossection(spline1,1,z4,z4)
makeshapelist()
= addshapetolist(loftlist,crs1)
= addshapetolist(loftlist,crs2)
= addshapetolist(loftlist,crs3)
= addshapetolist(loftlist,crs4)
makeloft(loftlist)
panelize(loft1,10,10,mypanel)
function crossection(spline,percent,width,height)
{
ratio = percent
width = (width/2) +1
height = height + 1
up = makevector(0,0,1)
p1 = makepointoncurve(spline1,ratio)
v1 = makevectortangenttocurve(spline1,ratio)
l1 = makelineptdir(p1,v1,0,width)
left =
makerotate(l1,p1,up,-90)
right =
makerotate(l1,p1,up,90)
endpl = makepointoncurve(left,1)
endpr = makepointoncurve(right,1)
19
upline
endpup
=
=
makelineptdir(p1,up,0,height)
makepointoncurve(upline,1)
curvelist = makepointlist()
curvelist = addpointtolist(curvelist,endpl)
curvelist = addpointtolist(curvelist, endpup)
curvelist = addpointtolist(curvelist,endpr)
curve = makebspline(curvelist)
//vis(curve)
return
}
curve
function
{
mypanel(p1,p2,p3,p4)
vis(p1)
vis(p3)
//vis(p2)
diag1 = makelineptpt(p1,p3)
diag2 = makelineptpt(p2,p4)
midp1 = makepointoncurve(diag1,0.5)
vis(midp1)
vis(diag1)
vis(diag2)
}
24
ucount = getval(0,1,100)
vcount = getval(0,1,100)
upercent = getval(0,1,100)
vpercent = getval(0,1,100)
a = getval(1,1,100)
b = getval(2,1,100)
c = getval(3,1,100)
upival = 2 * 3.14 * (upercent/100)
vpival = 2 * 3.14 * (vpercent/100)
a1 = a /100
b1 = b /100
c1 = c /100
a2 = a/4 /100
20
b2 =
c2 =
b /100
c /3 /100
for (i=0;i<ucount;i++) {
u = (upival/ ucount) * i
for (j=0;j<vcount;j++) {
v = (vpival / vcount) *
x=a1 * Math.cos(u) *
y=b1 * Math.sin(u) *
z= c1 * Math.cos(v)
Math.sin(v)
Math.sin(v)
Part IV
ECMAscript-262
25
ECMAScript Reference
This reference contains a list of built-in objects, functions and properties supported by QtScript. For a detailed description, see the ECMA-262 specification.
25.1
NaN
Infinity
undefined
eval(x)
parseInt(string, radix)
parseFloat(string)
isNaN(number)
21
isFinite(number)
decodeURI(encodedURI)
decodeURIComponent(encodedURIComponent)
encodeURI(uri)
encodeURIComponent(uriComponent)
25.2
Constructor Properties
Object
Function
Array
String
Boolean
Number
Date
RegExp
Error
EvalError
RangeError
ReferenceError
SyntaxError
TypeError
URIError
25.3
Other Properties
Math
JSON
Object Objects
Object Constructor
Function Properties
getPrototypeOf(O)
getOwnPropertyDescriptor(O, P)
getOwnPropertyNames(O)
create(O [, Properties])
defineProperty(O, P, Attributes)
defineProperties(O, Properties)
keys(O)
25.4
Array Objects
toString()
toLocaleString()
concat([item1 [, item2 [, ...]]])
join(separator)
pop()
22
25.5
Number Objects
toString(radix)
toLocaleString()
toFixed(fractionDigits)
toExponential(fractionDigits)
toPrecision(precision)
23
25.6
E
LN10
LN2
LOG2E
LOG10E
PI
$SQRT1_2$
$SQRT2$
Function Properties
abs(x)
acos(x)
asin(x)
atan(x)
atan2(y, x)
ceil(x)
cos(x)
exp(x)
floor(x)
log(x)
max([value1 [, value2 [, ...]]])
min([value1 [, value2 [, ...]]])
pow(x, y)
random()
round(x)
sin(x)
sqrt(x)
tan(x)
25.7
Date Objects
toString()
toDateString()
toTimeString()
toLocaleString()
toLocaleDateString()
toLocaleTimeString()
valueOf()
getTime()
getFullYear()
getUTCFullYear()
getMonth()
getUTCMonth()
getDate()
getUTCDate()
24
getDay()
getUTCDay()
getHours()
getUTCHours()
getMinutes()
getUTCMinutes()
getSeconds()
getUTCSeconds()
getMilliseconds()
getUTCMilliseconds()
getTimeZoneOffset()
setTime(time)
setMilliseconds(ms)
setUTCMilliseconds(ms)
setSeconds(sec [, ms])
setUTCSeconds(sec [, ms])
setMinutes(min [, sec [, ms]])
setUTCMinutes(min [, sec [, ms]])
setHours(hour [, min [, sec [, ms]]])
setUTCHours(hour [, min [, sec [, ms]]])
setDate(date)
setUTCDate(date)
setMonth(month [, date])
setUTCMonth(month [, date])
setFullYear(year [, month [, date]])
setUTCFullYear(year [, month [, date]])
toUTCString()
toISOString()
toJSON()
25.8
RegExp Objects
exec(string)
test(string)
toString()
25.9
Error Objects
name
message
Function Properties
toString()
25.10
parse(text [, reviver])
25
26