File indexing completed on 2026-04-09 07:48:52
0001
0002 """
0003 csg_intersect_prim_test.py
0004 ===========================
0005
0006 [:,0,3] > 0
0007
0008
0009
0010
0011
0012 """
0013
0014 import os, logging, numpy as np
0015 from opticks.ana.fold import Fold, IsRemoteSession
0016 from opticks.ana.pvplt import pvplt_show
0017 MODE = int(os.environ.get("MODE","3"))
0018
0019 log = logging.getLogger(__name__)
0020
0021
0022 if IsRemoteSession():
0023 MODE = 0
0024 print("detect fold.IsRemoteSession forcing MODE:%d" % MODE)
0025 elif MODE in [2,3]:
0026 from opticks.ana.pvplt import *
0027 pass
0028
0029
0030 if __name__ == '__main__':
0031 logging.basicConfig(level=logging.INFO)
0032 f = Fold.Load("$FOLD/$TEST", symbol="f")
0033 print(repr(f))
0034 xy = f.xy
0035
0036 H,V = 0,1
0037 sc = 10
0038
0039 for e in [xy]:
0040
0041 nrm = e[:,0,:3]
0042 r_nrm = np.sqrt(np.sum( nrm*nrm, axis=1 ))
0043 print(r_nrm)
0044
0045
0046 label = "CSG/tests/csg_intersect_prim_test.sh "
0047
0048 if MODE in [0,1]:
0049 print("not plotting as MODE %d in environ" % MODE )
0050 elif MODE == 2:
0051 pl = mpplt_plotter(label=label)
0052 fig, axs = pl
0053 assert len(axs) == 1
0054 ax = axs[0]
0055 ax.set_xlim(-120,120)
0056
0057 elif MODE == 3:
0058 pl = pvplt_plotter(label)
0059 pvplt_viewpoint(pl)
0060
0061
0062 pass
0063
0064
0065 spos = e[:,1,:3]
0066 snrm = e[:,0,:3]
0067
0068
0069 if MODE == 2:
0070 ax.scatter( spos[:,H], spos[:,V], s=0.1 )
0071
0072 for i in range(len(spos)):
0073 p = spos[i]
0074 n = snrm[i]
0075 ax.arrow( p[H], p[V], sc*n[H], sc*n[V] )
0076 pass
0077
0078 elif MODE == 3:
0079 pl.add_points(spos[:,:3])
0080 else:
0081 pass
0082 pass
0083
0084 if MODE == 2:
0085 fig.show()
0086 elif MODE == 3:
0087 pvplt_show(pl)
0088 pass
0089 pass
0090 pass