Changeset 639 for GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
- Timestamp:
- 02/14/06 17:13:42 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r612 r639 16 16 #include "RssPreprocessor.h" 17 17 18 #define SAMPLE_AFTER_SUBDIVISION 018 #define SAMPLE_AFTER_SUBDIVISION 1 19 19 20 20 … … 115 115 116 116 /// helper function which destroys rays or copies them into the output ray container 117 inline void addOutRays(VssRayContainer &rays, VssRayContainer *outRays)117 inline void disposeRays(VssRayContainer &rays, VssRayContainer *outRays) 118 118 { 119 119 cout << "disposing samples ... "; … … 132 132 else 133 133 { 134 CLEAR_CONTAINER(rays); 135 } 134 VssRayContainer::const_iterator it, it_end = rays.end(); 135 136 for (it = rays.begin(); it != it_end; ++ it) 137 { 138 //(*it)->Unref(); 139 if (!(*it)->IsActive()) 140 delete (*it); 141 } 142 } 143 136 144 cout << "finished" << endl; 137 145 Debug << "disposed " << n << " samples in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; … … 162 170 163 171 // rays can be passed or deleted 164 addOutRays(initialSamples, outRays);172 disposeRays(initialSamples, outRays); 165 173 166 174 … … 196 204 197 205 198 addOutRays(constructionSamples, outRays);206 disposeRays(constructionSamples, outRays); 199 207 200 208 cout << "total samples: " << numSamples << endl; … … 236 244 Visualize(preprocessor->mObjects, visualizationSamples); 237 245 238 addOutRays(visualizationSamples, outRays);246 disposeRays(visualizationSamples, outRays); 239 247 240 248 return numSamples; … … 3056 3064 const VssRayContainer &rays) 3057 3065 { 3058 const int leafOut = 10;3066 const int leafOut = 20; 3059 3067 3060 3068 ViewCell::NewMail(); 3061 3069 3062 cout << "visualization using " << mVisualizationSamples << " samples" << endl; 3070 cout << "visualization using " << (int)rays.size() << " samples" << endl; 3071 Debug << "visualization using " << (int)rays.size() << " samples" << endl; 3063 3072 Debug << "\nOutput view cells: " << endl; 3064 3073 … … 3066 3075 if (0) 3067 3076 stable_sort(mViewCells.begin(), mViewCells.end(), vc_gt); 3068 3077 3069 3078 int limit = min(leafOut, (int)mViewCells.size()); 3070 3079 3071 int raysOut ;3080 int raysOut = 0; 3072 3081 3073 3082 //-- some rays for output 3074 if (1)3075 raysOut = min((int)rays.size(), mVisualizationSamples);3076 3077 3083 for (int i = 0; i < limit; ++ i) 3078 3084 { 3079 3085 cout << "creating output for view cell " << i << " ... "; 3080 3086 3081 VssRayContainer vcRays; 3082 Intersectable::NewMail(); 3087 3083 3088 ViewCell *vc; 3084 3089 … … 3086 3091 vc = mViewCells[i]; 3087 3092 else 3088 vc = mViewCells[Random((int)mViewCells.size())]; 3089 3090 vector<ViewCell *> leaves; 3091 mViewCellsTree->CollectLeaves(vc, leaves); 3092 3093 if (1) 3094 { 3095 // check whether we can add the current ray to the output rays 3096 for (int k = 0; k < raysOut; ++ k) 3097 { 3098 VssRay *ray = rays[k]; 3099 for (int j = 0; j < (int)ray->mViewCells.size(); ++ j) 3100 { 3101 ViewCell *rayvc = ray->mViewCells[j]; 3102 3103 if (leaves[0] == rayvc) 3104 vcRays.push_back(ray); 3105 } 3106 } 3107 } 3093 vc = mViewCells[(int)RandomValue(0, (float)mViewCells.size() - 1)]; 3108 3094 3109 3095 //bspLeaves[j]->Mail(); 3110 3096 char s[64]; sprintf(s, "bsp-pvs%04d.x3d", i); 3111 3097 Exporter *exporter = Exporter::GetExporter(s); 3098 3099 Debug << i << ": pvs size=" << (int)mViewCellsTree->GetPvsSize(vc) << endl; 3100 3101 if (1 || mExportRays) 3102 { 3103 if (1) 3104 { 3105 VssRayContainer vcRays; 3106 VssRayContainer collectRays; 3107 3108 raysOut = min((int)rays.size(), 100); 3109 3110 // collect intial view cells 3111 ViewCellContainer leaves; 3112 mViewCellsTree->CollectLeaves(vc, leaves); 3113 3114 ViewCellContainer::const_iterator vit, vit_end = leaves.end(); 3115 3116 for (vit = leaves.begin(); vit != vit_end; ++ vit) 3117 { 3118 BspLeaf *vcLeaf = dynamic_cast<BspViewCell *>(*vit)->mLeaf; 3119 3120 VssRayContainer::const_iterator rit, rit_end = vcLeaf->mVssRays.end(); 3121 3122 for (rit = vcLeaf->mVssRays.begin(); rit != rit_end; ++ rit) 3123 { 3124 collectRays.push_back(*rit); 3125 } 3126 } 3127 3128 VssRayContainer::const_iterator rit, rit_end = collectRays.end(); 3129 3130 for (rit = collectRays.begin(); rit != rit_end; ++ rit) 3131 { 3132 float p = RandomValue(0.0f, (float)collectRays.size()); 3133 3134 if (p < raysOut) 3135 vcRays.push_back(*rit); 3136 } 3137 //-- export rays piercing this view cell 3138 exporter->ExportRays(vcRays, RgbColor(1, 1, 1)); 3139 } 3140 3141 3142 3143 if (0) 3144 { 3145 VssRayContainer vcRays; 3146 raysOut = min((int)rays.size(), mVisualizationSamples); 3147 // check whether we can add the current ray to the output rays 3148 for (int k = 0; k < raysOut; ++ k) 3149 { 3150 VssRay *ray = rays[k]; 3151 for (int j = 0; j < (int)ray->mViewCells.size(); ++ j) 3152 { 3153 ViewCell *rayvc = ray->mViewCells[j]; 3154 3155 if (rayvc == vc) 3156 vcRays.push_back(ray); 3157 } 3158 } 3159 3160 //-- export rays piercing this view cell 3161 exporter->ExportRays(vcRays, RgbColor(1, 1, 0)); 3162 } 3163 3164 } 3165 3166 3167 3168 3112 3169 exporter->SetWireframe(); 3113 3170 … … 3117 3174 3118 3175 ExportViewCellGeometry(exporter, vc); 3119 3120 3121 Debug << i << ": pvs size=" << (int)mViewCellsTree->GetPvsSize(vc)3122 << ", piercing rays=" << (int)vcRays.size() << endl;3123 // << ", leaves=" << (int)vc->mLeaves.size() << endl; 3124 3125 3126 //-- export rays piercing this view cell 3176 3177 3178 m.mDiffuseColor = RgbColor(1, 0, 0); 3179 exporter->SetForcedMaterial(m); 3180 3181 exporter->SetFilled(); 3182 3183 3127 3184 if (1) 3128 3185 { 3129 exporter->ExportRays(vcRays, RgbColor(1, 1, 1)); 3186 ObjectPvsMap::const_iterator oit, 3187 oit_end = vc->GetPvs().mEntries.end(); 3188 3189 3190 exporter->SetFilled(); 3191 3192 Intersectable::NewMail(); 3193 3194 // output PVS of view cell 3195 for (oit = vc->GetPvs().mEntries.begin(); oit != oit_end; ++ oit) 3196 { 3197 Intersectable *intersect = (*oit).first; 3198 3199 if (!intersect->Mailed()) 3200 { 3201 //m = RandomMaterial(); 3202 //exporter->SetForcedMaterial(m); 3203 3204 exporter->ExportIntersectable(intersect); 3205 intersect->Mail(); 3206 } 3207 } 3130 3208 } 3131 3209 else 3132 3210 { 3133 3134 ViewCellContainer leaves; 3135 mViewCellsTree->CollectLeaves(vc, leaves); 3136 3137 ViewCellContainer::const_iterator lit, lit_end = leaves.end(); 3138 3139 for (lit = leaves.begin(); lit != lit_end; ++ lit) 3140 { 3141 BspLeaf *l = dynamic_cast<BspViewCell *>(*lit)->mLeaf; 3142 exporter->ExportRays(l->mVssRays); 3143 } 3144 } 3145 3146 3147 m.mDiffuseColor = RgbColor(1, 0, 0); 3148 exporter->SetForcedMaterial(m); 3149 3150 ObjectPvsMap::const_iterator it, 3151 it_end = vc->GetPvs().mEntries.end(); 3152 3153 exporter->SetFilled(); 3154 3155 3156 // output PVS of view cell 3157 for (it = vc->GetPvs().mEntries.begin(); it != it_end; ++ it) 3158 { 3159 3160 Intersectable *intersect = (*it).first; 3161 3162 if (!intersect->Mailed()) 3163 { 3164 Material m = RandomMaterial(); 3165 exporter->SetForcedMaterial(m); 3166 3167 exporter->ExportIntersectable(intersect); 3168 intersect->Mail(); 3169 } 3170 } 3171 3172 3211 exporter->ExportGeometry(objects); 3212 } 3213 3173 3214 DEL_PTR(exporter); 3174 3215 cout << "finished" << endl;
Note: See TracChangeset
for help on using the changeset viewer.