32 const std::vector<CCVector3>& rays,
38 size_t errorCount = 0;
43 QString objName(
"unknown");
56 if (cloud ==
nullptr) {
76 "Couldn't allocate a new scalar field for computing "
77 "PCV field! Try to free some memory...",
83 QString objNameForPorgressDialog = objName;
84 if (candidates.size() > 1) {
85 objNameForPorgressDialog +=
86 QStringLiteral(
"(%1/%2)").arg(++
count).arg(
90 bool wasEnabled = obj->isEnabled();
91 bool wasVisible = obj->isVisible();
92 obj->setEnabled(
true);
93 obj->setVisible(
true);
95 PCV::Launch(rays, cloud, mesh, meshIsClosed, resolution,
96 resolution, progressDlg, objNameForPorgressDialog);
97 obj->setEnabled(wasEnabled);
98 obj->setVisible(wasVisible);
104 "entity '%1' illumination!")
116 if (obj->hasNormals() && obj->normalsShown()) {
119 QObject::tr(
"Entity '%1' normals have been "
120 "automatically disabled")
124 obj->showNormals(
false);
129 obj->prepareDisplayForRefresh_recursive();
135 if (progressDlg && progressDlg->wasCanceled()) {
138 QObject::tr(
"Process has been cancelled by the user"),
145 return (errorCount == 0);
152 return cmd.
error(qPCV::tr(
"No entity is loaded."));
156 unsigned rayCount = 256;
157 bool meshIsClosed =
false;
159 unsigned resolution = 1024;
162 const QString& arg = cmd.
arguments().front();
176 bool conversionOk =
false;
177 rayCount = cmd.
arguments().takeFirst().toUInt(&conversionOk);
180 QObject::tr(
"Invalid parameter: value after \"-%1\"")
186 bool conversionOk =
false;
187 resolution = cmd.
arguments().takeFirst().toUInt(&conversionOk);
190 QObject::tr(
"Invalid parameter: value after \"-%1\"")
199 std::vector<CCVector3> rays;
201 return cmd.
error(QObject::tr(
"Failed to generate the set of rays"));
205 pcvProgressCb.setAutoClose(
false);
209 candidates.reserve(cmd.
clouds().size() + cmd.
meshes().size());
210 }
catch (
const std::bad_alloc) {
211 return cmd.
error(QObject::tr(
"Not enough memory"));
217 if (!
Process(candidates, rays, meshIsClosed, resolution, &pcvProgressCb,
219 return cmd.
error(QObject::tr(
"Process failed"));
223 desc.basename += QString(
"_PCV");
228 if (!errorStr.isEmpty()) {
229 return cmd.
error(errorStr);
235 desc.basename += QString(
"_PCV");
240 if (!errorStr.isEmpty()) {
241 return cmd.
error(errorStr);
constexpr char COMMAND_PCV_180[]
constexpr char COMMAND_PCV_IS_CLOSED[]
constexpr char COMMAND_PCV_N_RAYS[]
constexpr char COMMAND_PCV[]
constexpr char CC_PCV_FIELD_LABEL_NAME[]
constexpr char COMMAND_PCV_RESOLUTION[]
bool process(ccCommandLineInterface &cmd) override
Main process.
static bool Process(const ccHObject::Container &candidates, const std::vector< CCVector3 > &rays, bool meshIsClosed, unsigned resolution, ecvProgressDialog *progressDlg=nullptr, ecvMainAppInterface *app=nullptr)
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)
bool autoSaveMode() const
virtual QStringList & arguments()=0
Returns the list of arguments.
virtual void print(const QString &message) const =0
virtual bool error(const QString &message) const =0
static bool IsCommand(const QString &token, const char *command)
Test whether a command line token is a valid command keyword or not.
virtual QString exportEntity(CLEntityDesc &entityDesc, const QString &suffix=QString(), QString *outputFilename=nullptr, ccCommandLineInterface::ExportOptions options=ExportOption::NoOptions)=0
Exports a cloud or a mesh.
virtual std::vector< CLMeshDesc > & meshes()
Currently opened meshes and their filename.
virtual std::vector< CLCloudDesc > & clouds()
Currently opened point clouds and their filename.
virtual void showSF(bool state)
Sets active scalarfield visibility.
virtual ccGenericPointCloud * getAssociatedCloud() const =0
Returns the vertices cloud.
static ccPointCloud * ToPointCloud(ccHObject *obj, bool *isLockedVertices=nullptr)
Converts current object to 'equivalent' ccPointCloud.
static ccGenericMesh * ToGenericMesh(ccHObject *obj)
Converts current object to ccGenericMesh (if possible)
Hierarchical CLOUDVIEWER Object.
std::vector< ccHObject * > Container
Standard instances container (for children, etc.)
virtual QString getName() const
Returns object name.
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.
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.
Main application interface (for plugins)
virtual void dispToConsole(QString message, ConsoleMessageLevel level=STD_CONSOLE_MESSAGE)=0
Graphical progress indicator (thread-safe)
Loaded cloud description.