OctreeNodePlyReaderDelegate.h
Go to the documentation of this file.
// This file is a part of the OpenSurgSim project.
// Copyright 2013, SimQuest Solutions Inc.
//
// 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.
#ifndef SURGSIM_DATASTRUCTURES_OCTREENODEPLYREADERDELEGATE_H
#define SURGSIM_DATASTRUCTURES_OCTREENODEPLYREADERDELEGATE_H
#include "SurgSim/DataStructures/PlyReaderDelegate.h"
#include "SurgSim/DataStructures/OctreeNode.h"
#include "SurgSim/DataStructures/EmptyData.h"
namespace SurgSim
{
namespace DataStructures
{
class OctreeNodePlyReaderDelegateBase : public PlyReaderDelegate
{
public:
OctreeNodePlyReaderDelegateBase();
virtual ~OctreeNodePlyReaderDelegateBase();
bool registerDelegate(PlyReader* reader) override;
bool fileIsAcceptable(const PlyReader& reader) override;
void* beginBounds(const std::string& elementName, size_t count);
void* beginDimension(const std::string& elementName, size_t count);
void* beginSpacing(const std::string& elementName, size_t count);
virtual void* beginVoxel(const std::string& elementName, size_t count);
virtual void processVoxel(const std::string& elementName) = 0;
protected:
virtual void initializeOctree() = 0;
struct BoundsData
{
double xMin;
double yMin;
double zMin;
double xMax;
double yMax;
double zMax;
} m_bounds;
Eigen::AlignedBox<double, 3> m_boundingBox;
struct SpacingData
{
double x;
double y;
double z;
} m_spacing;
struct DimensionData
{
unsigned int x;
unsigned int y;
unsigned int z;
} m_dimension;
struct VoxelData
{
double x;
double y;
double z;
} m_voxel;
int m_numLevels;
bool m_haveSpacing;
bool m_haveDimensions;
bool m_haveBounds;
};
template <typename Data>
class OctreeNodePlyReaderDelegate : public OctreeNodePlyReaderDelegateBase
{
public:
OctreeNodePlyReaderDelegate();
explicit OctreeNodePlyReaderDelegate(std::shared_ptr<OctreeNode<Data>> octree);
virtual ~OctreeNodePlyReaderDelegate();
std::shared_ptr<OctreeNode<Data>> getOctree();
void processVoxel(const std::string& elementName) override;
void initializeOctree() override;
private:
std::shared_ptr<OctreeNode<Data>> m_octree;
};
}
}
#include "SurgSim/DataStructures/OctreeNodePlyReaderDelegate-inl.h"
#endif
SurgSim::DataStructures::OctreeNodePlyReaderDelegateBase::DimensionData::x
unsigned int x
Definition: OctreeNodePlyReaderDelegate.h:105
SurgSim::DataStructures::OctreeNodePlyReaderDelegateBase::SpacingData::x
double x
Definition: OctreeNodePlyReaderDelegate.h:97
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::DataStructures::OctreeNodePlyReaderDelegateBase::m_haveDimensions
bool m_haveDimensions
Definition: OctreeNodePlyReaderDelegate.h:124
OctreeNodePlyReaderDelegate-inl.h
SurgSim::DataStructures::OctreeNodePlyReaderDelegateBase::VoxelData::y
double y
Definition: OctreeNodePlyReaderDelegate.h:114
SurgSim::DataStructures::OctreeNodePlyReaderDelegateBase::BoundsData::zMin
double zMin
Definition: OctreeNodePlyReaderDelegate.h:85
SurgSim::DataStructures::OctreeNodePlyReaderDelegateBase::beginBounds
void * beginBounds(const std::string &elementName, size_t count)
Callback function, begin the processing of the bounds.
Definition: OctreeNodePlyReaderDelegate.cpp:101
SurgSim::DataStructures::OctreeNodePlyReaderDelegateBase::BoundsData::yMin
double yMin
Definition: OctreeNodePlyReaderDelegate.h:84
SurgSim::DataStructures::OctreeNodePlyReaderDelegateBase::SpacingData::y
double y
Definition: OctreeNodePlyReaderDelegate.h:98
SurgSim::DataStructures::OctreeNodePlyReaderDelegateBase::fileIsAcceptable
bool fileIsAcceptable(const PlyReader &reader) override
Check whether the file in the reader can be used with this delegate, this gives the delegate a chance...
Definition: OctreeNodePlyReaderDelegate.cpp:83
SurgSim::DataStructures::OctreeNodePlyReaderDelegateBase::registerDelegate
bool registerDelegate(PlyReader *reader) override
Registers the delegate with the reader.
Definition: OctreeNodePlyReaderDelegate.cpp:38
SurgSim::DataStructures::OctreeNodePlyReaderDelegateBase::BoundsData::yMax
double yMax
Definition: OctreeNodePlyReaderDelegate.h:87
SurgSim::DataStructures::OctreeNodePlyReaderDelegateBase::SpacingData::z
double z
Definition: OctreeNodePlyReaderDelegate.h:99
SurgSim::DataStructures::OctreeNodePlyReaderDelegateBase::m_boundingBox
Eigen::AlignedBox< double, 3 > m_boundingBox
Bounding box, will be initialized from the file.
Definition: OctreeNodePlyReaderDelegate.h:92
SurgSim::DataStructures::OctreeNodePlyReaderDelegateBase::m_bounds
struct SurgSim::DataStructures::OctreeNodePlyReaderDelegateBase::BoundsData m_bounds
SurgSim::DataStructures::OctreeNodePlyReaderDelegateBase::beginVoxel
virtual void * beginVoxel(const std::string &elementName, size_t count)
Callback function, begin the processing of the voxels.
Definition: OctreeNodePlyReaderDelegate.cpp:122
SurgSim::DataStructures::OctreeNodePlyReaderDelegateBase::DimensionData::y
unsigned int y
Definition: OctreeNodePlyReaderDelegate.h:106
SurgSim::DataStructures::OctreeNodePlyReaderDelegateBase::VoxelData::z
double z
Definition: OctreeNodePlyReaderDelegate.h:115
SurgSim::DataStructures::OctreeNodePlyReaderDelegateBase::BoundsData
Data Structure to receive the bounds information.
Definition: OctreeNodePlyReaderDelegate.h:81
SurgSim::DataStructures::OctreeNodePlyReaderDelegate::m_octree
std::shared_ptr< OctreeNode< Data > > m_octree
The octree that will be filled with the data from the file.
Definition: OctreeNodePlyReaderDelegate.h:158
SurgSim::DataStructures::PlyReader
Wrapper for the C .ply file parser This class wraps the main functionality for the original C ...
Definition: PlyReader.h:85
SurgSim::DataStructures::OctreeNodePlyReaderDelegateBase::VoxelData::x
double x
Definition: OctreeNodePlyReaderDelegate.h:113
SurgSim::DataStructures::OctreeNodePlyReaderDelegateBase::~OctreeNodePlyReaderDelegateBase
virtual ~OctreeNodePlyReaderDelegateBase()
Destructor.
Definition: OctreeNodePlyReaderDelegate.cpp:33
SurgSim::DataStructures::OctreeNodePlyReaderDelegateBase::beginSpacing
void * beginSpacing(const std::string &elementName, size_t count)
Callback function, begin the processing of the bounds.
Definition: OctreeNodePlyReaderDelegate.cpp:115
SurgSim::DataStructures::OctreeNodePlyReaderDelegateBase::initializeOctree
virtual void initializeOctree()=0
Set up the octree, this is left up to the derived classes.
SurgSim::DataStructures::OctreeNodePlyReaderDelegate
Subclass the OctreeNodePLyReaderDelegateBase class to enable processing of the templated data...
Definition: OctreeNode.h:113
SurgSim::DataStructures::OctreeNodePlyReaderDelegateBase::BoundsData::xMax
double xMax
Definition: OctreeNodePlyReaderDelegate.h:86
SurgSim::DataStructures::OctreeNodePlyReaderDelegateBase::BoundsData::zMax
double zMax
Definition: OctreeNodePlyReaderDelegate.h:88
SurgSim::DataStructures::OctreeNodePlyReaderDelegateBase::m_voxel
struct SurgSim::DataStructures::OctreeNodePlyReaderDelegateBase::VoxelData m_voxel
SurgSim::DataStructures::OctreeNodePlyReaderDelegateBase::m_haveBounds
bool m_haveBounds
Definition: OctreeNodePlyReaderDelegate.h:125
OctreeNode.h
SurgSim::DataStructures::OctreeNodePlyReaderDelegateBase::m_dimension
struct SurgSim::DataStructures::OctreeNodePlyReaderDelegateBase::DimensionData m_dimension
SurgSim::DataStructures::OctreeNodePlyReaderDelegateBase::m_spacing
struct SurgSim::DataStructures::OctreeNodePlyReaderDelegateBase::SpacingData m_spacing
SurgSim::DataStructures::OctreeNodePlyReaderDelegateBase
Delegate to read Octrees from ply files, this is the abstract base class, to let us modify loading by...
Definition: OctreeNodePlyReaderDelegate.h:30
PlyReaderDelegate.h
SurgSim::DataStructures::OctreeNodePlyReaderDelegateBase::beginDimension
void * beginDimension(const std::string &elementName, size_t count)
Callback function, begin the processing of the dimension.
Definition: OctreeNodePlyReaderDelegate.cpp:108
SurgSim::DataStructures::OctreeNodePlyReaderDelegateBase::m_haveSpacing
bool m_haveSpacing
Definition: OctreeNodePlyReaderDelegate.h:123
SurgSim::DataStructures::OctreeNodePlyReaderDelegateBase::DimensionData::z
unsigned int z
Definition: OctreeNodePlyReaderDelegate.h:107
SurgSim::DataStructures::OctreeNodePlyReaderDelegateBase::processVoxel
virtual void processVoxel(const std::string &elementName)=0
Callback function to process one voxel.
SurgSim::DataStructures::OctreeNodePlyReaderDelegateBase::DimensionData
Data structure to receive the dimension information from the file.
Definition: OctreeNodePlyReaderDelegate.h:103
SurgSim::DataStructures::OctreeNodePlyReaderDelegateBase::OctreeNodePlyReaderDelegateBase
OctreeNodePlyReaderDelegateBase()
Constructor.
Definition: OctreeNodePlyReaderDelegate.cpp:25
SurgSim::DataStructures::OctreeNodePlyReaderDelegateBase::BoundsData::xMin
double xMin
Definition: OctreeNodePlyReaderDelegate.h:83
SurgSim::DataStructures::OctreeNodePlyReaderDelegateBase::m_numLevels
int m_numLevels
Calculated number of levels for the octree.
Definition: OctreeNodePlyReaderDelegate.h:119
SurgSim::DataStructures::OctreeNodePlyReaderDelegateBase::VoxelData
Data structure to receive the specific voxel information from the file.
Definition: OctreeNodePlyReaderDelegate.h:111
SurgSim::DataStructures::OctreeNode
Octree data structure.
Definition: OctreeNode.h:131
EmptyData.h
SurgSim::DataStructures::PlyReaderDelegate
PlyReaderDelegate abstract class.
Definition: PlyReaderDelegate.h:31
SurgSim::DataStructures::OctreeNodePlyReaderDelegateBase::SpacingData
Data structure to receive the spacing information from the file.
Definition: OctreeNodePlyReaderDelegate.h:95