Frusta

Check-in [8c02f0c506]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:initial swag at db objects
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:8c02f0c50673dd137aa8697e9145bcd9d2bd97e3
User & Date: rmelton 2013-05-29 22:23:57
Context
2013-05-30
14:36
forgot to add sqlite in prior commit check-in: 76b1afdf30 user: rmelton tags: trunk
2013-05-29
22:23
initial swag at db objects check-in: 8c02f0c506 user: rmelton tags: trunk
17:00
bumped version number to 0.1 check-in: a18d250364 user: rmelton tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to lib/geom.tcl.




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



namespace eval Geom {
  ## a geometry manager layer.  It knows about:
  ##  a library of named "objects"
  ##  each named object is composed of a list facets
  ##    (pure STL for now)

  ## rev 0.1 - start object management.  organize objects by name
  variable obj
  ## obj($name) = {facetList pathList pathLayerRange}


  variable facets {}


































  variable paths {}
  variable layerMin 0
  variable layerMax 0
  proc NewObject {name facetList pathList layerRange} {
    log::Puts -- [format "create object %s with %d facets %d paths" $name [llength $facetList] [llength $pathList]]
    variable facets
    set facets $facetList


































    variable paths
    set paths $pathList
    variable layerMin
    variable layerMax
    if {[llength $layerRange] == 2} {
      lassign $layerRange layerMin layerMax
    }
    variable obj
    set obj($name) [list $facetList $pathList $layerRange]

















  }
  proc FacetExtents {facet} {
    ## format {normal V1 V2 v3}
    lassign $facet normal v1 v2 v3
    lassign $v1 x1 y1 z1
    lassign $v2 x2 y2 z2
    lassign $v3 x3 y3 z3
>
>
>











|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>





<
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>









>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







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
package require sqlite3


namespace eval Geom {
  ## a geometry manager layer.  It knows about:
  ##  a library of named "objects"
  ##  each named object is composed of a list facets
  ##    (pure STL for now)

  ## rev 0.1 - start object management.  organize objects by name
  variable obj
  ## obj($name) = {facetList pathList pathLayerRange}


  proc Init {} {
    ## create an in-memory database
    sqlite3 geomDB ":memory:" -nomutex 1
    geomDB eval {
      CREATE TABLE 'facets'
      (
       objName "TEXT",
       minX "NUM", minY "NUM", minZ "NUM",
       maxX "NUM", maxY "NUM", maxZ "NUM",
       x1 "NUM", y1 "NUM", z1 "NUM",
       x2 "NUM", y2 "NUM", z2 "NUM",
       x3 "NUM", y3 "NUM", z3 "NUM",
       xN "NUM", yN "NUM", zN "NUM")
    }
  }

  if {0} {
    proc dbQuote {x} {return [format {'%s'} $x]}
    proc dbQuoteList {x} {
      set ans {}
      foreach i $x {
        lappend ans [dbQuote $i]
      }
      return $ans
    }
    proc dbQuoteIdent {x} {return [format {[%s]} $x]}
    proc dbQuoteIdentList {x} {
      set ans {}
      foreach i $x {
        lappend ans [dbQuoteIdent $i]
      }
      return $ans
    }
  }

  variable paths {}
  variable layerMin 0
  variable layerMax 0
  proc NewObject {name facetList pathList layerRange} {
    log::Puts -- [format "create object %s with %d facets %d paths" $name [llength $facetList] [llength $pathList]]

    foreach facet $facetList {
      lassign $facet normal v1 v2 v3
      lassign $v1 x1 y1 z1
      lassign $v2 x2 y2 z2
      lassign $v3 x3 y3 z3
      lassign $normal xN yN zN
      ## by hand
      set minX [expr {min($x1,$x2,$x3)}]
      set minY [expr {min($y1,$y2,$y3)}]
      set minZ [expr {min($z1,$z2,$z3)}]
      set maxX [expr {max($x1,$x2,$x3)}]
      set maxY [expr {max($y1,$y2,$y3)}]
      set maxZ [expr {max($z1,$z2,$z3)}]
      if {0} {
        lassign [FacetExtents $facet] minP maxP
        lassign $minP minX minY minZ
        lassign $maxP maxX maxY maxZ
      }
      geomDB eval {INSERT INTO 'facets'
        ([objName],
         minX, minY, minZ,
         maxX, maxY, maxZ,
         x1, y1, z1,
         x2, y2, z2,
         x3, y3, z3,
         xN, yN, zN)
        VALUES
        ($name,
         $minX, $minY, $minZ,
         $maxX, $maxY, $maxZ,
         $x1, $y1, $z1,
         $x2, $y2, $z2,
         $x3, $y3, $z3,
         $xN, $yN, $zN)}
    }
    variable paths
    set paths $pathList
    variable layerMin
    variable layerMax
    if {[llength $layerRange] == 2} {
      lassign $layerRange layerMin layerMax
    }
    variable obj
    set obj($name) [list $facetList $pathList $layerRange]
    ## dump the db
    set dump [geomDB eval {SELECT ALL
      [objName],
      [minX], minY, minZ,
      maxX, maxY, maxZ,
      x1, y1, z1,
      x2, y2, z2,
      x3, y3, z3,
      xN, yN, zN
      FROM
      [facets]
    }]
    puts stderr "DB DUMP"
    foreach {a b c  d e f  g h i  j k l  m n o  p q r  s} $dump {
      puts stderr [list $a  "min=" $b $c  $d "max=" $e $f  $g "A=" $h $i  $j "B=" $k $l  $m "C=" $n $o  $p "N=" $q $r  $s]
    }
    #puts stderr $dump
  }
  proc FacetExtents {facet} {
    ## format {normal V1 V2 v3}
    lassign $facet normal v1 v2 v3
    lassign $v1 x1 y1 z1
    lassign $v2 x2 y2 z2
    lassign $v3 x3 y3 z3

Changes to main.tcl.

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
# \
exec ./tclkit "$0" ${1+"$@"}

set cfg(installPath) [file dirname [info script]]
set cfg(frustaLib)   [file join $cfg(installPath) lib]
set cfg(kitLib)      [file join $cfg(installPath) kits]





## hard code for now, autoload later...
source [file join $cfg(frustaLib) commandLineArgs.tcl]
source [file join $cfg(frustaLib) stl.tcl]
source [file join $cfg(frustaLib) gcode.tcl]
source [file join $cfg(frustaLib) geom.tcl]
source [file join $cfg(frustaLib) gui.tcl]
source [file join $cfg(frustaLib) view.tcl]
source [file join $cfg(frustaLib) menu.tcl]
source [file join $cfg(frustaLib) logging.tcl]

##
lappend auto_path [file join $cfg(frustaLib) utils]

## kits stuff
lappend auto_path [file join $cfg(kitLib) Canvas3d]

proc Exit {} {
  ## do any needed cleanup


  exit
}

## main

parseCmdlineArgs



## Local Variables:
## mode: tcl
## tcl-indent-level: 2
## indent-tabs-mode: nil
## End:







>
>
>
>













<
<
<


>
>




>









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
# \
exec ./tclkit "$0" ${1+"$@"}

set cfg(installPath) [file dirname [info script]]
set cfg(frustaLib)   [file join $cfg(installPath) lib]
set cfg(kitLib)      [file join $cfg(installPath) kits]

## kits stuff
lappend auto_path [file join $cfg(kitLib) Canvas3d]
lappend auto_path [file join $cfg(kitLib) sqlite3]

## hard code for now, autoload later...
source [file join $cfg(frustaLib) commandLineArgs.tcl]
source [file join $cfg(frustaLib) stl.tcl]
source [file join $cfg(frustaLib) gcode.tcl]
source [file join $cfg(frustaLib) geom.tcl]
source [file join $cfg(frustaLib) gui.tcl]
source [file join $cfg(frustaLib) view.tcl]
source [file join $cfg(frustaLib) menu.tcl]
source [file join $cfg(frustaLib) logging.tcl]

##
lappend auto_path [file join $cfg(frustaLib) utils]




proc Exit {} {
  ## do any needed cleanup
  #puts stderr "closing in-memory db"
  geomDB close
  exit
}

## main
Geom::Init
parseCmdlineArgs



## Local Variables:
## mode: tcl
## tcl-indent-level: 2
## indent-tabs-mode: nil
## End: