Commit 14c3f576 authored by Sylvain Thery's avatar Sylvain Thery
Browse files

remove needMarker parameter

parent 1e679811
......@@ -459,45 +459,41 @@ void Viewer::cb_keyPress(int keycode)
Utils::Chrono ch;
ch.start();
for (unsigned int i=0; i<4; ++i)
Algo::Surface::Geometry::computeNormalVertices<PFP>(myMap, position, normal) ;
std::cout << "Algo::Surface::Geometry::Parallel::computeNormalVertices "<< ch.elapsed()<< " ms "<< std::endl;
ch.start();
CGoGN::Parallel::NumberOfThreads = 1;
for (unsigned int i=0; i<4; ++i)
Algo::Surface::Geometry::Parallel::computeNormalVertices<PFP>(myMap, position, normal) ;
std::cout << "Algo::Surface::Geometry::Parallel::computeNormalVertices1 "<< ch.elapsed()<< " ms "<< std::endl;
ch.start();
// ch.start();
// CGoGN::Parallel::NumberOfThreads = 2;
// for (unsigned int i=0; i<4; ++i)
// Algo::Surface::Geometry::Parallel::computeNormalVertices<PFP>(myMap, position, normal) ;
// std::cout << "Algo::Surface::Geometry::Parallel::computeNormalVertices2 "<< ch.elapsed()<< " ms "<< std::endl;
CGoGN::Parallel::NumberOfThreads = 2;
for (unsigned int i=0; i<4; ++i)
Algo::Surface::Geometry::Parallel::computeNormalVertices<PFP>(myMap, position, normal) ;
std::cout << "Algo::Surface::Geometry::Parallel::computeNormalVertices2 "<< ch.elapsed()<< " ms "<< std::endl;
// ch.start();
// CGoGN::Parallel::NumberOfThreads = 3;
// for (unsigned int i=0; i<4; ++i)
// Algo::Surface::Geometry::Parallel::computeNormalVertices<PFP>(myMap, position, normal) ;
// std::cout << "Algo::Surface::Geometry::Parallel::computeNormalVertices3 "<< ch.elapsed()<< " ms "<< std::endl;
ch.start();
CGoGN::Parallel::NumberOfThreads = 3;
for (unsigned int i=0; i<4; ++i)
Algo::Surface::Geometry::Parallel::computeNormalVertices<PFP>(myMap, position, normal) ;
std::cout << "Algo::Surface::Geometry::Parallel::computeNormalVertices3 "<< ch.elapsed()<< " ms "<< std::endl;
ch.start();
CGoGN::Parallel::NumberOfThreads = 4;
for (unsigned int i=0; i<4; ++i)
Algo::Surface::Geometry::Parallel::computeNormalVertices<PFP>(myMap, position, normal) ;
std::cout << "Algo::Surface::Geometry::Parallel::computeNormalVertices4 "<< ch.elapsed()<< " ms "<< std::endl;
ch.start();
// ch.start();
// CGoGN::Parallel::NumberOfThreads = 8;
// for (unsigned int i=0; i<4; ++i)
// Algo::Surface::Geometry::Parallel::computeNormalVertices<PFP>(myMap, position, normal) ;
// std::cout << "Algo::Surface::Geometry::Parallel::computeNormalVertices8 "<< ch.elapsed()<< " ms "<< std::endl;
CGoGN::Parallel::NumberOfThreads = 8;
ch.start();
CGoGN::Parallel::NumberOfThreads = 1;
for (unsigned int i=0; i<4; ++i)
Algo::Surface::Geometry::Parallel::computeNormalVertices<PFP>(myMap, position, normal) ;
std::cout << "Algo::Surface::Geometry::Parallel::computeNormalVertices8 "<< ch.elapsed()<< " ms "<< std::endl;
std::cout << "Algo::Surface::Geometry::Parallel::computeNormalVertices1 "<< ch.elapsed()<< " ms "<< std::endl;
ch.start();
......@@ -505,7 +501,7 @@ void Viewer::cb_keyPress(int keycode)
Parallel::foreach_cell<VERTEX>(myMap, [&] (Vertex v, unsigned int th)
{
normal[v] = Algo::Surface::Geometry::vertexNormal<PFP>(myMap,v,position);
}, false, FORCE_CELL_MARKING);
}, FORCE_CELL_MARKING);
std::cout << "Parallel::foreach_cell "<< ch.elapsed()<< " ms "<< std::endl;
......
......@@ -108,7 +108,7 @@ int main()
{
position[v] += VEC3(0.0, 0.0, PFP::REAL(thread) * 0.1f);
// WARNING thread vary here from 1 to 4 (and not from 0 to 3) !!!!
}, false); // 4:4 thread, false for no need for markers in threaded code.
}); // 4:4 thread, false for no need for markers in threaded code.
std::cout << "After // processing"<< std::endl;
foreach_cell<VERTEX>(myMap, [&] (Vertex v) // for each Vertex v of the MAP myMap
......@@ -132,7 +132,7 @@ int main()
{
// for each face add surface to accumulator (-1 because counter between 1-3 not 0-3)
surf[thr-1] += Algo::Surface::Geometry::convexFaceArea<PFP>(myMap, f, position);
}, false);
});
std::cout << surf[0]<< "/"<< surf[1]<< "/"<< surf[2]<< "/"<< std::endl;
std::cout << "Total="<<surf[0]+surf[1]+surf[2]<< std::endl;
......
......@@ -236,7 +236,7 @@ void computeAreaFaces(typename PFP::MAP& map, const VertexAttribute<typename PFP
CGoGN::Parallel::foreach_cell<FACE>(map,[&](Face f, unsigned int thr)
{
area[f] = convexFaceArea<PFP>(map, f, position) ;
},false,AUTO);
});
}
......@@ -246,7 +246,7 @@ void computeOneRingAreaVertices(typename PFP::MAP& map, const VertexAttribute<ty
CGoGN::Parallel::foreach_cell<VERTEX>(map,[&](Vertex v, unsigned int thr)
{
area[v] = vertexOneRingArea<PFP>(map, v, position) ;
},false,FORCE_CELL_MARKING);
},FORCE_CELL_MARKING);
}
template <typename PFP>
......@@ -256,7 +256,7 @@ void computeBarycentricAreaVertices(typename PFP::MAP& map, const VertexAttribut
{
vertex_area[v] = vertexBarycentricArea<PFP>(map, v, position) ;
}
,false,FORCE_CELL_MARKING);
,FORCE_CELL_MARKING);
}
template <typename PFP>
......@@ -265,7 +265,7 @@ void computeVoronoiAreaVertices(typename PFP::MAP& map, const VertexAttribute<ty
CGoGN::Parallel::foreach_cell<VERTEX>(map,[&](Vertex v, unsigned int thr)
{
area[v] = vertexVoronoiArea<PFP>(map, v, position) ;
},false,FORCE_CELL_MARKING);
},FORCE_CELL_MARKING);
}
} // namespace Parallel
......
......@@ -187,7 +187,7 @@ void computeCentroidFaces(typename PFP::MAP& map, const V_ATT& position, F_ATT&
CGoGN::Parallel::foreach_cell<FACE>(map,[&](Face f, unsigned int thr)
{
face_centroid[f] = faceCentroid<PFP>(map, f, position) ;
},false,AUTO);
});
}
template <typename PFP, typename V_ATT, typename F_ATT>
......@@ -196,7 +196,7 @@ void computeCentroidELWFaces(typename PFP::MAP& map, const V_ATT& position, F_AT
CGoGN::Parallel::foreach_cell<FACE>(map,[&](Face f, unsigned int thr)
{
face_centroid[f] = faceCentroidELW<PFP>(map, f, position) ;
},false,AUTO);
});
}
......@@ -207,7 +207,7 @@ void computeNeighborhoodCentroidVertices(typename PFP::MAP& map,
CGoGN::Parallel::foreach_cell<VERTEX>(map,[&](Vertex v, unsigned int thr)
{
vertex_centroid[v] = vertexNeighborhoodCentroid<PFP>(map, v, position) ;
},false,FORCE_CELL_MARKING);
},FORCE_CELL_MARKING);
}
} // namespace Parallel
......@@ -297,7 +297,7 @@ void computeCentroidVolumes(typename PFP::MAP& map, const V_ATT& position, W_ATT
CGoGN::Parallel::foreach_cell<VOLUME>(map,[&](Vol v, unsigned int thr)
{
vol_centroid[v] = Surface::Geometry::volumeCentroid<PFP,V_ATT>(map, v, position, thr) ;
},true,AUTO);
});
}
template <typename PFP, typename V_ATT, typename W_ATT>
......@@ -306,7 +306,7 @@ void computeCentroidELWVolumes(typename PFP::MAP& map, const V_ATT& position, W_
CGoGN::Parallel::foreach_cell<VOLUME>(map,[&](Vol v, unsigned int thr)
{
vol_centroid[v] = Surface::Geometry::volumeCentroidELW<PFP,V_ATT>(map, v, position, thr) ;
},true,AUTO);
});
}
......
......@@ -667,7 +667,7 @@ void computeCurvatureVertices_NormalCycles(
CGoGN::Parallel::foreach_cell<VERTEX>(map,[&](Vertex v, unsigned int threadID)
{
computeCurvatureVertex_NormalCycles<PFP>(map, v, radius, position, normal, edgeangle, kmax, kmin, Kmax, Kmin, Knormal, threadID) ;
},true,FORCE_CELL_MARKING);
},FORCE_CELL_MARKING);
}
template <typename PFP>
......@@ -696,7 +696,7 @@ void computeCurvatureVertices_NormalCycles_Projected(
CGoGN::Parallel::foreach_cell<VERTEX>(map,[&](Vertex v, unsigned int threadID)
{
computeCurvatureVertex_NormalCycles_Projected<PFP>(map, v, radius, position, normal, edgeangle, kmax, kmin, Kmax, Kmin, Knormal, threadID) ;
},true,FORCE_CELL_MARKING);
},FORCE_CELL_MARKING);
}
......@@ -714,7 +714,7 @@ void computeCurvatureVertices_QuadraticFitting(
CGoGN::Parallel::foreach_cell<VERTEX>(map,[&](Vertex v, unsigned int threadID)
{
computeCurvatureVertex_QuadraticFitting<PFP>(map, v, position, normal, kmax, kmin, Kmax, Kmin, threadID) ;
},true,FORCE_CELL_MARKING);
},FORCE_CELL_MARKING);
}
......
......@@ -235,7 +235,7 @@ void computeNormalVertices(typename PFP::MAP& map, const V_ATT& position, V_ATT&
CGoGN::Parallel::foreach_cell<VERTEX>(map,[&](Vertex v, unsigned int /*thr*/)
{
normal[v] = vertexNormal<PFP>(map, v, position) ;
},true,FORCE_CELL_MARKING);
},FORCE_CELL_MARKING);
}
template <typename PFP, typename V_ATT, typename F_ATT>
......@@ -244,7 +244,7 @@ void computeNormalFaces(typename PFP::MAP& map, const V_ATT& position, F_ATT& no
CGoGN::Parallel::foreach_cell<FACE>(map,[&](Face f, unsigned int thr)
{
normal[f] = faceNormal<PFP>(map, f, position) ;
},true,AUTO);
});
}
......@@ -254,7 +254,7 @@ void computeAnglesBetweenNormalsOnEdges(typename PFP::MAP& map, const V_ATT& pos
CGoGN::Parallel::foreach_cell<EDGE>(map,[&](Edge e, unsigned int thr)
{
angles[e] = computeAngleBetweenNormalsOnEdge<PFP>(map, e, position) ;
},true,AUTO);
});
}
} // namespace Parallel
......
......@@ -37,328 +37,13 @@ public:
template <>
class AttributeMultiVector<MarkerBool> : public AttributeMultiVectorGen
{
/**
* table of blocks of data pointers: vectors!
*/
std::vector< std::vector<bool> > m_tableData;
public:
AttributeMultiVector(const std::string& strName, const std::string& strType):
AttributeMultiVectorGen(strName, strType)
{
m_tableData.reserve(1024);
}
AttributeMultiVector()
{
m_tableData.reserve(1024);
}
~AttributeMultiVector() {}
AttributeMultiVectorGen* new_obj()
{
AttributeMultiVectorGen* ptr = new AttributeMultiVector<MarkerBool>;
ptr->setTypeName(m_typeName);
return ptr;
}
/**************************************
* MULTI VECTOR MANAGEMENT *
**************************************/
void addBlock()
{
m_tableData.resize(m_tableData.size()+1);
m_tableData.back().resize(_BLOCKSIZE_);
}
void setNbBlocks(unsigned int nbb)
{
if (nbb >= m_tableData.size())
{
unsigned int sz = m_tableData.size();
m_tableData.resize(nbb);
for (unsigned int i= sz; i <nbb; ++i)
m_tableData[i].resize(_BLOCKSIZE_);
}
else
{
m_tableData.resize(nbb);
}
}
unsigned int getNbBlocks() const
{
return m_tableData.size();
}
// void addBlocksBefore(unsigned int nbb);
bool copy(const AttributeMultiVectorGen* atmvg)
{
const AttributeMultiVector<MarkerBool>* atmv = dynamic_cast<const AttributeMultiVector<MarkerBool>*>(atmvg);
if (atmv == NULL)
{
CGoGNerr << "trying to copy attributes of different type" << CGoGNendl;
return false;
}
// if (atmv->m_typeName != m_typeName)
// {
// CGoGNerr << "trying to copy attributes with different type names" << CGoGNendl;
// return false;
// }
m_tableData.resize( atmv->m_tableData.size() );
for (unsigned int i = 0; i < atmv->m_tableData.size(); ++i)
m_tableData[i] = atmv->m_tableData[i];
return true;
}
bool swap(AttributeMultiVectorGen* atmvg)
{
AttributeMultiVector<MarkerBool>* atmv = dynamic_cast<AttributeMultiVector<MarkerBool>*>(atmvg);
if (atmv == NULL)
{
CGoGNerr << "trying to swap attributes of different type" << CGoGNendl;
return false;
}
if (atmv->m_typeName != m_typeName)
{
CGoGNerr << "trying to swap attributes with different type names" << CGoGNendl;
return false;
}
m_tableData.swap(atmv->m_tableData) ;
return true;
}
bool merge(const AttributeMultiVectorGen& att)
{
const AttributeMultiVector<MarkerBool>* attrib = dynamic_cast< const AttributeMultiVector<MarkerBool>* >(&att);
if (attrib==NULL)
{
CGoGNerr << "trying to merge attributes of different type" << CGoGNendl;
return false;
}
if (attrib->m_typeName != m_typeName)
{
CGoGNerr << "trying to merge attributes with different type names" << CGoGNendl;
return false;
}
for (auto it = attrib->m_tableData.begin(); it != attrib->m_tableData.end(); ++it)
m_tableData.push_back(*it);
return true;
}
void clear()
{
m_tableData.clear();
}
int getSizeOfType() const
{
return sizeof(bool); // ?
}
void allFalse()
{
// std::cout << "Marker "<<this->getName()<<" - allFalse"<< std::endl;
for (unsigned int i = 0; i < m_tableData.size(); ++i)
{
m_tableData[i].assign(_BLOCKSIZE_,false);
}
//memset(m_tableData[i],0,_BLOCKSIZE_/8);
}
/**************************************
* DATA ACCESS *
**************************************/
void setFalse(unsigned int i)
{
m_tableData[i / _BLOCKSIZE_][i % _BLOCKSIZE_] =false;
// std::cout << "Marker "<<this->getName()<<" - ";
// std::cout << "SET FALSE: "<< this->operator[](i)<< std::endl;
}
void setTrue(unsigned int i)
{
m_tableData[i / _BLOCKSIZE_][i % _BLOCKSIZE_] = true;
// std::cout << "Marker "<<this->getName()<<" - ";
// std::cout << "SET TRUE: "<< this->operator[](i)<< std::endl;
}
void setVal(unsigned int i, bool b)
{
m_tableData[i / _BLOCKSIZE_][i % _BLOCKSIZE_] = b;
// std::cout << "Marker "<<this->getName()<<" - ";
// std::cout << "SET VAL: "<< b << " -> "<< this->operator[](i)<< std::endl;
}
/**
* get a const reference on a elt
* @param i index of element
*/
bool operator[](unsigned int i) const
{
// std::cout << "BITS="<<std::hex<< m_tableData[jj][x]<< " MASK="<<mask<<" ~MASK="<<~mask<<std::endl;
return m_tableData[i / _BLOCKSIZE_][i % _BLOCKSIZE_];
}
/**
* Get the addresses of each block of data
*/
unsigned int getBlocksPointers(std::vector<void*>& addr, unsigned int& /*byteBlockSize*/) const
{
CGoGNerr << "DO NOT USE getBlocksPointers with bool attribute"<< CGoGNendl;
return 0;
// addr.reserve(m_tableData.size());
// addr.clear();
// for (auto it = m_tableData.begin(); it != m_tableData.end(); ++it)
// addr.push_back(NULL );
// return addr.size();
}
/**************************************
* LINES MANAGEMENT *
**************************************/
void initElt(unsigned int id)
{
// std::cout << "Marker "<<this->getName()<<" - InitElt"<< std::endl;
setFalse(id);
}
void copyElt(unsigned int dst, unsigned int src)
{
// std::cout << "Marker "<<this->getName()<<" - CopyElt"<< std::endl;
setVal(dst,this->operator [](src));
}
void swapElt(unsigned int id1, unsigned int id2)
{
// std::cout << "Marker "<<this->getName()<<" - SwapElt"<< std::endl;
bool data = this->operator [](id1);
setVal(id1,this->operator [](id2));
setVal(id2,data);
}
/**
* swap two elements in container (useful for compact function)
* @param src_b block index of source element
* @param src_id index in block of source element
* @param dst_b block index of destination element
* @param dst_id index in block of destination element
*/
void overwrite(unsigned int src_b, unsigned int src_id, unsigned int dst_b, unsigned int dst_id)
{
// std::cout << "Marker "<<this->getName()<<" - overwrite"<< std::endl;
m_tableData[dst_b][dst_id] = m_tableData[src_b][src_id];
}
/**************************************
* SAVE & LOAD *
**************************************/
/**
* Sauvegarde binaire
* @param fs filestream
* @param id id of mv
*/
void saveBin(CGoGNostream& fs, unsigned int id)
{
// unsigned int nbs[3];
// nbs[0] = id;
// int len1 = m_attrName.size()+1;
// int len2 = m_typeName.size()+1;
// nbs[1] = len1;
// nbs[2] = len2;
// fs.write(reinterpret_cast<const char*>(nbs),3*sizeof(unsigned int));
// // store names
// char buffer[256];
// const char* s1 = m_attrName.c_str();
// memcpy(buffer,s1,len1);
// const char* s2 = m_typeName.c_str();
// memcpy(buffer+len1,s2,len2);
// fs.write(reinterpret_cast<const char*>(buffer),(len1+len2)*sizeof(char));
// nbs[0] = m_tableData.size();
// nbs[1] = nbs[0] * _BLOCKSIZE_/32;
// fs.write(reinterpret_cast<const char*>(nbs),2*sizeof(unsigned int));
// for (auto ptrIt = m_tableData.begin(); ptrIt!=m_tableData.end(); ++ptrIt)
// fs.write(reinterpret_cast<const char*>(*ptrIt),_BLOCKSIZE_/8);
}
/**
* lecture binaire
* @param fs filestream
*/
bool loadBin(CGoGNistream& fs)
{
// unsigned int nbs[2];
// fs.read(reinterpret_cast<char*>(nbs), 2*sizeof(unsigned int));
// unsigned int nb = nbs[0];
// bool *bbuff = new bool[nb*_BLOCKSIZE_];
// fs.read(reinterpret_cast<char*>(bbuff),nb*_BLOCKSIZE_*sizeof(bool));
// // load data blocks
// m_tableData.resize(nb);
// for(unsigned int i = 0; i < nb; ++i)
// {
// m_tableData[i] = new unsigned int[_BLOCKSIZE_/32];
// for (unsigned int j=0; j<_BLOCKSIZE_;++j)
// fs.read(reinterpret_cast<char*>(m_tableData[i]),_BLOCKSIZE_/8);
// }
return true;
}
/**
* lecture binaire
* @param fs filestream
*/
virtual void dump(unsigned int i) const
{
CGoGNout << this->operator[](i);
}
};
//template <>
//class AttributeMultiVector<MarkerBool> : public AttributeMultiVectorGen
//{
// /**
// * table of blocks of data pointers: vectors!
// */
// std::vector< unsigned int* > m_tableData;
// std::vector< unsigned char* > m_tableData;
//public:
// AttributeMultiVector(const std::string& strName, const std::string& strType):
......@@ -387,10 +72,9 @@ public:
// void addBlock()
// {
// unsigned int* ptr = new unsigned int[_BLOCKSIZE_/32];
// memset(ptr,0,_BLOCKSIZE_/8);
// unsigned char* ptr = new unsigned char[_BLOCKSIZE_];
// memset(ptr,0,_BLOCKSIZE_);
// m_tableData.push_back(ptr);
//// std::cout << "Marker "<<this->getName()<<" - addBlock"<< std::endl;
// }
// void setNbBlocks(unsigned int nbb)
......@@ -404,7 +88,6 @@ public:
// {
// for (unsigned int i = m_tableData.size()-1; i>=nbb; --i)
// delete[] m_tableData[i];
// m_tableData.resize(nbb);
// }
// }
......@@ -432,8 +115,9 @@ public:
//// return false;
//// }
// m_tableData.resize( atmv->m_tableData.size() );
// for (unsigned int i = 0; i < atmv->m_tableData.size(); ++i)
// memcpy(m_tableData[i],atmv->m_tableData[i],_BLOCKSIZE_/32);
// m_tableData[i] = atmv->m_tableData[i];
// return true;
// }
......@@ -478,227 +162,541 @@ public:
// return true;
// }
// void clear()
// {
// for (auto it=m_tableData.begin(); it !=m_tableData.end(); ++it)
// delete[] *it;
// m_tableData.clear();
// }
// void clear()
// {
// m_tableData.clear();
// }
// int getSizeOfType() const
// {
// return sizeof(bool); // ?
// }
// void allFalse()
// {
//// std::cout << "Marker "<<this->getName()<<" - allFalse"<< std::endl;
// for (unsigned int i = 0; i < m_tableData.size(); ++i)
// {
// memset(m_tableData[i],0,_BLOCKSIZE_);