Changeset 1686 for GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h
- Timestamp:
- 10/27/06 03:05:49 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h
r1679 r1686 377 377 void CollectViewCells(const int n); 378 378 379 /** Sets current view cells set to active, i.e., the sampling is done in this view cell set. 379 /** Sets current view cells set to active, 380 i.e., the sampling is done in this view cell set. 380 381 */ 381 382 void SetViewCellsActive(); … … 393 394 int GetMaxFilterSize() const; 394 395 395 /** Deletes interior nodes from the tree which have negative merge cost set (local merge). 396 /** Deletes interior nodes from the tree which have negative 397 merge cost set (local merge). 396 398 */ 397 399 void DeleteLocalMergeTree(ViewCell *vc) const; … … 495 497 @returns true if the sample gives a contribution to the pvs. 496 498 */ 497 virtual bool AddSampleToPvs( 498 Intersectable *obj, 499 const Vector3 &hitPoint, 500 ViewCell *vc, 501 const float pdf, 502 float &contribution) const; 499 virtual bool AddSampleToPvs(Intersectable *obj, 500 const Vector3 &hitPoint, 501 ViewCell *vc, 502 const float pdf, 503 float &contribution) const; 503 504 504 505 /** Exports single view cells for visualization. … … 512 513 @param visRays additional rays 513 514 */ 514 virtual 515 void ExportSingleViewCells( 516 const ObjectContainer &objects, 517 const int maxViewCells, 518 const bool sortViewCells, 519 const bool exportPvs, 520 const bool exportRays, 521 const int maxRays, 522 const string prefix, 523 VssRayContainer *visRays = NULL) = NULL; 515 virtual void ExportSingleViewCells(const ObjectContainer &objects, 516 const int maxViewCells, 517 const bool sortViewCells, 518 const bool exportPvs, 519 const bool exportRays, 520 const int maxRays, 521 const string prefix, 522 VssRayContainer *visRays = NULL) = NULL; 524 523 525 524 … … 589 588 /** Exports the view cell partition. 590 589 */ 591 void ExportViewCellsForViz( 592 Exporter *exporter, 593 const AxisAlignedBox3 *box, 594 const AxisAlignedPlane *clipPlane = NULL, 595 const bool colorCode = 0) const; 590 void ExportViewCellsForViz(Exporter *exporter, 591 const AxisAlignedBox3 *box, 592 const AxisAlignedPlane *clipPlane = NULL, 593 const bool colorCode = 0) const; 596 594 597 595 /** Sets exporter color. … … 701 699 702 700 // only for debugging 703 VssRayContainer storedRays; 701 VssRayContainer storedRays; 702 704 703 ////////////////// 705 704 //-- visualization options … … 787 786 ViewCell *ConstructSpatialMergeTree(BspNode *root); 788 787 789 void ExportSingleViewCells(790 const ObjectContainer &objects,791 const int maxViewCells,792 const bool sortViewCells,793 const bool exportPvs,794 const bool exportRays,795 const int maxRays,796 const string prefix,797 VssRayContainer *visRays = NULL);798 799 protected:800 801 void CollectViewCells();802 803 /// the BSP tree.804 BspTree *mBspTree;805 vector<BspRay *> mBspRays;806 807 private:808 809 /** Constructs a spatial merge tree only 2 levels deep.810 */811 ViewCell *ConstructDummyMergeTree(BspNode *root);812 813 /** Exports visualization of the BSP splits.814 */815 void ExportSplits(const ObjectContainer &objects);816 817 /** test if subdivision is valid in terms of volume / area.818 */819 void TestSubdivision();820 };821 822 823 /**824 Manages different higher order operations on the KD type view cells.825 */826 class KdViewCellsManager: public ViewCellsManager827 {828 829 public:830 831 KdViewCellsManager(ViewCellsTree *viewCellsTree, KdTree *tree);832 833 int ConstructSubdivision(const ObjectContainer &objects,834 const VssRayContainer &rays);835 836 int CastLineSegment(const Vector3 &origin,837 const Vector3 &termination,838 ViewCellContainer &viewcells);839 840 int PostProcess(const ObjectContainer &objects,841 const VssRayContainer &rays);842 843 void Visualize(const ObjectContainer &objects,844 const VssRayContainer &sampleRays);845 846 int GetType() const;847 848 bool ViewCellsConstructed() const;849 850 ViewCell *GenerateViewCell(Mesh *mesh) const;851 852 /** Prints out statistics of this approach.853 */854 // virtual void PrintStatistics(ostream &s) const;855 ViewCell *GetViewCell(const Vector3 &point, const bool active = false) const856 { return NULL; }857 858 float GetProbability(ViewCell *viewCell);859 860 void CreateMesh(ViewCell *vc);861 862 void ExportViewCellGeometry(863 Exporter *exporter,864 ViewCell *vc,865 const AxisAlignedBox3 *box,866 const AxisAlignedPlane *clipPlane = NULL867 ) const;868 869 870 void CollectMergeCandidates(const VssRayContainer &rays,871 vector<MergeCandidate> &candidates);872 873 void ExportSingleViewCells(874 const ObjectContainer &objects,875 const int maxViewCells,876 const bool sortViewCells,877 const bool exportPvs,878 const bool exportRays,879 const int maxRays,880 const string prefix,881 VssRayContainer *visRays = NULL);882 883 protected:884 885 /** Collects view cells from a hierarchy.886 */887 void CollectViewCells();888 889 KdNode *GetNodeForPvs(KdLeaf *leaf);890 891 ////////////////////////////////////////892 893 /// the BSP tree.894 KdTree *mKdTree;895 896 /// depth of the KD tree nodes with represent the view cells897 int mKdPvsDepth;898 899 900 };901 902 903 /** Manages different higher order operations on the view cells.904 */905 class VspBspViewCellsManager: public ViewCellsManager906 {907 908 public:909 910 VspBspViewCellsManager(ViewCellsTree *viewCellsTree, VspBspTree *tree);911 ~VspBspViewCellsManager();912 913 int ConstructSubdivision(const ObjectContainer &objects,914 const VssRayContainer &rays);915 916 int PostProcess(const ObjectContainer &objects,917 const VssRayContainer &rays);918 919 void Visualize(const ObjectContainer &objects,920 const VssRayContainer &sampleRays);921 922 int GetType() const;923 924 ViewCell *GenerateViewCell(Mesh *mesh = NULL) const;925 926 bool ViewCellsConstructed() const;927 928 929 int CastLineSegment(const Vector3 &origin,930 const Vector3 &termination,931 ViewCellContainer &viewcells);932 933 float GetProbability(ViewCell *viewCell);934 935 ViewCell *GetViewCell(const Vector3 &point, const bool active = false) const;936 937 bool GetViewPoint(Vector3 &viewPoint) const;938 939 bool ViewPointValid(const Vector3 &viewPoint) const;940 941 void CreateMesh(ViewCell *vc);942 943 bool ExportViewCells(944 const string filename,945 const bool exportPvs,946 const ObjectContainer &objects);947 948 int CastBeam(Beam &beam);949 950 void ExportViewCellGeometry(951 Exporter *exporter,952 ViewCell *vc,953 const AxisAlignedBox3 *box,954 const AxisAlignedPlane *clipPlane = NULL955 ) const;956 957 958 void Finalize(ViewCell *viewCell, const bool createMesh);959 960 void CollectMergeCandidates(const VssRayContainer &rays, vector<MergeCandidate> &candidates);961 962 void ExportSingleViewCells(963 const ObjectContainer &objects,964 const int maxViewCells,965 const bool sortViewCells,966 const bool exportPvs,967 const bool exportRays,968 const int maxRays,969 const string prefix,970 VssRayContainer *visRays = NULL);971 972 973 protected:974 975 int ComputeBoxIntersections(const AxisAlignedBox3 &box, ViewCellContainer &viewCells) const;976 977 /** Merges view cells according to some criteria978 */979 void MergeViewCells(const VssRayContainer &rays,980 const ObjectContainer &objects);981 982 void RefineViewCells(const VssRayContainer &rays, const ObjectContainer &objects);983 984 void CollectViewCells();985 986 /** Returns maximal depth difference of view cell987 leaves in tree.988 */989 int GetMaxTreeDiff(ViewCell *vc) const;990 991 /** Prepare view cells for use after loading them from disc.992 */993 void PrepareLoadedViewCells();994 995 /** Constructs merge hierarchy which corresponds to the spatial hierarchy.996 */997 ViewCell *ConstructSpatialMergeTree(BspNode *root);998 999 /// HACK for testing visibility filter functionality1000 void TestFilter(const ObjectContainer &objects);1001 1002 /** Visualization of the pvs difference to exact visubility using1003 from point queries.1004 */1005 void VisualizeWithFromPointQueries();1006 1007 /** Evaluate from point queries for the current scene.1008 */1009 void EvalFromPointQueries();1010 1011 /** Exports visualization of the BSP splits.1012 */1013 void ExportSplits(const ObjectContainer &objects,1014 const VssRayContainer &rays);1015 1016 /// the view space partition BSP tree.1017 VspBspTree *mVspBspTree;1018 1019 1020 private:1021 1022 /** test if subdivision is valid in terms of volume / area.1023 */1024 void TestSubdivision();1025 };1026 1027 #define TEST_EVALUATION 01028 1029 /**1030 Manages different higher order operations on the view cells.1031 */1032 class VspOspViewCellsManager: public ViewCellsManager1033 {1034 1035 public:1036 1037 VspOspViewCellsManager(ViewCellsTree *vcTree, HierarchyManager *hm);1038 1039 ~VspOspViewCellsManager();1040 1041 int ConstructSubdivision(const ObjectContainer &objects,1042 const VssRayContainer &rays);1043 1044 int PostProcess(const ObjectContainer &objects,1045 const VssRayContainer &rays);1046 1047 void Visualize(const ObjectContainer &objects,1048 const VssRayContainer &sampleRays);1049 1050 int GetType() const;1051 1052 ViewCell *GenerateViewCell(Mesh *mesh = NULL) const;1053 1054 bool ViewCellsConstructed() const;1055 1056 1057 int CastLineSegment(const Vector3 &origin,1058 const Vector3 &termination,1059 ViewCellContainer &viewcells);1060 1061 float GetProbability(ViewCell *viewCell);1062 1063 ViewCell *GetViewCell(const Vector3 &point, const bool active = false) const;1064 1065 bool GetViewPoint(Vector3 &viewPoint) const;1066 1067 bool ViewPointValid(const Vector3 &viewPoint) const;1068 1069 void CreateMesh(ViewCell *vc);1070 1071 bool ExportViewCells(const string filename,1072 const bool exportPvs,1073 const ObjectContainer &objects);1074 1075 int CastBeam(Beam &beam);1076 1077 void Finalize(ViewCell *viewCell, const bool createMesh);1078 1079 /** Stores sample contribution for kd cells or objects.1080 */1081 virtual float ComputeSampleContribution(VssRay &ray,1082 const bool addRays,1083 const bool storeViewCells);1084 1085 ViewCellsManager *LoadViewCells(const string &filename,1086 ObjectContainer *objects,1087 const bool finalizeViewCells,1088 BoundingBoxConverter *bconverter);1089 1090 bool AddSampleToPvs(Intersectable *obj,1091 const Vector3 &hitPoint,1092 ViewCell *vc,1093 const float pdf,1094 float &contribution) const;1095 1096 788 void ExportSingleViewCells(const ObjectContainer &objects, 1097 789 const int maxViewCells, … … 1105 797 protected: 1106 798 1107 #if TEST_EVALUATION 1108 virtual void EvalViewCellPartition(); 1109 #endif 1110 1111 /** Exports view cell geometry. 1112 */ 799 void CollectViewCells(); 800 801 /// the BSP tree. 802 BspTree *mBspTree; 803 vector<BspRay *> mBspRays; 804 805 private: 806 807 /** Constructs a spatial merge tree only 2 levels deep. 808 */ 809 ViewCell *ConstructDummyMergeTree(BspNode *root); 810 811 /** Exports visualization of the BSP splits. 812 */ 813 void ExportSplits(const ObjectContainer &objects); 814 815 /** test if subdivision is valid in terms of volume / area. 816 */ 817 void TestSubdivision(); 818 }; 819 820 821 /** 822 Manages different higher order operations on the KD type view cells. 823 */ 824 class KdViewCellsManager: public ViewCellsManager 825 { 826 827 public: 828 829 KdViewCellsManager(ViewCellsTree *viewCellsTree, KdTree *tree); 830 831 int ConstructSubdivision(const ObjectContainer &objects, 832 const VssRayContainer &rays); 833 834 int CastLineSegment(const Vector3 &origin, 835 const Vector3 &termination, 836 ViewCellContainer &viewcells); 837 838 int PostProcess(const ObjectContainer &objects, 839 const VssRayContainer &rays); 840 841 void Visualize(const ObjectContainer &objects, 842 const VssRayContainer &sampleRays); 843 844 int GetType() const; 845 846 bool ViewCellsConstructed() const; 847 848 ViewCell *GenerateViewCell(Mesh *mesh) const; 849 850 /** Prints out statistics of this approach. 851 */ 852 // virtual void PrintStatistics(ostream &s) const; 853 ViewCell *GetViewCell(const Vector3 &point, const bool active = false) const 854 { return NULL; } 855 856 float GetProbability(ViewCell *viewCell); 857 858 void CreateMesh(ViewCell *vc); 859 1113 860 void ExportViewCellGeometry(Exporter *exporter, 1114 861 ViewCell *vc, … … 1116 863 const AxisAlignedPlane *clipPlane = NULL) const; 1117 864 865 866 void CollectMergeCandidates(const VssRayContainer &rays, 867 vector<MergeCandidate> &candidates); 868 869 void ExportSingleViewCells(const ObjectContainer &objects, 870 const int maxViewCells, 871 const bool sortViewCells, 872 const bool exportPvs, 873 const bool exportRays, 874 const int maxRays, 875 const string prefix, 876 VssRayContainer *visRays = NULL); 877 878 protected: 879 880 /** Collects view cells from a hierarchy. 881 */ 882 void CollectViewCells(); 883 884 KdNode *GetNodeForPvs(KdLeaf *leaf); 885 886 //////////////////////////////////////// 887 888 /// the BSP tree. 889 KdTree *mKdTree; 890 891 /// depth of the KD tree nodes with represent the view cells 892 int mKdPvsDepth; 893 894 895 }; 896 897 898 /** Manages different higher order operations on the view cells. 899 */ 900 class VspBspViewCellsManager: public ViewCellsManager 901 { 902 903 public: 904 905 VspBspViewCellsManager(ViewCellsTree *viewCellsTree, VspBspTree *tree); 906 ~VspBspViewCellsManager(); 907 908 int ConstructSubdivision(const ObjectContainer &objects, 909 const VssRayContainer &rays); 910 911 int PostProcess(const ObjectContainer &objects, 912 const VssRayContainer &rays); 913 914 void Visualize(const ObjectContainer &objects, 915 const VssRayContainer &sampleRays); 916 917 int GetType() const; 918 919 ViewCell *GenerateViewCell(Mesh *mesh = NULL) const; 920 921 bool ViewCellsConstructed() const; 922 923 924 int CastLineSegment(const Vector3 &origin, 925 const Vector3 &termination, 926 ViewCellContainer &viewcells); 927 928 float GetProbability(ViewCell *viewCell); 929 930 ViewCell *GetViewCell(const Vector3 &point, const bool active = false) const; 931 932 bool GetViewPoint(Vector3 &viewPoint) const; 933 934 bool ViewPointValid(const Vector3 &viewPoint) const; 935 936 void CreateMesh(ViewCell *vc); 937 938 bool ExportViewCells(const string filename, 939 const bool exportPvs, 940 const ObjectContainer &objects); 941 942 int CastBeam(Beam &beam); 943 944 void ExportViewCellGeometry(Exporter *exporter, 945 ViewCell *vc, 946 const AxisAlignedBox3 *box, 947 const AxisAlignedPlane *clipPlane = NULL) const; 948 949 950 void Finalize(ViewCell *viewCell, const bool createMesh); 951 952 void CollectMergeCandidates(const VssRayContainer &rays, 953 vector<MergeCandidate> &candidates); 954 955 void ExportSingleViewCells(const ObjectContainer &objects, 956 const int maxViewCells, 957 const bool sortViewCells, 958 const bool exportPvs, 959 const bool exportRays, 960 const int maxRays, 961 const string prefix, 962 VssRayContainer *visRays = NULL); 963 964 965 protected: 966 1118 967 int ComputeBoxIntersections(const AxisAlignedBox3 &box, 1119 968 ViewCellContainer &viewCells) const; 1120 969 970 /** Merges view cells according to some criteria 971 */ 972 void MergeViewCells(const VssRayContainer &rays, 973 const ObjectContainer &objects); 974 975 void RefineViewCells(const VssRayContainer &rays, const ObjectContainer &objects); 976 977 void CollectViewCells(); 978 979 /** Returns maximal depth difference of view cell 980 leaves in tree. 981 */ 982 int GetMaxTreeDiff(ViewCell *vc) const; 983 984 /** Prepare view cells for use after loading them from disc. 985 */ 986 void PrepareLoadedViewCells(); 987 988 /** Constructs merge hierarchy which corresponds to the spatial hierarchy. 989 */ 990 ViewCell *ConstructSpatialMergeTree(BspNode *root); 991 992 /// HACK for testing visibility filter functionality 993 void TestFilter(const ObjectContainer &objects); 994 995 /** Visualization of the pvs difference to exact visubility using 996 from point queries. 997 */ 998 void VisualizeWithFromPointQueries(); 999 1000 /** Evaluate from point queries for the current scene. 1001 */ 1002 void EvalFromPointQueries(); 1003 1004 /** Exports visualization of the BSP splits. 1005 */ 1006 void ExportSplits(const ObjectContainer &objects, 1007 const VssRayContainer &rays); 1008 1009 1010 ///////////////////////// 1011 1012 /// the view space partition BSP tree. 1013 VspBspTree *mVspBspTree; 1014 1015 1016 private: 1017 1018 /** test if subdivision is valid in terms of volume / area. 1019 */ 1020 void TestSubdivision(); 1021 }; 1022 1023 #define TEST_EVALUATION 0 1024 1025 /** 1026 Manages different higher order operations on the view cells. 1027 */ 1028 class VspOspViewCellsManager: public ViewCellsManager 1029 { 1030 1031 public: 1032 1033 VspOspViewCellsManager(ViewCellsTree *vcTree, HierarchyManager *hm); 1034 1035 ~VspOspViewCellsManager(); 1036 1037 int ConstructSubdivision(const ObjectContainer &objects, 1038 const VssRayContainer &rays); 1039 1040 int PostProcess(const ObjectContainer &objects, 1041 const VssRayContainer &rays); 1042 1043 void Visualize(const ObjectContainer &objects, 1044 const VssRayContainer &sampleRays); 1045 1046 int GetType() const; 1047 1048 ViewCell *GenerateViewCell(Mesh *mesh = NULL) const; 1049 1050 bool ViewCellsConstructed() const; 1051 1052 1053 int CastLineSegment(const Vector3 &origin, 1054 const Vector3 &termination, 1055 ViewCellContainer &viewcells); 1056 1057 float GetProbability(ViewCell *viewCell); 1058 1059 ViewCell *GetViewCell(const Vector3 &point, const bool active = false) const; 1060 1061 bool GetViewPoint(Vector3 &viewPoint) const; 1062 1063 bool ViewPointValid(const Vector3 &viewPoint) const; 1064 1065 void CreateMesh(ViewCell *vc); 1066 1067 bool ExportViewCells(const string filename, 1068 const bool exportPvs, 1069 const ObjectContainer &objects); 1070 1071 int CastBeam(Beam &beam); 1072 1073 void Finalize(ViewCell *viewCell, const bool createMesh); 1074 1075 /** Stores sample contribution for kd cells or objects. 1076 */ 1077 virtual float ComputeSampleContribution(VssRay &ray, 1078 const bool addRays, 1079 const bool storeViewCells); 1080 1081 ViewCellsManager *LoadViewCells(const string &filename, 1082 ObjectContainer *objects, 1083 const bool finalizeViewCells, 1084 BoundingBoxConverter *bconverter); 1085 1086 bool AddSampleToPvs(Intersectable *obj, 1087 const Vector3 &hitPoint, 1088 ViewCell *vc, 1089 const float pdf, 1090 float &contribution) const; 1091 1092 void ExportSingleViewCells(const ObjectContainer &objects, 1093 const int maxViewCells, 1094 const bool sortViewCells, 1095 const bool exportPvs, 1096 const bool exportRays, 1097 const int maxRays, 1098 const string prefix, 1099 VssRayContainer *visRays = NULL); 1100 1101 protected: 1102 1103 //#if TEST_EVALUATION 1104 virtual void EvalViewCellPartition(); 1105 //#endif 1106 1107 /** Exports view cell geometry. 1108 */ 1109 void ExportViewCellGeometry(Exporter *exporter, 1110 ViewCell *vc, 1111 const AxisAlignedBox3 *box, 1112 const AxisAlignedPlane *clipPlane = NULL) const; 1113 1114 int ComputeBoxIntersections(const AxisAlignedBox3 &box, 1115 ViewCellContainer &viewCells) const; 1116 1121 1117 void CollectViewCells(); 1122 1118
Note: See TracChangeset
for help on using the changeset viewer.