Commit 4b50f19b authored by Sylvain Thery's avatar Sylvain Thery

testing templates...

parent 6018ea78
......@@ -10,14 +10,14 @@ add_subdirectory(Geometry)
#add_subdirectory(Histogram)
#add_subdirectory(ImplicitHierarchicalMesh)
add_subdirectory(Import)
#add_subdirectory(LinearSolving)
add_subdirectory(LinearSolving)
add_subdirectory(MC)
add_subdirectory(Modelisation)
#add_subdirectory(MovingObjects)
add_subdirectory(MovingObjects)
#add_subdirectory(Multiresolution)
add_subdirectory(ProgressiveMesh)
add_subdirectory(Remeshing)
#add_subdirectory(Render)
add_subdirectory(Render)
add_subdirectory(Selection)
add_subdirectory(Simulation)
add_subdirectory(Tiling)
......
cmake_minimum_required(VERSION 2.6)
project(testing_algo_linearSolving)
add_executable( test_algo_linearSolving
algo_linearSolving.cpp
basic.cpp
)
target_link_libraries( test_algo_linearSolving
${CGoGN_LIBS} ${CGoGN_EXT_LIBS})
#include <iostream>
extern int test_basic();
int main()
{
test_basic();
return 0;
}
This diff is collapsed.
cmake_minimum_required(VERSION 2.6)
project(testing_algo_movingObjects)
add_executable( test_algo_movingObjects
algo_movingObjects.cpp
particle_cell_2D.cpp
particle_cell_2D_memo.cpp
particle_cell_2D_secured.cpp
particle_cell_2DandHalf.cpp
particle_cell_2DandHalf_memo.cpp
particle_cell_3D.cpp
)
target_link_libraries( test_algo_movingObjects
${CGoGN_LIBS} ${CGoGN_EXT_LIBS})
#include <iostream>
extern int test_particle_cell_2D();
extern int test_particle_cell_2D_memo();
extern int test_particle_cell_2D_secured();
extern int test_particle_cell_2DandHalf();
extern int test_particle_cell_2DandHalf_memo();
extern int test_particle_cell_3D();
int main()
{
test_particle_cell_2D();
test_particle_cell_2D_memo();
test_particle_cell_2D_secured();
test_particle_cell_2DandHalf();
test_particle_cell_2DandHalf_memo();
test_particle_cell_3D();
return 0;
}
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your *
* option) any later version. *
* *
* This library is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
* Web site: http://cgogn.unistra.fr/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#ifndef PARTBASE_H
#define PARTBASE_H
//#include "Geometry/vector_gen.h"
namespace CGoGN
{
namespace Algo
{
namespace MovingObjects
{
/* A particle base defines a position with a displacement function */
template <typename PFP>
class ParticleBase
{
protected:
typename PFP::VEC3 m_position ;
unsigned int m_state ;
public:
ParticleBase(const typename PFP::VEC3& position) :
m_position(position), m_state(FACE)
{
}
virtual ~ParticleBase()
{
}
void setState(unsigned int state)
{
m_state = state ;
}
unsigned int getState()
{
return m_state ;
}
bool move(const typename PFP::VEC3& position)
{
m_position = position ;
return true ;
}
const typename PFP::VEC3& getPosition() const
{
return m_position ;
}
} ;
} // namespace MovingObjects
} // namespace Algo
} // namespace CGoGN
#endif
#ifndef PARTCELL_H
#define PARTCELL_H
#include "Topology/generic/parameters.h"
#include "Topology/map/embeddedMap2.h"
#include "Topology/map/embeddedMap3.h"
#include "Topology/gmap/embeddedGMap2.h"
#include "Algo/MovingObjects/particle_base.h"
#include "Algo/Geometry/inclusion.h"
#include "Geometry/intersection.h"
#include "Algo/Geometry/orientation.h"
/* A particle cell is a particle base within a map, within a precise cell,
* the displacement function should indicate after each displacement
* wherein lies the new position of the particle
*/
#include "Algo/MovingObjects/particle_cell_2D.h"
namespace CGoGN
{
using namespace CGoGN;
namespace Algo
struct PFP1 : public PFP_STANDARD
{
typedef EmbeddedMap2 MAP;
};
namespace Surface
{
template class Algo::Surface::MovingObjects::ParticleCell2D<PFP1>;
namespace MovingObjects
{
#ifndef PARTCELL25D_H
enum
struct PFP2 : public PFP_DOUBLE
{
NO_CROSS, CROSS_EDGE, CROSS_OTHER
} ;
#endif
template <typename PFP>
class ParticleCell2D : public Algo::MovingObjects::ParticleBase<PFP>
{
public:
typedef typename PFP::MAP MAP ;
typedef typename PFP::VEC3 VEC3 ;
typedef VertexAttribute<VEC3, MAP> TAB_POS ;
MAP& m ;
const TAB_POS& positionAttribut ;
Dart d ;
Dart lastCrossed ;
unsigned int crossCell ;
ParticleCell2D(MAP& map, Dart belonging_cell, const VEC3& pos, const TAB_POS& tabPos) :
Algo::MovingObjects::ParticleBase<PFP>(pos),
m(map),
positionAttribut(tabPos),
d(belonging_cell),
lastCrossed(belonging_cell),
crossCell(NO_CROSS)
{
}
~ParticleCell2D()
{
}
Dart getCell()
{
return d ;
}
Geom::Orientation2D getOrientationEdge(const VEC3& point, Dart d) ;
typedef EmbeddedMap2 MAP;
};
void display() ;
template class Algo::Surface::MovingObjects::ParticleCell2D<PFP2>;
// template <unsigned int DD, typename TT>
// friend std::istream& operator>> (std::istream& in, Vector<DD,TT>& v) ;
VEC3 pointInFace(Dart d) ;
//
//struct PFP3 : public PFP_DOUBLE
//{
// typedef EmbeddedGMap2 MAP;
//};
//
//template class Algo::Surface::MovingObjects::ParticleCell2D<PFP3>;
VEC3 intersectLineEdge(const VEC3& pA, const VEC3& pB, Dart d) ;
Geom::Orientation2D getOrientationFace(VEC3 sourcePoint, Dart d) ;
virtual void vertexState(const VEC3& current) ;
virtual void edgeState(const VEC3& current, Geom::Orientation2D sideOfEdge = Geom::ALIGNED) ;
//just an orientation test : check which dart is aimed to leave the current face to reach an other position
Dart faceOrientationState(const VEC3& toward) ;
virtual void faceState(const VEC3& current) ;
void move(const VEC3& goal)
{
crossCell = NO_CROSS ;
if (!Geom::arePointsEquals(goal, this->getPosition()))
{
switch (this->getState())
{
case VERTEX :
vertexState(goal) ;
break ;
case EDGE :
edgeState(goal) ;
break ;
case FACE :
faceState(goal) ;
break ;
}
display() ;
}
else
{
// TODO Des petits pas répétés peuvent faire sortir de la cellule actuelle
this->Algo::MovingObjects::ParticleBase<PFP>::move(goal) ;
}
}
} ;
} // namespace MovingObjects
} // namespace Surface
} // namespace Algo
} // namespace CGoGN
#include "Algo/MovingObjects/particle_cell_2D.hpp"
int test_particle_cell_2D()
{
#endif
return 0;
}
#ifndef PARTCELL2DMEMO_H
#define PARTCELL2DMEMO_H
#include "Topology/generic/parameters.h"
#include "Topology/map/embeddedMap2.h"
#include "Topology/map/embeddedMap3.h"
#include "Topology/gmap/embeddedGMap2.h"
//#define DEBUG
#include "Algo/MovingObjects/particle_cell_2D.h"
#include "Algo/MovingObjects/particle_cell_2D_memo.h"
#include "Algo/Geometry/inclusion.h"
#include "Geometry/intersection.h"
#include "Geometry/orientation.h"
using namespace CGoGN;
#include <iostream>
/* A particle cell is a particle base within a map, within a precise cell, the displacement function should indicate
after each displacement wherein lies the new position of the particle */
namespace CGoGN
{
namespace Algo
struct PFP1 : public PFP_STANDARD
{
typedef EmbeddedMap2 MAP;
};
namespace Surface
{
template class Algo::Surface::MovingObjects::ParticleCell2DMemo<PFP1>;
namespace MovingObjects
{
template <typename PFP>
class ParticleCell2DMemo : public ParticleCell2D<PFP>
struct PFP2 : public PFP_DOUBLE
{
public:
typedef typename PFP::MAP MAP ;
typedef typename PFP::VEC3 VEC3;
typedef VertexAttribute<VEC3, MAP> TAB_POS ;
private:
ParticleCell2DMemo()
{
}
public:
typedef EmbeddedMap2 MAP;
};
ParticleCell2DMemo(MAP& map, Dart belonging_cell, VEC3 pos, const TAB_POS& tabPos) :
ParticleCell2D<PFP>(map, belonging_cell, pos, tabPos)
{
}
template class Algo::Surface::MovingObjects::ParticleCell2DMemo<PFP2>;
virtual ~ParticleCell2DMemo()
{
}
virtual void vertexState(const VEC3& current, CellMarkerMemo<MAP, FACE>& memo_cross) ;
virtual void edgeState(const VEC3& current, CellMarkerMemo<MAP, FACE>& memo_cross, Geom::Orientation2D sideOfEdge = Geom::ALIGNED) ;
//struct PFP3 : public PFP_DOUBLE
//{
// typedef EmbeddedGMap2 MAP;
//};
//
//template class Algo::Surface::MovingObjects::ParticleCell2DMemo<PFP3>;
//
virtual void faceState(const VEC3& current, CellMarkerMemo<MAP, FACE>& memo_cross) ;
std::vector<Dart> move(const VEC3& goal, CellMarkerMemo<MAP, FACE>& memo_cross) ;
std::vector<Dart> move(const VEC3& goal);
} ;
} // namespace MovingObjects
} // namespace Surface
} // namespace Algo
} // namespace CGoGN
int test_particle_cell_2D_memo()
{
#include "Algo/MovingObjects/particle_cell_2D_memo.hpp"
return 0;
}
#endif
#ifndef PARTCELL2DMEMOSECURED_H
#define PARTCELL2DMEMOSECURED_H
#include "Topology/generic/parameters.h"
#include "Topology/map/embeddedMap2.h"
#include "Topology/map/embeddedMap3.h"
#include "Topology/gmap/embeddedGMap2.h"
//#define DEBUG
#include "Algo/MovingObjects/particle_cell_2D_memo.h"
#include "Algo/MovingObjects/particle_cell_2D_secured.h"
#include "Algo/Geometry/inclusion.h"
#include "Geometry/intersection.h"
#include "Geometry/orientation.h"
using namespace CGoGN;
#include <iostream>
/* A particle cell secured : version of particle cell-memo where particles might go outside the navigation map
* this class should be used for debug mode only */
namespace CGoGN
{
namespace Algo
struct PFP1 : public PFP_STANDARD
{
typedef EmbeddedMap2 MAP;
};
namespace Surface
{
template class Algo::Surface::MovingObjects::ParticleCell2DSecured<PFP1>;
namespace MovingObjects
{
template <typename PFP>
class ParticleCell2DSecured : public ParticleCell2DMemo<PFP>
struct PFP2 : public PFP_DOUBLE
{
typedef typename PFP::MAP MAP ;
typedef typename PFP::VEC3 VEC3;
typedef VertexAttribute<VEC3, MAP> TAB_POS ;
private:
ParticleCell2DSecured()
{
std::cout << "Particle Secured : for debugging (unoptimized)" << std::endl;
}
public:
typedef EmbeddedMap2 MAP;
};
ParticleCell2DSecured(MAP& map, Dart belonging_cell, VEC3 pos, const TAB_POS& tabPos) :
ParticleCell2DMemo<PFP>(map, belonging_cell, pos, tabPos)
{
// std::cout << "Particle Memo : for debugging (unoptimized)" << std::endl;
}
template class Algo::Surface::MovingObjects::ParticleCell2DSecured<PFP2>;
~ParticleCell2DSecured()
{
}
virtual void vertexState(const VEC3& current, CellMarkerMemo<MAP, FACE>& memo_cross) ;
virtual void edgeState(const VEC3& current, CellMarkerMemo<MAP, FACE>& memo_cross, Geom::Orientation2D sideOfEdge = Geom::ALIGNED) ;
//struct PFP3 : public PFP_DOUBLE
//{
// typedef EmbeddedGMap2 MAP;
//};
//
//template class Algo::Surface::MovingObjects::ParticleCell2DSecured<PFP3>;
//
virtual void faceState(const VEC3& current, CellMarkerMemo<MAP, FACE>& memo_cross) ;
std::vector<Dart> move(const VEC3& goal) ;
std::vector<Dart> move(const VEC3& goal, CellMarkerMemo<MAP, FACE>& memo_cross) ;
} ;
} // namespace MovingObjects
} // namespace Surface
} // namespace Algo
} // namespace CGoGN
int test_particle_cell_2D_secured()
{
#include "Algo/MovingObjects/particle_cell_2D_secured.hpp"
return 0;
}
#endif
#ifndef PARTCELL25D_H
#define PARTCELL25D_H
#include "Topology/generic/parameters.h"
#include "Topology/map/embeddedMap2.h"
#include "Topology/map/embeddedMap3.h"
#include "Topology/gmap/embeddedGMap2.h"
#include "Algo/MovingObjects/particle_base.h"
#include "Algo/Geometry/inclusion.h"
#include "Algo/Geometry/plane.h"
#include "Geometry/intersection.h"
#include "Geometry/orientation.h"
#include "Algo/MovingObjects/particle_cell_2DandHalf.h"
#include <iostream>
using namespace CGoGN;
/* A particle cell is a particle base within a map, within a precise cell, the displacement function should indicate
after each displacement wherein lies the new position of the particle */
namespace CGoGN
{
namespace Algo
struct PFP1 : public PFP_STANDARD
{
typedef EmbeddedMap2 MAP;
};
namespace Surface
{
template class Algo::Surface::MovingObjects::ParticleCell2DAndHalf<PFP1>;
namespace MovingObjects
{
#ifndef PARTCELL_H
enum
struct PFP2 : public PFP_DOUBLE
{
NO_CROSS,
CROSS_EDGE,
CROSS_OTHER
typedef EmbeddedMap2 MAP;
};
#endif
template <typename PFP>
class ParticleCell2DAndHalf : public Algo::MovingObjects::ParticleBase<PFP>
{
public :
typedef typename PFP::MAP MAP;
typedef typename PFP::VEC3 VEC3;
typedef VertexAttribute<VEC3, MAP> TAB_POS;
MAP& m;
const TAB_POS& m_positions;
Dart d;
Dart lastCrossed;
unsigned int state;
unsigned int crossCell ;
float distance;
ParticleCell2DAndHalf(MAP& map) : m(map)
{}
ParticleCell2DAndHalf(MAP& map, Dart belonging_cell, VEC3 pos, const TAB_POS& tabPos) :
Algo::MovingObjects::ParticleBase<PFP>(pos),
m(map),
m_positions(tabPos),
d(belonging_cell),
lastCrossed(belonging_cell),
state(FACE),
crossCell(NO_CROSS),
distance(0)
{}
template class Algo::Surface::MovingObjects::ParticleCell2DAndHalf<PFP2>;
Dart getCell() { return d; }
float getDistance() { return distance; }
//
//struct PFP3 : public PFP_DOUBLE
//{
// typedef EmbeddedGMap2 MAP;
//};
//
//template class Algo::Surface::MovingObjects::ParticleCell2DAndHalf<PFP3>;
Geom::Orientation3D getOrientationEdge(const VEC3& point, Dart d);
void display();
VEC3 pointInFace(Dart d);
VEC3 intersectLineEdge(const VEC3& pA, const VEC3& pB, Dart d);
Geom::Orientation3D getOrientationFace(VEC3 sourcePoint, VEC3 point, Dart d);
void vertexState(VEC3 current);
void edgeState(VEC3 current, Geom::Orientation3D sideOfEdge = Geom::ON);
void faceState(VEC3 current);
virtual unsigned int getState()
{
return state;
}
void move(const VEC3& newCurrent)
{
distance = 0 ;
crossCell = NO_CROSS ;
if(!Geom::arePointsEquals(newCurrent, this->getPosition()))
{
switch(state) {
case VERTEX : vertexState(newCurrent); break;
case EDGE : edgeState(newCurrent); break;
case FACE : faceState(newCurrent); break;
}
// display();
}
else
this->Algo::MovingObjects::ParticleBase<PFP>::move(newCurrent);
}
};
} // namespace MovingObjects
} // namespace Surface
} // namespace Algo
int test_particle_cell_2DandHalf()
{
} // namespace CGoGN
return 0;
}
#include "Algo/MovingObjects/particle_cell_2DandHalf.hpp"
#endif
#ifndef PARTCELL2DANDHALFMEMO_H
#define PARTCELL2DANDHALFMEMO_H
#include "Topology/generic/parameters.h"
#include "Topology/map/embeddedMap2.h"
#include "Topology/map/embeddedMap3.h"
#include "Topology/gmap/embeddedGMap2.h"
#include "Algo/MovingObjects/particle_cell_2DandHalf.h"
#include "Algo/Geometry/inclusion.h"
#include "Geometry/intersection.h"
#include "Geometry/orientation.h"
#include "Algo/MovingObjects/particle_cell_2DandHalf_memo.h"
#include <iostream>
using namespace CGoGN;
/* A particle cell is a particle base within a map, within a precise cell, the displacement function should indicate
after each displacement wherein lies the new position of the particle */
namespace CGoGN
{
namespace Algo