00001 //----------------------------------------------------------------------------- 00002 // 00003 // Module: AffinePseudoSphereArrangement.h 00004 // 00005 // Author: Feng Xie -- xief@mcmaster.ca 00006 // 00007 // Discription: Affine pseudo-sphere arrangement. 00008 // 00009 // Note: 1) Only the bounded faces that are above the infinity equator 00010 // are stored. 00011 // 00012 // Todo: *) Which is more efficient in finding the vertices of a cell? 00013 // a) Iterate the vertices and keep the ones that are 00014 // conformal to the cell. 00015 // b) Try all signed sets by setting (r-2) elements of the 00016 // cell to 0, keep the ones that are vertices. 00017 // *) Dump option for dimensions other than 3. It is much harder 00018 // in dimensions beyond 3, because a polytope can not be 00019 // uniquely represented by its skeleton any more. 00020 // 00021 // Change log: 00022 // 09-06-25 Created. 00023 // 00024 //----------------------------------------------------------------------------- 00025 00026 #ifndef OMC_AFFINE_PSEUDO_SPHERE_ARRANGEMENT_H 00027 #define OMC_AFFINE_PSEUDO_SPHERE_ARRANGEMENT_H 00028 00029 #include "PseudoSphereArrangement.h" 00030 #include "AffineObject.h" 00031 #include "AffineCircuits.h" 00032 #include "OMCGraph.h" 00033 #include "Combination.h" 00034 #include <iostream> 00035 #include <set> 00036 #include <map> 00037 00038 namespace omc 00039 { 00040 class AffinePseudoSphereArrangement 00041 : public PseudoSphereArrangement, public AffineObject 00042 { 00043 public: 00044 AffinePseudoSphereArrangement (Circuits &, index_t); // constructors 00045 AffinePseudoSphereArrangement (AffineCircuits &); 00046 00047 ~AffinePseudoSphereArrangement () {}; // destructor 00048 00049 size_t getNumBoundedCells () const; // get the # of bounded cells 00050 size_t getNumBoundedFacets () const; // get the # of bounded facets 00051 size_t getNumExternalFacets () const; // get the # of external facets 00052 size_t getNumBoundedEdges () const; // get the # of bounded edges 00053 size_t getNumBoundedVertices () const; // get the # of bounded vertices 00054 00055 void setInfinityElement (index_t); // set the infinity element 00056 00057 double averageDiameter (bool dump=false); // compute the average diameter 00058 00059 // Iterators. 00060 typedef std::set<SignedSet>::iterator bounded_cell_iterator; 00061 bounded_cell_iterator bounded_cell_begin (); 00062 bounded_cell_iterator bounded_cell_end (); 00063 00064 typedef std::set<SignedSet>::reverse_iterator 00065 reverse_bounded_cell_iterator; 00066 reverse_bounded_cell_iterator bounded_cell_rbegin (); 00067 reverse_bounded_cell_iterator bounded_cell_rend (); 00068 00069 typedef std::set<SignedSet>::iterator bounded_facet_iterator; 00070 bounded_facet_iterator bounded_facet_begin (); 00071 bounded_facet_iterator bounded_facet_end (); 00072 00073 typedef std::set<SignedSet>::reverse_iterator 00074 reverse_bounded_facet_iterator; 00075 reverse_bounded_facet_iterator bounded_facet_rbegin (); 00076 reverse_bounded_facet_iterator bounded_facet_rend (); 00077 00078 typedef std::set<SignedSet>::iterator external_facet_iterator; 00079 external_facet_iterator external_facet_begin (); 00080 external_facet_iterator external_facet_end (); 00081 00082 typedef std::set<SignedSet>::reverse_iterator 00083 reverse_external_facet_iterator; 00084 reverse_external_facet_iterator external_facet_rbegin (); 00085 reverse_external_facet_iterator external_facet_rend (); 00086 00087 typedef std::set<SignedSet>::iterator bounded_edge_iterator; 00088 bounded_edge_iterator bounded_edge_begin (); 00089 bounded_edge_iterator bounded_edge_end (); 00090 00091 typedef std::set<SignedSet>::reverse_iterator 00092 reverse_bounded_edge_iterator; 00093 reverse_bounded_edge_iterator bounded_edge_rbegin (); 00094 reverse_bounded_edge_iterator bounded_edge_rend (); 00095 00096 typedef std::set<SignedSet>::iterator bounded_vertex_iterator; 00097 bounded_vertex_iterator bounded_vertex_begin (); 00098 bounded_vertex_iterator bounded_vertex_end (); 00099 00100 typedef std::set<SignedSet>::reverse_iterator 00101 reverse_bounded_vertex_iterator; 00102 reverse_bounded_vertex_iterator bounded_vertex_rbegin (); 00103 reverse_bounded_vertex_iterator bounded_vertex_rend (); 00104 00105 protected: 00106 std::set <SignedSet> m_BoundedCell; // set of covectors of bounded cells 00107 std::set <SignedSet> m_BoundedFacet; // set of covectors of bounded facets 00108 std::set <SignedSet> m_ExternalFacet; // set of covectors of external facets 00109 std::set <SignedSet> m_BoundedEdge; // set of covectors of bounded edges 00110 std::set <SignedSet> m_BoundedVertex; // set of covectors of bounded vertices 00111 00112 void updateBoundedFaces (); // update bounded faces 00113 00114 std::map <std::string, int> m_CellCounter; // rough counter 00115 std::map <std::string, std::map<std::string,int> > m_ExtraCellCounter; 00116 // finer counter 00117 00118 void recordCellType (const OMCGraph &); // record cell info for dump 00119 void dumpCellTypes (); // dump cell info 00120 00121 private: 00122 std::set <SignedSet> m_InfinityVertex; // vectors of vertices at infinity 00123 00124 }; // class AffinePseudoSphereArrangement 00125 00126 // Output stream overloading. 00127 std::ostream & operator<< (std::ostream &, AffinePseudoSphereArrangement &); 00128 00129 00131 inline AffinePseudoSphereArrangement::AffinePseudoSphereArrangement 00132 (Circuits & C, index_t i) 00133 : PseudoSphereArrangement (C), AffineObject (i) 00134 { 00135 updateBoundedFaces (); 00136 } 00137 00139 inline AffinePseudoSphereArrangement::AffinePseudoSphereArrangement 00140 (AffineCircuits & C) 00141 : PseudoSphereArrangement (C), AffineObject (C.getInfinityElement()) 00142 { 00143 updateBoundedFaces (); 00144 } 00145 00146 00148 inline size_t AffinePseudoSphereArrangement::getNumBoundedCells () const { 00149 return m_BoundedCell.size (); 00150 } 00151 00153 inline size_t AffinePseudoSphereArrangement::getNumBoundedFacets () const { 00154 return m_BoundedFacet.size (); 00155 } 00156 00158 inline size_t AffinePseudoSphereArrangement::getNumExternalFacets () const { 00159 return m_ExternalFacet.size (); 00160 } 00161 00163 inline size_t AffinePseudoSphereArrangement::getNumBoundedEdges () const { 00164 return m_BoundedEdge.size (); 00165 } 00166 00168 inline size_t AffinePseudoSphereArrangement::getNumBoundedVertices () const { 00169 return m_BoundedVertex.size (); 00170 } 00171 00173 inline void AffinePseudoSphereArrangement::setInfinityElement (index_t i) { 00174 AffineObject::setInfinityElement (i); 00175 updateBoundedFaces (); // bounded faces need to be updated 00176 } 00177 00179 inline AffinePseudoSphereArrangement::bounded_cell_iterator 00180 AffinePseudoSphereArrangement::bounded_cell_begin () 00181 { 00182 return m_BoundedCell.begin (); 00183 } 00184 00186 inline AffinePseudoSphereArrangement::bounded_cell_iterator 00187 AffinePseudoSphereArrangement::bounded_cell_end () 00188 { 00189 return m_BoundedCell.end (); 00190 } 00191 00193 inline AffinePseudoSphereArrangement::reverse_bounded_cell_iterator 00194 AffinePseudoSphereArrangement::bounded_cell_rbegin () 00195 { 00196 return m_BoundedCell.rbegin (); 00197 } 00198 00200 inline AffinePseudoSphereArrangement::reverse_bounded_cell_iterator 00201 AffinePseudoSphereArrangement::bounded_cell_rend () 00202 { 00203 return m_BoundedCell.rend (); 00204 } 00205 00207 inline AffinePseudoSphereArrangement::bounded_facet_iterator 00208 AffinePseudoSphereArrangement::bounded_facet_begin () 00209 { 00210 return m_BoundedFacet.begin (); 00211 } 00212 00214 inline AffinePseudoSphereArrangement::bounded_facet_iterator 00215 AffinePseudoSphereArrangement::bounded_facet_end () 00216 { 00217 return m_BoundedFacet.end (); 00218 } 00219 00221 inline AffinePseudoSphereArrangement::reverse_bounded_facet_iterator 00222 AffinePseudoSphereArrangement::bounded_facet_rbegin () 00223 { 00224 return m_BoundedFacet.rbegin (); 00225 } 00226 00228 inline AffinePseudoSphereArrangement::reverse_bounded_facet_iterator 00229 AffinePseudoSphereArrangement::bounded_facet_rend () 00230 { 00231 return m_BoundedFacet.rend (); 00232 } 00233 00235 inline AffinePseudoSphereArrangement::external_facet_iterator 00236 AffinePseudoSphereArrangement::external_facet_begin () 00237 { 00238 return m_ExternalFacet.begin (); 00239 } 00240 00242 inline AffinePseudoSphereArrangement::external_facet_iterator 00243 AffinePseudoSphereArrangement::external_facet_end () 00244 { 00245 return m_ExternalFacet.end (); 00246 } 00247 00249 inline AffinePseudoSphereArrangement::reverse_external_facet_iterator 00250 AffinePseudoSphereArrangement::external_facet_rbegin () 00251 { 00252 return m_ExternalFacet.rbegin (); 00253 } 00254 00256 inline AffinePseudoSphereArrangement::reverse_external_facet_iterator 00257 AffinePseudoSphereArrangement::external_facet_rend () 00258 { 00259 return m_ExternalFacet.rend (); 00260 } 00261 00263 inline AffinePseudoSphereArrangement::bounded_edge_iterator 00264 AffinePseudoSphereArrangement::bounded_edge_begin () 00265 { 00266 return m_BoundedEdge.begin (); 00267 } 00268 00270 inline AffinePseudoSphereArrangement::bounded_edge_iterator 00271 AffinePseudoSphereArrangement::bounded_edge_end () 00272 { 00273 return m_BoundedEdge.end (); 00274 } 00275 00277 inline AffinePseudoSphereArrangement::reverse_bounded_edge_iterator 00278 AffinePseudoSphereArrangement::bounded_edge_rbegin () 00279 { 00280 return m_BoundedEdge.rbegin (); 00281 } 00282 00284 inline AffinePseudoSphereArrangement::reverse_bounded_edge_iterator 00285 AffinePseudoSphereArrangement::bounded_edge_rend () 00286 { 00287 return m_BoundedEdge.rend (); 00288 } 00289 00291 inline AffinePseudoSphereArrangement::bounded_vertex_iterator 00292 AffinePseudoSphereArrangement::bounded_vertex_begin () 00293 { 00294 return m_BoundedVertex.begin (); 00295 } 00296 00298 inline AffinePseudoSphereArrangement::bounded_vertex_iterator 00299 AffinePseudoSphereArrangement::bounded_vertex_end () 00300 { 00301 return m_BoundedVertex.end (); 00302 } 00303 00305 inline AffinePseudoSphereArrangement::reverse_bounded_vertex_iterator 00306 AffinePseudoSphereArrangement::bounded_vertex_rbegin () 00307 { 00308 return m_BoundedVertex.rbegin (); 00309 } 00310 00312 inline AffinePseudoSphereArrangement::reverse_bounded_vertex_iterator 00313 AffinePseudoSphereArrangement::bounded_vertex_rend () 00314 { 00315 return m_BoundedVertex.rend (); 00316 } 00317 00318 }; // namespace omc 00319 00320 #endif // OMC_AFFINE_PSEUDO_SPHERE_ARRANGEMENT_H