Commit d0565b60 authored by Pierre Kraemer's avatar Pierre Kraemer

orbit as template -> parallel + particles

parent 4b26d77d
......@@ -39,10 +39,10 @@ namespace BooleanOperator
{
template <typename PFP>
void mergeVertex(typename PFP::MAP& map, const typename PFP::TVEC3& positions, Dart d, Dart e);
void mergeVertex(typename PFP::MAP& map, const AttributeHandler<typename PFP::VEC3, VERTEX>& positions, Dart d, Dart e);
template <typename PFP>
void mergeVertices(typename PFP::MAP& map, const typename PFP::TVEC3& positions);
void mergeVertices(typename PFP::MAP& map, const AttributeHandler<typename PFP::VEC3, VERTEX>& positions);
}
......
......@@ -32,7 +32,7 @@ namespace BooleanOperator
{
template <typename PFP>
void mergeVertex(typename PFP::MAP& map, const typename PFP::TVEC3& positions, Dart d, Dart e)
void mergeVertex(typename PFP::MAP& map, const AttributeHandler<typename PFP::VEC3, VERTEX>& positions, Dart d, Dart e)
{
assert(Geom::arePointsEquals(positions[d],positions[e]) && !map.sameVertex(d,e));
Dart dd;
......@@ -55,11 +55,11 @@ void mergeVertex(typename PFP::MAP& map, const typename PFP::TVEC3& positions, D
}
template <typename PFP>
void mergeVertices(typename PFP::MAP& map, const typename PFP::TVEC3& positions)
void mergeVertices(typename PFP::MAP& map, const AttributeHandler<typename PFP::VEC3, VERTEX>& positions)
{
for(Dart d = map.begin() ; d != map.end() ; map.next(d))
{
CellMarker vM(map,VERTEX);
CellMarker<VERTEX> vM(map);
vM.mark(d);
for(Dart dd = map.begin() ; dd != map.end() ; map.next(dd))
{
......
......@@ -35,7 +35,7 @@ void exportTrianglePlain(std::ofstream& out,typename PFP::VEC3& p1,typename PFP:
}
template <typename PFP>
void exportMeshPlain(std::ofstream& out, typename PFP::MAP& map, typename PFP::TVEC3& position, const std::string& meshName, const FunctorSelect& good = allDarts)
void exportMeshPlain(std::ofstream& out, typename PFP::MAP& map, AttributeHandler<typename PFP::VEC3, VERTEX>& position, const std::string& meshName, const FunctorSelect& good = allDarts)
{
out << "#declare " << meshName << "= union {" << std::endl;
......@@ -75,7 +75,7 @@ void exportMeshPlain(std::ofstream& out, typename PFP::MAP& map, typename PFP::T
}
template <typename PFP>
void export3MeshPlainSmooth(std::ofstream& out, typename PFP::MAP& map, typename PFP::TVEC3& position, const std::string& meshName, const FunctorSelect& good = allDarts)
void export3MeshPlainSmooth(std::ofstream& out, typename PFP::MAP& map, AttributeHandler<typename PFP::VEC3, VERTEX>& position, const std::string& meshName, const FunctorSelect& good = allDarts)
{
typedef typename PFP::VEC3 VEC3;
......@@ -102,7 +102,7 @@ void export3MeshPlainSmooth(std::ofstream& out, typename PFP::MAP& map, typename
vertices.reserve(nbDarts/6) ;
normals.reserve(nbDarts/6) ;
CellMarker markV(map, VERTEX) ;
CellMarker<VERTEX> markV(map) ;
DartMarker markF(map) ;
for(Dart d = map.begin(); d != map.end(); map.next(d))
{
......@@ -173,7 +173,7 @@ void export3MeshPlainSmooth(std::ofstream& out, typename PFP::MAP& map, typename
}
template <typename PFP>
void exportMeshWire(std::ofstream& out, typename PFP::MAP& map, typename PFP::TVEC3& position, const std::string& meshName, const FunctorSelect& good = allDarts)
void exportMeshWire(std::ofstream& out, typename PFP::MAP& map, AttributeHandler<typename PFP::VEC3, VERTEX>& position, const std::string& meshName, const FunctorSelect& good = allDarts)
{
out << "#declare " << meshName << "= union {" << std::endl;
......@@ -187,7 +187,7 @@ void exportMeshWire(std::ofstream& out, typename PFP::MAP& map, typename PFP::TV
Dart dd = d;
do
{
traite.markOrbit(DART, dd);
traite.mark(dd);
dd = map.phi1(dd);
nb++;
} while(dd != d);
......@@ -216,7 +216,7 @@ void exportMeshWire(std::ofstream& out, typename PFP::MAP& map, typename PFP::TV
}
template <typename PFP>
bool exportScenePov(typename PFP::MAP& map, typename PFP::TVEC3& position, const std::string& filename, typename PFP::VEC3 cameraPos, typename PFP::VEC3 cameraLook, typename PFP::VEC3 translate, float angle_X, float angle_Y, float angle_Z,const FunctorSelect& good = allDarts)
bool exportScenePov(typename PFP::MAP& map, AttributeHandler<typename PFP::VEC3, VERTEX>& position, const std::string& filename, typename PFP::VEC3 cameraPos, typename PFP::VEC3 cameraLook, typename PFP::VEC3 translate, float angle_X, float angle_Y, float angle_Z,const FunctorSelect& good = allDarts)
{
std::ofstream out(filename.c_str(), std::ios::out);
if (!out.good())
......@@ -258,7 +258,7 @@ bool exportScenePov(typename PFP::MAP& map, typename PFP::TVEC3& position, const
}
template <typename PFP>
bool exportScenePovSmooth(typename PFP::MAP& map, typename PFP::TVEC3& position, const std::string& filename, typename PFP::VEC3 cameraPos, typename PFP::VEC3 cameraLook, typename PFP::VEC3 translate, float angle_X, float angle_Y, float angle_Z,const FunctorSelect& good = allDarts)
bool exportScenePovSmooth(typename PFP::MAP& map, AttributeHandler<typename PFP::VEC3, VERTEX>& position, const std::string& filename, typename PFP::VEC3 cameraPos, typename PFP::VEC3 cameraLook, typename PFP::VEC3 translate, float angle_X, float angle_Y, float angle_Z,const FunctorSelect& good = allDarts)
{
std::ofstream out(filename.c_str(), std::ios::out);
if (!out.good()) {
......
......@@ -39,21 +39,21 @@ namespace Geometry
{
template <typename PFP>
Geom::Plane3D<typename PFP::REAL> trianglePlane(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& position)
Geom::Plane3D<typename PFP::REAL> trianglePlane(typename PFP::MAP& map, Dart d, const AttributeHandler<typename PFP::VEC3, VERTEX>& position)
{
typename PFP::VEC3 n = triangleNormal<PFP>(map, d, position) ;
return Geom::Plane3D<typename PFP::REAL>(n, position[d]) ;
}
template <typename PFP>
Geom::Plane3D<typename PFP::REAL> facePlane(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& position)
Geom::Plane3D<typename PFP::REAL> facePlane(typename PFP::MAP& map, Dart d, const AttributeHandler<typename PFP::VEC3, VERTEX>& position)
{
typename PFP::VEC3 n = faceNormal<PFP>(map, d, position) ;
return Geom::Plane3D<typename PFP::REAL>(n, position[d]) ;
}
template <typename PFP>
Geom::Plane3D<typename PFP::REAL> vertexTangentPlane(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& position)
Geom::Plane3D<typename PFP::REAL> vertexTangentPlane(typename PFP::MAP& map, Dart d, const AttributeHandler<typename PFP::VEC3, VERTEX>& position)
{
typename PFP::VEC3 n = vertexNormal<PFP>(map, d, position) ;
return Geom::Plane3D<typename PFP::REAL>(n, position[d]) ;
......
......@@ -35,16 +35,16 @@ namespace IHM
{
template <typename PFP>
void subdivideEdge(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position) ;
void subdivideEdge(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP::VEC3, VERTEX>& position) ;
template <typename PFP>
void subdivideFace(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position) ;
void subdivideFace(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP::VEC3, VERTEX>& position) ;
template <typename PFP>
void coarsenEdge(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position) ;
void coarsenEdge(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP::VEC3, VERTEX>& position) ;
template <typename PFP>
void coarsenFace(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position) ;
void coarsenFace(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP::VEC3, VERTEX>& position) ;
} //namespace IHM
......
......@@ -32,7 +32,7 @@ namespace IHM
{
template <typename PFP>
void subdivideEdge(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position)
void subdivideEdge(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP::VEC3, VERTEX>& position)
{
assert(map.getDartLevel(d) <= map.getCurrentLevel() || !"Access to a dart introduced after current level") ;
assert(!map.edgeIsSubdivided(d) || !"Trying to subdivide an already subdivided edge") ;
......@@ -58,7 +58,7 @@ void subdivideEdge(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position
}
template <typename PFP>
void subdivideFace(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position)
void subdivideFace(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP::VEC3, VERTEX>& position)
{
assert(map.getDartLevel(d) <= map.getCurrentLevel() || !"Access to a dart introduced after current level") ;
assert(!map.faceIsSubdivided(d) || !"Trying to subdivide an already subdivided face") ;
......@@ -141,7 +141,7 @@ void subdivideFace(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position
}
template <typename PFP>
void coarsenEdge(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position)
void coarsenEdge(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP::VEC3, VERTEX>& position)
{
assert(map.getDartLevel(d) <= map.getCurrentLevel() || !"Access to a dart introduced after current level") ;
assert(map.edgeCanBeCoarsened(d) || !"Trying to coarsen an edge that can not be coarsened") ;
......@@ -157,7 +157,7 @@ void coarsenEdge(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position)
}
template <typename PFP>
void coarsenFace(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position)
void coarsenFace(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP::VEC3, VERTEX>& position)
{
assert(map.getDartLevel(d) <= map.getCurrentLevel() || !"Access to a dart introduced after current level") ;
assert(map.faceIsSubdividedOnce(d) || !"Trying to coarsen a non-subdivided face or a more than once subdivided face") ;
......
......@@ -43,8 +43,7 @@ namespace Import
bool checkXmlNode(xmlNodePtr node, const std::string& name);
template <typename PFP>
bool importSVG(typename PFP::MAP& map, const std::string& filename, typename PFP::TVEC3& position, CellMarker& polygons);
bool importSVG(typename PFP::MAP& map, const std::string& filename, AttributeHandler<typename PFP::VEC3, VERTEX>& position, CellMarker<EDGE>& polygons, CellMarker<FACE>& polygonsFaces);
/**
*
......
......@@ -211,7 +211,7 @@ void getPolygonFromSVG(std::string allcoords, std::vector<VEC3>& curPoly, bool&
}
template <typename PFP>
bool importSVG(typename PFP::MAP& map, const std::string& filename, typename PFP::TVEC3& position, CellMarker& polygons, CellMarker& polygonsFaces)
bool importSVG(typename PFP::MAP& map, const std::string& filename, AttributeHandler<typename PFP::VEC3, VERTEX>& position, CellMarker<EDGE>& polygons, CellMarker<FACE>& polygonsFaces)
{
typedef typename PFP::VEC3 VEC3;
typedef std::vector<VEC3 > POLYGON;
......@@ -343,9 +343,9 @@ bool importSVG(typename PFP::MAP& map, const std::string& filename, typename PFP
return false;
}
CellMarker brokenMark(map,EDGE);
AttributeHandler<float> edgeWidth = map.template addAttribute<float>(EDGE, "width");
AttributeHandler<NoMathAttribute<Geom::Plane3D<typename PFP::REAL> > > edgePlanes = map.template addAttribute<NoMathAttribute<Geom::Plane3D<typename PFP::REAL> > >(EDGE, "planes");
CellMarker<EDGE> brokenMark(map);
AttributeHandler<float, EDGE> edgeWidth = map.template addAttribute<float, EDGE>("width");
AttributeHandler<NoMathAttribute<Geom::Plane3D<typename PFP::REAL> >, EDGE> edgePlanes = map.template addAttribute<NoMathAttribute<Geom::Plane3D<typename PFP::REAL> >, EDGE>("planes");
/////////////////////////////////////////////////////////////////////////////////////////////
//create broken lines
......@@ -453,7 +453,7 @@ bool importSVG(typename PFP::MAP& map, const std::string& filename, typename PFP
/////////////////////////////////////////////////////////////////////////////////////////////
//add bounding box
CellMarker boundingBox(map,VERTEX);
CellMarker<VERTEX> boundingBox(map);
// Dart dBorder = map.newFace(4);
//
// VEC3 bbCenter = bb->center();
......@@ -512,7 +512,7 @@ bool importSVG(typename PFP::MAP& map, const std::string& filename, typename PFP
/////////////////////////////////////////////////////////////////////////////////////////////
//process broken lines
CellMarker eMTreated(map,EDGE);
CellMarker<EDGE> eMTreated(map);
for(Dart d = map.begin();d != map.end(); map.next(d))
{
if(brokenL.isMarked(d) && !eMTreated.isMarked(d))
......
#ifndef PARTCELL_H
#define PARTCELL_H
#include "particle_base.h"
#include "Algo/MovingObjects/particle_base.h"
#include "Algo/Geometry/inclusion.h"
#include "Geometry/intersection.h"
......@@ -32,7 +32,7 @@ class ParticleCell2D : public ParticleBase
public :
typedef typename PFP::MAP Map;
typedef typename PFP::VEC3 VEC3;
typedef typename PFP::TVEC3 TAB_POS;
typedef AttributeHandler<typename PFP::VEC3, VERTEX> TAB_POS;
Map& m;
......
......@@ -27,7 +27,7 @@ class ParticleCell2DMemo : public ParticleCell2D<PFP>
public :
typedef typename PFP::MAP Map;
typedef typename PFP::VEC3 VEC3;
typedef typename PFP::TVEC3 TAB_POS;
typedef AttributeHandler<typename PFP::VEC3, VERTEX> TAB_POS;
std::list<Dart> memo_cross;
......
......@@ -34,7 +34,7 @@ class ParticleCell2DAndHalf : public ParticleBase
public :
typedef typename PFP::MAP Map;
typedef typename PFP::VEC3 VEC3;
typedef typename PFP::TVEC3 TAB_POS;
typedef AttributeHandler<typename PFP::VEC3, VERTEX> TAB_POS;
Map& m;
......
......@@ -33,7 +33,7 @@ class ParticleCell3D : public ParticleBase
public :
typedef typename PFP::MAP Map;
typedef typename PFP::VEC3 VEC3;
typedef typename PFP::TVEC3 TAB_POS;
typedef AttributeHandler<typename PFP::VEC3, VERTEX> TAB_POS;
Map& m;
......
......@@ -52,7 +52,7 @@ public:
* @param map traversed map
* @param th current thread id
*/
FunctorMapThreaded(MAP& m, unsigned int th=0): FunctorMap<MAP>(m), m_threadId(th) {}
FunctorMapThreaded(MAP& m, unsigned int th = 0): FunctorMap<MAP>(m), m_threadId(th) {}
/**
* Method that duplicate the fonctor for each thread, typically:
......@@ -61,7 +61,6 @@ public:
* @param id thread id assigned to functor
*/
virtual FunctorMapThreaded<MAP>* duplicate(unsigned int id)=0;
};
/**
......@@ -71,7 +70,7 @@ template<typename MAP,typename T>
class FunctorMapThreadedResult: public FunctorMapThreaded<MAP>
{
public:
FunctorMapThreadedResult(MAP& m, unsigned int th=0): FunctorMapThreaded<MAP>(m,th) {}
FunctorMapThreadedResult(MAP& m, unsigned int th = 0): FunctorMapThreaded<MAP>(m,th) {}
/**
* get back result (used by foreach_xxx_res for filling vector of results
......@@ -79,23 +78,18 @@ public:
virtual T getResult() = 0;
};
/**
* Traverse orbits of a map in parallel. Use topological marker
* Functor application must be independant
* @param map the map
* @param orbit the orbit (VERTEX/EDGE/FACE/..
* @param func the functor to apply
* @param nbth number of thread to use
* @param szbuff size of buffers to store darts in each thread (default is 8192, use less for lower memory consumsion)
* @param needMarkers set to yes if you want that each thread use different markers (markers are allocated if necessary)
* @param good a selector
*/
template <typename PFP>
void foreach_orbit(typename PFP::MAP& map, unsigned int orbit, FunctorMapThreaded<typename PFP::MAP>& func, unsigned int nbth, unsigned int szbuff=8192, bool needMarkers=false, const FunctorSelect& good= allDarts);
template <typename PFP, unsigned int ORBIT>
void foreach_orbit(typename PFP::MAP& map, FunctorMapThreaded<typename PFP::MAP>& func, unsigned int nbth, unsigned int szbuff = 8192, bool needMarkers = false, const FunctorSelect& good = allDarts);
/**
* Traverse cells of a map in parallel. Use embedding marker
......@@ -108,9 +102,8 @@ void foreach_orbit(typename PFP::MAP& map, unsigned int orbit, FunctorMapThread
* @param needMarkers set to yes if you want that each thread use different markers (markers are allocated if necessary)
* @param good a selector
*/
template <typename PFP>
void foreach_cell(typename PFP::MAP& map, unsigned int cell, FunctorMapThreaded<typename PFP::MAP>& func, unsigned int nbth, unsigned int szbuff=8192, bool needMarkers=false, const FunctorSelect& good= allDarts);
template <typename PFP, unsigned int CELL>
void foreach_cell(typename PFP::MAP& map, FunctorMapThreaded<typename PFP::MAP>& func, unsigned int nbth, unsigned int szbuff = 8192, bool needMarkers = false, const FunctorSelect& good = allDarts);
/**
* Traverse darts of a map in parallel
......@@ -123,9 +116,7 @@ void foreach_cell(typename PFP::MAP& map, unsigned int cell, FunctorMapThreaded<
* @param good a selector
*/
template <typename PFP>
void foreach_dart(typename PFP::MAP& map, FunctorMapThreaded<typename PFP::MAP>& func, unsigned int nbth, unsigned int szbuff=8192, bool needMarkers=false, const FunctorSelect& good = allDarts);
void foreach_dart(typename PFP::MAP& map, FunctorMapThreaded<typename PFP::MAP>& func, unsigned int nbth, unsigned int szbuff = 8192, bool needMarkers = false, const FunctorSelect& good = allDarts);
/**
* Traverse orbits of a map in parallel. Use topo marker
......@@ -139,8 +130,8 @@ void foreach_dart(typename PFP::MAP& map, FunctorMapThreaded<typename PFP::MAP>&
* @param needMarkers set to yes if you want that each thread use different markers (markers are allocated if necessary)
* @param good a selector
*/
template <typename PFP, typename T>
void foreach_orbit_res(typename PFP::MAP& map, unsigned int orbit, FunctorMapThreadedResult<typename PFP::MAP, T>& func, unsigned int nbth, unsigned int szbuff, std::vector<T>& results, bool needMarkers=false, const FunctorSelect& good = allDarts);
template <typename PFP, unsigned int ORBIT, typename T>
void foreach_orbit_res(typename PFP::MAP& map, FunctorMapThreadedResult<typename PFP::MAP, T>& func, unsigned int nbth, unsigned int szbuff, std::vector<T>& results, bool needMarkers = false, const FunctorSelect& good = allDarts);
/**
* Traverse cells of a map in parallel. Use embedding marker
......@@ -154,8 +145,8 @@ void foreach_orbit_res(typename PFP::MAP& map, unsigned int orbit, FunctorMapTh
* @param needMarkers set to yes if you want that each thread use different markers (markers are allocated if necessary)
* @param good a selector
*/
template <typename PFP, typename T>
void foreach_cell_res(typename PFP::MAP& map, unsigned int cell, FunctorMapThreadedResult<typename PFP::MAP, T>& func, unsigned int nbth, unsigned int szbuff, std::vector<T>& results, bool needMarkers=false, const FunctorSelect& good = allDarts);
template <typename PFP, unsigned int CELL, typename T>
void foreach_cell_res(typename PFP::MAP& map, FunctorMapThreadedResult<typename PFP::MAP, T>& func, unsigned int nbth, unsigned int szbuff, std::vector<T>& results, bool needMarkers = false, const FunctorSelect& good = allDarts);
/**
* Traverse cells of a map in parallel. Use embedding marker
......@@ -170,10 +161,7 @@ void foreach_cell_res(typename PFP::MAP& map, unsigned int cell, FunctorMapThre
* @param good a selector
*/
template <typename PFP, typename T>
void foreach_dart_res(typename PFP::MAP& map, FunctorMapThreadedResult<typename PFP::MAP, T>& func, unsigned int nbth, unsigned int szbuff, std::vector<T>& results, bool needMarkers=false, const FunctorSelect& good = allDarts);
void foreach_dart_res(typename PFP::MAP& map, FunctorMapThreadedResult<typename PFP::MAP, T>& func, unsigned int nbth, unsigned int szbuff, std::vector<T>& results, bool needMarkers = false, const FunctorSelect& good = allDarts);
/**
* easy sum of returned result of foreach_xxx_res
......@@ -199,7 +187,6 @@ T maxResult(const std::vector<T>& res);
template <typename T>
T minResult(const std::vector<T>& res);
/**
* Class to encapsulate algorithm in a boost thread
* Usage:
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment