Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Light Cell Geometry #1499

Merged
merged 36 commits into from
Jul 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
d875398
New version of CellGeometry and DigitalConvexity based on more compac…
JacquesOlivierLachaud May 28, 2020
423cc45
Fixing UnorderedSetByBlock::includes
JacquesOlivierLachaud Jun 4, 2020
dc2c4fa
Merge branch 'master' of github.com:DGtal-team/DGtal into LightCellGe…
JacquesOlivierLachaud Jun 5, 2020
fa0ba8a
Moving UnorderedSetByBlock into kernel to build Splitter specializati…
JacquesOlivierLachaud Jun 5, 2020
a15500f
Working on doc
JacquesOlivierLachaud Jun 5, 2020
575f3e4
Working on ref doc of UnorderedSetByBlock
JacquesOlivierLachaud Jun 5, 2020
2b4c556
Making a test for new UnorderedSetByBlock
JacquesOlivierLachaud Jun 5, 2020
e6ae43c
Completing testUnorderedSetByBlock
JacquesOlivierLachaud Jun 5, 2020
d5745dc
Add test with 3d points and int64
JacquesOlivierLachaud Jun 5, 2020
f010704
Small fixes
JacquesOlivierLachaud Jun 5, 2020
6893cbb
Update doc of module DigitalConvexity
JacquesOlivierLachaud Jun 5, 2020
470bba5
Fix doc error
JacquesOlivierLachaud Jun 5, 2020
49bc164
Fix doc error
JacquesOlivierLachaud Jun 5, 2020
528ce71
Fix defaulted special member in UnorderedSetByBlock
JacquesOlivierLachaud Jun 5, 2020
810dfc5
Fix defaulted special member assignment in UnorderedSetByBlock
JacquesOlivierLachaud Jun 5, 2020
0c6d29b
Update ChangeLog
JacquesOlivierLachaud Jun 5, 2020
de43cc5
Fix doc
JacquesOlivierLachaud Jun 6, 2020
d93aacb
Merge branch 'master' into LightCellGeometry
dcoeurjo Jun 8, 2020
f88bb68
Apply suggestions from code review
JacquesOlivierLachaud Jun 11, 2020
6ea1772
Changing splitter and updating tests with 64 bits blocks
JacquesOlivierLachaud Jun 16, 2020
d1a7167
Update CellGeometry with 64 bits words
JacquesOlivierLachaud Jun 16, 2020
3eb21dc
clean old code in Splitter specialization
JacquesOlivierLachaud Jun 16, 2020
b452a4c
fix conflict
JacquesOlivierLachaud Jun 16, 2020
ef65481
Try to fix error in travis
JacquesOlivierLachaud Jun 16, 2020
5e6abbc
Update tests/kernel/testUnorderedSetByBlock.cpp
JacquesOlivierLachaud Jun 16, 2020
6744024
Update src/DGtal/kernel/UnorderedSetByBlock.h
JacquesOlivierLachaud Jun 16, 2020
7d1cd4a
Update src/DGtal/kernel/UnorderedSetByBlock.h
JacquesOlivierLachaud Jun 16, 2020
01404c6
Update src/DGtal/kernel/UnorderedSetByBlock.h
JacquesOlivierLachaud Jun 16, 2020
cbdddf4
Again some fixes
JacquesOlivierLachaud Jun 16, 2020
a9da680
Detail test to find bug
JacquesOlivierLachaud Jun 16, 2020
7fde406
Put back CHAR_BIT
JacquesOlivierLachaud Jun 16, 2020
1720042
Again detailing test instance to understand tracis CI'problem
JacquesOlivierLachaud Jun 16, 2020
23bde11
Put static_cast in all iterators
JacquesOlivierLachaud Jun 17, 2020
97cb6ae
Put static_cast in remaining code of UnorderedSetByBlock
JacquesOlivierLachaud Jun 17, 2020
8f5e4ea
Removing trailing spaces and fixing mixed space/tab indents
rolanddenis Jun 17, 2020
2008023
Fixing unused variable warning in testUnorderedSetByBlock
rolanddenis Jun 20, 2020
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
13 changes: 11 additions & 2 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@
- *Geometry Package*
- New piecewise smooth digital surface regularization class (David Coeurjolly,
[#1440](https://github.com/DGtal-team/DGtal/pull/1440))
- Provides support for digital full convexity and subconvexity (Jacques-Olivier Lachaud,
[#1459](https://github.com/DGtal-team/DGtal/pull/1459))
- Provides support for digital full convexity and subconvexity
(Jacques-Olivier Lachaud,
[#1459](https://github.com/DGtal-team/DGtal/pull/1459))
- Updates cell geometry and digital convexity to use specialized
unordered set data structure UnorderedSetByBlock for storing
digital points (Jacques-Olivier Lachaud,
[#1499](https://github.com/DGtal-team/DGtal/pull/1499))

## Changes

Expand Down Expand Up @@ -49,6 +54,10 @@
- *Kernel package*
- Add .data() function to PointVector to expose internal array data.
(Pablo Hernandez-Cerdan, [#1452](https://github.com/DGtal-team/DGtal/pull/1452))
- Add a specialized unordered set data structure
UnorderedSetByBlock for storing digital points, which is more
compact and as efficient as unordered set
(Jacques-Olivier Lachaud,[#1499](https://github.com/DGtal-team/DGtal/pull/1499))

- *Helpers*
- Add vector field output as OBJ to module Shortcuts (Jacques-Olivier Lachaud,
Expand Down
43 changes: 20 additions & 23 deletions examples/geometry/curves/exampleDigitalConvexity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
@see \ref moduleDigitalConvexity

\image html grid-curve-dig-convexity.png "Extraction of all subconvex triangles to the digital curve."

\example geometry/curves/exampleDigitalConvexity.cpp
*/

Expand All @@ -57,54 +57,51 @@

using namespace std;
using namespace DGtal;
using namespace Z2i;
using namespace Z2i;


///////////////////////////////////////////////////////////////////////////////
int main( int argc, char** argv )
{
trace.beginBlock ( "Example for 2d gridcurves" );
string S = examplesPath + "samples/contourS.fc";

// domain
const Point lowerBound( -200, -200 );
const Point upperBound( 200, 200 );

fstream inputStream( S.c_str(), ios::in );
FreemanChain<int> fc(inputStream);
inputStream.close();
Curve c;
c.initFromPointsRange( fc.begin(), fc.end() );
Curve c;
c.initFromPointsRange( fc.begin(), fc.end() );
auto points = c.getPointsRange();
std::vector<Point> T( points.begin(), points.end() );
Board2D aBoard;
aBoard.setUnit(Board2D::UCentimeter);
DigitalConvexity<KSpace> dconv( lowerBound, upperBound );
auto c_cover = dconv.makeCellCover( T.begin(), T.end(), 1, 1 );
trace.beginBlock( "Prepare subset operations" );
c_cover.prepareSubsetOperations();
trace.endBlock();
const float sx = -0.5;
const float sy = -0.5;
trace.beginBlock( "Compute fully subconvex sets" );
for ( unsigned int i = 0; i < T.size(); ++i )
for ( unsigned int j = i+2; j < T.size(); ++j )
{
aBoard.setPenColorRGBi( rand() % 255, rand() % 255, rand() % 255 );
unsigned int k = (i+j)/2;
if ( ! dconv.isSimplexFullDimensional( { T[i], T[j], T[k] } ) ) continue;
auto triangle = dconv.makeSimplex( { T[i], T[j], T[k] } );
if ( dconv.isFullySubconvex( triangle, c_cover ) )
{
aBoard.drawLine( sx+(float)T[i][0], sy+(float)T[i][1],
sx+(float)T[j][0], sy+(float)T[j][1] );
aBoard.drawLine( sx+(float)T[i][0], sy+(float)T[i][1],
sx+(float)T[k][0], sy+(float)T[k][1] );
aBoard.drawLine( sx+(float)T[k][0], sy+(float)T[k][1],
sx+(float)T[j][0], sy+(float)T[j][1] );
}
else
j = T.size();
aBoard.setPenColorRGBi( rand() % 255, rand() % 255, rand() % 255 );
unsigned int k = (i+j)/2;
if ( ! dconv.isSimplexFullDimensional( { T[i], T[j], T[k] } ) ) continue;
auto triangle = dconv.makeSimplex( { T[i], T[j], T[k] } );
if ( dconv.isFullySubconvex( triangle, c_cover ) )
{
aBoard.drawLine( sx+(float)T[i][0], sy+(float)T[i][1],
sx+(float)T[j][0], sy+(float)T[j][1] );
aBoard.drawLine( sx+(float)T[i][0], sy+(float)T[i][1],
sx+(float)T[k][0], sy+(float)T[k][1] );
aBoard.drawLine( sx+(float)T[k][0], sy+(float)T[k][1],
sx+(float)T[j][0], sy+(float)T[j][1] );
}
else
j = T.size();
}
trace.endBlock();
aBoard.setPenColor( Color::Black );
Expand Down
37 changes: 17 additions & 20 deletions examples/geometry/curves/exampleRationalConvexity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
@see \ref moduleDigitalConvexity

\image html grid-curve-subconvex-rational-segment.png "Extraction of all maximal rational segments between midpoints that are subconvex to the digital curve."

\example geometry/curves/exampleRationalConvexity.cpp
*/

Expand All @@ -58,25 +58,25 @@

using namespace std;
using namespace DGtal;
using namespace Z2i;
using namespace Z2i;


///////////////////////////////////////////////////////////////////////////////
int main( int argc, char** argv )
{
trace.beginBlock ( "Example for 2d gridcurves" );
string S = examplesPath + "samples/contourS.fc";

// domain
const Point lowerBound( -200, -200 );
const Point upperBound( 200, 200 );
DigitalConvexity<KSpace> dconv( lowerBound, upperBound );

fstream inputStream( S.c_str(), ios::in );
FreemanChain<int> fc(inputStream);
inputStream.close();
Curve c;
c.initFromPointsRange( fc.begin(), fc.end() );
Curve c;
c.initFromPointsRange( fc.begin(), fc.end() );
auto points = c.getPointsRange();
std::vector<Point> T( points.begin(), points.end() );
auto midpoints = c.getMidPointsRange();
Expand All @@ -85,7 +85,7 @@ int main( int argc, char** argv )
for ( auto && rp : midpoints )
// there is a shift of (0.5,0.5) between points and cells embedder.
T2.push_back( Point( (int) round( 2. * rp[ 0 ] + 1. ),
(int) round( 2. * rp[ 1 ] + 1. ) ) );
(int) round( 2. * rp[ 1 ] + 1. ) ) );
Board2D aBoard;
aBoard.setUnit(Board2D::UCentimeter);
// Display cells
Expand All @@ -101,15 +101,12 @@ int main( int argc, char** argv )
}
for ( auto && pixel : pixels )
aBoard << CustomStyle( pixel.className(), new CustomColors( grey, grey ) )
<< pixel;
<< pixel;
// Display contour
aBoard.setPenColor( Color::Black );
aBoard << c;
// Compute subconvex rational segments.
auto c_cover = dconv.makeCellCover( T.begin(), T.end(), 1, 1 );
trace.beginBlock( "Prepare subset operations" );
c_cover.prepareSubsetOperations();
trace.endBlock();
trace.beginBlock( "Compute fully subconvex rational sets" );
Point denominator( 2, 2 );
unsigned int last_j = 0;
Expand All @@ -119,16 +116,16 @@ int main( int argc, char** argv )
aBoard.setPenColorRGBi( rand() % 255, rand() % 255, rand() % 255 );
unsigned int start_j = ( i + 1 ) % T2.size();
for ( j = ( start_j + 1 ) % T2.size(); j != start_j; j = ( j + 1 ) % T2.size() )
{
auto segment = dconv.makeRationalSimplex( { denominator, T2[i], T2[j] } );
if ( ! dconv.isFullySubconvex( segment, c_cover ) ) break;
}
{
auto segment = dconv.makeRationalSimplex( { denominator, T2[i], T2[j] } );
if ( ! dconv.isFullySubconvex( segment, c_cover ) ) break;
}
j = ( j + T2.size() - 1 ) % T2.size();
if ( j != last_j )
{ // display fully subconvex segments
aBoard.setLineWidth( 2.5 );
aBoard.drawLine( RT[i][0], RT[i][1], RT[j][0], RT[j][1] );
}
if ( j != last_j )
{ // display fully subconvex segments
aBoard.setLineWidth( 2.5 );
aBoard.drawLine( RT[i][0], RT[i][1], RT[j][0], RT[j][1] );
}
last_j = j;
}
trace.endBlock();
Expand Down
12 changes: 5 additions & 7 deletions src/DGtal/geometry/doc/moduleDigitalConvexity.dox
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,10 @@ Lattice point retrieval services:

The class CellGeometry can compute and store set of lattice cells of
different dimensions. You specify at construction a Khalimsky space
(any model of concepts::CCellularGridSpaceND) or a CubicalComplex, as well as the
(any model of concepts::CCellularGridSpaceND), as well as the
dimensions of the cells you are interested in. Internally it uses a
CubicalComplex to store the lattice cells.
variant of unordered set of points (see \ref UnorderedSetByBlock) to
store the lattice cells in a compact manner.

\code
#include "DGtal/geometry/volumes/CellGeometry.h"
Expand All @@ -181,7 +182,7 @@ CellGeometry< KSpace > cell_geometry( K, 1, 2 ); // only 1-cells and 2-cells

Then you may add cells that touch a range of points, or cells
intersected by a polytope, or cells belonging to another CellGeometry
object, or cells belonging to a CubicalComplex.
object.

- CellGeometry::addCellsTouchingPoints: Updates the cell cover with
the cells touching a range of digital points [itB, itE).
Expand All @@ -195,9 +196,6 @@ object, or cells belonging to a CubicalComplex.
- CellGeometry::operator+=( const CellGeometry& other ): Adds the
cells of dimension k of object \a other, for `minCellDim() <= k <=
maxCellDim()`, to this cell geometry.
- CellGeometry::operator+=( const CubicalComplex& CC ): Adds the cells
of dimension k of cubical complex \a CC, for `minCellDim() <= k <=
maxCellDim()`, to this cell geometry.

With respect to full digital convexity,
CellGeometry::addCellsTouchingPolytope is very important since it
Expand Down Expand Up @@ -299,7 +297,7 @@ The class BoundedLatticePolytope is different from the class LatticePolytope2D f
There are no simple conversion from one to the other. Class
LatticePolytope2D is optimized for cuts and lattice points
enumeration, and is very specific to 2D. Class BoundedLatticePolytope
is less optimized to the previous one but works in nD and provides
is less optimized than the previous one but works in nD and provides
Minkowski sum and dilation services.


Expand Down
Loading