Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-09 07:48:51

0001 #!/usr/bin/env python
0002 #
0003 # Copyright (c) 2019 Opticks Team. All Rights Reserved.
0004 #
0005 # This file is part of Opticks
0006 # (see https://bitbucket.org/simoncblyth/opticks).
0007 #
0008 # Licensed under the Apache License, Version 2.0 (the "License"); 
0009 # you may not use this file except in compliance with the License.  
0010 # You may obtain a copy of the License at
0011 #
0012 #   http://www.apache.org/licenses/LICENSE-2.0
0013 #
0014 # Unless required by applicable law or agreed to in writing, software 
0015 # distributed under the License is distributed on an "AS IS" BASIS, 
0016 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  
0017 # See the License for the specific language governing permissions and 
0018 # limitations under the License.
0019 #
0020 
0021 
0022 """
0023 Labelling with the subdepth... 
0024 
0025 * all *in* are at subdepth 1
0026 
0027 
0028 args: deep.py
0029 [2017-06-19 18:33:57,767] p82049 {/Users/blyth/opticks/analytic/csg.py:342} INFO - CSG.Serialize : writing 2 trees to directory /tmp/blyth/opticks/analytic/deep_py 
0030 analytic=1_csgpath=/tmp/blyth/opticks/analytic/deep_py_name=deep_py_mode=PyCsgInBox
0031                                                                                             un 7            
0032                                                                             un 6                     in 1    
0033                                                             un 5                     in 1         cy 0     !cy 0
0034                                             un 4                     in 1         cy 0     !cy 0                
0035                             un 3                     in 1         cy 0     !cy 0                                
0036             un 2                     in 1         cy 0     !cy 0                                                
0037     in 1             in 1         cy 0     !cy 0                                                                
0038 cy 0     !cy 0     cy 0     !cy 0                                                                                
0039 delta:analytic blyth$ 
0040 
0041 
0042 
0043 """
0044 
0045 import logging
0046 log = logging.getLogger(__name__)
0047 from opticks.ana.main import opticks_main
0048 from opticks.analytic.csg import CSG  
0049 args = opticks_main(csgpath="$TMP/analytic/deep_py" )
0050 
0051 CSG.boundary = args.testobject
0052 CSG.kwa = dict(verbosity="1")
0053 
0054 
0055 
0056 
0057 a = CSG("cylinder", param = [0.000,0.000,0.000,660.000],param1 = [-5.000,5.000,0.000,0.000])
0058 b = CSG("cylinder", param = [0.000,0.000,0.000,31.500],param1 = [-5.050,5.050,0.000,0.000],complement = True)
0059 ab = CSG("intersection", left=a, right=b)
0060 
0061 c = CSG("cylinder", param = [0.000,0.000,0.000,46.500],param1 = [-12.500,12.500,0.000,0.000])
0062 d = CSG("cylinder", param = [0.000,0.000,0.000,31.500],param1 = [-12.625,12.625,0.000,0.000],complement = True)
0063 cd = CSG("intersection", left=c, right=d)
0064 cd.transform = [[1.000,0.000,0.000,0.000],[0.000,1.000,0.000,0.000],[0.000,0.000,1.000,0.000],[0.000,0.000,-17.500,1.000]]
0065 
0066 abcd = CSG("union", left=ab, right=cd)
0067 
0068 e = CSG("cylinder", param = [0.000,0.000,0.000,660.000],param1 = [-67.500,67.500,0.000,0.000])
0069 f = CSG("cylinder", param = [0.000,0.000,0.000,650.000],param1 = [-68.175,68.175,0.000,0.000],complement = True)
0070 ef = CSG("intersection", left=e, right=f)
0071 ef.transform = [[1.000,0.000,0.000,0.000],[0.000,1.000,0.000,0.000],[0.000,0.000,1.000,0.000],[0.000,0.000,72.500,1.000]]
0072 
0073 abcdef = CSG("union", left=abcd, right=ef)
0074 
0075 g = CSG("cylinder", param = [0.000,0.000,0.000,660.000],param1 = [-5.000,5.000,0.000,0.000])
0076 h = CSG("cylinder", param = [0.000,0.000,0.000,122.000],param1 = [-5.050,5.050,0.000,0.000],complement = True)
0077 gh = CSG("intersection", left=g, right=h)
0078 gh.transform = [[1.000,0.000,0.000,0.000],[0.000,1.000,0.000,0.000],[0.000,0.000,1.000,0.000],[0.000,0.000,145.000,1.000]]
0079 
0080 abcdefgh = CSG("union", left=abcdef, right=gh)
0081 
0082 i = CSG("cylinder", param = [0.000,0.000,0.000,132.000],param1 = [-17.500,17.500,0.000,0.000])
0083 j = CSG("cylinder", param = [0.000,0.000,0.000,122.000],param1 = [-17.675,17.675,0.000,0.000],complement = True)
0084 ij = CSG("intersection", left=i, right=j)
0085 ij.transform = [[1.000,0.000,0.000,0.000],[0.000,1.000,0.000,0.000],[0.000,0.000,1.000,0.000],[0.000,0.000,167.500,1.000]]
0086 
0087 abcdefghij = CSG("union", left=abcdefgh, right=ij)
0088 
0089 k = CSG("cylinder", param = [0.000,0.000,0.000,167.000],param1 = [-10.000,10.000,0.000,0.000])
0090 l = CSG("cylinder", param = [0.000,0.000,0.000,122.000],param1 = [-10.100,10.100,0.000,0.000],complement = True)
0091 kl = CSG("intersection", left=k, right=l)
0092 kl.transform = [[1.000,0.000,0.000,0.000],[0.000,1.000,0.000,0.000],[0.000,0.000,1.000,0.000],[0.000,0.000,195.000,1.000]]
0093 
0094 abcdefghijkl = CSG("union", left=abcdefghij, right=kl)
0095 
0096 m = CSG("cylinder", param = [0.000,0.000,0.000,167.000],param1 = [-10.000,10.000,0.000,0.000])
0097 n = CSG("cylinder", param = [0.000,0.000,0.000,41.500],param1 = [-10.100,10.100,0.000,0.000],complement = True)
0098 mn = CSG("intersection", left=m, right=n)
0099 mn.transform = [[1.000,0.000,0.000,0.000],[0.000,1.000,0.000,0.000],[0.000,0.000,1.000,0.000],[0.000,0.000,215.000,1.000]]
0100 
0101 abcdefghijklmn = CSG("union", left=abcdefghijkl, right=mn)
0102 
0103 
0104 
0105 
0106 
0107 obj = abcdefghijklmn
0108 
0109 con = CSG("sphere",  param=[0,0,0,10], container="1", containerscale="2", boundary=args.container , poly="HY", level="5" )
0110 CSG.Serialize([con, obj], args.csgpath )
0111 
0112 
0113 print(obj.txt)
0114 
0115 
0116 subdepth = 1   # bileaf level, one step up from the primitives
0117 subtrees = obj.subtrees_(subdepth=subdepth)   # collect the bileafs
0118 ops = obj.operators_(minsubdepth=subdepth+1)  # look at operators above the bileafs 
0119 
0120 print("ops:",list(map(CSG.desc, ops)))
0121 
0122 for i,sub in enumerate(subtrees):
0123     print("\n\nsub %s " % i)
0124     sub.analyse()
0125     sub.dump(detailed=True)
0126 
0127 
0128 
0129 
0130