View Issue Details

IDProjectCategoryView StatusLast Update
0023399CommunityOCCT:Shape Healingpublic2017-07-20 21:04
ReporterFabian Hachenberg Assigned Tobugmaster  
PrioritynormalSeveritymajor 
Status closedResolutionno change required 
Product Version6.5.3 
Summary0023399: ShapeCustom_Surface fails to detect a simple spherical surface
DescriptionHas 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;
}
TagsNo tags attached.
Test case numberNot needed

Activities

gka

2012-08-24 16:03

developer   ~0021332

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/

Issue History

Date Modified Username Field Change
2012-08-24 11:37 Fabian Hachenberg New Issue
2012-08-24 11:37 Fabian Hachenberg Assigned To => gka
2012-08-24 16:03 gka Note Added: 0021332
2017-07-20 20:10 mkv Assigned To gka => bugmaster
2017-07-20 20:10 mkv Status new => feedback
2017-07-20 20:10 mkv Test case number => Not needed
2017-07-20 21:04 bugmaster Status feedback => closed
2017-07-20 21:04 bugmaster Resolution open => no change required