27 #include <QMainWindow>
28 #include <QProgressBar>
44 bool elligibleEntitiies =
false;
48 elligibleEntitiies =
true;
52 m_action->setEnabled(elligibleEntitiies);
76 bool hasMeshes =
false;
85 candidates.push_back(obj);
91 candidates.push_back(obj);
107 dlg.closedMeshCheckBox->setEnabled(hasMeshes);
110 std::vector<ccGenericPointCloud*> cloudsWithNormals;
115 for (
size_t i = 0; i < clouds.size(); ++i) {
120 cloudsWithNormals.push_back(cloud);
121 QString cloudTitle = QString(
"%1 - %2 points")
126 cloudTitle.append(QString(
" (%1)").arg(
130 dlg.cloudsComboBox->addItem(cloudTitle);
134 if (cloudsWithNormals.empty()) {
135 dlg.useCloudRadioButton->setEnabled(
false);
151 unsigned raysNumber = dlg.raysSpinBox->value();
152 unsigned resolution = dlg.resSpinBox->value();
154 (hasMeshes ? dlg.closedMeshCheckBox->isChecked() :
false);
155 bool mode360 = !dlg.mode180CheckBox->isChecked();
158 std::vector<CCVector3> rays;
159 if (!cloudsWithNormals.empty() && dlg.useCloudRadioButton->isChecked()) {
161 assert(dlg.cloudsComboBox->currentIndex() <
162 static_cast<int>(cloudsWithNormals.size()));
164 cloudsWithNormals[dlg.cloudsComboBox->currentIndex()];
168 }
catch (std::bad_alloc) {
170 "Not enough memory to generate the set of rays",
174 for (
unsigned i = 0; i <
count; ++i) {
194 pcvProgressCb.setAutoClose(
false);
200 QString objName =
"unknown";
222 "Couldn't allocate a new scalar field for computing PCV "
223 "field ! Try to free some memory ...",
229 QString objNameForPorgressDialog = objName;
230 if (candidates.size() > 1) {
231 objNameForPorgressDialog +=
232 QString(
"(%1/%2)").arg(++
count).arg(candidates.size());
235 bool wasEnabled = obj->isEnabled();
236 bool wasVisible = obj->isVisible();
237 obj->setEnabled(
true);
238 obj->setVisible(
true);
239 bool success =
PCV::Launch(rays, cloud, mesh, meshIsClosed, resolution,
240 resolution, &pcvProgressCb,
241 objNameForPorgressDialog);
242 obj->setEnabled(wasEnabled);
243 obj->setVisible(wasVisible);
248 tr(
"An error occurred during entity '%1' illumination!")
259 if (obj->hasNormals() && obj->normalsShown()) {
261 tr(
"Entity '%1' normals have been automatically "
266 obj->showNormals(
false);
276 if (pcvProgressCb.wasCanceled()) {
283 pcvProgressCb.close();
Vector3Tpl< PointCoordinateType > CCVector3
Default 3D Vector.
constexpr char CC_PCV_FIELD_LABEL_NAME[]
static bool GenerateRays(unsigned numberOfRays, std::vector< CCVector3 > &rays, bool mode360=true)
Generates a given number of rays.
static int Launch(unsigned numberOfRays, cloudViewer::GenericCloud *vertices, cloudViewer::GenericMesh *mesh=nullptr, bool meshIsClosed=false, bool mode360=true, unsigned width=1024, unsigned height=1024, cloudViewer::GenericProgressCallback *progressCb=nullptr, QString entityName=QString())
static ccColorScale::Shared GetDefaultScale(DEFAULT_SCALES scale=BGYR)
Returns a pre-defined color scale (static shortcut)
virtual bool registerCommand(Command::Shared command)=0
Registers a new command.
virtual QString getName() const override
Returns (short) name (for menu entry, etc.)
virtual QString getDescription() const override
Returns long name/description (for tooltip, etc.)
virtual QIcon getIcon() const override
Returns icon.
virtual bool hasNormals() const
Returns whether normals are enabled or not.
virtual void showSF(bool state)
Sets active scalarfield visibility.
virtual ccGenericPointCloud * getAssociatedCloud() const =0
Returns the vertices cloud.
A 3D cloud interface with associated features (color, normals, octree, etc.)
virtual const CCVector3 & getPointNormal(unsigned pointIndex) const =0
Returns normal corresponding to a given point.
static ccPointCloud * ToPointCloud(ccHObject *obj, bool *isLockedVertices=nullptr)
Converts current object to 'equivalent' ccPointCloud.
static ccGenericPointCloud * ToGenericPointCloud(ccHObject *obj, bool *isLockedVertices=nullptr)
Converts current object to 'equivalent' ccGenericPointCloud.
static ccGenericMesh * ToGenericMesh(ccHObject *obj)
Converts current object to ccGenericMesh (if possible)
Hierarchical CLOUDVIEWER Object.
ccHObject * getParent() const
Returns parent object.
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.)
virtual QString getName() const
Returns object name.
bool isA(CV_CLASS_ENUM type) const
bool isKindOf(CV_CLASS_ENUM type) const
Dialog for the PCV plugin.
A 3D cloud and its associated features (color, normals, scalar fields, etc.)
void setCurrentDisplayedScalarField(int index)
Sets the currently displayed scalar field.
int addScalarField(const char *uniqueName) override
Creates a new scalar field and registers it.
void deleteScalarField(int index) override
Deletes a specific scalar field.
A scalar field associated to display-related parameters.
void setColorScale(ccColorScale::Shared scale)
Sets associated color scale.
void computeMinAndMax() override
Determines the min and max values.
Standard ECV plugin interface.
ecvMainAppInterface * m_app
Main application interface.
virtual unsigned size() const =0
Returns the number of points.
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 setCurrentScalarField(int index)
Sets both the INPUT & OUTPUT scalar field.
virtual void updateUI()=0
virtual ccHObject * dbRootObject()=0
Returns DB root (as a ccHObject)
virtual QMainWindow * getMainWindow()=0
Returns main window.
virtual void refreshSelected(bool only2D=false, bool forceRedraw=true)=0
virtual const ccHObject::Container & getSelectedEntities() const =0
Returns currently selected entities ("read only")
virtual void dispToConsole(QString message, ConsoleMessageLevel level=STD_CONSOLE_MESSAGE)=0
Graphical progress indicator (thread-safe)
virtual QList< QAction * > getActions() override
Get a list of actions for this plugin.
void doAction()
Slot called when associated ation is triggered.
QAction * m_action
Associated action.
qPCV(QObject *parent=nullptr)
Default constructor.
virtual void onNewSelection(const ccHObject::Container &selectedEntities) override
virtual void registerCommands(ccCommandLineInterface *cmd) override
Optional: registers commands (for the command line mode)
static bool s_closedMeshCheckBoxState
static bool s_firstLaunch
static bool s_mode180CheckBoxState
static int s_resSpinBoxValue
static int s_raysSpinBoxValue
QSharedPointer< Command > Shared
Shared type.