View Issue Details

IDProjectCategoryView StatusLast Update
0032863CommunityOCCT:Modeling Algorithmspublic2022-04-07 08:09
Reportermayer Assigned Toazv 
PrioritynormalSeveritymajor 
Status verifiedResolutionfixed 
PlatformLinuxOSDebian 6.0 
Product Version7.3.0 
Target Version7.7.0 
Summary0032863: Cone surface returns wrong v derivative
DescriptionWhen using Geom_ConicalSurface::DN to compute the tangents then for "V" the result is always incorrect.
When using Geom_ConicalSurface::D1 instead then it's correct.

The error is caused by the implementation of ElSLib::ConeDN

The error was tested with OCC 7.3.0 but it's still present in current master.
Steps To ReproduceHere is the C++ test code. It was built under Ubuntu with: g++ main.cpp -I/usr/include/opencascade -lTKG3d -lTKernel -lTKGeomBase

#include <Geom_ConicalSurface.hxx>
#include <GC_MakeConicalSurface.hxx>
#include <GeomLProp_SLProps.hxx>
#include <gp_Pnt.hxx>
#include <Precision.hxx>
#include <iostream>

gp_Vec DN(Handle(Geom_ConicalSurface) s, double u, double v, int Nu, int Nv)
{
    // Copied from ElSLib::ConeDN() and applied the needed fix
    auto ElSLib__ConeDN = [](const Standard_Real U,
                             const Standard_Real V,
                             const gp_Ax3& Pos,
                             const Standard_Real Radius,
                             const Standard_Real SAngle,
                             const Standard_Integer Nu,
                             const Standard_Integer Nv)
    {
       gp_XYZ Xdir = Pos.XDirection().XYZ();
       gp_XYZ Ydir = Pos.YDirection().XYZ();
       gp_XYZ Zdir = Pos.Direction ().XYZ();
       Standard_Real Um = U + Nu * M_PI_2; // M_PI * 0.5
       Xdir.Multiply(cos(Um));
       Ydir.Multiply(sin(Um));
       Xdir.Add(Ydir);
       if(Nv == 0) {
         Xdir.Multiply(Radius + V * sin(SAngle));
         if(Nu == 0) Xdir.Add(Pos.Location().XYZ());
         return gp_Vec(Xdir);
       }
       else if(Nv == 1) {
         Xdir.Multiply(sin(SAngle));
         Zdir.Multiply(cos(SAngle));
         Xdir.Add(Zdir);
         return gp_Vec(Xdir);
       }
       return gp_Vec(0.0,0.0,0.0);
    };

    Standard_RangeError_Raise_if (Nu + Nv < 1 || Nu < 0 || Nv < 0, " ");
    if (Nv > 1) {
        return gp_Vec (0.0, 0.0, 0.0);
    }
    else {
      return ElSLib__ConeDN(u, v, s->Position(), s->RefRadius(), s->SemiAngle(), Nu, Nv);
    }
}

int main()
{
    double u = 5.23290599890759;
    double v = 5.06498283391571;
    GC_MakeConicalSurface gc(gp_Pnt(0,0,0), gp_Pnt(0,0,10), 2, 4);
    Handle(Geom_ConicalSurface) cone = gc.Value();
    gp_Vec du = cone->DN(u, v, 1, 0);
    gp_Vec dv = cone->DN(u, v, 0, 1);
    du.Normalize();
    dv.Normalize();

    std::cout << "\nResult of DN\n";
    std::cout << "(" << du.X() << ", " << du.Y() << ", " << du.Z() << ")\n";
    std::cout << "(" << dv.X() << ", " << dv.Y() << ", " << dv.Z() << ")\n";

    gp_Pnt pnt;
    cone->D1(u, v, pnt, du, dv);
    du.Normalize();
    dv.Normalize();

    std::cout << "\nResult of D1\n";
    std::cout << "(" << du.X() << ", " << du.Y() << ", " << du.Z() << ")\n";
    std::cout << "(" << dv.X() << ", " << dv.Y() << ", " << dv.Z() << ")\n";

    GeomLProp_SLProps prop(cone, u, v, 2, Precision::Confusion());
    if (prop.IsTangentVDefined()) {
        gp_Dir du, dv;
        prop.TangentU(du);
        prop.TangentV(dv);
        std::cout << "\nResult of GeomLProp_SLProps\n";
        std::cout << "(" << du.X() << ", " << du.Y() << ", " << du.Z() << ")\n";
        std::cout << "(" << dv.X() << ", " << dv.Y() << ", " << dv.Z() << ")\n";
    }

    du = DN(cone, u, v, 1, 0);
    dv = DN(cone, u, v, 0, 1);
    du.Normalize();
    dv.Normalize();

    std::cout << "\nResult of fixed ElSLib::ConeDN\n";
    std::cout << "(" << du.X() << ", " << du.Y() << ", " << du.Z() << ")\n";
    std::cout << "(" << dv.X() << ", " << dv.Y() << ", " << dv.Z() << ")\n";
}
Additional information
and documentation updates
The error was reported in the FreeCAD forum: https://forum.freecadweb.org/viewtopic.php?f=10&t=66677
TagsNo tags attached.
Test case numberbugs/modalg_7/bug32863

Activities

git

2022-03-24 22:21

administrator   ~0107427

Branch CR32863 has been created by azv.

SHA-1: 54b67d8e7bd80263f28ff009ff6eadc4cbd10bcf


Detailed log of new commits:

Author: azv
Date: Thu Mar 24 22:21:06 2022 +0300

    0032863: Cone surface returns wrong v derivative
    
    * Fix error on computing V first derivative on a cone (take into account the slope of the conical generatrix).
    * Add DRAW command 'sderivative' to compute certain derivative on a surface.

azv

2022-03-25 07:11

administrator   ~0107428

Dear Mikhail,

Could you review the solution?

The following branches to be integrated:
OCCT: CR32863
Products: NOT
Test results: http://jenkins-test-occt/view/CR32863-master-AZV/view/COMPARE/

smoskvin

2022-03-27 10:46

administrator   ~0107440

Combination -
OCCT branch : IR-2022-03-25
master SHA - e4753a7d1658331a79025964d1c55f2a6d999c6c
49e51745631c52b6c452c65adae4d6dfa21a1b1e
Products branch : IR-2022-03-25 SHA - 303106116fcb5c01a598ea01cc5174a45aae8f18
was compiled on Linux, MacOS and Windows platforms and tested in optimize mode.

Number of compiler warnings:
No new/fixed warnings

Regressions/Differences/Improvements:
No regressions/differences

CPU differences:
Debian80-64:
OCCT
Total CPU difference: 18507.51000000038 / 18488.570000000385 [+0.10%]
Products
Total CPU difference: 11703.320000000122 / 11709.530000000132 [-0.05%]
Windows-64-VC14:
OCCT
Total CPU difference: 20451.96875 / 20413.53125 [+0.19%]
Products
Total CPU difference: 13191.96875 / 13181.65625 [+0.08%]


Image differences :
No differences that require special attention

Memory differences :
No differences that require special attention

git

2022-04-02 19:34

administrator   ~0107562

Branch CR32863 has been deleted by mnt.

SHA-1: 54b67d8e7bd80263f28ff009ff6eadc4cbd10bcf

Related Changesets

occt: master e4753a7d

2022-03-24 22:21:06

azv


Committer: smoskvin Details Diff
0032863: Cone surface returns wrong v derivative

* Fix error on computing V first derivative on a cone (take into account the slope of the conical generatrix).
* Add DRAW command 'sderivative' to compute certain derivative on a surface.
Affected Issues
0032863
mod - src/ElSLib/ElSLib.cxx Diff File
mod - src/GeomliteTest/GeomliteTest_SurfaceCommands.cxx Diff File
add - tests/bugs/modalg_7/bug32863 Diff File

Issue History

Date Modified Username Field Change
2022-03-02 18:16 mayer New Issue
2022-03-02 18:16 mayer Assigned To => msv
2022-03-24 15:27 azv Assigned To msv => azv
2022-03-24 15:27 azv Status new => assigned
2022-03-24 22:21 git Note Added: 0107427
2022-03-25 07:11 azv Assigned To azv => msv
2022-03-25 07:11 azv Status assigned => resolved
2022-03-25 07:11 azv Note Added: 0107428
2022-03-25 18:32 msv Assigned To msv => bugmaster
2022-03-25 18:32 msv Status resolved => reviewed
2022-03-27 10:46 smoskvin Status reviewed => tested
2022-03-27 10:46 smoskvin Note Added: 0107440
2022-03-27 10:49 smoskvin Test case number => bugs/modalg_7/bug32863
2022-03-27 12:32 smoskvin Changeset attached => occt master e4753a7d
2022-03-27 12:32 azv Assigned To bugmaster => azv
2022-03-27 12:32 azv Status tested => verified
2022-03-27 12:32 azv Resolution open => fixed
2022-04-02 19:34 git Note Added: 0107562
2022-04-07 08:09 kgv Target Version => 7.7.0