+ handling of organized point cloud
This commit is contained in:
parent
60e0c447ca
commit
7bdecf9b38
|
@ -57,7 +57,9 @@ PyMODINIT_FUNC initPoints()
|
|||
|
||||
// add data types
|
||||
Points::Feature ::init();
|
||||
Points::Organized ::init();
|
||||
Points::FeatureCustom ::init();
|
||||
Points::OrganizedCustom ::init();
|
||||
Points::FeaturePython ::init();
|
||||
Points::ViewFeature ::init();
|
||||
}
|
||||
|
|
|
@ -104,8 +104,28 @@ private:
|
|||
reader->read(EncodedName);
|
||||
|
||||
App::Document *pcDoc = App::GetApplication().newDocument("Unnamed");
|
||||
|
||||
Points::Feature *pcFeature = 0;
|
||||
if (reader->hasProperties()) {
|
||||
Points::FeatureCustom *pcFeature = new Points::FeatureCustom();
|
||||
// is organized in a grid structure?
|
||||
if (reader->isOrganized()) {
|
||||
pcFeature = new Points::OrganizedCustom();
|
||||
|
||||
App::PropertyInteger* width = static_cast<App::PropertyInteger*>
|
||||
(pcFeature->getPropertyByName("Width"));
|
||||
if (width) {
|
||||
width->setValue(reader->getWidth());
|
||||
}
|
||||
App::PropertyInteger* height = static_cast<App::PropertyInteger*>
|
||||
(pcFeature->getPropertyByName("Height"));
|
||||
if (height) {
|
||||
height->setValue(reader->getHeight());
|
||||
}
|
||||
}
|
||||
else {
|
||||
pcFeature = new Points::FeatureCustom();
|
||||
}
|
||||
|
||||
pcFeature->Points.setValue(reader->getPoints());
|
||||
// add gray values
|
||||
if (reader->hasIntensities()) {
|
||||
|
@ -190,8 +210,27 @@ private:
|
|||
pcDoc = App::GetApplication().newDocument(DocName);
|
||||
}
|
||||
|
||||
Points::Feature *pcFeature = 0;
|
||||
if (reader->hasProperties()) {
|
||||
Points::FeatureCustom *pcFeature = new Points::FeatureCustom();
|
||||
// is organized in a grid structure?
|
||||
if (reader->isOrganized()) {
|
||||
pcFeature = new Points::OrganizedCustom();
|
||||
|
||||
App::PropertyInteger* width = static_cast<App::PropertyInteger*>
|
||||
(pcFeature->getPropertyByName("Width"));
|
||||
if (width) {
|
||||
width->setValue(reader->getWidth());
|
||||
}
|
||||
App::PropertyInteger* height = static_cast<App::PropertyInteger*>
|
||||
(pcFeature->getPropertyByName("Height"));
|
||||
if (height) {
|
||||
height->setValue(reader->getHeight());
|
||||
}
|
||||
}
|
||||
else {
|
||||
pcFeature = new Points::FeatureCustom();
|
||||
}
|
||||
|
||||
pcFeature->Points.setValue(reader->getPoints());
|
||||
// add gray values
|
||||
if (reader->hasIntensities()) {
|
||||
|
|
|
@ -122,6 +122,8 @@ void PointsAlgos::LoadAscii(PointKernel &points, const char *FileName)
|
|||
|
||||
Reader::Reader()
|
||||
{
|
||||
width = 0;
|
||||
height = 0;
|
||||
}
|
||||
|
||||
Reader::~Reader()
|
||||
|
@ -175,6 +177,21 @@ bool Reader::hasNormals() const
|
|||
return (!normals.empty());
|
||||
}
|
||||
|
||||
bool Reader::isOrganized() const
|
||||
{
|
||||
return (width > 1 && height > 1);
|
||||
}
|
||||
|
||||
int Reader::getWidth() const
|
||||
{
|
||||
return width;
|
||||
}
|
||||
|
||||
int Reader::getHeight() const
|
||||
{
|
||||
return height;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
AscReader::AscReader()
|
||||
|
@ -351,6 +368,9 @@ void PcdReader::read(const std::string& filename)
|
|||
hasColors = true;
|
||||
}
|
||||
|
||||
width = cloud2.width;
|
||||
height = cloud2.height;
|
||||
|
||||
if (hasNormals && hasColors) {
|
||||
pcl::PointCloud<pcl::PointXYZRGBNormal> cloud_in;
|
||||
pcl::io::loadPCDFile<pcl::PointXYZRGBNormal>(filename, cloud_in);
|
||||
|
|
|
@ -59,12 +59,16 @@ public:
|
|||
bool hasColors() const;
|
||||
const std::vector<Base::Vector3f>& getNormals() const;
|
||||
bool hasNormals() const;
|
||||
bool isOrganized() const;
|
||||
int getWidth() const;
|
||||
int getHeight() const;
|
||||
|
||||
protected:
|
||||
PointKernel points;
|
||||
std::vector<float> intensity;
|
||||
std::vector<App::Color> colors;
|
||||
std::vector<Base::Vector3f> normals;
|
||||
int width, height;
|
||||
};
|
||||
|
||||
class AscReader : public Reader
|
||||
|
|
|
@ -91,6 +91,20 @@ void Feature::onChanged(const App::Property* prop)
|
|||
|
||||
// ---------------------------------------------------------
|
||||
|
||||
PROPERTY_SOURCE(Points::Organized, Points::Feature)
|
||||
|
||||
Organized::Organized()
|
||||
{
|
||||
ADD_PROPERTY_TYPE(Width,(1),"Width",App::Prop_ReadOnly,"Width");
|
||||
ADD_PROPERTY_TYPE(Height,(1),"Height",App::Prop_ReadOnly,"Height");
|
||||
}
|
||||
|
||||
Organized::~Organized()
|
||||
{
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------
|
||||
|
||||
namespace App {
|
||||
/// @cond DOXERR
|
||||
PROPERTY_SOURCE_TEMPLATE(Points::FeatureCustom, Points::Feature)
|
||||
|
@ -100,6 +114,15 @@ PROPERTY_SOURCE_TEMPLATE(Points::FeatureCustom, Points::Feature)
|
|||
template class PointsExport FeatureCustomT<Points::Feature>;
|
||||
}
|
||||
|
||||
namespace App {
|
||||
/// @cond DOXERR
|
||||
PROPERTY_SOURCE_TEMPLATE(Points::OrganizedCustom, Points::Organized)
|
||||
/// @endcond
|
||||
|
||||
// explicit template instantiation
|
||||
template class PointsExport FeatureCustomT<Points::Organized>;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------
|
||||
|
||||
namespace App {
|
||||
|
|
|
@ -76,7 +76,31 @@ public:
|
|||
PropertyPointKernel Points; /**< The point kernel property. */
|
||||
};
|
||||
|
||||
/** Feature for organized points.
|
||||
*/
|
||||
class PointsExport Organized : public Feature
|
||||
{
|
||||
PROPERTY_HEADER(Points::Organized);
|
||||
|
||||
public:
|
||||
/// Constructor
|
||||
Organized(void);
|
||||
virtual ~Organized(void);
|
||||
|
||||
App::PropertyInteger Width;
|
||||
App::PropertyInteger Height;
|
||||
|
||||
/** @name methods overide Feature */
|
||||
//@{
|
||||
/// returns the type name of the ViewProvider
|
||||
virtual const char* getViewProviderName(void) const {
|
||||
return "PointsGui::ViewProviderOrganized";
|
||||
}
|
||||
//@}
|
||||
};
|
||||
|
||||
typedef App::FeatureCustomT<Feature> FeatureCustom;
|
||||
typedef App::FeatureCustomT<Organized> OrganizedCustom;
|
||||
typedef App::FeaturePythonT<Feature> FeaturePython;
|
||||
|
||||
} //namespace Points
|
||||
|
|
|
@ -87,9 +87,10 @@ PyMODINIT_FUNC initPointsGui()
|
|||
// instantiating the commands
|
||||
CreatePointsCommands();
|
||||
|
||||
PointsGui::ViewProviderPoints::init();
|
||||
PointsGui::ViewProviderPython::init();
|
||||
PointsGui::Workbench ::init();
|
||||
PointsGui::ViewProviderPoints ::init();
|
||||
PointsGui::ViewProviderOrganized ::init();
|
||||
PointsGui::ViewProviderPython ::init();
|
||||
PointsGui::Workbench ::init();
|
||||
Gui::ViewProviderBuilder::add(
|
||||
Points::PropertyPointKernel::getClassTypeId(),
|
||||
PointsGui::ViewProviderPoints::getClassTypeId());
|
||||
|
|
|
@ -456,6 +456,30 @@ void ViewProviderPoints::cut(const std::vector<SbVec2f>& picked, Gui::View3DInve
|
|||
|
||||
// -------------------------------------------------
|
||||
|
||||
PROPERTY_SOURCE(PointsGui::ViewProviderOrganized, PointsGui::ViewProviderPoints)
|
||||
|
||||
ViewProviderOrganized::ViewProviderOrganized()
|
||||
{
|
||||
}
|
||||
|
||||
ViewProviderOrganized::~ViewProviderOrganized()
|
||||
{
|
||||
}
|
||||
|
||||
void ViewProviderOrganized::updateData(const App::Property* prop)
|
||||
{
|
||||
Gui::ViewProviderGeometryObject::updateData(prop);
|
||||
if (prop->getTypeId() == Points::PropertyPointKernel::getClassTypeId()) {
|
||||
ViewProviderPointsBuilder builder;
|
||||
builder.createPoints(prop, pcPointsCoord, pcPoints);
|
||||
|
||||
// The number of points might have changed, so force also a resize of the Inventor internals
|
||||
setActiveMode();
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------------------------------
|
||||
|
||||
namespace Gui {
|
||||
/// @cond DOXERR
|
||||
PROPERTY_SOURCE_TEMPLATE(PointsGui::ViewProviderPython, PointsGui::ViewProviderPoints)
|
||||
|
|
|
@ -119,6 +119,23 @@ private:
|
|||
static App::PropertyFloatConstraint::Constraints floatRange;
|
||||
};
|
||||
|
||||
/**
|
||||
* The ViewProviderOrganized class creates
|
||||
* a node representing the organized points.
|
||||
* @author Werner Mayer
|
||||
*/
|
||||
class PointsGuiExport ViewProviderOrganized : public ViewProviderPoints
|
||||
{
|
||||
PROPERTY_HEADER(PointsGui::ViewProviderOrganized);
|
||||
|
||||
public:
|
||||
ViewProviderOrganized();
|
||||
virtual ~ViewProviderOrganized();
|
||||
|
||||
/// Update the point representation
|
||||
virtual void updateData(const App::Property*);
|
||||
};
|
||||
|
||||
typedef Gui::ViewProviderPythonFeatureT<ViewProviderPoints> ViewProviderPython;
|
||||
|
||||
} // namespace PointsGui
|
||||
|
|
Loading…
Reference in New Issue
Block a user