-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
75cfd93
commit 6a90096
Showing
20 changed files
with
619 additions
and
250 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
tesseract_geometry/include/tesseract_geometry/impl/compound_mesh.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/** | ||
* @file compound_mesh.h | ||
* @brief Tesseract Compound Mesh Geometry | ||
* | ||
* @author Levi Armstrong | ||
* @date September 14, 2024 | ||
* @version TODO | ||
* @bug No known bugs | ||
* | ||
* @copyright Copyright (c) 2024, Levi Armstrong | ||
* | ||
* @par License | ||
* Software License Agreement (Apache License) | ||
* @par | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* @par | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
#ifndef TESSERACT_GEOMETRY_COMPOUND_MESH_H | ||
#define TESSERACT_GEOMETRY_COMPOUND_MESH_H | ||
|
||
#include <tesseract_common/macros.h> | ||
TESSERACT_COMMON_IGNORE_WARNINGS_PUSH | ||
#include <boost/serialization/export.hpp> | ||
#include <memory> | ||
TESSERACT_COMMON_IGNORE_WARNINGS_POP | ||
|
||
#include <tesseract_geometry/impl/polygon_mesh.h> | ||
|
||
namespace boost::serialization | ||
{ | ||
class access; | ||
} | ||
|
||
namespace tesseract_geometry | ||
{ | ||
/** @brief This is store meshes that are associated with as single resource */ | ||
class CompoundMesh : public Geometry | ||
{ | ||
public: | ||
using Ptr = std::shared_ptr<CompoundMesh>; | ||
using ConstPtr = std::shared_ptr<const CompoundMesh>; | ||
|
||
CompoundMesh() = default; | ||
CompoundMesh(std::vector<std::shared_ptr<PolygonMesh>> meshes); | ||
|
||
/** | ||
* @brief Get the meshes | ||
* @return The meshes | ||
*/ | ||
const std::vector<std::shared_ptr<PolygonMesh>>& getMeshes() const; | ||
|
||
/** | ||
* @brief Get the path to file used to generate the meshs | ||
* | ||
* Note: If empty, assume it was manually generated. | ||
* | ||
* @return Absolute path to the mesh file | ||
*/ | ||
std::shared_ptr<const tesseract_common::Resource> getResource() const; | ||
|
||
/** | ||
* @brief Get the scale applied to file used to generate the meshs | ||
* @return The scale x, y, z | ||
*/ | ||
const Eigen::Vector3d& getScale() const; | ||
|
||
Geometry::Ptr clone() const override final; | ||
|
||
bool operator==(const CompoundMesh& rhs) const; | ||
bool operator!=(const CompoundMesh& rhs) const; | ||
|
||
private: | ||
std::vector<std::shared_ptr<PolygonMesh>> meshes_; | ||
|
||
friend class boost::serialization::access; | ||
template <class Archive> | ||
void serialize(Archive& ar, const unsigned int version); // NOLINT | ||
}; | ||
|
||
} // namespace tesseract_geometry | ||
|
||
BOOST_CLASS_EXPORT_KEY(tesseract_geometry::CompoundMesh) | ||
|
||
#endif // TESSERACT_GEOMETRY_COMPOUND_MESH_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/** | ||
* @file compund_mesh.cpp | ||
* @brief Tesseract Compound Mesh Geometry | ||
* | ||
* @author Levi Armstrong | ||
* @date March 16, 2022 | ||
* @version TODO | ||
* @bug No known bugs | ||
* | ||
* @par License | ||
* Software License Agreement (Apache License) | ||
* @par | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* @par | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include <tesseract_common/macros.h> | ||
TESSERACT_COMMON_IGNORE_WARNINGS_PUSH | ||
#include <boost/serialization/access.hpp> | ||
#include <boost/serialization/base_object.hpp> | ||
#include <boost/serialization/nvp.hpp> | ||
#include <boost/serialization/vector.hpp> | ||
#include <boost/serialization/shared_ptr.hpp> | ||
TESSERACT_COMMON_IGNORE_WARNINGS_POP | ||
|
||
#include <tesseract_common/utils.h> | ||
#include <tesseract_geometry/impl/compound_mesh.h> | ||
|
||
namespace tesseract_geometry | ||
{ | ||
CompoundMesh::CompoundMesh(std::vector<std::shared_ptr<PolygonMesh>> meshes) | ||
: Geometry(GeometryType::COMPOUND_MESH), meshes_(std::move(meshes)) | ||
{ | ||
if (meshes_.size() <= 1) | ||
throw std::runtime_error("Meshes must contain more than one mesh"); | ||
|
||
#ifndef NDEBUG | ||
for (const auto& mesh : meshes_) | ||
{ | ||
assert(meshes_[0]->getResource() == mesh->getResource()); | ||
assert(tesseract_common::almostEqualRelativeAndAbs(meshes_[0]->getScale(), mesh->getScale())); | ||
} | ||
#endif | ||
} | ||
|
||
const std::vector<std::shared_ptr<PolygonMesh>>& CompoundMesh::getMeshes() const { return meshes_; } | ||
|
||
std::shared_ptr<const tesseract_common::Resource> CompoundMesh::getResource() const | ||
{ | ||
return meshes_.front()->getResource(); | ||
} | ||
|
||
const Eigen::Vector3d& CompoundMesh::getScale() const { return meshes_.front()->getScale(); } | ||
|
||
Geometry::Ptr CompoundMesh::clone() const | ||
{ | ||
std::vector<std::shared_ptr<PolygonMesh>> meshes; | ||
meshes.reserve(meshes_.size()); | ||
for (const auto& mesh : meshes_) | ||
meshes.emplace_back(std::dynamic_pointer_cast<PolygonMesh>(mesh->clone())); | ||
|
||
return std::make_shared<CompoundMesh>(meshes); | ||
} | ||
|
||
bool CompoundMesh::operator==(const CompoundMesh& rhs) const | ||
{ | ||
if (meshes_.size() != rhs.meshes_.size()) | ||
return false; | ||
|
||
bool equal = true; | ||
equal &= Geometry::operator==(rhs); | ||
for (std::size_t i = 0; i < meshes_.size(); ++i) | ||
equal &= (*meshes_.at(i) == *rhs.meshes_.at(i)); | ||
|
||
return equal; | ||
} | ||
bool CompoundMesh::operator!=(const CompoundMesh& rhs) const { return !operator==(rhs); } | ||
|
||
template <class Archive> | ||
void CompoundMesh::serialize(Archive& ar, const unsigned int /*version*/) | ||
{ | ||
ar& BOOST_SERIALIZATION_BASE_OBJECT_NVP(Geometry); | ||
ar& BOOST_SERIALIZATION_NVP(meshes_); | ||
} | ||
} // namespace tesseract_geometry | ||
|
||
#include <tesseract_common/serialization.h> | ||
BOOST_CLASS_EXPORT_IMPLEMENT(tesseract_geometry::CompoundMesh) | ||
TESSERACT_SERIALIZE_ARCHIVES_INSTANTIATE(tesseract_geometry::CompoundMesh) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.