Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-09 07:49:31

0001 #pragma once
0002 /**
0003 scsg.hh : Manages pools of CSG nodes, param, bounding box and transforms
0004 ============================================================================
0005 
0006 Canonical *csg* instance is instanciated by stree::stree and "snd::SetPOOL(csg)"
0007 is called from stree::init. 
0008 
0009 Note that the *idx* "integer pointer" used in the API corresponds to the 
0010 relevant species node/param/aabb/xform for each method. 
0011 
0012 CAUTION: DO NOT RETAIN POINTERS/REFS WHILST ADDING NODES 
0013 AS REALLOC WILL SOMETIMES INVALIDATE THEM
0014 
0015 Users of scsg.hh
0016 -----------------
0017 
0018 ::
0019 
0020     epsilon:sysrap blyth$ opticks-f scsg.hh 
0021     ./sysrap/CMakeLists.txt:    scsg.hh
0022     ./sysrap/snd.hh:Usage requires the scsg.hh POOL. That is now done at stree instanciation::
0023     ./sysrap/stree.h:#include "scsg.hh"
0024     ./sysrap/snd.cc:#include "scsg.hh"
0025     ./sysrap/tests/snd_test.cc:#include "scsg.hh"
0026     ./sysrap/scsg.hh:scsg.hh : pools of CSG nodes, param, bounding box and transforms
0027     ./sysrap/scsg.cc:#include "scsg.hh"
0028     ./u4/tests/U4SolidTest.cc:#include "scsg.hh"
0029     epsilon:opticks blyth$ 
0030 
0031 
0032 Q: CAN THIS GO HEADER-ONLY .h ?
0033 A1: snd.hh static pools are problematic header only, so NO currently
0034 A2: After upgrade beyond C++11 can reconsider.     
0035 
0036 **/
0037 
0038 #include <vector>
0039 #include "SYSRAP_API_EXPORT.hh"
0040 
0041 #include "snd.hh"
0042 #include "spa.h"
0043 #include "sbb.h"
0044 #include "sxf.h"
0045 
0046 struct NPFold ; 
0047 
0048 struct SYSRAP_API scsg
0049 {
0050     int level ; 
0051 
0052     std::vector<snd> node ; 
0053     std::vector<spa> param ; 
0054     std::vector<sbb> aabb ; 
0055     std::vector<sxf> xform ; 
0056 
0057     static constexpr const unsigned IMAX = 1000 ;
0058 
0059     scsg(); 
0060     void init(); 
0061 
0062     template<typename T>
0063     int add_(const T& obj, std::vector<T>& vec); 
0064 
0065     int addND(const snd& nd );
0066     int addPA(const spa& pa );
0067     int addBB(const sbb& bb );
0068     int addXF(const sxf& xf );
0069 
0070     template<typename T>
0071     const T* get(int idx, const std::vector<T>& vec) const ; 
0072 
0073     const snd* getND(int idx) const ; 
0074     const spa* getPA(int idx) const ;  
0075     const sbb* getBB(int idx) const ;
0076     const sxf* getXF(int idx) const ; 
0077 
0078     template<typename T>
0079     T* get_(int idx, std::vector<T>& vec) ; 
0080 
0081     snd* getND_(int idx); 
0082     spa* getPA_(int idx);  
0083     sbb* getBB_(int idx);
0084     sxf* getXF_(int idx); 
0085 
0086     template<typename T>
0087     std::string desc_(int idx, const std::vector<T>& vec) const ; 
0088 
0089     std::string descND(int idx) const ; 
0090     std::string descPA(int idx) const ; 
0091     std::string descBB(int idx) const ;  
0092     std::string descXF(int idx) const ; 
0093 
0094     std::string brief() const ; 
0095     std::string desc() const ; 
0096 
0097     NPFold* serialize() const ; 
0098     void    import(const NPFold* fold); 
0099 
0100 
0101     // slightly less "mechanical" methods than the above 
0102     void getLVID( std::vector<snd>& nds, int lvid ) const ; 
0103     const snd* getLVRoot(int lvid ) const ; 
0104 
0105 };
0106