23 #include <boost/math/special_functions/factorials.hpp>
40 {
for (iteHS.begin(); iteHS.end()!=
true; iteHS.next()) {
43 for (iteGN.begin(); iteGN.end()!=
true; iteGN.next()) {
45 {
for (
unsigned int j=0; j<iteGN.current()->numberOfFacets(); j++) {
46 if (iteGN.current()->getFacet(j) == iteHS.current())
60 {
for (iteGN.begin(); iteGN.end()!=
true; iteGN.next()) {
62 {
for (
unsigned int j=0; j<iteGN.current()->numberOfFacets(); j++) {
63 unsigned int facetNumber = P->getHalfSpaceNumber( iteGN.current()->getFacet(j) );
83 std::stack< PolytopeToSimplexes > stackOfPolToSimp;
84 std::vector< unsigned int > listOfVtx;
86 for (
unsigned int i=0; i<
_polytope->numberOfGenerators(); ++i)
87 listOfVtx.push_back(i);
89 stackOfPolToSimp.push(P2S);
91 while (stackOfPolToSimp.size() != 0) {
93 unsigned int shift =
_dimension-stackOfPolToSimp.top().dimension();
94 std::cout <<
"The top of the stack is:" << std::endl;
95 stackOfPolToSimp.top().dump(std::cout, shift);
100 std::cout <<
"[*** The current polytope is a simplex ***]" << std::endl;
109 std::cout <<
"After switchToFullDimension():" << std::endl;
110 stackOfPolToSimp.top().dump(std::cout, shift);
112 stackOfPolToSimp.pop();
119 std::cout <<
"[*** The current polytope is to be split ***]" << std::endl;
124 unsigned int apexNumber = vtx2plit[0];
125 std::vector< unsigned int >::const_iterator itEnd = vtx2plit.end();
126 std::vector< unsigned int >::const_iterator itBeg = vtx2plit.begin();
129 std::vector< unsigned int > newVtx;
130 newVtx.insert(newVtx.begin(), itBeg, itEnd);
133 stackOfPolToSimp.pop();
135 {
for (
unsigned int facetNumber=0; facetNumber<
_numberOfFacets; ++facetNumber) {
138 std::cout <<
"Search " << facetNumber <<
" in : ";
140 std::cout << std::endl;
146 std::cout <<
"Not found facet number : " << facetNumber << std::endl;
150 std::vector< unsigned int > verticesOnGivenFacet;
151 std::set_intersection(
156 std::inserter( verticesOnGivenFacet, verticesOnGivenFacet.begin() ) );
157 if (verticesOnGivenFacet.size() >= topOfStack_cp.
dimension()) {
159 stackOfPolToSimp.push(newP2S);
162 std::copy(newVtx.begin(), newVtx.end(), std::ostream_iterator<unsigned int>(std::cout,
" "));
163 std::cout <<
"} INTER { ";
165 std::cout <<
"}" << std::endl;
166 for (
unsigned int i=0; i<
_dimension-newP2S.dimension(); ++i) std::cout <<
"\t";
167 std::cout <<
"{" << newP2S.dimension() <<
":";
168 std::copy(newP2S.getListOfProcessedVertices().begin(), newP2S.getListOfProcessedVertices().end(), std::ostream_iterator<unsigned int>(std::cout,
" "));
169 std::cout << std::endl;
170 for (
unsigned int i=0; i<
_dimension-newP2S.dimension(); ++i) std::cout <<
"\t";
171 std::copy(newP2S.getListOfVerticesToSplit().begin(), newP2S.getListOfVerticesToSplit().end(), std::ostream_iterator<unsigned int>(std::cout,
" "));
172 std::cout <<
"}" << std::endl;
182 std::cout <<
"_allSimplices : " << std::endl;
184 std::cout <<
"{" << it->dimension() <<
":";
185 std::copy(it->getListOfProcessedVertices().begin(), it->getListOfProcessedVertices().end(), std::ostream_iterator<unsigned int>(std::cout,
" "));
186 std::cout << std::endl;
187 std::copy(it->getListOfVerticesToSplit().begin(), it->getListOfVerticesToSplit().end(), std::ostream_iterator<unsigned int>(std::cout,
" "));
188 std::cout <<
"}" << std::endl;
189 std::cout << std::endl;
197 std::cout <<
"VolumeOfPolytopes_Rn::volume() : " <<
_allSimplices.size() << std::endl;
199 std::set< std::set< boost::shared_ptr<Generator_Rn> > > listOfCoordSimplices;
200 std::vector< PolytopeToSimplexes >::iterator it1;
203 std::set< boost::shared_ptr<Generator_Rn> > setOfGN;
204 std::vector< unsigned int >::const_iterator it2;
206 std::cout <<
"Current simplex : ";
207 std::copy(it1->getListOfProcessedVertices().begin(), it1->getListOfProcessedVertices().end(), std::ostream_iterator<unsigned int>(std::cout,
" "));
208 std::cout << std::endl;
210 {
for (it2=it1->getListOfProcessedVertices().begin(); it2!=it1->getListOfProcessedVertices().end(); ++it2) {
211 setOfGN.insert(
_polytope->getGenerator( *it2 ));
213 listOfCoordSimplices. insert(setOfGN);
217 std::set< std::set< boost::shared_ptr<Generator_Rn> > >::const_iterator constITER_setGN;
218 {
for (constITER_setGN=listOfCoordSimplices.begin(); constITER_setGN!=listOfCoordSimplices.end(); ++constITER_setGN) {
221 std::cout <<
"volumeOfSimplex=" << current_volume << std::endl;
231 boost::shared_ptr<Generator_Rn> vx0 = *(listOfSimplexVertices.begin());
232 boost::numeric::ublas::matrix<double> mat2computeDET(RnDIM, RnDIM);
233 std::set< boost::shared_ptr<Generator_Rn> >::const_iterator constITER_GN = listOfSimplexVertices.begin();
236 {
for ( ; constITER_GN!=listOfSimplexVertices.end(); ++constITER_GN) {
237 for (
unsigned int j=0; j<mat2computeDET.size2(); ++j)
238 mat2computeDET(i,j) = (*constITER_GN)->getCoordinate(j) - vx0->getCoordinate(j);
242 std::cout <<
"mat2computeDET=" << mat2computeDET << std::endl;
250 unsigned int i,j,j1,j2;
251 unsigned int n = mat.size1();
259 det = mat(0,0)*mat(1,1) - mat(1,0)*mat(0,1);
263 for (j1=0; j1<n; j1++) {
264 boost::numeric::ublas::matrix<double> smaller_mat(n-1, n-1);
265 for (i=1; i<n; i++) {
267 for (j=0; j<n; j++) {
270 smaller_mat(i-1,j2) = mat(i,j);
unsigned int dimension() const
void switchToFullDimension()
std::vector< PolytopeToSimplexes > _allSimplices
List to store all the simplices partitioning the polytope.
unsigned int _numberOfFacets
The number of facets of the current polytope.
double computeSimplexVolume(const std::set< boost::shared_ptr< Generator_Rn > > &listOfSimplexVertices) const
std::vector< std::vector< unsigned int > > _verticesByFacets
The ordered list of all vertices stored by facets.
const std::vector< unsigned int > & getListOfVerticesToSplit() const
int currentIteratorNumber() const
Return the current position in the list.
void dumpDS(std::ostream &this_ostream) const
boost::shared_ptr< Polytope_Rn > _polytope
The current polytope we are working on.
unsigned int _numberOfVertices
The number of vertices of the current polytope.
static polito_EXPORT unsigned int getDimension()
Return the dimension of the cartesian space we work in.
double _volume
The volume of the polytope.
std::vector< std::vector< unsigned int > > _facetsByVertices
The ordered list of all facets stored by vertices.
const std::vector< unsigned int > & getListOfProcessedVertices() const
double volume()
Sum the volumes of all simplices partitionning the polytope.
unsigned int _dimension
As the algorithm goes down in lower dimensions, we want to store the starting space dimension...
This class is designed to run the list of all geometric objects representing a polytope.
void splitCloudOfVertices(unsigned int DIM)
double determinant(boost::numeric::ublas::matrix< double > a) const
VolumeOfPolytopes_Rn(const boost::shared_ptr< Polytope_Rn > P)
Constructor.
bool checkSimplex() const