Tesseract 0.28.4
Loading...
Searching...
No Matches
tesseract_geometry_serialization_unit.cpp File Reference

Tests serialization of geometry. More...

#include <tesseract/common/macros.h>
#include <gtest/gtest.h>
#include <sstream>
#include <octomap/octomap.h>
#include <cereal/archives/xml.hpp>
#include <tesseract/common/unit_test_utils.h>
#include <tesseract/common/resource_locator.h>
#include <tesseract/common/utils.h>
#include <tesseract/geometry/geometries.h>
#include <tesseract/geometry/mesh_parser.h>
#include <tesseract/geometry/cereal_serialization.h>
#include <tesseract/geometry/impl/octree_utils.h>
#include <tesseract/common/serialization.h>

Functions

meshes push_back (object.front())
 
pc points emplace_back (.5, 0.5, 0.5)
 
pc points emplace_back (-.5, -0.5, -0.5)
 
pc points emplace_back (-.5, 0.5, 0.5)
 
cloned setUUID (orig->getUUID())
 
 EXPECT_EQ (orig_str, clone_str)
 
const Eigen::Vector3i dims (2, 2, 2)
 
SignedDistanceField object (domain, dims, distances)
 
 ar (object)
 
cereal::XMLInputArchive ar (valid)
 
 EXPECT_NO_THROW (ar(loaded))
 
 ASSERT_NE (pos, std::string::npos)
 
corrupted_xml replace (pos, from.size(), to)
 
std::stringstream corrupted (corrupted_xml)
 
cereal::XMLInputArchive ar (corrupted)
 
 EXPECT_ANY_THROW (ar(loaded))
 
int main (int argc, char **argv)
 

Variables

tesseract::common::testSerialization< Box > * object
 
std::string path = "package://tesseract/support/meshes/sphere_p25m.stl"
 
std::vector< tesseract::geometry::PolygonMesh::Ptr > meshes = createMeshFromPath<Mesh>(mesh_file)
 
auto compound_object = std::make_shared<CompoundMesh>(meshes)
 
TestPointCloud pc
 
auto octree = createOctree(pc, 1, false, true)
 
auto orig = std::make_shared<Octree>(std::move(octree), OctreeSubType::BOX, false, true)
 
auto cloned = std::static_pointer_cast<Octree>(orig->clone())
 
auto orig_str = tesseract::common::Serialization::toArchiveStringXML<std::shared_ptr<Octree>>(orig, "octree")
 
auto clone_str = tesseract::common::Serialization::toArchiveStringXML<std::shared_ptr<Octree>>(cloned, "octree")
 
const std::vector< double > distances { -0.5, -0.4, -0.3, -0.2, 0.1, 0.2, 0.3, 0.4 }
 
std::stringstream ss
 
const std::string xml = ss.str()
 
SignedDistanceField loaded
 
std::string corrupted_xml = xml
 
const std::string from = "<dim_x>2</dim_x>"
 
const std::string to = "<dim_x>3</dim_x>"
 
const auto pos = corrupted_xml.find(from)
 

Detailed Description

Tests serialization of geometry.

Author
Levi Armstrong
Matthew Powelson
Date
March 16, 2022
License
Software License Agreement (Apache License)
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
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.

Function Documentation

◆ dims()

const Eigen::Vector3i dims ( ,
,
 
)
Initial value:
{
const Eigen::AlignedBox3d domain(Eigen::Vector3d(-1, -1, -1), Eigen::Vector3d(1, 1, 1))

Variable Documentation

◆ object

Initial value:
{
auto object = std::make_shared<Box>(1, 2, 3)

◆ pc

Initial value:
{
struct TestPointCloud
{
struct point
{
point(double x, double y, double z) : x(x), y(y), z(z) {}
double x;
double y;
double z;
};
std::vector<point> points;
}