Skip to content

Commit

Permalink
+ do some code cleanup and renaming in Points module
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Feb 21, 2016
1 parent 24e4e08 commit a3209e1
Show file tree
Hide file tree
Showing 13 changed files with 76 additions and 104 deletions.
7 changes: 3 additions & 4 deletions src/Mod/Points/App/AppPoints.cpp
Expand Up @@ -33,7 +33,7 @@
#include "PointsPy.h"
#include "Properties.h"
#include "PropertyPointKernel.h"
#include "ViewFeature.h"
#include "Structured.h"

namespace Points {
extern PyObject* initModule();
Expand All @@ -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();
}
14 changes: 7 additions & 7 deletions src/Mod/Points/App/AppPointsPy.cpp
Expand Up @@ -48,7 +48,7 @@
#include "Points.h"
#include "PointsPy.h"
#include "PointsAlgos.h"
#include "PointsFeature.h"
#include "Structured.h"
#include "Properties.h"

namespace Points {
Expand Down Expand Up @@ -107,9 +107,9 @@ class Module : public Py::ExtensionModule<Module>

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"));
Expand Down Expand Up @@ -214,9 +214,9 @@ class Module : public Py::ExtensionModule<Module>

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"));
Expand Down
4 changes: 2 additions & 2 deletions src/Mod/Points/App/CMakeLists.txt
Expand Up @@ -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})
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Points/App/PointsAlgos.cpp
Expand Up @@ -177,7 +177,7 @@ bool Reader::hasNormals() const
return (!normals.empty());
}

bool Reader::isOrganized() const
bool Reader::isStructured() const
{
return (width > 1 && height > 1);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Points/App/PointsAlgos.h
Expand Up @@ -59,7 +59,7 @@ class Reader
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;

Expand Down
23 changes: 0 additions & 23 deletions src/Mod/Points/App/PointsFeature.cpp
Expand Up @@ -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)
Expand All @@ -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 {
Expand Down
24 changes: 0 additions & 24 deletions src/Mod/Points/App/PointsFeature.h
Expand Up @@ -77,31 +77,7 @@ class PointsExport Feature : public App::GeoFeature
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
Expand Down
Expand Up @@ -32,13 +32,13 @@
#include <Base/Exception.h>


#include "ViewFeature.h"
#include "Structured.h"

using namespace Points;


//===========================================================================
// ViewFeature
// Structured
//===========================================================================
/*
import Points
Expand All @@ -55,34 +55,46 @@ 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()
{
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");
PROPERTY_SOURCE(Points::Structured, Points::Feature)

Width.setStatus(App::Property::ReadOnly, true);
Height.setStatus(App::Property::ReadOnly, true);
Structured::Structured()
{
// 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())
throw Base::ValueError("(Width * Height) doesn't match with number of points");
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>;
}
Expand Up @@ -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


Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Points/Gui/AppPointsGui.cpp
Expand Up @@ -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(
Expand Down
12 changes: 6 additions & 6 deletions src/Mod/Points/Gui/ViewProvider.cpp
Expand Up @@ -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);
Expand Down Expand Up @@ -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()) {
Expand All @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions src/Mod/Points/Gui/ViewProvider.h
Expand Up @@ -142,17 +142,17 @@ class PointsGuiExport ViewProviderScattered : public ViewProviderPoints
};

/**
* 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
Expand Down
12 changes: 6 additions & 6 deletions src/Mod/ReverseEngineering/Gui/Command.cpp
Expand Up @@ -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>

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit a3209e1

Please sign in to comment.