Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
631d4d9
comment typo
Jun 28, 2017
19580b4
Merge branch 'develop' of github.com:cgogn/CGoGN_2 into kvanhoey
Jul 3, 2017
c63c9f6
Merge branch 'develop' of github.com:cgogn/CGoGN_1 into kvanhoey
Aug 8, 2017
1504c97
Add map_quad_render
Aug 8, 2017
9f9efc6
Cleanup MapQuadRender
Aug 11, 2017
53c7b8e
add ParallelogramTiling Topo. Ongoing ...
Aug 21, 2017
100adff
paralellogram_grid
Aug 23, 2017
7dca195
cleanup for parallelogram grid
Aug 23, 2017
4bee075
code refactoring on parallelogram_grid
Aug 24, 2017
7e6a4e7
code refactoring on parallelogram_grid
Aug 24, 2017
4abd9c5
integrate MapQuadRender into MapRender with an enum QUAD
Sep 12, 2017
f5e2681
Merge branch 'develop' of github.com:cgogn/CGoGN_2 into kvanhoey
Sep 12, 2017
ff110a1
update CMakeList accordingly
Sep 12, 2017
ad23554
add missing break; instruction
Sep 12, 2017
a099b06
change spaces to tabs
Sep 12, 2017
e3d0cc5
sampling parallelograms
Sep 13, 2017
f50c66f
sample parallelograms
Sep 13, 2017
c12be0e
Sample parallelograms updated
Sep 18, 2017
c2dcb16
Sample parallelograms updated
Sep 18, 2017
b0726f5
bug fixing
Sep 22, 2017
4921587
double templates for parallelogram_grid
Sep 29, 2017
9717168
replace assert by warning
Oct 5, 2017
1eb98f4
compil fix
kvanhoey Oct 6, 2017
c24b111
Merge branch 'develop' of github.com:cgogn/CGoGN_2 into kvanhoey
kvanhoey Oct 6, 2017
869cc70
tmp commit
kvanhoey Oct 9, 2017
cca187d
fix conflict
kvanhoey Oct 9, 2017
71ffd9c
adding planarity and convexity tests for faces
Oct 27, 2017
cbd1ec9
add parallelogram::isApprox
Oct 27, 2017
082bba6
correct snake_case
kvanhoey Oct 27, 2017
0cad941
correct snake_case
kvanhoey Oct 27, 2017
bce8843
uint -> uint32 for windows compatibility
Oct 30, 2017
af487e9
uint -> uint32 for windows compatibility
Oct 30, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions cgogn/core/container/chunk_array.h
Original file line number Diff line number Diff line change
Expand Up @@ -347,10 +347,10 @@ class ChunkArray : public ChunkArrayGen<CHUNK_SIZE>
}
}

void import_element(uint32 idx, std::istream& in) override
{
serialization::parse(in, this->operator [](idx));
}
// void import_element(uint32 idx, std::istream& in) override
// {
// serialization::parse(in, this->operator [](idx));
// }

const void* element_ptr(uint32 idx) const override
{
Expand Down Expand Up @@ -701,14 +701,14 @@ class ChunkArrayBool : public ChunkArrayGen<CHUNK_SIZE>
serialization::ostream_writer(o, this->operator[](idx),binary, little_endian);
}

void import_element(uint32 idx, std::istream& in) override
{
std::string val;
in >> val;
val = to_lower(val);
const bool b = (val == "true") || (std::stoi(val) != 0);
set_value(idx,b);
}
// void import_element(uint32 idx, std::istream& in) override
// {
// std::string val;
// in >> val;
// val = to_lower(val);
// const bool b = (val == "true") || (std::stoi(val) != 0);
// set_value(idx,b);
// }

const void* element_ptr(uint32) const override
{
Expand Down
3 changes: 2 additions & 1 deletion cgogn/core/container/chunk_array_container.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,9 @@ class ChunkArrayContainer
// first check if attribute already exists
const uint32 index = array_index(name);
if (index == UNKNOWN)
{
return nullptr;
}
return dynamic_cast<ChunkArray<T>*>(table_arrays_[index]);
}

Expand All @@ -238,7 +240,6 @@ class ChunkArrayContainer
const uint32 index = array_index(name);
if (index == UNKNOWN)
{
cgogn_log_warning("get_chunk_array") << "Chunk array of name \"" << name << "\" not found.";
return nullptr;
}

Expand Down
2 changes: 1 addition & 1 deletion cgogn/core/container/chunk_array_gen.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ class ChunkArrayGen
* @param idx
* @param i
*/
virtual void import_element(uint32 idx, std::istream& in) = 0;
// virtual void import_element(uint32 idx, std::istream& in) = 0;
/**
* @brief element_ptr
* @return a generic pointer to the element of index idx.
Expand Down
1 change: 1 addition & 0 deletions cgogn/geometry/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ set(HEADER_ALGOS
algos/area.h
algos/centroid.h
algos/curvature.h
algos/convexity.h
algos/normal.h
algos/ear_triangulation.h
algos/picking.h
Expand Down
141 changes: 141 additions & 0 deletions cgogn/geometry/algos/convexity.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* Copyright (C) 2015, IGG Group, ICube, University of Strasbourg, France *
* *
* 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 CGOGN_GEOMETRY_ALGOS_CONVEXITY_H
#define CGOGN_GEOMETRY_ALGOS_CONVEXITY_H

#include <cgogn/geometry/types/geometry_traits.h>
#include <cgogn/geometry/algos/length.h>

#include <cgogn/core/cmap/attribute.h>

namespace cgogn
{

namespace geometry
{

/**
* @brief is_planar verifies if a face is planar: defined by the fact that all coordinates other than the first two (x and y) are constant (up to epsilon)
* @param map the map
* @param f the face
* @param position container of vertex positions
* @param epsilon maximum deviation of each component
* @return true iff planar
*/
template <typename VEC, typename MAP>
inline bool is_planar(
const MAP& map,
const typename MAP::Face f,
const typename MAP::template VertexAttribute<VEC>& position,
typename vector_traits<VEC>::Scalar epsilon = Eigen::NumTraits<typename vector_traits<VEC>::Scalar>::dummy_precision()
)
{
using Scalar = typename vector_traits<VEC>::Scalar;
using Vertex = typename MAP::Vertex;

if (vector_traits<VEC>::SIZE < 3)
return true ;

using VecN_2 = Eigen::Matrix<Scalar,vector_traits<VEC>::SIZE - 2,1> ;
// Init with first vertex
VecN_2 depth0 ;
for (uint i = 0 ; i < vector_traits<VEC>::SIZE - 2 ; ++i)
depth0[i] = position[Vertex(f.dart)][i+2] ;

// verify that other vertices do not deviate in coordinates 3 (z) and higher.
bool planar = true ;
map.foreach_incident_vertex(f, [&] (Vertex v) -> bool
{
VecN_2 depth ;
for (uint i = 0 ; i < vector_traits<VEC>::SIZE - 2 ; ++i)
{
depth[i] = position[v][i+2] ;
if (!depth.isApprox(depth0,epsilon))
{
planar = false ;
}
}
return planar ;
});

return planar ;
}

/**
* @brief is_convex verifies if a given face is convex (in the plane, not in 3D).
* @param map the map
* @param f the face
* @param position the geometric embedding of the vertices
* @note if the face is not planar (see #is_planar), false is returned.
* @return true iff the face is convex.
*/
template <typename VEC, typename MAP>
inline bool is_convex(
const MAP& map,
const typename MAP::Face f,
const typename MAP::template VertexAttribute<VEC>& position
)
{
if (!is_planar<VEC,MAP>(map,f,position))
{
cgogn_log_error("Trying to assess convexity of a face while it's not planar. This is ill-defined") ;
return false ;
}

using Scalar = typename vector_traits<VEC>::Scalar;
using Vertex = typename MAP::Vertex;
//using Dart = typename MAP::Dart;

bool convex = true ;
if (map.codegree(f) >= 3) // true otherwise
{
// Take all two consecutive darts and compute cross products.
// The face is convex iff the z components of all products have the same sign.
bool sign ;
bool first = true ;
map.foreach_dart_of_orbit(f, [&] (Dart d)
{
const VEC d1 = vector_from<VEC>(map,d,position) ;
const VEC d2 = vector_from<VEC>(map,map.phi1(d),position) ;
const Scalar zcross = d1[0]*d2[1] - d1[1]*d2[0] ;
if (first)
{
sign = (zcross > Scalar(0)) ;
first = false ;
}
else
{
if (sign != (zcross > Scalar(0)))
convex = false ;
}
});
}
return convex ;
}

} // Geometry

} // CGoGN

#endif // CGOGN_GEOMETRY_ALGOS_CONVEXITY_H
21 changes: 18 additions & 3 deletions cgogn/geometry/functions/area.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,28 @@ namespace geometry
/**
* area of the triangle formed by 3 points in 3D
*/
template <typename VEC3>
inline typename vector_traits<VEC3>::Scalar area(const VEC3& p1, const VEC3& p2, const VEC3& p3)
template <typename VEC>
inline auto area(const VEC& p1, const VEC& p2, const VEC& p3)
-> typename std::enable_if<vector_traits<VEC>::SIZE == 3, typename vector_traits<VEC>::Scalar>::type
{
using Scalar = typename vector_traits<VEC3>::Scalar;
using Scalar = typename vector_traits<VEC>::Scalar;
return (Scalar(0.5) * ((p2 - p1).cross(p3 - p1)).norm());
}

/**
* area of the triangle formed by 3 points in 2D
*/
template <typename VEC>
inline auto area(const VEC& p1, const VEC& p2, const VEC& p3)
-> typename std::enable_if<vector_traits<VEC>::SIZE == 2, typename vector_traits<VEC>::Scalar>::type
{
using Scalar = typename vector_traits<VEC>::Scalar;
VEC v1 = p2 - p1;
VEC v2 = p3 - p1;
return (Scalar(0.5) * (v1[0] * v2[1] - v1[1] * v2[0]));
}


} // namespace geometry

} // namespace cgogn
Expand Down
3 changes: 2 additions & 1 deletion cgogn/geometry/types/aabb.h
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,9 @@ class AABB

/// \brief Test if a ray intersectes an axis-aligned box
/// \tparam VEC3 the domain of the box. Has to be of dimension 3
template <bool B = true>
auto ray_intersect(const Vec& P, const Vec& V) const
-> typename std::enable_if<nb_components_traits<Vec>::value == 3, bool>::type
-> typename std::enable_if<B && nb_components_traits<Vec>::value == 3, bool>::type
{
if (!cgogn::almost_equal_relative(V[2], Scalar(0)))
{
Expand Down
2 changes: 2 additions & 0 deletions cgogn/modeling/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ set(HEADER_TILING
tiling/square_grid.h
tiling/square_cylinder.h
tiling/square_tore.h
tiling/parallelogram_grid.h
)
set(HEADER_DECIMATION
decimation/edge_approximator.h
Expand Down Expand Up @@ -50,6 +51,7 @@ set(SOURCE_TILING
tiling/square_cylinder.cpp
tiling/square_tore.cpp
# tiling/square_cube.h
tiling/parallelogram_grid.cpp
)
set(SOURCE_FILES ${SOURCE_ALGOS} ${SOURCE_TILING})

Expand Down
38 changes: 38 additions & 0 deletions cgogn/modeling/tiling/parallelogram_grid.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* Copyright (C) 2015, IGG Group, ICube, University of Strasbourg, France *
* *
* 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 *
* *
*******************************************************************************/

#define CGOGN_MODELING_TILING_PARALLELOGRAM_GRID_CPP_

#include <cgogn/modeling/tiling/parallelogram_grid.h>

namespace cgogn
{

namespace modeling
{

//template class CGOGN_MODELING_API ParallelogramGrid<CMap2,Eigen::Vector2d>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Est-ce qu'il y a une raison pour laquelle c'est commenté ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non. Ou du moins, je ne m'en souviens pas. En fait, je devrais vraiment exclure cette classe du pull request car cette classe n'est absolument pas finalisée (c'était un effet de bord de mon pull request pour le MapRender).
C'est faisable facilement ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Je pense que le plus simple est de faire un commit dans lequel tu enlèves les parties non-finalisées. Sinon ça peut très bien rester en l'état le temps que tu travailles dessus, faut voir avec Pierre.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ouai mais j'aimerais quand même avoir le commit et le push sur mon github à des fins de backup ... mais pas dans le pull request pour ne pas polluer CGoGN.
@pierrekraemer, un avis ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tu peux créer une nouvelle branche de backup à partir de celle que tu utilises pour la PR. Puis tu continues tes modifs dans l'ancienne branche.


} // namespace modeling

} // namespace cgogn
Loading