This file is indexed.

/usr/share/axiom-20170501/src/algebra/SPACE3.spad is in axiom-source 20170501-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
)abbrev domain SPACE3 ThreeSpace
++ Author: Mark Botch
++ Description:
++ The domain ThreeSpace is used for creating three dimensional 
++ objects using functions for defining points, curves, polygons, constructs 
++ and the subspaces containing them.

ThreeSpace(R) : SIG == CODE where
  R : Ring
 
  I    ==> Integer
  PI   ==> PositiveInteger
  NNI  ==> NonNegativeInteger
  L    ==> List
  B    ==> Boolean
  O    ==> OutputForm
  SUBSPACE ==> SubSpace(3,R)
  POINT  ==> Point(R)
  PROP   ==> SubSpaceComponentProperty()
  REP3D  ==> Record(lp:L POINT,llliPt:L L L NNI, llProp:L L PROP, lProp:L PROP)
  OBJ3D  ==> Record(points:NNI, curves:NNI, polygons:NNI, constructs:NNI)

  SIG ==> ThreeSpaceCategory(R)

  CODE ==> add

    import COMPPROP
    import POINT
    import SUBSPACE
    import ListFunctions2(List(R),POINT)
    import Set(NNI)

    Rep := Record( subspaceField:SUBSPACE, compositesField:L SUBSPACE, _
                   rep3DField:REP3D, objectsField:OBJ3D, _
                   converted:B)
 
--% Local Functions

    convertSpace : % -> %
    convertSpace space ==
      space.converted => space
      space.converted := true
      lllipt : L L L NNI := [] 
      llprop : L L PROP := []
      lprop : L PROP := []
      for component in children space.subspaceField repeat
        lprop := cons(extractProperty component,lprop)  
        tmpllipt : L L NNI := []
        tmplprop : L PROP := []
        for curve in children component repeat
          tmplprop := cons(extractProperty curve,tmplprop)
          tmplipt : L NNI := []
          for point in children curve repeat
            tmplipt := cons(extractIndex point,tmplipt)
          tmpllipt := cons(reverse_! tmplipt,tmpllipt)
        llprop := cons(reverse_! tmplprop, llprop)
        lllipt := cons(reverse_! tmpllipt, lllipt)
      space.rep3DField := [pointData space.subspaceField, 
                           reverse_! lllipt,reverse_! llprop,reverse_! lprop]
      space
      

--% Exported Functions

    polygon(space:%,points:L POINT) ==
      #points < 3 =>
        error "You need at least 3 points to define a polygon"
      pt := addPoint2(space.subspaceField,first points)
      points := rest points
      addPointLast(space.subspaceField, pt, first points, 1)
      for p in rest points repeat
        addPointLast(space.subspaceField, pt, p, 2)
      space.converted := false
      space

    create3Space() == 
      [ new()$SUBSPACE, [], [ [], [], [], [] ], [0,0,0,0], false ]

    create3Space(s) == [ s, [], [ [], [], [], [] ], [0,0,0,0], false ]

    numberOfComponents(space) == #(children((space::Rep).subspaceField))

    numberOfComposites(space) == #((space::Rep).compositesField)

    merge(listOfThreeSpaces) ==
      newspace := _
        create3Space(merge([ts.subspaceField for ts in listOfThreeSpaces]))
      for ts in listOfThreeSpaces repeat 
        newspace.compositesField := _
          append(ts.compositesField,newspace.compositesField)
      newspace

    merge(s1,s2) == merge([s1,s2])

    composite(listOfThreeSpaces) ==
      space := create3Space()
      space.subspaceField := merge [s.subspaceField for s in listOfThreeSpaces]
      space.compositesField := [deepCopy space.subspaceField]
      space

    components(space) == 
      [create3Space(s) for s in separate space.subspaceField]

    composites(space) == [create3Space(s) for s in space.compositesField]

    copy(space) ==
      spc := create3Space(deepCopy(space.subspaceField))
      spc.compositesField := [deepCopy s for s in space.compositesField]
      spc

    enterPointData(space,listOfPoints) ==
      for p in listOfPoints repeat
        addPoint(space.subspaceField,p)
      #(pointData space.subspaceField)

    modifyPointData(space,i,p) ==
      modifyPoint(space.subspaceField,i,p)
      space

      -- 3D primitives, each grouped in the following order
      --     xxx?(s)  : query whether the threespace, s, holds an xxx
      --     xxx(s)   : extract xxx from threespace, s
      --     xxx(p)   : create a new three space with xxx, p
      --     xxx(s,p) : add xxx, p, to a three space, s
      --     xxx(s,q) : add an xxx, convertable from q, to a three space, s
      --     xxx(s,i) : add an xxx, the data for xxx being indexed by reference

    point?(space:%) ==
      #(c:=children space.subspaceField) > 1$NNI => 
        error "This ThreeSpace has more than one component"
        -- our 3-space has one component, a list of list of points
        -- the component has one subcomponent (a list of points)
      #(kid:=children first c) = 1$NNI => 
        -- this list of points only has one entry, so it's a point
        #(children first kid) = 1$NNI  
      false

    point(space:%) ==
      point? space => _
        extractPoint(traverse(space.subspaceField,[1,1,1]::L NNI))
      error "This ThreeSpace is not a single point - try the objects() command"

    point(aPoint:POINT) == point(create3Space(),aPoint)

    point(space:%,aPoint:POINT) ==
      addPoint(space.subspaceField,[],aPoint)
      space.converted := false
      space

    point(space:%,l:L R) ==
      pt := point(l)
      point(space,pt)

    point(space:%,i:NNI) ==
      addPoint(space.subspaceField,[],i)
      space.converted := false
      space

    curve?(space:%) ==
      #(c:=children space.subspaceField) > 1$NNI => 
        error "This ThreeSpace has more than one component"
        -- our 3-space has one component, a list of list of points
        -- there is only one subcomponent, so it's a list of points
      #(children first c) = 1$NNI 

    curve(space:%) ==
      curve? space => 
        spc := first children first children space.subspaceField
        [extractPoint(s) for s in children spc]
      error "This ThreeSpace is not a curve - try the objects() command"

    curve(points:L POINT) == curve(create3Space(),points)

    curve(space:%,points:L POINT) ==
      addPoint(space.subspaceField,[],first points)
      path : L NNI := [#(children space.subspaceField),1]
      for p in rest points repeat
        addPoint(space.subspaceField,path,p)
      space.converted := false
      space

    curve(space:%,points:L L R) ==
      pts := map(point,points)
      curve(space,pts)
      
    closedCurve?(space:%) ==
      #(c:=children space.subspaceField) > 1$NNI => 
        error "This ThreeSpace has more than one component"
        -- our 3-space has one component, a list of list of points
        -- there is one subcomponent => it's a list of points
      #(kid := children first c) = 1$NNI => 
        extractClosed first kid   -- is it a closed curve?
      false

    closedCurve(space:%) ==
      closedCurve? space => 
        spc := first children first children space.subspaceField 
          -- get the list of points
        [extractPoint(s) for s in children spc]  
          -- for now, we are not repeating points...
      error "This ThreeSpace is not a curve - try the objects() command"

    closedCurve(points:L POINT) == closedCurve(create3Space(),points)

    closedCurve(space:%,points:L POINT) ==
      addPoint(space.subspaceField,[],first points)
      path : L NNI := [#(children space.subspaceField),1]
      closeComponent(space.subspaceField,path,true)
      for p in rest points repeat
        addPoint(space.subspaceField,path,p)
      space.converted := false
      space

    closedCurve(space:%,points:L L R) ==
      pts := map(point,points)
      closedCurve(space,pts)

    polygon?(space:%) ==
      #(c:=children space.subspaceField) > 1$NNI => 
        error "This ThreeSpace has more than one component"
        -- our 3-space has one component, a list of list of points
      #(kid:=children first c) = 2::NNI => 
          -- there are two subcomponents
          -- the convention is to have one point in the first child and to put 
          -- the remaining points (2 or more) in the second, and last, child
        #(children first kid) = 1$NNI and #(children second kid) > 2::NNI
      false  -- => returns Void...?

    polygon(space:%) ==
      polygon? space =>
        listOfPoints : L POINT := 
          [extractPoint(first children first _
            (cs := children first children space.subspaceField))]
        [extractPoint(s) for s in children second cs]
      error "This ThreeSpace is not a polygon - try the objects() command"

    polygon(points:L POINT) == polygon(create3Space(),points)

    polygon(space:%,points:L L R) ==
      pts := map(point,points)
      polygon(space,pts) 

    mesh?(space:%) ==
      #(c:=children space.subspaceField) > 1$NNI => 
        error "This ThreeSpace has more than one component"
        -- our 3-space has one component, a list of list of points
      #(kid:=children first c) > 1$NNI => 
          -- there are two or more subcomponents (list of points)
          -- so this may be a definition of a mesh; if the size
          -- of each list of points is the same and they are all
          -- greater than 1(?) then we have an acceptable mesh
          -- use a set to hold the curve size info: if heterogenous
          -- curve sizes exist, then the set would hold all the sizes;
          -- otherwise it would just have the one element indicating
          -- the sizes for all the curves
          whatSizes := brace()$Set(NNI)
          for eachCurve in kid repeat
            insert_!(#children eachCurve,whatSizes)
          #whatSizes > 1 => error "Mesh defined with curves of different sizes"
          first parts whatSizes < 2 => 
            error "Mesh defined with single point curves (use curve())"
          true
      false

    mesh(space:%) ==
      mesh? space =>
        llp : L L POINT := []
        for lpSpace in children first children space.subspaceField repeat
          llp := cons([extractPoint(s) for s in children lpSpace],llp)
        llp
      error "This ThreeSpace is not a mesh - try the objects() command"

    mesh(points:L L POINT) == mesh(create3Space(),points,false,false)

    mesh(points:L L POINT,prop1:B,prop2:B) == 
      mesh(create3Space(),points,prop1,prop2)

    --+ old ones \/
    mesh(space:%,llpoints:L L L R,lprops:L PROP,prop:PROP) ==
      pts := [map(point,points) for points in llpoints]
      mesh(space,pts,lprops,prop)
    mesh(space:%,llp:L L POINT,lprops:L PROP,prop:PROP) ==
      addPoint(space.subspaceField,[],first first llp)
      defineProperty(space.subspaceField,path:L NNI:=_
        [#children space.subspaceField],prop)
      path := append(path,[1])
      defineProperty(space.subspaceField,path,first lprops)
      for p in rest (first llp) repeat
        addPoint(space.subspaceField,path,p)
      for lp in rest llp for aProp in rest lprops for count in 2.. repeat
        addPoint(space.subspaceField,path := [first path],first lp)
        path := append(path,[count])
        defineProperty(space.subspaceField,path,aProp)
        for p in rest lp repeat
          addPoint(space.subspaceField,path,p)
      space.converted := false
      space

    --+ old ones /\

    mesh(space:%,llpoints:L L L R,prop1:B,prop2:B) ==
      pts := [map(point,points) for points in llpoints]
      mesh(space,pts,prop1,prop2)

    mesh(space:%,llp:L L POINT,prop1:B,prop2:B) ==
        -- prop2 refers to property of the ends of a surface 
        -- (list of lists of points)
        -- while prop1 refers to the individual curves (list of points)
        -- ** note we currently use Booleans for closed (rather than a pair
        -- ** of booleans for closed and solid)
      propA : PROP := new()
      close(propA,prop1)
      propB : PROP := new()
      close(propB,prop2)
      addPoint(space.subspaceField,[],first first llp)
      defineProperty(space.subspaceField,path:L NNI:=_
        [#children space.subspaceField],propB)
      path := append(path,[1])
      defineProperty(space.subspaceField,path,propA)
      for p in rest (first llp) repeat
        addPoint(space.subspaceField,path,p)
      for lp in rest llp for count in 2.. repeat
        addPoint(space.subspaceField,path := [first path],first lp)
        path := append(path,[count])
        defineProperty(space.subspaceField,path,propA)
        for p in rest lp repeat
          addPoint(space.subspaceField,path,p)
      space.converted := false
      space

    lp space ==
      if ^space.converted then space := convertSpace space 
      space.rep3DField.lp

    lllip space   == 
      if ^space.converted then space := convertSpace space 
      space.rep3DField.llliPt

    llprop space == 
      if ^space.converted then space := convertSpace space 
      space.rep3DField.llProp

    lprop space  == 
      if ^space.converted then space := convertSpace space 
      space.rep3DField.lProp

      -- this function is just to see how this representation really
      -- does work
    objects space ==
      if ^space.converted then space := convertSpace space 
      numPts        := 0$NNI
      numCurves     := 0$NNI
      numPolys      := 0$NNI
      numConstructs := 0$NNI
      for component in children space.subspaceField repeat
        #(kid:=children component) = 1 =>
          #(children first kid) = 1 => numPts := numPts + 1
          numCurves := numCurves + 1
        (#kid = 2) and _
          (#children first kid = 1) and _
          (#children first rest kid ^= 1) =>
             numPolys := numPolys + 1
        numConstructs := numConstructs + 1
        -- otherwise, a mathematical surface is assumed
        -- there could also be garbage representation
        -- since there are always more permutations that
        -- we could ever want, so the user should not
        -- fumble around too much with the structure
        -- as other applications need to interpret it
      [numPts,numCurves,numPolys,numConstructs]

    check(s) ==
      ^s.converted => convertSpace s
      s

    subspace(s) == s.subspaceField

    coerce(s) == 
      if ^s.converted then s := convertSpace s
      hconcat(["3-Space with "::O, _
               (sizo:=#(s.rep3DField.llliPt))::O, _
               (sizo=1=>" component"::O;" components"::O)])