Skip to content

Commit

Permalink
Fix global polydec sharp/flat
Browse files Browse the repository at this point in the history
  • Loading branch information
Deploy from CI committed Jan 27, 2025
1 parent 8134cfa commit 4379c52
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 15 deletions.
2 changes: 1 addition & 1 deletion examples/polyscope-examples/dgtalFEM-poisson.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ int main()
auto params = SH3::defaultParameters() | SHG3::defaultParameters() | SHG3::parametersGeometryEstimation();

auto h=.7 ; //gridstep
params( "polynomial", "0.1*y*y -0.1*x*x - 2.0*z" )( "gridstep", h );
params( "polynomial", "0.1*y*y -0.1*x*x - 2.1*z" )( "gridstep", h );
auto implicit_shape = SH3::makeImplicitShape3D ( params );
auto digitized_shape = SH3::makeDigitizedImplicitShape3D( implicit_shape, params );
auto K = SH3::getKSpace( params );
Expand Down
37 changes: 23 additions & 14 deletions src/DGtal/dec/PolygonalCalculus.h
Original file line number Diff line number Diff line change
Expand Up @@ -1488,10 +1488,14 @@ namespace DGtal
auto v = sharp( j, i );
auto edge_i = mySurfaceMesh->makeEdge( vertices[ i ],
vertices[ ( i + 1 ) % nf ] );
if ( v != 0.0 )
triplets.emplace_back( Triplet(
(SparseMatrix::StorageIndex)f + j * mySurfaceMesh->nbFaces(),
(SparseMatrix::StorageIndex)edge_i, v ) );
if(vertices[i] < vertices[(i + 1) % nf])
triplets.emplace_back( Triplet(
(SparseMatrix::StorageIndex)3 * f + j,
(SparseMatrix::StorageIndex)edge_i, v ) );
else
triplets.emplace_back( Triplet(
(SparseMatrix::StorageIndex)3 * f + j,
(SparseMatrix::StorageIndex)edge_i, -v ) );
}
}
mySharp.setFromTriplets( triplets.begin(), triplets.end() );
Expand All @@ -1510,17 +1514,22 @@ namespace DGtal
DenseMatrix flat = this->flat( f );
const auto vertices = mySurfaceMesh->incidentVertices( f );
for ( auto i = 0u; i < nf; ++i )
for ( auto j = 0; j < 3; ++j )
{
auto v = flat( i, j );
for ( auto j = 0; j < 3; ++j )
{
auto edge_i = mySurfaceMesh->makeEdge( vertices[ i ],
vertices[ ( i + 1 ) % nf ] );
if ( v != 0.0 )
triplets.emplace_back( Triplet(
(SparseMatrix::StorageIndex)edge_i,
(SparseMatrix::StorageIndex)f + j * mySurfaceMesh->nbFaces(),
v ) );
}
vertices[ ( i + 1 ) % nf ] );
auto v = flat( i, j ) / (double) mySurfaceMesh->edgeFaces(edge_i).size();
if(vertices[i] < vertices[(i + 1) % nf])
triplets.emplace_back( Triplet(
(SparseMatrix::StorageIndex)edge_i,
(SparseMatrix::StorageIndex)3 * f + j,
v ) );
else
triplets.emplace_back( Triplet(
(SparseMatrix::StorageIndex)edge_i,
(SparseMatrix::StorageIndex)3 * f + j,
-v ) );
}
}
myFlat.setFromTriplets( triplets.begin(), triplets.end() );
return myFlat;
Expand Down

0 comments on commit 4379c52

Please sign in to comment.