Page 1 of 1

Using the GeometricalAnalysisTools

Posted: Mon Feb 10, 2020 2:45 pm
by alvarofergar
Hi everyone,

I'm having trouble using the GeometricalAnalysisTools inside my own class.

In the code below, mCloud is a succesfully read ccPointCloud, but when the program enters the ComputeCharactersitic function it never leaves it.

Code: Select all

void CCGeometricAnalizer::compute()
{
   //create SF
    int idx = mCloud.addScalarField("Curvature");
    mCloud.setCurrentInScalarField(idx); //set in scalar field - curvature is written here
    mCloud.setCurrentScalarField(idx);

    double radius=10;

    GeometricalAnalysisTools::ErrorCode error = GeometricalAnalysisTools::ComputeCharactersitic(CCLib::GeometricalAnalysisTools::Curvature,
                                                                                                                                                            CCLib::Neighbourhood::CurvatureType::MEAN_CURV,
                                                                                                                                                            &mCloud,
                                                                                                                                                             static_cast<PointCoordinateType>(radius));
}
If I calculate the octree outside of the function, using the DgmOctree class, and then passing it as a parameter to the function I get an CCLib::GeometricalAnalysisTools::ProcessFailed (-4). However, I think this may be an even worse behavior.

Code: Select all

    DgmOctree* octreee=new DgmOctree(&mCloud);
Has anyone done anything similar or does know where is the problem?

Thanks in advance!

Re: Using the GeometricalAnalysisTools

Posted: Mon Feb 10, 2020 8:00 pm
by daniel
What about the 'radius' value? Is it expressed in the right units? (because if it's huge, the computation time might be very long).

And be sure not to be in debug mode (especially if the cloud is big ;). It might take ages to run as well.

One option to see how fat things go it to passe a 'generic progress' notifier to the function (optional parameter).

And last, for your octree, you have to create it and BUILD it before passing it to the function.

Re: Using the GeometricalAnalysisTools

Posted: Tue Feb 11, 2020 12:19 pm
by alvarofergar
Yes, I was running in Debug and it looks like I wasn't being patient enough :)

Now it works but, even in Release, I think its slower than it should be. Calculating the same feature in the CloudCompare program is faster and the 'Octree level', 'Cells' and 'Max population' values are much lower. With my program, the 'Max population' is equal to the size of the cloud.
Is there a way to fix this?

If it helps somebody, here it is my chunk of code

Code: Select all


    int idx = mCloud.addScalarField("Curvature");
    mCloud.setCurrentInScalarField(idx); //set in scalar field - curvature is written here
    mCloud.setCurrentScalarField(idx);

    ccProgressDialog pDlg(false);
    pDlg.setWindowModality(Qt::WindowModal);
    double radius=4;

    ccOctree::Shared octree = mCloud.getOctree();
    if (!octree)
           octree = mCloud.computeOctree(&pDlg);
   
   CCLib::DgmOctree dgm_oct=*octree.data();

    GeometricalAnalysisTools::ErrorCode error = GeometricalAnalysisTools::ComputeCharactersitic (
                                                                                   CCLib: :GeometricalAnalysisTools::GeomCharacteristic::Feature,
                                                                                   CCLib::Neighbourhood::Omnivariance,
                                                                                   &mCloud,
                                                                                   static_cast<PointCoordinateType>(radius),
                                                                                   &pDlg,&dgm_oct);


Thanks for the help!

Re: Using the GeometricalAnalysisTools

Posted: Wed Feb 12, 2020 8:38 am
by alvarofergar
Sorry, I missed the build line I copied my code into the previous post.

Code: Select all

dgm_oct.build(&pDlg);
I do it right before the geometric analysis but it doesn't seem to have any effect.

Re: Using the GeometricalAnalysisTools

Posted: Wed Feb 12, 2020 11:06 pm
by daniel
Which the 'max population per cell' equals the size of the cloud, then the subdivision level is probably too small.

And the only reason why it would happen, is that the radius is actually way too big. Are you sure about its value / units?

Re: Using the GeometricalAnalysisTools

Posted: Thu Feb 13, 2020 11:33 am
by alvarofergar
It wasn't a radius problem. I was using a value very close to the default value in the program's dialog. The problem with the octree levels was due to a bug in my reading of the cloud.

Sorry about that!