Using the GeometricalAnalysisTools

Any question about the database & algorithms library 'CCLib'
Post Reply
alvarofergar
Posts: 10
Joined: Wed Mar 13, 2019 12:07 pm

Using the GeometricalAnalysisTools

Post 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!
daniel
Site Admin
Posts: 7701
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: Using the GeometricalAnalysisTools

Post 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.
Daniel, CloudCompare admin
alvarofergar
Posts: 10
Joined: Wed Mar 13, 2019 12:07 pm

Re: Using the GeometricalAnalysisTools

Post 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!
alvarofergar
Posts: 10
Joined: Wed Mar 13, 2019 12:07 pm

Re: Using the GeometricalAnalysisTools

Post 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.
daniel
Site Admin
Posts: 7701
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: Using the GeometricalAnalysisTools

Post 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?
Daniel, CloudCompare admin
alvarofergar
Posts: 10
Joined: Wed Mar 13, 2019 12:07 pm

Re: Using the GeometricalAnalysisTools

Post 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!
Post Reply