File indexing completed on 2026-04-09 07:49:18
0001
0002
0003 #include "ssys.h"
0004 #include "sn.h"
0005 #include "s_csg.h"
0006
0007
0008 void test_GetLVNodes()
0009 {
0010 int lvid = ssys::getenvint("LVID", 108) ;
0011
0012 std::vector<sn*> nds ;
0013 sn::GetLVNodes(nds, lvid) ;
0014
0015 std::cerr
0016 << "test_GetLVNodes"
0017 << " lvid " << lvid
0018 << std::endl
0019 << sn::Desc(nds)
0020 << std::endl
0021 ;
0022 }
0023
0024 void test_getLVNodes()
0025 {
0026 int lvid = ssys::getenvint("LVID", 108) ;
0027 sn* root = sn::GetLVRoot(lvid) ;
0028 if(!root) return ;
0029
0030 std::vector<sn*> nds ;
0031 root->getLVNodes(nds) ;
0032
0033 std::cerr
0034 << "test_getLVNodes"
0035 << " lvid " << lvid
0036 << std::endl
0037 << sn::Desc(nds)
0038 << std::endl
0039 ;
0040 }
0041
0042 void test_GetLVRoot()
0043 {
0044 int lvid = ssys::getenvint("LVID", 108) ;
0045 sn* root = sn::GetLVRoot(lvid) ;
0046
0047 std::cerr
0048 << "test_GetLVRoot"
0049 << " lvid " << lvid
0050 << std::endl
0051 << ( root ? root->desc() : "-" )
0052 << std::endl
0053 << ( root ? root->render(sn::TYPETAG) : "-" )
0054 << std::endl
0055 << ( root ? root->rbrief() : "-" )
0056 << std::endl
0057 ;
0058 }
0059
0060 void test_max_binary_depth()
0061 {
0062 int lvid = ssys::getenvint("LVID", 108) ;
0063 sn* root = sn::GetLVRoot(lvid) ;
0064
0065 std::cerr
0066 << "test_max_binary_depth"
0067 << " lvid " << lvid
0068 << std::endl
0069 << ( root ? root->desc() : "-" )
0070 << std::endl
0071 << ( root ? root->render(sn::TYPETAG) : "-" )
0072 << std::endl
0073 << ( root ? root->rbrief() : "-" )
0074 << std::endl
0075 << " max_binary_depth " << ( root ? root->max_binary_depth() : -1 )
0076 << std::endl
0077 ;
0078 }
0079
0080 void test_typenodes_()
0081 {
0082 int lvid = ssys::getenvint("LVID", 108) ;
0083 sn* root = sn::GetLVRoot(lvid) ;
0084
0085 std::vector<const sn*> nds0 ;
0086 root->typenodes_(nds0, CSG_UNION );
0087
0088 std::vector<const sn*> nds1 ;
0089 root->typenodes_(nds1, CSG_CYLINDER, CSG_CONE );
0090
0091
0092 std::cerr
0093 << "test_typenodes_"
0094 << " lvid " << lvid
0095 << std::endl
0096 << ( root ? root->desc() : "-" )
0097 << std::endl
0098 << ( root ? root->render(sn::TYPETAG) : "-" )
0099 << std::endl
0100 << ( root ? root->rbrief() : "-" )
0101 << std::endl
0102 << " root->typenodes_(nds0, CSG_UNION) "
0103 << std::endl
0104 << sn::Desc(nds0)
0105 << std::endl
0106 << " root->typenodes_(nds1, CSG_CYLINDER, CSG_CONE ) "
0107 << std::endl
0108 << sn::Desc(nds1)
0109 << std::endl
0110 ;
0111 }
0112
0113 void test_getLVNumNode()
0114 {
0115 sn* root = sn::GetLVRoot(ssys::getenvint("LVID", 108)) ;
0116 if(!root) return ;
0117
0118 std::cerr
0119 << "test_getLVNumNode"
0120 << std::endl
0121 << root->desc()
0122 << std::endl
0123 << " root->getLVNumNode() "
0124 << root->getLVNumNode()
0125 << std::endl
0126 << " root->getLVBinNode() "
0127 << root->getLVBinNode()
0128 << std::endl
0129 << " root->getLVSubNode() "
0130 << root->getLVSubNode()
0131 << std::endl
0132 ;
0133 }
0134
0135
0136 void test_GetLVNodesComplete()
0137 {
0138 int lvid = ssys::getenvint("LVID", 108);
0139
0140 std::vector<const sn*> nds ;
0141 sn::GetLVNodesComplete(nds, lvid ) ;
0142
0143 std::cerr
0144 << "test_GetLVNodesComplete"
0145 << std::endl
0146 << sn::Desc(nds)
0147 << std::endl
0148 ;
0149 }
0150 void test_getLVNodesComplete()
0151 {
0152 sn* root = sn::GetLVRoot(ssys::getenvint("LVID", 108)) ;
0153 if(!root) return ;
0154
0155 std::vector<const sn*> nds ;
0156 root->getLVNodesComplete(nds);
0157
0158 std::cerr
0159 << "test_getLVNodesComplete"
0160 << std::endl
0161 << sn::Desc(nds)
0162 << std::endl
0163 << ( root ? root->render(sn::TYPETAG) : "-" )
0164 << std::endl
0165 ;
0166 }
0167
0168 void test_ancestors()
0169 {
0170 sn* root = sn::GetLVRoot(ssys::getenvint("LVID", 108)) ;
0171 if(!root) return ;
0172
0173 std::vector<const sn*> nds0 ;
0174 root->ancestors(nds0);
0175 assert( nds0.size() == 0 && "root nodes should not have ancestors" );
0176
0177 std::cerr
0178 << "test_ancestors"
0179 << std::endl
0180 << sn::Desc(nds0)
0181 << std::endl
0182 << ( root ? root->render(sn::TYPETAG) : "-" )
0183 << std::endl
0184 ;
0185
0186
0187 std::vector<sn*> nds1 ;
0188 root->getLVNodes(nds1);
0189
0190 std::cerr
0191 << "test_ancestors"
0192 << std::endl
0193 << " root->getLVNodes(nds1) "
0194 << std::endl
0195 << sn::Desc(nds1)
0196 << std::endl
0197 ;
0198
0199 for(int i=0 ; i < int(nds1.size()) ; i++)
0200 {
0201 sn* nd = nds1[i] ;
0202 std::vector<const sn*> anc ;
0203 nd->ancestors(anc);
0204 std::cerr
0205 << std::setw(3) << i << " : "
0206 << " anc.size " << anc.size()
0207 << std::endl
0208 ;
0209 }
0210 }
0211
0212 void test_getNodeTransformProduct()
0213 {
0214 sn* root = sn::GetLVRoot(ssys::getenvint("LVID", 108)) ;
0215 if(!root) return ;
0216
0217 std::vector<sn*> nds ;
0218 root->getLVNodes(nds);
0219
0220 std::cerr
0221 << "test_getNodeTransformProduct"
0222 << std::endl
0223 << sn::Desc(nds)
0224 << std::endl
0225 ;
0226
0227 for(int i=0 ; i < int(nds.size()) ; i++)
0228 {
0229 sn* nd = nds[i] ;
0230
0231 glm::tmat4x4<double> t(1.);
0232 glm::tmat4x4<double> v(1.);
0233 bool reverse = false ;
0234
0235 std::cerr
0236 << "test_getNodeTransformProduct"
0237 << std::endl
0238 << nd->desc_getNodeTransformProduct(t,v,reverse)
0239 << std::endl
0240 ;
0241 }
0242 }
0243
0244 int main()
0245 {
0246 s_csg::Load("$BASE");
0247
0248
0249
0250
0251
0252
0253
0254
0255
0256
0257
0258
0259
0260 test_getNodeTransformProduct();
0261
0262 return 0 ;
0263 }