Skip to content

Commit bca8875

Browse files
committed
feat(criterion): Add inspector criterion on degeneration for SurfaceMesh and SolidMesh
1 parent 322f0d9 commit bca8875

File tree

10 files changed

+475
-109
lines changed

10 files changed

+475
-109
lines changed

.github/workflows/CD.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ jobs:
3030
cd build
3131
version="${GITHUB_REF##*/*/}"
3232
echo ::set-output name=version::$version
33-
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH:PATH=${{ steps.opengeode.outputs.path }} -DMYMODULE_WITH_TESTS:BOOL=OFF -DCPACK_PACKAGE_VERSION:STRING=$version -DCPACK_SYSTEM_NAME:STRING=${{ matrix.config.system }} ..
33+
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH:PATH=${{ steps.opengeode.outputs.path }} -DOPENGEODE_INSPECTOR_WITH_TESTS:BOOL=OFF -DCPACK_PACKAGE_VERSION:STRING=$version -DCPACK_SYSTEM_NAME:STRING=${{ matrix.config.system }} ..
3434
cmake --build . -- -j2
3535
cmake --build . --target package
3636
- name: Upload
3737
uses: softprops/action-gh-release@v1
3838
with:
39-
files: "build/MyModule-${{ steps.package.outputs.version }}-${{ matrix.config.system }}.tar.gz"
39+
files: "build/OpenGeode-inspector-${{ steps.package.outputs.version }}-${{ matrix.config.system }}.tar.gz"
4040
env:
4141
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4242
- name: Doc
@@ -63,13 +63,13 @@ jobs:
6363
cd build
6464
version="${GITHUB_REF##*/*/}"
6565
echo ::set-output name=version::$version
66-
cmake -G "Xcode" -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH:PATH=${{ steps.opengeode.outputs.path }} -DMYMODULE_WITH_TESTS:BOOL=OFF -DCPACK_PACKAGE_VERSION:STRING=$version -DCPACK_SYSTEM_NAME:STRING=darwin ..
66+
cmake -G "Xcode" -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH:PATH=${{ steps.opengeode.outputs.path }} -DOPENGEODE_INSPECTOR_WITH_TESTS:BOOL=OFF -DCPACK_PACKAGE_VERSION:STRING=$version -DCPACK_SYSTEM_NAME:STRING=darwin ..
6767
cmake --build . --config Release
6868
cmake --build . --target package --config Release
6969
- name: Upload
7070
uses: softprops/action-gh-release@v1
7171
with:
72-
files: "build/MyModule-${{ steps.package.outputs.version }}-darwin.tar.gz"
72+
files: "build/OpenGeode-inspector-${{ steps.package.outputs.version }}-darwin.tar.gz"
7373
env:
7474
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7575

@@ -91,13 +91,13 @@ jobs:
9191
cd build
9292
version="${GITHUB_REF##*/*/}"
9393
echo ::set-output name=version::$version
94-
cmake -G "Visual Studio 15 2017 Win64" -DCMAKE_PREFIX_PATH:PATH=${{ steps.opengeode.outputs.path }} -DMYMODULE_WITH_TESTS:BOOL=OFF -DCPACK_PACKAGE_VERSION:STRING=$version -DCPACK_SYSTEM_NAME:STRING=win64 ..
94+
cmake -G "Visual Studio 15 2017 Win64" -DCMAKE_PREFIX_PATH:PATH=${{ steps.opengeode.outputs.path }} -DOPENGEODE_INSPECTOR_WITH_TESTS:BOOL=OFF -DCPACK_PACKAGE_VERSION:STRING=$version -DCPACK_SYSTEM_NAME:STRING=win64 ..
9595
cmake --build . --config Release
9696
cmake --build . --target PACKAGE --config Release
9797
shell: bash
9898
- name: Upload
9999
uses: softprops/action-gh-release@v1
100100
with:
101-
files: "build/MyModule-${{ steps.package.outputs.version }}-win64.zip"
101+
files: "build/OpenGeode-inspector-${{ steps.package.outputs.version }}-win64.zip"
102102
env:
103103
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
* Copyright (c) 2019 - 2021 Geode-solutions
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy
5+
* of this software and associated documentation files (the "Software"), to deal
6+
* in the Software without restriction, including without limitation the rights
7+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
* copies of the Software, and to permit persons to whom the Software is
9+
* furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
* SOFTWARE.
21+
*
22+
*/
23+
24+
#pragma once
25+
26+
#include <geode/basic/pimpl.h>
27+
28+
#include <geode/inspector/common.h>
29+
30+
namespace geode
31+
{
32+
FORWARD_DECLARATION_DIMENSION_CLASS( SolidMesh );
33+
ALIAS_3D( SolidMesh );
34+
} // namespace geode
35+
36+
namespace geode
37+
{
38+
namespace inspector
39+
{
40+
/*!
41+
* Class for inspecting the degeneration of a SolidMesh
42+
*/
43+
class SolidMeshDegeneration
44+
{
45+
public:
46+
SolidMeshDegeneration();
47+
~SolidMeshDegeneration();
48+
49+
bool is_mesh_degenerated( const SolidMesh3D& mesh ) const;
50+
51+
index_t nb_degenerated_edges( const SolidMesh3D& mesh ) const;
52+
53+
const std::vector< index_t > degenerated_edges(
54+
const SolidMesh3D& mesh ) const;
55+
56+
private:
57+
// SolidMeshDegeneration( SolidMeshDegeneration&& other );
58+
59+
IMPLEMENTATION_MEMBER( impl_ );
60+
};
61+
} // namespace inspector
62+
} // namespace geode

include/geode/inspector/criterion/degeneration.h renamed to include/geode/inspector/criterion/degeneration/surface_degeneration.h

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
namespace geode
3131
{
3232
FORWARD_DECLARATION_DIMENSION_CLASS( SurfaceMesh );
33-
FORWARD_DECLARATION_DIMENSION_CLASS( SolidMesh );
3433
} // namespace geode
3534

3635
namespace geode
@@ -44,8 +43,7 @@ namespace geode
4443
class opengeode_inspector_inspector_api SurfaceMeshDegeneration
4544
{
4645
public:
47-
SurfaceMeshDegeneration() = default;
48-
SurfaceMeshDegeneration( SurfaceMeshDegeneration&& other );
46+
SurfaceMeshDegeneration();
4947
~SurfaceMeshDegeneration();
5048

5149
bool is_mesh_degenerated(
@@ -58,30 +56,10 @@ namespace geode
5856
const SurfaceMesh< dimension >& mesh ) const;
5957

6058
private:
59+
// SurfaceMeshDegeneration( SurfaceMeshDegeneration&& other );
60+
6161
IMPLEMENTATION_MEMBER( impl_ );
6262
};
6363
ALIAS_2D_AND_3D( SurfaceMeshDegeneration );
64-
65-
// template < index_t dimension >
66-
// class SolidMeshDegeneration
67-
// {
68-
// public:
69-
// SolidMeshDegeneration();
70-
// SolidMeshDegeneration( SolidMeshDegeneration&& other );
71-
// ~SolidMeshDegeneration();
72-
73-
// bool is_mesh_degenerated(
74-
// const SolidMesh< dimension >& mesh ) const;
75-
76-
// index_t nb_degenerated_edges(
77-
// const SolidMesh< dimension >& mesh ) const;
78-
79-
// const std::vector< index_t > degenerated_edges(
80-
// const SolidMesh< dimension >& mesh ) const;
81-
82-
// private:
83-
// IMPLEMENTATION_MEMBER( impl_ );
84-
// };
85-
// ALIAS_2D_AND_3D( SolidMeshDegeneration );
8664
} // namespace inspector
8765
} // namespace geode

src/geode/inspector/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@ add_geode_library(
2323
FOLDER "geode/inspector"
2424
SOURCES
2525
"common.cpp"
26-
"criterion/degeneration.cpp"
26+
"criterion/degeneration/surface_degeneration.cpp"
27+
"criterion/degeneration/solid_degeneration.cpp"
2728
PUBLIC_HEADERS
2829
"common.h"
29-
"criterion/degeneration.h"
30+
"criterion/degeneration/surface_degeneration.h"
31+
"criterion/degeneration/solid_degeneration.h"
3032
ADVANCED_HEADERS
3133
# "mixin/core/detail/components_storage.h"
3234
PRIVATE_HEADERS
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
/*
2+
* Copyright (c) 2019 - 2021 Geode-solutions
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy
5+
* of this software and associated documentation files (the "Software"), to deal
6+
* in the Software without restriction, including without limitation the rights
7+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
* copies of the Software, and to permit persons to whom the Software is
9+
* furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
* SOFTWARE.
21+
*
22+
*/
23+
24+
#include <geode/inspector/criterion/degeneration/solid_degeneration.h>
25+
26+
#include <geode/basic/pimpl_impl.h>
27+
28+
#include <geode/mesh/core/solid_edges.h>
29+
#include <geode/mesh/core/solid_mesh.h>
30+
31+
#include <geode/geometry/distance.h>
32+
#include <geode/geometry/point.h>
33+
34+
namespace geode
35+
{
36+
namespace inspector
37+
{
38+
class SolidMeshDegeneration::Impl
39+
{
40+
public:
41+
Impl() = default;
42+
43+
bool is_mesh_degenerated( const SolidMesh3D& mesh ) const
44+
{
45+
bool is_degenerated = false;
46+
47+
mesh.enable_edges();
48+
for( auto edge_index : Range( mesh.edges().nb_edges() ) )
49+
{
50+
const auto edge_vertices =
51+
mesh.edges().edge_vertices( edge_index );
52+
const Point3D &p1 = mesh.point( edge_vertices[0] ),
53+
p2 = mesh.point( edge_vertices[1] );
54+
if( geode::point_point_distance( p1, p2 ) < global_epsilon )
55+
{
56+
is_degenerated = true;
57+
break;
58+
}
59+
}
60+
61+
return is_degenerated;
62+
}
63+
64+
index_t nb_degenerated_edges( const SolidMesh3D& mesh ) const
65+
{
66+
index_t nb_degeneration = 0;
67+
68+
mesh.enable_edges();
69+
for( auto edge_index : Range( mesh.edges().nb_edges() ) )
70+
{
71+
const auto edge_vertices =
72+
mesh.edges().edge_vertices( edge_index );
73+
const Point3D &p1 = mesh.point( edge_vertices[0] ),
74+
p2 = mesh.point( edge_vertices[1] );
75+
if( geode::point_point_distance( p1, p2 ) < global_epsilon )
76+
{
77+
nb_degeneration++;
78+
}
79+
}
80+
81+
return nb_degeneration;
82+
}
83+
84+
std::vector< index_t > degenerated_edges(
85+
const SolidMesh3D& mesh ) const
86+
{
87+
std::vector< index_t > degenerated_edges_index;
88+
89+
mesh.enable_edges();
90+
for( auto edge_index : Range( mesh.edges().nb_edges() ) )
91+
{
92+
const auto edge_vertices =
93+
mesh.edges().edge_vertices( edge_index );
94+
const Point3D &p1 = mesh.point( edge_vertices[0] ),
95+
p2 = mesh.point( edge_vertices[1] );
96+
if( geode::point_point_distance( p1, p2 ) < global_epsilon )
97+
{
98+
degenerated_edges_index.push_back( edge_index );
99+
}
100+
}
101+
102+
return degenerated_edges_index;
103+
}
104+
};
105+
106+
SolidMeshDegeneration::SolidMeshDegeneration() {}
107+
108+
SolidMeshDegeneration::~SolidMeshDegeneration() {}
109+
110+
bool SolidMeshDegeneration::is_mesh_degenerated(
111+
const SolidMesh3D& mesh ) const
112+
{
113+
return impl_->is_mesh_degenerated( mesh );
114+
}
115+
116+
index_t SolidMeshDegeneration::nb_degenerated_edges(
117+
const SolidMesh3D& mesh ) const
118+
{
119+
return impl_->nb_degenerated_edges( mesh );
120+
}
121+
122+
const std::vector< index_t > SolidMeshDegeneration::degenerated_edges(
123+
const SolidMesh3D& mesh ) const
124+
{
125+
return impl_->degenerated_edges( mesh );
126+
}
127+
} // namespace inspector
128+
} // namespace geode

src/geode/inspector/criterion/degeneration.cpp renamed to src/geode/inspector/criterion/degeneration/surface_degeneration.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
*
2222
*/
2323

24-
#include <geode/inspector/criterion/degeneration.h>
24+
#include <geode/inspector/criterion/degeneration/surface_degeneration.h>
2525

2626
#include <geode/basic/pimpl_impl.h>
2727

@@ -67,7 +67,7 @@ namespace geode
6767
index_t nb_degenerated_edges(
6868
const SurfaceMesh< dimension >& mesh ) const
6969
{
70-
index_t nb_degeneration;
70+
index_t nb_degeneration = 0;
7171

7272
mesh.enable_edges();
7373
for( auto edge_index : Range( mesh.edges().nb_edges() ) )
@@ -89,7 +89,7 @@ namespace geode
8989
std::vector< index_t > degenerated_edges(
9090
const SurfaceMesh< dimension >& mesh ) const
9191
{
92-
std::vector< index_t > degenerated_edge_points;
92+
std::vector< index_t > degenerated_edges_index;
9393

9494
mesh.enable_edges();
9595
for( auto edge_index : Range( mesh.edges().nb_edges() ) )
@@ -101,14 +101,19 @@ namespace geode
101101
p2 = mesh.point( edge_vertices[1] );
102102
if( geode::point_point_distance( p1, p2 ) < global_epsilon )
103103
{
104-
degenerated_edge_points.push_back( edge_index );
104+
degenerated_edges_index.push_back( edge_index );
105105
}
106106
}
107107

108-
return degenerated_edge_points;
108+
return degenerated_edges_index;
109109
}
110110
};
111111

112+
template < index_t dimension >
113+
SurfaceMeshDegeneration< dimension >::SurfaceMeshDegeneration()
114+
{
115+
}
116+
112117
template < index_t dimension >
113118
SurfaceMeshDegeneration< dimension >::~SurfaceMeshDegeneration()
114119
{

tests/inspector/CMakeLists.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,19 @@
1919
# SOFTWARE.
2020

2121
add_geode_test(
22-
SOURCE "test-degeneration.cpp"
22+
SOURCE "test-surface-degeneration.cpp"
2323
DEPENDENCIES
2424
OpenGeode::basic
2525
OpenGeode::geometry
2626
OpenGeode::mesh
2727
${PROJECT_NAME}::inspector
2828
)
29+
30+
add_geode_test(
31+
SOURCE "test-solid-degeneration.cpp"
32+
DEPENDENCIES
33+
OpenGeode::basic
34+
OpenGeode::geometry
35+
OpenGeode::mesh
36+
${PROJECT_NAME}::inspector
37+
)

0 commit comments

Comments
 (0)