+ 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 "Properties.h"
|
||||
#include "PropertyPointKernel.h"
|
||||
#include "ViewFeature.h"
|
||||
#include "Structured.h"
|
||||
|
||||
namespace Points {
|
||||
extern PyObject* initModule();
|
||||
|
@ -57,9 +57,8 @@ PyMODINIT_FUNC initPoints()
|
|||
|
||||
// add data types
|
||||
Points::Feature ::init();
|
||||
Points::Organized ::init();
|
||||
Points::Structured ::init();
|
||||
Points::FeatureCustom ::init();
|
||||
Points::OrganizedCustom ::init();
|
||||
Points::StructuredCustom ::init();
|
||||
Points::FeaturePython ::init();
|
||||
Points::ViewFeature ::init();
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
#include "Points.h"
|
||||
#include "PointsPy.h"
|
||||
#include "PointsAlgos.h"
|
||||
#include "PointsFeature.h"
|
||||
#include "Structured.h"
|
||||
#include "Properties.h"
|
||||
|
||||
namespace Points {
|
||||
|
@ -107,9 +107,9 @@ private:
|
|||
|
||||
Points::Feature *pcFeature = 0;
|
||||
if (reader->hasProperties()) {
|
||||
// is organized in a grid structure?
|
||||
if (reader->isOrganized()) {
|
||||
pcFeature = new Points::OrganizedCustom();
|
||||
// Scattered or structured points?
|
||||
if (reader->isStructured()) {
|
||||
pcFeature = new Points::StructuredCustom();
|
||||
|
||||
App::PropertyInteger* width = static_cast<App::PropertyInteger*>
|
||||
(pcFeature->getPropertyByName("Width"));
|
||||
|
@ -214,9 +214,9 @@ private:
|
|||
|
||||
Points::Feature *pcFeature = 0;
|
||||
if (reader->hasProperties()) {
|
||||
// is organized in a grid structure?
|
||||
if (reader->isOrganized()) {
|
||||
pcFeature = new Points::OrganizedCustom();
|
||||
// Scattered or structured points?
|
||||
if (reader->isStructured()) {
|
||||
pcFeature = new Points::StructuredCustom();
|
||||
|
||||
App::PropertyInteger* width = static_cast<App::PropertyInteger*>
|
||||
(pcFeature->getPropertyByName("Width"));
|
||||
|
|
|
@ -47,8 +47,8 @@ SET(Points_SRCS
|
|||
Properties.h
|
||||
PropertyPointKernel.cpp
|
||||
PropertyPointKernel.h
|
||||
ViewFeature.cpp
|
||||
ViewFeature.h
|
||||
Structured.cpp
|
||||
Structured.h
|
||||
)
|
||||
|
||||
add_library(Points SHARED ${Points_SRCS})
|
||||
|
|
|
@ -177,7 +177,7 @@ bool Reader::hasNormals() const
|
|||
return (!normals.empty());
|
||||
}
|
||||
|
||||
bool Reader::isOrganized() const
|
||||
bool Reader::isStructured() const
|
||||
{
|
||||
return (width > 1 && height > 1);
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ public:
|
|||
bool hasColors() const;
|
||||
const std::vector<Base::Vector3f>& getNormals() const;
|
||||
bool hasNormals() const;
|
||||
bool isOrganized() const;
|
||||
bool isStructured() const;
|
||||
int getWidth() 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 {
|
||||
/// @cond DOXERR
|
||||
PROPERTY_SOURCE_TEMPLATE(Points::FeatureCustom, Points::Feature)
|
||||
|
@ -119,15 +105,6 @@ 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 {
|
||||
|
|
|
@ -77,31 +77,7 @@ 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
|
||||
|
|
|
@ -32,13 +32,13 @@
|
|||
#include <Base/Exception.h>
|
||||
|
||||
|
||||
#include "ViewFeature.h"
|
||||
#include "Structured.h"
|
||||
|
||||
using namespace Points;
|
||||
|
||||
|
||||
//===========================================================================
|
||||
// ViewFeature
|
||||
// Structured
|
||||
//===========================================================================
|
||||
/*
|
||||
import Points
|
||||
|
@ -55,30 +55,31 @@ for i in range(21):
|
|||
|
||||
p.addPoints(pts)
|
||||
doc=App.ActiveDocument
|
||||
pts=doc.addObject('Points::ViewFeature','View')
|
||||
pts=doc.addObject('Points::Structured','View')
|
||||
pts.Points=p
|
||||
pts.Width=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);
|
||||
ADD_PROPERTY_TYPE(Width ,(0), "View", type, "The width of the point view");
|
||||
ADD_PROPERTY_TYPE(Height,(0), "View", type, "The height of the point view");
|
||||
ADD_PROPERTY_TYPE(Direction ,(Base::Vector3d(0,0,1)), "View", type, "The direction of the point view");
|
||||
|
||||
Width.setStatus(App::Property::ReadOnly, true);
|
||||
Height.setStatus(App::Property::ReadOnly, true);
|
||||
// App::PropertyType type = static_cast<App::PropertyType>(App::Prop_None);
|
||||
App::PropertyType type = static_cast<App::PropertyType>(App::Prop_ReadOnly);
|
||||
ADD_PROPERTY_TYPE(Width,(1),"Structured points", type, "Width of the image");
|
||||
ADD_PROPERTY_TYPE(Height,(1),"Structured points", type, "Height of the image");
|
||||
//Width.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();
|
||||
if (size != Points.getValue().size())
|
||||
|
@ -86,3 +87,14 @@ App::DocumentObjectExecReturn *ViewFeature::execute(void)
|
|||
this->Points.touch();
|
||||
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
|
||||
{
|
||||
|
||||
/*! 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.
|
||||
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:
|
||||
/// Constructor
|
||||
ViewFeature(void);
|
||||
virtual ~ViewFeature(void);
|
||||
Structured(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
|
||||
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
|
||||
|
||||
|
|
@ -89,7 +89,7 @@ PyMODINIT_FUNC initPointsGui()
|
|||
|
||||
PointsGui::ViewProviderPoints ::init();
|
||||
PointsGui::ViewProviderScattered ::init();
|
||||
PointsGui::ViewProviderOrganized ::init();
|
||||
PointsGui::ViewProviderStructured ::init();
|
||||
PointsGui::ViewProviderPython ::init();
|
||||
PointsGui::Workbench ::init();
|
||||
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->ref();
|
||||
}
|
||||
|
||||
ViewProviderOrganized::~ViewProviderOrganized()
|
||||
ViewProviderStructured::~ViewProviderStructured()
|
||||
{
|
||||
pcPoints->unref();
|
||||
}
|
||||
|
||||
void ViewProviderOrganized::attach(App::DocumentObject* pcObj)
|
||||
void ViewProviderStructured::attach(App::DocumentObject* pcObj)
|
||||
{
|
||||
// call parent's attach to define display modes
|
||||
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);
|
||||
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
|
||||
Base::Polygon2D cPoly;
|
||||
|
|
|
@ -142,17 +142,17 @@ protected:
|
|||
};
|
||||
|
||||
/**
|
||||
* The ViewProviderOrganized class creates
|
||||
* a node representing the organized points.
|
||||
* The ViewProviderStructured class creates
|
||||
* a node representing the structured points.
|
||||
* @author Werner Mayer
|
||||
*/
|
||||
class PointsGuiExport ViewProviderOrganized : public ViewProviderPoints
|
||||
class PointsGuiExport ViewProviderStructured : public ViewProviderPoints
|
||||
{
|
||||
PROPERTY_HEADER(PointsGui::ViewProviderOrganized);
|
||||
PROPERTY_HEADER(PointsGui::ViewProviderStructured);
|
||||
|
||||
public:
|
||||
ViewProviderOrganized();
|
||||
virtual ~ViewProviderOrganized();
|
||||
ViewProviderStructured();
|
||||
virtual ~ViewProviderStructured();
|
||||
|
||||
/**
|
||||
* 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/PartFeature.h>
|
||||
#include <Mod/Points/App/ViewFeature.h>
|
||||
#include <Mod/Points/App/Structured.h>
|
||||
#include <Mod/Mesh/App/MeshFeature.h>
|
||||
#include <Mod/Mesh/App/Core/Approximation.h>
|
||||
|
||||
|
@ -221,15 +221,15 @@ CmdViewTriangulation::CmdViewTriangulation()
|
|||
{
|
||||
sAppModule = "Reen";
|
||||
sGroup = QT_TR_NOOP("Reverse Engineering");
|
||||
sMenuText = QT_TR_NOOP("View triangulation");
|
||||
sToolTipText = QT_TR_NOOP("View triangulation");
|
||||
sToolTipText = QT_TR_NOOP("View triangulation");
|
||||
sMenuText = QT_TR_NOOP("Structured point clouds");
|
||||
sToolTipText = QT_TR_NOOP("Triangulation of structured point clouds");
|
||||
sToolTipText = QT_TR_NOOP("Triangulation of structured point clouds");
|
||||
sWhatsThis = "Reen_ViewTriangulation";
|
||||
}
|
||||
|
||||
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");
|
||||
openCommand("View triangulation");
|
||||
try {
|
||||
|
@ -263,7 +263,7 @@ void CmdViewTriangulation::activated(int iMsg)
|
|||
|
||||
bool CmdViewTriangulation::isActive(void)
|
||||
{
|
||||
return Gui::Selection().countObjectsOfType(Points::ViewFeature::getClassTypeId()) > 0;
|
||||
return (Gui::Selection().countObjectsOfType(Points::Structured::getClassTypeId()) > 0);
|
||||
}
|
||||
|
||||
void CreateReverseEngineeringCommands(void)
|
||||
|
|
Loading…
Reference in New Issue
Block a user