Skip to content

Commit 108dd06

Browse files
doyubkimutilForever
authored andcommitted
Fix isBound function for surface set classes (#235)
1 parent 874499d commit 108dd06

14 files changed

+149
-3
lines changed

include/jet/implicit_surface_set2.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ class ImplicitSurfaceSet2 final : public ImplicitSurface2 {
4444
//! Updates internal spatial query engine.
4545
void updateQueryEngine() override;
4646

47+
//! Returns true if bounding box can be defined.
48+
bool isBounded() const override;
49+
4750
//! Returns true if the surface is a valid geometry.
4851
bool isValidGeometry() const override;
4952

include/jet/implicit_surface_set3.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ class ImplicitSurfaceSet3 final : public ImplicitSurface3 {
4444
//! Updates internal spatial query engine.
4545
void updateQueryEngine() override;
4646

47+
//! Returns true if bounding box can be defined.
48+
bool isBounded() const override;
49+
4750
//! Returns true if the surface is a valid geometry.
4851
bool isValidGeometry() const override;
4952

include/jet/surface_set2.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ class SurfaceSet2 final : public Surface2 {
3939
//! Updates internal spatial query engine.
4040
void updateQueryEngine() override;
4141

42+
//! Returns true if bounding box can be defined.
43+
bool isBounded() const override;
44+
4245
//! Returns true if the surface is a valid geometry.
4346
bool isValidGeometry() const override;
4447

include/jet/surface_set3.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ class SurfaceSet3 final : public Surface3 {
3939
//! Updates internal spatial query engine.
4040
void updateQueryEngine() override;
4141

42+
//! Returns true if bounding box can be defined.
43+
bool isBounded() const override;
44+
4245
//! Returns true if the surface is a valid geometry.
4346
bool isValidGeometry() const override;
4447

src/jet/implicit_surface_set2.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,18 @@ ImplicitSurfaceSet2::ImplicitSurfaceSet2(const ImplicitSurfaceSet2& other)
4141

4242
void ImplicitSurfaceSet2::updateQueryEngine() { buildBvh(); }
4343

44+
bool ImplicitSurfaceSet2::isBounded() const {
45+
// All surfaces should be bounded.
46+
for (auto surface : _surfaces) {
47+
if (!surface->isBounded()) {
48+
return false;
49+
}
50+
}
51+
52+
// Empty set is not bounded.
53+
return !_surfaces.empty();
54+
}
55+
4456
bool ImplicitSurfaceSet2::isValidGeometry() const {
4557
// All surfaces should be valid.
4658
for (auto surface : _surfaces) {

src/jet/implicit_surface_set3.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,18 @@ ImplicitSurfaceSet3::ImplicitSurfaceSet3(const ImplicitSurfaceSet3& other)
4141

4242
void ImplicitSurfaceSet3::updateQueryEngine() { buildBvh(); }
4343

44+
bool ImplicitSurfaceSet3::isBounded() const {
45+
// All surfaces should be bounded.
46+
for (auto surface : _surfaces) {
47+
if (!surface->isBounded()) {
48+
return false;
49+
}
50+
}
51+
52+
// Empty set is not bounded.
53+
return !_surfaces.empty();
54+
}
55+
4456
bool ImplicitSurfaceSet3::isValidGeometry() const {
4557
// All surfaces should be valid.
4658
for (auto surface : _surfaces) {

src/jet/surface2.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ bool Surface2::isBounded() const { return true; }
6060
bool Surface2::isValidGeometry() const { return true; }
6161

6262
bool Surface2::isInside(const Vector2D& otherPoint) const {
63-
return isInsideLocal(transform.toLocal(otherPoint));
63+
return isNormalFlipped == !isInsideLocal(transform.toLocal(otherPoint));
6464
}
6565

6666
bool Surface2::intersectsLocal(const Ray2D& rayLocal) const {

src/jet/surface3.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ bool Surface3::isBounded() const { return true; }
6565
bool Surface3::isValidGeometry() const { return true; }
6666

6767
bool Surface3::isInside(const Vector3D& otherPoint) const {
68-
return isInsideLocal(transform.toLocal(otherPoint));
68+
return isNormalFlipped == !isInsideLocal(transform.toLocal(otherPoint));
6969
}
7070

7171
double Surface3::closestDistanceLocal(const Vector3D& otherPointLocal) const {

src/jet/surface_set2.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,18 @@ SurfaceSet2::SurfaceSet2(const SurfaceSet2& other)
3232

3333
void SurfaceSet2::updateQueryEngine() { buildBvh(); }
3434

35+
bool SurfaceSet2::isBounded() const {
36+
// All surfaces should be bounded.
37+
for (auto surface : _surfaces) {
38+
if (!surface->isBounded()) {
39+
return false;
40+
}
41+
}
42+
43+
// Empty set is not bounded.
44+
return !_surfaces.empty();
45+
}
46+
3547
bool SurfaceSet2::isValidGeometry() const {
3648
// All surfaces should be valid.
3749
for (auto surface : _surfaces) {

src/jet/surface_set3.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,18 @@ SurfaceSet3::SurfaceSet3(const SurfaceSet3& other)
3232

3333
void SurfaceSet3::updateQueryEngine() { buildBvh(); }
3434

35+
bool SurfaceSet3::isBounded() const {
36+
// All surfaces should be bounded.
37+
for (auto surface : _surfaces) {
38+
if (!surface->isBounded()) {
39+
return false;
40+
}
41+
}
42+
43+
// Empty set is not bounded.
44+
return !_surfaces.empty();
45+
}
46+
3547
bool SurfaceSet3::isValidGeometry() const {
3648
// All surfaces should be valid.
3749
for (auto surface : _surfaces) {

0 commit comments

Comments
 (0)