DiscussionsIssue archiveOCCT:Shape Healing

Archived issue #0023399

ShapeCustom_Surface fails to detect a simple spherical surface

CommunityOCCT:Shape Healingclosed1 public note

Search issues

Description

Has anybody ever tried to create an analytical surface from a BSpline surface using ShapeCustom_Surface? I have found a straighforward bug in the code. The attached code creates a face on a spherical surface, creates the bspline approximation of the sphere and then uses ShapeCustom_Surface to detect the original sphere again. It fails.

I did the following modification in the code, which seems to fix the problem:
Line 208 : gp_Ax3 aAx3 (p3(3),aDir,xVec); //p3(1) -> p3(3)

I don't know whether this makes the algorithm now fail in other cases, I have tried none...

Steps to reproduce

#include <iostream>
#include <iomanip>
#include <exception>
#include <limits.h>

#include <BRepPrimAPI_MakeSphere.hxx>
#include <ShapeCustom_Surface.hxx>
#include <GeomConvert_ApproxSurface.hxx>
#include <ShapeAnalysis.hxx>

#include <Geom2d_Line.hxx>

#include <gp_Pnt2d.hxx>
#include <gp_Dir2d.hxx>

#include <assert.h>

int main( int argc, const char* argv[] )
{

    //We create a sphere
    double radius = 1.0;
    BRepPrimAPI_MakeSphere primsphere(gp_Pnt(0,0,0), radius);
    TopoDS_Face sphereface = primsphere.Face();
    Handle(Geom_Surface) sphere = BRep_Tool::Surface(sphereface);

    //We create a NURBS approximation of the sphere
    double tol3d = 0.001;
    int maxsegm = 100;
    int preciscode = 0;
    GeomConvert_ApproxSurface approxsurf(sphere, tol3d, GeomAbs_C0, GeomAbs_C0, 3, 3, maxsegm, preciscode);
    assert(approxsurf.IsDone());
    Handle(Geom_BSplineSurface) nurbs_sphere = approxsurf.Surface();

    //We try to detect the original sphere again
    double tolerance = 0.1;
    ShapeCustom_Surface surfconv(nurbs_sphere);
    Handle(Geom_Surface) found_analytical_surf = surfconv.ConvertToAnalytical(tolerance, false);
    assert(!found_analytical_surf.IsNull());

    return 0;
}

Public activity

1 archived note

Participants are labeled by their role within this record.

01Commenter 1
This fix is not quite valid. Because it is not correct for case of cylinder.
Unfortunately method ShapeCustom::ConvertToAnalytical is obsolete and is not supported now. Instead it "Canonical Recognition" functionality can be used.
Please find description by link
http://www.opencascade.org/support/products/canrec/