1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

0024682: Move out B-spline cache from curves and surfaces to dedicated classes BSplCLib_Cache and BSplSLib_Cache

1. B-spline cache was moved into separated classes: BSplCLib_Cache for 2D and 3D curves and BSplSLib_Cache for surfaces.

2. The cache is used now in corresponding adaptor classes (Geom2dAdaptor_Curve, GeomAdaptor_Curve and GeomAdaptor_Surface) when the curve or surface is a B-spline.

3. Algorithms were changed to use adaptors for B-spline calculations instead of curves or surfaces.

4. Precised calculation of derivatives of surface of revolution is implemented for the points of surface placed on the axis of revolution (Geom_SurfaceOfRevolution.cxx)

5. Small modifications are made to adjust algorithms to new behavior of B-spline calculation.

6. Test cases were modified according to the modern behavior.

7. Changes in BOPAlgo_WireSplitter, BOPTools_AlgoTools, BRepLib_CheckCurveOnSurface and ShapeAnalysis_Wire to use adaptors instead of geometric entities

8. Allow Geom2dAdaptor and GeomAdaptor in case of offset curve to use corresponding adaptor for basis curve

Modification of test-cases according to the new behavior.
This commit is contained in:
azv
2015-05-28 13:36:57 +03:00
committed by bugmaster
parent 9176540c64
commit 94f71cad33
137 changed files with 4104 additions and 2503 deletions

View File

@@ -165,7 +165,13 @@ gp_Dir& Normal
// if (D1UMag <= MagTol || D1VMag <= MagTol && NMag > MagTol) MagTol = 2* NMag;
}
else
{ Normal = gp_Dir (D1UvD1V); Status = Defined; }
{
// Firstly normalize tangent vectors D1U and D1V (this method is more stable)
gp_Dir aD1U(D1U);
gp_Dir aD1V(D1V);
Normal = gp_Dir(aD1U.Crossed(aD1V));
Status = Defined;
}
}

470
src/CSLib/CSLib_Offset.cxx Normal file
View File

@@ -0,0 +1,470 @@
// Copyright (c) 2015-... 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 <CSLib_Offset.hxx>
#include <gp_Dir2d.hxx>
#include <gp_XY.hxx>
#include <Geom_UndefinedValue.hxx>
#include <Geom_UndefinedDerivative.hxx>
#include <Geom2d_UndefinedValue.hxx>
#include <Geom2d_UndefinedDerivative.hxx>
#include <Standard_NullValue.hxx>
// ========== Offset values for 2D curves ==========
void CSLib_Offset::D0(const gp_Pnt2d& theBasePoint,
const gp_Vec2d& theBaseDeriv,
Standard_Real theOffset,
Standard_Boolean , // unused
gp_Pnt2d& theResPoint)
{
if (theBaseDeriv.SquareMagnitude() <= gp::Resolution())
Standard_NullValue::Raise("CSLib_Offset: Undefined normal vector "
"because tangent vector has zero-magnitude!");
gp_Dir2d aNormal(theBaseDeriv.Y(), -theBaseDeriv.X());
theResPoint.SetCoord(theBasePoint.X() + aNormal.X() * theOffset,
theBasePoint.Y() + aNormal.Y() * theOffset);
}
void CSLib_Offset::D1(const gp_Pnt2d& theBasePoint,
const gp_Vec2d& theBaseD1,
const gp_Vec2d& theBaseD2,
Standard_Real theOffset,
Standard_Boolean , // unused
gp_Pnt2d& theResPoint,
gp_Vec2d& theResDeriv)
{
// P(u) = p(u) + Offset * Ndir / R
// with R = || p' ^ Z|| and Ndir = P' ^ Z
// P'(u) = p'(u) + (Offset / R**2) * (DNdir/DU * R - Ndir * (DR/R))
gp_XY Ndir(theBaseD1.Y(), -theBaseD1.X());
gp_XY DNdir(theBaseD2.Y(), -theBaseD2.X());
Standard_Real R2 = Ndir.SquareModulus();
Standard_Real R = Sqrt (R2);
Standard_Real R3 = R * R2;
Standard_Real Dr = Ndir.Dot(DNdir);
if (R3 <= gp::Resolution())
{
if (R2 <= gp::Resolution())
Standard_NullValue::Raise("CSLib_Offset: Null derivative");
//We try another computation but the stability is not very good.
DNdir.Multiply(R);
DNdir.Subtract(Ndir.Multiplied(Dr / R));
DNdir.Multiply(theOffset / R2);
}
else
{
// Same computation as IICURV in EUCLID-IS because the stability is better
DNdir.Multiply(theOffset / R);
DNdir.Subtract(Ndir.Multiplied(theOffset * Dr / R3));
}
// P(u)
D0(theBasePoint, theBaseD1, theOffset, Standard_False, theResPoint);
// P'(u)
theResDeriv = theBaseD1.Added(gp_Vec2d(DNdir));
}
void CSLib_Offset::D2(const gp_Pnt2d& theBasePoint,
const gp_Vec2d& theBaseD1,
const gp_Vec2d& theBaseD2,
const gp_Vec2d& theBaseD3,
Standard_Real theOffset,
Standard_Boolean theIsDirectionChange,
gp_Pnt2d& theResPoint,
gp_Vec2d& theResD1,
gp_Vec2d& theResD2)
{
// P(u) = p(u) + Offset * Ndir / R
// with R = || p' ^ Z|| and Ndir = P' ^ Z
// P'(u) = p'(u) + (Offset / R**2) * (DNdir/DU * R - Ndir * (DR/R))
// P"(u) = p"(u) + (Offset / R) * (D2Ndir/DU - DNdir * (2.0 * Dr/ R**2) +
// Ndir * ( (3.0 * Dr**2 / R**4) - (D2r / R**2)))
gp_XY Ndir(theBaseD1.Y(), -theBaseD1.X());
gp_XY DNdir(theBaseD2.Y(), -theBaseD2.X());
gp_XY D2Ndir(theBaseD3.Y(), -theBaseD3.X());
Standard_Real R2 = Ndir.SquareModulus();
Standard_Real R = Sqrt(R2);
Standard_Real R3 = R2 * R;
Standard_Real R4 = R2 * R2;
Standard_Real R5 = R3 * R2;
Standard_Real Dr = Ndir.Dot(DNdir);
Standard_Real D2r = Ndir.Dot(D2Ndir) + DNdir.Dot (DNdir);
if (R5 <= gp::Resolution())
{
if (R4 <= gp::Resolution())
Standard_NullValue::Raise("CSLib_Offset: Null derivative");
//We try another computation but the stability is not very good dixit ISG.
// V2 = P" (U) :
D2Ndir.Subtract(DNdir.Multiplied (2.0 * Dr / R2));
D2Ndir.Add(Ndir.Multiplied (((3.0 * Dr * Dr)/R4) - (D2r/R2)));
D2Ndir.Multiply(theOffset / R);
// V1 = P' (U) :
DNdir.Multiply(R);
DNdir.Subtract(Ndir.Multiplied(Dr / R));
DNdir.Multiply(theOffset / R2);
}
else
{
// Same computation as IICURV in EUCLID-IS because the stability is better.
// V2 = P" (U) :
D2Ndir.Multiply(theOffset / R);
D2Ndir.Subtract(DNdir.Multiplied (2.0 * theOffset * Dr / R3));
D2Ndir.Add (Ndir.Multiplied(theOffset * (((3.0 * Dr * Dr) / R5) - (D2r / R3))));
// V1 = P' (U)
DNdir.Multiply(theOffset / R);
DNdir.Subtract(Ndir.Multiplied(theOffset * Dr / R3));
}
// P(u) :
D0(theBasePoint, theBaseD1, theOffset, theIsDirectionChange, theResPoint);
// P'(u) :
theResD1 = theBaseD1.Added(gp_Vec2d(DNdir));
// P"(u) :
if (theIsDirectionChange)
theResD2 = -theBaseD2;
else
theResD2 = theBaseD2;
theResD2.Add(gp_Vec2d(D2Ndir));
}
void CSLib_Offset::D3(const gp_Pnt2d& theBasePoint,
const gp_Vec2d& theBaseD1,
const gp_Vec2d& theBaseD2,
const gp_Vec2d& theBaseD3,
const gp_Vec2d& theBaseD4,
Standard_Real theOffset,
Standard_Boolean theIsDirectionChange,
gp_Pnt2d& theResPoint,
gp_Vec2d& theResD1,
gp_Vec2d& theResD2,
gp_Vec2d& theResD3)
{
// P(u) = p(u) + Offset * Ndir / R
// with R = || p' ^ Z|| and Ndir = P' ^ Z
// P'(u) = p'(u) + (Offset / R**2) * (DNdir/DU * R - Ndir * (DR/R))
// P"(u) = p"(u) + (Offset / R) * (D2Ndir/DU - DNdir * (2.0 * Dr/ R**2) +
// Ndir * ( (3.0 * Dr**2 / R**4) - (D2r / R**2)))
// P"'(u) = p"'(u) + (Offset / R) * (D3Ndir - (3.0 * Dr/R**2 ) * D2Ndir -
// (3.0 * D2r / R2) * DNdir) + (3.0 * Dr * Dr / R4) * DNdir -
// (D3r/R2) * Ndir + (6.0 * Dr * Dr / R4) * Ndir +
// (6.0 * Dr * D2r / R4) * Ndir - (15.0 * Dr* Dr* Dr /R6) * Ndir
gp_XY Ndir(theBaseD1.Y(), -theBaseD1.X());
gp_XY DNdir(theBaseD2.Y(), -theBaseD2.X());
gp_XY D2Ndir(theBaseD3.Y(), -theBaseD3.X());
gp_XY D3Ndir(theBaseD4.Y(), -theBaseD4.X());
Standard_Real R2 = Ndir.SquareModulus();
Standard_Real R = Sqrt (R2);
Standard_Real R3 = R2 * R;
Standard_Real R4 = R2 * R2;
Standard_Real R5 = R3 * R2;
Standard_Real R6 = R3 * R3;
Standard_Real R7 = R5 * R2;
Standard_Real Dr = Ndir.Dot(DNdir);
Standard_Real D2r = Ndir.Dot(D2Ndir) + DNdir.Dot (DNdir);
Standard_Real D3r = Ndir.Dot(D3Ndir) + 3.0 * DNdir.Dot (D2Ndir);
if (R7 <= gp::Resolution())
{
if (R6 <= gp::Resolution())
Standard_NullValue::Raise("CSLib_Offset: Null derivative");
//We try another computation but the stability is not very good dixit ISG.
// V3 = P"' (U) :
D3Ndir.Subtract (D2Ndir.Multiplied (3.0 * theOffset * Dr / R2));
D3Ndir.Subtract (
(DNdir.Multiplied ((3.0 * theOffset) * ((D2r/R2) + (Dr*Dr)/R4))));
D3Ndir.Add (Ndir.Multiplied (
(theOffset * (6.0*Dr*Dr/R4 + 6.0*Dr*D2r/R4 - 15.0*Dr*Dr*Dr/R6 - D3r))));
D3Ndir.Multiply (theOffset/R);
// V2 = P" (U) :
Standard_Real R4 = R2 * R2;
D2Ndir.Subtract (DNdir.Multiplied (2.0 * Dr / R2));
D2Ndir.Subtract (Ndir.Multiplied (((3.0 * Dr * Dr)/R4) - (D2r/R2)));
D2Ndir.Multiply (theOffset / R);
// V1 = P' (U) :
DNdir.Multiply(R);
DNdir.Subtract (Ndir.Multiplied (Dr/R));
DNdir.Multiply (theOffset/R2);
}
else
{
// Same computation as IICURV in EUCLID-IS because the stability is better.
// V3 = P"' (U) :
D3Ndir.Multiply (theOffset/R);
D3Ndir.Subtract (D2Ndir.Multiplied (3.0 * theOffset * Dr / R3));
D3Ndir.Subtract (DNdir.Multiplied (
((3.0 * theOffset) * ((D2r/R3) + (Dr*Dr)/R5))) );
D3Ndir.Add (Ndir.Multiplied (
(theOffset * (6.0*Dr*Dr/R5 + 6.0*Dr*D2r/R5 - 15.0*Dr*Dr*Dr/R7 - D3r))));
// V2 = P" (U) :
D2Ndir.Multiply (theOffset/R);
D2Ndir.Subtract (DNdir.Multiplied (2.0 * theOffset * Dr / R3));
D2Ndir.Subtract (Ndir.Multiplied (
theOffset * (((3.0 * Dr * Dr) / R5) - (D2r / R3))));
// V1 = P' (U) :
DNdir.Multiply (theOffset/R);
DNdir.Subtract (Ndir.Multiplied (theOffset*Dr/R3));
}
// P(u)
D0(theBasePoint, theBaseD1, theOffset, theIsDirectionChange, theResPoint);
// P'(u)
theResD1 = theBaseD1.Added(gp_Vec2d(DNdir));
// P"(u)
theResD2 = theBaseD2.Added(gp_Vec2d(D2Ndir));
// P"'(u)
if (theIsDirectionChange)
theResD3 = -theBaseD3;
else
theResD3 = theBaseD3;
theResD3.Add(gp_Vec2d(D2Ndir));
}
// ========== Offset values for 3D curves ==========
void CSLib_Offset::D0(const gp_Pnt& theBasePoint,
const gp_Vec& theBaseDeriv,
const gp_Dir& theOffsetDirection,
Standard_Real theOffsetValue,
Standard_Boolean , // unused
gp_Pnt& theResPoint)
{
gp_XYZ Ndir = (theBaseDeriv.XYZ()).Crossed(theOffsetDirection.XYZ());
Standard_Real R = Ndir.Modulus();
if (R <= gp::Resolution())
Standard_NullValue::Raise("CSLib_Offset: Undefined normal vector "
"because tangent vector has zero-magnitude!");
Ndir.Multiply(theOffsetValue / R);
Ndir.Add(theBasePoint.XYZ());
theResPoint.SetXYZ(Ndir);
}
void CSLib_Offset::D1(const gp_Pnt& theBasePoint,
const gp_Vec& theBaseD1,
const gp_Vec& theBaseD2,
const gp_Dir& theOffsetDirection,
Standard_Real theOffsetValue,
Standard_Boolean , // unused
gp_Pnt& theResPoint,
gp_Vec& theResDeriv)
{
// P(u) = p(u) + Offset * Ndir / R
// with R = || p' ^ V|| and Ndir = P' ^ direction (local normal direction)
// P'(u) = p'(u) + (Offset / R**2) * (DNdir/DU * R - Ndir * (DR/R))
gp_XYZ Ndir = (theBaseD1.XYZ()).Crossed(theOffsetDirection.XYZ());
gp_XYZ DNdir = (theBaseD2.XYZ()).Crossed(theOffsetDirection.XYZ());
Standard_Real R2 = Ndir.SquareModulus();
Standard_Real R = Sqrt (R2);
Standard_Real R3 = R * R2;
Standard_Real Dr = Ndir.Dot (DNdir);
if (R3 <= gp::Resolution()) {
if (R2 <= gp::Resolution())
Standard_NullValue::Raise("CSLib_Offset: Null derivative");
//We try another computation but the stability is not very good.
DNdir.Multiply(R);
DNdir.Subtract(Ndir.Multiplied(Dr / R));
DNdir.Multiply(theOffsetValue / R2);
}
else {
// Same computation as IICURV in EUCLID-IS because the stability is
// better
DNdir.Multiply(theOffsetValue / R);
DNdir.Subtract(Ndir.Multiplied(theOffsetValue * Dr / R3));
}
// P(u)
D0(theBasePoint, theBaseD1, theOffsetDirection, theOffsetValue, Standard_False, theResPoint);
// P'(u)
theResDeriv = theBaseD1.Added(gp_Vec(DNdir));
}
void CSLib_Offset::D2(const gp_Pnt& theBasePoint,
const gp_Vec& theBaseD1,
const gp_Vec& theBaseD2,
const gp_Vec& theBaseD3,
const gp_Dir& theOffsetDirection,
Standard_Real theOffsetValue,
Standard_Boolean theIsDirectionChange,
gp_Pnt& theResPoint,
gp_Vec& theResD1,
gp_Vec& theResD2)
{
// P(u) = p(u) + Offset * Ndir / R
// with R = || p' ^ V|| and Ndir = P' ^ direction (local normal direction)
// P'(u) = p'(u) + (Offset / R**2) * (DNdir/DU * R - Ndir * (DR/R))
// P"(u) = p"(u) + (Offset / R) * (D2Ndir/DU - DNdir * (2.0 * Dr/ R**2) +
// Ndir * ( (3.0 * Dr**2 / R**4) - (D2r / R**2)))
gp_XYZ Ndir = (theBaseD1.XYZ()).Crossed(theOffsetDirection.XYZ());
gp_XYZ DNdir = (theBaseD2.XYZ()).Crossed(theOffsetDirection.XYZ());
gp_XYZ D2Ndir = (theBaseD3.XYZ()).Crossed(theOffsetDirection.XYZ());
Standard_Real R2 = Ndir.SquareModulus();
Standard_Real R = Sqrt (R2);
Standard_Real R3 = R2 * R;
Standard_Real R4 = R2 * R2;
Standard_Real R5 = R3 * R2;
Standard_Real Dr = Ndir.Dot (DNdir);
Standard_Real D2r = Ndir.Dot (D2Ndir) + DNdir.Dot (DNdir);
if (R5 <= gp::Resolution()) {
if (R4 <= gp::Resolution())
Standard_NullValue::Raise("CSLib_Offset: Null derivative");
//We try another computation but the stability is not very good
//dixit ISG.
// V2 = P" (U) :
Standard_Real R4 = R2 * R2;
D2Ndir.Subtract (DNdir.Multiplied (2.0 * Dr / R2));
D2Ndir.Add (Ndir.Multiplied (((3.0 * Dr * Dr)/R4) - (D2r/R2)));
D2Ndir.Multiply (theOffsetValue / R);
// V1 = P' (U) :
DNdir.Multiply(R);
DNdir.Subtract (Ndir.Multiplied (Dr/R));
DNdir.Multiply (theOffsetValue/R2);
}
else {
// Same computation as IICURV in EUCLID-IS because the stability is
// better.
// V2 = P" (U) :
D2Ndir.Multiply (theOffsetValue/R);
D2Ndir.Subtract (DNdir.Multiplied (2.0 * theOffsetValue * Dr / R3));
D2Ndir.Add (Ndir.Multiplied (theOffsetValue * (((3.0 * Dr * Dr) / R5) - (D2r / R3))));
// V1 = P' (U) :
DNdir.Multiply (theOffsetValue/R);
DNdir.Subtract (Ndir.Multiplied (theOffsetValue*Dr/R3));
}
// P(u) :
D0(theBasePoint, theBaseD1, theOffsetDirection, theOffsetValue, theIsDirectionChange, theResPoint);
// P'(u) :
theResD1 = theBaseD1.Added(gp_Vec(DNdir));
// P"(u) :
if (theIsDirectionChange)
theResD2 = -theBaseD2;
else
theResD2 = theBaseD2;
theResD2.Add(gp_Vec(D2Ndir));
}
void CSLib_Offset::D3(const gp_Pnt& theBasePoint,
const gp_Vec& theBaseD1,
const gp_Vec& theBaseD2,
const gp_Vec& theBaseD3,
const gp_Vec& theBaseD4,
const gp_Dir& theOffsetDirection,
Standard_Real theOffsetValue,
Standard_Boolean theIsDirectionChange,
gp_Pnt& theResPoint,
gp_Vec& theResD1,
gp_Vec& theResD2,
gp_Vec& theResD3)
{
// P(u) = p(u) + Offset * Ndir / R
// with R = || p' ^ V|| and Ndir = P' ^ direction (local normal direction)
// P'(u) = p'(u) + (Offset / R**2) * (DNdir/DU * R - Ndir * (DR/R))
// P"(u) = p"(u) + (Offset / R) * (D2Ndir/DU - DNdir * (2.0 * Dr/ R**2) +
// Ndir * ( (3.0 * Dr**2 / R**4) - (D2r / R**2)))
//P"'(u) = p"'(u) + (Offset / R) * (D3Ndir - (3.0 * Dr/R**2) * D2Ndir -
// (3.0 * D2r / R2) * DNdir + (3.0 * Dr * Dr / R4) * DNdir -
// (D3r/R2) * Ndir + (6.0 * Dr * Dr / R4) * Ndir +
// (6.0 * Dr * D2r / R4) * Ndir - (15.0 * Dr* Dr* Dr /R6) * Ndir
gp_XYZ Ndir = (theBaseD1.XYZ()).Crossed(theOffsetDirection.XYZ());
gp_XYZ DNdir = (theBaseD2.XYZ()).Crossed(theOffsetDirection.XYZ());
gp_XYZ D2Ndir = (theBaseD3.XYZ()).Crossed(theOffsetDirection.XYZ());
gp_XYZ D3Ndir = (theBaseD4.XYZ()).Crossed(theOffsetDirection.XYZ());
Standard_Real R2 = Ndir.SquareModulus();
Standard_Real R = Sqrt (R2);
Standard_Real R3 = R2 * R;
Standard_Real R4 = R2 * R2;
Standard_Real R5 = R3 * R2;
Standard_Real R6 = R3 * R3;
Standard_Real R7 = R5 * R2;
Standard_Real Dr = Ndir.Dot (DNdir);
Standard_Real D2r = Ndir.Dot (D2Ndir) + DNdir.Dot (DNdir);
Standard_Real D3r = Ndir.Dot (D3Ndir) + 3.0 * DNdir.Dot (D2Ndir);
if (R7 <= gp::Resolution()) {
if (R6 <= gp::Resolution())
Standard_NullValue::Raise("CSLib_Offset: Null derivative");
// V3 = P"' (U) :
D3Ndir.Subtract (D2Ndir.Multiplied (3.0 * Dr / R2));
D3Ndir.Subtract (DNdir.Multiplied (3.0 * ((D2r/R2) + (Dr*Dr/R4))));
D3Ndir.Add (Ndir.Multiplied (6.0*Dr*Dr/R4 + 6.0*Dr*D2r/R4 - 15.0*Dr*Dr*Dr/R6 - D3r));
D3Ndir.Multiply (theOffsetValue/R);
// V2 = P" (U) :
Standard_Real R4 = R2 * R2;
D2Ndir.Subtract (DNdir.Multiplied (2.0 * Dr / R2));
D2Ndir.Subtract (Ndir.Multiplied ((3.0 * Dr * Dr / R4) - (D2r / R2)));
D2Ndir.Multiply (theOffsetValue / R);
// V1 = P' (U) :
DNdir.Multiply(R);
DNdir.Subtract (Ndir.Multiplied (Dr/R));
DNdir.Multiply (theOffsetValue/R2);
}
else {
// V3 = P"' (U) :
D3Ndir.Divide (R);
D3Ndir.Subtract (D2Ndir.Multiplied (3.0 * Dr / R3));
D3Ndir.Subtract (DNdir.Multiplied ((3.0 * ((D2r/R3) + (Dr*Dr)/R5))));
D3Ndir.Add (Ndir.Multiplied (6.0*Dr*Dr/R5 + 6.0*Dr*D2r/R5 - 15.0*Dr*Dr*Dr/R7 - D3r));
D3Ndir.Multiply (theOffsetValue);
// V2 = P" (U) :
D2Ndir.Divide (R);
D2Ndir.Subtract (DNdir.Multiplied (2.0 * Dr / R3));
D2Ndir.Subtract (Ndir.Multiplied ((3.0 * Dr * Dr / R5) - (D2r / R3)));
D2Ndir.Multiply (theOffsetValue);
// V1 = P' (U) :
DNdir.Multiply (theOffsetValue/R);
DNdir.Subtract (Ndir.Multiplied (theOffsetValue*Dr/R3));
}
// P(u)
D0(theBasePoint, theBaseD1, theOffsetDirection, theOffsetValue, theIsDirectionChange, theResPoint);
// P'(u)
theResD1 = theBaseD1.Added(gp_Vec(DNdir));
// P"(u)
theResD2 = theBaseD2.Added(gp_Vec(D2Ndir));
// P"'(u)
if (theIsDirectionChange)
theResD3 = -theBaseD3;
else
theResD3 = theBaseD3;
theResD3.Add(gp_Vec(D2Ndir));
}

190
src/CSLib/CSLib_Offset.hxx Normal file
View File

@@ -0,0 +1,190 @@
// Copyright (c) 2015-... 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.
#ifndef _CSLib_Offset_Headerfile
#define _CSLib_Offset_Headerfile
#include <gp_Dir.hxx>
#include <gp_Pnt.hxx>
#include <gp_Pnt2d.hxx>
#include <gp_Vec.hxx>
#include <gp_Vec2d.hxx>
#include <Standard.hxx>
/** \namespace CSLib_Offset
* \brief Provides a number of static methods to calculate values and derivatives
* of an offset curves and surfaces using values and derivatives of
* a base curve/surface.
*/
namespace CSLib_Offset
{
/** \brief Calculate value of offset curve in 2D
* \param[in] theBasePoint point on a base curve
* \param[in] theBaseDeriv derivative on a base curve
* \param[in] theOffset size of offset
* \param[in] theIsDirectionChange shows that it is necessary to consider the direction of derivative (not used)
* \param[out] theResPoint point on offset curve
*/
Standard_EXPORT void D0(const gp_Pnt2d& theBasePoint,
const gp_Vec2d& theBaseDeriv,
Standard_Real theOffset,
Standard_Boolean theIsDirectionChange,
gp_Pnt2d& theResPoint);
/** \brief Calculate value of offset curve in 3D
* \param[in] theBasePoint point on a base curve
* \param[in] theBaseDeriv derivative on a base curve
* \param[in] theOffsetDirection direction of the offset
* \param[in] theOffsetValue length of the offset
* \param[in] theIsDirectionChange shows that it is necessary to consider the direction of derivative (not used)
* \param[out] theResPoint point on offset curve
*/
Standard_EXPORT void D0(const gp_Pnt& theBasePoint,
const gp_Vec& theBaseDeriv,
const gp_Dir& theOffsetDirection,
Standard_Real theOffsetValue,
Standard_Boolean theIsDirectionChange,
gp_Pnt& theResPoint);
/** \brief Calculate value and the first derivative of offset curve in 2D
* \param[in] theBasePoint point on a base curve
* \param[in] theBaseD1 first derivative on a base curve
* \param[in] theBaseD2 second derivative on a base curve
* \param[in] theOffset size of offset
* \param[in] theIsDirectionChange shows that it is necessary to consider the direction of derivative (not used)
* \param[out] theResPoint point on offset curve
* \param[out] theResDeriv derivative on offset curve
*/
Standard_EXPORT void D1(const gp_Pnt2d& theBasePoint,
const gp_Vec2d& theBaseD1,
const gp_Vec2d& theBaseD2,
Standard_Real theOffset,
Standard_Boolean theIsDirectionChange,
gp_Pnt2d& theResPoint,
gp_Vec2d& theResDeriv);
/** \brief Calculate value and the first derivative of offset curve in 3D
* \param[in] theBasePoint point on a base curve
* \param[in] theBaseD1 first derivative on a base curve
* \param[in] theBaseD2 second derivative on a base curve
* \param[in] theOffsetDirection direction of the offset
* \param[in] theOffsetValue length of the offset
* \param[in] theIsDirectionChange shows that it is necessary to consider the direction of derivative (not used)
* \param[out] theResPoint point on offset curve
* \param[out] theResDeriv derivative on offset curve
*/
Standard_EXPORT void D1(const gp_Pnt& theBasePoint,
const gp_Vec& theBaseD1,
const gp_Vec& theBaseD2,
const gp_Dir& theOffsetDirection,
Standard_Real theOffsetValue,
Standard_Boolean theIsDirectionChange,
gp_Pnt& theResPoint,
gp_Vec& theResDeriv);
/** \brief Calculate value and two derivatives of offset curve in 2D
* \param[in] theBasePoint point on a base curve
* \param[in] theBaseD1 first derivative on a base curve
* \param[in] theBaseD2 second derivative on a base curve
* \param[in] theBaseD3 third derivative on a base curve
* \param[in] theOffset size of offset
* \param[in] theIsDirectionChange shows that it is necessary to consider the direction of derivative
* \param[out] theResPoint point on offset curve
* \param[out] theResD1 first derivative on offset curve
* \param[out] theResD2 second derivative on offset curve
*/
Standard_EXPORT void D2(const gp_Pnt2d& theBasePoint,
const gp_Vec2d& theBaseD1,
const gp_Vec2d& theBaseD2,
const gp_Vec2d& theBaseD3,
Standard_Real theOffset,
Standard_Boolean theIsDirectionChange,
gp_Pnt2d& theResPoint,
gp_Vec2d& theResD1,
gp_Vec2d& theResD2);
/** \brief Calculate value and two derivatives of offset curve in 3D
* \param[in] theBasePoint point on a base curve
* \param[in] theBaseD1 first derivative on a base curve
* \param[in] theBaseD2 second derivative on a base curve
* \param[in] theBaseD3 third derivative on a base curve
* \param[in] theOffsetDirection direction of the offset
* \param[in] theOffsetValue length of the offset
* \param[in] theIsDirectionChange shows that it is necessary to consider the direction of derivative
* \param[out] theResPoint point on offset curve
* \param[out] theResD1 first derivative on offset curve
* \param[out] theResD2 second derivative on offset curve
*/
Standard_EXPORT void D2(const gp_Pnt& theBasePoint,
const gp_Vec& theBaseD1,
const gp_Vec& theBaseD2,
const gp_Vec& theBaseD3,
const gp_Dir& theOffsetDirection,
Standard_Real theOffsetValue,
Standard_Boolean theIsDirectionChange,
gp_Pnt& theResPoint,
gp_Vec& theResD1,
gp_Vec& theResD2);
/** \brief Calculate value and three derivatives of offset curve in 2D
* \param[in] theBasePoint point on a base curve
* \param[in] theBaseD1 first derivative on a base curve
* \param[in] theBaseD2 second derivative on a base curve
* \param[in] theBaseD3 third derivative on a base curve
* \param[in] theBaseD4 fourth derivative on a base curve
* \param[in] theOffset size of offset
* \param[in] theIsDirectionChange shows that it is necessary to consider the direction of derivative
* \param[out] theResPoint point on offset curve
* \param[out] theResD1 first derivative on offset curve
* \param[out] theResD2 second derivative on offset curve
* \param[out] theResD3 third derivative on offset curve
*/
Standard_EXPORT void D3(const gp_Pnt2d& theBasePoint,
const gp_Vec2d& theBaseD1,
const gp_Vec2d& theBaseD2,
const gp_Vec2d& theBaseD3,
const gp_Vec2d& theBaseD4,
Standard_Real theOffset,
Standard_Boolean theIsDirectionChange,
gp_Pnt2d& theResPoint,
gp_Vec2d& theResD1,
gp_Vec2d& theResD2,
gp_Vec2d& theResD3);
/** \brief Calculate value and three derivatives of offset curve in 3D
* \param[in] theBasePoint point on a base curve
* \param[in] theBaseD1 first derivative on a base curve
* \param[in] theBaseD2 second derivative on a base curve
* \param[in] theBaseD3 third derivative on a base curve
* \param[in] theBaseD4 fourth derivative on a base curve
* \param[in] theOffsetDirection direction of the offset
* \param[in] theOffsetValue length of the offset
* \param[in] theIsDirectionChange shows that it is necessary to consider the direction of derivative
* \param[out] theResPoint point on offset curve
* \param[out] theResD1 first derivative on offset curve
* \param[out] theResD2 second derivative on offset curve
* \param[out] theResD3 third derivative on offset curve
*/
Standard_EXPORT void D3(const gp_Pnt& theBasePoint,
const gp_Vec& theBaseD1,
const gp_Vec& theBaseD2,
const gp_Vec& theBaseD3,
const gp_Vec& theBaseD4,
const gp_Dir& theOffsetDirection,
Standard_Real theOffsetValue,
Standard_Boolean theIsDirectionChange,
gp_Pnt& theResPoint,
gp_Vec& theResD1,
gp_Vec& theResD2,
gp_Vec& theResD3);
}
#endif // _CSLib_Offset_Headerfile

2
src/CSLib/FILES Normal file
View File

@@ -0,0 +1,2 @@
CSLib_Offset.hxx
CSLib_Offset.cxx