Conversation
7a2d81f to
ea0bfec
Compare
|
The You could do so here, if that would provide improvement? |
|
I'm not sure it would provide an improvement. The reasons I can see it being an improvement are:
If I understand correctly it would probably be preferable to not introduce this link if possible, but I don't understand the above considerations well enough to say that it isn't needed (nor do I know what other considerations I have overlooked) |
|
To help the reviewer, linked issue says |
I don't think I'm answering this (I'm not sure what NeXuS standard is, nor what precedent is being set out) but here is a brief overview of what I think the linked issue is suggesting the solution be
which is used by mantid/Framework/NexusGeometry/src/NexusGeometryParser.cpp Lines 662 to 682 in cd229b5 where
mantid/Framework/NexusGeometry/src/NexusShapeFactory.cpp Lines 182 to 198 in cd229b5 So basically using NX_OFF requires adding support for converting the existing So I would say the approach in this PR is more efficient, I think it is probably not formalised as a nexus standard though. I suppose if we did go down the route of linking in |
| if (auto meshObject = std::dynamic_pointer_cast<Mantid::Geometry::MeshObject>(m_shape)) { | ||
| const int hasMesh = 1; | ||
| file->writeData("vertices", meshObject->getVertices()); | ||
| file->writeData("faces", meshObject->getTriangles()); | ||
| file->putAttr("shape_mesh", hasMesh); | ||
| } |
There was a problem hiding this comment.
In the MeshObject class, add a method saveNexus() that will handle saving these.
Framework/API/src/Sample.cpp
Outdated
| if (hasMesh == 1) { | ||
| std::vector<double> flatVertices; | ||
| std::vector<uint32_t> faces; | ||
|
|
||
| file->readData("vertices", flatVertices); | ||
| file->readData("faces", faces); | ||
|
|
||
| const size_t nverts = flatVertices.size() / 3; | ||
| std::vector<Mantid::Kernel::V3D> vertices; | ||
| vertices.reserve(nverts); | ||
| for (size_t i = 0; i < nverts; ++i) { | ||
| vertices.emplace_back(flatVertices[3 * i + 0], flatVertices[3 * i + 1], flatVertices[3 * i + 2]); | ||
| } |
There was a problem hiding this comment.
In the MeshObject class, add a method loadNexus() that will handle these steps
|
Further update, after discussions, I proposed these two solution options:
Having looked into the first option I think it is even more convoluted as I think So can't directly link without a circular dependency. For this reason I think the second option - packaging the existing changes into functions on mesh object, is the way to go? |
Description of work
Currently the only sample/environment shape information that is saved to a nexus file is the sample shape if it is a CSG shape. I have extended it to now also handle mesh shapes.
This is discussed in #28581 but this does not close that issue as I haven't added handling for the environment.
I would have liked to use some more of the existing tools, specifically the NX_OFF and the
NexusGeometryParserdiscussed in the issue, but they cannot be brought into API::Sample (at least, I couldn't do it).The solution I gone with seems deceptively simple, just saving the vertices and face arrays directly. Upon loading I just reconstruct the MeshObject by reading these arrays. I do have some uncertainty about the scope and ownership of the newly created object, but my hope is that the
std::make_shared<Mantid::Geometry::MeshObject>takes care of that.To test:
run the following script
If you have any other ideas of where this might break things please test/ let me know
Reviewer
Your comments will be used as part of the gatekeeper process. Comment clearly on what you have checked and tested during your review. Provide an audit trail for any changes requested.
As per the review guidelines:
mantid-developersormantid-contributorsteams, add a review commentrerun cito authorize/rerun the CIGatekeeper
As per the gatekeeping guidelines: