mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +03:00
0028346: Function ProjectOnSegments of ShapeAnalysis_Curve returns only single solution leading to projection result far from optimal
Subdivision of curve parametric interval based on deflection criteria is added for curve type OtherCurve in Extrema_GExtPC.gxx. Algorithm of subdivision is implemented in Extrema_Curve(2d)Tool.cxx New Draw command projpcurve for projection of point on CurveOnSurface is added in SWDRAW_ShapeAnalysis.cxx projpcurve is modified to reflect "start parameter" in usage message and Draw help.
This commit is contained in:
74
src/Extrema/Extrema_Curve2dTool.cxx
Normal file
74
src/Extrema/Extrema_Curve2dTool.cxx
Normal file
@@ -0,0 +1,74 @@
|
||||
// Created on: 1995-07-18
|
||||
// Created by: Modelistation
|
||||
// Copyright (c) 1995-1999 Matra Datavision
|
||||
// Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <Extrema_Curve2dTool.hxx>
|
||||
#include <Adaptor2d_Curve2d.hxx>
|
||||
#include <TColStd_HArray1OfReal.hxx>
|
||||
#include <Precision.hxx>
|
||||
#include <GCPnts_TangentialDeflection.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : DeflCurvIntervals
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(TColStd_HArray1OfReal)
|
||||
Extrema_Curve2dTool::DeflCurvIntervals(const Adaptor2d_Curve2d& C)
|
||||
{
|
||||
const Standard_Real epsd = 1.e-3;
|
||||
const Standard_Real maxdefl = 1.e3;
|
||||
const Standard_Real mindefl = 1.e-3;
|
||||
Handle(TColStd_HArray1OfReal) Intervals;
|
||||
Standard_Integer nbpnts = 23, i;
|
||||
Standard_Real L = 0.;
|
||||
Standard_Real tf = C.FirstParameter(), tl = C.LastParameter();
|
||||
gp_Pnt2d aP = C.Value(tf);
|
||||
for (i = 2; i <= nbpnts; ++i)
|
||||
{
|
||||
Standard_Real t = (tf * (nbpnts - i) + (i - 1) * tl) / (nbpnts - 1);
|
||||
gp_Pnt2d aP1 = C.Value(t);
|
||||
L += aP.Distance(aP1);
|
||||
}
|
||||
//
|
||||
Standard_Real dLdt = L / (tl - tf);
|
||||
if (L <= Precision::Confusion() || dLdt < epsd || (tl - tf) > 10000.)
|
||||
{
|
||||
nbpnts = 2;
|
||||
Intervals = new TColStd_HArray1OfReal(1, nbpnts);
|
||||
Intervals->SetValue(1, tf);
|
||||
Intervals->SetValue(nbpnts, tl);
|
||||
return Intervals;
|
||||
}
|
||||
//
|
||||
Standard_Real aDefl = Max(0.01 * L / (2. * M_PI), mindefl);
|
||||
if (aDefl > maxdefl)
|
||||
{
|
||||
nbpnts = 2;
|
||||
Intervals = new TColStd_HArray1OfReal(1, nbpnts);
|
||||
Intervals->SetValue(1, tf);
|
||||
Intervals->SetValue(nbpnts, tl);
|
||||
return Intervals;
|
||||
}
|
||||
Standard_Real aMinLen = Max(.00001*L, Precision::Confusion());
|
||||
Standard_Real aTol = Max(0.00001*(tl - tf), Precision::PConfusion());
|
||||
GCPnts_TangentialDeflection aPntGen(C, M_PI / 6, aDefl, 2, aTol, aMinLen);
|
||||
nbpnts = aPntGen.NbPoints();
|
||||
Intervals = new TColStd_HArray1OfReal(1, nbpnts);
|
||||
for (i = 1; i <= nbpnts; ++i)
|
||||
{
|
||||
Intervals->SetValue(i, aPntGen.Parameter(i));
|
||||
}
|
||||
return Intervals;
|
||||
}
|
@@ -25,6 +25,7 @@
|
||||
#include <GeomAbs_Shape.hxx>
|
||||
#include <Standard_Integer.hxx>
|
||||
#include <TColStd_Array1OfReal.hxx>
|
||||
#include <TColStd_HArray1OfReal.hxx>
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <gp_Pnt2d.hxx>
|
||||
#include <gp_Vec2d.hxx>
|
||||
@@ -63,7 +64,12 @@ public:
|
||||
//! Stores in <T> the parameters bounding the intervals
|
||||
//! of continuity <S>.
|
||||
static void Intervals (const Adaptor2d_Curve2d& C, TColStd_Array1OfReal& T, const GeomAbs_Shape S);
|
||||
|
||||
|
||||
//! Returns the parameters bounding the intervals of subdivision of curve
|
||||
//! according to Curvature deflection. Value of deflection is defined in method.
|
||||
//!
|
||||
Standard_EXPORT static Handle(TColStd_HArray1OfReal) DeflCurvIntervals(const Adaptor2d_Curve2d& C);
|
||||
|
||||
static Standard_Boolean IsClosed (const Adaptor2d_Curve2d& C);
|
||||
|
||||
static Standard_Boolean IsPeriodic (const Adaptor2d_Curve2d& C);
|
||||
|
@@ -21,6 +21,7 @@
|
||||
#include <Geom_BSplineCurve.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <gp_Vec.hxx>
|
||||
#include <GCPnts_TangentialDeflection.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : IsPeriodic
|
||||
@@ -36,4 +37,57 @@ Standard_Boolean Extrema_CurveTool::IsPeriodic(const Adaptor3d_Curve& C)
|
||||
return C.IsPeriodic();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : DeflCurvIntervals
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(TColStd_HArray1OfReal)
|
||||
Extrema_CurveTool::DeflCurvIntervals(const Adaptor3d_Curve& C)
|
||||
{
|
||||
const Standard_Real epsd = 1.e-3;
|
||||
const Standard_Real maxdefl = 1.e3;
|
||||
const Standard_Real mindefl = 1.e-3;
|
||||
Handle(TColStd_HArray1OfReal) Intervals;
|
||||
Standard_Integer nbpnts = 23, i;
|
||||
Standard_Real L = 0.;
|
||||
Standard_Real tf = C.FirstParameter(), tl = C.LastParameter();
|
||||
gp_Pnt aP = C.Value(tf);
|
||||
for (i = 2; i <= nbpnts; ++i)
|
||||
{
|
||||
Standard_Real t = (tf * (nbpnts - i) + (i - 1) * tl) / (nbpnts - 1);
|
||||
gp_Pnt aP1 = C.Value(t);
|
||||
L += aP.Distance(aP1);
|
||||
}
|
||||
//
|
||||
Standard_Real dLdt = L / (tl - tf);
|
||||
if (L <= Precision::Confusion() || dLdt < epsd || (tl - tf) > 10000.) // To avoid problemwith GCPnts
|
||||
{
|
||||
nbpnts = 2;
|
||||
Intervals = new TColStd_HArray1OfReal(1, nbpnts);
|
||||
Intervals->SetValue(1, tf);
|
||||
Intervals->SetValue(nbpnts, tl);
|
||||
return Intervals;
|
||||
}
|
||||
//
|
||||
Standard_Real aDefl = Max(0.01 * L / (2. * M_PI), mindefl);
|
||||
if (aDefl > maxdefl)
|
||||
{
|
||||
nbpnts = 2;
|
||||
Intervals = new TColStd_HArray1OfReal(1, nbpnts);
|
||||
Intervals->SetValue(1, tf);
|
||||
Intervals->SetValue(nbpnts, tl);
|
||||
return Intervals;
|
||||
}
|
||||
//
|
||||
Standard_Real aMinLen = Max(.00001*L, Precision::Confusion());
|
||||
Standard_Real aTol = Max(0.00001*(tl - tf), Precision::PConfusion());
|
||||
//
|
||||
GCPnts_TangentialDeflection aPntGen(C, M_PI / 6, aDefl, 2, aTol, aMinLen);
|
||||
nbpnts = aPntGen.NbPoints();
|
||||
Intervals = new TColStd_HArray1OfReal(1, nbpnts);
|
||||
for (i = 1; i <= nbpnts; ++i)
|
||||
{
|
||||
Intervals->SetValue(i, aPntGen.Parameter(i));
|
||||
}
|
||||
return Intervals;
|
||||
}
|
||||
|
@@ -25,6 +25,7 @@
|
||||
#include <GeomAbs_Shape.hxx>
|
||||
#include <Standard_Integer.hxx>
|
||||
#include <TColStd_Array1OfReal.hxx>
|
||||
#include <TColStd_HArray1OfReal.hxx>
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <GeomAbs_CurveType.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
@@ -65,8 +66,13 @@ public:
|
||||
//! The array must provide enough room to accomodate
|
||||
//! for the parameters. i.e. T.Length() > NbIntervals()
|
||||
static void Intervals (Adaptor3d_Curve& C, TColStd_Array1OfReal& T, const GeomAbs_Shape S);
|
||||
|
||||
Standard_EXPORT static Standard_Boolean IsPeriodic (const Adaptor3d_Curve& C);
|
||||
|
||||
//! Returns the parameters bounding the intervals of subdivision of curve
|
||||
//! according to Curvature deflection. Value of deflection is defined in method.
|
||||
//!
|
||||
Standard_EXPORT static Handle(TColStd_HArray1OfReal) DeflCurvIntervals(const Adaptor3d_Curve& C);
|
||||
|
||||
Standard_EXPORT static Standard_Boolean IsPeriodic (const Adaptor3d_Curve& C);
|
||||
|
||||
static Standard_Real Period (const Adaptor3d_Curve& C);
|
||||
|
||||
|
@@ -28,6 +28,7 @@
|
||||
#include <Precision.hxx>
|
||||
#include <ElCLib.hxx>
|
||||
#include <TColStd_Array1OfReal.hxx>
|
||||
#include <TColStd_HArray1OfReal.hxx>
|
||||
#include <NCollection_Array1.hxx>
|
||||
|
||||
|
||||
@@ -260,13 +261,32 @@ void Extrema_GExtPC::Perform(const ThePoint& P)
|
||||
}
|
||||
default:
|
||||
{
|
||||
const Standard_Integer aMaxSample = 17;
|
||||
Standard_Boolean IntExtIsDone = Standard_False;
|
||||
Standard_Boolean IntIsNotValid;
|
||||
Handle(TColStd_HArray1OfReal) theHInter;
|
||||
n = TheCurveTool::NbIntervals(aCurve, GeomAbs_C2);
|
||||
TColStd_Array1OfReal theInter(1, n+1);
|
||||
if (n > 1)
|
||||
{
|
||||
theHInter = new TColStd_HArray1OfReal(1, n + 1);
|
||||
TheCurveTool::Intervals(aCurve, theHInter->ChangeArray1(), GeomAbs_C2);
|
||||
}
|
||||
else
|
||||
{
|
||||
theHInter = TheCurveTool::DeflCurvIntervals(aCurve);
|
||||
n = theHInter->Length() - 1;
|
||||
}
|
||||
mysample = Max(mysample / n, aMaxSample);
|
||||
Standard_Real maxint = 0.;
|
||||
for (i = 1; i <= n; ++i)
|
||||
{
|
||||
Standard_Real dt = theHInter->Value(i + 1) - theHInter->Value(i);
|
||||
if (maxint < dt)
|
||||
{
|
||||
maxint = dt;
|
||||
}
|
||||
}
|
||||
Standard_Boolean isPeriodic = TheCurveTool::IsPeriodic(aCurve);
|
||||
TheCurveTool::Intervals(aCurve, theInter, GeomAbs_C2);
|
||||
mysample = Max(mysample/n, 17);
|
||||
TheVector V1;
|
||||
ThePoint PP;
|
||||
Standard_Real s1 = 0.0 ;
|
||||
@@ -274,8 +294,9 @@ void Extrema_GExtPC::Perform(const ThePoint& P)
|
||||
myExtPC.Initialize(aCurve);
|
||||
for (i = 1; i <= n; i++)
|
||||
{
|
||||
myintuinf = theInter(i);
|
||||
myintusup = theInter(i+1);
|
||||
myintuinf = theHInter->Value(i);
|
||||
myintusup = theHInter->Value(i+1);
|
||||
mysample = Max(RealToInt(aMaxSample*(myintusup - myintuinf) / maxint), 3);
|
||||
|
||||
Standard_Real anInfToCheck = myintuinf;
|
||||
Standard_Real aSupToCheck = myintusup;
|
||||
|
@@ -9,6 +9,7 @@ Extrema_CCLocFOfLocECC.hxx
|
||||
Extrema_CCLocFOfLocECC2d.hxx
|
||||
Extrema_CCLocFOfLocECC2d_0.cxx
|
||||
Extrema_CCLocFOfLocECC_0.cxx
|
||||
Extrema_Curve2dTool.cxx
|
||||
Extrema_Curve2dTool.hxx
|
||||
Extrema_Curve2dTool.lxx
|
||||
Extrema_CurveLocator.gxx
|
||||
|
Reference in New Issue
Block a user