Changeset 1287 for GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp
- Timestamp:
- 08/27/06 23:39:50 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp
r1286 r1287 159 159 if (mObjectSpaceHierarchyType == OSP) 160 160 { 161 // for a spatial subdivision, it is not necessary to store 162 // the objects with the leaves, they can be classified now 161 163 mHierarchyManager->mOspTree->InsertObjects( 162 164 mHierarchyManager->mOspTree->mRoot, *mObjects); 163 165 } 166 else 167 cout << "here209" << endl; 168 164 169 } 165 170 … … 279 284 280 285 281 void ViewCellsParseHandlers::StartHierarchy(AttributeList& attributes)282 {283 int len = attributes.getLength();284 285 for (int i = 0; i < len; ++ i)286 {287 string attrName(StrX(attributes.getName(i)).LocalForm());288 289 if (attrName == "name")290 {291 StrX attrValue(attributes.getValue(i));292 293 const char *ptr = attrValue.LocalForm();294 295 // the view cells manager is created here296 //CreateViewCellsManager(ptr);297 }298 }299 }300 301 302 286 void ViewCellsParseHandlers::StartBspElement(string element, 303 287 AttributeList& attributes) … … 437 421 // create new view cells hierarchy 438 422 mViewCellsTree = new ViewCellsTree(); 439 }440 441 // decides about the view cells manager type442 if (element == "Hierarchy")443 {444 cout << "parsing view cells manager type" << endl;445 StartHierarchy(attributes);446 423 } 447 424 … … 688 665 const char *ptr = attrValue.LocalForm(); 689 666 690 691 667 if (attrName == "id") 692 668 { … … 711 687 void ViewCellsParseHandlers::StartBspLeaf(AttributeList& attributes) 712 688 { 713 BspLeaf * leaf = 714 new BspLeaf(dynamic_cast<BspInterior *>(mCurrentBspNode), NULL); 689 BspLeaf * leaf; 715 690 716 691 if (mCurrentBspNode) // replace front or (if not NULL) back child 717 692 { 718 dynamic_cast<BspInterior *>(mCurrentBspNode)->ReplaceChildLink(NULL, leaf); 693 BspInterior *interior = dynamic_cast<BspInterior *>(mCurrentBspNode); 694 695 leaf = new BspLeaf(interior); 696 interior->ReplaceChildLink(NULL, leaf); 719 697 } 720 698 else 721 699 { 700 leaf = new BspLeaf(); 722 701 mVspBspTree->mRoot = leaf; 723 702 } … … 797 776 if (mCurrentBspNode) // replace NULL child of parent with current node 798 777 { 799 BspInterior * current = dynamic_cast<BspInterior *>(mCurrentBspNode);800 801 current->ReplaceChildLink(NULL, interior);802 interior->SetParent( current);778 BspInterior *parent = dynamic_cast<BspInterior *>(mCurrentBspNode); 779 780 parent->ReplaceChildLink(NULL, interior); 781 interior->SetParent(parent); 803 782 } 804 783 else … … 856 835 void ViewCellsParseHandlers::CreateViewSpaceHierarchy() 857 836 { 858 ViewCellContainer::iterator it, it_end = mViewCells.end();859 cout << "\n====================" << endl << endl;860 for (it = mViewCells.begin(); it != it_end; ++ it)861 {862 cout << (*it)->GetId() << " ";863 }864 cout << endl;865 837 if (mViewSpaceHierarchyType == BSP) 866 838 { … … 936 908 } 937 909 } 938 cout << "************************" << endl; 939 it_end = mViewCells.end(); 940 for (it = mViewCells.begin(); it != it_end; ++ it) 941 { 942 cout << (*it)->GetId() << " "; 943 } 944 cout << endl; 945 cout << "\nview space box: " << mViewSpaceBox << endl; 910 //cout << "\nview space box: " << mViewSpaceBox << endl; 946 911 } 947 912 … … 992 957 void ViewCellsParseHandlers::StartVspLeaf(AttributeList& attributes) 993 958 { 994 VspLeaf * leaf = 995 new VspLeaf(dynamic_cast<VspInterior *>(mCurrentVspNode), NULL); 996 959 VspLeaf * leaf; 960 997 961 if (mCurrentVspNode) // replace front or (if not NULL) back child 998 962 { 999 dynamic_cast<VspInterior *>(mCurrentVspNode)->ReplaceChildLink(NULL, leaf); 963 VspInterior *interior = dynamic_cast<VspInterior *>(mCurrentVspNode); 964 leaf = new VspLeaf(interior); 965 interior->ReplaceChildLink(NULL, leaf); 1000 966 } 1001 967 else 1002 968 { 969 leaf = new VspLeaf(); 1003 970 mVspTree->mRoot = leaf; 1004 971 } … … 1029 996 dummyVc.SetId(viewCellId); 1030 997 1031 cout << "\nsearching view cell with id " << viewCellId << endl;998 //cout << "\nsearching view cell with id " << viewCellId << endl; 1032 999 1033 1000 ViewCellContainer::iterator vit = … … 1087 1054 AxisAlignedBox3 frontBox, backBox; 1088 1055 1089 parent->GetBoundingBox().Split(parent->GetPlane().mAxis, parent->GetPlane().mPosition, frontBox, backBox); 1056 parent->GetBoundingBox().Split( 1057 parent->GetPlane().mAxis, 1058 parent->GetPlane().mPosition, 1059 frontBox, 1060 backBox); 1061 1090 1062 if (parent->GetFront() == interior) 1091 1063 interior->SetBoundingBox(frontBox); … … 1134 1106 1135 1107 parent->mBox.Split(parent->mAxis, parent->mPosition, frontBox, backBox); 1108 1136 1109 if (parent->mFront == interior) 1137 1110 interior->mBox = frontBox; … … 1180 1153 if (attrName == "min") 1181 1154 { 1182 sscanf(ptr, "%f %f %f", &minBox );1155 sscanf(ptr, "%f %f %f", &minBox.x, &minBox.y, &minBox.z); 1183 1156 } 1184 1157 if (attrName == "max") 1185 1158 { 1186 sscanf(ptr, "%f %f %f", &maxBox );1159 sscanf(ptr, "%f %f %f", &maxBox.x, &maxBox.y, &maxBox.z); 1187 1160 } 1188 1161 if (attrName == "objects") … … 1192 1165 } 1193 1166 1194 BvhLeaf * leaf = 1195 new BvhLeaf(AxisAlignedBox3(minBox, maxBox), 1196 dynamic_cast<BvhInterior *>(mCurrentBvhNode), (int)objects.size()); 1167 AxisAlignedBox3 box = AxisAlignedBox3(minBox, maxBox); 1168 1169 BvhLeaf *leaf; 1170 1171 if (mCurrentBvhNode) // replace front or (if not NULL) back child 1172 { 1173 BvhInterior *interior = dynamic_cast<BvhInterior *>(mCurrentBvhNode); 1174 leaf = new BvhLeaf(box, interior, (int)objects.size()); 1175 interior->ReplaceChildLink(NULL, leaf); 1176 } 1177 else 1178 { 1179 leaf = new BvhLeaf(box, NULL, (int)objects.size()); 1180 mHierarchyManager->mBvHierarchy->mRoot = leaf; 1181 } 1197 1182 1198 1183 leaf->mObjects = objects; 1199 1200 if (mCurrentBvhNode) // replace front or (if not NULL) back child1201 {1202 dynamic_cast<BvhInterior *>(mCurrentBvhNode)->ReplaceChildLink(NULL, leaf);1203 }1204 else1205 {1206 mHierarchyManager->mBvHierarchy->mRoot = leaf;1207 }1208 1184 } 1209 1185 … … 1219 1195 { 1220 1196 const int index = strtol(ptr, &endptr, 10); 1221 1222 1197 if (ptr == endptr) break; 1223 1198 1224 1199 objIndices.push_back(index); 1225 1226 1200 ptr = endptr; 1227 1201 } … … 1239 1213 1240 1214 ObjectContainer::iterator oit = 1241 lower_bound(mObjects->begin(), mObjects->end(), (Intersectable *)&dummyInst, ilt); 1215 lower_bound(mObjects->begin(), 1216 mObjects->end(), 1217 (Intersectable *)&dummyInst, 1218 ilt); 1242 1219 1243 1220 if ((oit != mObjects->end()) && ((*oit)->GetId() == objId)) … … 1260 1237 for (int i = 0; i < len; ++ i) 1261 1238 { 1239 cout << "here5" << endl; 1262 1240 string attrName(StrX(attributes.getName(i)).LocalForm()); 1263 1241 StrX attrValue(attributes.getValue(i)); … … 1265 1243 1266 1244 if (attrName == "min") 1267 { 1268 sscanf(ptr, "%f %f %f", &minBox );1245 {cout << "here6" << endl; 1246 sscanf(ptr, "%f %f %f", &minBox.x, &minBox.y, &minBox.z); 1269 1247 } 1270 1248 if (attrName == "max") 1271 { 1272 sscanf(ptr, "%f %f %f", &maxBox );1249 {cout << "here7" << endl; 1250 sscanf(ptr, "%f %f %f", &maxBox.x, &maxBox.y, &maxBox.z); 1273 1251 } 1274 1252 } … … 1278 1256 if (mCurrentBvhNode) // replace NULL child of parent with current node 1279 1257 { 1258 cout << "here8" << endl; 1280 1259 BvhInterior *parent = dynamic_cast<BvhInterior *>(mCurrentBvhNode); 1281 1260 parent->ReplaceChildLink(NULL, interior); … … 1283 1262 } 1284 1263 else 1285 { 1286 m BvHierarchy->mRoot = interior;1287 } 1288 1264 {cout << "here18" << endl; 1265 mHierarchyManager->mBvHierarchy->mRoot = interior; 1266 } 1267 cout << "here28" << endl; 1289 1268 mCurrentBvhNode = interior; 1290 1269 }
Note: See TracChangeset
for help on using the changeset viewer.