File indexing completed on 2026-04-09 07:49:29
0001 #pragma once
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 #include <cassert>
0022 #include <string>
0023 #include <sstream>
0024 #include <iomanip>
0025
0026 #include "s_pool.h"
0027
0028 struct _s_pa
0029 {
0030 static constexpr const char* ITEM = "6" ;
0031
0032 double x0, y0, z0, w0, x1, y1 ;
0033 };
0034
0035 #include "SYSRAP_API_EXPORT.hh"
0036
0037 struct SYSRAP_API s_pa
0038 {
0039 static constexpr const char* NAME = "s_pa.npy" ;
0040 static constexpr const bool LEAK = false ;
0041
0042 typedef s_pool<s_pa,_s_pa> POOL ;
0043 static POOL* pool ;
0044 static void SetPOOL( POOL* pool_ );
0045 static int level() ;
0046 static void Serialize( _s_pa& p, const s_pa* o );
0047 static s_pa* Import( const _s_pa* p, const std::vector<_s_pa>& buf );
0048
0049 s_pa();
0050 ~s_pa();
0051 s_pa* copy() const ;
0052
0053 int pid ;
0054
0055 double x0, y0, z0, w0, x1, y1 ;
0056
0057 const double* data() const { return &x0 ; }
0058 double* data_() { return &x0 ; }
0059 bool is_root() const { return true ; }
0060
0061 double value(int i) const { assert( i >=0 && i < 6 ) ; return *(data() + i) ; }
0062 void set_value(int i, double v ) { assert( i >=0 && i < 6 ) ; *(data_()+i) = v ; }
0063
0064
0065 std::string desc() const ;
0066 };
0067
0068 inline void s_pa::SetPOOL( POOL* pool_ ){ pool = pool_ ; }
0069 inline int s_pa::level() { return pool ? pool->level : ssys::getenvint("sn__level",-1) ; }
0070
0071 inline void s_pa::Serialize( _s_pa& p, const s_pa* o )
0072 {
0073 p.x0 = o->x0 ;
0074 p.y0 = o->y0 ;
0075 p.z0 = o->z0 ;
0076 p.w0 = o->w0 ;
0077 p.x1 = o->x1 ;
0078 p.y1 = o->y1 ;
0079 }
0080 inline s_pa* s_pa::Import( const _s_pa* p, const std::vector<_s_pa>& )
0081 {
0082 s_pa* o = new s_pa ;
0083 o->x0 = p->x0 ;
0084 o->y0 = p->y0 ;
0085 o->z0 = p->z0 ;
0086 o->w0 = p->w0 ;
0087 o->x1 = p->x1 ;
0088 o->y1 = p->y1 ;
0089 return o ;
0090 }
0091
0092
0093 inline s_pa::s_pa()
0094 :
0095 pid(pool ? pool->add(this) : -1),
0096 x0(0.),
0097 y0(0.),
0098 z0(0.),
0099 w0(0.),
0100 x1(0.),
0101 y1(0.)
0102 {
0103 if(level() > 1) std::cerr << "s_pa::s_pa pid " << pid << std::endl ;
0104 }
0105 inline s_pa::~s_pa()
0106 {
0107 if(level() > 1) std::cerr << "s_pa::~s_pa pid " << pid << std::endl ;
0108 if(pool) pool->remove(this);
0109 }
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121 inline s_pa* s_pa::copy() const
0122 {
0123 s_pa* n = new s_pa ;
0124 n->x0 = x0 ;
0125 n->y0 = y0 ;
0126 n->z0 = z0 ;
0127 n->w0 = w0 ;
0128 n->x1 = x1 ;
0129 n->y1 = y1 ;
0130 return n ;
0131 }
0132
0133
0134
0135
0136
0137 inline std::string s_pa::desc() const
0138 {
0139 std::stringstream ss ;
0140 ss
0141 << " x0 " << std::setw(10) << std::fixed << std::setprecision(3) << x0
0142 << " y0 " << std::setw(10) << std::fixed << std::setprecision(3) << y0
0143 << " z0 " << std::setw(10) << std::fixed << std::setprecision(3) << z0
0144 << " w0 " << std::setw(10) << std::fixed << std::setprecision(3) << w0
0145 << " x1 " << std::setw(10) << std::fixed << std::setprecision(3) << x1
0146 << " y1 " << std::setw(10) << std::fixed << std::setprecision(3) << y1
0147 ;
0148
0149 std::string str = ss.str();
0150 return str ;
0151 }
0152
0153