+ do some code cleanup and renaming in Points module
This commit is contained in:
parent
24e4e08be5
commit
a3209e1aee
|
@ -33,7 +33,7 @@
|
||||||
#include "PointsPy.h"
|
#include "PointsPy.h"
|
||||||
#include "Properties.h"
|
#include "Properties.h"
|
||||||
#include "PropertyPointKernel.h"
|
#include "PropertyPointKernel.h"
|
||||||
#include "ViewFeature.h"
|
#include "Structured.h"
|
||||||
|
|
||||||
namespace Points {
|
namespace Points {
|
||||||
extern PyObject* initModule();
|
extern PyObject* initModule();
|
||||||
|
@ -57,9 +57,8 @@ PyMODINIT_FUNC initPoints()
|
||||||
|
|
||||||
// add data types
|
// add data types
|
||||||
Points::Feature ::init();
|
Points::Feature ::init();
|
||||||
Points::Organized ::init();
|
Points::Structured ::init();
|
||||||
Points::FeatureCustom ::init();
|
Points::FeatureCustom ::init();
|
||||||
Points::OrganizedCustom ::init();
|
Points::StructuredCustom ::init();
|
||||||
Points::FeaturePython ::init();
|
Points::FeaturePython ::init();
|
||||||
Points::ViewFeature ::init();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@
|
||||||
#include "Points.h"
|
#include "Points.h"
|
||||||
#include "PointsPy.h"
|
#include "PointsPy.h"
|
||||||
#include "PointsAlgos.h"
|
#include "PointsAlgos.h"
|
||||||
#include "PointsFeature.h"
|
#include "Structured.h"
|
||||||
#include "Properties.h"
|
#include "Properties.h"
|
||||||
|
|
||||||
namespace Points {
|
namespace Points {
|
||||||
|
@ -107,9 +107,9 @@ private:
|
||||||
|
|
||||||
Points::Feature *pcFeature = 0;
|
Points::Feature *pcFeature = 0;
|
||||||
if (reader->hasProperties()) {
|
if (reader->hasProperties()) {
|
||||||
// is organized in a grid structure?
|
// Scattered or structured points?
|
||||||
if (reader->isOrganized()) {
|
if (reader->isStructured()) {
|
||||||
pcFeature = new Points::OrganizedCustom();
|
pcFeature = new Points::StructuredCustom();
|
||||||
|
|
||||||
App::PropertyInteger* width = static_cast<App::PropertyInteger*>
|
App::PropertyInteger* width = static_cast<App::PropertyInteger*>
|
||||||
(pcFeature->getPropertyByName("Width"));
|
(pcFeature->getPropertyByName("Width"));
|
||||||
|
@ -214,9 +214,9 @@ private:
|
||||||
|
|
||||||
Points::Feature *pcFeature = 0;
|
Points::Feature *pcFeature = 0;
|
||||||
if (reader->hasProperties()) {
|
if (reader->hasProperties()) {
|
||||||
// is organized in a grid structure?
|
// Scattered or structured points?
|
||||||
if (reader->isOrganized()) {
|
if (reader->isStructured()) {
|
||||||
pcFeature = new Points::OrganizedCustom();
|
pcFeature = new Points::StructuredCustom();
|
||||||
|
|
||||||
App::PropertyInteger* width = static_cast<App::PropertyInteger*>
|
App::PropertyInteger* width = static_cast<App::PropertyInteger*>
|
||||||
(pcFeature->getPropertyByName("Width"));
|
(pcFeature->getPropertyByName("Width"));
|
||||||
|
|
|
@ -47,8 +47,8 @@ SET(Points_SRCS
|
||||||
Properties.h
|
Properties.h
|
||||||
PropertyPointKernel.cpp
|
PropertyPointKernel.cpp
|
||||||
PropertyPointKernel.h
|
PropertyPointKernel.h
|
||||||
ViewFeature.cpp
|
Structured.cpp
|
||||||
ViewFeature.h
|
Structured.h
|
||||||
)
|
)
|
||||||
|
|
||||||
add_library(Points SHARED ${Points_SRCS})
|
add_library(Points SHARED ${Points_SRCS})
|
||||||
|
|
|
@ -177,7 +177,7 @@ bool Reader::hasNormals() const
|
||||||
return (!normals.empty());
|
return (!normals.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Reader::isOrganized() const
|
bool Reader::isStructured() const
|
||||||
{
|
{
|
||||||
return (width > 1 && height > 1);
|
return (width > 1 && height > 1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ public:
|
||||||
bool hasColors() const;
|
bool hasColors() const;
|
||||||
const std::vector<Base::Vector3f>& getNormals() const;
|
const std::vector<Base::Vector3f>& getNormals() const;
|
||||||
bool hasNormals() const;
|
bool hasNormals() const;
|
||||||
bool isOrganized() const;
|
bool isStructured() const;
|
||||||
int getWidth() const;
|
int getWidth() const;
|
||||||
int getHeight() const;
|
int getHeight() const;
|
||||||
|
|
||||||
|
|
|
@ -96,20 +96,6 @@ void Feature::onChanged(const App::Property* prop)
|
||||||
|
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
|
|
||||||
PROPERTY_SOURCE(Points::Organized, Points::Feature)
|
|
||||||
|
|
||||||
Organized::Organized()
|
|
||||||
{
|
|
||||||
ADD_PROPERTY_TYPE(Width,(1),"Organized points",App::Prop_ReadOnly,"Width of the frame");
|
|
||||||
ADD_PROPERTY_TYPE(Height,(1),"Organized points",App::Prop_ReadOnly,"Height of the frame");
|
|
||||||
}
|
|
||||||
|
|
||||||
Organized::~Organized()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------
|
|
||||||
|
|
||||||
namespace App {
|
namespace App {
|
||||||
/// @cond DOXERR
|
/// @cond DOXERR
|
||||||
PROPERTY_SOURCE_TEMPLATE(Points::FeatureCustom, Points::Feature)
|
PROPERTY_SOURCE_TEMPLATE(Points::FeatureCustom, Points::Feature)
|
||||||
|
@ -119,15 +105,6 @@ PROPERTY_SOURCE_TEMPLATE(Points::FeatureCustom, Points::Feature)
|
||||||
template class PointsExport FeatureCustomT<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 {
|
namespace App {
|
||||||
|
|
|
@ -77,31 +77,7 @@ public:
|
||||||
PropertyPointKernel Points; /**< The point kernel property. */
|
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<Feature> FeatureCustom;
|
||||||
typedef App::FeatureCustomT<Organized> OrganizedCustom;
|
|
||||||
typedef App::FeaturePythonT<Feature> FeaturePython;
|
typedef App::FeaturePythonT<Feature> FeaturePython;
|
||||||
|
|
||||||
} //namespace Points
|
} //namespace Points
|
||||||
|
|
|
@ -32,13 +32,13 @@
|
||||||
#include <Base/Exception.h>
|
#include <Base/Exception.h>
|
||||||
|
|
||||||
|
|
||||||
#include "ViewFeature.h"
|
#include "Structured.h"
|
||||||
|
|
||||||
using namespace Points;
|
using namespace Points;
|
||||||
|
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
// ViewFeature
|
// Structured
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
/*
|
/*
|
||||||
import Points
|
import Points
|
||||||
|
@ -55,30 +55,31 @@ for i in range(21):
|
||||||
|
|
||||||
p.addPoints(pts)
|
p.addPoints(pts)
|
||||||
doc=App.ActiveDocument
|
doc=App.ActiveDocument
|
||||||
pts=doc.addObject('Points::ViewFeature','View')
|
pts=doc.addObject('Points::Structured','View')
|
||||||
pts.Points=p
|
pts.Points=p
|
||||||
pts.Width=21
|
pts.Width=21
|
||||||
pts.Height=21
|
pts.Height=21
|
||||||
*/
|
*/
|
||||||
|
|
||||||
PROPERTY_SOURCE(Points::ViewFeature, Points::Feature)
|
// ---------------------------------------------------------
|
||||||
|
|
||||||
ViewFeature::ViewFeature()
|
PROPERTY_SOURCE(Points::Structured, Points::Feature)
|
||||||
|
|
||||||
|
Structured::Structured()
|
||||||
{
|
{
|
||||||
App::PropertyType type = static_cast<App::PropertyType>(App::Prop_None);
|
// App::PropertyType type = static_cast<App::PropertyType>(App::Prop_None);
|
||||||
ADD_PROPERTY_TYPE(Width ,(0), "View", type, "The width of the point view");
|
App::PropertyType type = static_cast<App::PropertyType>(App::Prop_ReadOnly);
|
||||||
ADD_PROPERTY_TYPE(Height,(0), "View", type, "The height of the point view");
|
ADD_PROPERTY_TYPE(Width,(1),"Structured points", type, "Width of the image");
|
||||||
ADD_PROPERTY_TYPE(Direction ,(Base::Vector3d(0,0,1)), "View", type, "The direction of the point view");
|
ADD_PROPERTY_TYPE(Height,(1),"Structured points", type, "Height of the image");
|
||||||
|
//Width.setStatus(App::Property::ReadOnly, true);
|
||||||
Width.setStatus(App::Property::ReadOnly, true);
|
//Height.setStatus(App::Property::ReadOnly, true);
|
||||||
Height.setStatus(App::Property::ReadOnly, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ViewFeature::~ViewFeature()
|
Structured::~Structured()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
App::DocumentObjectExecReturn *ViewFeature::execute(void)
|
App::DocumentObjectExecReturn *Structured::execute(void)
|
||||||
{
|
{
|
||||||
std::size_t size = Height.getValue() * Width.getValue();
|
std::size_t size = Height.getValue() * Width.getValue();
|
||||||
if (size != Points.getValue().size())
|
if (size != Points.getValue().size())
|
||||||
|
@ -86,3 +87,14 @@ App::DocumentObjectExecReturn *ViewFeature::execute(void)
|
||||||
this->Points.touch();
|
this->Points.touch();
|
||||||
return App::DocumentObject::StdReturn;
|
return App::DocumentObject::StdReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------
|
||||||
|
|
||||||
|
namespace App {
|
||||||
|
/// @cond DOXERR
|
||||||
|
PROPERTY_SOURCE_TEMPLATE(Points::StructuredCustom, Points::Structured)
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
|
// explicit template instantiation
|
||||||
|
template class PointsExport FeatureCustomT<Points::Structured>;
|
||||||
|
}
|
|
@ -30,27 +30,35 @@
|
||||||
namespace Points
|
namespace Points
|
||||||
{
|
{
|
||||||
|
|
||||||
/*! For the ViewFeature class it is expected that the Point property has Width*Height vertices
|
/*! For the Structured class it is expected that the Point property has Width*Height vertices
|
||||||
and that with respect to their x,y coordinates they are ordered in a grid structure.
|
and that with respect to their x,y coordinates they are ordered in a grid structure.
|
||||||
If a point is marked invalid then one of its coordinates is set to NaN.
|
If a point is marked invalid then one of its coordinates is set to NaN.
|
||||||
*/
|
*/
|
||||||
class PointsExport ViewFeature : public Points::Feature
|
class PointsExport Structured : public Feature
|
||||||
{
|
{
|
||||||
PROPERTY_HEADER(Points::ViewFeature);
|
PROPERTY_HEADER(Points::Structured);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
ViewFeature(void);
|
Structured(void);
|
||||||
virtual ~ViewFeature(void);
|
virtual ~Structured(void);
|
||||||
|
|
||||||
|
App::PropertyInteger Width; /**< The width of the structured cloud. */
|
||||||
|
App::PropertyInteger Height; /**< The height of the structured cloud. */
|
||||||
|
|
||||||
|
/** @name methods overide Feature */
|
||||||
|
//@{
|
||||||
/// recalculate the Feature
|
/// recalculate the Feature
|
||||||
virtual App::DocumentObjectExecReturn *execute(void);
|
virtual App::DocumentObjectExecReturn *execute(void);
|
||||||
|
/// returns the type name of the ViewProvider
|
||||||
|
virtual const char* getViewProviderName(void) const {
|
||||||
|
return "PointsGui::ViewProviderStructured";
|
||||||
|
}
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
App::PropertyInteger Width; /**< The width of the view. */
|
|
||||||
App::PropertyInteger Height; /**< The height of the view. */
|
|
||||||
App::PropertyVector Direction; /**< The direction of the view. */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef App::FeatureCustomT<Structured> StructuredCustom;
|
||||||
|
|
||||||
} //namespace Points
|
} //namespace Points
|
||||||
|
|
||||||
|
|
|
@ -89,7 +89,7 @@ PyMODINIT_FUNC initPointsGui()
|
||||||
|
|
||||||
PointsGui::ViewProviderPoints ::init();
|
PointsGui::ViewProviderPoints ::init();
|
||||||
PointsGui::ViewProviderScattered ::init();
|
PointsGui::ViewProviderScattered ::init();
|
||||||
PointsGui::ViewProviderOrganized ::init();
|
PointsGui::ViewProviderStructured ::init();
|
||||||
PointsGui::ViewProviderPython ::init();
|
PointsGui::ViewProviderPython ::init();
|
||||||
PointsGui::Workbench ::init();
|
PointsGui::Workbench ::init();
|
||||||
Gui::ViewProviderBuilder::add(
|
Gui::ViewProviderBuilder::add(
|
||||||
|
|
|
@ -472,20 +472,20 @@ void ViewProviderScattered::cut(const std::vector<SbVec2f>& picked, Gui::View3DI
|
||||||
|
|
||||||
// -------------------------------------------------
|
// -------------------------------------------------
|
||||||
|
|
||||||
PROPERTY_SOURCE(PointsGui::ViewProviderOrganized, PointsGui::ViewProviderPoints)
|
PROPERTY_SOURCE(PointsGui::ViewProviderStructured, PointsGui::ViewProviderPoints)
|
||||||
|
|
||||||
ViewProviderOrganized::ViewProviderOrganized()
|
ViewProviderStructured::ViewProviderStructured()
|
||||||
{
|
{
|
||||||
pcPoints = new SoIndexedPointSet();
|
pcPoints = new SoIndexedPointSet();
|
||||||
pcPoints->ref();
|
pcPoints->ref();
|
||||||
}
|
}
|
||||||
|
|
||||||
ViewProviderOrganized::~ViewProviderOrganized()
|
ViewProviderStructured::~ViewProviderStructured()
|
||||||
{
|
{
|
||||||
pcPoints->unref();
|
pcPoints->unref();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViewProviderOrganized::attach(App::DocumentObject* pcObj)
|
void ViewProviderStructured::attach(App::DocumentObject* pcObj)
|
||||||
{
|
{
|
||||||
// call parent's attach to define display modes
|
// call parent's attach to define display modes
|
||||||
ViewProviderGeometryObject::attach(pcObj);
|
ViewProviderGeometryObject::attach(pcObj);
|
||||||
|
@ -531,7 +531,7 @@ void ViewProviderOrganized::attach(App::DocumentObject* pcObj)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViewProviderOrganized::updateData(const App::Property* prop)
|
void ViewProviderStructured::updateData(const App::Property* prop)
|
||||||
{
|
{
|
||||||
ViewProviderPoints::updateData(prop);
|
ViewProviderPoints::updateData(prop);
|
||||||
if (prop->getTypeId() == Points::PropertyPointKernel::getClassTypeId()) {
|
if (prop->getTypeId() == Points::PropertyPointKernel::getClassTypeId()) {
|
||||||
|
@ -543,7 +543,7 @@ void ViewProviderOrganized::updateData(const App::Property* prop)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViewProviderOrganized::cut(const std::vector<SbVec2f>& picked, Gui::View3DInventorViewer &Viewer)
|
void ViewProviderStructured::cut(const std::vector<SbVec2f>& picked, Gui::View3DInventorViewer &Viewer)
|
||||||
{
|
{
|
||||||
// create the polygon from the picked points
|
// create the polygon from the picked points
|
||||||
Base::Polygon2D cPoly;
|
Base::Polygon2D cPoly;
|
||||||
|
|
|
@ -142,17 +142,17 @@ protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The ViewProviderOrganized class creates
|
* The ViewProviderStructured class creates
|
||||||
* a node representing the organized points.
|
* a node representing the structured points.
|
||||||
* @author Werner Mayer
|
* @author Werner Mayer
|
||||||
*/
|
*/
|
||||||
class PointsGuiExport ViewProviderOrganized : public ViewProviderPoints
|
class PointsGuiExport ViewProviderStructured : public ViewProviderPoints
|
||||||
{
|
{
|
||||||
PROPERTY_HEADER(PointsGui::ViewProviderOrganized);
|
PROPERTY_HEADER(PointsGui::ViewProviderStructured);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ViewProviderOrganized();
|
ViewProviderStructured();
|
||||||
virtual ~ViewProviderOrganized();
|
virtual ~ViewProviderStructured();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extracts the point data from the feature \a pcFeature and creates
|
* Extracts the point data from the feature \a pcFeature and creates
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
|
|
||||||
#include <Mod/Part/App/TopoShape.h>
|
#include <Mod/Part/App/TopoShape.h>
|
||||||
#include <Mod/Part/App/PartFeature.h>
|
#include <Mod/Part/App/PartFeature.h>
|
||||||
#include <Mod/Points/App/ViewFeature.h>
|
#include <Mod/Points/App/Structured.h>
|
||||||
#include <Mod/Mesh/App/MeshFeature.h>
|
#include <Mod/Mesh/App/MeshFeature.h>
|
||||||
#include <Mod/Mesh/App/Core/Approximation.h>
|
#include <Mod/Mesh/App/Core/Approximation.h>
|
||||||
|
|
||||||
|
@ -221,15 +221,15 @@ CmdViewTriangulation::CmdViewTriangulation()
|
||||||
{
|
{
|
||||||
sAppModule = "Reen";
|
sAppModule = "Reen";
|
||||||
sGroup = QT_TR_NOOP("Reverse Engineering");
|
sGroup = QT_TR_NOOP("Reverse Engineering");
|
||||||
sMenuText = QT_TR_NOOP("View triangulation");
|
sMenuText = QT_TR_NOOP("Structured point clouds");
|
||||||
sToolTipText = QT_TR_NOOP("View triangulation");
|
sToolTipText = QT_TR_NOOP("Triangulation of structured point clouds");
|
||||||
sToolTipText = QT_TR_NOOP("View triangulation");
|
sToolTipText = QT_TR_NOOP("Triangulation of structured point clouds");
|
||||||
sWhatsThis = "Reen_ViewTriangulation";
|
sWhatsThis = "Reen_ViewTriangulation";
|
||||||
}
|
}
|
||||||
|
|
||||||
void CmdViewTriangulation::activated(int iMsg)
|
void CmdViewTriangulation::activated(int iMsg)
|
||||||
{
|
{
|
||||||
std::vector<App::DocumentObject*> obj = Gui::Selection().getObjectsOfType(Points::ViewFeature::getClassTypeId());
|
std::vector<App::DocumentObject*> obj = Gui::Selection().getObjectsOfType(Points::Structured::getClassTypeId());
|
||||||
addModule(App,"ReverseEngineering");
|
addModule(App,"ReverseEngineering");
|
||||||
openCommand("View triangulation");
|
openCommand("View triangulation");
|
||||||
try {
|
try {
|
||||||
|
@ -263,7 +263,7 @@ void CmdViewTriangulation::activated(int iMsg)
|
||||||
|
|
||||||
bool CmdViewTriangulation::isActive(void)
|
bool CmdViewTriangulation::isActive(void)
|
||||||
{
|
{
|
||||||
return Gui::Selection().countObjectsOfType(Points::ViewFeature::getClassTypeId()) > 0;
|
return (Gui::Selection().countObjectsOfType(Points::Structured::getClassTypeId()) > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreateReverseEngineeringCommands(void)
|
void CreateReverseEngineeringCommands(void)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user