Changeset 2543 for GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp
- Timestamp:
- 08/21/07 19:37:28 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp
r2542 r2543 3854 3854 void VspTree::ExportBinInterior(OUT_STREAM &stream, VspInterior *interior) 3855 3855 { 3856 int interiorid= TYPE_INTERIOR;3857 stream.write(reinterpret_cast<char *>(& interiorid), sizeof(int));3856 int type = TYPE_INTERIOR; 3857 stream.write(reinterpret_cast<char *>(&type), sizeof(int)); 3858 3858 3859 3859 int axis = interior->GetAxis(); … … 3867 3867 void VspTree::ExportBinLeaf(OUT_STREAM &stream, VspLeaf *leaf) 3868 3868 { 3869 ViewCell *viewCell = mViewCellsTree->GetActiveViewCell(leaf->GetViewCell());3870 3871 3869 int type = TYPE_LEAF; 3872 3873 int id = -1;3874 if (viewCell != mOutOfBoundsCell)3875 id = viewCell->GetId();3876 3877 3870 stream.write(reinterpret_cast<char *>(&type), sizeof(int)); 3878 stream.write(reinterpret_cast<char *>(&id), sizeof(int));3879 3880 int pvsSize = viewCell->GetPvs().GetSize();3881 stream.write(reinterpret_cast<char *>(&pvsSize), sizeof(int));3882 3883 ObjectPvsIterator pit = viewCell->GetPvs().GetIterator();3884 3885 // write PVS of view cell3886 while (pit.HasMoreEntries())3887 {3888 Intersectable *intersect = pit.Next();3889 id = intersect->GetId();3890 stream.write(reinterpret_cast<char *>(&id), sizeof(int));3891 }3892 3871 } 3893 3872 … … 3943 3922 const ObjectContainer &pvsObjects) 3944 3923 { 3945 #if TODO3946 3924 int leafId = TYPE_LEAF; 3947 3925 int objId = leafId; 3948 int size; 3949 3950 stream.read(reinterpret_cast<char *>(&size), sizeof(int)); 3951 KdLeaf *leaf = new KdLeaf(parent, size); 3952 3953 MeshInstance dummyInst(NULL); 3954 3955 // read object ids 3956 // note: could also do this geometrically 3957 for (int i = 0; i < size; ++ i) 3958 { 3959 stream.read(reinterpret_cast<char *>(&objId), sizeof(int)); 3960 dummyInst.SetId(objId); 3961 3962 ObjectContainer::const_iterator oit = 3963 lower_bound(objects.begin(), objects.end(), (Intersectable *)&dummyInst, ilt); 3964 3965 if ((oit != objects.end()) && ((*oit)->GetId() == objId)) 3966 leaf->mObjects.push_back(*oit); 3967 else 3968 Debug << "error: object with id " << objId << " does not exist" << endl; 3969 } 3926 3927 VspLeaf *leaf = new VspLeaf(parent); 3928 3929 // pvs is loaded by view cell 3970 3930 return leaf; 3971 #endif3972 return NULL;3973 3931 } 3974 3932 … … 3982 3940 3983 3941 if (nodeType == TYPE_LEAF) 3942 { 3943 //cerr << "l"; 3984 3944 return ImportBinLeaf(stream, static_cast<VspInterior *>(parent), objects); 3945 } 3985 3946 3986 3947 if (nodeType == TYPE_INTERIOR) 3948 { 3949 //cerr << "i"; 3987 3950 return ImportBinInterior(stream, static_cast<VspInterior *>(parent)); 3988 3989 Debug << "error! loading failed!" << endl; 3951 } 3952 3953 cerr << "error! loading vsp node failed!" << endl; 3990 3954 return NULL; 3991 3955 } … … 4024 3988 // hack: we make a new root 4025 3989 DEL_PTR(mRoot); 4026 4027 3990 mRoot = ImportNextNode(stream, NULL, pvsObjects); 4028 3991 … … 4042 4005 mVspStats.nodes += 2; 4043 4006 4044 //Debug << "i" ;4045 4007 VspInterior *interior = static_cast<VspInterior *>(node); 4046 4008 interior->SetBoundingBox(tData.mBox); … … 4070 4032 } 4071 4033 } 4034 4072 4035 return true; 4073 4036 } 4074 4037 4075 4038 4076 } 4039 void VspTree::TestOutput(const std::string &filename) 4040 { 4041 ofstream str(filename.c_str()); 4042 4043 vector<VspLeaf *> vspLeaves; 4044 CollectLeaves(vspLeaves); 4045 4046 vector<VspLeaf *>::const_iterator vit, vit_end = vspLeaves.end(); 4047 4048 for (vit = vspLeaves.begin(); vit != vit_end; ++ vit) 4049 { 4050 VspLeaf *leaf = *vit; 4051 ViewCell *vc = leaf->GetViewCell(); 4052 4053 str << "\nleaf: " << GetBoundingBox(leaf) << endl; 4054 4055 ObjectPvsIterator pit = vc->GetPvs().GetIterator(); 4056 4057 while (pit.HasMoreEntries()) 4058 { 4059 Intersectable *obj = pit.Next(); 4060 str << obj->GetId() << " "; 4061 } 4062 } 4063 } 4064 4065 4066 }
Note: See TracChangeset
for help on using the changeset viewer.