- Timestamp:
- 07/18/06 05:07:05 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/scripts/Preprocessor.vcproj
r1137 r1138 206 206 </File> 207 207 <File 208 RelativePath="..\src\KdIntersectable.cpp"> 209 </File> 210 <File 211 RelativePath="..\src\KdIntersectable.h"> 212 </File> 213 <File 208 214 RelativePath="..\src\KdTree.cpp"> 209 215 </File> -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r1135 r1138 5465 5465 5466 5466 if (1) 5467 { //-- export pvs5468 5467 { 5468 //-- export pvs 5469 5469 ObjectPvsMap::const_iterator oit, 5470 5470 oit_end = pvs.mEntries.end(); … … 5482 5482 for (oit = pvs.mEntries.begin(); oit != oit_end; ++ oit) 5483 5483 { 5484 // export Ž"original" pvs5484 // export "original" pvs 5485 5485 Intersectable *obj = (*oit).first; 5486 5486 … … 5490 5490 obj->Mail(); 5491 5491 } 5492 // TODO matt§§ 5493 #if TODO 5494 // collect kd leaves 5495 //KdLeaf = 5496 set<KdLeaf *>::const_iterator kdit, kdit_end = obj->mKdLeaves.end(); 5497 5498 for (kdit = obj->mKdLeaves.begin(); kdit != kdit_end; ++ kdit) 5492 5493 // TODO matt§§ 5494 // export kd pvs 5495 KdLeaf *kdleaf = 0; 5496 5497 if (!kdleaf->Mailed()) 5499 5498 { 5500 KdLeaf *kdleaf = *kdit; 5501 5502 if (!kdleaf->Mailed()) 5503 { 5504 kdleaf->Mail(); 5505 kdLeaves.push_back(kdleaf); 5506 } 5499 kdleaf->Mail(); 5500 kdLeaves.push_back(kdleaf); 5507 5501 } 5508 #endif5509 5502 } 5510 5503 … … 5522 5515 5523 5516 //-- export kd node 5524 /*exporter->SetWireframe(); 5525 exporter->ExportBox(mKdTree->GetBox(kdleaf)); 5526 exporter->SetFilled();*/ 5527 5517 5528 5518 ObjectContainer::const_iterator oit, oit_end = kdleaf->mObjects.end(); 5529 5519 -
GTP/trunk/Lib/Vis/Preprocessing/src/VspOspTree.cpp
r1137 r1138 982 982 983 983 984 int VspTree::PrepareHeuristics( Intersectable *object)984 int VspTree::PrepareHeuristics(KdLeaf *leaf) 985 985 { 986 986 int pvsSize = 0; 987 // TODO matt§§ 988 #if TODO 989 set<KdLeaf *>::const_iterator kit, kit_end = object->mKdLeaves.end(); 990 991 for (kit = object->mKdLeaves.begin(); kit != kit_end; ++ kit) 992 { 993 KdLeaf *node = dynamic_cast<KdLeaf *>(*kit); 994 995 if (!node->Mailed()) 996 { 997 node->Mail(); 998 node->mCounter = 1; 999 1000 // add objects without the objects which are in several kd leaves 1001 pvsSize += (int)(node->mObjects.size() - node->mMultipleObjects.size()); 987 988 if (!leaf->Mailed()) 989 { 990 leaf->Mail(); 991 leaf->mCounter = 1; 992 993 // add objects without the objects which are in several kd leaves 994 pvsSize += (int)(leaf->mObjects.size() - leaf->mMultipleObjects.size()); 995 } 996 else 997 { 998 ++ leaf->mCounter; 999 } 1000 1001 //-- the objects belonging to several leaves must be handled seperately 1002 1003 ObjectContainer::const_iterator oit, oit_end = leaf->mMultipleObjects.end(); 1004 1005 for (oit = leaf->mMultipleObjects.begin(); oit != oit_end; ++ oit) 1006 { 1007 Intersectable *object = *oit; 1008 1009 if (!object->Mailed()) 1010 { 1011 object->Mail(); 1012 object->mCounter = 1; 1013 1014 ++ pvsSize; 1002 1015 } 1003 1016 else 1004 1017 { 1005 ++ node->mCounter; 1006 } 1007 1008 //-- the objects belonging to several leaves must be handled seperately 1009 1010 ObjectContainer::const_iterator oit, oit_end = node->mMultipleObjects.end(); 1011 1012 for (oit = node->mMultipleObjects.begin(); oit != oit_end; ++ oit) 1013 { 1014 Intersectable *object = *oit; 1015 1016 if (!object->Mailed()) 1017 { 1018 object->Mail(); 1019 object->mCounter = 1; 1020 1021 ++ pvsSize; 1022 } 1023 else 1024 { 1025 ++ object->mCounter; 1026 } 1027 } 1028 } 1029 #endif 1018 ++ object->mCounter; 1019 } 1020 } 1021 1030 1022 return pvsSize; 1031 1023 } … … 1045 1037 for (ri = rays.begin(); ri != ri_end; ++ ri) 1046 1038 { 1047 Intersectable *oObject = (*ri).mRay->mOriginObject; 1039 VssRay *ray = (*ri).mRay; 1040 Intersectable *oObject = ray->mOriginObject; 1048 1041 1049 1042 if (oObject) … … 1064 1057 else 1065 1058 { 1066 pvsSize += PrepareHeuristics(oObject); 1059 KdLeaf *leaf = mOspTree->GetLeaf(ray->mOrigin, ray->mOriginNode); 1060 pvsSize += PrepareHeuristics(leaf); 1067 1061 } 1068 1062 } … … 1087 1081 else 1088 1082 { 1089 pvsSize += PrepareHeuristics(tObject); 1083 KdLeaf *leaf = mOspTree->GetLeaf(ray->mTermination, ray->mTerminationNode); 1084 pvsSize += PrepareHeuristics(leaf); 1090 1085 } 1091 1086 } … … 1175 1170 else // per kd node 1176 1171 { 1177 // TODO matt§§ 1178 #if TODO 1179 set<KdLeaf *>::const_iterator kit, kit_end = oObject->mKdLeaves.end(); 1180 1181 for (kit = oObject->mKdLeaves.begin(); kit != kit_end; ++ kit) 1182 { 1183 KdLeaf *node = dynamic_cast<KdLeaf *>(*kit); 1184 1185 // add contributions of the kd nodes 1186 if (ci.type == SortableEntry::ERayMin) 1187 { 1188 AddContriToPvs(node, pvsLeft); 1189 } 1190 else if (ci.type == SortableEntry::ERayMax) 1191 { 1192 RemoveContriFromPvs(node, pvsRight); 1193 } 1194 } 1195 #endif 1172 KdLeaf *node = mOspTree->GetLeaf(ray->mOrigin, ray->mOriginNode); 1173 1174 // add contributions of the kd nodes 1175 if (ci.type == SortableEntry::ERayMin) 1176 { 1177 AddContriToPvs(node, pvsLeft); 1178 } 1179 else if (ci.type == SortableEntry::ERayMax) 1180 { 1181 RemoveContriFromPvs(node, pvsRight); 1182 } 1196 1183 } 1197 1184 … … 1219 1206 else // per kd node 1220 1207 { 1221 // TODO matt§§ 1222 #if TODO 1223 set<KdLeaf *>::const_iterator kit, kit_end = tObject->mKdLeaves.end(); 1224 1225 for (kit = tObject->mKdLeaves.begin(); kit != kit_end; ++ kit) 1226 { 1227 KdLeaf *node = dynamic_cast<KdLeaf *>(*kit); 1228 1229 if (ci.type == SortableEntry::ERayMin) 1230 { 1231 AddContriToPvs(node, pvsLeft); 1232 } 1233 else if (ci.type == SortableEntry::ERayMax) 1234 { 1235 RemoveContriFromPvs(node, pvsRight); 1236 } 1237 } 1238 #endif 1208 KdLeaf *node = mOspTree->GetLeaf(ray->mTermination, ray->mTerminationNode); 1209 1210 if (ci.type == SortableEntry::ERayMin) 1211 { 1212 AddContriToPvs(node, pvsLeft); 1213 } 1214 else if (ci.type == SortableEntry::ERayMax) 1215 { 1216 RemoveContriFromPvs(node, pvsRight); 1217 } 1239 1218 } 1240 1219 } … … 2562 2541 vector<SplitCandidate *> &dirtyList) 2563 2542 { 2564 VspLeaf *node = sc->mParentData.mNode; 2565 2566 ViewCellLeaf *vc = node->GetViewCell(); 2543 VspTraversalData &tData = sc->mParentData; 2544 VspLeaf *node = tData.mNode; 2545 2546 KdLeaf::NewMail(); 2547 2548 RayInfoContainer::const_iterator rit, rit_end = tData.mRays->end(); 2549 2550 // add all kd nodes seen by the rays 2551 for (rit = tData.mRays->begin(); rit != rit_end; ++ rit) 2552 { 2553 VssRay *ray = (*rit).mRay; 2554 2555 KdLeaf *leaf = mOspTree->GetLeaf(ray->mOrigin, ray->mOriginNode); 2556 2557 if (!leaf->Mailed()) 2558 { 2559 leaf->Mail(); 2560 dirtyList.push_back(leaf->mSplitCandidate); 2561 } 2567 2562 2568 ObjectPvsMap::const_iterator oit, oit_end = vc->GetPvs().mEntries.end(); 2569 2570 KdLeaf::NewMail(); 2571 2572 for (oit = vc->GetPvs().mEntries.begin(); oit != oit_end; ++ oit) 2573 { 2574 Intersectable *obj = (*oit).first; 2575 // TODO matt§§ 2576 #if TODO 2577 set<KdLeaf *>::const_iterator kit, kit_end = obj->mKdLeaves.end(); 2578 2579 for (kit = obj->mKdLeaves.begin(); kit != kit_end; ++ kit) 2580 { 2581 KdLeaf *leaf = *kit; 2582 2583 if (!leaf->Mailed()) 2584 { 2585 leaf->Mail(); 2586 dirtyList.push_back(leaf->mSplitCandidate); 2587 } 2588 } 2589 #endif 2563 leaf = mOspTree->GetLeaf(ray->mTermination, ray->mTerminationNode); 2564 2565 if (!leaf->Mailed()) 2566 { 2567 leaf->Mail(); 2568 dirtyList.push_back(leaf->mSplitCandidate); 2569 } 2590 2570 } 2591 2571 } … … 3014 2994 SortSplitCandidates(tData, axis, minBand, maxBand); 3015 2995 3016 float totalVol = PrepareHeuristics(tData .mNode->mObjects);2996 float totalVol = PrepareHeuristics(tData); 3017 2997 float voll = 0; 3018 2998 float volr = totalVol; … … 3227 3207 ViewCellContainer viewCells; 3228 3208 3229 mVspTree->GetViewCells(ray );3209 mVspTree->GetViewCells(ray, viewCells); 3230 3210 3231 3211 ViewCellContainer::const_iterator vit, vit_end = viewCells.end(); … … 3267 3247 (GetLeaf(ray->mTermination, ray->mTerminationNode) == leaf)) 3268 3248 { 3269 vol += PrepareHeuristics( ray);3249 vol += PrepareHeuristics(tData); 3270 3250 } 3271 3251 } … … 3428 3408 3429 3409 float OspTree::EvalRenderCostDecrease(const AxisAlignedPlane &candidatePlane, 3430 const OspTraversalData & data) const3410 const OspTraversalData &tData) const 3431 3411 { 3432 3412 #if 0 3433 return (float)- data.mDepth;3413 return (float)-tData.mDepth; 3434 3414 #endif 3435 3415 … … 3439 3419 3440 3420 // probability that view point lies in back / front node 3441 float pOverall = data.mBoundingBox.GetVolume();//data.mProbability;3421 float pOverall = 0;//data.mProbability; // todo matt§: value ok? 3442 3422 float pFront = 0; 3443 3423 float pBack = 0; … … 3447 3427 ViewCell::NewMail(); 3448 3428 3449 KdLeaf *leaf = data.mNode;3429 KdLeaf *leaf = tData.mNode; 3450 3430 ObjectContainer::const_iterator oit, oit_end = leaf->mObjects.end(); 3451 3431 … … 3482 3462 if (GetLeaf(ray->mOrigin, ray->mOriginNode) == leaf) 3483 3463 { 3484 if (ray->mOrigin[candidatePlane.mAxis] > candidatePlane.mPosition) 3485 { 3486 // add view cells volume to front 3487 mVspTree->GetViewCells(ray, viewCells); 3488 3489 ViewCellContainer::const_iterator vit, vit_end = viewCells.end(); 3490 3491 for (vit = viewCells.begin(); vit != vit_end; ++ vit) 3464 ViewCellContainer viewCells; 3465 mVspTree->GetViewCells(*ray, viewCells); 3466 3467 ViewCellContainer::const_iterator vit, vit_end = viewCells.end(); 3468 3469 // add view cells volume to front 3470 for (vit = viewCells.begin(); vit != vit_end; ++ vit) 3471 { 3472 ViewCell *vc = *vit; 3473 3474 if (!vc->Mailed()) 3492 3475 { 3493 ViewCell *vc = *vit; 3494 3495 if (!vit->Mailed()) 3496 { 3497 vit->Mail(); 3498 volBack += vc->GetVolume(); 3499 } 3476 vc->Mail(); 3477 3478 const float vol = vc->GetVolume(); 3479 pOverall += vol; 3480 3481 if (ray->mOrigin[candidatePlane.mAxis] > candidatePlane.mPosition) 3482 pFront += vol; 3483 else 3484 pBack += vol; 3500 3485 } 3501 3486 } 3502 else 3503 {// TODO matt§§ 3504 // add view cells volume to back 3505 if (ray->mOrigin[candidatePlane.mAxis] < candidatePlane.mPosition) 3506 { 3507 // add view cells volume to front 3508 mVspTree->GetViewCells(ray, viewCells); 3509 3510 ViewCellContainer::const_iterator vit, vit_end = viewCells.end(); 3511 3512 for (vit = viewCells.begin(); vit != vit_end; ++ vit) 3513 { 3514 ViewCell *vc = *vit; 3515 3516 if (!vit->Mailed()) 3517 { 3518 vit->Mail(); 3519 volBack += vc->GetVolume(); 3520 } 3521 } 3522 } 3523 } 3524 } 3525 } 3526 3527 3528 3529 AxisAlignedBox3 frontBox; 3530 AxisAlignedBox3 backBox; 3531 3532 data.mBoundingBox.Split(candidatePlane.mAxis, candidatePlane.mPosition, frontBox, backBox); 3533 3534 pFront = frontBox.GetVolume(); 3535 pBack = pOverall - pFront; 3536 3487 } 3488 } 3489 3537 3490 3538 3491 //-- pvs rendering heuristics 3539 const int lowerPvsLimit = mViewCellsManager->GetMinPvsSize(); 3540 const int upperPvsLimit = mViewCellsManager->GetMaxPvsSize(); 3541 3542 //-- only render cost heuristics or combined with standard deviation 3543 const float penaltyOld = totalPvs;//EvalPvsPenalty((int)totalPvs, lowerPvsLimit, upperPvsLimit); 3544 const float penaltyFront = pvsFront;//EvalPvsPenalty((int)pvsFront, lowerPvsLimit, upperPvsLimit); 3545 const float penaltyBack = pvsBack;//EvalPvsPenalty((int)pvsBack, lowerPvsLimit, upperPvsLimit); 3546 3547 Debug << "total pvs: " << totalPvs << " p " << pOverall << endl; 3548 const float oldRenderCost = pOverall * penaltyOld; 3549 const float newRenderCost = penaltyFront * pFront + penaltyBack * pBack; 3550 3551 Debug << "old: " << oldRenderCost << " new: " << newRenderCost << " decrease: " 3552 << oldRenderCost - newRenderCost << endl; 3553 const float renderCostDecrease = (oldRenderCost - newRenderCost) / mBoundingBox.GetVolume(); 3492 const float oldRenderCost = pOverall * totalPvs; 3493 const float newRenderCost = pvsFront * pFront + pvsBack * pBack; 3494 3495 Debug << "total pvs: " << totalPvs << " p " << pOverall << endl 3496 << "old: " << oldRenderCost << " new: " << newRenderCost << " decrease: " 3497 << oldRenderCost - newRenderCost << endl; 3498 3499 // todo matt§§: how to normalize volume?? 3500 const float renderCostDecrease = (oldRenderCost - newRenderCost);// / mBoundingBox.GetVolume(); 3554 3501 3555 3502 // take render cost of node into account … … 3557 3504 const float factor = mRenderCostDecreaseWeight; 3558 3505 3559 const float normalizedOldRenderCost = oldRenderCost / mBoundingBox.GetVolume();3506 const float normalizedOldRenderCost = oldRenderCost;// / mBoundingBox.GetVolume(); 3560 3507 return factor * renderCostDecrease + (1.0f - factor) * normalizedOldRenderCost; 3561 3508 } … … 3745 3692 vector<SplitCandidate *> &dirtyList) 3746 3693 { 3747 KdLeaf *node = sc->mParentData.mNode;3748 3749 ObjectContainer::const_iterator oit, oit_end = node->mObjects.end();3750 3694 OspTraversalData &tData = sc->mParentData; 3695 KdLeaf *node = tData.mNode; 3696 3697 ViewCell::NewMail(); 3751 3698 ViewCellContainer viewCells; 3752 3753 CollectViewCells(node, viewCells); 3754 3699 ViewCellContainer tmpViewCells; 3700 3701 RayInfoContainer::const_iterator rit, rit_end = tData.mRays->end(); 3702 3703 // find all view cells associated with the rays, add them to view cells 3704 for (rit = tData.mRays->begin(); rit != rit_end; ++ rit) 3705 { 3706 VssRay *ray = (*rit).mRay; 3707 mVspTree->GetViewCells(*ray, tmpViewCells); 3708 3709 ViewCellContainer::const_iterator vit, vit_end = tmpViewCells.end(); 3710 3711 for (vit = tmpViewCells.begin(); vit != vit_end; ++ vit) 3712 { 3713 VspViewCell *vc = dynamic_cast<VspViewCell *>(*vit); 3714 3715 if (!vc->Mailed()) 3716 { 3717 vc->Mail(); 3718 viewCells.push_back(vc); 3719 } 3720 } 3721 } 3722 3723 3724 // split candidates holding this view cells 3725 // are thrown into dirty list 3755 3726 ViewCellContainer::const_iterator vit, vit_end = viewCells.end(); 3756 3727 3757 // through split candidates corresponding to view cell pvs of this3758 // node into dirty list3759 3728 for (vit = viewCells.begin(); vit != vit_end; ++ vit) 3760 3729 { -
GTP/trunk/Lib/Vis/Preprocessing/src/VspOspTree.h
r1137 r1138 927 927 int PrepareHeuristics(const RayInfoContainer &rays); 928 928 929 int PrepareHeuristics( Intersectable *object);929 int PrepareHeuristics(KdLeaf *leaf); 930 930 931 931 /** Subdivides the rays into front and back rays according to the split plane.
Note: See TracChangeset
for help on using the changeset viewer.