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

Adding mesh double description #450

Merged

Conversation

lmontaut
Copy link
Contributor

A polytope can be seen as either a set of vertices or a set of planes (normals + offsets).
The double description is normals + offsets.
In GJK/EPA we only use the vertices of polytopes. However, for computing normals/witness points, having the double description may be usefull in the future.

@lmontaut lmontaut requested a review from jcarpent July 27, 2023 15:24
Comment on lines 73 to 86
if (other.neighbors) {
neighbors = new Neighbors[num_points];
std::copy(other.neighbors, other.neighbors + num_points, neighbors);
} else
neighbors = nullptr;

if (other.nneighbors_) {
std::size_t c_nneighbors = 0;
for (std::size_t i = 0; i < num_points; ++i)
c_nneighbors += neighbors[i].count();
nneighbors_ = new unsigned int[c_nneighbors];
std::copy(other.nneighbors_, other.nneighbors_ + c_nneighbors, nneighbors_);
} else
nneighbors_ = nullptr;
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the strategy for own_storage_?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For the moment the ConvexBase/Convex<PolygonT> always owns its normals and offsets.
However I can do the same strategy as for points.
For it to make sense though, this requires adding a constructor to Convex<PolygonT> or at least a function buildDoubleRepresentation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jcarpent I can put a function buildDoubleRepresentation in ConvexBase and remove the normals construction from ConvexBase::convexHull.
Then, either the user calls buildDoubleRepresentation or we force the call to buildDoubleRepresentation at the end of convexHull (in the future, we might systematically need the double representation information for witness points after calling GJK/EPA).

Copy link
Contributor

Choose a reason for hiding this comment

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

At first glance, the double description should not be computed when creating the objects to avoid any computational burden.

Copy link
Contributor Author

@lmontaut lmontaut Jul 28, 2023

Choose a reason for hiding this comment

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

Yes I agree but since we call Qhull inside ConvexBase::convexHull, we get the double representation for free. Computing the double representation later would result in computationnal burden (need to call Qhull again).
I will restructure the code so that ConvexBase::convexHull still constructs the double representation but buildDoubleRepresentation can still be called later i.e for Convex objects which have not been constructed by the ConvexBase::convexHull function.
Does this sound ok for you?

Copy link
Contributor

Choose a reason for hiding this comment

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

Good to me.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe, adding a method hasDoubleDescription() could help by checking the content of the pointers (if they are not NULL for instance)

Comment on lines 88 to 98
if (other.normals) {
normals = new Vec3f[num_normals_and_offsets];
std::copy(other.normals, other.normals + num_normals_and_offsets, normals);
} else
normals = nullptr;

if (other.offsets) {
offsets = new FCL_REAL[num_normals_and_offsets];
std::copy(other.offsets, other.offsets + num_normals_and_offsets, offsets);
} else
offsets = nullptr;
Copy link
Contributor

Choose a reason for hiding this comment

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

The same question applies here.

@lmontaut
Copy link
Contributor Author

@jcarpent what do you think about changing points, normals and offsets in ConvexBase from a regular pointer to a shared_ptr? This would remove the concept of own_storage and simplify having to keep track whether a Convex owns its points representation and/or its normals + offsets representation.

@jcarpent
Copy link
Contributor

@jcarpent what do you think about changing points, normals and offsets in ConvexBase from a regular pointer to a shared_ptr? This would remove the concept of own_storage and simplify having to keep track whether a Convex owns its points representation and/or its normals + offsets representation.

Looks good to me. I do think we need to transition from raw pointers to smart ones in all the code.
A huge task, but will simplify our life in the very near future.

@lmontaut lmontaut marked this pull request as draft July 28, 2023 17:02
@lmontaut lmontaut force-pushed the topic/hppfcl3x/mesh-double-description branch from 6ceb435 to 4a8a162 Compare August 9, 2023 17:32
@lmontaut lmontaut marked this pull request as ready for review August 9, 2023 17:33
@jcarpent jcarpent force-pushed the topic/hppfcl3x/mesh-double-description branch from 651813c to 08d2dd5 Compare August 10, 2023 10:21
src/shape/convex.cpp Outdated Show resolved Hide resolved
Comment on lines 162 to 163
typedef Eigen::Map<RowMatrixX3> MapVecOfDoubles;
typedef Eigen::Ref<RowMatrixX3> RefVecOfDoubles;
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not totally correct. This is just a copy-pasting of previous lines.

Comment on lines 160 to 161
typedef Eigen::Matrix<double, Eigen::Dynamic, 1, Eigen::RowMajor>
VecOfDoubles;
Copy link
Contributor

Choose a reason for hiding this comment

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

I would call it VectorX.

Copy link
Contributor

Choose a reason for hiding this comment

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

Row::Major is not needed. You can also use Eigen::VectorXd

Comment on lines 160 to 161
typedef Eigen::Matrix<double, Eigen::Dynamic, 1, Eigen::RowMajor>
VecOfDoubles;
Copy link
Contributor

Choose a reason for hiding this comment

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

Row::Major is not needed. You can also use Eigen::VectorXd

@lmontaut lmontaut force-pushed the topic/hppfcl3x/mesh-double-description branch from f0161a4 to a89bd24 Compare September 7, 2023 13:43
[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci
@lmontaut lmontaut force-pushed the topic/hppfcl3x/mesh-double-description branch from 0926120 to 3ea3001 Compare September 7, 2023 14:05
@jcarpent jcarpent merged commit 3766c24 into coal-library:hppfcl3x Sep 22, 2023
18 of 20 checks passed
@lmontaut lmontaut deleted the topic/hppfcl3x/mesh-double-description branch November 13, 2023 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants