Simplified stuff, and removed useless template (enabled template

deduction)
This commit is contained in:
Thomas FORGIONE 2015-03-15 18:30:19 +01:00
parent 5736c0b410
commit ba8cf18779
10 changed files with 95 additions and 88 deletions

View File

@ -130,7 +130,7 @@ bool whichSide(geo::Vector<T,4> const& plane, geo::Vector3<T> const& point);
/// \return the caracteristic elements of the plane a, b, c, d in the plane equation : ax + by + cz + d = 0.)
/////////////////////////////////////////////////////////
template<typename T>
geo::Vector<float,4> closestPlane(std::vector<geo::Vector3<T>> const& points);
geo::Vector<T,4> closestPlane(std::vector<geo::Vector3<T>> const& points);
} // namespace geo

View File

@ -210,7 +210,7 @@ float distanceToSegment(T1 const& v, T2 const& p1, T3 const& p2)
}
template<typename T>
geo::Vector<float,4> closestPlane(std::vector<geo::Vector3<T>> const& points)
geo::Vector4<T> closestPlane(std::vector<geo::Vector3<T>> const& points)
{
// for 3 points we just compute the plane that contains the 3 points
if (points.size() == 3)
@ -218,7 +218,7 @@ geo::Vector<float,4> closestPlane(std::vector<geo::Vector3<T>> const& points)
auto vec = crossProduct(points[1] - points[0], points[2] - points[0]);
vec /= vec.norm();
float t = - (points[0].x()*vec.x() + points[0].y()*vec.y() + points[0].z()*vec.z());
return geo::Vector<float,4>{vec.x(), vec.y(), vec.z(), t};
return geo::Vector4f{vec.x(), vec.y(), vec.z(), t};
}
// for more points we use an PCA decomposition to find the best plane
else
@ -242,12 +242,12 @@ geo::Vector<float,4> closestPlane(std::vector<geo::Vector3<T>> const& points)
Eigen::Vector3f n = v1.cross(v2);
return( geo::Vector<float,4>{n(0),n(1),n(2), -n.dot(m.colwise().mean())} );
return( geo::Vector4f{n(0),n(1),n(2), -n.dot(m.colwise().mean())} );
}
}
template<typename T>
bool whichSide(geo::Vector<float,4> const& plane, geo::Vector3<float> const& point)
bool whichSide(geo::Vector4<T> const& plane, geo::Vector3<T> const& point)
{
return plane.x()*point.x() + plane.y()*point.y() + plane.z()*point.z() < - plane.t();
}

View File

@ -377,6 +377,13 @@ using Vector2 = Vector<T,2>;
template<typename T>
using Vector3 = Vector<T,3>;
/////////////////////////////////////////////////////////////////
/// \relates Vector
/// \brief Smaller name for Vector of 4 coordinates
/////////////////////////////////////////////////////////////////
template<typename T>
using Vector4 = Vector<T,4>;
/////////////////////////////////////////////////////////////////
/// \relates Vector
/// \brief Smaller name for Vector of 2 int

View File

@ -64,7 +64,7 @@ namespace detail
/// - a vector of lists of down points for all the circles
/// the n th list of the up points vector correspond to the same circle than the n th list of the down points.
/////////////////////////////////////////////////////////
std::pair<std::vector<std::list<geo::Point<float>>>, std::vector<std::list<geo::Point<float>>>> sortedPoints(geo::Vector<float,4> const& plane, std::vector<geo::Circle<float>> const& junction_circles);
std::pair<std::vector<std::list<geo::Point<float>>>, std::vector<std::list<geo::Point<float>>>> sortedPoints(geo::Vector4f const& plane, std::vector<geo::Circle<float>> const& junction_circles);
/////////////////////////////////////////////////////////
/// \ingroup meshing
@ -77,7 +77,7 @@ namespace detail
/// Compute the vector between the center of the sphere and the points of the faces
/// and add the face so that the normal is pointing outside the sphere.
//////////////////////////////////////////////////////////
void pushFaceOriented(geo::Mesh& mesh, geo::Vector3<unsigned int> const& face, geo::Vector3<float> const& sphere_center);
void pushFaceOriented(geo::Mesh& mesh, geo::Vector3u const& face, geo::Vector3f const& sphere_center);
}
/////////////////////////////////////////////////////////////////
@ -92,7 +92,7 @@ namespace detail
///
/// \return the plane that cut the circles in two (helpful to test).
////////////////////////////////////////////////////////////////
geo::Vector<float,4> meshJunction(geo::Mesh& mesh, geo::Vector3<float> const& junction_point, float junction_radius, std::vector<geo::Circle<float>> const& junction_circles);
geo::Vector4f meshJunction(geo::Mesh& mesh, geo::Vector3f const& junction_point, float junction_radius, std::vector<geo::Circle<float>> const& junction_circles);
/////////////////////////////////////////////////////////////////
/// \ingroup meshing
@ -167,7 +167,7 @@ class Skeleton3D
/// \param radius the radius of the sphere
/// \param t the time where is the extremity on the spline
//////////////////////////////////////////////////////////
void subdivision(geo::Mesh& mesh, unsigned int profondeur, geo::Circle<float> extremCircle, unsigned int intersectionIndex, geo::Vector3<float> intersection, geo::Vector3<float> center, float radius, float t) const;
void subdivision(geo::Mesh& mesh, unsigned int profondeur, geo::Circle<float> extremCircle, unsigned int intersectionIndex, geo::Vector3f intersection, geo::Vector3f center, float radius, float t) const;
/////////////////////////////////////////////////////////
/// \brief the subdivision on one segment
@ -179,7 +179,7 @@ class Skeleton3D
/// \param center the center of the sphere
/// \param radius the radius of the sphere
////////////////////////////////////////////////////////
void arcSubdivise(geo::Vector3<float> pt1, geo::Vector3<float> pt2, unsigned int profondeur, std::vector<geo::Vector3<float>>& arc, geo::Vector3<float> center, float radius) const;
void arcSubdivise(geo::Vector3f pt1, geo::Vector3f pt2, unsigned int profondeur, std::vector<geo::Vector3f>& arc, geo::Vector3f center, float radius) const;
////////////////////////////////////////////////////////
/// \brief sort the indexes
@ -190,7 +190,7 @@ class Skeleton3D
/// \pre t must be 0 or 1
/// \return (a,b,c) if t == 0, (a,c,b) if t == 1
////////////////////////////////////////////////////////
geo::Vector3<unsigned int> sortedIndexes(unsigned int a, unsigned int b, unsigned int c, float t) const;
geo::Vector3u sortedIndexes(unsigned int a, unsigned int b, unsigned int c, float t) const;
////////////////////////////////////////////////////////
/// \brief Compute a mesh around the skeleton
@ -215,7 +215,7 @@ class Skeleton3D
friend std::ostream& operator<<(std::ostream& out, Skeleton3D const& s);
// private:
std::vector<geo::Spline<geo::Vector3<float>, float>> splines; ///< all the splines that the skeleton contains
std::vector<geo::Spline<geo::Vector3f, float>> splines; ///< all the splines that the skeleton contains
std::vector<Junction> junctions; ///< all the junction points of the skeleton
};

View File

@ -93,7 +93,7 @@ int main()
test(std::distance(std::begin(space1), it1) == 3);
geo::Vector<float,2> element2{0.0f,0.0f};
geo::Vector2f element2{0.0f,0.0f};
std::vector<geo::Vector3<float>> space2 = {
{1.0f, 2.0f, 3.0f},
@ -103,7 +103,7 @@ int main()
};
auto const it2 = geo::project(element2, std::begin(space2), std::end(space2),
[] (geo::Vector<float, 2> const& v, geo::Vector3<float> const& d)
[] (geo::Vector2f const& v, geo::Vector3<float> const& d)
{
return std::abs(d.x()*v.x()+d.y()*v.y()+d.z())/d.norm();
}
@ -111,17 +111,17 @@ int main()
test(std::distance(std::begin(space2), it2) == 2);
geo::Vector<float,2> element3{2.0f,2.0f};
geo::Vector2f element3{2.0f,2.0f};
std::vector<geo::Segment<float,2>> space3 = {
{geo::Vector<float,2>{0.0f,0.0f},geo::Vector<float,2>{1.0f,0.0f}},
{geo::Vector<float,2>{0.0f,1.0f},geo::Vector<float,2>{0.0f,3.0f}},
{geo::Vector<float,2>{3.0f,0.0f},geo::Vector<float,2>{4.0f,1.0f}},
{geo::Vector<float,2>{3.0f,3.0f},geo::Vector<float,2>{4.0f,3.0f}}
{geo::Vector2f{0.0f,0.0f},geo::Vector2f{1.0f,0.0f}},
{geo::Vector2f{0.0f,1.0f},geo::Vector2f{0.0f,3.0f}},
{geo::Vector2f{3.0f,0.0f},geo::Vector2f{4.0f,1.0f}},
{geo::Vector2f{3.0f,3.0f},geo::Vector2f{4.0f,3.0f}}
};
auto const it3 = geo::project(element3, std::begin(space3), std::end(space3),
[] (geo::Vector<float,2> const& p, geo::Segment<float,2> const& s)
[] (geo::Vector2f const& p, geo::Segment<float,2> const& s)
{
return geo::distanceToSegment(p, s.first, s.second);
}

View File

@ -117,8 +117,8 @@ int main(int argc, char *argv[])
std::cout << plane << std::endl;
// Dessin du plan
auto p1 = geo::Vector<float,3>{-plane.y(), plane.x(), -plane.t() / plane.z()};
auto v1 = geo::Vector<float,3>{-plane.z(), 0.0f, plane.x()};
auto p1 = geo::Vector3f{-plane.y(), plane.x(), -plane.t() / plane.z()};
auto v1 = geo::Vector3f{-plane.z(), 0.0f, plane.x()};
auto v2 = geo::crossProduct(geo::Vector3<float>{plane.x(), plane.y(), plane.z()}, v1);

View File

@ -99,7 +99,7 @@ bool Skeleton3D::loadFromFile(std::string const& path)
std::stringstream stream;
std::string line;
bool alreadyFoundL = false;
geo::Spline<geo::Vector3<float>, float> currentSpline;
geo::Spline<geo::Vector3f, float> currentSpline;
while (std::getline(file, line))
{
@ -120,7 +120,7 @@ bool Skeleton3D::loadFromFile(std::string const& path)
splines.push_back(currentSpline);
// Prepare the new one
currentSpline = geo::Spline<geo::Vector3<float>, float>{};
currentSpline = geo::Spline<geo::Vector3f, float>{};
// Set the degree of the spline
int i;
@ -197,7 +197,7 @@ void Skeleton3D::meshJunctions(geo::Mesh& mesh, std::vector<std::vector<geo::Cir
{
for(unsigned int i = 0; i < junctions.size(); i++)
{
geo::Vector3<float> junction_point; // sphere's center of the junction point
geo::Vector3f junction_point; // sphere's center of the junction point
float junction_radius; // sphere's radius
// Get the junction elements
@ -229,24 +229,24 @@ void Skeleton3D::meshJunctions(geo::Mesh& mesh, std::vector<std::vector<geo::Cir
}
geo::Vector<float,4> meshJunction(geo::Mesh& mesh, geo::Vector3<float> const& junction_point, float junction_radius, std::vector<geo::Circle<float>> const& junction_circles)
geo::Vector4f meshJunction(geo::Mesh& mesh, geo::Vector3f const& junction_point, float junction_radius, std::vector<geo::Circle<float>> const& junction_circles)
{
std::vector<geo::Vector3<float>> centerPoints;
std::vector<geo::Vector3f> centerPoints;
for (auto const& circle : junction_circles)
{
centerPoints.push_back(circle.center);
}
// Find the medium plane that cut the circles in two
geo::Vector<float,4> plane = geo::closestPlane<float>(centerPoints);
geo::Vector4f plane = geo::closestPlane<float>(centerPoints);
// Compute list of points upside the plane and downside
auto sorted_points = detail::sortedPoints(plane, junction_circles);
geo::Vector3<float> direction{plane.x(),plane.y(),plane.z()};
geo::Vector3f direction{plane.x(),plane.y(),plane.z()};
direction /= direction.norm();
geo::Vector3<float> up_point_proj = junction_point - direction*junction_radius;
geo::Vector3<float>down_point_proj = junction_point + direction*junction_radius;
geo::Vector3f up_point_proj = junction_point - direction*junction_radius;
geo::Vector3f down_point_proj = junction_point + direction*junction_radius;
mesh.vertices.push_back(up_point_proj);
mesh.vertices.push_back(down_point_proj);
@ -268,7 +268,7 @@ geo::Vector<float,4> meshJunction(geo::Mesh& mesh, geo::Vector3<float> const& ju
auto cp = it;
cp ++;
detail::pushFaceOriented(mesh,
geo::Vector3<unsigned int>{it->first,cp->first,ind_up},
geo::Vector3u{it->first,cp->first,ind_up},
junction_point);
}
}
@ -287,7 +287,7 @@ geo::Vector<float,4> meshJunction(geo::Mesh& mesh, geo::Vector3<float> const& ju
auto cp = it;
cp ++;
detail::pushFaceOriented(mesh,
geo::Vector3<unsigned int>{it->first,cp->first,ind_down},
geo::Vector3u{it->first,cp->first,ind_down},
junction_point);
}
}
@ -346,16 +346,16 @@ geo::Vector<float,4> meshJunction(geo::Mesh& mesh, geo::Vector3<float> const& ju
detail::pushFaceOriented(mesh,
geo::Vector3<unsigned int>{ind_p_c1_up, ind_p_c2_up, ind_p_c1_down},
geo::Vector3u{ind_p_c1_up, ind_p_c2_up, ind_p_c1_down},
junction_point);
detail::pushFaceOriented(mesh,
geo::Vector3<unsigned int>{ind_p_c1_down, ind_p_c2_up, ind_p_c2_down},
geo::Vector3u{ind_p_c1_down, ind_p_c2_up, ind_p_c2_down},
junction_point);
detail::pushFaceOriented(mesh,
geo::Vector3<unsigned int>{ind_p_c1_up, ind_up, ind_p_c2_up},
geo::Vector3u{ind_p_c1_up, ind_up, ind_p_c2_up},
junction_point);
detail::pushFaceOriented(mesh,
geo::Vector3<unsigned int>{ind_p_c1_down, ind_p_c2_down, ind_down},
geo::Vector3u{ind_p_c1_down, ind_p_c2_down, ind_down},
junction_point);
geo::Point<float> p_c2_down = points_c2_down.front();
@ -371,16 +371,16 @@ geo::Vector<float,4> meshJunction(geo::Mesh& mesh, geo::Vector3<float> const& ju
ind_p_c2_down = points_c2_down.front().first;
detail::pushFaceOriented(mesh,
geo::Vector3<unsigned int>{ind_p_c1_up, ind_p_c2_up1, ind_p_c1_down1},
geo::Vector3u{ind_p_c1_up, ind_p_c2_up1, ind_p_c1_down1},
junction_point);
detail::pushFaceOriented(mesh,
geo::Vector3<unsigned int>{ind_p_c1_down1, ind_p_c2_up1, ind_p_c2_down},
geo::Vector3u{ind_p_c1_down1, ind_p_c2_up1, ind_p_c2_down},
junction_point);
detail::pushFaceOriented(mesh,
geo::Vector3<unsigned int>{ind_p_c1_up, ind_up, ind_p_c2_up1},
geo::Vector3u{ind_p_c1_up, ind_up, ind_p_c2_up1},
junction_point);
detail::pushFaceOriented(mesh,
geo::Vector3<unsigned int>{ind_p_c2_down, ind_p_c1_down1, ind_down},
geo::Vector3u{ind_p_c2_down, ind_p_c1_down1, ind_down},
junction_point);
geo::Point<float> p_c2_down1 = points_c2_down.back();
@ -397,16 +397,16 @@ geo::Vector<float,4> meshJunction(geo::Mesh& mesh, geo::Vector3<float> const& ju
ind_p_c2_down1 = points_c2_down.back().first;
detail::pushFaceOriented(mesh,
geo::Vector3<unsigned int>{ind_p_c1_up1, ind_p_c2_up, ind_p_c1_down},
geo::Vector3u{ind_p_c1_up1, ind_p_c2_up, ind_p_c1_down},
junction_point);
detail::pushFaceOriented(mesh,
geo::Vector3<unsigned int>{ind_p_c1_up1, ind_p_c1_down, ind_p_c2_down1},
geo::Vector3u{ind_p_c1_up1, ind_p_c1_down, ind_p_c2_down1},
junction_point);
detail::pushFaceOriented(mesh,
geo::Vector3<unsigned int>{ind_p_c1_up1, ind_up, ind_p_c2_up},
geo::Vector3u{ind_p_c1_up1, ind_up, ind_p_c2_up},
junction_point);
detail::pushFaceOriented(mesh,
geo::Vector3<unsigned int>{ind_p_c1_down, ind_p_c2_down1, ind_down},
geo::Vector3u{ind_p_c1_down, ind_p_c2_down1, ind_down},
junction_point);
geo::Point<float> p_c2_down = points_c2_down.front();
@ -424,16 +424,16 @@ geo::Vector<float,4> meshJunction(geo::Mesh& mesh, geo::Vector3<float> const& ju
ind_p_c2_down = points_c2_down.front().first;
detail::pushFaceOriented(mesh,
geo::Vector3<unsigned int>{ind_p_c1_up, ind_p_c2_up, ind_p_c1_down},
geo::Vector3u{ind_p_c1_up, ind_p_c2_up, ind_p_c1_down},
junction_point);
detail::pushFaceOriented(mesh,
geo::Vector3<unsigned int>{ind_p_c1_down, ind_p_c2_up, ind_p_c2_down},
geo::Vector3u{ind_p_c1_down, ind_p_c2_up, ind_p_c2_down},
junction_point);
detail::pushFaceOriented(mesh,
geo::Vector3<unsigned int>{ind_p_c1_up, ind_up, ind_p_c2_up},
geo::Vector3u{ind_p_c1_up, ind_up, ind_p_c2_up},
junction_point);
detail::pushFaceOriented(mesh,
geo::Vector3<unsigned int>{ind_p_c1_down, ind_p_c2_down, ind_down},
geo::Vector3u{ind_p_c1_down, ind_p_c2_down, ind_down},
junction_point);
auto p_c2_down1 = points_c2_down.back();
@ -473,16 +473,16 @@ geo::Vector<float,4> meshJunction(geo::Mesh& mesh, geo::Vector3<float> const& ju
unsigned int ind_p_c3_down = p_c3_down1.first;
detail::pushFaceOriented(mesh,
geo::Vector3<unsigned int>{ind_p_c2_up, ind_p_c3_up, ind_p_c2_down},
geo::Vector3u{ind_p_c2_up, ind_p_c3_up, ind_p_c2_down},
junction_point);
detail::pushFaceOriented(mesh,
geo::Vector3<unsigned int>{ind_p_c2_down, ind_p_c3_up, ind_p_c3_down},
geo::Vector3u{ind_p_c2_down, ind_p_c3_up, ind_p_c3_down},
junction_point);
detail::pushFaceOriented(mesh,
geo::Vector3<unsigned int>{ind_p_c2_up, ind_up, ind_p_c3_up},
geo::Vector3u{ind_p_c2_up, ind_up, ind_p_c3_up},
junction_point);
detail::pushFaceOriented(mesh,
geo::Vector3<unsigned int>{ind_p_c2_down, ind_p_c3_down, ind_down},
geo::Vector3u{ind_p_c2_down, ind_p_c3_down, ind_down},
junction_point);
next_points.first = p_c3_up1;
@ -499,16 +499,16 @@ geo::Vector<float,4> meshJunction(geo::Mesh& mesh, geo::Vector3<float> const& ju
unsigned int ind_p_c3_down = p_c3_down.first;
detail::pushFaceOriented(mesh,
geo::Vector3<unsigned int>{ind_p_c2_up, ind_p_c3_up, ind_p_c2_down},
geo::Vector3u{ind_p_c2_up, ind_p_c3_up, ind_p_c2_down},
junction_point);
detail::pushFaceOriented(mesh,
geo::Vector3<unsigned int>{ind_p_c2_down, ind_p_c3_up, ind_p_c3_down},
geo::Vector3u{ind_p_c2_down, ind_p_c3_up, ind_p_c3_down},
junction_point);
detail::pushFaceOriented(mesh,
geo::Vector3<unsigned int>{ind_p_c2_up, ind_up, ind_p_c3_up},
geo::Vector3u{ind_p_c2_up, ind_up, ind_p_c3_up},
junction_point);
detail::pushFaceOriented(mesh,
geo::Vector3<unsigned int>{ind_p_c2_down, ind_p_c3_down, ind_down},
geo::Vector3u{ind_p_c2_down, ind_p_c3_down, ind_down},
junction_point);
next_points.first = p_c3_up;
@ -643,14 +643,14 @@ void Skeleton3D::meshExtremity(geo::Mesh& mesh, std::vector<std::vector<geo::Cir
}
}
void Skeleton3D::subdivision(geo::Mesh& mesh, unsigned int profondeur, geo::Circle<float> extremCircle, unsigned int intersectionIndex, geo::Vector3<float> intersection, geo::Vector3<float> center, float radius, float t) const
void Skeleton3D::subdivision(geo::Mesh& mesh, unsigned int profondeur, geo::Circle<float> extremCircle, unsigned int intersectionIndex, geo::Vector3f intersection, geo::Vector3f center, float radius, float t) const
{
std::vector<std::vector<geo::Vector3<float>>> arcs;
std::vector<std::vector<geo::Vector3f>> arcs;
for (unsigned int i=0;i<extremCircle.points.size();i++)
{
// compute the points build by subdivision on one arc (between a point on the extrem
// circle and the extremity)
std::vector<geo::Vector3<float>> arc;
std::vector<geo::Vector3f> arc;
arc.push_back(intersection);
arcSubdivise(intersection, extremCircle.points[i].second, profondeur, arc, center, radius);
arc.push_back(extremCircle.points[i].second);
@ -730,31 +730,31 @@ void Skeleton3D::subdivision(geo::Mesh& mesh, unsigned int profondeur, geo::Circ
mesh.faces.push_back(sortedIndexes(indexVertices + nbPoints, indexVerticesInit + nbPoints, i2, t));
}
geo::Vector3<unsigned int> Skeleton3D::sortedIndexes(unsigned int a, unsigned int b, unsigned int c, float t) const
geo::Vector3u Skeleton3D::sortedIndexes(unsigned int a, unsigned int b, unsigned int c, float t) const
{
if(t==0)
{
return geo::Vector3<unsigned int> {a,b,c};
return geo::Vector3u {a,b,c};
}
else
{
return geo::Vector3<unsigned int> {a,c,b};
return geo::Vector3u {a,c,b};
}
}
//pt1 the extremity
void Skeleton3D::arcSubdivise(geo::Vector3<float> pt1, geo::Vector3<float> pt2, unsigned int profondeur, std::vector<geo::Vector3<float>>& arc, geo::Vector3<float> center, float radius) const
void Skeleton3D::arcSubdivise(geo::Vector3f pt1, geo::Vector3f pt2, unsigned int profondeur, std::vector<geo::Vector3f>& arc, geo::Vector3f center, float radius) const
{
if (profondeur!=0)
{
// compute middle of arc
geo::Vector3<float> middleSegment;
geo::Vector3f middleSegment;
middleSegment = (pt1+pt2)/2;
// projection on the sphere
geo::Vector3<float> direction = (middleSegment - center);
geo::Vector3f direction = (middleSegment - center);
direction /= direction.norm();
direction *= radius;
geo::Vector3<float> middle = center + direction;
geo::Vector3f middle = center + direction;
arcSubdivise(pt1, middle, profondeur-1, arc, center, radius);
arc.push_back(middle);
@ -813,7 +813,7 @@ std::ostream& operator<<(std::ostream& out, Skeleton3D const& s)
namespace detail
{
std::pair<std::vector<std::list<geo::Point<float>>>, std::vector<std::list<geo::Point<float>>>> sortedPoints(geo::Vector<float,4> const& plane, std::vector<geo::Circle<float>> const& junction_circles)
std::pair<std::vector<std::list<geo::Point<float>>>, std::vector<std::list<geo::Point<float>>>> sortedPoints(geo::Vector4f const& plane, std::vector<geo::Circle<float>> const& junction_circles)
{
std::vector<std::list<geo::Point<float>>> up_points;
std::vector<std::list<geo::Point<float>>> down_points;
@ -822,26 +822,26 @@ std::pair<std::vector<std::list<geo::Point<float>>>, std::vector<std::list<geo::
{
std::list<geo::Point<float>> first_points; // points located on one side of the circle, the first side reached.The two sides are separated by the median plane computed earlier.
std::list<geo::Point<float>> second_points; // points located on the other side of the circle
const bool up_side = geo::whichSide<double>(plane, junction_circles[i].points[0].second); // constant boolean initialized at the beginning to know with which side we begin the way on the circle.
const bool up_side = geo::whichSide(plane, junction_circles[i].points[0].second); // constant boolean initialized at the beginning to know with which side we begin the way on the circle.
bool side_current_points = up_side; // boolean to know on which side we must had the points.
for (unsigned int j = 0; j < junction_circles[i].points.size(); j++)
{
if (up_side == side_current_points)
{
if (geo::whichSide<double>(plane, junction_circles[i].points[j].second) == up_side)
if (geo::whichSide(plane, junction_circles[i].points[j].second) == up_side)
{
first_points.push_back(junction_circles[i].points[j]);
}
else
{
side_current_points = geo::whichSide<double>(plane, junction_circles[i].points[j].second);
side_current_points = geo::whichSide(plane, junction_circles[i].points[j].second);
second_points.push_back(junction_circles[i].points[j]);
}
}
else
{
if (geo::whichSide<double>(plane, junction_circles[i].points[j].second) == side_current_points)
if (geo::whichSide(plane, junction_circles[i].points[j].second) == side_current_points)
{
second_points.push_back(junction_circles[i].points[j]);
}
@ -855,7 +855,7 @@ std::pair<std::vector<std::list<geo::Point<float>>>, std::vector<std::list<geo::
for (int j = static_cast<int>(junction_circles[i].points.size()-1); j >= 0; j--)
{
if (geo::whichSide<double>(plane, junction_circles[i].points[j].second) == up_side)
if (geo::whichSide(plane, junction_circles[i].points[j].second) == up_side)
{
first_points.push_front(junction_circles[i].points[j]);
}
@ -881,10 +881,10 @@ std::pair<std::vector<std::list<geo::Point<float>>>, std::vector<std::list<geo::
return std::make_pair(up_points, down_points);
}
void pushFaceOriented(geo::Mesh& mesh, geo::Vector3<unsigned int> const& face, geo::Vector3<float> const& sphere_center)
void pushFaceOriented(geo::Mesh& mesh, geo::Vector3u const& face, geo::Vector3f const& sphere_center)
{
geo::Vector3<float> v1 = mesh.vertices[face.x()] - sphere_center;
geo::Vector3<float> v2 = geo::crossProduct(mesh.vertices[face.z()] - mesh.vertices[face.y()],
geo::Vector3f v1 = mesh.vertices[face.x()] - sphere_center;
geo::Vector3f v2 = geo::crossProduct(mesh.vertices[face.z()] - mesh.vertices[face.y()],
mesh.vertices[face.z()] - mesh.vertices[face.x()]);
if (v1*v2 < 0)
@ -893,7 +893,7 @@ void pushFaceOriented(geo::Mesh& mesh, geo::Vector3<unsigned int> const& face, g
}
else
{
mesh.faces.push_back(geo::Vector3<unsigned int>{face.x(),face.z(),face.y()});
mesh.faces.push_back(geo::Vector3u{face.x(),face.z(),face.y()});
}
}

View File

@ -45,7 +45,7 @@
constexpr auto WIDTH = 1920;
constexpr auto HEIGHT = 1080;
void drawScene(sft::FreeFlyCamera const& camera, geo::Mesh const& mesh, std::vector<geo::Circle<float>> const& circles, geo::Vector<float,4> const& plane);
void drawScene(sft::FreeFlyCamera const& camera, geo::Mesh const& mesh, std::vector<geo::Circle<float>> const& circles, geo::Vector4f const& plane);
void drawCircle(geo::Circle<float> const& circle);
@ -178,7 +178,7 @@ int main(int argc, char *argv[])
return 0;
}
void drawScene(sft::FreeFlyCamera const& camera, geo::Mesh const& mesh, std::vector<geo::Circle<float>> const& circles, geo::Vector<float,4> const& plane)
void drawScene(sft::FreeFlyCamera const& camera, geo::Mesh const& mesh, std::vector<geo::Circle<float>> const& circles, geo::Vector4f const& plane)
{
// Initialisation
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@ -212,8 +212,8 @@ void drawScene(sft::FreeFlyCamera const& camera, geo::Mesh const& mesh, std::vec
drawCircle(circles[2]);
// // Dessin du plan
// auto p1 = geo::Vector<float,3>{-plane.y(), plane.x(), -plane.t() / plane.z()};
// auto v1 = geo::Vector<float,3>{-plane.z(), 0.0f, plane.x()};
// auto p1 = geo::Vector3f{-plane.y(), plane.x(), -plane.t() / plane.z()};
// auto v1 = geo::Vector3f{-plane.z(), 0.0f, plane.x()};
// auto v2 = geo::crossProduct(geo::Vector3<float>{plane.x(), plane.y(), plane.z()}, v1);
// v1 /= v1.norm();

View File

@ -45,7 +45,7 @@
constexpr auto WIDTH = 1920;
constexpr auto HEIGHT = 1080;
void drawScene(sft::FreeFlyCamera const& camera, geo::Mesh const& mesh, std::vector<geo::Circle<float>> const& circles, geo::Vector<float,4> const& plane);
void drawScene(sft::FreeFlyCamera const& camera, geo::Mesh const& mesh, std::vector<geo::Circle<float>> const& circles, geo::Vector4f const& plane);
void drawCircle(geo::Circle<float> const& circle);
@ -178,7 +178,7 @@ int main(int argc, char *argv[])
return 0;
}
void drawScene(sft::FreeFlyCamera const& camera, geo::Mesh const& mesh, std::vector<geo::Circle<float>> const& circles, geo::Vector<float,4> const& plane)
void drawScene(sft::FreeFlyCamera const& camera, geo::Mesh const& mesh, std::vector<geo::Circle<float>> const& circles, geo::Vector4f const& plane)
{
// Initialisation
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@ -212,8 +212,8 @@ void drawScene(sft::FreeFlyCamera const& camera, geo::Mesh const& mesh, std::vec
drawCircle(circles[2]);
// // Dessin du plan
// auto p1 = geo::Vector<float,3>{-plane.y(), plane.x(), -plane.t() / plane.z()};
// auto v1 = geo::Vector<float,3>{-plane.z(), 0.0f, plane.x()};
// auto p1 = geo::Vector3f{-plane.y(), plane.x(), -plane.t() / plane.z()};
// auto v1 = geo::Vector3f{-plane.z(), 0.0f, plane.x()};
// auto v2 = geo::crossProduct(geo::Vector3<float>{plane.x(), plane.y(), plane.z()}, v1);
// v1 /= v1.norm();

View File

@ -85,7 +85,7 @@ bool Skeleton::loadFromFile(std::string const& path)
unsigned int v1;
unsigned int v2;
stream >> v1 >> v2;
m_edges.push_back(geo::Vector<unsigned int, 2>{v1-1,v2-1});
m_edges.push_back(geo::Vector2u{v1-1,v2-1});
break;
}
@ -370,9 +370,9 @@ unsigned int Skeleton::searchNearestBrancheIndex(cv::Point const& keypoint, Skel
keypoint,
// m_vertices[m_edges[branche[k]].x()],
// m_vertices[m_edges[branche[k]].y()]
geo::Vector<float,2>{m_vertices.at(branche.at(k)).x(),
geo::Vector2f{m_vertices.at(branche.at(k)).x(),
m_vertices.at(branche.at(k)).y()},
geo::Vector<float,2>{m_vertices.at(branche.at(k+1)).x(),
geo::Vector2f{m_vertices.at(branche.at(k+1)).x(),
m_vertices.at(branche.at(k+1)).y()}
);