Commit 089fc32b authored by Sylvain Thery's avatar Sylvain Thery

add ray selection on dart of topo

add cone selection on vertex n edge
parent 87367ef4
......@@ -124,6 +124,9 @@ protected:
*/
DartAttribute<unsigned int> m_attIndex;
Geom::Vec3f* m_bufferDartPosition;
/**
* save colors
*/
......@@ -308,6 +311,13 @@ public:
*/
void svgout2D(const std::string& filename, const glm::mat4& model, const glm::mat4& proj);
template<typename PFP>
Dart coneSelection(typename PFP::MAP& map, const Geom::Vec3f& rayA, const Geom::Vec3f& rayAB, float angle, const FunctorSelect& good=allDarts);
template<typename PFP>
Dart raySelection(typename PFP::MAP& map, const Geom::Vec3f& rayA, const Geom::Vec3f& rayAB, float distmax, const FunctorSelect& good=allDarts);
protected:
/**
* update all drawing buffers to render a dual map
......
......@@ -33,6 +33,8 @@
#include "Topology/generic/traversorCell.h"
#include "Algo/Geometry/centroid.h"
#include "Geometry/distances.h"
namespace CGoGN
{
......@@ -349,10 +351,16 @@ void Topo3Render::updateDataGMap3(typename PFP::MAP& mapx, const VertexAttribute
GLvoid* ColorDartsBuffer = glMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE);
VEC3* colorDartBuf = reinterpret_cast<VEC3*>(ColorDartsBuffer);
m_vbo0->bind();
glBufferData(GL_ARRAY_BUFFER, 2*m_nbDarts*sizeof(VEC3), 0, GL_STREAM_DRAW);
GLvoid* PositionDartsBuffer = glMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE);
VEC3* positionDartBuf = reinterpret_cast<VEC3*>(PositionDartsBuffer);
if (m_bufferDartPosition!=NULL)
delete m_bufferDartPosition;
m_bufferDartPosition = new Geom::Vec3f[2*m_nbDarts];
VEC3* positionDartBuf = reinterpret_cast<VEC3*>(m_bufferDartPosition);
// m_vbo0->bind();
// glBufferData(GL_ARRAY_BUFFER, 2*m_nbDarts*sizeof(VEC3), 0, GL_STREAM_DRAW);
// GLvoid* PositionDartsBuffer = glMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE);
// VEC3* positionDartBuf = reinterpret_cast<VEC3*>(PositionDartsBuffer);
std::vector<Dart> vecDartFaces;
vecDartFaces.reserve(m_nbDarts/6);
......@@ -433,7 +441,9 @@ void Topo3Render::updateDataGMap3(typename PFP::MAP& mapx, const VertexAttribute
}
m_vbo0->bind();
glUnmapBuffer(GL_ARRAY_BUFFER);
glBufferData(GL_ARRAY_BUFFER, 2*m_nbDarts*sizeof(VEC3), m_bufferDartPosition, GL_STREAM_DRAW);
// m_vbo0->bind();
// glUnmapBuffer(GL_ARRAY_BUFFER);
m_vbo4->bind();
glUnmapBuffer(GL_ARRAY_BUFFER);
......@@ -764,6 +774,123 @@ void Topo3Render::computeDartMiddlePositions(typename PFP::MAP& map, DartAttribu
// glUnmapBuffer(GL_ARRAY_BUFFER);
//}
template<typename PFP>
Dart Topo3Render::coneSelection(typename PFP::MAP& map, const Geom::Vec3f& rayA, const Geom::Vec3f& rayAB, float angle, const FunctorSelect& good)
{
float AB2 = rayAB*rayAB;
Dart dFinal;
double sin2 = sin(M_PI/180.0 * angle);
sin2 = sin2*sin2;
double dist2 = std::numeric_limits<double>::max();
for(Dart d = map.begin(); d!=map.end(); map.next(d))
{
// get back position of segment PQ
const Geom::Vec3f& P = m_bufferDartPosition[m_attIndex[d]];
const Geom::Vec3f& Q =m_bufferDartPosition[m_attIndex[d]+1];
float ld2 = Geom::squaredDistanceLine2Seg(rayA, rayAB, AB2, P, Q);
Geom::Vec3f V = (P+Q)/2.0f - rayA;
double d2 = double(V*V);
double s2 = double(ld2) / d2;
if (s2 < sin2)
{
if (d2<dist2)
{
dist2 = d2;
dFinal = d;
}
}
}
return dFinal;
}
template<typename PFP>
Dart Topo3Render::raySelection(typename PFP::MAP& map, const Geom::Vec3f& rayA, const Geom::Vec3f& rayAB, float dmax, const FunctorSelect& good)
{
float AB2 = rayAB*rayAB;
Dart dFinal;
float dm2 = dmax*dmax;
double dist2 = std::numeric_limits<double>::max();
for(Dart d = map.begin(); d!=map.end(); map.next(d))
{
// get back position of segment PQ
const Geom::Vec3f& P = m_bufferDartPosition[m_attIndex[d]];
const Geom::Vec3f& Q =m_bufferDartPosition[m_attIndex[d]+1];
float ld2 = Geom::squaredDistanceLine2Seg(rayA, rayAB, AB2, P, Q);
if (ld2<dm2)
{
Geom::Vec3f V = (P+Q)/2.0f - rayA;
double d2 = double(V*V);
if (d2<dist2)
{
dist2 = d2;
dFinal = d;
}
}
}
return dFinal;
}
// DART RAY SELECTION
//template<typename PFP>
//void edgesConeSelection(, const VertexAttribute<typename PFP::VEC3>& position, const typename PFP::VEC3& rayA, const typename PFP::VEC3& rayAB, float angle, std::vector<Dart>& vecEdges, const FunctorSelect& good)
//{
// typename PFP::REAL AB2 = rayAB * rayAB;
//
// double sin2 = sin(M_PI/180.0 * angle);
// sin2 = sin2*sin2;
//
// // recuperation des aretes intersectees
// vecEdges.reserve(256);
// vecEdges.clear();
//
// TraversorE<typename PFP::MAP> trav(map);
// for(Dart d = trav.begin(); d!=trav.end(); d = trav.next())
// {
// // get back position of segment PQ
// const typename PFP::VEC3& P = position[d];
// const typename PFP::VEC3& Q = position[map.phi1(d)];
// // the three distance to P, Q and (PQ) not used here
// float ld2 = Geom::squaredDistanceLine2Seg(rayA, rayAB, AB2, P, Q);
// typename PFP::VEC3 V = P - rayA;
// double s2 = double(ld2) / double(V*V);
// if (s2 < sin2)
// vecEdges.push_back(d);
// }
//
// typedef std::pair<typename PFP::REAL, Dart> DartDist;
// std::vector<DartDist> distndart;
//
// unsigned int nbi = vecEdges.size();
// distndart.resize(nbi);
//
// // compute all distances to observer for each middle of intersected edge
// // and put them in a vector for sorting
// for (unsigned int i = 0; i < nbi; ++i)
// {
// Dart d = vecEdges[i];
// distndart[i].second = d;
// typename PFP::VEC3 V = (position[d] + position[map.phi1(d)]) / typename PFP::REAL(2);
// V -= rayA;
// distndart[i].first = V.norm2();
// }
//
// // sort the vector of pair dist/dart
// std::sort(distndart.begin(), distndart.end(), distndartOrdering<PFP>);
//
// // store sorted darts in returned vector
// for (unsigned int i = 0; i < nbi; ++i)
// vecEdges[i] = distndart[i].second;
//}
} //end namespace GL2
} //end namespace Render
......
......@@ -108,6 +108,8 @@ protected:
*/
DartAttribute<unsigned int> m_attIndex;
Geom::Vec3f* m_bufferDartPosition;
Utils::ShaderSimpleColor* m_shader1;
Utils::ShaderColorPerVertex* m_shader2;
......@@ -231,6 +233,15 @@ public:
template<typename PFP>
Dart picking(typename PFP::MAP& map, int x, int y, const FunctorSelect& good=allDarts);
template<typename PFP>
Dart coneSelection(typename PFP::MAP& map, const Geom::Vec3f& rayA, const Geom::Vec3f& rayAB, float angle, const FunctorSelect& good=allDarts);
template<typename PFP>
Dart raySelection(typename PFP::MAP& map, const Geom::Vec3f& rayA, const Geom::Vec3f& rayAB, float distmax, const FunctorSelect& good=allDarts);
template <typename PFP>
void updateData(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& positions, float ke, float kf, const FunctorSelect& good = allDarts);
......
......@@ -30,6 +30,8 @@
#include "Topology/map/embeddedMap2.h"
#include "Topology/gmap/embeddedGMap2.h"
#include "Geometry/distances.h"
namespace CGoGN
{
......@@ -94,10 +96,15 @@ void TopoRender::updateDataMap(typename PFP::MAP& mapx, const VertexAttribute<ty
GLvoid* ColorDartsBuffer = glMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE);
VEC3* colorDartBuf = reinterpret_cast<VEC3*>(ColorDartsBuffer);
m_vbo0->bind();
glBufferData(GL_ARRAY_BUFFER, 2*m_nbDarts*sizeof(VEC3), 0, GL_STREAM_DRAW);
GLvoid* PositionDartsBuffer = glMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE);
VEC3* positionDartBuf = reinterpret_cast<VEC3*>(PositionDartsBuffer);
// m_vbo0->bind();
// glBufferData(GL_ARRAY_BUFFER, 2*m_nbDarts*sizeof(VEC3), 0, GL_STREAM_DRAW);
// GLvoid* PositionDartsBuffer = glMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE);
// VEC3* positionDartBuf = reinterpret_cast<VEC3*>(PositionDartsBuffer);
if (m_bufferDartPosition!=NULL)
delete m_bufferDartPosition;
m_bufferDartPosition = new Geom::Vec3f[2*m_nbDarts];
VEC3* positionDartBuf = reinterpret_cast<VEC3*>(m_bufferDartPosition);
std::vector<VEC3> vecPos;
vecPos.reserve(16);
......@@ -158,7 +165,8 @@ void TopoRender::updateDataMap(typename PFP::MAP& mapx, const VertexAttribute<ty
}
m_vbo0->bind();
glUnmapBuffer(GL_ARRAY_BUFFER);
glBufferData(GL_ARRAY_BUFFER, 2*m_nbDarts*sizeof(VEC3), m_bufferDartPosition, GL_STREAM_DRAW);
// glUnmapBuffer(GL_ARRAY_BUFFER);
m_vbo3->bind();
glUnmapBuffer(GL_ARRAY_BUFFER);
......@@ -411,6 +419,67 @@ Dart TopoRender::picking(typename PFP::MAP& map,int x, int y, const FunctorSelec
}
template<typename PFP>
Dart TopoRender::coneSelection(typename PFP::MAP& map, const Geom::Vec3f& rayA, const Geom::Vec3f& rayAB, float angle, const FunctorSelect& good)
{
float AB2 = rayAB*rayAB;
Dart dFinal;
double sin2 = sin(M_PI/180.0 * angle);
sin2 = sin2*sin2;
double dist2 = std::numeric_limits<double>::max();
for(Dart d = map.begin(); d!=map.end(); map.next(d))
{
// get back position of segment PQ
const Geom::Vec3f& P = m_bufferDartPosition[m_attIndex[d]];
const Geom::Vec3f& Q =m_bufferDartPosition[m_attIndex[d]+1];
float ld2 = Geom::squaredDistanceLine2Seg(rayA, rayAB, AB2, P, Q);
Geom::Vec3f V = (P+Q)/2.0f - rayA;
double d2 = double(V*V);
double s2 = double(ld2) / d2;
if (s2 < sin2)
{
if (d2<dist2)
{
dist2 = d2;
dFinal = d;
}
}
}
return dFinal;
}
template<typename PFP>
Dart TopoRender::raySelection(typename PFP::MAP& map, const Geom::Vec3f& rayA, const Geom::Vec3f& rayAB, float dmax, const FunctorSelect& good)
{
float AB2 = rayAB*rayAB;
Dart dFinal;
float dm2 = dmax*dmax;
double dist2 = std::numeric_limits<double>::max();
for(Dart d = map.begin(); d!=map.end(); map.next(d))
{
// get back position of segment PQ
const Geom::Vec3f& P = m_bufferDartPosition[m_attIndex[d]];
const Geom::Vec3f& Q =m_bufferDartPosition[m_attIndex[d]+1];
float ld2 = Geom::squaredDistanceLine2Seg(rayA, rayAB, AB2, P, Q);
if (ld2<dm2)
{
Geom::Vec3f V = (P+Q)/2.0f - rayA;
double d2 = double(V*V);
if (d2<dist2)
{
dist2 = d2;
dFinal = d;
}
}
}
return dFinal;
}
}//end namespace GL2
}//end namespace Algo
......
......@@ -38,139 +38,139 @@ namespace Algo
namespace Selection
{
template <typename PFP>
class FuncFaceInter: public FunctorMap<typename PFP::MAP>
{
typedef typename PFP::MAP MAP;
protected:
std::vector<Dart>& m_faces;
std::vector<typename PFP::VEC3>& m_Ipoints ;
const typename PFP::VEC3& m_A;
const typename PFP::VEC3& m_AB;
const VertexAttribute<typename PFP::VEC3>& m_positions;
public:
/**
* @param map the map
* @param f vector of selected darts
* @param A first point of ray
* @param AB direction of ray
*/
FuncFaceInter(MAP& map, const VertexAttribute<typename PFP::VEC3>& position, std::vector<Dart>& f, std::vector<typename PFP::VEC3>& ip, const typename PFP::VEC3& A, const typename PFP::VEC3& AB):
FunctorMap<typename PFP::MAP>(map), m_faces(f), m_Ipoints(ip), m_A(A), m_AB(AB), m_positions(position)
{}
bool operator()(Dart d)
{
const typename PFP::VEC3& Ta = m_positions[d];
Dart dd = this->m_map.phi1(d);
Dart ddd = this->m_map.phi1(dd);
bool notfound = true;
do
{
// get back position of triangle Ta,Tb,Tc
const typename PFP::VEC3& Tb = m_positions[dd];
const typename PFP::VEC3& Tc = m_positions[ddd];
typename PFP::VEC3 I;
// if (Geom::intersectionLineTriangle<typename PFP::VEC3>(m_A, m_AB, Ta, Tb, Tc, I))
if (Geom::intersectionRayTriangleOpt<typename PFP::VEC3>(m_A, m_AB, Ta, Tb, Tc, I))
{
m_faces.push_back(d);
m_Ipoints.push_back(I);
notfound = false;
}
// next triangle if we are in polygon
dd = ddd;
ddd = this->m_map.phi1(dd);
} while ((ddd != d) && notfound);
return false;
}
};
template <typename PFP>
class FuncEdgeInter: public FunctorMap<typename PFP::MAP>
{
typedef typename PFP::MAP MAP;
protected:
std::vector<Dart>& m_edges;
const typename PFP::VEC3& m_A;
const typename PFP::VEC3& m_AB;
float m_AB2;
float m_distMax;
const VertexAttribute<typename PFP::VEC3>& m_positions;
public:
/**
* @param map the map
* @param e vector of selected darts
* @param A first point of ray
* @param AB direction of ray
* @param AB2 squared length of direction
* @param dm2 max distance from ray squared
*/
FuncEdgeInter(MAP& map, const VertexAttribute<typename PFP::VEC3>& position, std::vector<Dart>& e, const typename PFP::VEC3& A, const typename PFP::VEC3& AB, typename PFP::REAL AB2, typename PFP::REAL dm2):
FunctorMap<typename PFP::MAP>(map), m_edges(e), m_A(A), m_AB(AB), m_AB2(AB2), m_distMax(dm2), m_positions(position)
{}
bool operator()(Dart d)
{
// get back position of segment PQ
const typename PFP::VEC3& P = m_positions[d];
Dart dd = this->m_map.phi1(d);
const typename PFP::VEC3& Q = m_positions[dd];
// the three distance to P, Q and (PQ) not used here
float dist = Geom::squaredDistanceLine2Seg(m_A, m_AB, m_AB2, P, Q);
if (dist < m_distMax)
{
m_edges.push_back(d);
}
return false;
}
};
template <typename PFP>
class FuncVertexInter: public FunctorMap<typename PFP::MAP>
{
typedef typename PFP::MAP MAP;
protected:
std::vector<Dart>& m_vertices;
const typename PFP::VEC3& m_A;
const typename PFP::VEC3& m_AB;
float m_AB2;
float m_distMax;
const VertexAttribute<typename PFP::VEC3>& m_positions;
public:
/**
* @param map the map
* @param v vector of selected darts
* @param A first point of ray
* @param AB direction of ray
* @param AB2 squared length of direction
* @param dm2 max distance from ray squared
*/
FuncVertexInter(MAP& map, const VertexAttribute<typename PFP::VEC3>& position, std::vector<Dart>& v, const typename PFP::VEC3& A, const typename PFP::VEC3& AB, typename PFP::REAL AB2, typename PFP::REAL dm2):
FunctorMap<typename PFP::MAP>(map), m_vertices(v), m_A(A), m_AB(AB), m_AB2(AB2), m_distMax(dm2), m_positions(position)
{}
bool operator()(Dart d)
{
const typename PFP::VEC3& P = m_positions[d];
float dist = Geom::squaredDistanceLine2Point(m_A, m_AB, m_AB2, P);
if (dist < m_distMax)
{
m_vertices.push_back(d);
}
return false;
}
};
//
//template <typename PFP>
//class FuncFaceInter: public FunctorMap<typename PFP::MAP>
//{
// typedef typename PFP::MAP MAP;
//
//protected:
// std::vector<Dart>& m_faces;
// std::vector<typename PFP::VEC3>& m_Ipoints ;
// const typename PFP::VEC3& m_A;
// const typename PFP::VEC3& m_AB;
// const VertexAttribute<typename PFP::VEC3>& m_positions;
//
//public:
// /**
// * @param map the map
// * @param f vector of selected darts
// * @param A first point of ray
// * @param AB direction of ray
// */
// FuncFaceInter(MAP& map, const VertexAttribute<typename PFP::VEC3>& position, std::vector<Dart>& f, std::vector<typename PFP::VEC3>& ip, const typename PFP::VEC3& A, const typename PFP::VEC3& AB):
// FunctorMap<typename PFP::MAP>(map), m_faces(f), m_Ipoints(ip), m_A(A), m_AB(AB), m_positions(position)
// {}
//
// bool operator()(Dart d)
// {
// const typename PFP::VEC3& Ta = m_positions[d];
//
// Dart dd = this->m_map.phi1(d);
// Dart ddd = this->m_map.phi1(dd);
// bool notfound = true;
// do
// {
// // get back position of triangle Ta,Tb,Tc
// const typename PFP::VEC3& Tb = m_positions[dd];
// const typename PFP::VEC3& Tc = m_positions[ddd];
// typename PFP::VEC3 I;
//// if (Geom::intersectionLineTriangle<typename PFP::VEC3>(m_A, m_AB, Ta, Tb, Tc, I))
// if (Geom::intersectionRayTriangleOpt<typename PFP::VEC3>(m_A, m_AB, Ta, Tb, Tc, I))
// {
// m_faces.push_back(d);
// m_Ipoints.push_back(I);
// notfound = false;
// }
// // next triangle if we are in polygon
// dd = ddd;
// ddd = this->m_map.phi1(dd);
// } while ((ddd != d) && notfound);
// return false;
// }
//};
//
//
//template <typename PFP>
//class FuncEdgeInter: public FunctorMap<typename PFP::MAP>
//{
// typedef typename PFP::MAP MAP;
//
//protected:
// std::vector<Dart>& m_edges;
// const typename PFP::VEC3& m_A;
// const typename PFP::VEC3& m_AB;
// float m_AB2;
// float m_distMax;
// const VertexAttribute<typename PFP::VEC3>& m_positions;
//
//public:
// /**
// * @param map the map
// * @param e vector of selected darts
// * @param A first point of ray
// * @param AB direction of ray
// * @param AB2 squared length of direction
// * @param dm2 max distance from ray squared
// */
// FuncEdgeInter(MAP& map, const VertexAttribute<typename PFP::VEC3>& position, std::vector<Dart>& e, const typename PFP::VEC3& A, const typename PFP::VEC3& AB, typename PFP::REAL AB2, typename PFP::REAL dm2):
// FunctorMap<typename PFP::MAP>(map), m_edges(e), m_A(A), m_AB(AB), m_AB2(AB2), m_distMax(dm2), m_positions(position)
// {}
//
// bool operator()(Dart d)
// {
// // get back position of segment PQ
// const typename PFP::VEC3& P = m_positions[d];
// Dart dd = this->m_map.phi1(d);
// const typename PFP::VEC3& Q = m_positions[dd];
// // the three distance to P, Q and (PQ) not used here
// float dist = Geom::squaredDistanceLine2Seg(m_A, m_AB, m_AB2, P, Q);
//
// if (dist < m_distMax)
// {
// m_edges.push_back(d);
// }
// return false;
// }
//};
//
//
//template <typename PFP>
//class FuncVertexInter: public FunctorMap<typename PFP::MAP>
//{
// typedef typename PFP::MAP MAP;
//
//protected:
// std::vector<Dart>& m_vertices;
// const typename PFP::VEC3& m_A;
// const typename PFP::VEC3& m_AB;
// float m_AB2;
// float m_distMax;
// const VertexAttribute<typename PFP::VEC3>& m_positions;
//public:
// /**
// * @param map the map
// * @param v vector of selected darts
// * @param A first point of ray
// * @param AB direction of ray
// * @param AB2 squared length of direction
// * @param dm2 max distance from ray squared
// */
// FuncVertexInter(MAP& map, const VertexAttribute<typename PFP::VEC3>& position, std::vector<Dart>& v, const typename PFP::VEC3& A, const typename PFP::VEC3& AB, typename PFP::REAL AB2, typename PFP::REAL dm2):
// FunctorMap<typename PFP::MAP>(map), m_vertices(v), m_A(A), m_AB(AB), m_AB2(AB2), m_distMax(dm2), m_positions(position)
// {}
//
// bool operator()(Dart d)
// {
// const typename PFP::VEC3& P = m_positions[d];
// float dist = Geom::squaredDistanceLine2Point(m_A, m_AB, m_AB2, P);
// if (dist < m_distMax)
// {
// m_vertices.push_back(d);
// }
// return false;
// }
//};
/**
* Functor which store the dart that correspond to the subpart of face
......
......@@ -149,7 +149,7 @@ void edgesConeSelection(typename PFP::MAP& map, const VertexAttribute<typename P
*/
template<typename PFP>
Dart verticesBubbleSelection(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& position,
const typename PFP::VEC3& cursor, PFP::REAL radiusMax,
const typename PFP::VEC3& cursor, typename PFP::REAL radiusMax,
const FunctorSelect& good=allDarts);
......@@ -163,7 +163,7 @@ Dart verticesBubbleSelection(typename PFP::MAP& map, const VertexAttribute<typen
*/
template<typename PFP>
Dart edgesBubbleSelection(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& position,
const typename PFP::VEC3& cursor, PFP::REAL radiusMax,
const typename PFP::VEC3& cursor, typename PFP::REAL radiusMax,
const FunctorSelect& good=allDarts);
......
......@@ -24,6 +24,9 @@
#include <algorithm>
#include <set>
#include "Geometry/distances.h"
#include "Geometry/intersection.h"
#include "Algo/Geometry/centroid.h"
namespace CGoGN
{
......@@ -43,7 +46,7 @@ namespace Selection
* @param vecFaces (out) vector to store the darts of intersected faces
*/
template<typename PFP>
void facesRaySelection(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& position, const FunctorSelect& good, const typename PFP::VEC3& rayA, const typename PFP::VEC3& rayAB, std::vector<Dart>& vecFaces)
void facesRaySelection(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& position, const typename PFP::VEC3& rayA, const typename PFP::VEC3& rayAB, std::vector<Dart>& vecFaces, const FunctorSelect& good)
{
std::vector<typename PFP::VEC3> iPoints;
......@@ -496,7 +499,7 @@ void edgesConeSelection(typename PFP::MAP& map, const VertexAttribute<typename P
const typename PFP::VEC3& Q = position[map.phi1(d)];
// the three distance to P, Q and (PQ) not used here
float ld2 = Geom::squaredDistanceLine2Seg(rayA, rayAB, AB2, P, Q);
typename PFP::VEC3 V = P - rayA;
typename PFP::VEC3 V = (P+Q)/2.0f - rayA;
double s2 = double(ld2) / double(V*V);
if (s2 < sin2)
vecEdges.push_back(d);
......@@ -530,7 +533,7 @@ void edgesConeSelection(typename PFP::MAP& map, const VertexAttribute<typename P
template<typename PFP>
Dart verticesBubbleSelection(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& position, const typename PFP::VEC3& cursor, PFP::REAL radiusMax, const FunctorSelect& good=allDarts)
Dart verticesBubbleSelection(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& position, const typename PFP::VEC3& cursor, typename PFP::REAL radiusMax, const FunctorSelect& good=allDarts)
{
typename PFP::REAL l2max = radiusMax*radiusMax;
typename PFP::REAL l2min(std::numeric_limits<float>::max());
......@@ -552,7 +555,7 @@ Dart verticesBubbleSelection(typename PFP::MAP& map, const VertexAttribute<typen
template<typename PFP>
Dart edgesBubbleSelection(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& position, const typename PFP::VEC3& cursor, PFP::REAL radiusMax, const FunctorSelect& good=allDarts)
Dart edgesBubbleSelection(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& position, const typename PFP::VEC3& cursor, typename PFP::REAL radiusMax, const FunctorSelect& good=allDarts)
{
typename PFP::REAL l2max = radiusMax*radiusMax;
typename PFP::REAL l2min(std::numeric_limits<float>::max());
......
......@@ -49,7 +49,8 @@ Topo3Render::Topo3Render():
m_topo_dart_width(2.0f),
m_topo_relation_width(3.0f),
m_color_save(NULL),
m_dartsColor(1.0f,1.0f,1.0f)
m_dartsColor(1.0f,1.0f,1.0f),
m_bufferDartPosition(NULL)
{
m_vbo0 = new Utils::VBO();
m_vbo1 = new Utils::VBO();
......@@ -97,6 +98,9 @@ Topo3Render::~Topo3Render()
{
delete[] m_color_save;
}
if (m_bufferDartPosition!=NULL)
delete[] m_bufferDartPosition;
}
void Topo3Render::setDartWidth(float dw)
......@@ -451,7 +455,6 @@ void Topo3Render::toSVG(Utils::SVG::SVGOut& svg)
}
}//end namespace GL2
}//end namespace Render
......
......@@ -43,7 +43,8 @@ TopoRender::TopoRender():
m_nbRel2(0),
m_topo_dart_width(2.0f),
m_topo_relation_width(3.0f),
m_dartsColor(1.0f,1.0f,1.0f)
m_dartsColor(1.0f,1.0f,1.0f),
m_bufferDartPosition(NULL)
{
m_vbo0 = new Utils::VBO();
m_vbo1 = new Utils::VBO();
......@@ -83,6 +84,9 @@ TopoRender::~TopoRender()
if (m_attIndex.map() != NULL)
static_cast<AttribMap*>(m_attIndex.map())->removeAttribute(m_attIndex);