Changeset 508 for trunk/VUT/GtpVisibilityPreprocessor/src
- Timestamp:
- 01/08/06 05:56:40 (19 years ago)
- Location:
- trunk/VUT/GtpVisibilityPreprocessor/src
- Files:
-
- 3 added
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/Environment.cpp
r503 r508 1140 1140 "0.1"); 1141 1141 1142 RegisterOption("Sampling .totalSamples",1142 RegisterOption("SamplingPreprocessor.totalSamples", 1143 1143 optInt, 1144 1144 "total_samples=", 1145 1145 "1000000"); 1146 1146 1147 RegisterOption("Sampling .samplesPerPass",1147 RegisterOption("SamplingPreprocessor.samplesPerPass", 1148 1148 optInt, 1149 1149 "samples_per_pass=", … … 1191 1191 optBool, 1192 1192 "-vss_use_viewspace_box=", 1193 " true");1193 "false"); 1194 1194 1195 1195 … … 1199 1199 1200 1200 1201 RegisterOption("ViewCells.type", 1202 optString, 1203 "view_cells_type", 1204 "bspTree"); 1205 1206 RegisterOption("ViewCells.PostProcess.samples", 1207 optInt, 1208 "view_cells_postprocess_samples=", 1209 "200000"); 1210 1211 RegisterOption("ViewCells.Visualization.samples", 1212 optInt, 1213 "view_cells_visualization_samples=", 1214 "20000"); 1215 1216 RegisterOption("ViewCells.loadFromFile", 1217 optBool, 1218 "view_cells_load_from_file", 1219 "false"); 1220 1221 RegisterOption("ViewCells.maxViewCells", 1222 optInt, 1223 "view_cells_max_view_cells=", 1224 "0"); 1225 1226 1227 RegisterOption("ViewCells.maxPvs", 1228 optInt, 1229 "view_cells_max_pvs=", 1230 "300"); 1231 1232 RegisterOption("ViewCells.filename", 1233 optString, 1234 "view_cells_filename=", 1235 "atlanta_viewcells_large.x3d"); 1236 1237 RegisterOption("ViewCells.height", 1238 optFloat, 1239 "view_cells_height=", 1240 "5.0"); 1241 1242 RegisterOption("ViewCells.Visualization.colorCode", 1201 RegisterOption("ViewCells.type", 1202 optString, 1203 "view_cells_type", 1204 "bspTree"); 1205 1206 RegisterOption("ViewCells.PostProcess.samples", 1207 optInt, 1208 "view_cells_postprocess_samples=", 1209 "200000"); 1210 1211 RegisterOption("ViewCells.Visualization.samples", 1212 optInt, 1213 "view_cells_visualization_samples=", 1214 "20000"); 1215 1216 RegisterOption("ViewCells.loadFromFile", 1217 optBool, 1218 "view_cells_load_from_file", 1219 "false"); 1220 1221 RegisterOption("ViewCells.exportToFile", 1222 optBool, 1223 "view_cells_export_to_file", 1224 "false"); 1225 1226 RegisterOption("ViewCells.maxViewCells", 1227 optInt, 1228 "view_cells_max_view_cells=", 1229 "0"); 1230 1231 RegisterOption("ViewCells.maxPvs", 1232 optInt, 1233 "view_cells_max_pvs=", 1234 "300"); 1235 1236 RegisterOption("ViewCells.filename", 1237 optString, 1238 "view_cells_filename=", 1239 "atlanta_viewcells_large.x3d"); 1240 1241 RegisterOption("ViewCells.height", 1242 optFloat, 1243 "view_cells_height=", 1244 "5.0"); 1245 1246 RegisterOption("ViewCells.Visualization.colorCode", 1243 1247 optString, 1244 1248 "-view_cells_visualization.color_code", 1245 1249 "PVS"); 1246 1250 1247 RegisterOption("ViewCells.Visualization.exportRays", 1248 optBool, 1249 "-bsp_visualization.export_rays", 1250 "false"); 1251 1252 RegisterOption("ViewCells.Visualization.exportGeometry", 1253 optBool, 1254 "-bsp_visualization.export_geometry", 1255 "false"); 1256 1257 /************************************************************************************/ 1258 /* Render simulation related options */ 1259 /************************************************************************************/ 1260 1261 1262 RegisterOption("Simulation.objRenderCost", 1263 optFloat, 1264 "simulation_obj_render_cost", 1265 "1.0"); 1266 1267 RegisterOption("Simulation.vcOverhead", 1268 optFloat, 1269 "simulation_vc_overhead", 1270 "0.05"); 1271 1272 RegisterOption("Simulation.moveSpeed", 1273 optFloat, 1274 "simulation_moveSpeed", 1275 "1.0"); 1276 1277 1278 1279 1280 /************************************************************************************/ 1281 /* Bsp tree related options */ 1282 /************************************************************************************/ 1283 1284 1285 RegisterOption("BspTree.Construction.input", 1286 optString, 1287 "bsp_construction_input=", 1288 "fromViewCells"); 1289 1290 RegisterOption("BspTree.Construction.samples", 1291 optInt, 1292 "bsp_construction_samples=", 1293 "100000"); 1294 1295 RegisterOption("BspTree.Construction.epsilon", 1296 optFloat, 1297 "bsp_construction_side_tolerance=", 1298 "0.002"); 1299 1300 RegisterOption("BspTree.Termination.minPolygons", 1301 optInt, 1302 "bsp_term_min_polygons=", 1303 "5"); 1304 1305 RegisterOption("BspTree.Termination.minPvs", 1306 optInt, 1307 "bsp_term_min_pvs=", 1308 "20"); 1309 1310 RegisterOption("BspTree.Termination.minArea", 1311 optFloat, 1312 "bsp_term_min_area=", 1313 "0.001"); 1314 1315 RegisterOption("BspTree.Termination.maxRayContribution", 1316 optFloat, 1317 "bsp_term_ray_contribution=", 1318 "0.005"); 1319 1320 RegisterOption("BspTree.Termination.minAccRayLenght", 1321 optFloat, 1322 "bsp_term_min_acc_ray_length=", 1323 "50"); 1324 1325 RegisterOption("BspTree.Termination.minRays", 1326 optInt, 1327 "bsp_term_min_rays=", 1328 "-1"); 1329 1330 RegisterOption("BspTree.Termination.ct_div_ci", 1331 optFloat, 1332 "bsp_term_ct_div_ci=", 1333 "0.0"); 1334 1335 RegisterOption("BspTree.Termination.maxDepth", 1336 optInt, 1337 "bsp_term_max_depth=", 1338 "100"); 1339 1340 RegisterOption("BspTree.Termination.maxCostRatio", 1341 optFloat, 1342 "bsp_term_axis_aligned_max_cost_ratio=", 1343 "1.5"); 1344 1345 RegisterOption("BspTree.Termination.AxisAligned.ct_div_ci", 1346 optFloat, 1347 "bsp_term_axis_aligned_ct_div_ci=", 1348 "0.5"); 1349 1350 RegisterOption("BspTree.AxisAligned.splitBorder", 1351 optFloat, 1352 "bsp__axis_aligned_split_border=", 1353 "0.1"); 1354 1355 RegisterOption("BspTree.Termination.AxisAligned.minPolys", 1356 optInt, 1357 "bsp_term_axis_aligned_max_polygons=", 1358 "50"); 1359 1360 RegisterOption("BspTree.Termination.AxisAligned.minObjects", 1361 optInt, 1362 "bsp_term_min_objects=", 1363 "3"); 1364 1365 RegisterOption("BspTree.Termination.AxisAligned.minRays", 1366 optInt, 1367 "bsp_term_axis_aligned_min_rays=", 1368 "-1"); 1369 1370 RegisterOption("BspTree.splitPlaneStrategy", 1371 optString, 1372 "bsp_split_method=", 1373 "leastSplits"); 1374 1375 RegisterOption("BspTree.maxPolyCandidates", 1376 optInt, 1377 "bsp_max_poly_candidates=", 1378 "20"); 1379 1380 RegisterOption("BspTree.maxRayCandidates", 1381 optInt, 1382 "bsp_max_plane_candidates=", 1383 "20"); 1384 1385 RegisterOption("BspTree.maxTests", 1386 optInt, 1387 "bsp_max_tests=", 1388 "5000"); 1389 1390 RegisterOption("BspTree.Visualization.exportSplits", 1391 optBool, 1392 "bsp_visualization.export_splits", 1393 "false"); 1394 1395 RegisterOption("BspTree.Factor.verticalSplits", optFloat, "bsp_factor_vertical=", "1.0"); 1396 RegisterOption("BspTree.Factor.largestPolyArea", optFloat, "bsp_factor_largest_poly=", "1.0"); 1397 RegisterOption("BspTree.Factor.blockedRays", optFloat, "bsp_factor_blocked=", "1.0"); 1398 RegisterOption("BspTree.Factor.leastSplits", optFloat, "bsp_factor_least_splits=", "1.0"); 1399 RegisterOption("BspTree.Factor.balancedPolys", optFloat, "bsp_factor_balanced_polys=", "1.0"); 1400 RegisterOption("BspTree.Factor.balancedViewCells", optFloat, "bsp_factor_balanced_view_cells=", "1.0"); 1401 RegisterOption("BspTree.Factor.leastRaySplits", optFloat, "bsp_factor_least_ray_splits=", "1.0"); 1402 RegisterOption("BspTree.Factor.balancedRays", optFloat, "bsp_factor_balanced_rays=", "1.0"); 1403 RegisterOption("BspTree.Factor.pvs", optFloat, "bsp_factor_pvs=", "1.0"); 1404 1405 /************************************************************************************/ 1406 /* Preprocessor related options */ 1407 /************************************************************************************/ 1408 1409 RegisterOption("Preprocessor.type", 1410 optString, 1411 "preprocessor=", 1412 "sampling"); 1413 1414 RegisterOption("Preprocessor.samplesFilename", 1415 optString, 1416 "-preprocessor_samples_filename=", 1417 "rays.out"); 1418 1419 RegisterOption("Preprocessor.useGlRenderer", 1420 optBool, 1421 "useGlRenderer", 1422 "false"); 1423 1424 /**************************************************************************************/ 1425 /* View space partition KD tree related options */ 1426 /**************************************************************************************/ 1427 1428 RegisterOption("VspKdTree.Construction.samples", 1429 optInt, 1430 "vsp_kd_construction_samples=", 1431 "100000"); 1432 1433 RegisterOption("VspKdTree.Termination.maxDepth", 1434 optInt, 1435 "vsp_term_maxdepth=", "30"); 1436 1437 RegisterOption("VspKdTree.Termination.minPvs", 1438 optInt, 1439 "vsp_minpvs=", 1440 "1"); 1441 1442 RegisterOption("VspKdTree.Termination.minRays", 1443 optInt, 1444 "vsp_term_minrays=", 1445 "10"); 1446 1447 RegisterOption("VspKdTree.Termination.minSize", 1448 optFloat, 1449 "vsp_term_minsize=", 1450 "0.001"); 1451 1452 RegisterOption("VspKdTree.Termination.maxCostRatio", 1453 optFloat, 1454 "vsp_term_maxcost=", 1455 "0.95"); 1456 1457 RegisterOption("VspKdTree.Termination.maxRayContribution", 1458 optFloat, 1459 "vsp_term_max_ray_contrib=", 1460 "0.5"); 1461 1462 RegisterOption("VspKdTree.epsilon", 1463 optFloat, 1464 "kd_eps=", 1465 "1e-6"); 1466 1467 RegisterOption("VspKdTree.ct_div_ci", 1468 optFloat, 1469 "vsp_ctdivci=", "1.0"); 1470 1471 RegisterOption("VspKdTree.splitType", 1472 optString, 1473 "split=", 1474 "queries"); 1475 1476 RegisterOption("VspKdTree.splitAxis", 1477 optString, 1478 "split=", 1479 "drivingAxis"); 1480 1481 RegisterOption("VspKdTree.splitUseOnlyDrivingAxis", 1482 optBool, 1483 "vsp_kd_splitdriving=", 1484 "false"); 1251 RegisterOption("ViewCells.Visualization.exportRays", 1252 optBool, 1253 "-bsp_visualization.export_rays", 1254 "false"); 1255 1256 RegisterOption("ViewCells.Visualization.exportGeometry", 1257 optBool, 1258 "-bsp_visualization.export_geometry", 1259 "false"); 1260 1261 1262 /************************************************************************************/ 1263 /* Render simulation related options */ 1264 /************************************************************************************/ 1265 1266 1267 RegisterOption("Simulation.objRenderCost", 1268 optFloat, 1269 "simulation_obj_render_cost", 1270 "1.0"); 1271 1272 RegisterOption("Simulation.vcOverhead", 1273 optFloat, 1274 "simulation_vc_overhead", 1275 "0.05"); 1276 1277 RegisterOption("Simulation.moveSpeed", 1278 optFloat, 1279 "simulation_moveSpeed", 1280 "1.0"); 1281 1282 1283 1284 1285 /************************************************************************************/ 1286 /* Bsp tree related options */ 1287 /************************************************************************************/ 1288 1289 1290 RegisterOption("BspTree.Construction.input", 1291 optString, 1292 "bsp_construction_input=", 1293 "fromViewCells"); 1294 1295 RegisterOption("BspTree.Construction.samples", 1296 optInt, 1297 "bsp_construction_samples=", 1298 "100000"); 1299 1300 RegisterOption("BspTree.Construction.epsilon", 1301 optFloat, 1302 "bsp_construction_side_tolerance=", 1303 "0.002"); 1304 1305 RegisterOption("BspTree.Termination.minPolygons", 1306 optInt, 1307 "bsp_term_min_polygons=", 1308 "5"); 1309 1310 RegisterOption("BspTree.Termination.minPvs", 1311 optInt, 1312 "bsp_term_min_pvs=", 1313 "20"); 1314 1315 RegisterOption("BspTree.Termination.minArea", 1316 optFloat, 1317 "bsp_term_min_area=", 1318 "0.001"); 1319 1320 RegisterOption("BspTree.Termination.maxRayContribution", 1321 optFloat, 1322 "bsp_term_ray_contribution=", 1323 "0.005"); 1324 1325 RegisterOption("BspTree.Termination.minAccRayLenght", 1326 optFloat, 1327 "bsp_term_min_acc_ray_length=", 1328 "50"); 1329 1330 RegisterOption("BspTree.Termination.minRays", 1331 optInt, 1332 "bsp_term_min_rays=", 1333 "-1"); 1334 1335 RegisterOption("BspTree.Termination.ct_div_ci", 1336 optFloat, 1337 "bsp_term_ct_div_ci=", 1338 "0.0"); 1339 1340 RegisterOption("BspTree.Termination.maxDepth", 1341 optInt, 1342 "bsp_term_max_depth=", 1343 "100"); 1344 1345 RegisterOption("BspTree.Termination.maxCostRatio", 1346 optFloat, 1347 "bsp_term_axis_aligned_max_cost_ratio=", 1348 "1.5"); 1349 1350 RegisterOption("BspTree.Termination.AxisAligned.ct_div_ci", 1351 optFloat, 1352 "bsp_term_axis_aligned_ct_div_ci=", 1353 "0.5"); 1354 1355 RegisterOption("BspTree.AxisAligned.splitBorder", 1356 optFloat, 1357 "bsp__axis_aligned_split_border=", 1358 "0.1"); 1359 1360 RegisterOption("BspTree.Termination.AxisAligned.minPolys", 1361 optInt, 1362 "bsp_term_axis_aligned_max_polygons=", 1363 "50"); 1364 1365 RegisterOption("BspTree.Termination.AxisAligned.minObjects", 1366 optInt, 1367 "bsp_term_min_objects=", 1368 "3"); 1369 1370 RegisterOption("BspTree.Termination.AxisAligned.minRays", 1371 optInt, 1372 "bsp_term_axis_aligned_min_rays=", 1373 "-1"); 1374 1375 RegisterOption("BspTree.splitPlaneStrategy", 1376 optString, 1377 "bsp_split_method=", 1378 "leastSplits"); 1379 1380 RegisterOption("BspTree.maxPolyCandidates", 1381 optInt, 1382 "bsp_max_poly_candidates=", 1383 "20"); 1384 1385 RegisterOption("BspTree.maxRayCandidates", 1386 optInt, 1387 "bsp_max_plane_candidates=", 1388 "20"); 1389 1390 RegisterOption("BspTree.maxTests", 1391 optInt, 1392 "bsp_max_tests=", 1393 "5000"); 1394 1395 RegisterOption("BspTree.Visualization.exportSplits", 1396 optBool, 1397 "bsp_visualization.export_splits", 1398 "false"); 1399 1400 RegisterOption("BspTree.Factor.verticalSplits", optFloat, "bsp_factor_vertical=", "1.0"); 1401 RegisterOption("BspTree.Factor.largestPolyArea", optFloat, "bsp_factor_largest_poly=", "1.0"); 1402 RegisterOption("BspTree.Factor.blockedRays", optFloat, "bsp_factor_blocked=", "1.0"); 1403 RegisterOption("BspTree.Factor.leastSplits", optFloat, "bsp_factor_least_splits=", "1.0"); 1404 RegisterOption("BspTree.Factor.balancedPolys", optFloat, "bsp_factor_balanced_polys=", "1.0"); 1405 RegisterOption("BspTree.Factor.balancedViewCells", optFloat, "bsp_factor_balanced_view_cells=", "1.0"); 1406 RegisterOption("BspTree.Factor.leastRaySplits", optFloat, "bsp_factor_least_ray_splits=", "1.0"); 1407 RegisterOption("BspTree.Factor.balancedRays", optFloat, "bsp_factor_balanced_rays=", "1.0"); 1408 RegisterOption("BspTree.Factor.pvs", optFloat, "bsp_factor_pvs=", "1.0"); 1409 1410 /************************************************************************************/ 1411 /* Preprocessor related options */ 1412 /************************************************************************************/ 1413 1414 RegisterOption("Preprocessor.type", 1415 optString, 1416 "preprocessor=", 1417 "sampling"); 1418 1419 RegisterOption("Preprocessor.samplesFilename", 1420 optString, 1421 "-preprocessor_samples_filename=", 1422 "rays.out"); 1423 1424 RegisterOption("Preprocessor.useGlRenderer", 1425 optBool, 1426 "useGlRenderer", 1427 "false"); 1428 1429 /**************************************************************************************/ 1430 /* View space partition KD tree related options */ 1431 /**************************************************************************************/ 1432 1433 RegisterOption("VspKdTree.Construction.samples", 1434 optInt, 1435 "vsp_kd_construction_samples=", 1436 "100000"); 1437 1438 RegisterOption("VspKdTree.Termination.maxDepth", 1439 optInt, 1440 "vsp_term_maxdepth=", "30"); 1441 1442 RegisterOption("VspKdTree.Termination.minPvs", 1443 optInt, 1444 "vsp_minpvs=", 1445 "1"); 1446 1447 RegisterOption("VspKdTree.Termination.minRays", 1448 optInt, 1449 "vsp_term_minrays=", 1450 "10"); 1451 1452 RegisterOption("VspKdTree.Termination.minSize", 1453 optFloat, 1454 "vsp_term_minsize=", 1455 "0.001"); 1456 1457 RegisterOption("VspKdTree.Termination.maxCostRatio", 1458 optFloat, 1459 "vsp_term_maxcost=", 1460 "0.95"); 1461 1462 RegisterOption("VspKdTree.Termination.maxRayContribution", 1463 optFloat, 1464 "vsp_term_max_ray_contrib=", 1465 "0.5"); 1466 1467 RegisterOption("VspKdTree.epsilon", 1468 optFloat, 1469 "kd_eps=", 1470 "1e-6"); 1471 1472 RegisterOption("VspKdTree.ct_div_ci", 1473 optFloat, 1474 "vsp_ctdivci=", "1.0"); 1475 1476 RegisterOption("VspKdTree.splitType", 1477 optString, 1478 "split=", 1479 "queries"); 1480 1481 RegisterOption("VspKdTree.splitAxis", 1482 optString, 1483 "split=", 1484 "drivingAxis"); 1485 1486 RegisterOption("VspKdTree.splitUseOnlyDrivingAxis", 1487 optBool, 1488 "vsp_kd_splitdriving=", 1489 "false"); 1485 1490 1486 1491 RegisterOption("VspKdTree.numberOfEndPointDomains", … … 1535 1540 1536 1541 RegisterOption("VspKdTree.Termination.missTolerance", 1537 1538 1539 1542 optInt, 1543 "-vsp_kd_term_miss_tolerance=", 1544 "4"); 1540 1545 1541 1546 /************************************************************************************/ … … 1582 1587 1583 1588 RegisterOption("RssPreprocessor.vssSamples", 1584 1585 1586 1587 1589 optInt, 1590 "rss_vss_samples=", 1591 "1000000"); 1592 1588 1593 RegisterOption("RssPreprocessor.vssSamplesPerPass", 1589 1590 1591 1592 1594 optInt, 1595 "rss_vss_samples_per_pass=", 1596 "1000"); 1597 1593 1598 RegisterOption("RssPreprocessor.samplesPerPass", 1594 1595 1596 1597 1599 optInt, 1600 "rss_samples_per_pass=", 1601 "100000"); 1602 1598 1603 RegisterOption("RssPreprocessor.useImportanceSampling", 1599 1600 1601 1602 1604 optBool, 1605 "rss_use_importance", 1606 "true"); 1607 1603 1608 RegisterOption("RssPreprocessor.objectBasedSampling", 1604 1605 1606 1607 1609 optBool, 1610 "rss_object_based_sampling", 1611 "true"); 1612 1608 1613 RegisterOption("RssPreprocessor.directionalSampling", 1609 1610 1611 1612 1614 optBool, 1615 "rss_directional_sampling", 1616 "false"); 1617 1613 1618 RegisterOption("RssTree.maxDepth", optInt, "kd_depth=", "12"); 1614 1619 RegisterOption("RssTree.minPvs", optInt, "kd_minpvs=", "1"); … … 1616 1621 RegisterOption("RssTree.maxCostRatio", optFloat, "maxcost=", "0.95"); 1617 1622 RegisterOption("RssTree.maxRayContribution", optFloat, "maxraycontrib=", "0.5"); 1618 1623 1619 1624 RegisterOption("RssTree.epsilon", optFloat, "kd_eps=", "1e-6"); 1620 1625 RegisterOption("RssTree.ct_div_ci", optFloat, "kd_ctdivci=", "1.0"); … … 1622 1627 RegisterOption("RssTree.splitType", optString, "split=", "queries"); 1623 1628 RegisterOption("RssTree.splitUseOnlyDrivingAxis", optBool, "splitdriving=", "false"); 1624 1629 1625 1630 RegisterOption("RssTree.numberOfEndPointDomains", optInt, "endpoints=", "10000"); 1626 1631 1627 1632 RegisterOption("RssTree.minSize", optFloat, "minsize=", "0.001"); 1628 1633 1629 1634 RegisterOption("RssTree.maxTotalMemory", optFloat, "mem=", "60.0"); 1630 1635 RegisterOption("RssTree.maxStaticMemory", optFloat, "statmem=", "8.0"); 1631 1636 1632 1637 RegisterOption("RssTree.queryType", optString, "qtype=", "static"); 1633 1638 1634 1639 RegisterOption("RssTree.queryPosWeight", optFloat, "qposweight=", "0.0"); 1635 1640 RegisterOption("RssTree.useRefDirSplits", optBool, "refdir", "false"); … … 1638 1643 RegisterOption("RssTree.accessTimeThreshold", optInt, "accesstime=", "1000"); 1639 1644 RegisterOption("RssTree.minCollapseDepth", optInt, "colldepth=", "4"); 1640 1645 1641 1646 RegisterOption("RssTree.interleaveDirSplits", optBool, "interleavedirsplits", "true"); 1642 1647 RegisterOption("RssTree.dirSplitDepth", optInt, "dirsplidepth=", "10"); 1643 1648 RegisterOption("RssTree.importanceBasedCost", optBool, "importance_based_cost", "true"); 1644 1649 RegisterOption("RssTree.maxRays", optInt, "rss_max_rays=", "2000000"); 1645 1650 1646 1651 RegisterOption("RssPreprocessor.Export.pvs", optBool, "rss_export_pvs", "false"); 1647 1652 RegisterOption("RssPreprocessor.Export.rssTree", optBool, "rss_export_rss_tree", "false"); … … 1650 1655 RegisterOption("RssPreprocessor.useViewcells", optBool, "rss_use_viewcells", "false"); 1651 1656 RegisterOption("RssPreprocessor.updateSubdivision", optBool, "rss_update_subdivision", "false"); 1652 1653 1654 1655 1656 1657 1658 1659 /************************************************************************************/ 1660 /* View space partition BSP tree related options */ 1661 /************************************************************************************/ 1657 1662 1658 1663 1659 1664 RegisterOption("RssPreprocessor.loadInitialSamples", 1660 1661 1662 1665 optBool, 1666 "vss_load_loadInitialSamples=", 1667 "false"); 1663 1668 1664 1669 RegisterOption("RssPreprocessor.storeInitialSamples", 1665 optBool, 1666 "vss_store_storeInitialSamples=", 1667 "false"); 1668 1669 /************************************************************************************/ 1670 /* View space partition BSP tree related options */ 1671 /************************************************************************************/ 1670 optBool, 1671 "vss_store_storeInitialSamples=", 1672 "false"); 1673 1674 1675 /************************************************************************************/ 1676 /* View space partition BSP tree related options */ 1677 /************************************************************************************/ 1678 1679 1672 1680 RegisterOption("VspBspTree.Termination.minPolygons", 1673 1674 1675 1681 optInt, 1682 "vsp_bsp_term_min_polygons=", 1683 "5"); 1676 1684 1677 1685 RegisterOption("VspBspTree.Termination.minPvs", 1678 1679 1680 1686 optInt, 1687 "vsp_bsp_term_min_pvs=", 1688 "20"); 1681 1689 RegisterOption("VspBspTree.Termination.minArea", 1682 1683 1684 1690 optFloat, 1691 "vsp_bsp_term_min_area=", 1692 "0.001"); 1685 1693 1686 1694 RegisterOption("VspBspTree.Termination.maxRayContribution", 1687 1688 1689 1695 optFloat, 1696 "vsp_bsp_term_ray_contribution=", 1697 "0.005"); 1690 1698 1691 1699 RegisterOption("VspBspTree.Termination.minAccRayLenght", 1692 1693 1694 1700 optFloat, 1701 "vsp_bsp_term_min_acc_ray_length=", 1702 "50"); 1695 1703 1696 1704 RegisterOption("VspBspTree.Termination.minRays", 1697 1698 1699 1705 optInt, 1706 "vsp_bsp_term_min_rays=", 1707 "-1"); 1700 1708 1701 1709 RegisterOption("VspBspTree.Termination.ct_div_ci", 1702 1703 1704 1710 optFloat, 1711 "vsp_bsp_term_ct_div_ci=", 1712 "0.0"); 1705 1713 1706 1714 RegisterOption("VspBspTree.Termination.maxDepth", 1707 1708 1709 1715 optInt, 1716 "vsp_bsp_term_max_depth=", 1717 "100"); 1710 1718 1711 1719 RegisterOption("VspBspTree.Termination.AxisAligned.maxCostRatio", … … 1725 1733 1726 1734 RegisterOption("VspBspTree.Termination.missTolerance", 1727 1728 1729 1735 optInt, 1736 "vsp_bsp_term_miss_tolerance=", 1737 "4"); 1730 1738 RegisterOption("VspBspTree.splitPlaneStrategy", 1731 1732 1733 1739 optString, 1740 "vsp_bsp_split_method=", 1741 "leastSplits"); 1734 1742 1735 1743 RegisterOption("VspBspTree.maxPolyCandidates", 1736 1737 1738 1744 optInt, 1745 "vsp_bsp_max_poly_candidates=", 1746 "20"); 1739 1747 RegisterOption("VspBspTree.maxRayCandidates", 1740 1741 1742 1748 optInt, 1749 "vsp_bsp_max_plane_candidates=", 1750 "20"); 1743 1751 1744 1752 RegisterOption("VspBspTree.maxTests", 1745 1746 1747 1753 optInt, 1754 "vsp_bsp_max_tests=", 1755 "5000"); 1748 1756 1749 1757 RegisterOption("VspBspTree.Construction.samples", 1750 1751 1752 1758 optInt, 1759 "bsp_construction_samples=", 1760 "100000"); 1753 1761 1754 1762 RegisterOption("VspBspTree.Construction.epsilon", 1755 1756 1757 1763 optFloat, 1764 "vsp_bsp_construction_side_tolerance=", 1765 "0.002"); 1758 1766 1759 1767 RegisterOption("VspBspTree.Visualization.exportSplits", 1760 optBool, 1761 "vsp_bsp_visualization.export_splits", 1762 "false"); 1768 optBool, 1769 "vsp_bsp_visualization.export_splits", 1770 "false"); 1771 1772 RegisterOption("VspBspTree.splitUseOnlyDrivingAxis", 1773 optBool, 1774 "vsp_bsp_splitdriving=", 1775 "false"); 1776 1777 RegisterOption("VspBspTree.Termination.AxisAligned.minRays", 1778 optInt, 1779 "bsp_term_axis_aligned_min_rays=", 1780 "100"); 1763 1781 1764 RegisterOption("VspBspTree. splitUseOnlyDrivingAxis",1765 optBool,1766 "vsp_bsp_splitdriving=",1767 "false");1768 1782 RegisterOption("VspBspTree.Termination.AxisAligned.maxRayContribution", 1783 optFloat, 1784 "bsp_term_axis_aligned_min_rays=", 1785 "0.1"); 1786 1769 1787 RegisterOption("VspBspTree.Factor.leastRaySplits", optFloat, "-vsp_bsp_factor_least_ray_splits=", "1.0"); 1770 1788 RegisterOption("VspBspTree.Factor.balancedRays", optFloat, "-vsp_bsp_factor_balanced_rays=", "1.0"); … … 1785 1803 "vsp_bsp_term_post_process_max_pvs_size=", 1786 1804 "100"); 1787 1805 1788 1806 RegisterOption("VspBspTree.PostProcess.useRaysForMerge", 1789 1807 optBool, … … 1795 1813 "vsp_bsp_construction_randomize=", 1796 1814 "false"); 1815 1816 1817 RegisterOption("VspBspTree.maxTotalMemory", 1818 optFloat, 1819 "vsp_bsp_max_total_mem=", 1820 "60.0"); 1821 1822 RegisterOption("VspBspTree.maxStaticMemory", 1823 optFloat, 1824 "vsp_bsp_max_static_mem=", 1825 "8.0"); 1797 1826 ////////////////////////////////////////////////////////////////////////////////// 1798 1827 } -
trunk/VUT/GtpVisibilityPreprocessor/src/Parser.h
r339 r508 14 14 Parser() {} 15 15 16 virtual bool ParseFile(const string filename, SceneGraphNode **root) = 0;16 virtual bool ParseFile(const string filename, SceneGraphNode **root) {return false;}; 17 17 18 18 }; -
trunk/VUT/GtpVisibilityPreprocessor/src/Polygon3.cpp
r503 r508 477 477 int i = 1; 478 478 int j = 0; 479 int k = mVertices.size() - 1;479 int k = (int)mVertices.size() - 1; 480 480 int count = 0; 481 481 … … 490 490 } 491 491 } 492 493 494 void Polygon3::Triangulate(VertexIndexContainer &indices) 495 { 496 int i = 1; 497 int j = 0; 498 int k = (int)mVertices.size() - 1; 499 500 int count = 0; 501 502 while (i < k) 503 { 504 indices.push_back(k); 505 indices.push_back(j); 506 indices.push_back(i); 507 508 if ((count ++) % 2) 509 j = i ++; 510 else 511 j = k --; 512 } 513 } 514 515 516 void Polygon3::AddToMesh(Mesh &mesh) 517 { 518 const int n = (int)mesh.mVertices.size(); 519 520 //-- add the vertices 521 VertexContainer::const_iterator vit, vit_end = mVertices.end(); 522 for (vit = mVertices.begin(); vit != vit_end; ++ vit) 523 { 524 mesh.mVertices.push_back(*vit); 525 } 526 527 // one quad => no triangulation necessary 528 if ((int)mVertices.size() == 4) 529 { 530 mesh.AddFace(new Face(n, n + 1, n + 2, n + 3)); 531 } 532 else 533 { 534 VertexIndexContainer indices; 535 Triangulate(indices); 536 537 // add indices of triangle strip 538 for (int i = 0; i < (int)indices.size(); i += 3) 539 { 540 Face *face = new Face(n + indices[i], 541 n + indices[i + 1], 542 n + indices[i + 2]); 543 mesh.AddFace(face); 544 } 545 } 546 } -
trunk/VUT/GtpVisibilityPreprocessor/src/Polygon3.h
r503 r508 98 98 int CastRay(const Ray &ray, float &t, const float nearestT); 99 99 100 /** The polygon is triangulated.100 /** The polygon is converted to triangles. 101 101 */ 102 102 void Triangulate(vector<Triangle3> &triangles); 103 103 /** 104 Adds polygon to mesh 105 */ 106 void AddToMesh(Mesh &mesh); 107 /** 108 Triangle strip indices are created from this polgon. 109 */ 110 void Triangulate(VertexIndexContainer &indices); 111 104 112 /** The piercing rays of the polygon are inherited by the child fragments 105 113 @parm front_piece the front fragment inheriting the front rays -
trunk/VUT/GtpVisibilityPreprocessor/src/Preprocessor.cpp
r496 r508 59 59 Preprocessor::LoadScene(const string filename) 60 60 { 61 // use leaf nodes of the original spatial hiearrchy as occludees 62 63 mSceneGraph = new SceneGraph; 61 // use leaf nodes of the original spatial hiearrchy as occludees 62 mSceneGraph = new SceneGraph; 64 63 65 64 Parser *parser; 66 65 vector<string> filenames; 67 66 int files = SplitFilenames(filename, filenames); … … 176 175 } 177 176 177 178 178 bool Preprocessor::PrepareViewCells() 179 179 { … … 257 257 environment->GetStringValue("ViewCells.filename", buff); 258 258 string vcFilename(buff); 259 mViewCellsManager->LoadViewCells(vcFilename );259 mViewCellsManager->LoadViewCells(vcFilename, &mObjects); 260 260 } 261 261 … … 364 364 } 365 365 366 bool Preprocessor::WriteSamples(const VssRayContainer &samples) const 366 367 bool Preprocessor::ExportSamples(const VssRayContainer &samples) const 367 368 { 368 369 char fileName[100]; -
trunk/VUT/GtpVisibilityPreprocessor/src/Preprocessor.h
r496 r508 96 96 @returns true if samples were written successfully 97 97 */ 98 bool WriteSamples(const VssRayContainer &samples) const; 98 bool ExportSamples(const VssRayContainer &samples) const; 99 99 100 /// scene graph loaded from file 100 101 SceneGraph *mSceneGraph; -
trunk/VUT/GtpVisibilityPreprocessor/src/RayInfo.cpp
r485 r508 139 139 // non-intersecting, otherwise polygon-plane intersections of bsp tree 140 140 // approaches are not eliminating any rays intersecting the polygon! 141 142 //if (t > GetMaxT()) 141 #if 1 143 142 if (t >= GetMaxT() - 1e-20) 144 143 return splitPlane.Side(ExtrapOrigin()); 145 //if (t < GetMinT())146 144 if (t <= GetMinT() + 1e-20) 147 145 return splitPlane.Side(ExtrapTermination()); 148 146 #else 147 if (t > GetMaxT()) 148 return splitPlane.Side(ExtrapOrigin()); 149 else if (t < GetMinT()) 150 return splitPlane.Side(ExtrapTermination()); 151 #endif 149 152 return 0; 150 153 } -
trunk/VUT/GtpVisibilityPreprocessor/src/RssPreprocessor.cpp
r504 r508 580 580 cout << "#totalRayStackSize=" << (int)mVssRays.size() << endl <<flush; 581 581 582 rssSamples += mVssRays.size();582 rssSamples += (int)mVssRays.size(); 583 583 584 584 … … 592 592 { 593 593 cout << "Writing samples to file ... "; 594 WriteSamples(mVssRays);594 ExportSamples(mVssRays); 595 595 cout << "finished\n" << endl; 596 596 } … … 731 731 VssRayContainer contributingRays; 732 732 vssRays.GetContributingRays(contributingRays, mPass); 733 mStats<<"#NUM_CONTRIBUTING_RAYS\n"<< contributingRays.size()<<endl;733 mStats<<"#NUM_CONTRIBUTING_RAYS\n"<<(int)contributingRays.size()<<endl; 734 734 sprintf(filename, "rss-crays-%04d.x3d", rssPass); 735 735 ExportRays(filename, contributingRays, mExportNumRays); -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp
r503 r508 2527 2527 2528 2528 2529 BspNodeGeometry::BspNodeGeometry(const BspNodeGeometry &rhs) 2530 { 2531 PolygonContainer::const_iterator it, it_end = rhs.mPolys.end(); 2532 for (it = rhs.mPolys.begin(); it != it_end; ++ it) 2533 { 2534 Polygon3 *poly = *it; 2535 mPolys.push_back(new Polygon3(*poly)); 2536 } 2537 } 2538 2529 2539 BspNodeGeometry::~BspNodeGeometry() 2530 2540 { … … 2542 2552 { 2543 2553 PolygonContainer::const_iterator it, it_end = mPolys.end(); 2544 int vcount = 0; 2545 2554 2546 2555 for (it = mPolys.begin(); it != mPolys.end(); ++ it) 2547 2556 { 2548 Polygon3 *poly = *it; 2549 2550 vector<Triangle3> triangles; 2551 poly->Triangulate(triangles); 2552 vector<Triangle3>::const_iterator tit, tit_end = triangles.end(); 2553 2554 for (tit = triangles.begin(); tit != tit_end; ++ tit) 2555 { 2556 mesh.mVertices.push_back((*tit).mVertices[0]); 2557 mesh.mVertices.push_back((*tit).mVertices[1]); 2558 mesh.mVertices.push_back((*tit).mVertices[2]); 2559 2560 Face *face = new Face(vcount ++, vcount ++, vcount ++); 2561 mesh.AddFace(face); 2562 } 2557 (*it)->AddToMesh(mesh); 2563 2558 } 2564 2559 } -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.h
r503 r508 25 25 BspNodeGeometry() 26 26 {}; 27 28 // copy constructor copying the polygon array 29 BspNodeGeometry(const BspNodeGeometry &rhs); 27 30 28 31 ~BspNodeGeometry(); … … 330 333 /// leaf pvs 331 334 ObjectPvs *mPvs; 335 332 336 /// leaf area 333 337 float mArea; -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.cpp
r503 r508 11 11 #include "Exporter.h" 12 12 #include "VspBspTree.h" 13 13 #include "ViewCellsParser.h" 14 14 15 15 ViewCellsManager::ViewCellsManager(): … … 66 66 67 67 68 bool ViewCellsManager::LoadViewCells(const string filename )68 bool ViewCellsManager::LoadViewCells(const string filename, ObjectContainer *objects) 69 69 { 70 70 X3dParser parser; … … 317 317 { 318 318 mViewCells.clear(); 319 319 320 320 CollectViewCells(); 321 321 322 mViewCellsStats.Reset(); 322 323 EvaluateViewCellsStats(); … … 328 329 void ViewCellsManager::ComputeSampleContributions(VssRay &ray) 329 330 { 330 331 332 333 331 ViewCellContainer viewcells; 334 332 … … 445 443 446 444 447 void ViewCellsManager::ExportViewCells(Exporter *exporter) const 445 void ViewCellsManager::CreateUniqueViewCellIds() 446 { 447 for (int i = 0; i < (int)mViewCells.size(); ++ i) 448 mViewCells[i]->SetId(i); 449 } 450 451 452 void ViewCellsManager::ExportViewCellsForViz(Exporter *exporter) const 448 453 { 449 454 ViewCellContainer::const_iterator it, it_end = mViewCells.end(); … … 457 462 458 463 459 460 464 void ViewCellsManager::CreateViewCellsMeshes() 461 465 { … … 468 472 } 469 473 } 474 475 476 bool ViewCellsManager::ExportViewCells(const string filename) 477 { 478 return false; 479 } 480 481 482 void ViewCellsManager::ExportViewCell(ViewCell *viewCell, ofstream &stream) 483 { 484 stream << "<ViewCell id=\"" << viewCell->GetId() << "\" "; 485 stream << "pvs=\""; 486 487 ObjectPvsMap::iterator it, it_end = viewCell->GetPvs().mEntries.end(); 488 if(0) // test with empty pvs 489 for (it = viewCell->GetPvs().mEntries.begin(); it != it_end; ++ it) 490 { 491 stream << (*it).first->GetId() << " "; 492 } 493 494 stream << "\" />" << endl; 495 } 496 470 497 471 498 /**********************************************************************/ … … 617 644 //exporter->SetWireframe(); 618 645 exporter->SetFilled(); 619 ExportViewCells (exporter);646 ExportViewCellsForViz(exporter); 620 647 621 648 if (mExportGeometry) … … 723 750 if (exporter) 724 751 { 725 ExportViewCells (exporter);752 ExportViewCellsForViz(exporter); 726 753 delete exporter; 727 754 } … … 1605 1632 //else exporter->SetFilled(); 1606 1633 1607 ExportViewCells (exporter);1634 ExportViewCellsForViz(exporter); 1608 1635 1609 1636 if (mExportGeometry) … … 1789 1816 GetRaySets(rays, mConstructionSamples, constructionRays, &savedRays); 1790 1817 1791 Debug << "construction rays: " << (int) savedRays.size() << endl;1792 Debug << "saved rays: " << (int) constructionRays.size() << endl;1818 Debug << "construction rays: " << (int)constructionRays.size() << endl; 1819 Debug << "saved rays: " << (int)savedRays.size() << endl; 1793 1820 1794 1821 mVspBspTree->Construct(constructionRays, &mSceneBox); … … 1818 1845 //exporter->SetWireframe(); 1819 1846 exporter->SetFilled(); 1820 ExportViewCells (exporter);1847 ExportViewCellsForViz(exporter); 1821 1848 1822 1849 if (0 && mExportRays) … … 1909 1936 //exporter->SetWireframe(); 1910 1937 exporter->SetFilled(); 1911 ExportViewCells (exporter);1938 ExportViewCellsForViz(exporter); 1912 1939 1913 1940 if (mExportGeometry) … … 1960 1987 } 1961 1988 1989 // real meshes are only contructed only at this stage 1962 1990 CreateViewCellsMeshes(); 1991 // write view cells to disc 1992 if (mExportViewCells) 1993 { 1994 ExportViewCells("viewcells.xml"); 1995 } 1963 1996 1964 1997 return 0; … … 2025 2058 } 2026 2059 2027 ExportViewCells (exporter);2060 ExportViewCellsForViz(exporter); 2028 2061 delete exporter; 2029 2062 } … … 2310 2343 ViewCell *VspBspViewCellsManager::GetViewCell(const Vector3 &point) 2311 2344 { 2312 2313 return NULL;2314 2345 if (!mVspBspTree) 2346 return NULL; 2347 return mVspBspTree->GetViewCell(point); 2315 2348 } 2316 2349 … … 2327 2360 mMeshContainer.push_back(mesh); 2328 2361 } 2362 2363 2364 bool VspBspViewCellsManager::LoadViewCells(const string filename, ObjectContainer *objects) 2365 { 2366 ViewCellsParser parser; 2367 2368 DEL_PTR(mVspBspTree); 2369 mVspBspTree = new VspBspTree(); 2370 2371 bool success = parser.ParseFile(filename, mVspBspTree, this, objects); 2372 ResetViewCells(); 2373 2374 Debug << (int)mViewCells.size() << " view cells loaded" << endl; 2375 2376 return success; 2377 } 2378 2379 2380 inline bool ilt(Intersectable *obj1, Intersectable *obj2) 2381 { 2382 return obj1->mId < obj2->mId; 2383 } 2384 2385 2386 bool VspBspViewCellsManager::ExportViewCells(const string filename) 2387 { 2388 cout << "exporting view cells to xml ... "; 2389 std::ofstream stream; 2390 2391 // for output we need unique ids 2392 CreateUniqueViewCellIds(); 2393 2394 stream.open(filename.c_str()); 2395 stream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"<<endl; 2396 stream << "<Visibility_Solution>" << endl; 2397 2398 //-- load the view cells itself, i.e., the ids and the pvs 2399 stream << "<ViewCells>" << endl; 2400 ViewCellContainer::const_iterator it, it_end = mViewCells.end(); 2401 for (it = mViewCells.begin(); it != it_end; ++ it) 2402 ExportViewCell(*it, stream); 2403 2404 stream << "</ViewCells>" << endl; 2405 2406 //-- load the hierarchy 2407 stream << "<BspTree>" << endl; 2408 mVspBspTree->Export(stream); 2409 stream << endl << "</BspTree>" << endl; 2410 2411 stream << "</Visibility_Solution>" << endl; 2412 stream.close(); 2413 2414 cout << "finished" << endl; 2415 2416 return true; 2417 } -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.h
r503 r508 104 104 @return true on success 105 105 */ 106 bool LoadViewCells(const string filename);106 virtual bool LoadViewCells(const string filename, ObjectContainer *objects); 107 107 108 108 /** Constructs view cell from base triangle. The ViewCell is extruded along the normal vector. … … 237 237 virtual void CreateMesh(ViewCell *vc) = NULL; 238 238 239 /** Writes view cells to disc. 240 */ 241 virtual bool ExportViewCells(const string filename); 242 239 243 protected: 240 244 241 245 void ParseEnvironment(); 242 246 247 /** Creates unique view cell ids. 248 */ 249 void CreateUniqueViewCellIds(); 243 250 /** Recollects view cells and resets statistics. 244 251 */ … … 254 261 void EvaluateViewCellsStats(); 255 262 256 257 263 //-- helper functions for view cell visualization 258 264 259 265 /** Exports the view cell partition. 260 266 */ 261 void ExportViewCells (Exporter *exporter) const;267 void ExportViewCellsForViz(Exporter *exporter) const; 262 268 263 269 /** Sets exporter color. … … 272 278 */ 273 279 void CreateViewCellsMeshes(); 280 281 /** 282 Exports single view cell. 283 NOTE: should be in exporter!! 284 */ 285 void ExportViewCell(ViewCell *viewCell, ofstream &stream); 274 286 275 287 /// the view cell corresponding to space ouside the valid view space … … 298 310 /// the scene bounding box 299 311 AxisAlignedBox3 mSceneBox; 300 312 /// holds the view cell meshes 301 313 MeshContainer mMeshContainer; 302 314 /// if view cells should be exported 315 bool mExportViewCells; 303 316 //-- visualization options 304 317 … … 551 564 void CreateMesh(ViewCell *vc); 552 565 566 bool LoadViewCells(const string filename, ObjectContainer *objects); 567 bool ExportViewCells(const string filename); 568 553 569 protected: 554 570 555 571 /** Merges the view cells. 556 572 */ 557 void MergeViewCells(const VssRayContainer &rays, const ObjectContainer &objects); 573 void MergeViewCells(const VssRayContainer &rays, 574 const ObjectContainer &objects); 558 575 559 576 void RefineViewCells(const VssRayContainer &rays); -
trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.cpp
r503 r508 19 19 20 20 //-- static members 21 21 22 /** Evaluates split plane classification with respect to the plane's 22 23 contribution for a minimum number of ray splits. … … 35 36 float BspMergeCandidate::sOverallCost = 0; 36 37 37 /**************************************************************** /38 /* class VspBspTree implementation */39 /**************************************************************** /38 /********************************************************************/ 39 /* class VspBspTree implementation */ 40 /********************************************************************/ 40 41 41 42 VspBspTree::VspBspTree(): … … 44 45 mCostNormalizer(Limits::Small), 45 46 mViewCellsManager(NULL), 46 mStoreRays(false),47 47 mOutOfBoundsCell(NULL), 48 mShowInvalidSpace(false) 48 mShowInvalidSpace(false), 49 mStoreRays(false) 49 50 { 50 51 bool randomize = false; … … 88 89 environment->GetIntValue("ViewCells.maxPvs", mMaxPvs); 89 90 91 //-- termination criteria for axis aligned split 92 environment->GetFloatValue("VspBspTree.Termination.AxisAligned.maxRayContribution", 93 mTermMaxRayContriForAxisAligned); 94 environment->GetIntValue("VspBspTree.Termination.AxisAligned.minRays", 95 mTermMinRaysForAxisAligned); 96 97 //environment->GetFloatValue("VspBspTree.maxTotalMemory", mMaxTotalMemory); 98 environment->GetFloatValue("VspBspTree.maxStaticMemory", mMaxMemory); 90 99 91 100 //-- debug output … … 135 144 } 136 145 146 BspViewCell *VspBspTree::GetOutOfBoundsCell() 147 { 148 return mOutOfBoundsCell; 149 } 150 137 151 138 152 BspViewCell *VspBspTree::GetOrCreateOutOfBoundsCell() 139 153 { 140 154 if (!mOutOfBoundsCell) 155 { 141 156 mOutOfBoundsCell = new BspViewCell(); 142 157 mOutOfBoundsCell->SetId(-1); 158 } 143 159 return mOutOfBoundsCell; 144 160 } … … 326 342 } 327 343 344 345 // return memory usage in MB 346 float VspBspTree::GetMemUsage() const 347 { 348 return 349 (sizeof(VspBspTree) + 350 mStat.Leaves() * sizeof(BspLeaf) + 351 mStat.Interior() * sizeof(BspInterior) + 352 mStat.accumRays * sizeof(RayInfo)) / (1024.0f * 1024.0f); 353 } 354 355 356 328 357 void VspBspTree::Construct(const PolygonContainer &polys, RayInfoContainer *rays) 329 358 { … … 350 379 351 380 long startTime = GetTime(); 381 382 bool mOutOfMemory = false; 352 383 353 384 while (!tStack.empty()) 354 385 { 355 386 tData = tStack.top(); 356 357 tStack.pop(); 387 tStack.pop(); 388 389 if (0 && !mOutOfMemory) 390 { 391 float mem = GetMemUsage(); 392 393 if (mem > mMaxMemory) 394 { 395 mOutOfMemory = true; 396 Debug << "memory limit reached: " << mem << endl; 397 } 398 } 358 399 359 400 // subdivide leaf node … … 365 406 } 366 407 408 Debug << "Used Memory: " << GetMemUsage() << " MB" << endl; 367 409 cout << "finished\n"; 368 410 369 411 mStat.Stop(); 370 412 } 413 371 414 372 415 bool VspBspTree::TerminationCriteriaMet(const VspBspTraversalData &data) const … … 377 420 (data.mArea <= mTermMinArea) || 378 421 (mStat.Leaves() >= mMaxViewCells) || 379 //(data.GetAvgRayContribution() >= mTermMaxRayContribution) ||422 (data.GetAvgRayContribution() >= mTermMaxRayContribution) || 380 423 (data.mDepth >= mTermMaxDepth)); 381 424 } 425 382 426 383 427 BspNode *VspBspTree::Subdivide(VspBspTraversalStack &tStack, … … 386 430 BspNode *newNode = tData.mNode; 387 431 388 if (! TerminationCriteriaMet(tData))432 if (!mOutOfMemory || !TerminationCriteriaMet(tData)) 389 433 { 390 434 PolygonContainer coincident; … … 423 467 } 424 468 else 425 { 426 // create new view cell for this leaf 469 { // create new view cell for this leaf 427 470 viewCell = new BspViewCell(); 428 471 } … … 465 508 { 466 509 BspLeaf *leaf = dynamic_cast<BspLeaf *>(tData.mNode); 467 468 int maxCostMisses = tData.mMaxCostMisses; 469 510 470 511 // select subdivision plane 471 512 Plane3 splitPlane; 472 if (!SelectPlane(splitPlane, leaf, tData)) 513 int maxCostMisses = tData.mMaxCostMisses; 514 bool success = SelectPlane(splitPlane, 515 leaf, 516 tData, 517 frontData, 518 backData); 519 if (!success) 473 520 { 474 521 ++ maxCostMisses; … … 492 539 493 540 //-- the front and back traversal data is filled with the new values 541 frontData.mDepth = tData.mDepth + 1; 494 542 frontData.mPolygons = new PolygonContainer(); 495 frontData.mDepth = tData.mDepth + 1;496 543 frontData.mRays = new RayInfoContainer(); 497 frontData.mGeometry = new BspNodeGeometry();498 544 545 backData.mDepth = tData.mDepth + 1; 499 546 backData.mPolygons = new PolygonContainer(); 500 backData.mDepth = tData.mDepth + 1;501 547 backData.mRays = new RayInfoContainer(); 502 backData.mGeometry = new BspNodeGeometry(); 503 548 504 549 // subdivide rays 505 550 SplitRays(interior->GetPlane(), … … 524 569 backData.mPvs = ComputePvsSize(*backData.mRays); 525 570 526 // split geometry and compute area 527 if (1) 528 { 529 tData.mGeometry->SplitGeometry(*frontData.mGeometry, 530 *backData.mGeometry, 531 interior->GetPlane(), 532 mBox, 533 mEpsilon); 534 535 frontData.mArea = frontData.mGeometry->GetArea(); 536 backData.mArea = backData.mGeometry->GetArea(); 537 } 538 539 // compute accumulated ray length 540 //frontData.mAccRayLength = AccumulatedRayLength(*frontData.mRays); 541 //backData.mAccRayLength = AccumulatedRayLength(*backData.mRays); 571 // split front and back node geometry and compute area 572 if (mPvsUseArea) 573 { 574 // if not already computed 575 if (!frontData.mGeometry && !backData.mGeometry) 576 { 577 frontData.mGeometry = new BspNodeGeometry(); 578 backData.mGeometry = new BspNodeGeometry(); 579 580 tData.mGeometry->SplitGeometry(*frontData.mGeometry, 581 *backData.mGeometry, 582 interior->GetPlane(), 583 mBox, 584 mEpsilon); 585 586 frontData.mArea = frontData.mGeometry->GetArea(); 587 backData.mArea = backData.mGeometry->GetArea(); 588 } 589 } 590 else 591 { 592 frontData.mArea = (float)frontData.mRays->size(); 593 backData.mArea = (float)backData.mRays->size(); 594 } 542 595 543 596 //-- create front and back leaf … … 565 618 return interior; 566 619 } 620 567 621 568 622 void VspBspTree::AddToPvs(BspLeaf *leaf, … … 757 811 const VspBspTraversalData &tData, 758 812 int &axis, 759 float &position, 760 int &raysBack, 761 int &raysFront, 762 int &pvsBack, 763 int &pvsFront) 764 { 765 AxisAlignedBox3 box; 766 box.Initialize(); 767 768 // create bounding box of region 769 RayInfoContainer::const_iterator ri, ri_end = tData.mRays->end(); 770 771 for(ri = tData.mRays->begin(); ri < ri_end; ++ ri) 772 box.Include((*ri).ExtrapTermination()); 773 813 BspNodeGeometry **frontGeom, 814 BspNodeGeometry **backGeom, 815 float &frontArea, 816 float &backArea) 817 { 774 818 const bool useCostHeuristics = false; 775 819 … … 777 821 float nPosition[3]; 778 822 float nCostRatio[3]; 823 float nFrontArea[3]; 824 float nBackArea[3]; 825 826 BspNodeGeometry *nFrontGeom[3]; 827 BspNodeGeometry *nBackGeom[3]; 828 779 829 int bestAxis = -1; 780 830 781 const int sAxis = box.Size().DrivingAxis(); 831 // create bounding box of node extent 832 AxisAlignedBox3 box; 833 box.Initialize(); 834 835 #if 0 836 RayInfoContainer::const_iterator ri, ri_end = tData.mRays->end(); 837 838 for(ri = tData.mRays->begin(); ri < ri_end; ++ ri) 839 box.Include((*ri).ExtrapTermination()); 840 #else 841 PolygonContainer::const_iterator it, it_end = tData.mGeometry->mPolys.end(); 842 843 for(it = tData.mGeometry->mPolys.begin(); it < it_end; ++ it) 844 box.Include(*(*it)); 845 846 #endif 847 int sAxis = box.Size().DrivingAxis(); 782 848 783 849 for (axis = 0; axis < 3; ++ axis) 784 850 { 851 nFrontGeom[axis] = new BspNodeGeometry(); 852 nBackGeom[axis] = new BspNodeGeometry(); 853 785 854 if (!mOnlyDrivingAxis || axis == sAxis) 786 855 { … … 789 858 nPosition[axis] = (box.Min()[axis] + box.Max()[axis]) * 0.5f; 790 859 Vector3 normal(0,0,0); normal[axis] = 1; 791 792 nCostRatio[axis] = SplitPlaneCost(Plane3(normal, nPosition[axis]), tData); 860 861 nCostRatio[axis] = SplitPlaneCost(Plane3(normal, nPosition[axis]), 862 tData, *nFrontGeom[axis], *nBackGeom[axis], 863 nFrontArea[axis], nBackArea[axis]); 793 864 } 794 865 else … … 809 880 else if (nCostRatio[axis] < nCostRatio[bestAxis]) 810 881 { 811 /*Debug << "pvs front " << nPvsBack[axis]812 << " pvs back " << nPvsFront[axis]813 << " overall pvs " << leaf->GetPvsSize() << endl;*/814 882 bestAxis = axis; 815 883 } … … 820 888 //-- assign values 821 889 axis = bestAxis; 822 position = nPosition[bestAxis]; 823 824 raysBack = 0;//nRaysBack[bestAxis]; 825 raysFront = 0;//nRaysFront[bestAxis]; 826 827 pvsBack = 0;//nPvsBack[bestAxis]; 828 pvsFront = 0;//nPvsFront[bestAxis]; 829 830 Vector3 normal(0,0,0); normal[bestAxis] = 1; 890 frontArea = nFrontArea[bestAxis]; 891 backArea = nBackArea[bestAxis]; 892 893 // assign best split nodes geometry 894 *frontGeom = nFrontGeom[bestAxis]; 895 *backGeom = nBackGeom[bestAxis]; 896 // and delete other geometry 897 delete nFrontGeom[(bestAxis + 1) % 3]; 898 delete nBackGeom[(bestAxis + 2) % 3]; 899 900 //-- split plane 901 Vector3 normal(0,0,0); normal[bestAxis] = 1; 831 902 plane = Plane3(normal, nPosition[bestAxis]); 832 903 833 904 return nCostRatio[bestAxis]; 834 905 } 835 906 836 907 837 /* 838 float VspBspTree::EvalCostRatio(const VspBspTraversalData &tData, 839 const AxisAlignedBox3 &box, 840 const int axis, 841 const float position, 842 int &raysBack, 843 int &raysFront, 844 int &pvsBack, 845 int &pvsFront) 846 { 847 raysBack = 0; 848 raysFront = 0; 849 pvsFront = 0; 850 pvsBack = 0; 851 852 Intersectable::NewMail(3); 853 854 // eval pvs size 855 const int pvsSize = tData.mPvs; 856 857 // create unique ids for pvs heuristics 858 GenerateUniqueIdsForPvs(); 859 860 // this is the main ray classification loop! 861 for(RayInfoContainer::iterator ri = tData.mRays->begin(); 862 ri != tData.mRays->end(); ++ ri) 863 { 864 if (!(*ri).mRay->IsActive()) 865 continue; 866 867 // determine the side of this ray with respect to the plane 868 float t; 869 int side = (*ri).ComputeRayIntersection(axis, position, t); 870 871 if (side <= 0) 872 ++ raysBack; 873 874 if (side >= 0) 875 ++ raysFront; 876 877 AddObjToPvs((*ri).mRay->mTerminationObject, side, pvsBack, pvsFront); 878 } 879 880 //-- only one of these options should be one 881 882 if (0) //-- only pvs 883 { 884 const float sum = float(pvsBack + pvsFront); 885 const float oldCost = (float)pvsSize; 886 887 return sum / oldCost; 888 } 889 890 //-- pvs + probability heuristics 891 float pBack, pFront, pOverall; 892 893 if (0) 894 { 895 // box length substitute for probability 896 const float minBox = box.Min(axis); 897 const float maxBox = box.Max(axis); 898 899 pBack = position - minBox; 900 pFront = maxBox - position; 901 pOverall = maxBox - minBox; 902 } 903 904 if (1) //-- area substitute for probability 905 { 906 907 const bool useMidSplit = true; 908 //const bool useMidSplit = false; 909 910 pOverall = box.SurfaceArea(); 911 912 if (!useMidSplit) 913 { 914 Vector3 pos = box.Max(); pos[axis] = position; 915 pBack = AxisAlignedBox3(box.Min(), pos).SurfaceArea(); 916 917 pos = box.Min(); pos[axis] = position; 918 pFront = AxisAlignedBox3(pos, box.Max()).SurfaceArea(); 919 } 920 else 921 { 922 //-- simplified computation for mid split 923 const int axis2 = (axis + 1) % 3; 924 const int axis3 = (axis + 2) % 3; 925 926 const float faceArea = 927 (box.Max(axis2) - box.Min(axis2)) * 928 (box.Max(axis3) - box.Min(axis3)); 929 930 pBack = pFront = pOverall * 0.5f + faceArea; 931 } 932 } 933 934 //-- ray density substitute for probability 935 if (0) 936 { 937 pBack = (float)raysBack; 938 pFront = (float)raysFront; 939 pOverall = (float)tData.mRays->size(); 940 } 941 942 //Debug << axis << " " << pvsSize << " " << pvsBack << " " << pvsFront << endl; 943 //Debug << pFront << " " << pBack << " " << pOverall << endl; 944 945 // float sum = raysBack*(position - minBox) + raysFront*(maxBox - position); 946 const float newCost = pvsBack * pBack + pvsFront * pFront; 947 // float oldCost = leaf->mRays.size(); 948 const float oldCost = (float)pvsSize * pOverall; 949 950 return (mCtDivCi + newCost) / oldCost; 951 } 952 */ 953 954 955 bool VspBspTree::SelectPlane(Plane3 &plane, 908 bool VspBspTree::SelectPlane(Plane3 &bestPlane, 956 909 BspLeaf *leaf, 957 VspBspTraversalData &data) 910 VspBspTraversalData &data, 911 VspBspTraversalData &frontData, 912 VspBspTraversalData &backData) 958 913 { 959 914 // simplest strategy: just take next polygon … … 962 917 if (!data.mPolygons->empty()) 963 918 { 964 const int randIdx = (int)RandomValue(0, (Real)((int)data.mPolygons->size() - 1)); 919 const int randIdx = 920 (int)RandomValue(0, (Real)((int)data.mPolygons->size() - 1)); 965 921 Polygon3 *nextPoly = (*data.mPolygons)[randIdx]; 966 922 967 plane = nextPoly->GetSupportingPlane();923 bestPlane = nextPoly->GetSupportingPlane(); 968 924 return true; 969 925 } 970 926 } 971 927 972 // use heuristics to find appropriate plane 973 return SelectPlaneHeuristics(plane, leaf, data); 928 //-- use heuristics to find appropriate plane 929 930 // intermediate plane 931 Plane3 plane; 932 float lowestCost = MAX_FLOAT; 933 934 const bool onlyAxisAligned = 935 (mSplitPlaneStrategy & AXIS_ALIGNED) && 936 ((int)data.mRays->size() > mTermMinRaysForAxisAligned) && 937 ((int)data.GetAvgRayContribution() < mTermMaxRayContriForAxisAligned); 938 939 // split polygons if no axis aligned splits 940 const int limit = onlyAxisAligned ? 0 : 941 Min((int)data.mPolygons->size(), mMaxPolyCandidates); 942 943 float candidateCost; 944 945 int maxIdx = (int)data.mPolygons->size(); 946 947 for (int i = 0; i < limit; ++ i) 948 { 949 //-- assure that no index is taken twice 950 const int candidateIdx = (int)RandomValue(0, (Real)(-- maxIdx)); 951 Polygon3 *poly = (*data.mPolygons)[candidateIdx]; 952 953 // swap candidate to the end to avoid testing same plane 954 std::swap((*data.mPolygons)[maxIdx], (*data.mPolygons)[candidateIdx]); 955 //Polygon3 *poly = (*data.mPolygons)[(int)RandomValue(0, (int)polys.size() - 1)]; 956 957 // evaluate current candidate 958 BspNodeGeometry fGeom, bGeom; 959 float fArea, bArea; 960 plane = poly->GetSupportingPlane(); 961 candidateCost = SplitPlaneCost(plane, data, fGeom, bGeom, fArea, bArea); 962 963 if (candidateCost < lowestCost) 964 { 965 bestPlane = plane; 966 lowestCost = candidateCost; 967 } 968 } 969 970 //-- evaluate axis aligned splits 971 int axis; 972 BspNodeGeometry *fGeom, *bGeom; 973 float fArea, bArea; 974 975 candidateCost = SelectAxisAlignedPlane(plane, data, axis, 976 &fGeom, &bGeom, 977 fArea, bArea); 978 979 if (candidateCost < lowestCost) 980 { 981 bestPlane = plane; 982 lowestCost = candidateCost; 983 984 //-- assign already computed values 985 frontData.mGeometry = fGeom; 986 backData.mGeometry = bGeom; 987 frontData.mArea = fArea; 988 backData.mArea = bArea; 989 990 //! error also computed if cost ratio is missed 991 ++ mStat.splits[axis]; 992 } 993 else 994 { 995 DEL_PTR(fGeom); 996 DEL_PTR(bGeom); 997 } 998 999 #ifdef _DEBUG 1000 Debug << "plane lowest cost: " << lowestCost << endl; 1001 #endif 1002 1003 // cost ratio miss 1004 if (lowestCost > mTermMaxCostRatio) 1005 return false; 1006 1007 return true; 974 1008 } 975 1009 … … 1048 1082 1049 1083 1050 bool VspBspTree::SelectPlaneHeuristics(Plane3 &bestPlane,1051 BspLeaf *leaf,1052 VspBspTraversalData &data)1053 {1054 float lowestCost = MAX_FLOAT;1055 // intermediate plane1056 Plane3 plane;1057 bool useAxisAlignedPlane = false;1058 1059 const int limit = Min((int)data.mPolygons->size(), mMaxPolyCandidates);1060 int maxIdx = (int)data.mPolygons->size();1061 1062 float candidateCost;1063 1064 for (int i = 0; i < limit; ++ i)1065 {1066 //-- assure that no index is taken twice1067 const int candidateIdx = (int)RandomValue(0, (Real)(-- maxIdx));1068 Polygon3 *poly = (*data.mPolygons)[candidateIdx];1069 1070 // swap candidate to the end to avoid testing same plane1071 std::swap((*data.mPolygons)[maxIdx], (*data.mPolygons)[candidateIdx]);1072 1073 //Polygon3 *poly = (*data.mPolygons)[(int)RandomValue(0, (int)polys.size() - 1)];1074 1075 // evaluate current candidate1076 candidateCost = SplitPlaneCost(poly->GetSupportingPlane(), data);1077 1078 if (candidateCost < lowestCost)1079 {1080 bestPlane = poly->GetSupportingPlane();1081 lowestCost = candidateCost;1082 }1083 }1084 1085 //-- axis aligned splits1086 int axis;1087 float position;1088 int raysBack;1089 int raysFront;1090 int pvsFront;1091 int pvsBack;1092 1093 candidateCost = SelectAxisAlignedPlane(plane,1094 data,1095 axis,1096 position,1097 raysBack,1098 raysFront,1099 pvsFront,1100 pvsBack);1101 1102 if (candidateCost < lowestCost)1103 {1104 if (!useAxisAlignedPlane)1105 {1106 useAxisAlignedPlane = true;1107 //if (data.mPolygons->size() > 0)1108 // Debug << "haha" << endl;1109 //! error also computed if cost ratio is missed1110 ++ mStat.splits[axis];1111 }1112 1113 bestPlane = plane;1114 lowestCost = candidateCost;1115 }1116 1117 #ifdef _DEBUG1118 Debug << "plane lowest cost: " << lowestCost << endl;1119 #endif1120 1121 // cost ratio miss1122 if (lowestCost > mTermMaxCostRatio)1123 return false;1124 1125 return true;1126 }1127 1128 1129 1084 inline void VspBspTree::GenerateUniqueIdsForPvs() 1130 1085 { … … 1136 1091 1137 1092 float VspBspTree::SplitPlaneCost(const Plane3 &candidatePlane, 1138 const VspBspTraversalData &data) const 1093 const VspBspTraversalData &data, 1094 BspNodeGeometry &geomFront, 1095 BspNodeGeometry &geomBack, 1096 float &areaFront, 1097 float &areaBack) const 1139 1098 { 1140 1099 float cost = 0; … … 1143 1102 float sumRaySplits = 0; 1144 1103 1145 int frontPvs= 0;1146 int backPvs= 0;1147 1148 // probability that view point lies in child1104 int pvsFront = 0; 1105 int pvsBack = 0; 1106 1107 // probability that view point lies in back / front node 1149 1108 float pOverall = 0; 1150 1109 float pFront = 0; 1151 1110 float pBack = 0; 1152 1111 1112 int raysFront = 0; 1113 int raysBack = 0; 1114 int totalPvs = 0; 1115 1153 1116 if (mSplitPlaneStrategy & PVS) 1154 1117 { … … 1159 1122 { 1160 1123 // construct child geometry with regard to the candidate split plane 1161 BspNodeGeometry frontCell; 1162 BspNodeGeometry backCell; 1163 1164 data.mGeometry->SplitGeometry(frontCell, 1165 backCell, 1124 data.mGeometry->SplitGeometry(geomFront, 1125 geomBack, 1166 1126 candidatePlane, 1167 1127 mBox, 1168 1128 mEpsilon); 1169 1129 1170 pFront = frontCell.GetArea(); 1171 pBack = backCell.GetArea(); 1172 1130 areaFront = geomFront.GetArea(); 1131 areaBack = geomBack.GetArea(); 1132 1133 pBack = areaBack; 1134 pFront = areaFront; 1173 1135 pOverall = data.mArea; 1136 } 1137 else // use number of rays to approximate volume 1138 { 1139 pOverall = (float)data.mRays->size(); 1140 pFront = (float)raysFront; 1141 pBack = (float)raysBack; 1174 1142 } 1175 1143 } … … 1189 1157 limit = (int)data.mRays->size(); 1190 1158 } 1191 1159 1192 1160 for (int i = 0; i < limit; ++ i) 1193 1161 { 1194 const int testIdx = useRand ? (int)RandomValue(0, (Real)(limit - 1)) : i; 1162 const int testIdx = useRand ? 1163 (int)RandomValue(0, (Real)((int)data.mRays->size() - 1)) : i; 1195 1164 RayInfo rayInf = (*data.mRays)[testIdx]; 1196 1165 1166 float t; 1197 1167 VssRay *ray = rayInf.mRay; 1198 float t;1199 1168 const int cf = rayInf.ComputeRayIntersection(candidatePlane, t); 1169 1170 if (cf >= 0) 1171 ++ raysFront; 1172 if (cf <= 0) 1173 ++ raysBack; 1200 1174 1201 1175 if (mSplitPlaneStrategy & LEAST_RAY_SPLITS) … … 1212 1186 if (mSplitPlaneStrategy & PVS) 1213 1187 { 1214 // in case the ray intersects an object 1215 // assure that we only count the object 1216 // once for the front and once for the back side of the plane 1217 AddObjToPvs(ray->mTerminationObject, cf, frontPvs, backPvs); 1218 AddObjToPvs(ray->mOriginObject, cf, frontPvs, backPvs); 1219 1220 // use number of rays to approximate volume 1221 if (!mPvsUseArea) 1222 { 1223 pOverall = (float)data.mRays->size(); 1224 1225 if (cf >= 0) 1226 ++ pFront; 1227 if (cf <= 0) 1228 ++ pBack; 1229 } 1188 // find front and back pvs for origing and termination object 1189 AddObjToPvs(ray->mTerminationObject, cf, pvsFront, pvsBack, totalPvs); 1190 AddObjToPvs(ray->mOriginObject, cf, pvsFront, pvsBack, totalPvs); 1230 1191 } 1231 1192 } … … 1242 1203 if (mSplitPlaneStrategy & PVS) 1243 1204 { 1244 const float oldCost = pOverall * (float)data.mPvs + Limits::Small; 1245 cost += mPvsFactor * (frontPvs * pFront + backPvs * pBack) / oldCost; 1246 1247 //cost += mPvsFactor * 0.5 * (frontPvs * pFront + backPvs * pBack) / oldCost; 1248 //Debug << "new cost: " << cost << " over" << frontPvs * pFront + backPvs * pBack << " old cost " << oldCost << endl; 1249 1250 if (0) // give penalty to unbalanced split 1251 if (((pFront * 0.2 + Limits::Small) > pBack) || 1252 (pFront < (pBack * 0.2 + Limits::Small))) 1253 cost += 0.5; 1205 const float oldCost = pOverall * (float)totalPvs + Limits::Small; 1206 cost += mPvsFactor * (pvsFront * pFront + pvsBack * pBack) / oldCost; 1254 1207 } 1255 1208 1256 1209 #ifdef _DEBUG 1257 1210 Debug << "totalpvs: " << data.mPvs << " ptotal: " << pOverall 1258 << " frontpvs: " << frontPvs<< " pFront: " << pFront1259 << " backpvs: " << backPvs<< " pBack: " << pBack << endl << endl;1211 << " frontpvs: " << pvsFront << " pFront: " << pFront 1212 << " backpvs: " << pvsBack << " pBack: " << pBack << endl << endl; 1260 1213 #endif 1261 1214 … … 1263 1216 return cost / (float)mCostNormalizer; 1264 1217 } 1218 1265 1219 1266 1220 void VspBspTree::AddObjToPvs(Intersectable *obj, 1267 1221 const int cf, 1268 1222 int &frontPvs, 1269 int &backPvs) const 1223 int &backPvs, 1224 int &totalPvs) const 1270 1225 { 1271 1226 if (!obj) 1272 1227 return; 1228 1229 if ((obj->mMailbox != sFrontId) && 1230 (obj->mMailbox != sBackId) && 1231 (obj->mMailbox != sFrontAndBackId)) 1232 { 1233 ++ totalPvs; 1234 } 1235 1273 1236 // TODO: does this really belong to no pvs? 1274 1237 //if (cf == Ray::COINCIDENT) return; … … 1281 1244 { 1282 1245 ++ frontPvs; 1283 1246 1284 1247 if (obj->mMailbox == sBackId) 1285 1248 obj->mMailbox = sFrontAndBackId; … … 1295 1258 { 1296 1259 ++ backPvs; 1297 1260 1298 1261 if (obj->mMailbox == sFrontId) 1299 1262 obj->mMailbox = sFrontAndBackId; … … 1322 1285 BspLeaf *leaf = dynamic_cast<BspLeaf *>(node); 1323 1286 if (leaf->TreeValid() && 1324 (!onlyUnmailed || leaf->Mailed()) &&1287 (!onlyUnmailed || !leaf->Mailed()) && 1325 1288 ((maxPvsSize < 0) || (leaf->GetViewCell()->GetPvs().GetSize() <= maxPvsSize))) 1326 1289 { … … 1351 1314 1352 1315 1353 BspViewCell *VspBspTree::GetOutOfBoundsCell() const1354 {1355 return mOutOfBoundsCell;1356 }1357 1358 1359 1316 void VspBspTree::EvaluateLeafStats(const VspBspTraversalData &data) 1360 1317 { … … 1368 1325 if (data.mPvs > mStat.maxPvs) 1369 1326 mStat.maxPvs = data.mPvs; 1327 1370 1328 if (data.mDepth < mStat.minDepth) 1371 1329 mStat.minDepth = data.mDepth; 1330 1372 1331 if (data.mDepth >= mTermMaxDepth) 1373 1332 ++ mStat.maxDepthNodes; 1333 // accumulate rays to compute rays / leaf 1334 mStat.accumRays += (int)data.mRays->size(); 1374 1335 1375 1336 if (data.mPvs < mTermMinPvs) … … 1383 1344 1384 1345 if (data.mArea <= mTermMinArea) 1385 {1386 //Debug << "area: " << data.mArea / mBox.SurfaceArea() << " min area: " << mTermMinArea / mBox.SurfaceArea() << endl;1387 1346 ++ mStat.minAreaNodes; 1388 }1347 1389 1348 // accumulate depth to compute average depth 1390 1349 mStat.accumDepth += data.mDepth; … … 1498 1457 } 1499 1458 1500 bool VspBspTree::Export(const string filename)1501 {1502 Exporter *exporter = Exporter::GetExporter(filename);1503 1504 if (exporter)1505 {1506 //exporter->ExportVspBspTree(*this);1507 return true;1508 }1509 1510 return false;1511 }1512 1513 1459 void VspBspTree::CollectViewCells(ViewCellContainer &viewCells) const 1514 1460 { … … 1516 1462 1517 1463 if (!mRoot) 1518 return;1464 return; 1519 1465 1520 1466 nodeStack.push(mRoot); … … 1543 1489 { 1544 1490 BspInterior *interior = dynamic_cast<BspInterior *>(node); 1545 1491 1546 1492 nodeStack.push(interior->GetFront()); 1547 1493 nodeStack.push(interior->GetBack()); … … 2245 2191 { 2246 2192 BspLeaf::NewMail(); 2247 2193 2248 2194 vector<BspLeaf *>::const_iterator it, it_end = leaves.end(); 2249 2195 2196 Debug << "mergequeue size: " << mMergeQueue.size() << endl; 2250 2197 // find merge candidates and push them into queue 2251 2198 for (it = leaves.begin(); it != it_end; ++ it) … … 2268 2215 // TODO: test if at least one ray goes from one leaf to the other 2269 2216 for (nit = neighbors.begin(); nit != nit_end; ++ nit) 2270 { 2271 mMergeQueue.push(BspMergeCandidate(leaf, *nit)); 2272 } 2273 } 2217 { 2218 if ((*nit)->GetViewCell() != leaf->GetViewCell()) 2219 mMergeQueue.push(BspMergeCandidate(leaf, *nit)); 2220 } 2221 } 2222 2223 Debug << "new mergequeue size: " << mMergeQueue.size() << endl; 2274 2224 2275 2225 return (int)leaves.size(); … … 2283 2233 long startTime = GetTime(); 2284 2234 ConstructBspRays(bspRays, rays); 2285 Debug << (int)bspRays.size() << " bsp rays constructed in " << TimeDiff(startTime, GetTime()) * 1e-3f << " secs" << endl; 2235 Debug << (int)bspRays.size() << " bsp rays constructed in " 2236 << TimeDiff(startTime, GetTime()) * 1e-3f << " secs" << endl; 2286 2237 2287 2238 map<BspLeaf *, vector<BspLeaf*> > neighborMap; … … 2324 2275 leaf = (*iit).mLeaf; 2325 2276 2326 // view space not valid 2327 if (!leaf->TreeValid() || !prevLeaf->TreeValid()) 2277 // view space not valid or same view cell 2278 if (!leaf->TreeValid() || !prevLeaf->TreeValid() || 2279 (leaf->GetViewCell() == prevLeaf->GetViewCell())) 2328 2280 continue; 2329 2281 … … 2379 2331 vector<BspLeaf *> leaves; 2380 2332 CollectLeaves(leaves, true, mMaxPvs); 2381 Debug << "found " << (int)leaves.size() << " new leaves" << endl; 2382 //CollectMergeCandidates(leaves); 2333 Debug << "found " << (int)leaves.size() << " new leaves" << endl << endl; 2334 // TODO 2335 CollectMergeCandidates(leaves); 2383 2336 2384 2337 return numLeaves; … … 2508 2461 2509 2462 2510 ViewCell * 2511 VspBspTree::GetViewCell(const Vector3 &point) 2463 ViewCell *VspBspTree::GetViewCell(const Vector3 &point) 2512 2464 { 2513 2465 if (mRoot == NULL) … … 2737 2689 } 2738 2690 2739 #define USE_ASCII 0 2740 bool VspBspTree::WriteVspBspTree() 2741 { 2742 char fileName[100]; 2743 environment->GetStringValue("VspBspTree.viewCellsFilename", fileName); 2691 2692 bool VspBspTree::Export(ofstream &stream) 2693 { 2694 ExportNode(mRoot, stream); 2695 2696 return true; 2697 } 2698 2699 2700 void VspBspTree::ExportNode(BspNode *node, ofstream &stream) 2701 { 2702 if (node->IsLeaf()) 2703 { 2704 BspLeaf *leaf = dynamic_cast<BspLeaf *>(node); 2705 2706 int id = -1; 2707 if (leaf->GetViewCell() != mOutOfBoundsCell) 2708 id = leaf->GetViewCell()->GetId(); 2709 2710 stream << "<Leaf viewCellId=\"" << id << "\" />" << endl; 2711 } 2712 else 2713 { 2714 BspInterior *interior = dynamic_cast<BspInterior *>(node); 2744 2715 2745 /*VssRayContainer::const_iterator it, it_end = samples.end(); 2746 2747 #if USE_ASCII 2748 ofstream samplesOut(fileName); 2749 if (!samplesOut.is_open()) 2750 return false; 2751 2752 for (it = samples.begin(); it != it_end; ++ it) 2753 { 2754 VssRay *ray = *it; 2755 int sourceid = ray->mOriginObject ? ray->mOriginObject->mId : -1; 2756 int termid = ray->mTerminationObject ? ray->mTerminationObject->mId : -1; 2757 2758 samplesOut << ray->GetOrigin().x << " " << ray->GetOrigin().y << " " << ray->GetOrigin().z << " " 2759 << ray->GetTermination().x << " " << ray->GetTermination().y << " " << ray->GetTermination().z << " " 2760 << sourceid << " " << termid << "\n"; 2761 } 2762 #else 2763 ofstream samplesOut(fileName, ios::binary); 2764 if (!samplesOut.is_open()) 2765 return false; 2766 2767 for (it = samples.begin(); it != it_end; ++ it) 2768 { 2769 VssRay *ray = *it; 2770 Vector3 origin(ray->GetOrigin()); 2771 Vector3 termination(ray->GetTermination()); 2772 2773 int sourceid = ray->mOriginObject ? ray->mOriginObject->mId : -1; 2774 int termid = ray->mTerminationObject ? ray->mTerminationObject->mId : -1; 2775 2776 samplesOut.write(reinterpret_cast<char *>(&origin), sizeof(Vector3)); 2777 samplesOut.write(reinterpret_cast<char *>(&termination), sizeof(Vector3)); 2778 samplesOut.write(reinterpret_cast<char *>(&sourceid), sizeof(int)); 2779 samplesOut.write(reinterpret_cast<char *>(&termid), sizeof(int)); 2780 } 2781 #endif 2782 2783 samplesOut.close(); 2784 */ 2785 return true; 2786 } 2787 2788 bool VspBspTree::LoadVspBspTree() 2789 { 2790 /*std::stable_sort(objects.begin(), objects.end(), ilt); 2791 char fileName[100]; 2792 environment->GetStringValue("Preprocessor.samplesFilename", fileName); 2793 2794 Vector3 origin, termination; 2795 // HACK: needed only for lower_bound algorithm to find the 2796 // intersected objects 2797 MeshInstance sObj(NULL); 2798 MeshInstance tObj(NULL); 2799 2800 #if USE_ASCII 2801 ifstream samplesIn(fileName, ios::binary); 2802 if (!samplesIn.is_open()) 2803 return false; 2804 2805 string buf; 2806 while (!(getline(samplesIn, buf)).eof()) 2807 { 2808 sscanf(buf.c_str(), "%f %f %f %f %f %f %d %d", 2809 &origin.x, &origin.y, &origin.z, 2810 &termination.x, &termination.y, &termination.z, 2811 &(sObj.mId), &(tObj.mId)); 2812 2813 Intersectable *sourceObj = NULL; 2814 Intersectable *termObj = NULL; 2815 2816 if (sObj.mId >= 0) 2817 { 2818 ObjectContainer::iterator oit = 2819 lower_bound(objects.begin(), objects.end(), &sObj, ilt); 2820 sourceObj = *oit; 2821 } 2822 2823 if (tObj.mId >= 0) 2824 { 2825 ObjectContainer::iterator oit = 2826 lower_bound(objects.begin(), objects.end(), &tObj, ilt); 2827 termObj = *oit; 2828 } 2829 2830 samples.push_back(new VssRay(origin, termination, sourceObj, termObj)); 2831 } 2832 #else 2833 ifstream samplesIn(fileName, ios::binary); 2834 if (!samplesIn.is_open()) 2835 return false; 2836 2837 while (1) 2838 { 2839 samplesIn.read(reinterpret_cast<char *>(&origin), sizeof(Vector3)); 2840 samplesIn.read(reinterpret_cast<char *>(&termination), sizeof(Vector3)); 2841 samplesIn.read(reinterpret_cast<char *>(&(sObj.mId)), sizeof(int)); 2842 samplesIn.read(reinterpret_cast<char *>(&(tObj.mId)), sizeof(int)); 2843 2844 if (samplesIn.eof()) 2845 break; 2846 2847 Intersectable *sourceObj = NULL; 2848 Intersectable *termObj = NULL; 2849 2850 if (sObj.mId >= 0) 2851 { 2852 ObjectContainer::iterator oit = 2853 lower_bound(objects.begin(), objects.end(), &sObj, ilt); 2854 sourceObj = *oit; 2855 } 2856 2857 if (tObj.mId >= 0) 2858 { 2859 ObjectContainer::iterator oit = 2860 lower_bound(objects.begin(), objects.end(), &tObj, ilt); 2861 termObj = *oit; 2862 } 2863 2864 samples.push_back(new VssRay(origin, termination, sourceObj, termObj)); 2865 } 2866 2867 #endif 2868 samplesIn.close(); 2869 */ 2870 return true; 2871 } 2872 2716 Plane3 plane = interior->GetPlane(); 2717 stream << "<Interior plane=\"" << plane.mNormal.x << " " 2718 << plane.mNormal.y << " " << plane.mNormal.z << " " 2719 << plane.mD << "\">" << endl; 2720 2721 ExportNode(interior->GetBack(), stream); 2722 ExportNode(interior->GetFront(), stream); 2723 2724 stream << "</Interior>" << endl; 2725 } 2726 } 2873 2727 2874 2728 /************************************************************************/ -
trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.h
r503 r508 34 34 class VspBspTree 35 35 { 36 friend class ViewCellsParseHandlers; 37 36 38 public: 37 39 … … 180 182 BspNode *GetRoot() const; 181 183 182 /** Exports VspBsp tree to file.183 */184 bool Export(const string filename);185 186 184 /** Collects the leaf view cells of the tree 187 185 @param viewCells returns the view cells … … 279 277 bool ViewPointValid(const Vector3 &viewPoint) const; 280 278 281 /** Returns the view cell corresponding to 282 the space outside the valid view space. 283 */ 284 BspViewCell *GetOutOfBoundsCell() const; 285 286 /** Writes tree to disc. 287 */ 288 bool WriteVspBspTree(); 289 290 /** Loads tree from disc. 291 */ 292 bool LoadVspBspTree(); 279 /** Returns view cell corresponding to 280 the invalid view space. 281 */ 282 BspViewCell *GetOutOfBoundsCell(); 283 284 /** Writes tree to output stream 285 */ 286 bool Export(ofstream &stream); 293 287 294 288 protected: … … 321 315 }; 322 316 317 /** Returns view cell corresponding to 318 the invalid view space. If it does not exist, it is created. 319 */ 320 BspViewCell *GetOrCreateOutOfBoundsCell(); 321 323 322 /** Collapses the tree with respect to the view cell partition, 324 323 i.e. leaves having the same view cell are collapsed. … … 329 328 */ 330 329 BspNode *CollapseTree(BspNode *node, int &collapsed); 330 331 331 /** Shuffles the leaves, i.e., tests if exchanging 332 332 the leaves helps in improving the view cells. … … 367 367 bool SelectPlane(Plane3 &plane, 368 368 BspLeaf *leaf, 369 VspBspTraversalData &data); 369 VspBspTraversalData &data, 370 VspBspTraversalData &frontData, 371 VspBspTraversalData &backData); 370 372 371 373 /** Strategies where the effect of the split plane is tested … … 375 377 */ 376 378 float SplitPlaneCost(const Plane3 &candidatePlane, 377 const VspBspTraversalData &data) const; 378 379 const VspBspTraversalData &data, 380 BspNodeGeometry &geomFront, 381 BspNodeGeometry &geomBack, 382 float &areaFront, 383 float &areaBack) const; 379 384 380 385 /** Subdivide leaf. … … 397 402 PolygonContainer &coincident); 398 403 399 /** Selects the split plane in order to construct a tree with400 certain characteristics (e.g., balanced tree, least splits,401 2.5d aligned)402 @param bestPlane returns the split plane403 @param polygons container of polygons404 @param rays bundle of rays on which the split can be based405 406 @returns true if the overall cost is under maxCostRatio407 */408 bool SelectPlaneHeuristics(Plane3 &bestPlane,409 BspLeaf *leaf,410 VspBspTraversalData &data);411 412 404 /** Extracts the meshes of the objects and adds them to polygons. 413 405 Adds object aabb to the aabb of the tree. … … 441 433 const VspBspTraversalData &tData, 442 434 int &axis, 443 float &position, 444 int &raysBack, 445 int &raysFront, 446 int &pvsBack, 447 int &pvsFront); 435 BspNodeGeometry **frontGeom, 436 BspNodeGeometry **backGeom, 437 float &frontArea, 438 float &backArea); 448 439 449 440 /** Sorts split candidates for surface area heuristics for axis aligned splits. … … 506 497 507 498 */ 508 void AddObjToPvs(Intersectable *obj, const int cf, int &frontPvs, int &backPvs) const; 499 void AddObjToPvs(Intersectable *obj, 500 const int cf, 501 int &frontPvs, 502 int &backPvs, 503 int &totalPvs) const; 509 504 510 505 /** Computes PVS size induced by the rays. … … 591 586 void PropagateUpValidity(BspNode *node); 592 587 593 /** Creates or returns view cell corresponding to 594 the space outside the valid view space. 595 */ 596 BspViewCell *GetOrCreateOutOfBoundsCell(); 588 /** Writes the node to disk 589 @note: should be implemented as visitor 590 */ 591 void ExportNode(BspNode *node, ofstream &stream); 592 593 /** Returns memory usage of tree. 594 */ 595 float GetMemUsage() const; 597 596 598 597 /// Pointer to the root of the tree … … 621 620 /// mininum PVS 622 621 int mTermMinPvs; 623 624 /// minimal number of rays for axis aligned split625 int mTermMinRaysForAxisAligned;626 /// minimal number of objects for axis aligned split627 int mTermMinObjectsForAxisAligned;628 622 /// maximal contribution per ray 629 623 float mTermMaxRayContribution; 630 624 /// minimal accumulated ray length 631 625 float mTermMinAccRayLength; 626 627 //-- termination criteria for axis aligned split 628 629 /// minimal number of rays for axis aligned split 630 int mTermMinRaysForAxisAligned; 631 // max ray contribution 632 float mTermMaxRayContriForAxisAligned; 632 633 633 634 /// strategy to get the best split plane … … 684 685 685 686 MergeQueue mMergeQueue; 687 686 688 /// if rays should be used to collect merge candidates 687 689 bool mUseRaysForMerge; 690 688 691 /// maximal allowed pvs so that view cell is valid 689 692 int mMaxPvs; … … 695 698 bool mShowInvalidSpace; 696 699 700 int mCurrentViewCellsId; 701 702 /// maximal tree memory 703 float mMaxMemory; 704 705 bool mOutOfMemory; 697 706 private: 698 707 -
trunk/VUT/GtpVisibilityPreprocessor/src/VssPreprocessor.cpp
r501 r508 29 29 environment->GetBoolValue("VssPreprocessor.storeInitialSamples", mStoreInitialSamples); 30 30 environment->GetBoolValue("VssPreprocessor.useViewSpaceBox", mUseViewSpaceBox); 31 useViewspacePlane = mUseViewSpaceBox; //hack 31 32 32 33 mStats.open("stats.log"); … … 473 474 { 474 475 cout << "Writing " << (int)mVssRays.size() << " samples to file ... "; 475 WriteSamples(mVssRays);476 ExportSamples(mVssRays); 476 477 cout << "finished\n" << endl; 477 478 -
trunk/VUT/GtpVisibilityPreprocessor/src/X3dParser.cpp
r490 r508 134 134 } 135 135 ptr = endptr; 136 136 } 137 137 } 138 138 } … … 380 380 381 381 382 /*********************************************************** 383 * class X3dViewCellsParseHandlers implemenation * 384 382 /************************************************************************/ 383 /* class X3dViewCellsParseHandlers implementation */ 384 /************************************************************************/ 385 385 386 386 … … 534 534 } 535 535 536 // do nothing537 //if (element == "Shape") {}538 539 536 if (element == "Coordinate") { 540 537 // add coordinates to the triangles 541 538 StartCoordinate(attributes); 542 539 } 540 // do nothing 541 //if (element == "Shape") {} 543 542 // ignore material 544 543 //if (element == "Material") {} 545 544 546 mElementCount++;545 ++ mElementCount; 547 546 mAttrCount += attributes.getLength(); 548 547 }
Note: See TracChangeset
for help on using the changeset viewer.