12 #include "profileImportDlg.h"
18 #include <QMainWindow>
19 #include <QMessageBox>
44 m_doCompareCloudToProfile(0),
45 m_doProjectCloudDists(0) {}
52 tr(
"Loads the 2D profile of a Surface of Revolution (from a "
53 "dedicated ASCII file)"));
55 ":/CC/plugin/qSRA/images/loadProfileIcon.png")));
62 new QAction(tr(
"Cloud-SurfRev radial distance"),
this);
64 "Computes the radial distances between a cloud and a Surface "
65 "of Revolution (polyline/profile, cone or cylinder)"));
67 ":/CC/plugin/qSRA/images/distToProfileIcon.png")));
76 tr(
"Creates the 2D deviation map (radial distances) from a "
77 "Surface or Revolution (unroll)"));
79 ":/CC/plugin/qSRA/images/createMapIcon.png")));
85 return QList<QAction*>{
97 bool validSelection =
false;
98 if (selectedEntities.size() == 2) {
103 if (cloudIndex != -1) {
105 validSelection = (selectedEntities[1 - cloudIndex]->isA(
107 selectedEntities[1 - cloudIndex]->isKindOf(
134 for (
size_t j = 0; j < groups.size(); ++j) {
141 app->
addToDB(defaultContainer);
143 return defaultContainer;
154 settings.beginGroup(
"qSRA");
161 if (!piDlg.exec())
return;
167 settings.setValue(
"importPath", QFileInfo(
filename).absolutePath());
171 assert(axisDim >= 0 && axisDim <= 2);
187 heightShift = -origin.
u[axisDim];
194 T.
u[axisDim] += heightShift;
196 float* mat = trans.
data();
228 if (defaultContainer) {
229 defaultContainer->
addChild(polyline);
235 tr(
"[qSRA] File '%1' successfully loaded").arg(
filename),
255 for (
int i = 1; i < 3; ++i)
256 if (
fabs(axis.
u[i]) >
fabs(axis.
u[revolDim])) revolDim = i;
311 if (selectedEntities.size() != 2) {
319 bool tempPolyline =
false;
321 for (
unsigned i = 0; i < 2; ++i) {
323 cloud =
static_cast<ccPointCloud*
>(selectedEntities[i]);
325 polyline =
static_cast<ccPolyline*
>(selectedEntities[i]);
326 }
else if (!polyline &&
330 ccCone* cone =
static_cast<ccCone*
>(selectedEntities[i]);
349 tempPolyline =
false;
356 if (cloud && polyline) {
359 if (QMessageBox::question(
362 tr(
"Do you want to generate a 2D deviation map?"),
364 QMessageBox::No) == QMessageBox::Yes) {
371 tr(
"Select exactly one cloud and one Surface of Revolution "
372 "(polyline/profile, cone or cylinder)"),
376 if (polyline && tempPolyline) {
384 if (!cloud || !polyline) {
402 tr(
"An error occurred while computing radial distances!"),
415 size_t selectCount = selectedEntities.size();
416 if (selectCount != 1 && selectCount != 2) {
424 bool tempPolyline =
false;
426 for (
size_t i = 0; i < selectCount; ++i) {
428 cloud =
static_cast<ccPointCloud*
>(selectedEntities[i]);
430 polyline =
static_cast<ccPolyline*
>(selectedEntities[i]);
431 }
else if (!polyline &&
435 ccCone* cone =
static_cast<ccCone*
>(selectedEntities[i]);
446 if (cloud && polyline) {
450 if (polyline && tempPolyline) {
458 assert(cloud &&
m_app);
468 if (QMessageBox::question(
470 tr(
"Distance field"),
471 tr(
"Cloud has no '%1' field. Do you want to use "
472 "the active scalar field instead?")
475 QMessageBox::No) == QMessageBox::No) {
480 CVLog::Error(tr(
"Cloud has no no '%1' field and no active "
487 tr(
"You can compute the radial distances with the "
constexpr PointCoordinateType PC_ONE
'1' as a PointCoordinateType value
Vector3Tpl< PointCoordinateType > CCVector3
Default 3D Vector.
float PointCoordinateType
Type of the coordinates of a (N-D) point.
static bool Warning(const char *format,...)
Prints out a formatted warning message in console.
static bool Error(const char *format,...)
Display an error dialog with formatted message.
Dialog for generating a distance map (surface of revolution)
Dialog for importing a 2D revolution profile (qSRA plugin)
QString getFilename() const
Returns input filename (on completion)
int getAxisDimension() const
bool absoluteHeightValues() const
void setDefaultFilename(QString filename)
Sets default filename.
static ccPolyline * Load(QString filename, CCVector3 &origin, ecvMainAppInterface *app=0)
Loads a 2D profile from a file.
PointCoordinateType getTopRadius() const
Returns top radius.
PointCoordinateType getHeight() const
Returns height.
PointCoordinateType getBottomRadius() const
Returns bottom radius.
virtual void setVisible(bool state)
Sets entity visibility.
virtual void setRedraw(bool state)
Sets entity redraw mode.
virtual void showColors(bool state)
Sets colors visibility.
virtual void setGLTransformation(const ccGLMatrix &trans)
Associates entity with a GL transformation (rotation + translation)
Vector3Tpl< T > getTranslationAsVec3D() const
Returns a copy of the translation as a CCVector3.
static ccGLMatrixTpl< float > FromToRotation(const Vector3Tpl< float > &from, const Vector3Tpl< float > &to)
Creates a transformation matrix that rotates a vector to another.
T * data()
Returns a pointer to internal data.
void setTranslation(const Vector3Tpl< float > &Tr)
Sets translation (float version)
Vector3Tpl< T > getColumnAsVec3D(unsigned index) const
Returns a copy of a given column as a CCVector3.
Float version of ccGLMatrixTpl.
virtual ccGLMatrix & getTransformation()
Returns the transformation that is currently applied to the vertices.
Hierarchical CLOUDVIEWER Object.
virtual bool addChild(ccHObject *child, int dependencyFlags=DP_PARENT_OF_OTHER, int insertIndex=-1)
Adds a child.
unsigned filterChildren(Container &filteredChildren, bool recursive=false, CV_CLASS_ENUM filter=CV_TYPES::OBJECT, bool strict=false) const
Collects the children corresponding to a certain pattern.
std::vector< ccHObject * > Container
Standard instances container (for children, etc.)
A 3D cloud and its associated features (color, normals, scalar fields, etc.)
bool reserve(unsigned numberOfPoints) override
Reserves memory for all the active features.
ccScalarField * getCurrentDisplayedScalarField() const
Returns the currently displayed scalar (or 0 if none)
void set2DMode(bool state)
Defines if the polyline is considered as 2D or 3D.
void setColor(const ecvColor::Rgb &col)
Sets the polyline color.
void setWidth(PointCoordinateType width)
Sets the width of the line.
A scalar field associated to display-related parameters.
Standard ECV plugin interface.
ecvMainAppInterface * m_app
Main application interface.
int getScalarFieldIndexByName(const char *name) const
Returns the index of a scalar field represented by its name.
ScalarField * getScalarField(int index) const
Returns a pointer to a specific scalar field.
void addPoint(const CCVector3 &P)
Adds a 3D point to the database.
void setClosed(bool state)
Sets whether the polyline is closed or not.
virtual bool addPointIndex(unsigned globalIndex)
Point global index insertion mechanism.
virtual bool reserve(unsigned n)
Reserves some memory for hosting the point references.
Main application interface (for plugins)
virtual void updateUI()=0
virtual ccHObject * dbRootObject()=0
Returns DB root (as a ccHObject)
virtual QMainWindow * getMainWindow()=0
Returns main window.
virtual void refreshAll(bool only2D=false, bool forceRedraw=true)=0
Redraws all GL windows that have the 'refresh' flag on.
virtual const ccHObject::Container & getSelectedEntities() const =0
Returns currently selected entities ("read only")
virtual void addToDB(ccHObject *obj, bool updateZoom=false, bool autoExpandDBTree=true, bool checkDimensions=false, bool autoRedraw=true)=0
virtual void dispToConsole(QString message, ConsoleMessageLevel level=STD_CONSOLE_MESSAGE)=0
virtual void onNewSelection(const ccHObject::Container &selectedEntities) override
bool doComputeRadialDists(ccPointCloud *cloud, ccPolyline *polyline) const
Computes cloud-to-profile radial distances.
QAction * m_doCompareCloudToProfile
Associated action.
QAction * m_doLoadProfile
Associated action.
void loadProfile() const
Loads profile from a dedicated file.
qSRA(QObject *parent=nullptr)
Default constructor.
QAction * m_doProjectCloudDists
Associated action.
void doProjectCloudDistsInGrid(ccPointCloud *cloud, ccPolyline *polyline) const
virtual QList< QAction * > getActions() override
Get a list of actions for this plugin.
void projectCloudDistsInGrid() const
Projects the cloud distances into a 2D grid.
void computeCloud2ProfileRadialDist() const
Computes cloud-to-profile radial distances.
__host__ __device__ float2 fabs(float2 v)
static const std::string path
bool LessThanEpsilon(float x)
Test a floating point number against our epsilon (a very small number).
constexpr Rgb green(0, MAX, 0)
QString defaultDocPath()
Shortcut for getting the documents location path.
const QString QSRA_DEFAULT_CONTAINER_NAME("Profile(s)")
ccHObject * GetDefaultContainer(ecvMainAppInterface *app)
static ccPolyline * GetConeProfile(ccCone *cone)